public function actionAddtrans() { if (isset($_POST['component_id'])) { //print_r($_POST['id']); /* $criteria = new CDbCriteria(); $criteria->join = "JOIN angkutan on(angkutan.id_angkutan = t.id_angkutan)"; $criteria->condition = "id_detail = ".$_POST['id'][0]; */ $components = Components::model()->findByPk($_POST['component_id']); //{"id_detail":"1","nama":"Boeng 757 Jakarta - Surabaya","harga":"350","id_angkutan":"1"} $data["component_id"] = $components->id; echo CJSON::encode($data); } }
public function actionCekcomponents() { if (strpos($_GET['term'], "(") === false) { $condition = $_GET['term']; $criteria = new CDbCriteria(); $criteria->condition = " component_name like '%{$condition}%'"; $criteria->limit = 7; $info = Components::model()->findAll($criteria); $arModels = array(); foreach ($info as $model) { $arModels[] = array('id' => $model->id, 'label' => $model->component_name, 'value' => $model->component_name); } echo CJSON::encode($arModels); } }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return Components the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Components::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
<?php /* @var $this TravelerController */ /* @var $model Traveler */ $this->breadcrumbs = array(Yii::t('default', 'Travelers') => array('index'), Yii::t('default', 'Search')); $this->menu = array(array('label' => Yii::t('default', 'List Traveler'), 'url' => array('index')), array('label' => Yii::t('default', 'Create Traveler'), 'url' => array('create'), 'visible' => Yii::app()->user->getState('role') > 1)); ?> <h1><?php echo Yii::t('default', 'Search Travelers'); ?> </h1> <p> <?php echo Yii::t('default', 'You may optionally enter a comparison operator (<b><</b>, <b><=</b>, <b>></b>, <b>>=</b>, <b><></b> or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.'); ?> </p> <?php $this->widget('zii.widgets.grid.CGridView', array('id' => 'traveler-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'selectableRows' => 1, 'selectionChanged' => 'function(id){ location.href = "' . $this->createUrl('view') . '/id/"+$.fn.yiiGridView.getSelection(id);}', 'columns' => array(array('name' => 'componentId', 'filter' => CHtml::listData(Components::model()->getProjectGroups(), 'id', 'identifier', 'projectIdentifier'), 'value' => 'Components::Model()->FindByPk($data->componentId)->identifier'), 'name', array('name' => 'userId', 'filter' => CHtml::listData(User::model()->findAll(), 'id', 'username'), 'value' => 'User::Model()->FindByPk($data->userId)->username'), 'revision', array('name' => 'status', 'filter' => CHtml::activeDropDownList($model, 'status', $model->statusOptions, array('prompt' => Yii::t('default', ''))), 'value' => '$data->getStatusText()'))));
public function sortComponents($position) { $i = 1; foreach ($position as $id) { $model = Components::model()->findByPk($id); $model->position = $i; $model->save(); $i++; } }
/** * Lists all models. */ public function actionIndex() { $this->layout = "//layouts/column3"; $criteria = new CDbCriteria(); $criteria->join = "JOIN components c ON projectId = t.id JOIN equipment ON componentId = c.id"; $criteria->order = 't.position'; $criteria->distinct = true; $this->projects = Project::model()->findAll($criteria); $criteria2 = new CDbCriteria(); $criteria2->join = "JOIN equipment ON componentId = t.id"; $criteria2->distinct = true; $this->components = Components::model()->findAll($criteria2); $this->render('index', array('query' => Equipment::model()->getEquipmentsForTree(), 'equipments' => Equipment::model()->with('component')->findAll(array('order' => 'projectId, componentId, t.id')))); }
echo CHtml::activeDropDownList($model, 'componentId', $data, array('empty' => "--" . Yii::t('default', 'Select a Component') . "--")); ?> <?php echo $form->error($model, 'componentId'); ?> </div> <?php } ?> <?php } elseif ($model->status == 1) { ?> <div class="row"> <?php echo $form->labelEx($model, 'componentId'); $data = CHtml::listData(Components::model()->getProjectGroups(), 'id', 'text', 'group'); ?> <?php echo CHtml::activeDropDownList($model, 'componentId', $data, array('empty' => "--" . Yii::t('default', 'Select a Component') . "--")); ?> <?php echo $form->error($model, 'componentId'); ?> </div> <?php } ?> <div class="row"> <?php echo $form->labelEx($model, 'name'); ?>
<?php /* @var $this EquipmentController */ /* @var $model Equipment */ /* @var $form CActiveForm */ ?> <?php $this->breadcrumbs = array(Yii::t('default', 'Equipments') => array('equipment/index'), $model->identifier => array('equipment/view', 'id' => $model->id), Yii::t('default', 'Attached Equipments') => array('equipment/attached', 'id' => $model->id), Yii::t('default', 'Attach Equipments')); $this->menu = array(array('label' => Yii::t('default', 'List Equipment'), 'url' => array('index')), array('label' => Yii::t('default', 'List Assembly'), 'url' => array('assembly'))); Yii::app()->clientScript->registerScript('attach', "\n \$(':checkbox:checked').each(function(){\n \$(this).closest('tr').addClass('selected');\n });\n\$(':checkbox').change(function(){\n id = \$(this).val();\n \$.ajax({\n url: '{$model->id}',\n type: 'POST',\n data: 'equipmentId='+id,\n });\n \$(this).closest('tr').toggleClass('selected');\n});\n"); ?> <h1><?php echo Yii::t('default', 'Attach Equipments'); ?> </h1> <?php $projectId = $model->component->projectId; $data = $search->search(array('condition' => "t.id NOT IN ({$model->notIn}) AND componentId IN ({$model->inProject}) and (parentId = {$model->id} OR parentId IS NULL)")); $data->pagination->pageSize = $model->count(); $this->widget('zii.widgets.grid.CGridView', array('dataProvider' => $data, 'id' => 'equipment-grid', 'selectableRows' => 0, 'enablePagination' => false, 'filter' => $search, 'columns' => array(array('class' => 'CCheckBoxColumn', 'id' => 'chk', 'checked' => '$data->parentId', 'headerTemplate' => '', 'selectableRows' => 2), array('name' => 'componentId', 'filter' => CHtml::listData(Components::model()->findAll("projectId = {$projectId}"), 'id', 'name'), 'value' => 'Components::Model()->FindByPk($data->componentId)->name'), 'identifier', 'description')));
/** * Lists all models. */ public function actionIndex() { $this->layout = "//layouts/column3"; $criteria = new CDbCriteria(); $criteria->join = "JOIN components c ON projectId = t.id JOIN traveler ON componentId = c.id"; $criteria->order = "t.position"; $criteria->distinct = true; $this->projects = Project::model()->findAll($criteria); $criteria2 = new CDbCriteria(); $criteria2->join = "JOIN traveler ON componentId = t.id"; $criteria2->distinct = true; $this->components = Components::model()->findAll($criteria2); $this->render('index', array('query' => Traveler::model()->getTravelerForTree())); }
</h1> <ul id='treeview' class='filetree'> <?php $ul = ""; $projectId = 0; $componentId = 0; foreach ($query as $q) { $pname = $q['pname']; $pid = $q['pid']; $cname = $q['cname']; $cid = $q['cid']; $ename = $q['ename']; $eid = $q['eid']; $project = Project::model()->findByPk($pid); $component = Components::model()->findByPk($cid); $travelers = Equipment::model()->findByPk($eid)->travelers; if ($projectId != $pid) { $projectId = $pid; $componentId = 0; $status = 0; echo "{$ul}{$ul}"; $ul = ""; if ($project->hide) { $style = ""; } else { $style = "style='display:none'"; } ?> <li class="p<?php echo $pid;
public function afterSave() { $component_id = $this->getAttribute('component_id'); $stok = intval(Components::model()->findByPk($component_id)->stock); $balance = $stok + intval($this->getAttribute('qty')); Components::model()->updateByPk($component_id, array('stock' => $balance)); StockComponents::model()->updateByPk($component_id, array('stock' => $balance)); $this->updateByPk($this->id_trans, array('balance_history' => $balance)); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new ComponentSuplier(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['ComponentSuplier'])) { $model->attributes = $_POST['ComponentSuplier']; if ($model->save()) { $price = ComponentSuplier::model()->findAllByAttributes(array('component_id' => $model->component_id)); if ($price != null) { $i = 0; $price_inc = 0; $rate_price = 0; foreach ($price as $dataprice) { $price_inc = $price_inc + floatval($dataprice->price); $i++; //var_dump($dataprice->price)."<br><br>"; } $rate_price = intval($price_inc / $i); Components::model()->updateByPk($model->component_id, array('rate_price' => $rate_price)); } else { $rate_price = $model->price; Components::model()->updateByPk($model->component_id, array('rate_price' => $rate_price)); } //var_dump($price); $this->redirect(array('view', 'id' => $model->id)); } } $this->render('index', array('model' => $model)); }