Exemple #1
0
 /**
  * function ::create ($data)
  */
 public static function create($data)
 {
     $now = strtotime('now');
     $username = Yii::$app->user->identity->username;
     $model = new PurchaseOrder();
     if ($model->load($data)) {
         if ($log = new UserLog()) {
             $log->username = $username;
             $log->action = 'Create';
             $log->object_class = 'PurchaseOrder';
             $log->created_at = $now;
             $log->is_success = 0;
             $log->save();
         }
         $model->delivered_at = strtotime($model->delivered_at);
         $model->shipped_at = strtotime($model->shipped_at);
         if ($model->save()) {
             if ($log) {
                 $log->object_pk = $model->id;
                 $log->is_success = 1;
                 $log->save();
             }
             return $model;
         }
         $model->getErrors();
         return $model;
     }
     return false;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = PurchaseOrder::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'language_id' => $this->language_id, 'status' => $this->status, 'customer_id' => $this->customer_id, 'customer_phone_number' => $this->customer_phone_number, 'delivered_at' => $this->delivered_at, 'shipped_at' => $this->shipped_at, 'shipping_fee' => $this->shipping_fee]);
     $query->andFilterWhere(['like', 'transaction_id', $this->transaction_id])->andFilterWhere(['like', 'customer_name', $this->customer_name])->andFilterWhere(['like', 'customer_email', $this->customer_email])->andFilterWhere(['like', 'customer_address', $this->customer_address])->andFilterWhere(['like', 'customer_city', $this->customer_city])->andFilterWhere(['like', 'customer_country', $this->customer_country])->andFilterWhere(['like', 'country_calling_code', $this->country_calling_code])->andFilterWhere(['like', 'zip_postal_code', $this->zip_postal_code])->andFilterWhere(['like', 'delivery_to', $this->delivery_to])->andFilterWhere(['like', 'shipping_from', $this->shipping_from])->andFilterWhere(['like', 'shipping_via', $this->shipping_via])->andFilterWhere(['like', 'payment_method', $this->payment_method])->andFilterWhere(['like', 'customer_note', $this->customer_note])->andFilterWhere(['like', 'user_note', $this->user_note]);
     return $dataProvider;
 }
 /**
  * Finds the PurchaseOrder model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return PurchaseOrder the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = PurchaseOrder::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemple #4
0
        <ul class="sidebar-menu">
            <li class="header">NOW <?php 
    echo date('d/m/Y H:i');
    ?>
</li>
            <!-- Đơn hàng -->
            <li class="treeview <?php 
    echo in_array(Yii::$app->controller->id, ['purchase-order', 'purchase-order-detail']) ? 'active' : '';
    ?>
">
                <a href="<?php 
    echo Yii::$app->urlManager->createUrl('purchase-order/index');
    ?>
">
                    <i class="fa fa-truck"></i> <span>Đơn hàng</span> <span class="label label-warning pull-right"><?php 
    echo PurchaseOrder::find()->where(['status' => PurchaseOrder::STATUS_NEW])->count();
    ?>
</span>
                </a>
<!--                <ul class="treeview-menu">
                    <li class="<?php 
    echo Yii::$app->controller->id == 'purchase-order' && Yii::$app->controller->action->id == 'index' ? 'active' : '';
    ?>
"><a href="<?php 
    echo Yii::$app->urlManager->createUrl('purchase-order/index');
    ?>
"><i class="fa fa-circle-o"></i> Danh sách</a></li>
                </ul>-->
            </li>
            <!-- Theo dõi -->
            <li class="treeview <?php 
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPurchaseOrder()
 {
     return $this->hasOne(PurchaseOrder::className(), ['id' => 'purchase_order_id']);
 }