/** * * @param \biz\app\base\Event $event */ public function purchaseReceiveBody($event) { /* @var $detail \biz\master\models\PurchaseDtl */ $detail = $event->params[1]; $smallest_uom = Helper::getSmallestProductUom($detail->id_product); $this->updatePrice(['id_product' => $detail->id_product, 'id_uom' => $smallest_uom, 'price' => $detail->sales_price, 'app' => 'purchase', 'id_ref' => $detail->id_purchase_dtl]); }
protected function updateCogs($params) { $cogs = Cogs::findOne(['id_product' => $params['id_product']]); if (!$cogs) { $cogs = new Cogs(['id_product' => $params['id_product'], 'cogs' => 0.0]); } $current_stock = MasterHelper::getCurrentStockAll($params['id_product']); $qty_per_uom = MasterHelper::getQtyProductUom($params['id_product'], $params['id_uom']); $added_stock = $params['qty'] * $qty_per_uom; if ($current_stock + $added_stock != 0) { $cogs->cogs = 1.0 * ($cogs->cogs * $current_stock + $params['price'] * $params['qty']) / ($current_stock + $added_stock); } else { $cogs->cogs = 0; } if ($cogs->canSetProperty('logParams')) { $cogs->logParams = ['app' => $params['app'], 'id_ref' => $params['id_ref']]; } if (!$cogs->save()) { throw new UserException(implode(",\n", $cogs->firstErrors)); } return true; }
/** * * @param array $params * Required field id_warehouse, id_product, id_uom, qty * Optional field app, id_ref * @return boolean * @throws UserException */ public function updateStock($params) { $stock = ProductStock::findOne(['id_warehouse' => $params['id_warehouse'], 'id_product' => $params['id_product']]); $qty_per_uom = Helper::getQtyProductUom($params['id_product'], $params['id_uom']); if (!$stock) { $smallest_uom = Helper::getSmallestProductUom($params['id_product']); $stock = new ProductStock(); $stock->setAttributes(['id_warehouse' => $params['id_warehouse'], 'id_product' => $params['id_product'], 'id_uom' => $smallest_uom, 'qty_stock' => 0]); } $stock->qty_stock = $stock->qty_stock + $params['qty'] * $qty_per_uom; if ($stock->canSetProperty('logParams')) { $logParams = ['mv_qty' => $params['qty'] * $qty_per_uom]; foreach (['app', 'id_ref'] as $key) { if (isset($params[$key]) || array_key_exists($key, $params)) { $logParams[$key] = $params[$key]; } } $stock->logParams = $logParams; } if (!$stock->save()) { throw new UserException(implode(",\n", $stock->firstErrors)); } return true; }
<?php $models = $model->transferDtls; array_unshift($models, $model); echo $form->errorSummary($models); ?> <div class="col-lg-4"> <div class="box box-primary"> <div class="box-body"> <?php echo $form->field($model, 'transfer_num')->textInput(['maxlength' => 16, 'readonly' => true]); ?> <?php echo $form->field($model, 'id_warehouse_source')->dropDownList(Helper::getWarehouseList()); ?> <?php echo $form->field($model, 'id_warehouse_dest')->dropDownList(Helper::getWarehouseList()); ?> <?php echo $form->field($model, 'transferDate')->widget('yii\\jui\\DatePicker', ['options' => ['class' => 'form-control', 'style' => 'width:50%'], 'clientOptions' => ['dateFormat' => 'dd-mm-yy']]); ?> </div> <div class="box-footer"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> </div> </div> <div class="col-lg-8"> <?php echo $this->render('_detail', ['model' => $model]);
<?php use yii\bootstrap\Modal; use yii\helpers\Html; use biz\master\components\Helper; use biz\sales\models\Cashdrawer; $model = new Cashdrawer(['id_branch' => Yii::$app->clientIdBranch, 'cashier_no' => Yii::$app->clientCashierNo]); Modal::begin(['id' => 'dlg-drawer', 'closeButton' => null, 'clientOptions' => ['backdrop' => 'static', 'keyboard' => false]]); ?> <div class="cash-drawer-form"> <?php echo $form->field($model, 'id_branch')->dropDownList(Helper::getBranchList()); ?> <?php echo $form->field($model, 'cashier_no')->dropDownList([1 => 1, 2 => 2, 3 => 3, 4 => 4]); ?> <?php echo $form->field($model, 'init_cash'); ?> <div class="form-group"> <?php echo Html::a('Open New', '', ['class' => 'btn btn-success', 'id' => 'cashdrawer-opennew']); ?> </div> </div> <?php Modal::end(); ?> <?php Modal::begin(['id' => 'dlg-confirm-save', 'closeButton' => null, 'size' => Modal::SIZE_SMALL, 'clientOptions' => ['backdrop' => 'static']]);
use yii\jui\AutoComplete; use biz\inventory\models\TransferDtl; use mdm\widgets\TabularInput; use biz\app\assets\BizDataAsset; use biz\master\components\Helper as MasterHelper; ?> <div class="box box-info"> <div class="box-header" style="padding: 10px;"> Product : <?php echo AutoComplete::widget(['name' => 'product', 'id' => 'product', 'clientOptions' => ['source' => new JsExpression('yii.global.sourceProduct'), 'select' => new JsExpression('yii.transfer.onProductSelect'), 'delay' => 100], 'options' => ['class' => 'form-control']]); ?> </div> <div class="box-body no-padding"> <table class="table table-striped"> <?php echo TabularInput::widget(['id' => 'detail-grid', 'allModels' => $model->transferDtls, 'modelClass' => TransferDtl::className(), 'itemView' => '_item_detail', 'options' => ['tag' => 'tbody'], 'itemOptions' => ['tag' => 'tr'], 'clientOptions' => ['initRow' => new JsExpression('yii.transfer.initRow')]]); ?> </table> </div> </div> <?php $js = $this->render('_script', [], $this->context); $this->registerJs($js, yii\web\View::POS_END); BizDataAsset::register($this, ['master' => MasterHelper::getMasters('product, barcode, product_stock')]); $js_ready = <<<JS \$("#product").data("ui-autocomplete")._renderItem = yii.global.renderItem; yii.transfer.onReady(); JS; $this->registerJs($js_ready);
<td class="items" style="width: 45%"> <ul class="nav nav-list"> <li><span class="cd_product"><?php echo Html::getAttributeValue($model, 'idProduct[cd_product]'); ?> </span> - <span class="nm_product"><?php echo Html::getAttributeValue($model, 'idProduct[nm_product]'); ?> </span></li> <li> Jumlah <?php echo Html::activeTextInput($model, "[{$key}]transfer_qty_send", ['data-field' => 'transfer_qty_send', 'size' => 5, 'id' => false, 'required' => true]); ?> <?php echo Html::activeDropDownList($model, "[{$key}]id_uom", Helper::getProductUomList($model->id_product), ['data-field' => 'id_uom', 'id' => false]); ?> </li> <li> </li> </ul> </td> <td class="selling" style="width: 40%"> <ul class="nav nav-list"> <li>Receive</li> <li> Jumlah <?php echo Html::activeTextInput($model, "[{$key}]transfer_qty_receive", ['data-field' => 'transfer_qty_receive', 'size' => 5, 'id' => false, 'readonly' => true]); ?> </li> <li>
echo $form->errorSummary($models); ?> <?php echo $this->render('_detail', ['model' => $model, 'price' => $price]); ?> <div class="col-lg-3" style="padding-right: 0px;"> <div class="panel panel-primary"> <div class="panel-heading"> Sales Header </div> <div class="panel-body"> <?php echo $form->field($model, 'sales_num')->textInput(['readonly' => true]); ?> <?php echo $form->field($model, 'id_warehouse')->dropDownList(MasterHelper::getWarehouseList()); ?> <?php echo $form->field($model, 'salesDate')->widget('yii\\jui\\DatePicker', ['options' => ['class' => 'form-control', 'style' => 'width:50%'], 'clientOptions' => ['dateFormat' => 'dd-mm-yy']]); ?> <hr > <?php echo $form->field($model, 'nmCustomer')->widget('yii\\jui\\AutoComplete', ['options' => ['class' => 'form-control'], 'clientOptions' => ['source' => new JsExpression('biz.master.customers')]]); echo $form->field($model, 'discount')->textInput(); ?> </div> </div> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?>
public function getDataMaster() { return Helper::getMasters(['product', 'price', 'barcode']); }
use biz\master\components\Helper; /** * @var yii\web\View $this * @var biz\models\Branch $model * @var yii\widgets\ActiveForm $form */ ?> <div class="branch-form" style="padding-left: 0px;"> <?php $form = ActiveForm::begin(); ?> <div class="box box-danger"> <div class="box-body"> <?php echo $form->field($model, 'id_orgn')->dropDownList(Helper::getOrgnList(), ['style' => 'width:200px;']); ?> <?php echo $form->field($model, 'cd_branch')->textInput(['maxlength' => 4, 'style' => 'width:120px;']); ?> <?php echo $form->field($model, 'nm_branch')->textInput(['maxlength' => 32]); ?> </div> <div class="box-footer"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div>
<?php echo Html::a('', '#', ['class' => 'btn btn-danger btn-sm fa fa-times', 'title' => 'Min/Maximize', 'id' => 'tutup', 'data-widget' => 'remove']); ?> </div> </div> <div class="box-body"> <?php echo $form->field($model, 'gl_num'); ?> <?php echo $form->field($model, 'description'); ?> <?php $itemBrnch = \biz\master\components\Helper::getBranchList(); ?> <?php echo $form->field($model, 'id_branch')->dropDownList($itemBrnch, ['prompt' => '--All Status--']); ?> <?php $field = $form->field($model, "gl_date", ['template' => "{label}<br><div class='col-lg-4' style='padding-left:0px;'>{date1}</div><div class='col-lg-4' style='padding-left:0px;'>{date2}</div><br>"]); $field->label('Date Receive (From/To)'); $field->parts['{date1}'] = \yii\jui\DatePicker::widget(['model' => $model, 'attribute' => 'dateFrom', 'options' => ['class' => 'form-control'], 'clientOptions' => ['dateFormat' => 'dd-mm-yy']]); $field->parts['{date2}'] = \yii\jui\DatePicker::widget(['model' => $model, 'attribute' => 'dateTo', 'options' => ['class' => 'form-control'], 'clientOptions' => ['dateFormat' => 'dd-mm-yy']]); echo $field; ?> <?php echo '';
?> <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); BizDataAsset::register($this, ['master' => MasterHelper::getMasters('product, barcode, price, customer'), 'config' => ['price_ct' => $price]]); $js_ready = <<<JS yii.standart.onReady(); JS; $this->registerJs($js_ready);
public function actionPull(array $masters) { \Yii::$app->response->format = Response::FORMAT_JSON; return MasterHelper::getMasters($masters); }
public function getDataMaster() { return MasterHelper::getMasters('product, barcode, product_stock'); }
echo $form->field($model, 'cd_product'); ?> <?php echo $form->field($model, 'nm_product'); ?> <?php $itemWhse = Helper::getCategoryList(); ?> <?php echo $form->field($model, 'id_category')->dropDownList($itemWhse, ['prompt' => '--All Category--']); ?> <?php $itemGroup = Helper::getProductGroupList(); ?> <?php echo $form->field($model, 'id_group')->dropDownList($itemGroup, ['prompt' => '--All Groups--']); ?> <?php // echo $form->field($model, 'create_at') ?> <?php // echo $form->field($model, 'create_by') ?> <?php // echo $form->field($model, 'update_at')