HistoryController.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace app\controllers;
  3. use yii\data\ArrayDataProvider;
  4. class HistoryController extends \yii\web\Controller
  5. {
  6. private static $schet_path = '';
  7. private static $act_path = '';
  8. public function init()
  9. {
  10. self::$schet_path = \Yii::getAlias('@webroot') . '/invoices/' . \Yii::$app->user->identity->uuid . '/schet';
  11. self::$act_path = \Yii::getAlias('@webroot') . '/invoices/' . \Yii::$app->user->identity->uuid . '/act';
  12. parent::init(); // TODO: Change the autogenerated stub
  13. }
  14. public function actionIndex()
  15. {
  16. $scheta = new ArrayDataProvider([
  17. 'allModels' => \yii\helpers\FileHelper::findFiles(self::$schet_path)
  18. ]);
  19. $actu = new ArrayDataProvider([
  20. 'allModels' => \yii\helpers\FileHelper::findFiles(self::$act_path)
  21. ]);
  22. /* $files = array();
  23. if (file_exists($schet_path)) {
  24. $fileNames = array_diff(scandir($schet_path), array('..', '.'));
  25. foreach ($fileNames as $fileName) {
  26. //echo Html::img($webPath . '/' . $fileName);
  27. $files[] = $fileName;
  28. }
  29. }*/
  30. return $this->render('index', [
  31. 'scheta' => $scheta,
  32. 'actu' => $actu
  33. ]);
  34. }
  35. public function actionDownload($type, $file)
  36. {
  37. $schet_path = \Yii::getAlias('@webroot') . '/invoices/' . \Yii::$app->user->identity->uuid . '/'.$type.'/';
  38. return \Yii::$app->response->sendFile($schet_path. $file);
  39. }
  40. }