public function actionAccidente($id)
 {
     $model = new Trabajadoraccidente();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     $model->Trabajador_idTrabajador = Trabajador::model()->findByAttributes(array('Persona_idPersona' => $model->Trabajador_idTrabajador));
     $model->Accidente_idAccidente = $id;
     if (isset($_POST['Trabajadoraccidente'])) {
         $model->attributes = $_POST['Trabajadoraccidente'];
         try {
             if ($model->save()) {
                 $this->redirect(array('/accidente/view', 'id' => $model->Accidente_idAccidente));
             }
         } catch (CDbException $e) {
             $this->redirect(array('/accidente/view', 'id' => $model->Accidente_idAccidente));
         }
     }
     $this->render('accidente', array('model' => $model));
 }
Esempio n. 2
0
 /**
  * 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 Trabajador the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Trabajador::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Esempio n. 3
0
echo $form->labelEx($model1, 'Fecha');
?>
		<?php 
$this->widget('zii.widgets.jui.CJuiDatePicker', array('model' => $model1, 'attribute' => 'Fecha', 'themeUrl' => Yii::app()->baseUrl . '/css/jui', 'theme' => 'softark', 'cssFile' => 'jquery-ui-1.9.2.custom.css', 'options' => array('showOn' => 'both', 'dateFormat' => 'yy-mm-dd', 'showOtherMonths' => true, 'selectOtherMonths' => true, 'changeYear' => true, 'changeMonth' => true, 'yearRange' => '1950:2099', 'minDate' => '1950-01-01', 'maxDate' => '2099-12-31', 'showButtonPanel' => true), 'htmlOptions' => array('size' => '10', 'maxlength' => '10', 'placeholder' => 'aaaa-mm-dd')));
?>
		<?php 
echo $form->error($model1, 'Fecha');
?>
	</div>    

	<div class="row">
		<?php 
echo $form->labelEx($model1, 'Cedula');
?>
		<?php 
echo $form->dropDownList($model1, 'Persona_idPersona', CHtml::listData(Trabajador::model()->with("personaIdPersona")->together()->findAll(), 'Persona_idPersona', 'personaIdPersona.Cedula'), array('empty' => 'Seleccione un trabajador por su cédula'));
?>
		<?php 
echo $form->error($model1, 'Persona_idPersona');
?>
	</div>

	<div class="row">
		<?php 
echo $form->labelEx($model1, 'GrupoSanguineo');
?>
		<?php 
echo $form->dropDownList($model1, 'GrupoSanguineo', array('' => '', 'A' => 'A', 'B' => 'B', 'O' => 'O', 'AB' => 'AB'));
?>
		<?php 
echo $form->error($model1, 'GrupoSanguineo');