diff --git a/models/Order.php b/models/Order.php index 76ae009..7d76eca 100755 --- a/models/Order.php +++ b/models/Order.php @@ -14,6 +14,10 @@ * @property integer $created_at * @property integer $updated_at * @property integer $deleted_at + * @property integer $deadline + * @property integer $reason + * @property string $check + * @property string $sms * @property int $id * @property int $user_id * @property string $name @@ -72,7 +76,7 @@ { return [ [ - ['pay'], + [ 'pay' ], 'boolean', ], [ @@ -80,6 +84,9 @@ 'created_at', 'updated_at', 'deleted_at', + 'payment', + 'reason', + 'label', ], 'integer', ], @@ -107,6 +114,7 @@ ], [ [ + 'deadline', 'name', 'numbercard', 'body', @@ -120,6 +128,8 @@ 'adress', 'total', 'status', + 'check', + 'sms', ], 'string', 'max' => 255, @@ -127,6 +137,35 @@ ]; } + public function afterFind() + { + parent::afterFind(); + $this->deadline = !empty( $this->deadline ) ? date('d.m.Y', $this->deadline) : ''; + + } + + public function beforeSave($insert) + { + if (parent::beforeSave($insert)) { + + $this->convertDate(); + return true; + } + return false; + + } + + protected function convertDate() + { + if (!empty( $this->deadline )) { + $date = new \DateTime($this->deadline); + $date->format("d.m.Y"); + $this->deadline = $date->getTimestamp(); + + } + + } + public function attributeLabels() { return [ @@ -137,6 +176,10 @@ 'created_at' => Yii::t('app', 'Дата добавления'), 'updated_at' => Yii::t('app', 'Дата обновления'), 'deleted_at' => Yii::t('app', 'Дата удаления'), + 'deadline' => Yii::t('app', 'Дедлайн'), + 'reason' => Yii::t('app', 'Причина'), + 'check' => Yii::t('app', 'Чек'), + 'sms' => Yii::t('app', 'СМС'), ]; } @@ -144,7 +187,7 @@ { return $this->hasOne(Customer::className(), [ 'id' => 'user_id' ]); } - + /** * @return \yii\db\ActiveQuery */ @@ -152,39 +195,39 @@ { return $this->hasMany(OrderProduct::className(), [ 'order_id' => 'id' ]); } - - + /** * @return \yii\db\ActiveQuery */ - public function getOrderDelivery(){ - return $this->hasOne(Delivery::className(), ['id'=> 'delivery']); + public function getOrderDelivery() + { + return $this->hasOne(Delivery::className(), [ 'id' => 'delivery' ]); } - + /** * @return \yii\db\ActiveQuery */ - public function getOrderLabel(){ - return $this->hasOne(Label::className(),['id'=> 'status']); + public function getOrderLabel() + { + return $this->hasOne(Label::className(), [ 'id' => 'status' ]); } - - - + /** * @return \yii\db\ActiveQuery */ - public function getOrderPayment(){ - return $this->hasOne(OrderPayment::className(),['id'=> 'payment']); + public function getOrderPayment() + { + return $this->hasOne(OrderPayment::className(), [ 'id' => 'payment' ]); } - - + /** * @return string */ - public function getDeliveryString(){ - if(!empty($this->orderDelivery)){ - if(!empty($this->orderDelivery->parent)){ - return $this->orderDelivery->parent->lang->title .': '.$this->orderDelivery->lang->title; + public function getDeliveryString() + { + if (!empty( $this->orderDelivery )) { + if (!empty( $this->orderDelivery->parent )) { + return $this->orderDelivery->parent->lang->title . ': ' . $this->orderDelivery->lang->title; } else { return $this->orderDelivery->lang->title; } @@ -192,6 +235,5 @@ return ''; } } - - + } \ No newline at end of file diff --git a/views/order/_form.php b/views/order/_form.php index e73b140..1d270fa 100755 --- a/views/order/_form.php +++ b/views/order/_form.php @@ -89,6 +89,15 @@ JS; ] ); ?> + = $form->field($model, 'reason') + ->dropDownList( + [ + 1 => 'То', + 2 => 'Сё', + ], + [ 'prompt' => 'Выберите причину' ] + ) ?> + = $form->field($model, 'label') ->dropDownList( ArrayHelper::map( @@ -98,7 +107,7 @@ JS; 'id', 'label' ), - [ 'prompt' => 'Метка' ] + [ 'prompt' => 'Выберите метку' ] ); ?> = $form->field($model, 'name') ?> @@ -109,7 +118,11 @@ JS; = $form->field($model, 'email') ?> - = $form->field($model, 'numbercard') ?> + = $form->field( + $model, + 'numbercard' + ) + ->textInput([ 'readonly' => true ]) ?> = $form->field($model, 'comment') ->textarea([ 'rows' => '3' ]) ?> @@ -133,6 +146,8 @@ JS; = $form->field($model, 'stock') ?> + = $form->field($model, 'consignment') ?> + = $form->field($model, 'payment') ->dropDownList( ArrayHelper::map( @@ -163,6 +178,11 @@ JS; = $form->field($model, 'body') ->textarea([ 'rows' => '3' ]) ?> + + = $form->field($model, 'check') ?> + + = $form->field($model, 'sms') ?> + diff --git a/views/order/index.php b/views/order/index.php index c1d495c..bac5273 100755 --- a/views/order/index.php +++ b/views/order/index.php @@ -19,6 +19,14 @@ $this->title = 'Заказы'; $this->params[ 'breadcrumbs' ][] = $this->title; + + $js = <<< JS +$('[name="OrderSearch[phone]"]').mask('+38(000)000-00-00', { + placeholder: '+38(___)___-__-__' +}); +JS; + + $this->registerJs($js, View::POS_READY); ?>
-- libgit2 0.21.4