示例#1
0
 public function beforeSave()
 {
     if ($this->isNewRecord) {
         // $this->creadopor=Yii::app()->user->name;
         // $this->creadoel=Yii::app()->user->name;
         $this->prefijo = '7';
         $this->codigotra = Numeromaximo::numero($this, 'correlativo', 'maximovalor', 3, 'prefijo');
         //$this->cod_estado='01';
         //$this->c_salida='1';
     } else {
         //$this->ultimares=" ".strtoupper(trim($this->usuario=Yii::app()->user->name))." ".date("H:i")." :".$this->ultimares;
     }
     if ($this->oldattributes['iduser'] != $this->iduser) {
         if (!is_null($this->iduser)) {
             $registros = Yii::app()->db->createCommand(" select idfield  from\tcruge_field t where t.fieldname='codtra' ")->queryAll();
             if (count($registros) > 0) {
                 foreach ($registros as $row) {
                     $cuantoshay = Yii::app()->db->createCommand(" SELECT count(idfieldvalue) from cruge_fieldvalue where iduser="******" and idfield=" . $row['idfield'] . " ")->queryScalar();
                     if ($cuantoshay == 0) {
                         $comando = Yii::app()->db->createCommand(" INSERT INTO cruge_fieldvalue(iduser,idfield,value) values (" . $this->iduser . "," . $row['idfield'] . ",'" . $this->codigotra . "') ");
                         $comando->execute();
                     }
                     if ($cuantoshay == 1) {
                         $comando = Yii::app()->db->createCommand(" UPDATE cruge_fieldvalue  SET value= '" . $this->codigotra . "' where  iduser="******" and idfield=" . $row['idfield'] . " ");
                         $comando->execute();
                     }
                 }
             }
         }
     }
     return parent::beforeSave();
 }
示例#2
0
文件: Kardex.php 项目: hipogea/zega
 public function beforeSave()
 {
     if ($this->isNewRecord) {
         $this->creadopor = Yii::app()->user->name;
         $this->numdoc = Numeromaximo::numero($this->model(), 'correlativo', 'maximovalor', 12, 'prefijo');
         //$this->codigo='34343434';
     } else {
         //$this->ultimares=" ".strtoupper(trim($this->usuario=Yii::app()->user->name))." ".date("H:i")." :".$this->ultimares;
     }
     return parent::beforeSave();
 }
 public function beforeSave()
 {
     if ($this->isNewRecord) {
         $this->creadopor = Yii::app()->user->isGuest ? 'Invitado' : Yii::app()->user->name;
         // $this->creadoel=Yii::app()->user->name;
         $this->correlativo = Numeromaximo::numero($this->model(), 'correlativo', 'maximovalor', 5);
         $this->codigoestado = '01';
         //$this->c_salida='1';
     } else {
         //$this->ultimares=" ".strtoupper(trim($this->usuario=Yii::app()->user->name))." ".date("H:i")." :".$this->ultimares;
     }
     return parent::beforeSave();
 }
示例#4
0
文件: Mot.php 项目: hipogea/zega
 /**
  * Retrieves a list of models based on the current search/filter conditions.
  * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
  */
 public function beforeSave()
 {
     if ($this->isNewRecord) {
         //$this->created = new CDbExpression('NOW()');
         // $nuevovalor=new CDbExpression('SELEC MAX(NUMERO)');
         //$this->numero=new CDbExpression('SELECt MAX(NUMERO) from mot_materiales');
         //$this->modified = new CDbExpression('NOW()');
         $this->numero = Numeromaximo::numero($this, 'numero', 'maximovalor', 11);
         $this->codtraba = '0001';
         //$this->creadorpor='0001';
     }
     return parent::beforeSave();
 }
示例#5
0
文件: Lugares.php 项目: hipogea/zega
 public function beforeSave()
 {
     if ($this->isNewRecord) {
         //$this->creadopor=Yii::app()->user->name;
         // $this->creadoel=Yii::app()->user->name;
         //$this->codlugar='000001';
         $this->codlugar = Numeromaximo::numero($this->model(), 'codlugar', 'maximovalor', 6);
         //$this->cod_estado='01';
         //$this->c_salida='1';
     } else {
         //$this->ultimares=" ".strtoupper(trim($this->usuario=Yii::app()->user->name))." ".date("H:i")." :".$this->ultimares;
     }
     return parent::beforeSave();
 }
示例#6
0
文件: Cargos.php 项目: hipogea/zega
 public function beforeSave()
 {
     if ($this->isNewRecord) {
         ///$this->usuario=Yii::app()->user->name;
         $this->coddocucargo = '260';
         $this->cnumcargo = Numeromaximo::numero($this->model(), 'cnumcargo', 'maximovalor', 10);
         //$this->cnumcargo=
         //$command = Yii::app()->db->createCommand(" select nextval('sq_guias') ");
         //$this->n_guia= $command->queryScalar();
         $this->codigoestadocargo = '99';
         //para que no lo agarre la vista VW-GUIA  HASTA QUE GRABE TODO EL DETALLE
     } else {
         if ($this->c_estgui == '99') {
             //SI SE TRATA DE UNA GUIA NUEVA COLOCARLE 'PREVIO'
             $this->codigoestadocargo = '10';
         }
         //$this->ultimares=" ".strtoupper(trim($this->usuario=Yii::app()->user->name))." ".date("H:i")." :".$this->ultimares;
     }
     return parent::beforeSave();
 }
示例#7
0
文件: Clipro.php 项目: hipogea/zega
 public function beforeSave()
 {
     if ($this->isNewRecord) {
         $this->creadopor = Yii::app()->user->name;
         // $this->creadoel=Yii::app()->user->name;
         $this->prefijo = '97';
         $this->codocu = '360';
         $this->codestado = '10';
         //creado
         $gg = new Numeromaximo();
         $this->codpro = $gg->numero($this, 'correlativo', 'maximovalor', 4, 'prefijo');
         //  $this->codpro='97'.Numeromaximo::numero($this,'correlativo','maximovalor',4);
         // $this->codpro='97'.Numeromaximo::numero($this->model(),'codpro','maximovalor',4);
         //$this->cod_estado='01';
         //$this->c_salida='1';
     } else {
         //$this->ultimares=" ".strtoupper(trim($this->usuario=Yii::app()->user->name))." ".date("H:i")." :".$this->ultimares;
     }
     return parent::beforeSave();
 }
示例#8
0
 public function beforeSave()
 {
     $prefix = "public_";
     if ($this->isNewRecord) {
         $mij = null;
         //$command = Yii::app()->db->createCommand(" select nextval('sq_guias') ");
         //$this->n_guia= $command->queryScalar();
         $this->codocu = '340';
         //$this->codobjeto='001';
         $this->fechadoc = date("Y-m-d H:i:s");
         $this->creadopor = Yii::app()->user->name;
         $this->iduser = Yii::app()->user->id;
         $this->estado = '99';
         //para que no lo agarre la vista VW-GUIA  HASTA QUE GRABE TODO EL DETALLE
         //$this->numero=Numeromaximo::numero($this->model(),'numero','maximovalor',10);
     } else {
         if ($this->estado == '99') {
             //SI SE TRATA DE UNA GUIA NUEVA COLOCARLE 'PREVIO'
             $this->estado = '10';
             //$this->c_serie=substr($this->cod_cen, 1);
             //	$this->numero=Numeromaximo::numero($this->model(),'numero','maximovalor',10);
             $gg = new Numeromaximo();
             $this->numero = $gg->numero($this, 'correlativ', 'maximovalor', 7, 'codocu');
             // validate user input and redirect to the previous page if valid
             $command = Yii::app()->db->createCommand(" UPDATE " . $prefix . "desolpe1 set est='10' where hidsolpe=" . $this->id . " ");
             $command->execute();
         }
     }
     return parent::beforeSave();
 }
示例#9
0
文件: Coti.php 项目: hipogea/zega
 public function beforeSave()
 {
     if ($this->isNewRecord) {
         //buscano el igv
         $this->nigv = Igv::model()->findByPk(1)->valor;
         //
         $this->codestado = '99';
         $this->coddocu = '110';
         $this->fecdoc = date("Y-m-d");
     } else {
         if ($this->codestado == '99') {
             $this->codestado = '10';
             $this->numcot = Numeromaximo::numero($this->model(), 'numcot', 'maximovalor', 8);
             //ahora el hijo
             $command = Yii::app()->db->createCommand("update dcotmateriales set estadodetalle='10'  where hidguia =" . $this->idguia . " ");
             $command->execute();
         }
         $command = Yii::app()->db->createCommand("update dcotmateriales set estadodetalle='10'  where hidguia =" . $this->idguia . " and  estadodetalle ='99' ");
         $command->execute();
     }
     //$this->ultimares=" ".strtoupper(trim($this->usuario=Yii::app()->user->name))." ".date("H:i")." :".$this->ultimares;
     return parent::beforeSave();
 }
示例#10
0
 public function beforeSave()
 {
     if ($this->isNewRecord) {
         $this->creadopor = Yii::app()->user->name;
         //$this->codigo='34343434';
         $this->codocu = '101';
         $this->cestadovale = '99';
         //$this->codobjeto='001';
         //$gg=new Numeromaximo;
         $this->numvale = Numeromaximo::numero($this, 'correlativo', 'maximovalor', 8, 'codcentro');
         $this->fechacre = date("Y-m-d H:i:s");
     } else {
         //if ($this->cestadovale=='01')
         //$this->numvale=Numeromaximo::numero($this->model(),'correlativo','maximovalor',8,'codcentro');
         //$this->ultimares=" ".strtoupper(trim($this->usuario=Yii::app()->user->name))." ".date("H:i")." :".$this->ultimares;
     }
     return parent::beforeSave();
 }
示例#11
0
 public function actionprueba()
 {
     $modelo = new Maestrocompo();
     $modelo->codtipo = '12';
     echo Numeromaximo::numero($modelo, 'correl', 'maximovalor', 6, 'codtipo');
 }
示例#12
0
 public function beforeSave()
 {
     if ($this->isNewRecord) {
         //$this->creadopor=Yii::app()->user->name;
         $this->codocu = '901';
         //Si es un tipo de material que hereda el atributo ROTATIVO
         ///eNOTOICES COLOCARLO AUTOMATRICAMENTE
         if (Maestrotipos::model()->findBypK($this->codtipo)->esrotativo == '1') {
             $this->esrotativo = '1';
         }
         //$g=new Numeromaximo;
         $this->codigo = Numeromaximo::numero($this, 'correl', 'maximovalor', 6, 'codtipo');
         //$this->codigo='34343434';
     } else {
         //$this->ultimares=" ".strtoupper(trim($this->usuario=Yii::app()->user->name))." ".date("H:i")." :".$this->ultimares;
     }
     return parent::beforeSave();
 }
示例#13
0
 public function beforeSave()
 {
     if ($this->isNewRecord) {
         $this->creadopor = Yii::app()->user->name;
         $this->codtrabajador = yii::app()->user->um->getFieldValue(Yii::app()->user->id, 'codtra');
         //$this->codigo='34343434';
         $this->codocu = '101';
         $this->cestadovale = '99';
         //$this->codobjeto='001';
         //$gg=new Numeromaximo;
     } else {
         if ($this->oldAttributes['cestadovale'] != $this->cestadovale and $this->cestadovale == ESTADO_VALE_CREADO) {
             $this->numvale = Numeromaximo::numero($this, 'correlativo', 'maximovalor', 8, 'codcentro');
             $this->fechacre = date("Y-m-d H:i:s");
         }
         //if ($this->cestadovale=='01')
         //$this->numvale=Numeromaximo::numero($this->model(),'correlativo','maximovalor',8,'codcentro');
         //$this->ultimares=" ".strtoupper(trim($this->usuario=Yii::app()->user->name))." ".date("H:i")." :".$this->ultimares;
     }
     return parent::beforeSave();
 }