public function conciliarFarmatodo($rutaArchivo, $desde = 0, $hasta = 0) { $data = array(); if (($gestor = fopen($rutaArchivo, "r")) !== FALSE) { while (($datos = fgetcsv($gestor, 1000, ",")) !== FALSE) { if ($datos[0] == 1) { // Si se trata de un registro se incluye en la matriz de data $data[] = array('sucursal' => $datos[1], 'fecha' => strtotime($datos[2] . " " . $datos[3]), 'clave' => substr($datos[4], 0, 16), 'monto' => (int) $datos[6], 'total' => 0, 'farmatodo' => true, 'taquillacero' => false); } } fclose($gestor); } $rango = '1'; $matrix = array(); if ($desde and $hasta and preg_match("(\\d{4}-\\d{2}-\\d{2})", $desde) == 1 and preg_match("(\\d{4}-\\d{2}-\\d{2})", $hasta) == 1) { $rango = sprintf(" VentasFecHor BETWEEN '%s' and '%s' ", $desde, $hasta); } $criteria = new CDbCriteria(); $criteria->addCondition($rango); $criteria->addCondition("VentasSta<>'CANCELADO'"); $criteria->addCondition("UsuariosId=2"); $criteria->order = "t.VentasId"; $ventas = Ventas::model()->with('total', 'puntoventa')->findAll($criteria); foreach ($ventas as $venta) { $matrix[$venta->VentasId] = array('id' => $venta->VentasId, 'sucursal' => $venta->puntoventa->PuntosventaNom, 'fecha' => strtotime($venta->VentasFecHor), 'clave' => $venta->VentasNumRef, 'monto' => 0, 'total' => $venta->total, 'farmatodo' => false, 'taquillacero' => true); } foreach ($data as $i => $fila) { $venta = Ventas::model()->with('total')->findByAttributes(array('VentasNumRef' => $fila['clave'])); if (is_object($venta)) { $data[$i]['total'] = $venta->total; $data[$i]['taquillacero'] = true; $data[$i]['id'] = $venta->VentasId; $matrix[$venta->VentasId] = $data[$i]; } else { ${$data}[$i]['id'] = mktime(); $matrix[] = $data[$i]; } } return new CArrayDataProvider(array_values($matrix), array('pagination' => false)); }
/* @var $this VentasDetalleController */ /* @var $model VentasDetalle */ $this->breadcrumbs = array('Ventas Detalles' => array('index'), 'Manage'); $this->menu = array(array('label' => 'List VentasDetalle', 'url' => array('index')), array('label' => 'Create VentasDetalle', '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\$('#ventas-detalle-grid').yiiGridView('update', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n"); ?> <h1>Relación de Productos - <a href="#exportar" class="btn btn-warning" role="button" data-toggle="modal"><i class="icon-share-alt icon-white"></i> Exportar</a></h1> <?php //echo CHtml::link('Advanced Search','#',array('class'=>'search-button')); ?> <div class="search-form" style="display:none"> <?php $this->renderPartial('_search', array('model' => $model)); $lasVentas = Ventas::model()->findAll(); ?> </div><!-- search-form --> <?php $this->widget('zii.widgets.grid.CGridView', array('id' => 'ventas-detalle-grid', 'dataProvider' => $model->search(), 'afterAjaxUpdate' => 'reinstallDatePickerVentas', 'filter' => $model, 'columns' => array(array('header' => 'ID.', 'name' => 'id', 'value' => '$data->id', 'htmlOptions' => array('width' => '30')), array('name' => 'nombre_paciente', 'value' => '$data->paciente->nombre', 'htmlOptions' => array('width' => '100'), 'headerHtmlOptions' => array('style' => 'width:150px;text-align:center;')), array('name' => 'apellido_paciente', 'value' => '$data->paciente->apellido', 'htmlOptions' => array('width' => '100'), 'headerHtmlOptions' => array('style' => 'width:150px;text-align:center;')), array('header' => 'Producto', 'name' => 'producto_id', 'filter' => CHtml::listData(ProductoInventario::model()->findAll(array('order' => 'nombre_producto ASC')), 'id', 'nombre_producto'), 'value' => '$data[\'producto\'][\'nombre_producto\']', 'htmlOptions' => array('width' => '250')), array('header' => 'Vendedor', 'name' => 'vendedor_id', 'value' => '$data->venta->vendedor->nombreCompleto', 'filter' => CHtml::listData(Personal::model()->findAll(array('order' => 'nombres ASC')), 'id', 'nombreCompleto'), 'htmlOptions' => array('width' => '200'), 'headerHtmlOptions' => array('style' => 'width:150px;text-align:center;')), array('name' => 'cantidad', 'value' => '$data->cantidad', 'htmlOptions' => array('width' => '50'), 'footer' => "<h5>" . number_format($model->getTotal4($model->searchSuma())) . '</h5>'), array('name' => 'valor', 'value' => 'number_format($data->valor,2)', 'footer' => "<h5>\$ " . number_format($model->getTotal($model->searchSuma()), 2) . '</h5>'), array('name' => 'iva', 'value' => 'number_format($data->iva,2)', 'footer' => "<h5>\$ " . number_format($model->getTotal2($model->searchSuma()), 2) . '</h5>'), array('name' => 'total', 'value' => 'number_format($data->total,2)', 'footer' => "<h5>\$ " . number_format($model->getTotal3($model->searchSuma()), 2) . '</h5>'), array('header' => 'Fecha', 'name' => 'fecha', 'filter' => $this->widget('zii.widgets.jui.CJuiDatePicker', array('language' => 'es', 'model' => $model, 'attribute' => 'fecha', 'options' => array('showAnim' => 'fold', 'language' => 'es', 'dateFormat' => 'dd-mm-yy', 'changeMonth' => true, 'changeYear' => true, 'yearRange' => '2014:2025'), 'htmlOptions' => array('id' => 'datepicker_for_fecha', 'style' => 'height:20px;width:80px;'), 'defaultOptions' => array('showOn' => 'focus', 'showOtherMonths' => true, 'selectOtherMonths' => true, 'changeMonth' => true, 'changeYear' => true, 'showButtonPanel' => true)), true), 'value' => 'Yii::app()->dateformatter->format("dd-MM-yyyy",$data[\'fecha\']);', 'htmlOptions' => array('width' => '80')), array('class' => 'CButtonColumn', 'template' => '{view}')))); Yii::app()->clientScript->registerScript('re-install-date-picker', "\nfunction reinstallDatePickerVentas(id, data) {\n //use the same parameters that you had set in your widget else the datepicker will be refreshed by default\n \$('#datepicker_for_fecha').datepicker(jQuery.extend({showMonthAfterYear:false},jQuery.datepicker.regional['es'],{'dateFormat':'dd-mm-yy'}));\n //\$('#datepicker_for_fecha').datepicker(\$.datepicker.regional[ 'es' ]);\n //\$('#datepicker_for_fecha').datepicker({dateFormat: 'dd-mm-yy'});\n}\n"); ?> <div id="exportar" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h3 id="myModalLabel">Exportar a un archivo de Excel </h3> </div> <div class="modal-body"> <p>Seleccione las opciones de Exportar</p>
<?php //Detalles $numVentas = $_GET['id']; $lasVentas = Ventas::model()->findByPk($numVentas); $detalleVenta = VentasDetalle::model()->findAll("venta_id={$numVentas}"); ?> <style type="text/css"> p{ margin: 2px 0px; } </style> <table> <tr> <td width="200"> <p>MARIA ANGELICA DIAZ</p> <br> <p>NIT: 39.017.694-2</p> <p>CALLE 87 N° 47 – 47</p> <p>PBX: 3177190</p> <p>RES. REGIMEN SIMPLIFICADO</p> <p>ORDEN DE PAGO N°: <?php echo $lasVentas->id; ?> </p> <p>FECHA: <?php echo $lasVentas->fecha; ?>
/** * 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 Ventas the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Ventas::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public static function getMaxId() { $row = Ventas::model()->find(array('select' => 'MAX(VentasId) as maxId')); return $row['maxId']; }
<?php /* @var $this VentasController */ /* @var $model Ventas */ $this->menu = array(array('label' => 'Buscar Ventas', 'url' => array('admin'))); ?> <?php //Calcular proximo numero de compra $proxima = new Ventas(); $criteria = new CDbCriteria(); $criteria->select = 'max(id) AS id'; $row = $proxima->model()->find($criteria); $elid = $row['id'] + 1; ?> <h1>Crear Venta #<?php echo $elid; ?> </h1> <?php $this->renderPartial('_form', array('model' => $model));