/**
  * 
  * @param \biz\base\Event $event
  * @param \biz\models\TransferHdr $model
  */
 public function receiveReceiveEnd($event, $model)
 {
     $noticeDtls = [];
     foreach ($model->transferDtls as $detail) {
         if ($detail->transfer_qty_send != $detail->transfer_qty_receive) {
             $noticeDtl = new TransferNoticeDtl();
             $noticeDtl->id_product = $detail->id_product;
             $noticeDtl->qty_selisih = $detail->transfer_qty_receive - $detail->transfer_qty_send;
             $noticeDtl->id_uom = $detail->id_uom;
             $noticeDtls[] = $noticeDtl;
         }
     }
     if (count($noticeDtls)) {
         $notice = new TransferNotice();
         $notice->description = 'Qty kirim tidak sama dengan qty terima';
         $notice->notice_date = date('Y-m-d');
         $notice->status = TransferNotice::STATUS_CREATE;
         $notice->id_transfer = $model->id_transfer;
         if (!$notice->save()) {
             throw new \Exception(implode("\n", $notice->firstErrors));
         }
         Yii::$app->trigger(Hooks::E_TNCRE_21, new Event([$notice]));
         foreach ($noticeDtls as $noticeDtl) {
             $noticeDtl->id_transfer = $notice->id_transfer;
             if (!$noticeDtl->save()) {
                 throw new \Exception(implode("\n", $noticeDtl->firstErrors));
             }
             Yii::$app->trigger(Hooks::E_TNCRE_22, new Event([$notice, $noticeDtl]));
         }
         Yii::$app->trigger(Hooks::E_TNCRE_23, new Event([$notice]));
     }
 }
 public function search($params)
 {
     $query = TransferNoticeModel::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id_transfer' => $this->id_transfer, 'notice_date' => $this->notice_date, 'status' => $this->status, 'update_by' => $this->update_by, 'create_by' => $this->create_by]);
     $query->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'create_date', $this->create_date])->andFilterWhere(['like', 'update_date', $this->update_date]);
     return $dataProvider;
 }
Example #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTransferNotice()
 {
     return $this->hasOne(TransferNotice::className(), ['id_transfer' => 'id_transfer']);
 }
 /**
  * Finds the TransferNotice model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return TransferNotice the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = TransferNotice::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }