public function actionReceive($id) { $model = $this->findModel($id); Yii::$app->trigger(Hooks::E_IRREC_1, new Event([$model])); if (!AppHelper::checkAccess('receive', $model)) { throw new \yii\web\ForbiddenHttpException(); } $transaction = Yii::$app->db->beginTransaction(); try { $model->status = Transfer::STATUS_RECEIVE; if (!$model->save()) { throw new UserException(implode(",\n", $model->firstErrors)); } Yii::$app->trigger(Hooks::E_IRREC_21, new Event([$model])); foreach ($model->transferDtls as $detail) { Yii::$app->trigger(Hooks::E_IRREC_22, new Event([$model, $detail])); } Yii::$app->trigger(Hooks::E_IRREC_23, new Event([$model])); $transaction->commit(); } catch (Exception $exc) { $transaction->rollBack(); throw new UserException($exc->getMessage()); } return $this->redirect(['index']); }
/** * @inheritdoc */ protected function renderDataCellContent($model, $key, $index) { return preg_replace_callback('/\\{([\\w\\-\\/]+)\\}/', function ($matches) use($model, $key, $index) { $name = $matches[1]; if (isset($this->buttons[$name]) && Helper::checkAccess($name, $model)) { $url = $this->createUrl($name, $model, $key, $index); return call_user_func($this->buttons[$name], $url, $model); } else { return ''; } }, $this->template); }
case Transfer::STATUS_ISSUE: $warnaStatus = 'label-success'; break; case Transfer::STATUS_CONFIRM: $warnaStatus = 'label-info'; break; case Transfer::STATUS_CONFIRM_APPROVE: $warnaStatus = 'label-info'; break; case Transfer::STATUS_CONFIRM_REJECT: $warnaStatus = 'label-danger'; break; case Transfer::STATUS_RECEIVE: $warnaStatus = 'label-primary'; break; } return "<span class='label {$warnaStatus}'>{$model->nmStatus}</span>"; }, 'format' => 'raw'], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{view} {update} {delete} {issue}', 'buttons' => ['issue' => function ($url, $model) { if (Helper::checkAccess('issue', $model)) { return Html::a('<span class="glyphicon glyphicon-open"></span>', $url, ['title' => Yii::t('yii', 'Issue'), 'data-confirm' => Yii::t('yii', 'Are you sure you want to issue this item?'), 'data-method' => 'post', 'data-pjax' => '0']); } }]]]]); ?> </div> </div> <?php Pjax::end(); ?> </div> </div>
case TransferNotice::STATUS_UPDATE: $warnaStatus = 'label-success'; break; case TransferNotice::STATUS_APPROVE: $warnaStatus = 'label-primary'; break; } return "<span class='label {$warnaStatus}'>{$nm_status}</span>"; } echo DetailView::widget(['options' => ['class' => 'table table-striped detail-view', 'style' => 'padding:0px;'], 'model' => $model, 'attributes' => ['idTransfer.transfer_num', 'idTransfer.idWarehouseSource.nm_whse', 'idTransfer.idWarehouseDest.nm_whse', 'noticeDate', ['label' => 'Status', 'value' => cLabel($model->status, $model->nmStatus), 'format' => 'raw']]]); ?> </div> <div class="box-footer"> <?php echo Html::activeHiddenInput($model, 'status', ['value' => TransferNotice::STATUS_UPDATE]); if (AppHelper::checkAccess('update', $model)) { echo Html::submitButton('Update', ['class' => 'btn btn-success']); } ?> </div> </div> </div> <div class="col-lg-8"> <div class="box box-info"> <div class="box-body no-padding"> <?php echo GridView::widget(['tableOptions' => ['class' => 'table table-striped'], 'layout' => '{items}{pager}', 'dataProvider' => new ArrayDataProvider(['allModels' => $model->transferNoticeDtls, 'sort' => false, 'pagination' => false]), 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'idProduct.nm_product', 'transferDtl.transfer_qty_send:text:Qty Send', 'transferDtl.transfer_qty_receive:text:Qty Receive', 'qty_notice', ['label' => 'Qty Approve', 'format' => 'raw', 'content' => $renderField], 'idUom.nm_uom']]); ?> </div> </div> </div>
/** * Updates an existing Purchase model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); if (!AppHelper::checkAccess('update', $model)) { throw new \yii\web\ForbiddenHttpException('Forbidden'); } $post = Yii::$app->request->post(); if ($model->load($post)) { try { $transaction = Yii::$app->db->beginTransaction(); $success = $model->save(); $success = $model->saveRelated('purchaseDtls', $post, $success); if ($success) { $transaction->commit(); return $this->redirect(['view', 'id' => $model->id_purchase]); } else { $transaction->rollBack(); } } catch (\Exception $exc) { $transaction->rollBack(); $model->addError('', $exc->getMessage()); } } return $this->render('update', ['model' => $model, 'details' => $model->purchaseDtls]); }
/** * Deletes an existing TransferNotice model. * If deletion is successful, the browser will be redirected to the 'index' page. * @param integer $id * @return mixed */ public function actionDelete($id) { $model = $this->findModel($id); Yii::$app->trigger(Hooks::E_INDEL_1, new Event([$model])); if (!AppHelper::checkAccess('delete', $model)) { throw new \yii\web\ForbiddenHttpException(); } $model->delete(); return $this->redirect(['index']); }
/** * Deletes an existing Sales model. * If deletion is successful, the browser will be redirected to the 'index' page. * @param integer $id * @return mixed */ public function actionDelete($id) { $model = $this->findModel($id); if (!AppHelper::checkAccess('delete', $model)) { throw new \yii\web\ForbiddenHttpException(); } $model->delete(); return $this->redirect(['index']); }
case Transfer::STATUS_ISSUE: $warnaStatus = 'label-success'; break; case Transfer::STATUS_CONFIRM: $warnaStatus = 'label-info'; break; case Transfer::STATUS_CONFIRM_APPROVE: $warnaStatus = 'label-info'; break; case Transfer::STATUS_CONFIRM_REJECT: $warnaStatus = 'label-danger'; break; case Transfer::STATUS_RECEIVE: $warnaStatus = 'label-primary'; break; } return "<span class='label {$warnaStatus}'>{$model->nmStatus}</span>"; }, 'format' => 'raw'], ['class' => 'biz\\app\\components\\ActionColumn', 'template' => '{view} {update} {receive}', 'buttons' => ['receive' => function ($url, $model) { if (Helper::checkAccess('receive', $model)) { return Html::a('<span class="glyphicon glyphicon-save"></span>', $url, ['title' => Yii::t('yii', 'Receive'), 'data-confirm' => Yii::t('yii', 'Are you sure you want to receive this item?'), 'data-method' => 'post', 'data-pjax' => '0']); } }]]]]); ?> </div> </div> <?php Pjax::end(); ?> </div> </div>