Пример #1
0
 public function resolveType()
 {
     if ($config = Configs::movement($this->reff_type) !== null) {
         $this->type = $config['type'];
     } else {
         $this->addError('reff_type', "Reference type {$this->reff_type} not recognize");
     }
 }
Пример #2
0
 protected function getReference($reff_type, $reff_id, $origin = [])
 {
     $config = Configs::movement($reff_type);
     $class = $config['class'];
     $relation = $config['relation'];
     $modelRef = $class::findOne($reff_id);
     $refDtls = $modelRef->{$relation};
     $details = ArrayHelper::index($origin, 'product_id');
     foreach ($refDtls as $refDtl) {
         if (!isset($details[$refDtl->product_id])) {
             $details[$refDtl->product_id] = new GoodsMovementDtl(['product_id' => $refDtl->product_id]);
         }
         if (!empty($config['apply_method'])) {
             call_user_func([$refDtl, $config['apply_method']], $details[$refDtl->product_id]);
         }
     }
     return [$modelRef, array_values($details)];
 }
Пример #3
0
    {
        if (($config = $this->reffConfig) !== null && isset($config['link'])) {
            return $this->reffDoc ? Html::a($this->reffDoc->number, [$config['link'], 'id' => $this->reffDoc->id]) : null;
        }
        return null;
    }
    /**
     * 
     * @param sting $name
     * @return boolean
     */
    public function visibleButton($name)
    {
        switch ($name) {
            case 'update':
            case 'delete':
            case 'apply':
                return $this->status == static::STATUS_DRAFT;
            default:
                return true;
        }
    }
    public function behaviors()
    {
        $behaviors = parent::behaviors();
        return array_merge($behaviors, [['class' => 'mdm\\converter\\DateConverter', 'attributes' => ['Date' => 'date']], ['class' => 'mdm\\converter\\EnumConverter', 'attributes' => ['nmType' => 'type'], 'enumPrefix' => 'TYPE_']]);
    }
}
// Extend reference
Configs::merge('movement', '@app/config/biz/movement.php');
Пример #4
0
     */
    public function getInvoiceDtls()
    {
        return $this->hasMany(InvoiceDtl::className(), ['invoice_id' => 'id']);
    }
    public function getNmReffType()
    {
        if (($config = $this->reffConfig) !== null) {
            return isset($config['name']) ? $config['name'] : null;
        }
        return null;
    }
    public function getReffLink()
    {
        if (($config = $this->reffConfig) !== null && isset($config['link'])) {
            return $this->reffDoc ? Html::a($this->reffDoc->number, [$config['link'], 'id' => $this->reffDoc->id]) : null;
        }
        return null;
    }
    /**
     * @inheritdoc
     */
    public function behaviors()
    {
        $behaviors = parent::behaviors();
        return array_merge($behaviors, [['class' => 'mdm\\converter\\DateConverter', 'attributes' => ['Date' => 'date', 'DueDate' => 'due_date']], ['class' => 'mdm\\converter\\EnumConverter', 'attributes' => ['nmType' => 'type'], 'enumPrefix' => 'TYPE_']]);
    }
}
// Extend reference
Configs::merge('invoice', '@app/config/biz/invoice.php');
Пример #5
0
/* @var $searchModel app\models\inventory\searchs\GoodsMovement */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Goods Movement';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="row purchase-index">    
    <section class="col-lg-12">
        <?php 
echo Toolbar::widget(['items' => [['label' => '', 'url' => ['print-html'], 'icon' => 'fa fa-print', 'linkOptions' => ['class' => 'btn btn-default btn-sm disabled', 'target' => '_blank', 'title' => 'Html Print']], ['label' => '', 'url' => ['print-pdf'], 'icon' => 'fa fa-file', 'linkOptions' => ['class' => 'btn btn-default btn-sm disabled', 'target' => '_blank', 'title' => 'Export to Pdf']], ['label' => '', 'url' => ['print-xsl'], 'icon' => 'fa fa-table', 'linkOptions' => ['class' => 'btn btn-default btn-sm disabled', 'target' => '_blank', 'title' => 'Export to Excel']]]]) . '&nbsp;&nbsp;';
echo ActionToolbar::widget(['items' => [['label' => 'Create New', 'url' => ['create', 'type' => 100], 'icon' => 'fa fa-plus-square'], ['label' => 'Update', 'url' => ['update'], 'icon' => 'fa fa-pencil', 'linkOptions' => ['class' => 'disabled']], ['label' => 'Delete', 'url' => ['delete'], 'icon' => 'fa fa-trash-o', 'linkOptions' => ['class' => 'disabled', 'data' => ['confirm' => 'Are you sure you want to delete this item?', 'method' => 'post']]], ['label' => 'Goods Movement List', 'url' => ['index'], 'icon' => 'fa fa-list', 'linkOptions' => ['class' => 'disabled']]]]);
?>
        <div class="box box-info">
            <div class="box-body no-padding">
                <?php 
$filterRef = [];
foreach (Configs::movement() as $key => $value) {
    $filterRef[$key] = isset($value['name']) ? $value['name'] : $key;
}
?>
                <?php 
\yii\widgets\Pjax::begin(['enablePushState' => false]);
?>
                <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'layout' => "{items}\n{pager}", 'tableOptions' => ['class' => 'table table-striped'], 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'number', 'date:date', ['attribute' => 'reff_type', 'value' => 'nmReffType', 'filter' => $filterRef], ['label' => 'Reference', 'value' => 'reffLink', 'format' => 'raw'], ['attribute' => 'warehouse_id', 'value' => 'warehouse.name', 'filter' => Warehouse::selectOptions()], ['attribute' => 'status', 'format' => 'raw', 'filter' => [GoodsMovement::STATUS_DRAFT => 'Draft', GoodsMovement::STATUS_PROCESS => 'Proccess', GoodsMovement::STATUS_CLOSE => 'Closed'], 'value' => function ($data) {
    $color = $data->status == GoodsMovement::STATUS_DRAFT ? 'danger' : 'success';
    $color = $data->status == GoodsMovement::STATUS_PROCESS ? 'info' : $color;
    $color = $data->status == GoodsMovement::STATUS_CLOSE ? 'success' : $color;
    return Html::tag('small', $data->nmStatus, ['class' => 'label label-' . $color]);
}], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{view}{update}{delete}{apply}']]]);
?>
                <?php