| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
- namespace app\controllers;
- use yii\data\ArrayDataProvider;
- class HistoryController extends \yii\web\Controller
- {
- private static $schet_path = '';
- private static $act_path = '';
- public function init()
- {
- self::$schet_path = \Yii::getAlias('@webroot') . '/invoices/' . \Yii::$app->user->identity->uuid . '/schet';
- self::$act_path = \Yii::getAlias('@webroot') . '/invoices/' . \Yii::$app->user->identity->uuid . '/act';
- parent::init(); // TODO: Change the autogenerated stub
- }
- public function actionIndex()
- {
- $scheta = new ArrayDataProvider([
- 'allModels' => \yii\helpers\FileHelper::findFiles(self::$schet_path)
- ]);
- $actu = new ArrayDataProvider([
- 'allModels' => \yii\helpers\FileHelper::findFiles(self::$act_path)
- ]);
- /* $files = array();
- if (file_exists($schet_path)) {
- $fileNames = array_diff(scandir($schet_path), array('..', '.'));
- foreach ($fileNames as $fileName) {
- //echo Html::img($webPath . '/' . $fileName);
- $files[] = $fileName;
- }
- }*/
- return $this->render('index', [
- 'scheta' => $scheta,
- 'actu' => $actu
- ]);
- }
- public function actionDownload($type, $file)
- {
- $schet_path = \Yii::getAlias('@webroot') . '/invoices/' . \Yii::$app->user->identity->uuid . '/'.$type.'/';
- return \Yii::$app->response->sendFile($schet_path. $file);
- }
- }
|