/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { $model = $this->loadModel($id); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Commodity'])) { $model->attributes = $_POST['Commodity']; if ($_POST['Commodity']['categories'] !== '') { $model->categories = implode(' , ', $_POST['Commodity']['categories']); } //to string $model->save(); $categories = $_POST['Commodity']['categories']; $count = count($categories); foreach ($categories as $category) { $comcat_model = new CommodityCategory(); $comcat_model->commodity_id = $model->id; $comcat_model->category_id = $category; $temp2 = $comcat_model->commodity_id; $temp = $comcat_model->category_id; $newmodel = Category::model()->findByAttributes(array('id' => $temp)); if ($category == 1) { $comcat_model->path = $newmodel->name; } else { $newmodel1 = CommodityCategory::model()->findByAttributes(array('category_id' => $temp - 1, 'commodity_id' => $temp2)); $comcat_model->path = $newmodel1->path . "->" . $newmodel->name; //$comcat_model->path = $newmodel->name; } $comcat_model->save(); } if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('update', array('model' => $model)); }
echo $form->textField($model, 'belongs_to', array('span' => 2, 'readonly' => true, 'value' => $consumable['category_id'])); ?> </div> </div> </div> </tr> <tr> <div class="row"> <div class="col-md-3 col-sm-6"> <div class="span2"><?php echo $form->labelEx($model, 'transfer_to', array('class' => 'inline-labels')); ?> </div> <div class="span3"><?php echo $form->dropDownList($model, 'transfer_to', CHtml::listData(CommodityCategory::model()->findAll('path!=:path AND commodity_id=:commodity_id', array('path' => $consumable['category_id'], 'commodity_id' => $_GET['commodity_id'])), 'path', 'path'), array('span' => 2, 'prompt' => '---')); ?> </div> </div> </div> </tr> </table> <div style="text-align: center;"> <?php echo TbHtml::submitButton($model->isNewRecord ? 'Submit' : 'Update', array('color' => TbHtml::BUTTON_COLOR_SUCCESS, 'size' => TbHtml::BUTTON_SIZE_DEFAULT, 'onclick' => 'js:document.location.href="http://localhost/asset_management/index.php/consumable/admin"')); ?> <?php echo TbHtml::button('Cancel', array('color' => TbHtml::BUTTON_COLOR_DANGER, 'size' => TbHtml::BUTTON_SIZE_DEFAULT, 'onclick' => 'history.go(-1)'));
<span class="icon-bar"></span> </button> <a class="brand" href="<?php echo Yii::app()->homeUrl; ?> "> <?php echo "AM " . Yii::app()->user->getState("org_name"); ?> </a> <?php $allCommodities = Commodity::model()->findAllByAttributes(array('is_deleted' => 0)); foreach ($allCommodities as $commodity) { $commodityName = lcfirst($commodity['name']); $notDeletedCategories = MyUtility::getNotDeleted('category'); $categories = CommodityCategory::model()->findAllByAttributes(array('commodity_id' => $commodity['id'], 'category_id' => $notDeletedCategories)); foreach ($categories as $cat) { //$categoryRow = Category::model()->findByAttributes(array('id'=>$cat['category_id'])); $categoryList[] = array('label' => '<i class="icon-info-sign"></i> ' . $cat['path'], 'url' => array("/{$commodityName}/admin", 'category_id' => $cat['path'])); } $categoryList[] = array('label' => '<i class="icon-info-sign"></i> Show All', 'url' => array('/' . $commodity['name'] . '/admin')); $items[] = array('url' => array('/' . $commodity['name'] . '/admin'), 'label' => ' <i class="icon-info-sign"></i> ' . $commodity['name'], 'items' => $categoryList); $categoryList = array(); } $items[] = array('label' => '<i class="icon-info-sign"></i> files', 'url' => array("/fm/entry/index/form/16", 'category_id' => $cat['path'])); ?> <!--div class="nav-collapse collapse"--> <div id="myslidemenu" class="jqueryslidemenu"> <?php $this->widget('zii.widgets.CMenu', array('items' => array(array('label' => '<i class="icon-home"></i> Home', 'url' => array('/dash')), array('label' => '<b class="icon-inbox"></b> Commodities', 'url' => '#', 'linkOptions' => array('class' => 'dropdown-toggle', 'data-toggle' => 'dropdown'), 'itemOptions' => array('class' => 'dropdown'), 'items' => $items), array('label' => '<b class="icon-inbox"></b> Administration ', 'url' => array('/user/viewpage'), 'items' => array(array('label' => '<i class="icon-map-marker"></i> Location', 'url' => array('/location/tree')), array('label' => '<i class="icon-user"></i> Suppliers', 'url' => array('/supplier/admin')), array('label' => '<i class="icon-user"></i> Manufacturers', 'url' => array('/manufacturer/admin')), array('label' => '<i class="icon-folder-close"></i> Commodities', 'url' => array('/commodity/admin')), array('label' => '<i class="icon-folder-close"></i> Categories', 'url' => array('/category/admin')), array('label' => '<i class="icon-user"></i> Users', 'url' => array('/user/admin')), array('label' => '<i class="icon-users"></i> Groups', 'url' => array('/group/admin')), array('label' => '<i class="icon-user"></i> Departments', 'url' => array('/dept/admin')), array('label' => '<i class="icon-user"></i> Organisations', 'url' => array('/organisation/admin')), array('label' => '<i class="icon-tasks"></i> Status', 'url' => array('/status/admin')))), array('label' => '<i class="icon-cog"></i> Settings', 'url' => '#', 'linkOptions' => array('class' => 'dropdown-toggle', 'data-toggle' => 'dropdown'), 'itemOptions' => array('class' => 'dropdown'), 'items' => array(array('label' => '<i class="icon-print"></i> Paper Type', 'url' => array('/papertype/admin')), array('label' => '<i class="icon-print"></i> Print Label', 'url' => array('/label/printallform')), array('label' => '<i class="icon-tasks"></i> Set Stock Name', 'url' => array('/stockname/create')), array('label' => '<i class="icon-barcode"></i> Set Barcode', 'url' => array('/barcodedetail/create')), array('label' => '<i class="icon-tasks"></i> Link Commodity', 'url' => array('/link/admin')), array('label' => '<i class="icon-inr"></i> Currencies', 'url' => array('/currency/admin')))), array('label' => '<i class="icon-folder-close"></i> Report', 'url' => array('/report/admin'), 'items' => array(array('label' => '<i class="icon-folder-close"></i> Full Report', 'url' => array('/report/admin')), array('label' => '<i class="icon-folder-close"></i> User Report', 'url' => array('/reportuser/admin')), array('label' => '<i class="icon-folder-close"></i> Location Report', 'url' => array('/reportloc/admin')))), array('label' => '<i class="icon-folder-close"></i> Files', 'url' => array(''), 'items' => array(array('label' => '<i class="icon-tasks"></i> File Open', 'url' => array('/fm/entry/index/form/16')), array('label' => '<i class="icon-tasks"></i> File Type', 'url' => array('/filetype/admin')), array('label' => '<i class="icon-tasks"></i> File Status', 'url' => array('/filestatus/admin')), array('label' => '<i class="icon-tasks"></i> File Schedule', 'url' => array('/filemaintenanceschedule/admin')))), array('label' => '<i class="icon-user"></i> Login', 'url' => array('/site/login'), 'visible' => Yii::app()->user->isGuest), array('label' => '<i class="icon-arrow-right"></i> Logout (' . Yii::app()->user->name . ')', 'url' => array('/site/logout'), 'visible' => !Yii::app()->user->isGuest)), 'encodeLabel' => false, 'htmlOptions' => array('class' => 'nav pull-left'), 'submenuHtmlOptions' => array('class' => 'dropdown-menu')));
<div class="span2"><?php echo $form->labelEx($model, 'name', array('class' => 'inline-labels')); ?> </div> <div class="span3"><?php echo $form->textField($model, 'name', array('span' => 3, 'maxlength' => 50)); ?> </div> <div class="span2"><?php echo $form->labelEx($model, 'category_id', array('class' => 'inline-labels')); ?> </div> <?php // GET ONLY NOT DELETED CATEGORIES $notDeletedCategories = MyUtility::getNotDeleted('category'); $ccRow = CommodityCategory::model()->findAllByAttributes(array('commodity_id' => $value, 'category_id' => $notDeletedCategories)); ?> <div class="span3"><?php echo $form->dropDownList($model, 'category_id', CHtml::listData($ccRow, 'path', 'path'), array('span' => 2, 'prompt' => '---')); ?> </div> </div> </div> </tr> <tr> <div class="row"> <div class="col-md-3 col-sm-6"> <div class="span2"><?php echo $form->labelEx($model, 'location_id', array('class' => 'inline-labels')); ?> </div>
public function actionGeneratePdf() { $this->layout = 'pdf'; $model = new CommodityCategory('search'); if (isset($_GET['CommodityCategory'])) { $model->attributes = $_GET['CommodityCategory']; } // to execute the filters (if is the case) $dataProvider = $model->search(); $dataProvider->pagination = false; $mPDF1 = Yii::app()->ePdf->mpdf(); # You can easily override default constructor's params $mPDF1 = Yii::app()->ePdf->mpdf('', 'A5'); # renderPartial (only 'view' of current controller) $mPDF1->WriteHTML($this->renderPartial('admin', array('model' => $model), true)); # Outputs ready PDF $mPDF1->Output(); }