/** * * @param \yii\web\Application $app * @param array $config */ protected function initialize($app, $config) { if ($app instanceof \yii\web\Application) { if (ArrayHelper::getValue($config, 'attach_client_behavior', true)) { $app->attachBehavior(ClientBehavior::className(), ClientBehavior::className()); } AppHelper::registerAccessHandler(models\Sales::className(), components\AccessHandler::className()); } }
/** * * @param \yii\web\Application $app * @param array $config */ protected function initialize($app, $config) { if ($app instanceof \yii\web\Application) { $app->attachBehaviors([hooks\TransferNoticeHook::className() => hooks\TransferNoticeHook::className()]); AppHelper::registerAccessHandler(models\Transfer::className(), AccessHandler::className()); AppHelper::registerAccessHandler(models\TransferNotice::className(), AccessHandler::className()); } }
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>
?> <div class="col-lg-9" style="padding-left: 0px;"> <div class="panel panel-info"> <div class="panel-heading"> Product : <?php echo AutoComplete::widget(['name' => 'product', 'id' => 'product', 'clientOptions' => ['source' => new JsExpression('yii.global.sourceProduct'), 'select' => new JsExpression('yii.standart.onProductSelect'), 'delay' => 100]]); ?> </div> <div class="panel-body" style="text-align: right;"> <h2>Rp<span id="total-price"></h2></span> <?php echo Html::activeHiddenInput($model, 'sales_value', ['id' => 'total-price-inp']); ?> </div> <table class="table table-striped"> <?php echo TabularInput::widget(['id' => 'detail-grid', 'allModels' => $model->salesDtls, 'modelClass' => SalesDtl::className(), 'options' => ['tag' => 'tbody'], 'itemOptions' => ['tag' => 'tr'], 'itemView' => '_item_detail', 'clientOptions' => ['initRow' => new JsExpression('yii.standart.initRow')]]); ?> </table> </div> </div> <?php $js = $this->render('_script', ['price' => $price], $this->context); $this->registerJs($js, \yii\web\View::POS_END); AppHelper::bizConfig($this, ['masters' => ['products', 'barcodes', 'prices', 'customers'], 'price_ct' => $price]); $js_ready = <<<JS yii.standart.onReady(); JS; $this->registerJs($js_ready);
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]); }
<?php echo $form->field($model, 'nmProduct')->widget('yii\\jui\\AutoComplete', ['id' => 'product', 'options' => ['class' => 'form-control'], 'clientOptions' => ['source' => new JsExpression('yii.global.sourceProduct'), 'delay' => 100]]); ?> <?php echo $form->field($model, 'id_uom')->dropDownList(ArrayHelper::map(Uom::find()->all(), 'id_uom', 'nm_uom'), ['style' => 'width:200px;']); ?> <?php echo $form->field($model, 'isi')->textInput(); ?> </div> </div> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?> </div> <?php BizAsset::register($this); AppHelper::bizConfig($this, ['masters' => ['products', 'barcodes']]); $js_ready = <<<JS JS; $this->registerJs($js_ready);
/** * 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']); }
/** * * @param \yii\base\Application $app * @param array $config */ protected function initialize($app, $config) { if ($app instanceof \yii\web\Application) { AppHelper::registerAccessHandler(models\Purchase::className(), components\AccessHandler::className()); } }
} }); } JS; ?> <?php echo TabularInput::widget(['id' => 'tbl-gldetail', 'allModels' => $model->glDetails, 'itemView' => '_detail', 'modelClass' => GlDetail::className(), 'options' => ['tag' => 'tbody'], 'itemOptions' => ['tag' => 'tr'], 'clientOptions' => ['afterAddRow' => new yii\web\JsExpression($jsFunc), 'btnAddSelector' => '#append-row']]); ?> </table> <div class="panel-footer"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> </div> <?php ActiveForm::end(); ?> </div> <?php yii\jui\AutoCompleteAsset::register($this); yii\jui\ThemeAsset::register($this); biz\app\assets\BizAsset::register($this); AppHelper::bizConfig($this, ['masters' => ['coas']]); $js = <<<JS yii.numeric.input(\$('#tbl-glheader'),'input.amount'); yii.numeric.format(\$('#tbl-glheader'),'input.amount'); JS; $this->registerJs($js);
/** * 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>