/** * 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); $modelRaws = Raw::model()->findAll(); $modelRecipeRaw = new RecipeRaw(); $modelIngredients = RecipeRaw::model()->findAllByAttributes(array("RecipeID" => $model->ID)); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Recipe'])) { $model->attributes = $_POST['Recipe']; if ($model->save()) { $this->redirect(array('admin')); } } $this->render('update', array('model' => $model, 'modelRaws' => $modelRaws, 'modelRecipeRaw' => $modelRecipeRaw, 'modelIngredients' => $modelIngredients)); }
FICHA DE PROVEEDORES </td> </tr> <tr> <td style="border: 1px solid #555;"><b>Proveedor</b></td> <td style="border: 1px solid #555;"><b>Direccion</b></td> <td style="border: 1px solid #555;"><b>Telefono</b></td> <td style="border: 1px solid #555;"><b>Persona contacto</b></td> <td style="border: 1px solid #555;"><b>NRGSEAA</b></td> <td style="border: 1px solid #555;"><b>Materia primas</b></td> </tr> <?php $modelProviders = Provider::model()->findAllByAttributes(array("UserID" => Yii::app()->user->ID)); foreach ($modelProviders as $Provider) { $modelRaws = Raw::model()->findAllByAttributes(array("ProviderID" => $Provider->ID, "UserID" => Yii::app()->user->ID)); $finalRaws = ""; foreach ($modelRaws as $Raw) { $finalRaws .= $Raw->Name . ", "; } ?> <tr> <td><?php echo $Provider->Name; ?> </td> <td><?php echo $Provider->Address; ?> </td> <td><?php
echo $form->labelEx($model, 'Date'); ?> <?php $this->widget('zii.widgets.jui.CJuiDatePicker', array('model' => $model, 'attribute' => 'Date', 'value' => $model->Date, 'options' => array('changeYear' => true, 'yearRange' => '1930', 'language' => 'es', 'dateFormat' => 'yy-mm-dd', 'monthNames' => array("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"), 'monthNamesShort' => array("Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Sep", "Oct", "Nov", "Dic"), 'dayNames' => array("Domingo", "Lunes", "Martes", "Miercoles", "Jueves", "Viernes", "Sabado"), 'dayNamesMin' => array('Do', 'Lu', 'Ma', 'Mi', 'Ju', 'Vi', 'Sa'), 'defaultDate' => $model->Date), 'htmlOptions' => array('placeholder' => date("Y-m-d")))); ?> <?php echo $form->error($model, 'Date'); ?> </div> <div class="row" style="float:left;margin-left:50px;"> <?php echo $form->labelEx($model, 'RawID'); ?> <?php echo $form->dropDownList($model, 'RawID', CHtml::listData(Raw::model()->findAll(), 'ID', 'Name'), array('empty' => '-- Selecciona la materia prima --', 'style' => 'width: 300px;')); ?> <?php echo $form->error($model, 'RawID'); ?> </div> <div style="clear:both;"></div> <div class="row" style="float:left;"> <?php echo $form->labelEx($model, 'Document'); ?> <?php echo $form->textField($model, 'Document', array('size' => 20, 'maxlength' => 50)); ?>
/** * 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 the ID of the model to be loaded */ public function loadModel($id) { $model = Raw::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }