/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Choferes(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Choferes'])) { $model->attributes = $_POST['Choferes']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->brevete)); } } $this->render('create', array('model' => $model)); }
public function beforeSave() { if ($this->isNewRecord) { //$mij=null; ///$this->usuario=Yii::app()->user->name; $this->c_salida = '0'; //$command = Yii::app()->db->createCommand(" select nextval('sq_guias') "); //$this->n_guia= $command->queryScalar(); //$this->codocu='101'; $this->codobjeto = '001'; $this->codocu = '500'; $this->c_estgui = '99'; /**************************************************************** * Sacar la direccion ****************************************************************/ $criteria = new CDbCriteria(); $criteria->addCondition(" c_hcod='" . $this->c_coclig . "' "); $row = Direcciones::model()->findall($criteria); if (!is_null($row[0])) { $this->n_direcformaldes = $row->n_direc; } $criteria = new CDbCriteria(); $criteria->addCondition(" c_hcod='" . $this->c_codtra . "' "); $row = Direcciones::model()->findall($criteria); if (!is_null($row[0])) { $this->n_directran = $row->n_direc; } /******************************************************************* *********************************************************************/ /* SACANDO EL CORRELATIVO /* * */ } else { if ($this->c_estgui == '99') { //SI SE TRATA DE UNA GUIA NUEVA COLOCARLE 'PREVIO' $this->c_estgui = '10'; } if (is_null($this->c_numgui)) { $this->c_serie = substr($this->cod_cen, 0, 3); $criterio = new CDBcriteria(); $criterio->addcondition("cod_cen=:vcodcentro and c_salida='0' "); $criterio->params = array(":vcodcentro" => $this->cod_cen); /*var_dump( $criterio->condition); echo "<br>";*/ $this->c_numgui = $this->correlativo('c_numgui', $criterio, ""); } //$this->ultimares=" ".strtoupper(trim($this->usuario=Yii::app()->user->name))." ".date("H:i")." :".$this->ultimares; } /*********VERIFICANDO LOS CHOFERES****************/ $mij = Choferes::model()->find("brevete=:vbrevete", array(":vbrevete" => trim($this->c_licon))); if (is_null($mij)) { //si el brevete no esta registrado pues insertar en nla tabla choferes $nuevomodelo = new Choferes(); $nuevomodelo->nombre = $this->c_trans; $nuevomodelo->brevete = $this->c_licon; $nuevomodelo->save(); } return parent::beforeSave(); }
public function beforeSave() { if ($this->isNewRecord) { $mij = null; $this->c_salida = '1'; $this->codobjeto = '001'; $this->codocu = '100'; $this->c_estgui = '99'; //para que no lo agarre la vista VW-GUIA HASTA QUE GRABE TODO EL DETALLE /**************************************************************** * Sacar la direccion ****************************************************************/ $this->sacadireccion(); } else { if ($this->c_estgui == '99') { //SI SE TRATA DE UNA GUIA NUEVA COLOCARLE 'PREVIO' $this->c_estgui = '10'; } //$this->ultimares=" ".strtoupper(trim($this->usuario=Yii::app()->user->name))." ".date("H:i")." :".$this->ultimares; } /*********VERIFICANDO LOS CHOFERES****************/ $mij = Choferes::model()->find("brevete=:vbrevete", array(":vbrevete" => trim($this->c_licon))); if (is_null($mij)) { //si el brevete no esta registrado pues insertar en nla tabla choferes $nuevomodelo = new Choferes(); $nuevomodelo->nombre = $this->c_trans; $nuevomodelo->brevete = $this->c_licon; $nuevomodelo->save(); } return parent::beforeSave(); }