/** * function ::create ($data) */ public static function create($data) { $now = strtotime('now'); $username = Yii::$app->user->identity->username; $model = new ProductFollowing(); if ($model->load($data)) { if ($log = new UserLog()) { $log->username = $username; $log->action = 'Create'; $log->object_class = 'ProductFollowing'; $log->created_at = $now; $log->is_success = 0; $log->save(); } $model->created_at = $now; $model->replied_at = strtotime($model->replied_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 = ProductFollowing::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, 'product_id' => $this->product_id, 'customer_id' => $this->customer_id, 'customer_phone_number' => $this->customer_phone_number, 'language_id' => $this->language_id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'replied_at' => $this->replied_at, 'noreply_email_id' => $this->noreply_email_id, 'status' => $this->status]); $query->andFilterWhere(['like', 'product_name', $this->product_name])->andFilterWhere(['like', 'product_code', $this->product_code])->andFilterWhere(['like', 'customer_name', $this->customer_name])->andFilterWhere(['like', 'customer_email', $this->customer_email])->andFilterWhere(['like', 'zip_postal_code', $this->zip_postal_code])->andFilterWhere(['like', 'updated_by', $this->updated_by])->andFilterWhere(['like', 'replied_by', $this->replied_by]); return $dataProvider; }
/** * Finds the ProductFollowing model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return ProductFollowing the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = ProductFollowing::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
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 echo in_array(Yii::$app->controller->id, ['product-following']) ? 'active' : ''; ?> "> <a href="<?php echo Yii::$app->urlManager->createUrl('product-following/index'); ?> "> <i class="fa fa-retweet"></i> <span>Theo dõi</span> <span class="label label-success pull-right"><?php echo ProductFollowing::find()->where(['status' => ProductFollowing::STATUS_NEW])->count(); ?> </span> </a> <!-- <ul class="treeview-menu"> <li class="<?php echo Yii::$app->controller->id == 'product-following' && Yii::$app->controller->action->id == 'index' ? 'active' : ''; ?> "><a href="<?php echo Yii::$app->urlManager->createUrl('product-following/index'); ?> "><i class="fa fa-circle-o"></i> Danh sách</a></li> </ul>--> </li> <!-- Sản phẩm --> <li class="treeview <?php