Пример #1
0
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);
Пример #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTransferDtls()
 {
     return $this->hasMany(TransferDtl::className(), ['id_transfer' => 'id_transfer'])->orderBy([new \yii\db\Expression('transfer_qty_send=0 ASC')]);
 }
Пример #3
0
 /**
  * 
  * @param string $id
  * @param array $data
  * @param MTransfer $model
  * @return mixed
  * @throws \Exception
  */
 public static function receive($id, $data = [], $model = null)
 {
     $model = $model ?: static::findModel($id);
     $e_name = static::prefixEventName();
     $success = true;
     $model->scenario = MTransfer::SCENARIO_DEFAULT;
     $model->load($data, '');
     $model->status = MTransfer::STATUS_ISSUE;
     try {
         $transaction = Yii::$app->db->beginTransaction();
         Yii::$app->trigger($e_name . '_receive', new Event([$model]));
         if (!empty($data['details'])) {
             $transferDtls = ArrayHelper::index($model->transferDtls, 'id_product');
             Yii::$app->trigger($e_name . '_receive_head', new Event([$model]));
             foreach ($data['details'] as $dataDetail) {
                 $index = $dataDetail['id_product'];
                 if (isset($transferDtls[$index])) {
                     $detail = $transferDtls[$index];
                 } else {
                     $detail = new TransferDtl(['id_transfer' => $model->id_transfer, 'id_product' => $index, 'id_uom' => $dataDetail['id_uom_receive']]);
                 }
                 $detail->scenario = MTransfer::SCENARIO_RECEIVE;
                 $detail->load($dataDetail, '');
                 $success = $success && $detail->save();
                 Yii::$app->trigger($e_name . '_receive_body', new Event([$model, $detail]));
                 $transferDtls[$index] = $detail;
             }
             $model->populateRelation('transferDtls', array_values($transferDtls));
             if ($success) {
                 Yii::$app->trigger($e_name . '_receive_end', new Event([$model]));
             }
         }
         if ($success && $model->save()) {
             Yii::$app->trigger($e_name . '_received', new Event([$model]));
             $transaction->commit();
         } else {
             $transaction->rollBack();
             $success = false;
         }
     } catch (\Exception $exc) {
         $transaction->rollBack();
         throw $exc;
     }
     return [$success, $model];
 }
Пример #4
0
 */
?>
<div class="col-lg-9" style="padding-left: 0px;">
    <div class="panel panel-info">
        <table class="table table-striped">
            <tfoot>
                <tr>
                    <td colspan="4">
                        Product :
                        <?php 
echo AutoComplete::widget(['name' => 'product', 'id' => 'product', 'clientOptions' => ['source' => new JsExpression('yii.global.sourceProduct'), 'select' => new JsExpression('yii.receive.onProductSelect'), 'delay' => 100]]);
?>
                    </td>
                </tr>
            </tfoot>
            <?php 
echo TabularInput::widget(['id' => 'detail-grid', 'allModels' => $details, 'modelClass' => TransferDtl::className(), 'itemView' => '_item_detail', 'options' => ['tag' => 'tbody'], 'itemOptions' => ['tag' => 'tr']]);
?>
        </table>
    </div>
</div>

<?php 
$js = $this->render('_script', [], $this->context);
$this->registerJs($js, yii\web\View::POS_END);
AppHelper::bizConfig($this, ['masters' => ['products', 'barcodes', 'product_stock']]);
$js_ready = <<<JS
\$("#product").data("ui-autocomplete")._renderItem = yii.global.renderItem;
yii.receive.onReady();
JS;
$this->registerJs($js_ready);
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTransferDtl()
 {
     return $this->hasOne(TransferDtl::className(), ['id_transfer' => 'id_transfer', 'id_product' => 'id_product']);
 }