/** * Authenticates the password. * This is the 'authenticate' validator as declared in rules(). */ public function validarcentroalmacen($attribute, $params) { $centro = Centros::model()->findByPk($this->centro); $almacen = Almacenes::model()->findByPk($this->almacen); if (is_null($centro)) { $this->adderror('centro', 'El centro no existe'); } if (is_null($almacen)) { $this->adderror('almacen', 'El almacen no existe'); } if (!$almacen->codcen == $this->centro) { $this->adderror('almacen', 'Este almacen no correponde a este centro'); } }
/** * 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 Almacenes the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Almacenes::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public static function Validacentro($centro, $almacen) { $retorno = true; $almacenes = Almacenes::model()->findByPk($almacen); if (!is_null($almacenes)) { if (is_null($almacenes->centros)) { $retorno = false; } else { if ($almacenes->centros->codcen != trim($centro)) { $retorno = false; } } } else { $retorno = false; } return $retorno; }
<?php echo $form->error($model, 'codcen'); ?> </div> <div> <?php echo $form->labelEx($model, 'codalm'); ?> <?php $datos = CHtml::listData(Almacenes::model()->findAll(array('order' => 'nomal')), 'codalm', 'nomal'); echo $form->DropDownList($model, 'codalm', $datos, array('empty' => '--Llene el centro--', 'disabled' => $model->isNewRecord ? '' : 'disabled')); ?> <?php echo $form->error($model, 'codalm'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'periodocontable'); ?> <?php echo $form->textField($model, 'periodocontable', array('size' => 4, 'maxlength' => 4));
public function actioncargaalmacenes1() { $criteria = new CDbCriteria(); $criteria->addCondition("codcen=:proved"); $valor = $_POST['cargainForm']['centro']; //echo "el valor es ..".$valor; //Yii::app()->end(); $data = CHtml::listData(Almacenes::model()->findAll("codcen='" . $valor . "'"), "codalm", "nomal"); echo CHtml::tag('option', array('value' => null), CHtml::encode('Escoja un almacen'), true); foreach ($data as $value => $name) { echo CHtml::tag('option', array('value' => $value), CHtml::encode($name), true); } }
<div style="float: left; "> <?php echo $form->labelEx($model, 'codentro'); ?> <?php $datos = CHtml::listData(Centros::model()->findAll(array('order' => 'nomcen')), 'codcen', 'nomcen'); echo $form->DropDownList($model, 'codentro', $datos, array('empty' => '--Seleccione un centro --')); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'codigoalma'); ?> <?php $datos6 = CHtml::listData(Almacenes::model()->findAll(), 'codalm', 'nomal'); echo $form->DropDownList($model, 'codigoalma', $datos6, array('empty' => '--Seleccione un almacen --')); ?> </div> <div class="row"> <?php echo $form->label($model, 'texto'); ?> <?php echo $form->textField($model, 'texto', array('size' => 30, 'maxlength' => 30)); ?> </div> <div class="row"> <?php
public function checkcentros($attribute, $params) { $modeloalmacenes = Almacenes::model()->findByPk($this->codalmacen); if (is_null($modeloalmacenes)) { $this->adderror('codalmacen', 'Este almacen no existe'); } else { if (!$modeloalmacenes->codcen === $this->codcentro) { $this->adderror('codalmacen', 'Este almacen no existe en el centro seleccionado'); } } }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Maestrocompo(); $model->valorespordefecto(); // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($model); if (isset($_POST['Maestrocompo'])) { $model->attributes = $_POST['Maestrocompo']; $transaccion = $model->dbConnection->beginTransaction(); if ($model->save()) { //actualizamos tambien las tablas inventario y maestrodetalle //inventario $centros = Centros::model()->findAll(); foreach ($centros as $fila) { $modeloporcentros = new Maestrodetallecentros(); $modeloporcentros->setAttributes(array('hcodart' => $model->codigo, 'codcen' => $fila->codcen, 'catvalor' => '', 'iqf' => '0'), true); // var_dump($fila); $modeloalmacenes = Almacenes::model()->findall("codcen=:vcdocen", array(":vcdocen" => $fila->codcen)); foreach ($modeloalmacenes as $filaalmacen) { //$contact->setIsNewRecord(true); $modeloinventario = new Alinventario(); $modelodetalle = new Maestrodetalle(); $modelodetalle->setAttributes(array('codart' => $model->codigo, 'codcentro' => $fila->codcen, 'codal' => $filaalmacen->codalm, 'codgrupoventas' => '001', 'canaldist' => '01', 'sujetolote' => '0', 'canteconomica' => 0, 'cantreposic' => 0, 'cantreorden' => 0, 'leadtime' => 0, 'controlprecio' => 'V'), true); $modeloinventario->setAttributes(array('codart' => $model->codigo, 'codcen' => $fila->codcen, 'codalm' => $filaalmacen->codalm, 'cantlibre' => 0, 'canttran' => 0, 'cantres' => 0, 'ubicacion' => '', 'lote' => '', 'codmon' => Yii::app()->params['monedadef']), true); // var_dump($modeloinventario); /* echo "<br><br><br>"; var_dump($modelodetalle->attributes); echo "<br><br><br>";*/ // var_dump($modeloinventario->attributes); if (!$modeloinventario->save() or !$modelodetalle->save()) { $transaccion->rollback(); throw new CHttpException(404, 'No se pudieron grabar los datos detalles '); } else { } } //bucle de almacenes if (!$modeloporcentros->save()) { $transaccion->rollback(); throw new CHttpException(404, 'No se pudieron grabar los datos del modelo poR CENTROS '); } } ///FIN DEL BUCLE CENTROS $transaccion->commit(); Yii::app()->user->setFlash('success', "Se ha creado el material " . $model->codigo); } else { /// SSI HUBO UN ERRRO AL GRANAR EL MATERIAL $transaccion->rollback(); throw new CHttpException(404, 'No se pudieron grabar los datos del material '); } $this->redirect(array('update', 'id' => $model->codigo)); } /// si no se puede grabar $this->render('create', array('model' => $model, 'habilitado' => '')); }
public function checkalmacen($attribute, $params) { if (Almacenes::model()->find("codalm =:xcodalm and codcen=:xcodcen", array(":xcodalm" => $this->alam, ":xcodcen" => $this->codcent)) == null) { $this->adderror('alam', 'Este almacen no corresponde a este centro'); } }