public function actionCreate()
 {
     Yii::import('ext.multimodelform.MultiModelForm');
     $model = new OrdenTrabajo();
     $detalle = new DetallesOt();
     $detallesValidados = array();
     if (isset($_POST['OrdenTrabajo'])) {
         $model->setAttributes($_POST['OrdenTrabajo']);
         if (MultiModelForm::validate($detalle, $detallesValidados, $detallesBorrados) && $model->save()) {
             $masterValues = array('id_ot' => $model->id);
             if (MultiModelForm::save($detalle, $detallesValidados, $detallesBorrados, $masterValues)) {
                 $factura = $this->loadModel($model->id_rf, 'RegistroFactura');
                 $suma_neto = $factura->sumarNeto();
                 $iva = Ivas::model()->findBySql('SELECT valor_iva FROM ivas ORDER BY fecha DESC');
                 $suma_bruto = $suma_neto * ($iva['valor_iva'] / 100 + 1);
                 $factura->setAttributes(array('total_neto' => $suma_neto, 'total_bruto' => round($suma_bruto)));
                 if ($factura->save()) {
                     $oDbConnection = Yii::app()->db;
                     $presid = Presupuesto::model()->findBySql('SELECT id FROM presupuesto where ano = :an ORDER BY modificado DESC', array(':an' => date("Y", strtotime($factura->fecha))));
                     $presupuesto = $this->loadModel($presid->id, 'Presupuesto');
                     $gastado = $oDbConnection->createCommand('select sum(detalles_ot.subtotal) as gasto from detalles_ot INNER JOIN orden_trabajo on orden_trabajo.id = detalles_ot.id_ot where YEAR(orden_trabajo.fecha) = :fec');
                     $gastado->bindParam(':fec', date("Y", strtotime($model->fecha)));
                     $gas = $gastado->queryRow();
                     $presupuesto->setAttributes(array('ppto_disponible' => $presupuesto->ppto_anual - $gas['gasto']));
                     if ($presupuesto->save()) {
                         $this->redirect(array('registrofactura/view', 'id' => $factura->id));
                     }
                 }
             }
         }
     }
     $this->render('create', array('model' => $model, 'detalle' => $detalle, 'detallesValidados' => $detallesValidados));
 }
 public function actionCreate()
 {
     Yii::import('ext.multimodelform.MultiModelForm');
     $model = new Compra();
     $member = new Detallecompra();
     $producto = new Productos();
     $proveedor = new Proveedor();
     $forma = new Formapago();
     $validatedMembers = array();
     //ensure an empty array
     if (isset($_POST['Compra'])) {
         $model->attributes = $_POST['Compra'];
         if (MultiModelForm::validate($member, $validatedMembers, $deleteItems) && $model->save()) {
             $masterValues = array('NumCompra' => $model->NumCompra);
             if (MultiModelForm::save($member, $validatedMembers, $deleteMembers, $masterValues)) {
                 //                        $this->redirect(array('view','id'=>$model->Id));
                 $usuario = $_POST['Compra']['Usuario'];
                 $numdocumento = $_POST['Compra']['NumCompra'];
                 $forpago = $_POST['Compra']['ForPago'];
                 $rut = $_POST['Compra']['CodProveedor'];
                 $codigo = $_POST['Detallecompra']['CodProducto'];
                 $descripcion = $_POST['Detallecompra']['Descripcion'];
                 $cantidad = $_POST['Detallecompra']['Cantidad'];
                 $saldoanterior = $_POST['Detallecompra']['Saldo'];
                 $precio = $_POST['Detallecompra']['Precio'];
                 $subtotal = $_POST['Detallecompra']['Subtotal'];
                 $iva = $_POST['Detallecompra']['Iva'];
                 $medida = $_POST['Detallecompra']['UniMedida'];
                 for ($i = 0; $i < count($codigo); $i++) {
                     $saldoactual[$i] = $saldoanterior[$i] + $cantidad[$i];
                     //                                Yii::app()->db->createCommand('update productos set CanExistencia = (CanExistencia + '.$cantidad[$i].'),PreCompra where CodProducto = "'.$codigo[$i].'"')->query();
                     Yii::app()->db->createCommand('update productos set CanExistencia = (CanExistencia + ' . $cantidad[$i] . '),PreCompra=' . $precio[$i] . ',Iva=' . $iva[$i] . ' where CodProducto = "' . $codigo[$i] . '"')->query();
                     yii::app()->db->createCommand('insert into kardex (Rut,ForPago,NumDocumento, CodProducto,Descripcion,UniMedida, TipoMovimiento, Cantidad, SaldoAnterior, SaldoActual, Precio,Iva, Subtotal,Usuario)' . ' Values("' . $rut . '",' . $forpago . ',' . $numdocumento . ',"' . $codigo[$i] . '","' . $descripcion[$i] . '","' . $medida[$i] . '","compra",' . $cantidad[$i] . ',' . $saldoanterior[$i] . ',' . $saldoactual[$i] . ',' . $precio[$i] . ',' . $iva[$i] . ',' . $subtotal[$i] . ',"' . $usuario . '")')->query();
                     //
                     //                                yii::app()->db->createCommand('insert into kardex (Fecha,NumDocumento, CodProducto, TipoMovimiento, Cantidad, SaldoAnterior, SaldoActual, Precio, Subtotal)'
                     //                                                            . ' Values(today,'.$numdocumento.','.$codigo[$i].',"compra",'.$cantidad[$i].','.$saldoanterior[$i].','.$saldoactual[$i].','.$precio[$i].','.$subtotal[$i].')')->query();
                     //
                 }
                 //                            $this->redirect(array('view','id'=>$model->NumCompra));
                 //                           $this->redirect(array('view','NumCompra'=>$model->NumCompra));
                 //                          $this->render('admin',array('model'=>$model,));
                 $this->redirect(array('view', 'id' => $model->Id));
             }
         }
     }
     $this->render('create', array('model' => $model, 'member' => $member, 'producto' => $producto, 'proveedor' => $proveedor, 'forma' => $forma, 'validatedMembers' => $validatedMembers));
 }
 public function actionCreate()
 {
     Yii::import('ext.multimodelform.MultiModelForm');
     $model = new FacturaCombustible();
     $detalle = new DetFacturaCombustible();
     $detallesValidados = array();
     if (isset($_POST['FacturaCombustible'])) {
         $model->setAttributes($_POST['FacturaCombustible']);
         if (MultiModelForm::validate($detalle, $detallesValidados, $detallesBorrados) && $model->save()) {
             $masterValues = array('id_factura_combustible' => $model->id);
             if (MultiModelForm::save($detalle, $detallesValidados, $detallesBorrados, $masterValues)) {
                 $this->redirect(array('facturacombustible/view', 'id' => $model->id));
             }
         }
     }
     $this->render('create', array('model' => $model, 'detalle' => $detalle, 'detallesValidados' => $detallesValidados));
 }
Exemple #4
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     Yii::import('ext.multimodelform.MultiModelForm');
     $model = new Group();
     $member = new Member();
     $validatedMembers = array();
     //ensure an empty array
     if (isset($_POST['Group'])) {
         $model->attributes = $_POST['Group'];
         if (MultiModelForm::validate($member, $validatedMembers, $deleteItems) && $model->save()) {
             //the value for the foreign key 'groupid'
             $masterValues = array('groupid' => $model->id);
             if (MultiModelForm::save($member, $validatedMembers, $deleteMembers, $masterValues)) {
                 $this->redirect(array('view', 'id' => $model->id));
             }
         }
     }
     $this->render('create', array('model' => $model, 'member' => $member, 'validatedMembers' => $validatedMembers));
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     Yii::import('ext.multimodelform.MultiModelForm');
     $model = new Gruposocio();
     $socioG = new SocioG();
     $validatedMembers = array();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Gruposocio'])) {
         $model->attributes = $_POST['Gruposocio'];
         if (MultiModelForm::validate($socioG, $validatedMembers, $deleteItems) && $model->save()) {
             $masterValues = array('grupo_id' => $model->id);
             if (MultiModelForm::save($socioG, $validatedMembers, $deleteMembers, $masterValues)) {
                 $this->redirect(array('registrosocio/create', 'id' => $model->id));
             }
         }
     }
     $this->render('create', array('model' => $model, 'socioG' => $socioG, 'validatedMembers' => $validatedMembers));
     $this->renderPartial('/site/buscarsalida');
 }
 public function actionCreate()
 {
     Yii::import('ext.multimodelform.MultiModelForm');
     $model = new Venta();
     $member = new Detalleventa();
     $producto = new Producto();
     $cliente = new Cliente();
     $validatedMembers = array();
     //ensure an empty array
     if (isset($_POST['Venta'])) {
         $model->attributes = $_POST['Venta'];
         if (MultiModelForm::validate($member, $validatedMembers, $deleteItems) && $model->save()) {
             //the value for the foreign key 'groupid'
             $masterValues = array('NumVenta' => $model->NumVenta);
             if (MultiModelForm::save($member, $validatedMembers, $deleteMembers, $masterValues)) {
                 $usuario = Yii::app()->user->name;
                 $numdocumento = $_POST['Venta']['NumVenta'];
                 $forpago = $_POST['Venta']['ForPago'];
                 $rut = $_POST['Venta']['CodCliente'];
                 $descripcion = $_POST['Detalleventa']['Descripcion'];
                 $codigo = $_POST['Detalleventa']['CodProducto'];
                 $cantidad = $_POST['Detalleventa']['Cantidad'];
                 $saldoanterior = $_POST['Detalleventa']['Saldo'];
                 $precio = $_POST['Detalleventa']['Precio'];
                 $subtotal = $_POST['Detalleventa']['Subtotal'];
                 $iva = $_POST['Detalleventa']['Iva'];
                 $unidad = $_POST['Detalleventa']['UniMedida'];
                 for ($i = 0; $i < count($codigo); $i++) {
                     $saldoactual[$i] = $saldoanterior[$i] - $cantidad[$i];
                     Yii::app()->db->createCommand('update productos set CanExistencia = (CanExistencia - ' . $cantidad[$i] . '),PreCompra=' . $precio[$i] . ',Iva=' . $iva[$i] . ' where CodProducto = "' . $codigo[$i] . '"')->query();
                     Yii::app()->db->createCommand('insert into kardex (Rut,ForPago,NumDocumento, Descripcion, CodProducto, UniMedida, TipoMovimiento, Cantidad, SaldoAnterior, SaldoActual, Precio,Iva, Subtotal,Usuario)' . ' Values("' . $rut . '",' . $forpago . ',' . $numdocumento . ',"' . $descripcion[$i] . '","' . $codigo[$i] . '","' . $unidad[$i] . '","Venta",' . $cantidad[$i] . ',' . $saldoanterior[$i] . ',' . $saldoactual[$i] . ',' . $precio[$i] . ',' . $iva[$i] . ',' . $subtotal[$i] . ',"' . $usuario . '")')->query();
                     //
                 }
                 $this->redirect(array('view', 'id' => $model->Id));
             }
         }
     }
     $this->render('create', array('model' => $model, 'member' => $member, 'validatedMembers' => $validatedMembers, 'cliente' => $cliente));
 }
 public function actionIndex()
 {
     Yii::app()->getComponent("bootstrap");
     Yii::import('ext.multimodelform.MultiModelForm');
     $sede = "";
     if (isset($_GET['sede']) && $_GET['sede'] != "") {
         $sede = CatSedes::model()->find("codigo_dane_sede=" . $_GET['sede']);
         $model = Acta::model()->find("CODIGO_DANE_SEDE='" . $_GET['sede'] . "'");
         if ($model == null) {
             $model = new Acta();
         }
         $participante = new Participante();
         $validatedMembers = array();
         //ensure an empty array
         $deleteMembers = array();
         if (isset($_POST['Acta'])) {
             $model->attributes = $_POST['Acta'];
             $imageData = $_POST['imageData'];
             $imageDecoded = base64_decode($imageData);
             $fileName = $model->CODIGO_DANE_ESTABLEDUCATIVO . "_" . $model->CODIGO_DANE_SEDE . "_" . date('Y-m-d-H-i-s') . ".png";
             $resultImageSaveProcess = file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/men19/uploads/" . $fileName, $imageDecoded);
             if ($resultImageSaveProcess) {
                 $model->FIRMA = $fileName;
             }
             $model->LLAVE = md5($model->CODIGO_DANE_SEDE . "-" . $model->FECHA_INICIAL . "-" . Parametro::model()->findByPk(1)->NO_CONTRATO);
             $model->FECHA_ACTUALIZACION = date("Y-m-d H:i:s");
             if (MultiModelForm::validate($participante, $validatedMembers, $deleteMembers) && $model->save()) {
                 //the value for the foreign key 'groupid'
                 $masterValues = array('ACTA_ID' => $model->IDACTA);
                 if (MultiModelForm::save($participante, $validatedMembers, $deleteMembers, $masterValues)) {
                     //Yii::app()->db->createCommand("CALL aud_procedimiento_desempate()")->execute();
                     $this->redirect(array('acta', 'id' => $model->IDACTA));
                 }
             }
         }
         $this->render('index', array('model' => $model, 'participante' => $participante, 'validatedMembers' => $validatedMembers, 'sede' => $sede));
     }
 }
Exemple #8
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     Yii::import('ext.multimodelform.MultiModelForm');
     $model = new Grupo();
     $chico = new Chico();
     $validatedMembers = array();
     //ensure an empty array
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Grupo'])) {
         $model->attributes = $_POST['Grupo'];
         if (MultiModelForm::validate($chico, $validatedMembers, $deleteItems) && $model->save()) {
             //the value for the foreign key 'groupid'
             $masterValues = array('grupo_id' => $model->id);
             if (MultiModelForm::save($chico, $validatedMembers, $deleteMembers, $masterValues)) {
                 //$this->redirect(array('view','id'=>$model->id));
                 $this->redirect(array('registro/create', 'id' => $model->id));
             }
         }
     }
     $this->render('create', array('model' => $model, 'chico' => $chico, 'validatedMembers' => $validatedMembers));
     $this->renderPartial('/site/buscarsalida');
 }