Commit 80a6eda844c812aae53ed4b9ad7f7c38e03394a8
1 parent
10899280
примерный макет експорта
Showing
4 changed files
with
171 additions
and
1 deletions
Show diff stats
backend/assets/AppAsset.php
... | ... | @@ -15,8 +15,13 @@ |
15 | 15 | // 'css/add-new.css', |
16 | 16 | // 'css/site.css', |
17 | 17 | // 'css/table-new.css', |
18 | + | |
19 | + ]; | |
20 | + public $js = [ | |
21 | + # '/js/admin-script.js' | |
22 | + 'js/script.js', | |
23 | + 'js/jquery-ui.min.js', | |
18 | 24 | ]; |
19 | -// public $js = ['/js/admin-script.js']; | |
20 | 25 | public $depends = [ |
21 | 26 | 'yii\web\YiiAsset', |
22 | 27 | 'yii\bootstrap\BootstrapAsset', | ... | ... |
1 | +<?php | |
2 | +namespace backend\controllers; | |
3 | + | |
4 | + | |
5 | + | |
6 | +use yii\base\Model; | |
7 | +use yii\web\Controller; | |
8 | +use common\models\Customer; | |
9 | +use yii\filters\VerbFilter; | |
10 | +use backend\actions\Index; | |
11 | +use yii\base\DynamicModel; | |
12 | +use common\models\dummy\DateModel; | |
13 | +use Yii; | |
14 | + | |
15 | +class ExportController extends Controller{ | |
16 | + | |
17 | + | |
18 | + | |
19 | + | |
20 | + public function behaviors() | |
21 | + { | |
22 | + return [ | |
23 | + 'verbs' => [ | |
24 | + 'class' => VerbFilter::className(), | |
25 | + 'actions' => [ | |
26 | + 'view' => [ 'POST' ], | |
27 | + ], | |
28 | + ], | |
29 | + ]; | |
30 | + } | |
31 | + | |
32 | + | |
33 | + | |
34 | + | |
35 | + | |
36 | + public function actionIndex(){ | |
37 | + | |
38 | +// $model=new DynamicModel(['timeFrom','timeTo']); | |
39 | +// $model->addRule(['timeFrom','timeTo'],'string'); | |
40 | + | |
41 | + $model=new DateModel(); | |
42 | + return $this->render('index',[ | |
43 | + 'model' => $model | |
44 | + ]); | |
45 | + } | |
46 | + | |
47 | + | |
48 | + | |
49 | + public function actionView(){ | |
50 | + | |
51 | + $model=new DateModel(); | |
52 | + $model->load(Yii::$app->request->post()); | |
53 | + #die(var_dump($model->attributes)); | |
54 | + $date1=(new \DateTime($model->timeFrom))->getTimestamp(); | |
55 | + $date2=(new \DateTime($model->timeTo))->getTimestamp(); | |
56 | + die(var_dump($date1,$date2)); | |
57 | + | |
58 | + $data=Customer::find() | |
59 | + ->where(['>','create_at',$date1 ]) | |
60 | + ->andWhere(['<','create_at',$date2 ]) | |
61 | + ->all(); | |
62 | + die(var_dump($_POST)); | |
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 | + | |
91 | + | |
92 | + | ... | ... |
1 | +<?php | |
2 | +/** | |
3 | + * @var $model object yii\base\DynamicModel | |
4 | + */ | |
5 | +use yii\widgets\ActiveForm; | |
6 | +use common\helpers\datePickerData; | |
7 | +use yii\web\View; | |
8 | +use yii\helpers\Html; | |
9 | + | |
10 | +$this->registerJsFile('/js/script.js', ['depends' => 'yii\web\JqueryAsset']); | |
11 | +$this->registerJsFile('/js/jquery-ui.min.js', ['depends' => 'yii\web\JqueryAsset']); | |
12 | +$this->registerCssFile('/css/style.css'); | |
13 | +$dp=new datePickerData(); | |
14 | +$js=$dp->getDatepickerJs(); | |
15 | + | |
16 | + | |
17 | +$this->registerJs($js, View::POS_LOAD); | |
18 | + | |
19 | + | |
20 | + | |
21 | +?> | |
22 | + | |
23 | + | |
24 | + | |
25 | +<div class="form-admin-sort-wr"> | |
26 | + <div class="form-admin-sort"> | |
27 | + <?php $form=ActiveForm::begin( | |
28 | + [ | |
29 | + 'action' => '/admin/export/view', | |
30 | + 'method' => 'POST', | |
31 | + ] | |
32 | + );?> | |
33 | + <div class="input-wr"> | |
34 | + <?=$form->field($model,'timeFrom')->textInput(['class' => '_datepicer']);?> | |
35 | + </div> | |
36 | + | |
37 | + | |
38 | + <div class="input-wr"> | |
39 | + <?=$form->field($model,'timeTo')->textInput(['class' => '_datepicer']);?> | |
40 | + | |
41 | + </div> | |
42 | + <div class="form-search-btn-wr"> | |
43 | + <?=Html::submitButton('test1',['class'=> 'btn btn-success'])?> | |
44 | + </div> | |
45 | + | |
46 | + | |
47 | + <?php ActiveForm::end() ?> | |
48 | + </div> | |
49 | +</div> | |
50 | + | ... | ... |
1 | +<?php | |
2 | +namespace common\models\dummy; | |
3 | + | |
4 | + | |
5 | +use yii\base\Model; | |
6 | + | |
7 | + | |
8 | +class DateModel extends Model | |
9 | +{ | |
10 | + public $timeFrom; | |
11 | + public $timeTo; | |
12 | + | |
13 | + public function rules() | |
14 | + { | |
15 | + return [ | |
16 | + [ | |
17 | + ['timeFrom','timeTo'], | |
18 | + 'string' | |
19 | + ], | |
20 | + ]; | |
21 | + } | |
22 | + | |
23 | +} | |
0 | 24 | \ No newline at end of file | ... | ... |