Commit ccfc576392964f22e42e43fd66e2ced984c8be77

Authored by Alexey Boroda
1 parent 30b799f2

-Order in process 3

models/Order.php
... ... @@ -14,6 +14,10 @@
14 14 * @property integer $created_at
15 15 * @property integer $updated_at
16 16 * @property integer $deleted_at
  17 + * @property integer $deadline
  18 + * @property integer $reason
  19 + * @property string $check
  20 + * @property string $sms
17 21 * @property int $id
18 22 * @property int $user_id
19 23 * @property string $name
... ... @@ -72,7 +76,7 @@
72 76 {
73 77 return [
74 78 [
75   - ['pay'],
  79 + [ 'pay' ],
76 80 'boolean',
77 81 ],
78 82 [
... ... @@ -80,6 +84,9 @@
80 84 'created_at',
81 85 'updated_at',
82 86 'deleted_at',
  87 + 'payment',
  88 + 'reason',
  89 + 'label',
83 90 ],
84 91 'integer',
85 92 ],
... ... @@ -107,6 +114,7 @@
107 114 ],
108 115 [
109 116 [
  117 + 'deadline',
110 118 'name',
111 119 'numbercard',
112 120 'body',
... ... @@ -120,6 +128,8 @@
120 128 'adress',
121 129 'total',
122 130 'status',
  131 + 'check',
  132 + 'sms',
123 133 ],
124 134 'string',
125 135 'max' => 255,
... ... @@ -127,6 +137,35 @@
127 137 ];
128 138 }
129 139  
  140 + public function afterFind()
  141 + {
  142 + parent::afterFind();
  143 + $this->deadline = !empty( $this->deadline ) ? date('d.m.Y', $this->deadline) : '';
  144 +
  145 + }
  146 +
  147 + public function beforeSave($insert)
  148 + {
  149 + if (parent::beforeSave($insert)) {
  150 +
  151 + $this->convertDate();
  152 + return true;
  153 + }
  154 + return false;
  155 +
  156 + }
  157 +
  158 + protected function convertDate()
  159 + {
  160 + if (!empty( $this->deadline )) {
  161 + $date = new \DateTime($this->deadline);
  162 + $date->format("d.m.Y");
  163 + $this->deadline = $date->getTimestamp();
  164 +
  165 + }
  166 +
  167 + }
  168 +
130 169 public function attributeLabels()
131 170 {
132 171 return [
... ... @@ -137,6 +176,10 @@
137 176 'created_at' => Yii::t('app', 'Дата добавления'),
138 177 'updated_at' => Yii::t('app', 'Дата обновления'),
139 178 'deleted_at' => Yii::t('app', 'Дата удаления'),
  179 + 'deadline' => Yii::t('app', 'Дедлайн'),
  180 + 'reason' => Yii::t('app', 'Причина'),
  181 + 'check' => Yii::t('app', 'Чек'),
  182 + 'sms' => Yii::t('app', 'СМС'),
140 183 ];
141 184 }
142 185  
... ... @@ -144,7 +187,7 @@
144 187 {
145 188 return $this->hasOne(Customer::className(), [ 'id' => 'user_id' ]);
146 189 }
147   -
  190 +
148 191 /**
149 192 * @return \yii\db\ActiveQuery
150 193 */
... ... @@ -152,39 +195,39 @@
152 195 {
153 196 return $this->hasMany(OrderProduct::className(), [ 'order_id' => 'id' ]);
154 197 }
155   -
156   -
  198 +
157 199 /**
158 200 * @return \yii\db\ActiveQuery
159 201 */
160   - public function getOrderDelivery(){
161   - return $this->hasOne(Delivery::className(), ['id'=> 'delivery']);
  202 + public function getOrderDelivery()
  203 + {
  204 + return $this->hasOne(Delivery::className(), [ 'id' => 'delivery' ]);
162 205 }
163   -
  206 +
164 207 /**
165 208 * @return \yii\db\ActiveQuery
166 209 */
167   - public function getOrderLabel(){
168   - return $this->hasOne(Label::className(),['id'=> 'status']);
  210 + public function getOrderLabel()
  211 + {
  212 + return $this->hasOne(Label::className(), [ 'id' => 'status' ]);
169 213 }
170   -
171   -
172   -
  214 +
173 215 /**
174 216 * @return \yii\db\ActiveQuery
175 217 */
176   - public function getOrderPayment(){
177   - return $this->hasOne(OrderPayment::className(),['id'=> 'payment']);
  218 + public function getOrderPayment()
  219 + {
  220 + return $this->hasOne(OrderPayment::className(), [ 'id' => 'payment' ]);
178 221 }
179   -
180   -
  222 +
181 223 /**
182 224 * @return string
183 225 */
184   - public function getDeliveryString(){
185   - if(!empty($this->orderDelivery)){
186   - if(!empty($this->orderDelivery->parent)){
187   - return $this->orderDelivery->parent->lang->title .': '.$this->orderDelivery->lang->title;
  226 + public function getDeliveryString()
  227 + {
  228 + if (!empty( $this->orderDelivery )) {
  229 + if (!empty( $this->orderDelivery->parent )) {
  230 + return $this->orderDelivery->parent->lang->title . ': ' . $this->orderDelivery->lang->title;
188 231 } else {
189 232 return $this->orderDelivery->lang->title;
190 233 }
... ... @@ -192,6 +235,5 @@
192 235 return '';
193 236 }
194 237 }
195   -
196   -
  238 +
197 239 }
198 240 \ No newline at end of file
... ...
views/order/_form.php
... ... @@ -89,6 +89,15 @@ JS;
89 89 ]
90 90 ); ?>
91 91  
  92 + <?= $form->field($model, 'reason')
  93 + ->dropDownList(
  94 + [
  95 + 1 => 'То',
  96 + 2 => 'Сё',
  97 + ],
  98 + [ 'prompt' => 'Выберите причину' ]
  99 + ) ?>
  100 +
92 101 <?= $form->field($model, 'label')
93 102 ->dropDownList(
94 103 ArrayHelper::map(
... ... @@ -98,7 +107,7 @@ JS;
98 107 'id',
99 108 'label'
100 109 ),
101   - [ 'prompt' => 'Метка' ]
  110 + [ 'prompt' => 'Выберите метку' ]
102 111 ); ?>
103 112  
104 113 <?= $form->field($model, 'name') ?>
... ... @@ -109,7 +118,11 @@ JS;
109 118  
110 119 <?= $form->field($model, 'email') ?>
111 120  
112   - <?= $form->field($model, 'numbercard') ?>
  121 + <?= $form->field(
  122 + $model,
  123 + 'numbercard'
  124 + )
  125 + ->textInput([ 'readonly' => true ]) ?>
113 126  
114 127 <?= $form->field($model, 'comment')
115 128 ->textarea([ 'rows' => '3' ]) ?>
... ... @@ -133,6 +146,8 @@ JS;
133 146  
134 147 <?= $form->field($model, 'stock') ?>
135 148  
  149 + <?= $form->field($model, 'consignment') ?>
  150 +
136 151 <?= $form->field($model, 'payment')
137 152 ->dropDownList(
138 153 ArrayHelper::map(
... ... @@ -163,6 +178,11 @@ JS;
163 178  
164 179 <?= $form->field($model, 'body')
165 180 ->textarea([ 'rows' => '3' ]) ?>
  181 +
  182 + <?= $form->field($model, 'check') ?>
  183 +
  184 + <?= $form->field($model, 'sms') ?>
  185 +
166 186 </div>
167 187 </div>
168 188 </div>
... ...
views/order/index.php
... ... @@ -19,6 +19,14 @@
19 19  
20 20 $this->title = 'Заказы';
21 21 $this->params[ 'breadcrumbs' ][] = $this->title;
  22 +
  23 + $js = <<< JS
  24 +$('[name="OrderSearch[phone]"]').mask('+38(000)000-00-00', {
  25 + placeholder: '+38(___)___-__-__'
  26 +});
  27 +JS;
  28 +
  29 + $this->registerJs($js, View::POS_READY);
22 30 ?>
23 31 <h1>Заказы</h1>
24 32 <p>
... ...