Blame view

backend/controllers/ExportController.php 1.13 KB
80a6eda8   alex   примерный макет е...
1
2
3
4
5
  <?php
  namespace backend\controllers;
  
  
  
80a6eda8   alex   примерный макет е...
6
7
8
  use yii\web\Controller;
  use common\models\Customer;
  use yii\filters\VerbFilter;
80a6eda8   alex   примерный макет е...
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
  use common\models\dummy\DateModel;
  use Yii;
  
  class ExportController extends Controller{
  
  
  
  
  	public function behaviors()
  	{
  		return [
  			'verbs'  => [
  				'class'   => VerbFilter::className(),
  				'actions' => [
  					'view' => [ 'POST' ],
  				],
  			],
  		];
  	}
  
  
  
  
  
  		public function actionIndex(){
  
  //			$model=new DynamicModel(['timeFrom','timeTo']);
  //			$model->addRule(['timeFrom','timeTo'],'string');
  
  			$model=new DateModel();
  			return $this->render('index',[
  				'model'             => $model
  			]);
  		}
  
  
  
  	public function actionView(){
  
  		$model=new DateModel();
  		$model->load(Yii::$app->request->post());
  		#die(var_dump($model->attributes));
  		$date1=(new \DateTime($model->timeFrom))->getTimestamp();
  		$date2=(new \DateTime($model->timeTo))->getTimestamp();
84767bd5   Alexey Boroda   -Export small fixes
53
54
55
56
57
58
59
60
61
  //		die(var_dump($date1,$date2));
  
  		$data = Customer::find()
  			->where([
  			    'between',
                  'created_at',
                  $date1,
                  $date2
                      ])
80a6eda8   alex   примерный макет е...
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
  			->all();
  		die(var_dump($_POST));
  	}
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  }