/** * 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); $intervalos = Intervalo::model()->findAll(); $profesionales = Profesional::model()->findAll(); $intHelper = array(); foreach ($intervalos as $intervalo) { $intHelper[$intervalo->intervalo_id] = $intervalo->intervalo_inicio . " - " . $intervalo->intervalo_termino; } $proHelper = array(); foreach ($profesionales as $profesional) { $proHelper[$profesional->profesional_id] = $profesional->profesional_nombre . " " . $profesional->profesional_apellido_paterno . " " . $profesional->profesional_apellido_materno; } // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['DiaIntervaloProfesional'])) { $sql = "\n SELECT\n *\n FROM\n dia_intervalo_profesional\n WHERE\n intervalo_id = " . $_POST['DiaIntervaloProfesional']['intervalo_id'] . "\n AND dia_id = " . $_POST['DiaIntervaloProfesional']['dia_id'] . "\n AND profesional_id = " . $_POST['DiaIntervaloProfesional']['profesional_id'] . "\n AND sucursal_id = " . $_POST['DiaIntervaloProfesional']['sucursal_id'] . " "; $objIntervalo = DiaIntervaloProfesional::model()->findBySql($sql); //echo "<pre>"; print_r($objIntervalo); echo "</pre>"; exit(); if (isset($objIntervalo)) { yii::app()->user->setFlash('errorIntervaloExiste', 'El intervalo existe'); } else { $model->attributes = $_POST['DiaIntervaloProfesional']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->dia_intervalo_profesional_id)); } } } $this->render('update', array('model' => $model, 'intHelper' => $intHelper, 'proHelper' => $proHelper)); }
/** * 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 Intervalo the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Intervalo::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }