?> <?php echo CHtml::Button('Agregar +', array('id' => 'agregar', 'name' => 'agregar', 'onclick' => 'send();')); ?> <?php echo $form->error($modelDiagnosticWork, 'work_id'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'status_order_id'); ?> <?php $statusArray = array(5, 8, 13); echo $form->dropDownList($model, 'status_order_id', Chtml::listData(StatusOrder::model()->findAllByAttributes(array("id" => $statusArray)), 'id', 'status'), array('prompt' => 'Seleccionar')); ?> <?php echo $form->error($model, 'status_order_id'); ?> </div> <div class="row buttons"> <?php echo CHtml::submitButton('Guardar', array('id' => 'guardar', 'name' => 'guardar')); ?> </div> <?php $this->endWidget();
/** * 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 StatusOrder the loaded model * @throws CHttpException */ public function loadModel($id) { $model = StatusOrder::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function actionSave($id, $status, $technician) { $modelOrder = $this->loadModel($id); $order_id_old = $modelOrder->status_order_id; $technician_old = $modelOrder->technician_order_id; $modelOrder->scenario = "ajaxupdate"; $modelOrder->status_order_id = $status; $modelOrder->technician_order_id = $technician; $modelOrder->save(); $log = new BlogOrder(); $log->order_id = $id; if ($order_id_old != $status) { $sstatus = StatusOrder::model()->findByPk($status); $log->activity = 'La orden cambio a "' . $sstatus->status . '"'; } if ($technician_old != $technician) { $suser = User::model()->findByPk($technician); $log->activity = "La orden se reasignó a " . $suser->name . " " . $suser->last_name; } $log->user_technical_id = Yii::app()->user->id; $log->date_hour = date('Y-m-d H:i:s'); $log->save(); if (!isset($_GET['ajax'])) { $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin')); } }