public function getMultiModelForm() { $criteria = new CDbCriteria(); $criteria->order = 'patente ASC'; $detfactcomb = array('elements' => array('id_vehiculo' => array('type' => 'dropdownlist', 'items' => array('' => '---') + GxHtml::listDataEx(Vehiculos::model()->findAllAttributes(null, true, $criteria))), 'nro_guia' => array('type' => 'text'), 'litros' => array('type' => 'text', 'onblur' => 'totallitros(),calcularTotal();', 'onkeypress' => 'if (event.keyCode == 13){totallitros(),calcularTotal()};'))); return $detfactcomb; }
public function actionACPatente() { if (isset($_GET['term'])) { $searchTerm = $_GET['term']; $result = array(); $patentes = Vehiculos::model()->findAll('patente LIKE :nombre', array(':nombre' => '%' . $searchTerm . '%')); foreach ($patentes as $patente) { $result[] = array('label' => $patente->patente, 'value' => $patente->patente, 'id' => $patente->id); } echo CJSON::encode($result); } }
<?php $this->breadcrumbs = array('Bitacorases' => array('index'), 'Administrar'); $this->menu = array(array('label' => 'Listar Bitacoras', 'url' => array('index')), array('label' => 'Agregar Bitacoras', 'url' => array('create'))); Yii::app()->clientScript->registerScript('search', "\n\$('.search-button').click(function(){\n\t\$('.search-form').toggle();\n\treturn false;\n});\n\$('.search-form form').submit(function(){\n\t\$.fn.yiiGridView.update('bitacoras-grid', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n"); ?> <h1>Administrar Bitacoras</h1> <?php echo CHtml::link('Busqueda Avanzada', '#', array('class' => 'search-button')); ?> <div class="search-form" style="display:none"> <?php $this->renderPartial('_search', array('model' => $model)); ?> </div><!-- search-form --> <?php $this->widget('zii.widgets.grid.CGridView', array('id' => 'bitacoras-grid', 'dataProvider' => $model->search(), 'emptyText' => 'No hay resultados', 'summaryText' => 'Mostrando del {start} al {end} de {count} resultado(s).', 'pager' => array('header' => '', 'prevPageLabel' => 'Anterior', 'nextPageLabel' => 'Siguiente'), 'filter' => $model, 'columns' => array(array('name' => 'id_vehiculo', 'value' => 'GxHtml::valueEx($data->idVehiculo)', 'filter' => GxHtml::listDataEx(Vehiculos::model()->findAllAttributes(null, true)), 'htmlOptions' => array('width' => '85')), 'fecha', 'kilometraje_inicial', 'kilometraje_final', 'litros_adicionales', array('class' => 'CButtonColumn', 'header' => 'Opciones', 'htmlOptions' => array('width' => 120), 'template' => '{view}{update}{delete}', 'buttons' => array('view' => array('label' => 'Ver', 'url' => 'Yii::app()->createUrl("bitacoras/view", array("id"=>$data->id))', 'imageUrl' => Yii::app()->baseUrl . '/images/ver.png'), 'update' => array('label' => 'Editar', 'url' => 'Yii::app()->createUrl("bitacoras/update", array("id"=>$data->id))', 'imageUrl' => Yii::app()->baseUrl . '/images/editar.png'), 'delete' => array('label' => 'Borrar', 'url' => 'Yii::app()->createUrl("bitacoras/delete", array("id"=>$data->id))', 'imageUrl' => Yii::app()->baseUrl . '/images/delete.png'))))));
public function actionACVehi() { if (isset($_GET['term'])) { $searchTerm = $_GET['term']; $result = array(); $gevehis = Vehiculos::model()->findAll('patente LIKE :patente', array(':patente' => '%' . $searchTerm . '%')); foreach ($gevehis as $gevehi) { $result[] = array('label' => $gevehi->patente, 'value' => $gevehi->patente, 'id' => $gevehi->id, 'combu' => $gevehi->idCombustible); } echo CJSON::encode($result); } }
public function actionSubir() { if (isset($_FILES['excel']) && !empty($_FILES['excel']['name'])) { extract($_POST); if (isset($action) && $action == "upload") { $archivo = $_FILES['excel']['name']; $destino = "xls/bak_" . $archivo; $p = PlanillasCopec::model()->find('nombre = :archivo', array(':archivo' => $archivo)); if ($p != null && !isset($sobreescribir)) { Yii::app()->user->setFlash('notice', "El Archivo " . $archivo . " ya existe!"); $this->render('subir'); } else { if (copy($_FILES['excel']['tmp_name'], $destino)) { Yii::import('application.extensions.Classes.PHPExcel', true); $objReader = new PHPExcel_Reader_Excel5(); $objPHPExcel = $objReader->load("xls/bak_" . $archivo); $objPHPExcel->setActiveSheetIndex(0); $valid = true; $i = '2'; $gas = false; $petroleo = false; if (preg_match("/g93/i", $objPHPExcel->getActiveSheet()->getCell("F2")->getValue())) { $gas = true; } else { if (preg_match("/g95/i", $objPHPExcel->getActiveSheet()->getCell("F2")->getValue())) { $gas = true; } else { if (preg_match("/g95/i", $objPHPExcel->getActiveSheet()->getCell("F2")->getValue())) { $gas = true; } else { if (preg_match("/diesel/i", $objPHPExcel->getActiveSheet()->getCell("H2")->getValue())) { $petroleo = true; } } } } if ($p != null) { $planilla = $this->loadModel($p->id, 'PlanillasCopec'); $planilla->delete(); $planilla = new PlanillasCopec(); $planilla->nombre = $archivo; } else { $planilla = new PlanillasCopec(); $planilla->nombre = $archivo; } if ($gas) { $planilla->tipo_planilla = '1'; } else { $planilla->tipo_planilla = '0'; } if ($gas || $petroleo) { if ($planilla->save()) { Yii::app()->user->setFlash('success', $archivo . " Subido con Exito!"); if ($petroleo) { while ($objPHPExcel->getActiveSheet()->getCell("F" . $i)->getValue() != '') { $diesel[$i] = new Diesel(); $vehiculo = Vehiculos::model()->find('patente like :pate', array('pate' => substr(str_replace(array('-', ' '), '', trim($objPHPExcel->getActiveSheet()->getCell('D' . $i)->getCalculatedValue())), 0, 6) . '%')); $diesel[$i]->setAttributes(array('id_planilla' => $planilla->id, 'nro_factura' => $objPHPExcel->getActiveSheet()->getCell('B' . $i)->getCalculatedValue(), 'id_vehiculo' => isset($vehiculo->id) ? $vehiculo->id : '', 'fecha' => date("Y-m-d", PHPExcel_Shared_Date::ExcelToPHP($objPHPExcel->getActiveSheet()->getCell('E' . $i)->getCalculatedValue())), 'region' => $objPHPExcel->getActiveSheet()->getCell('F' . $i)->getCalculatedValue(), 'estacion' => $objPHPExcel->getActiveSheet()->getCell('G' . $i)->getCalculatedValue(), 'litros' => str_replace(',', '.', $objPHPExcel->getActiveSheet()->getCell('I' . $i)->getCalculatedValue()), 'precio_u' => intval($objPHPExcel->getActiveSheet()->getCell('J' . $i)->getCalculatedValue()), 'especifico' => intval($objPHPExcel->getActiveSheet()->getCell('K' . $i)->getCalculatedValue()), 'variable' => intval($objPHPExcel->getActiveSheet()->getCell('L' . $i)->getCalculatedValue()), 'total' => str_replace(array(',', '.'), '', $objPHPExcel->getActiveSheet()->getCell('M' . $i)->getCalculatedValue()), 'costo_empresa' => intval((str_replace(array(',', '.'), '', $objPHPExcel->getActiveSheet()->getCell('M' . $i)->getCalculatedValue()) - intval($objPHPExcel->getActiveSheet()->getCell('K' . $i)->getCalculatedValue())) / 1.19 + intval($objPHPExcel->getActiveSheet()->getCell('K' . $i)->getCalculatedValue())), 'nro_guia' => $objPHPExcel->getActiveSheet()->getCell('N' . $i)->getCalculatedValue(), 'rollo' => $objPHPExcel->getActiveSheet()->getCell('O' . $i)->getCalculatedValue())); $valid = $diesel[$i]->validate() && $valid; if ($valid == false) { $invalido[$i] = $i; } $i++; } if ($valid) { foreach ($diesel as $di) { $di->save(); } $this->redirect(array('planillascopec/view', 'id' => $planilla->id)); } else { Yii::app()->user->setFlash('error', "No se han podido validar los datos!"); $this->render('subir', array('invalido' => $invalido, 'diesel' => $diesel)); } } elseif ($gas) { while ($objPHPExcel->getActiveSheet()->getCell("F" . $i)->getValue() != '') { $gasolina[$i] = new Gasolina(); $vehiculo = Vehiculos::model()->find('patente like :pate', array('pate' => substr(str_replace(array('-', ' '), '', trim($objPHPExcel->getActiveSheet()->getCell('D' . $i)->getCalculatedValue())), 0, 6) . '%')); $gasolina[$i]->setAttributes(array('id_planilla' => $planilla->id, 'nro_factura' => $objPHPExcel->getActiveSheet()->getCell('B' . $i)->getCalculatedValue(), 'id_vehiculo' => isset($vehiculo->id) ? $vehiculo->id : '', 'tarjeta' => $objPHPExcel->getActiveSheet()->getCell('E' . $i)->getCalculatedValue(), 'fecha' => date("Y-m-d", PHPExcel_Shared_Date::ExcelToPHP($objPHPExcel->getActiveSheet()->getCell('G' . $i)->getCalculatedValue())), 'hora' => date("H:i:s", PHPExcel_Shared_Date::ExcelToPHP($objPHPExcel->getActiveSheet()->getCell('H' . $i)->getCalculatedValue())), 'comuna' => $objPHPExcel->getActiveSheet()->getCell('I' . $i)->getCalculatedValue(), 'direccion' => $objPHPExcel->getActiveSheet()->getCell('J' . $i)->getCalculatedValue(), 'nro_transaccion' => $objPHPExcel->getActiveSheet()->getCell('K' . $i)->getCalculatedValue(), 'precio_u' => intval($objPHPExcel->getActiveSheet()->getCell('M' . $i)->getCalculatedValue()), 'litros' => str_replace(',', '.', $objPHPExcel->getActiveSheet()->getCell('N' . $i)->getCalculatedValue()), 'especifico' => intval($especifico * str_replace(',', '.', $objPHPExcel->getActiveSheet()->getCell('N' . $i)->getCalculatedValue())), 'total' => str_replace(array(',', '.'), '', $objPHPExcel->getActiveSheet()->getCell('O' . $i)->getCalculatedValue()), 'costo_empresa' => intval((str_replace(array(',', '.'), '', $objPHPExcel->getActiveSheet()->getCell('O' . $i)->getCalculatedValue()) - $especifico * str_replace(',', '.', $objPHPExcel->getActiveSheet()->getCell('N' . $i)->getCalculatedValue())) / 1.19 + $especifico * str_replace(',', '.', $objPHPExcel->getActiveSheet()->getCell('N' . $i)->getCalculatedValue())))); $valid = $gasolina[$i]->validate() && $valid; if ($valid == false) { $invalido[$i] = $i; } $i++; } if ($valid) { foreach ($gasolina as $ga) { $ga->save(); } $this->redirect(array('planillascopec/view', 'id' => $planilla->id)); } else { Yii::app()->user->setFlash('error', "No se han podido validar los datos!"); $this->render('subir', array('invalido' => $invalido, 'gasolina' => $gasolina)); } } } else { unlink("xls/bak_" . $archivo); Yii::app()->user->setFlash('error', "No se han podido validar los datos!"); $this->render('subir', array('invalido' => $invalido, 'gasolina' => $gasolina)); } } else { unlink("xls/bak_" . $archivo); Yii::app()->user->setFlash('error', "Planilla no valida!"); $this->render('subir', array('planilla' => $planilla)); } } else { Yii::app()->user->setFlash('error', "Error al cargar archivo!"); } } } else { Yii::app()->user->setFlash('error', "Necesitas importar el archivo!"); } } else { if (isset($_FILES['excel']) && empty($_FILES['excel']['name'])) { Yii::app()->user->setFlash('notice', "No ha seleccionado archivo o esta vacio."); } $this->render('subir'); } }
<?php echo $form->labelEx($model, 'id_planilla'); ?> <?php echo $form->dropDownList($model, 'id_planilla', GxHtml::listDataEx(PlanillasCopec::model()->findAllAttributes(null, true))); ?> <?php echo $form->error($model, 'id_planilla'); ?> </div><!-- row --> <div class="row"> <?php echo $form->labelEx($model, 'id_vehiculo'); ?> <?php echo $form->dropDownList($model, 'id_vehiculo', GxHtml::listDataEx(Vehiculos::model()->findAllAttributes(null, true))); ?> <?php echo $form->error($model, 'id_vehiculo'); ?> </div><!-- row --> <div class="row"> <?php echo $form->labelEx($model, 'tarjeta'); ?> <?php echo $form->textField($model, 'tarjeta', array('maxlength' => 20)); ?> <?php echo $form->error($model, 'tarjeta'); ?>
<div class="wide form"> <?php $form = $this->beginWidget('CActiveForm', array('action' => Yii::app()->createUrl($this->route), 'method' => 'get')); ?> <?php $criteria = new CDbCriteria(); $criteria->order = 'patente ASC'; ?> <div class="row"> <?php echo $form->label($model, 'id_vehiculo'); ?> <?php echo $form->dropDownList($model, 'id_vehiculo', GxHtml::listDataEx(Vehiculos::model()->findAllAttributes(null, true, $criteria)), array('prompt' => Yii::t('app', 'All'))); ?> </div> <div class="row"> <?php echo $form->label($model, 'fecha'); ?> <?php $form->widget('zii.widgets.jui.CJuiDatePicker', array('model' => $model, 'attribute' => 'fecha', 'language' => 'es', 'value' => $model->fecha, 'options' => array('showButtonPanel' => true, 'changeYear' => true, 'dateFormat' => 'yy-mm-dd'))); ?> </div> <div class="row"> <?php echo $form->label($model, 'kilometraje_inicial');
<?php $this->breadcrumbs = array($model->label(2) => array('index'), Yii::t('app', 'Manage')); $this->menu = array(array('label' => Yii::t('app', 'List') . ' ' . $model->label(2), 'url' => array('index')), array('label' => Yii::t('app', 'Create') . ' ' . $model->label(), 'url' => array('create'))); Yii::app()->clientScript->registerScript('search', "\n\$('.search-button').click(function(){\n\t\$('.search-form').toggle();\n\treturn false;\n});\n\$('.search-form form').submit(function(){\n\t\$.fn.yiiGridView.update('gasolina-grid', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n"); ?> <h1><?php echo Yii::t('app', 'Manage') . ' ' . GxHtml::encode($model->label(2)); ?> </h1> <p> You may optionally enter a comparison operator (<, <=, >, >=, <> or =) at the beginning of each of your search values to specify how the comparison should be done. </p> <?php echo GxHtml::link(Yii::t('app', 'Advanced Search'), '#', array('class' => 'search-button')); ?> <div class="search-form"> <?php $this->renderPartial('_search', array('model' => $model)); ?> </div><!-- search-form --> <?php $this->widget('zii.widgets.grid.CGridView', array('id' => 'gasolina-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array('id', array('name' => 'id_planilla', 'value' => 'GxHtml::valueEx($data->idPlanilla)', 'filter' => GxHtml::listDataEx(PlanillasCopec::model()->findAllAttributes(null, true))), array('name' => 'id_vehiculo', 'value' => 'GxHtml::valueEx($data->idVehiculo)', 'filter' => GxHtml::listDataEx(Vehiculos::model()->findAllAttributes(null, true))), 'tarjeta', 'fecha', 'hora', array('class' => 'CButtonColumn'))));
<?php $this->breadcrumbs = array($model->label(2) => array('index'), Yii::t('app', 'Administrar')); $this->menu = array(array('label' => Yii::t('app', 'Listar') . ' ' . $model->label(2), 'url' => array('index')), array('label' => Yii::t('app', 'Agregar') . ' ' . $model->label(), 'url' => array('create'))); Yii::app()->clientScript->registerScript('search', "\n\$('.search-button').click(function(){\n\t\$('.search-form').toggle();\n\treturn false;\n});\n\$('.search-form form').submit(function(){\n\t\$.fn.yiiGridView.update('orden-trabajo-grid', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n"); ?> <h1><?php echo Yii::t('app', 'Administrar') . ' ' . GxHtml::encode($model->label(2)); ?> </h1> <?php echo GxHtml::link(Yii::t('app', 'Busqueda Avanzada'), '#', array('class' => 'search-button')); ?> <div class="search-form" style="display:none"> <?php $this->renderPartial('_search', array('model' => $model)); ?> </div><!-- search-form --> <?php $criteria = new CDbCriteria(); $criteria->order = 'patente ASC'; $this->widget('zii.widgets.grid.CGridView', array('id' => 'orden-trabajo-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'emptyText' => 'No hay resultados', 'summaryText' => 'Mostrando del {start} al {end} de {count} resultado(s).', 'pager' => array('header' => '', 'prevPageLabel' => 'Anterior', 'nextPageLabel' => 'Siguiente'), 'columns' => array('nro_guia', array('name' => 'id_vehiculo', 'value' => 'GxHtml::valueEx($data->idVehiculo)', 'filter' => GxHtml::listDataEx(Vehiculos::model()->findAllAttributes(null, true, $criteria))), array('name' => 'id_rf', 'value' => 'GxHtml::valueEx($data->idRf)', 'filter' => GxHtml::listDataEx(RegistroFactura::model()->findAllAttributes(null, true))), 'fecha', 'kilometraje', array('header' => 'Subtotal', 'value' => 'OrdenTrabajo::formatearPeso($data->sumita)', 'htmlOptions' => array('width' => '100')), array('class' => 'CButtonColumn', 'header' => 'Opciones', 'htmlOptions' => array('width' => 120), 'template' => '{view}{update}{delete}', 'buttons' => array('view' => array('label' => 'Ver', 'url' => 'Yii::app()->createUrl("ordentrabajo/view", array("id"=>$data->id))', 'imageUrl' => Yii::app()->baseUrl . '/images/ver.png'), 'update' => array('label' => 'Editar', 'url' => 'Yii::app()->createUrl("ordentrabajo/update", array("id"=>$data->id))', 'imageUrl' => Yii::app()->baseUrl . '/images/editar.png'), 'delete' => array('label' => 'Borrar', 'url' => 'Yii::app()->createUrl("ordentrabajo/delete", array("id"=>$data->id))', 'imageUrl' => Yii::app()->baseUrl . '/images/delete.png'))))));