public function afterSave() { $items = PfOrderItems::model()->findAllByAttributes(['order_id' => $this->order_id]); $m3 = $loadingMeters = 0; foreach ($items as $item) { $m3 += $item->m3; $loadingMeters += $item->load_meters; } $order = PfOrder::model()->findByPk($this->order_id); $order->m3 = $m3; $order->loading_meters = $loadingMeters; $order->save(); parent::afterSave(); }
<?php Yii::app()->clientScript->registerCss('rel_grid', ' .rel-grid-view {margin-top:-60px;} .rel-grid-view div.summary {height: 60px;} '); $moveButton = $this->widget('bootstrap.widgets.TbButton', ['buttonType' => 'Button', 'type' => 'primary', 'size' => 'mini', 'icon' => 'icon-random', 'url' => ['//ldm/pfOrderItems/getOther', 'order_id' => $modelMain->primaryKey], 'htmlOptions' => ['title' => Yii::t('LdmModule.crud', 'Get item from other order'), 'data-toggle' => 'tooltip'], 'visible' => Yii::app()->user->checkAccess('Administrator')], true); $addButton = $this->widget('bootstrap.widgets.TbButton', ['buttonType' => 'Button', 'type' => 'primary', 'size' => 'mini', 'icon' => 'icon-plus', 'url' => ['//ldm/pfOrderItems/create', 'order_id' => $modelMain->primaryKey], 'htmlOptions' => ['title' => Yii::t('LdmModule.crud', 'Add new Item'), 'data-toggle' => 'tooltip']], true); $criteria = new CDbCriteria(); $criteria->compare('order_id', $modelMain->primaryKey); $orderItems = PfOrderItems::model()->searchClient($criteria)->getData(); $boxTable = $this->renderPartial('_box_table', ['orderItems' => $orderItems], true); $this->widget('AceBoxTable', array('header_text' => Yii::t('LdmModule.model', 'Order Items'), 'toolbar' => $moveButton . $addButton, 'tableHead' => ['Manufacturer', 'Planed ready date', 'Load meters', 'Cubic meters', 'Notes'], 'body' => $boxTable));
/** * * @param type $id * @return PfOrderItems * @throws CHttpException */ public function loadModel($id) { $m = PfOrderItems::model(); // apply scope, if available $scopes = $m->scopes(); if (isset($scopes[$this->scope])) { $m->{$this->scope}(); } $model = $m->findByPk($id); if ($model === null) { throw new CHttpException(404, Yii::t('LdmModule.crud', 'The requested page does not exist.')); } return $model; }
</div> </div> <?php $form = $this->beginWidget('TbActiveForm', ['id' => 'pf-order-item-form', 'enableAjaxValidation' => true, 'enableClientValidation' => true, 'htmlOptions' => ['enctype' => '']]); ?> <div class="row"> <div class="span12"> <div class="form-horizontal"> <div class="control-group"> <div class='control-label'> Select Item </div> <div class='controls'> <span class="tooltip-wrapper" data-toggle='tooltip' data-placement="right"> <?php $items = PfOrderItems::model()->findPlaningOtherOrderItems($order_id); $listData = CHtml::listData($items, 'id', 'label'); echo CHtml::dropDownList('order_item_id', null, $listData); ?> </span> </div> </div> </div> </div> </div> <?php $this->endWidget(); ?> <div class="clearfix"> <div class="btn-toolbar pull-left">