function verfactura($caja, $cajero, $fecha, $numero) { $this->rapyd->load('datagrid2'); $grid = new DataGrid2(); $grid->db->select = array('a.codigo', 'b.descrip', 'a.precio', 'a.monto', 'a.cantidad', 'a.impuesto'); $grid->db->from('vieite AS a'); $grid->db->join('maes AS b', 'a.codigo=b.codigo'); $grid->db->where('fecha', $fecha); $grid->db->where('cajero', $cajero); $grid->db->where('caja', $caja); $grid->db->where('a.numero', $numero); $grid->db->orderby('a.fecha, a.caja, a.numero'); $grid->column('Código', 'codigo'); $grid->column('Descripción', 'descrip'); $grid->column('Cantidad', 'cantidad', 'align="right"'); $grid->column('Precio', 'precio', 'align="right"'); $grid->column('Impuesto', 'impuesto', 'align="right"'); $grid->column('Total', 'monto', 'align="right"'); $grid->totalizar('monto'); $grid->build(); $back = anchor('supermercado/buscafac/index/search/osp', 'Regresar'); $data['content'] = $grid->output . $back; $data['head'] = $this->rapyd->get_head(); $data['title'] = '<h1>Factura</h1>'; $this->load->view('view_ventanas', $data); }
function detalle($numero = '') { $this->rapyd->load("datagrid2"); $grid = new DataGrid2("Detalle"); $grid->db->select(array('codigoa', 'desca', 'cana', 'preca', 'iva', 'tota', 'detalle', 'combo', 'bonifica', 'costo')); $grid->db->from('sitemslog'); $grid->db->where('id', $numero); $grid->per_page = 20; $grid->column("Codigo", "codigoa", "align=left"); $grid->column("Descripcion", "desca", "align=left"); $grid->column("Cantidad", "cana", "align=center"); $grid->column("Precio", "preca", "align=right"); $grid->column("Iva", "iva", "align=right"); $grid->column("Total", "tota", "align=right"); $grid->column("Detalle", "detalle", "align=right"); $grid->column("combo", "combo", "align=right"); $grid->column("Bonifica", "bonifica", "align=right"); $grid->column("Costo", "costo", "align=right"); $grid->build(); //echo $grid->db->last_query(); $data['content'] = $grid->output; $data['title'] = "<h1>Detalle</h1>"; $data["head"] = $this->rapyd->get_head(); $this->load->view('view_ventanas', $data); }
function index() { $this->rapyd->load('datagrid2'); $this->rapyd->load('datafilter'); $diai = $this->uri->segment(4); $mesi = $this->uri->segment(5); $anoi = $this->uri->segment(6); if ($diai === FALSE or $mesi === FALSE or $anoi === FALSE) { $fechai = date('Y/m/d'); $qfechai = date('Ymd'); } else { $fechai = "{$anoi}/{$mesi}/{$diai}"; $qfechai = $anoi . $mesi . $diai; } $filter = new DataForm('supermercado/poscuadre/index'); $filter->title('Filtro de cajas'); $filter->fechai = new dateField("Fecha", "fechai", "d/m/Y"); $filter->fechai->insertValue = $fechai; $filter->fechai->size = 10; $filter->button("btnsubmit", "Buscar", form2uri(site_url('supermercado/poscuadre/index'), 'fechai'), $position = "BL"); $filter->build_form(); $grid = new DataGrid2(); $select = array('a.caja caja', "IFNULL(b.nombre,'N/A') nombre", 'a.cajero AS cajero', 'SUM(a.gtotal) AS monto'); $cupon = floatval($this->datasis->traevalor('FMAYCUPON')); if ($cupon > 0) { $select[] = "SUM(TRUNCATE(a.gtotal/{$cupon},0)) AS cupones"; } else { $select[] = '(0) AS cupones'; } $grid->db->select($select); $grid->db->from('posfact AS a'); $grid->db->where('SUBSTRING(numero,1,1)!=', 'X'); $grid->db->where('fecha', $qfechai); $grid->db->join('scaj b', 'a.cajero=b.cajero', 'LEFT'); $grid->db->groupby('a.caja,a.cajero'); $link = anchor("supermercado/poscuadre/concaja/<#caja#>/<#cajero#>/{$qfechai}", '<#caja#>'); $grid->column('Caja', $link); $grid->column('Nombre', 'nombre'); $grid->column('Cajero', 'cajero', 'align="center"'); $grid->column('Cupones', 'cupones', 'align="center"'); $grid->column('Monto', '<nformat><#monto#></nformat>', 'align="right"'); $grid->totalizar('monto'); $grid->build(); //echo $grid->db->last_query(); $consul = new DataForm('supermercado/buscafac/index/search/osp'); $consul->title('Buscar Factura'); $consul->fechad = new dateField("Desde", "fechad", "d/m/Y"); $consul->fechah = new dateField("Hasta", "fechah", "d/m/Y"); $consul->nombre = new inputField("Nombre", "nombre"); $consul->cedula = new inputField("Cédula/RIF", "cedula"); $consul->fechad->insertValue = $consul->fechah->insertValue = date("Y/m/d"); $consul->fechah->size = $consul->fechad->size = 10; $consul->submit("btn_submit", "Buscar"); $consul->build_form(); $data['content'] = $filter->output . $grid->output . $consul->output; $data['title'] = '<h1>Consulta de Cajas</h1>'; $data['head'] = $this->rapyd->get_head(); $this->load->view('view_ventanas', $data); }
function index() { $this->rapyd->load('dataform'); $this->rapyd->load('datagrid2'); $this->load->library('encrypt'); function dif($a, $b) { return number_format($a - $b, 2, ',', '.'); } $form = new DataForm('supermercado/conciliacion/index/process'); $form->fechad = new dateonlyField('Desde', 'fechad', 'd/m/Y'); $form->fechad->insertValue = date('Y-m-d', mktime(0, 0, 0, date("m"), date("d") - 30, date("Y"))); $form->fechad->rule = 'required'; $form->fechah = new dateonlyField('Hasta', 'fechah', 'd/m/Y'); $form->fechah->insertValue = date('Y-m-d'); $form->fechah->rule = 'required'; $form->submit('btnsubmit', 'Buscar'); $form->build_form(); $tabla = ''; if ($form->on_success()) { $fechad = $form->fechad->newValue; $fechah = $form->fechah->newValue; //$mSQL="SELECT 'PV' ,caja,SUM(gtotal*IF(MID(numero,1,2)='NC',-1,1)) FROM viefac WHERE fecha BETWEEN '$fechad' AND '$fechah' GROUP BY caja UNION //SELECT 'PV' ,'MAYO',SUM(gtotal*IF(tipo='D',-1,1)) FROM fmay WHERE fecha BETWEEN '$fechad' AND '$fechah' UNION //SELECT 'CZ' ,caja,SUM(exento+base+iva+base1+iva1+base2+iva2-ncexento-ncbase-nciva-ncbase1-nciva1-ncbase2-nciva2) FROM fiscalz WHERE fecha BETWEEN '$fechad' AND '$fechah' GROUP BY caja"; $mSQL = "SELECT a.fecha, a.caja, sum(a.gtotal*if(MID(a.numero,1,2)='NC',-1,1)) AS factura,\n\t\t\t(SELECT sum(exento+base+iva-ncexento-ncbase-nciva) venta FROM fiscalz c WHERE c.fecha=a.fecha AND c.caja=a.caja ) AS cierrez,\n\t\t\t(SELECT sum(exento+base+iva-ncexento-ncbase-nciva) venta FROM fiscalz c WHERE c.fecha=a.fecha AND c.caja=a.caja )-\n\t\t\tsum(a.gtotal*if(MID(a.numero,1,2)='NC',-1,1)) AS dife\n\t\t\tFROM viefac a\n\t\t\tWHERE a.fecha BETWEEN '{$fechad}' AND '{$fechah}' GROUP BY a.fecha, a.caja ORDER BY a.caja,a.fecha"; $grid = new DataGrid2('Resúmen'); $grid->db->_escape_char = ''; $grid->db->_protect_identifiers = false; //$grid->per_page = 20; $grid->use_function('dif'); $select = array('a.fecha', 'b.caja', '(SELECT sum(exento+base+iva+base1+iva1+base2+iva2-ncexento-ncbase-nciva-ncbase1-nciva1-ncbase2-nciva2) FROM fiscalz c WHERE c.fecha=a.fecha AND c.caja=b.caja) AS cierrez', '(SELECT sum(d.gtotal) FROM viefac AS d WHERE d.fecha=a.fecha AND d.caja=b.caja) AS factura'); $grid->db->select($select); $grid->db->from('tiempo AS a'); $grid->db->join("caja AS b", "a.fecha BETWEEN '{$fechad}' AND '{$fechah}'"); $grid->db->orderby("caja,fecha"); $grid->db->having("cierrez IS NOT null OR factura IS NOT null"); $grid->column("Fecha", "<dbdate_to_human><#fecha#></dbdate_to_human>", "align='center'"); $grid->column("Caja", "caja", 'align=center'); $grid->column("Factura", "<nformat><#factura#></nformat>", 'align=right'); $grid->column("Cierre Z", "<nformat><#cierrez#></nformat>", 'align=right'); $grid->column("Diferencia", "<dif><#factura#>|<#cierrez#></dif>", 'align=right'); $grid->totalizar('factura', 'cierrez'); $grid->build(); //echo $grid->db->last_query(); $tabla = $grid->output; } $reporte = anchor('reportes/ver/CONCILIACI', 'Imprimir'); $data['content'] = $form->output . $reporte . $tabla; $data["head"] = script("jquery.pack.js") . script("plugins/jquery.numeric.pack.js") . script("plugins/jquery.floatnumber.js") . $this->rapyd->get_head(); $data['title'] = heading('Concialiaciones de Cierre Z'); $this->load->view('view_ventanas', $data); }
function index() { $this->rapyd->load("datagrid2"); $this->rapyd->load("dataform"); $this->load->helper('openflash'); if ($this->uri->segment(4)) { $anio = $this->uri->segment(4); } elseif (isset($_POST['anio'])) { $anio = $_POST['anio']; } if (empty($anio)) { $anio = date("Y"); } $fechai = $anio . '0101'; $fechaf = $anio . '1231'; $filter = new DataForm('hospitalidad/anuales'); $filter->title('Filtro de ventas Anuales'); $filter->anio = new inputField("Año", "anio"); $filter->anio->size = 4; $filter->anio->insertValue = $anio; $filter->anio->maxlength = 4; //$filter->anio->onkeypress="return acceptNum(event)"; $filter->button("btnsubmit", "Buscar", form2uri(site_url('hospitalidad/anuales/index'), array('anio')), $position = "BL"); $filter->build_form(); $data = $this->_sincrodata($fechai, $fechaf); $grid = new DataGrid2('', $data); $grid->totalizar('impuesto', 'cobrado', 'contado', 'credito', 'subtotal', 'numfac'); $grid->column("Mes", "mes"); $grid->column("Sub-Total", "<number_format><#subtotal#>|2|,|.</number_format>", 'align=right'); $grid->column("Impuesto", "<number_format><#impuesto#>|2|,|.</number_format>", 'align=right'); $grid->column("Contado", "<number_format><#contado#>|2|,|.</number_format>", 'align=right'); $grid->column("Credito", "<number_format><#credito#>|2|,|.</number_format>", 'align=right'); $grid->column("Cobrado", "<number_format><#cobrado#>|2|,|.</number_format>", 'align=right'); $grid->column("% Ventas", "<number_format><#porcentaje#>|2|,|.</number_format>", 'align=right'); $grid->column("Cant. Fact", "numfac", 'align=right'); $grid->build(); $data['content'] = open_flash_chart_object(680, 300, site_url("hospitalidad/anuales/grafico/{$anio}")); $data['content'] .= $filter->output . $grid->output; $data['title'] = $this->rapyd->get_head() . "<h1>Ventas Anuales</h1>"; $data['script'] = '<script type="text/javascript"> $(document).ready(function() { $("#anio").keypress(function(event) { acceptNum(evt); return false; }); }); var nav4 = window.Event ? true : false; function acceptNum(evt) { var key = nav4 ? evt.which : evt.keyCode; return (key <= 13 || (key >= 48 && key <= 57)); } </script>'; $data["head"] = script("jquery-1.2.6.pack.js") . $this->rapyd->get_head(); $this->load->view('view_ventanas', $data); }
function filteredgrid() { $this->rapyd->load('datafilter', 'datagrid2'); $modbus = array('tabla' => 'sinv', 'columnas' => array('codigo' => 'Código', 'descrip' => 'Descripción', 'precio1' => 'Precio 1', 'precio2' => 'Precio 2', 'precio3' => 'Precio 3', 'precio4' => 'Precio 4'), 'filtro' => array('codigo' => 'Código', 'descrip' => 'Descripción'), 'retornar' => array('codigo' => 'codigo'), 'titulo' => 'Buscar en inventario'); $boton = $this->datasis->modbus($modbus); $filter = new DataFilter("Kardex de Inventario"); //$filter->codigo = new inputField("Código De Producto", "codigo"); //$filter->codigo->append($boton); $filter->ubica = new dropdownField("Almacen", "ubica"); $filter->ubica->option("", "Todos"); $filter->ubica->db_name = 'a.ubica'; $filter->ubica->options("SELECT ubica,CONCAT(ubica,' ',ubides) descrip FROM caub WHERE gasto='N' "); $filter->ubica->operator = "="; $filter->ubica->clause = "where"; $filter->fecha = new dropdownField("Fecha", "fecha"); $filter->fecha->db_name = 'a.fecha'; $filter->fecha->options("SELECT SQL_BIG_RESULT fecha,fecha descrip FROM maesfisico GROUP BY fecha ORDER BY fecha DESC LIMIT 5 "); $filter->fecha->operator = "="; $filter->fecha->clause = "where"; $filter->buttons("reset", "search"); $filter->build(); $data['lista'] = $filter->output; if (isset($_POST['codigo'])) { $code = $_POST['codigo']; $mSQL = "SELECT CONCAT(descrip,' ',descrip2) descrip FROM sinv WHERE codigo='{$code}'"; $query = $this->db->query($mSQL); $descrip = ''; if ($query->num_rows() > 0) { $row = $query->row(); $descrip = $row->descrip; } $link = "/inventario/kardex/grid/<#origen#>/<dbdate_to_human><#fecha#>|Ymd</dbdate_to_human>/<str_replace>/|:slach:|<#codigo#></str_replace>/<#ubica#>"; $grid = new DataGrid2("({$code}) {$descrip}"); $grid->agrupar('Almacen: ', 'almacen'); $grid->use_function('convierte', 'number_format', 'str_replace'); $grid->db->select = array("IFNULL(b.ubides,a.ubica) almacen", "a.ubica", "a.fecha", "a.venta", "a.cantidad", "a.saldo", "a.monto", "a.salcant", "a.codigo", "a.origen", "a.promedio"); $grid->db->from('costos a'); $grid->db->join('caub b ', 'b.ubica=a.ubica', 'LEFT'); $grid->db->orderby('almacen, fecha, origen'); $grid->per_page = 20; $grid->column("Fecha", "<dbdate_to_human><#fecha#></dbdate_to_human>"); $grid->column("Orígen", "<convierte><#origen#>|{$link}</convierte>", 'align=left'); $grid->column("Cantidad", "<number_format><#cantidad#>|2|,|.</number_format>", 'align=right'); $grid->column("Acumulado", "<number_format><#salcant#>|2|,|.</number_format>", 'align=right'); $grid->column("Monto", "<number_format><#monto#>|2|,|.</number_format>", 'align=right'); $grid->column("Saldo", "<number_format><#saldo#>|2|,|.</number_format>", 'align=right'); $grid->column("Costo Prom.", "<number_format><#promedio#>|2|,|.</number_format>", 'align=right'); $grid->column("Ventas", "<number_format><#venta#>|2|,|.</number_format>", 'align=right'); $grid->build(); $data['lista'] .= $grid->output; //echo $grid->db->last_query(); } $data['forma'] = ''; $data['titulo'] = $this->rapyd->get_head() . "<center><h2>Kardex de Inventario</h2></center>"; $this->layout->buildPage('ventas/view_ventas', $data); }
function index() { $this->rapyd->load("datagrid2"); $this->rapyd->load("dataform"); $this->load->helper('openflash'); if ($this->uri->segment(4)) { $mes = $this->uri->segment(4); } elseif (isset($_POST['mes'])) { $mes = $_POST['mes']; } if ($this->uri->segment(5)) { $anio = $this->uri->segment(5); } elseif (isset($_POST['anio'])) { $anio = $_POST['anio']; } if (empty($mes) or empty($anio)) { $mes = date("n"); } $anio = date("Y"); $fechai = $anio . str_pad($mes, 2, "0", STR_PAD_LEFT) . '01'; $fechaf = $anio . str_pad($mes, 2, "0", STR_PAD_LEFT) . '31'; $filter = new DataForm('ventas/mensuales'); $filter->attributes = array('onsubmit' => "this.action='index/'+this.form.mes.value+'/'+this.form.anio.value+'/';return FALSE;"); $filter->title('Filtro de ventas mensuales'); $filter->mes = new dropdownField("Mes/Año", "mes"); for ($i = 1; $i < 13; $i++) { $filter->mes->option(str_pad($i, 2, '0', STR_PAD_LEFT), str_pad($i, 2, '0', STR_PAD_LEFT)); } $filter->mes->size = 2; $filter->mes->style = ''; $filter->mes->insertValue = $mes; $filter->anio = new inputField("Año", "anio"); $filter->anio->in = 'mes'; $filter->anio->size = 4; $filter->anio->insertValue = $anio; $filter->anio->maxlength = 4; $filter->button("btnsubmit", "Buscar", form2uri(site_url('hospitalidad/mensuales/index'), array('mes', 'anio')), $position = "BL"); $filter->build_form(); $data = $this->_sincrodata($fechai, $fechaf); $grid = new DataGrid2('', $data); $grid->totalizar('impuesto', 'cobrado', 'contado', 'credito', 'subtotal', 'numfac'); $grid->column("Dia", "dia"); $grid->column("Sub-Total", "<number_format><#subtotal#>|2|,|.</number_format>", 'align=right'); $grid->column("Impuesto", "<number_format><#impuesto#>|2|,|.</number_format>", 'align=right'); $grid->column("Contado", "<number_format><#contado#>|2|,|.</number_format>", 'align=right'); $grid->column("Credito", "<number_format><#credito#>|2|,|.</number_format>", 'align=right'); $grid->column("Cobrado", "<number_format><#cobrado#>|2|,|.</number_format>", 'align=right'); $grid->column("% Ventas", "<number_format><#porcentaje#>|2|,|.</number_format>", 'align=right'); $grid->column("Cant. Fact", "numfac", 'align=right'); $grid->build(); $data['content'] = open_flash_chart_object(680, 300, site_url("hospitalidad/mensuales/grafico/{$mes}/{$anio}")); $data['content'] .= $filter->output . $grid->output; $data['title'] = $this->rapyd->get_head() . "<h1>Ventas Mensuales</h1>"; $data["head"] = $this->rapyd->get_head(); $this->load->view('view_ventanas', $data); }
function dia() { $this->rapyd->load("datagrid2"); $fecha = $this->uri->segment(4); if (empty($fecha)) { $fecha = date("d-m-Y"); } $grid = new DataGrid2("Ventas del Día {$fecha}"); $grid->column("Tipo", "<#tipo_doc#>", "align=left"); $grid->column("Numero", "<#numero#>", "align=left"); $grid->column("Cliente", "<#cod_cli#>", "align=left"); $grid->column("Nombre", "<#nombre#>", "align=left"); $grid->column("Sub-Total", "<number_format><#totals#>|2|,|.</number_format>", 'align=right'); $grid->column("I.V.A.", "<number_format><#iva#>|2|,|.</number_format>", 'align=right'); $grid->column("Total", "<number_format><#totalg#>|2|,|.</number_format>", 'align=right'); $select = array("tipo_doc", "numero", "cod_cli", "nombre", "totals", "iva", "totalg"); $grid->db->select($select); $grid->db->from('sfac'); echo $fecha; //$fecha2=substr($fecha,8,2).substr($fecha,6,2).substr($fecha,0,2); $grid->db->where('fecha', $fecha); //$grid->db->order('hora'); $grid->build(); echo $grid->db->last_query(); $data['content'] = '<div style="overflow: auto; width: 100%;">' . $grid->output . '</div>'; $data['title'] = "<h1>Analisis de Ventas</h1>"; $data["head"] = script("jquery.pack.js") . script("plugins/jquery.numeric.pack.js") . script("plugins/jquery.floatnumber.js") . $this->rapyd->get_head(); $this->load->view('view_ventanas', $data); }
function ver_tabla($numero) { $this->rapyd->load("datagrid2"); $grid = new DataGrid2(); $grid->db->select(array("codigo", "descri1", "precio", "cantidad", "importe", "hora")); $grid->db->from("sitems"); $grid->db->where('numero', $numero); $grid->totalizar('importe'); //$grid->add("hospitalidad/restaurante/agregar/$numero"); $grid->column("Descripción", "descri1"); $grid->column("Precio", "<number_format><#precio#>|2|,|.</number_format>", 'align=right'); $grid->column("Cantidad", "<number_format><#cantidad#>|2|,|.</number_format>", 'align=right'); $grid->column("Importe", "<number_format><#importe#>|2|,|.</number_format>", 'align=right'); $grid->column("Hora", "hora", 'align=right'); $grid->build(); $data['content'] = $grid->output; //'<input type="button" value="Regresar" name="Back" onclick="history.back()" />'. $data["head"] = $this->rapyd->get_head(); $this->load->view('view_ventanas_sola', $data); }
function verfactura($caja, $cajero, $fecha, $numero) { $this->rapyd->load("datagrid2"); $grid = new DataGrid2(); $grid->db->select = array("a.codigo", "b.descrip", "a.precio", "a.monto", "a.cantidad", "a.impuesto"); $grid->db->from("vieite AS a"); $grid->db->join("maes AS b", 'a.codigo=b.codigo'); $grid->db->where("fecha", $fecha); $grid->db->where("cajero", $cajero); $grid->db->where("caja", $caja); $grid->db->where("a.numero", $numero); $grid->db->orderby('a.fecha, a.caja, a.numero'); $grid->column("Código", "codigo"); $grid->column("Descripción", "descrip"); $grid->column("Cantidad", "cantidad", 'align="right"'); $grid->column("Precio", "precio", 'align="right"'); $grid->column("Impuesto", "impuesto", 'align="right"'); $grid->column("Total", "monto", 'align="right"'); $grid->totalizar('monto'); $grid->build(); $back = anchor("supermercado/buscafac/index/search/osp", 'Regresar'); $data['content'] = $grid->output . $back; $data["head"] = $this->rapyd->get_head(); $data['title'] = '<h1>Factura</h1>'; $this->load->view('view_ventanas', $data); }
function filtro() { $this->rapyd->load("datagrid2"); $this->rapyd->load("dataform"); $this->load->helper('openflash'); $sinv = array('tabla' => 'sinv', 'columnas' => array('codigo' => 'Código', 'descrip' => 'descrip'), 'filtro' => array('codigo' => 'Código', 'descrip' => 'descrip'), 'retornar' => array('codigo' => 'codigo'), 'titulo' => 'Buscar Articulo'); $iboton = $this->datasis->modbus($sinv); if ($this->uri->segment(4)) { $codigo = $this->uri->segment(4); } elseif (isset($_POST['codigo'])) { $codigo = $_POST['codigo']; } if (empty($codigo)) { $codigo = $this->datasis->dameval("SELECT codigo FROM sinv"); } if ($this->uri->segment(5)) { $mes = $this->uri->segment(5); } elseif (isset($_POST['mes'])) { $mes = $_POST['mes']; } else { $mes = date('m'); } if ($this->uri->segment(6)) { $anio = $this->uri->segment(6); } elseif (isset($_POST['anio'])) { $anio = $_POST['anio']; } else { $anio = date('Y'); } $script = ' $(function() { $(".inputnum").numeric("."); }); '; $fechad = $anio . str_pad($mes, 2, "0", STR_PAD_LEFT) . '01'; $fechah = $anio . str_pad($mes, 2, "0", STR_PAD_LEFT) . '31'; $filter = new DataForm('ventas/mensuales'); $filter->attributes = array('onsubmit' => "this.action='index/'+this.form.mes.value+'/'+this.form.anio.value+'/';return FALSE;"); $filter->title('Filtro de Ventas por Existencias'); $filter->script($script, "create"); $filter->script($script, "modify"); $filter->mes = new dropdownField("Mes/Año", "mes"); for ($i = 1; $i < 13; $i++) { $filter->mes->option(str_pad($i, 2, '0', STR_PAD_LEFT), str_pad($i, 2, '0', STR_PAD_LEFT)); } $filter->mes->size = 2; $filter->mes->style = ''; $filter->mes->insertValue = $mes; $filter->anio = new inputField("Año", "anio"); $filter->anio->in = 'mes'; $filter->anio->size = 4; $filter->anio->insertValue = $anio; $filter->anio->maxlength = 4; $filter->anio->rule = "trim"; $filter->anio->css_class = 'inputnum'; $filter->codigo = new inputField("Código", "codigo"); $filter->codigo->size = 15; $filter->codigo->append($iboton); $filter->codigo->insertValue = $codigo; $filter->button("btnsubmit", "Buscar", form2uri(site_url('inventario/gproductos/filtro/'), array('codigo', 'mes', 'anio')), $position = "BL"); $filter->build_form(); $grid = new DataGrid2(); $select = array("fecha", "codigo", "sum(cantidad) cantidad", "IF(sum(cantidad)<=salcant,sum(cantidad),salcant)*(salcant>0)as salcant"); $grid->db->select($select); $grid->db->from("costos"); $grid->db->where('codigo', $coigo); $grid->db->where('fecha >= ', $fechai); $grid->db->where('fecha <= ', $fechaf); $grid->db->where('origen', '3I'); $grid->db->groupby("fecha"); $grid->db->orderby("fecha"); $grid->db->having("cantidad>0"); $grid->column("Fecha", "<dbdate_to_human><#fecha#></dbdate_to_human>", 'align=center'); $grid->column("Ventas", "cantidad", 'align=center'); $grid->column("Existencias", "salcant", 'align=center'); //$grid->totalizar('grantotal'); $grid->build(); //echo $grid->db->last_query(); $grafico = open_flash_chart_object(680, 450, site_url("inventario/gproductos/grafico/{$codigo}/{$mes}/{$anio}/")); $data['content'] = $grafico; $data['content'] .= $filter->output . $grid->output; $data["head"] = $this->rapyd->get_head(); $data['title'] = $this->rapyd->get_head() . "<h1>Ventas por Existencias</h1>"; $this->load->view('view_ventanas', $data); }
function diarias($anio = '', $producto = '', $mes = '') { $this->rapyd->load("datagrid2"); $this->rapyd->load("dataform"); $this->load->helper('openflash'); if (isset($_POST['anio']) and empty($anio)) { $anio = $_POST['anio']; } if (isset($_POST['mes']) and empty($mes)) { $mes = $_POST['mes']; } if (isset($_POST['codigo']) and empty($producto)) { $producto = $_POST['codigo']; } //if(empty($anio) OR ($producto)) redirect("supermercado/gproductosanuales/index/$anio"); if (empty($mes)) { redirect("supermercado/gproductos/mensuales/{$anio}/{$producto}"); } $fechai = $anio . str_pad($mes, 2, "0", STR_PAD_LEFT) . '01'; $fechaf = $anio . str_pad($mes, 2, "0", STR_PAD_LEFT) . '31'; $maes = array('tabla' => 'maes', 'columnas' => array('codigo' => 'Código Producto', 'descrip' => 'Nombre'), 'filtro' => array('codigo' => 'Código Producto', 'descrip' => 'Nombre'), 'retornar' => array('codigo' => 'codigo'), 'titulo' => 'Buscar Vendedor'); $cboton = $this->datasis->modbus($maes); $filter = new DataForm('supermercado/gproductos/diarias'); $filter->attributes = array('onsubmit' => "this.action='index/'+this.form.mes.value+'/'+this.form.anio.value+'/';return FALSE;"); $filter->title('Filtro de Ventas Diarias'); $filter->mes = new dropdownField("Mes/Año", "mes"); for ($i = 1; $i < 13; $i++) { $filter->mes->option(str_pad($i, 2, '0', STR_PAD_LEFT), str_pad($i, 2, '0', STR_PAD_LEFT)); } $filter->mes->size = 2; $filter->mes->style = ''; $filter->mes->insertValue = $mes; $filter->anio = new inputField("Año", "anio"); $filter->anio->in = 'mes'; $filter->anio->size = 4; $filter->anio->insertValue = $anio; $filter->anio->rule = "max_length[4]"; $filter->producto = new inputField("Producto", "codigo"); $filter->producto->size = 10; $filter->producto->insertValue = $producto; $filter->producto->rule = "max_length[4]"; $filter->producto->append($cboton); $filter->button("btnsubmit", "Buscar", form2uri(site_url('supermercado/gproductos/diarias/'), array('anio', 'codigo', 'mes')), $position = "BL"); $filter->build_form(); $grid = new DataGrid2(); $select = array("a.codigo AS codigo", "b.descrip AS nombre", "a.cantidad AS cantidad", "DATE_FORMAT(fecha,'%m/%Y')AS mes", "SUM(a.venta)AS grantotal", "COUNT(*) AS numfac"); $grid->db->select($select); $grid->db->from("costos AS a"); $grid->db->join("maes AS b", "a.codigo=b.codigo"); $grid->db->where('fecha >= ', $fechai); $grid->db->where('fecha <= ', $fechaf); $grid->db->where('a.codigo', $producto); $grid->db->groupby("fecha"); $grid->db->orderby("fecha"); $grid->column("Fecha", "mes", "align='left'"); $grid->column("Total", "<number_format><#grantotal#>|2|,|.</number_format>", 'align=right'); $grid->column("Cantidad", "<number_format><#cantidad#>|2|,|.</number_format>", 'align=right'); $grid->column("Cant. Fact", "numfac", 'align=right'); $grid->totalizar('grantotal'); $grid->build(); $grafico = open_flash_chart_object(680, 350, site_url("supermercado/gproductos/gdiarias/{$anio}/{$producto}/{$mes}")); $data['content'] = $grafico; $data['content'] .= $filter->output . $grid->output; $data["head"] = $this->rapyd->get_head(); $data['title'] = $this->rapyd->get_head() . "<h1>Ventas Diarias</h1>"; $this->load->view('view_ventanas', $data); }
function filteredgrid() { function ractivo($estado, $numero) { if ($estado == 'R') { $retorna = array('name' => $numero, 'id' => $estado, 'value' => 'accept', 'checked' => TRUE); } else { $retorna = array('name' => $numero, 'id' => $estado, 'value' => 'accept', 'checked' => FALSE); } return form_checkbox($retorna); } $this->rapyd->load("datafilter", "datagrid2"); $scli = array('tabla' => 'scli', 'columnas' => array('cliente' => 'Código Cliente', 'nombre' => 'Nombre', 'contacto' => 'Contacto'), 'filtro' => array('cliente' => 'Código Cliente', 'nombre' => 'Nombre'), 'retornar' => array('cliente' => 'cliente'), 'titulo' => 'Buscar Cliente'); $boton = $this->datasis->modbus($scli); $filter = new DataFilter("Filtro de Control de Tiket"); $select = array("a.id as idm", "a.sucursal", "a.asignacion", "a.idt as idt", "a.padre", "a.pertenece", "a.prioridad", "a.usuario as usuarios", "a.contenido", "a.estampa", "a.actualizado", "a.estado as testado", "IF(a.estado='N','Nuevo',IF(a.estado='R','Resuelto',IF(a.estado='P','Pendiente','En Proceso')))as estado", "b.id", "b.cliente as clientes", "b.ubicacion", "b.url", "b.basededato", "b.puerto", "b.puerto", "b.usuario", "b.clave", "b.observacion", "c.nombre", "a.minutos"); $filter->db->select($select); $filter->db->from("tiketc AS a"); $filter->db->join("tiketconec AS b", "a.sucursal=b.id"); $filter->db->join("scli AS c", "b.cliente=c.cliente"); $filter->fechad = new dateonlyField("Fecha Desde", "fechad", 'd/m/Y'); $filter->fechad->clause = "where"; $filter->fechad->db_name = "estampa"; $filter->fechad->operator = ">="; $filter->fechad->size = 12; $filter->fechah = new dateonlyField("Fecha Hasta", "fechah", 'd/m/Y'); $filter->fechah->clause = "where"; $filter->fechah->db_name = "estampa"; $filter->fechah->operator = "<="; $filter->fechah->size = 12; $filter->estado = new dropdownField("Estado", "estado"); $filter->estado->option("", "Todos"); $filter->estado->options($this->estado); $filter->prioridad = new dropdownField("Prioridad", "prioridad"); $filter->prioridad->option("", "Todos"); $filter->prioridad->options($this->prioridad); $filter->contenido = new inputField("Contenido", "contenido"); //$filter->contenido->clause ="likesensitive"; //$filter->contenido->append("Sencible a las Mayuscúlas"); $filter->asignacion = new dropdownField("Asignacion", "asignacion"); $filter->asignacion->option("", "Todos"); $filter->asignacion->options("SELECT codigo, codigo as value FROM tiketservi"); $filter->asignacion->style = "width:150px"; $filter->cliente = new inputField("Cliente", "cliente"); $filter->cliente->size = 20; $filter->cliente->db_name = "c.cliente"; $filter->cliente->append($boton); $filter->idt = new inputField("Numero", "idt"); $filter->idt->size = 20; $filter->idt->db_name = "idt"; $filter->buttons("reset", "search"); $filter->build(); $grid = new DataGrid2("Lista de Control de Tiket"); $grid->order_by("a.id", "desc"); $grid->per_page = 10; $link = anchor("supervisor/tiketc/dataedit/modify/<#idm#>", "<#idm#>"); $grid->use_function('ractivo'); $grid->column("Id", $link); $grid->column("Resuelto", "<ractivo><#testado#>|<#idm#></ractivo>", 'align="center"'); $grid->column("Numero tiket", "idt"); $grid->column("Fecha de Ingreso", "<dbdate_to_human><#estampa#>|d/m/Y h:m:s</dbdate_to_human>"); $grid->column("Cliente", "nombre"); $grid->column("Usuario", "usuarios"); $grid->column("Contenido", "contenido"); $grid->column("Prioridad", "prioridad"); //$grid->column("Estado","estado"); $grid->column("Asignacion", "asignacion"); $grid->column("Tiempo", "minutos"); //$grid->column("URL","url"); //$resp=anchor("http://merida.matloca.com/proteoerp/supervisor/tiket/dataedit/pertenece/<#idt#>/create"", 'IR'); $resp = '<a href="http://<#url#>/proteoerp/supervisor/tiket/dataedit/pertenece/<#idt#>/create">Ir</a>'; //$resp='http://merida.matloca.com/proteoerp/supervisor/tiket/dataedit/pertenece/67/create'; $grid->column("Responder", $resp); $grid->totalizar('minutos'); //$grid->add("supervisor/tiketc/dataedit/create"); $grid->build(); //echo $grid->db->last_query(); $script = ''; $url = site_url('supervisor/tiketc/activar'); $data['script'] = '<script type="text/javascript"> $(document).ready(function() { $("form :checkbox").click(function () { $.ajax({ type: "POST", url: "' . $url . '", data: "numero="+this.name+"&estado="+this.id, success: function(msg){ //alert(msg); } }); }).change(); }); </script>'; $data['content'] = $filter->output . form_open('') . $grid->output . form_close() . $script; $data['title'] = "<h1>Ticket de Clientes</h1>"; $data["head"] = script("jquery-1.2.6.pack.js"); $data["head"] .= script("plugins/jquery.checkboxes.pack.js") . $this->rapyd->get_head(); $this->load->view('view_ventanas', $data); }
function vista($vd = '') { $this->rapyd->load('datagrid2'); $select = array('vd', 'tipo_doc', 'numero', 'fecha', 'vence', 'pagada', 'dias', 'comision', 'comical', 'cod_cli', 'nombre', 'sepago', 'comision'); $grid = new DataGrid2('Lista de ' . $this->titp); $grid->db->select($select); $grid->db->from('sfac'); $grid->db->where('tipo_doc <>', 'X'); if (!empty($vd)) { $grid->db->where('vd', $vd); } $grid->db->where('sepago', 'N'); $grid->db->where('pagada >= fecha'); $grid->order_by('numero', 'desc'); $grid->per_page = 1000; $grid->use_function('substr', 'str_pad', 'comi'); $grid->use_function('sta'); $grid->column('Vendedor', 'vd'); $grid->column('Tipo', '<colum><#tipo_doc#></colum>'); $grid->column('Número', 'numero'); $grid->column('Fecha', '<dbdate_to_human><#fecha#></dbdate_to_human>'); $grid->column('Vence', '<dbdate_to_human><#vence#></dbdate_to_human>'); $grid->column('Pagada', '<dbdate_to_human><#pagada#></dbdate_to_human>'); $grid->column('Dias', 'dias', 'align=\'right\''); $grid->column('Comisión', '<nformat><#comision#></nformat>', 'align=\'right\''); $grid->column('Comisión Calculada', '<nformat><#comical#></nformat>', 'align=\'right\''); $grid->column('Cliente', 'cod_cli'); $grid->column('Nombre', 'nombre'); //$grid->totalizar('reiva'); $grid->build(); $data['content'] = anchor($this->url . "filteredgrid", 'Atras') . $grid->output; $data['title'] = "<h1>{$this->titp}</h1>"; $data['head'] = $this->rapyd->get_head(); $this->load->view('view_ventanas', $data); }
function ver() { $this->rapyd->load('datagrid2'); $MANO = substr(date('Y'), 0, 4) + 0; $mmfecha = mktime(0, 0, 0, 1, 1, $MANO); $qfecha = date('Ymd', mktime(0, 0, 0, date("m", $mmfecha), date("d", $mmfecha), date("Y", $mmfecha))); $qfechaf = date('Ymd'); //$qfecha='20050101'; //$qfechaf='20051231'; $this->db->simple_query('DROP TABLE IF EXISTS vresumen'); $query = "CREATE TABLE vresumen \n\t\t SELECT\n\t\t EXTRACT(YEAR_MONTH FROM a.fecha) AS fecha,\n\t\t sum((a.gtotal-a.impuesto)*IF(MID(a.numero,1,2)='NC',-1,1)) ventas,\n\t\t 0 AS inicial,\n\t\t 0 AS compras,\n\t\t 0 AS ifinal,\n\t\t 0 AS gastos,\n\t\t 0 AS inversion,\n\t\t SUM(b.monto-b.costo) AS utilidad\n\t\t FROM viefac AS a \n\t\t JOIN vieite AS b ON a.numero=b.numero WHERE a.tipo<>'X' AND a.fecha BETWEEN {$qfecha} AND {$qfechaf}\n\t\t GROUP BY EXTRACT(YEAR_MONTH FROM a.fecha) "; $this->db->simple_query($query); $query = "INSERT INTO vresumen\n\t\t SELECT \n\t\t EXTRACT(YEAR_MONTH FROM fecha) AS fecha, \n\t\t 0.00 AS ventas,\n\t\t 0.00 AS inicial,\n\t\t sum(montotot*(fecha<=actuali)) AS compras, \n\t\t 0.00 AS ifinal,\n\t\t 0.00 AS gastos, \n\t\t 0.00 AS inversion,\n\t\t 0.00 AS utilidad\n\t\t FROM scst WHERE fecha BETWEEN {$qfecha} AND {$qfechaf} \n\t\t GROUP BY EXTRACT(YEAR_MONTH FROM fecha) "; $this->db->simple_query($query); $query = "INSERT INTO vresumen \n\t\t SELECT \n\t\t EXTRACT(YEAR_MONTH FROM fecha) AS fecha, \n\t\t 0.00 AS ventas,\n\t\t 0.00 AS inicial,\n\t\t 0.00 AS compras, \n\t\t 0.00 AS ifinal,\n\t\t sum(a.precio*(b.tipo<>'A')) AS gastos, \n\t\t sum(a.precio*(b.tipo='A')) AS inversion ,\n\t\t 0.00 AS utilidad\n\t\t FROM gitser AS a JOIN mgas AS b ON a.codigo=b.codigo\n\t\t WHERE a.fecha BETWEEN {$qfecha} AND {$qfechaf} \n\t\t GROUP BY EXTRACT(YEAR_MONTH FROM a.fecha) "; $this->db->simple_query($query); $atts = array('width' => '800', 'height' => '600', 'scrollbars' => 'yes', 'status' => 'yes', 'resizable' => 'yes', 'screenx' => '5', 'screeny' => '5'); $link = 'ventas/analisis'; $grid = new DataGrid2('Resumen de Gestión'); $grid->column('Fecha', '<#fecha#>'); $grid->column(anchor_popup($link, 'Ventas', $atts), "<number_format><#ventas#>|2|,|.</number_format>", "align=right"); $link = 'ventas/analisis'; $grid->column(anchor_popup($link, "Compras", $atts), "<number_format><#compras#>|2|,|.</number_format>", "align=right"); $grid->column("Utilidad", "<number_format><#porcent#>|2|,|.</number_format>", "align=right"); $link = "finanzas/analisisgastos"; $grid->column(anchor_popup($link, "Gastos", $atts), "<number_format><#gastos#>|2|,|.</number_format>", "align=right"); $grid->column("Inversiones", "<number_format><#inversion#>|2|,|.</number_format>", "align=right"); $select = array("fecha", "sum(utilidad) AS porcent", "sum(ventas) AS ventas", "sum(inicial) AS inicial", "sum(compras) AS compras", "sum(ifinal) AS ifinal", "sum(gastos) AS gastos", "sum(inversion) AS inversion"); // $grid->db->select($select); $grid->db->from('vresumen'); $grid->db->groupby('fecha'); $grid->build(); $grid2 = new DataGrid2('Disponibilidad'); $link = "finanzas/analisisbanc"; $grid2->column(anchor_popup($link, "Cajas", $atts), '<number_format><#cajas#>|2|,|.</number_format>', "align=right"); $link = "finanzas/analisisbanc"; $grid2->column(anchor_popup($link, "Bancos", $atts), '<number_format><#bancos#>|2|,|.</number_format>', "align=right"); $grid2->column("Total", '<number_format><#total#>|2|,|.</number_format>', "align=right"); $select = array("SUM(saldo*(tbanco='CAJ')) AS cajas", " SUM(saldo*(tbanco<>'CAJ')) AS bancos", " SUM(saldo) AS total"); // $grid2->db->select($select); $grid2->db->from('banc'); $grid2->db->where("activo", 'S'); $grid2->build(); $select = array("CONCAT(c.grupo,c.gr_desc) AS grupo", "SUM(monto*IF(tipo_doc IN ('FC','GI','ND'),1,-1 )) AS monto"); // $grid3 = new DataGrid2('Cartera Activa'); $grid3->column("Grupo", '<#grupo#>'); $grid3->column("Monto", '<number_format><#monto#>|2|,|.</number_format>', "align=right"); $grid3->db->select($select); $grid3->db->from('smov AS a'); $grid3->db->join('scli AS b', 'a.cod_cli=b.cliente'); $grid3->db->join('grcl AS c', 'b.grupo=c.grupo', 'LEFT'); $grid3->db->groupby("b.grupo"); $grid3->db->orderby("c.clase,c.gr_desc"); $grid3->build(); $select = array("c.gr_desc AS grupo", "SUM(monto*IF(tipo_doc IN ('FC','GI','ND'),1,-1 )) AS monto"); // $grid4 = new DataGrid2('Cartera Pasiva'); $grid4->column("Grupo", '<#grupo#>'); $grid4->column("Monto", '<number_format><#monto#>|2|,|.</number_format>', "align=right"); $grid4->db->select($select); $grid4->db->from('sprm AS a'); $grid4->db->join('sprv AS b', 'a.cod_prv=b.proveed'); $grid4->db->join('grpr AS c', 'b.grupo=c.grupo', 'LEFT'); $grid4->db->groupby('b.grupo'); $grid4->build(); $this->db->simple_query('DROP TABLE vresumen'); $data['content'] = "<table width='95%' border='0'>\n\t\t <tr>\n\t\t <td valign='top'><div style='overflow: auto; width: 100%;'>{$grid->output}</div></td>\n\t\t <td valign='top'><div style='overflow: auto; width: 100%;'>{$grid2->output}</div></td>\n\t\t </tr>\n\t\t <tr>\n\t\t <td valign='top'><div style='overflow: auto; width: 100%;'>{$grid3->output}</div></td>\n\t\t <td valign='top'><div style='overflow: auto; width: 100%;'>{$grid4->output}</div></td>\n\t\t </tr>\n\t\t</table>"; $data['title'] = '<h1>Visión General</h1>'; $data['head'] = script("jquery.pack.js") . script("plugins/jquery.numeric.pack.js") . script("plugins/jquery.floatnumber.js") . $this->rapyd->get_head(); $this->load->view('view_ventanas', $data); }
function diarias($anio = '', $cliente = '', $mes = '') { $this->rapyd->load("datagrid2"); $this->rapyd->load("dataform"); $this->load->helper('openflash'); if (isset($_POST['anio']) and empty($anio)) { $anio = $_POST['anio']; } if (isset($_POST['mes']) and empty($mes)) { $mes = $_POST['mes']; } if (isset($_POST['cod_cli']) and empty($cliente)) { $cliente = $_POST['cod_cli']; } if (empty($mes)) { redirect("hospitalidad/clientes/mensuales/{$anio}/{$cliente}"); } $fechai = $anio . str_pad($mes, 2, "0", STR_PAD_LEFT) . '01'; $fechaf = $anio . str_pad($mes, 2, "0", STR_PAD_LEFT) . '31'; $scli = array('tabla' => 'scli', 'columnas' => array('cliente' => 'Código Cliente', 'nombre' => 'Nombre', 'contacto' => 'Contacto'), 'filtro' => array('cliente' => 'Código Cliente', 'nombre' => 'Nombre'), 'retornar' => array('cliente' => 'cod_cli'), 'titulo' => 'Buscar Cliente'); $cboton = $this->datasis->modbus($scli); $filter = new DataForm('hospitalidad/clientesdiarias'); $filter->attributes = array('onsubmit' => "this.action='index/'+this.form.mes.value+'/'+this.form.anio.value+'/';return FALSE;"); $filter->title('Filtro de Ventas Diarias'); $filter->mes = new dropdownField("Mes/Año", "mes"); for ($i = 1; $i < 13; $i++) { $filter->mes->option(str_pad($i, 2, '0', STR_PAD_LEFT), str_pad($i, 2, '0', STR_PAD_LEFT)); } $filter->mes->size = 2; $filter->mes->style = ''; $filter->mes->insertValue = $mes; $filter->anio = new inputField("Año", "anio"); $filter->anio->in = 'mes'; $filter->anio->size = 4; $filter->anio->insertValue = $anio; $filter->anio->maxlength = 4; $filter->cliente = new inputField("Cliente", "cod_cli"); $filter->cliente->size = 10; $filter->cliente->insertValue = $cliente; $filter->cliente->rule = "max_length[4]"; $filter->cliente->append($cboton); $filter->button("btnsubmit", "Buscar", form2uri(site_url('hospitalidad/clientes/diarias/'), array('anio', 'cod_cli', 'mes')), $position = "BL"); $filter->build_form(); $grid = new DataGrid2(); $select = array("cod_cli,nombre", "DATE_FORMAT(fecha,'%d/%m/%Y') AS fecha", "SUM(gtotal*IF(tipo='D', -1, 1)) AS grantotal", "SUM(gtotal*IF(tipo='D', -1, 1))/ COUNT(*) AS porcentaje", "SUM(gtotal*IF(tipo='D', -1, 1)) AS contado", "SUM(gtotal*IF(tipo='D', -1, 1)) AS credito", "SUM(stotal*IF(tipo='D',-1,1))AS subtotal", "SUM(impuesto*IF(tipo='D',-1,1))AS impuesto", "COUNT(*) AS numfac"); $grid->db->select($select); $grid->db->from("fmay"); $grid->db->where('tipo<>', 'X'); $grid->db->where('fecha >= ', $fechai); $grid->db->where('fecha <= ', $fechaf); $grid->db->where('cod_cli', $cliente); $grid->db->groupby("fecha"); $grid->column("Dia", "fecha", "align='center'"); $grid->column("Sub-Total", "<number_format><#subtotal#>|2|,|.</number_format>", 'align=right'); $grid->column("Impuesto", "<number_format><#impuesto#>|2|,|.</number_format>", 'align=right'); $grid->column("Total", "<number_format><#grantotal#>|2|,|.</number_format>", 'align=right'); $grid->column("Contado", "<number_format><#contado#>|2|,|.</number_format>", 'align=right'); $grid->column("Credito", "<number_format><#credito#>|2|,|.</number_format>", 'align=right'); $grid->column("Participación", "<number_format><#porcentaje#>|2|,|.</number_format>", 'align=right'); $grid->column("Cant. Fact", "numfac", 'align=right'); $grid->totalizar('impuesto', 'grantotal', 'contado', 'credito', 'subtotal'); $grid->build(); $grafico = open_flash_chart_object(720, 350, site_url("hospitalidad/clientes/gdiarias/{$anio}/{$cliente}/{$mes}")); $data['content'] = $grafico; $data['content'] .= $filter->output . $grid->output; $data["head"] = $this->rapyd->get_head(); $data['title'] = $this->rapyd->get_head() . "<h1>Clientes</h1>"; $this->load->view('view_ventanas', $data); }
function forcierre() { $this->rapyd->load("datagrid2"); $this->rapyd->load("datagrid"); $this->rapyd->load("fields"); $caja = $this->uri->segment(4); $cajero = $this->uri->segment(5); $qfecha = $this->uri->segment(6); if (!$caja or !$cajero or !$qfecha) { redirect('/supermercado/cierre'); } //$data['forma'] =script('nformat.js'); $efectivo = array(); $atts = array('class' => 'inputnum', 'size' => '15', 'align' => 'right'); $attsr = array('class' => 'inputnum', 'size' => '15', 'align' => 'right', 'readonly' => 'readonly'); $catts = array('class' => 'inputnum', 'size' => '6', 'align' => 'right'); $query = $this->db->query('SELECT a.tipo,a.denomina,b.cambiobs*a.denomina equivalencia,a.nombre FROM monebillet a JOIN mone b ON a.moneda=b.moneda ORDER BY a.tipo,a.moneda,a.denomina DESC'); $i = 0; foreach ($query->result() as $row) { $valor = $row->equivalencia; $catts['name'] = $catts['id'] = $row->tipo . $row->denomina; $catts['name'] = $catts['id'] = 'EFE' . $i; $catts['onKeyDown'] = $catts['onKeyUp'] = "opera({$valor},'" . $catts['name'] . "');"; $cantidad = form_input($catts); //cantidad sistema $attsr['name'] = $attsr['id'] = 'T' . $catts['name']; $attsr['value'] = '0,00'; $total = form_input($attsr); $pasa = array(); $pasa['denom'] = $row->nombre; $pasa['cant'] = $cantidad; $pasa['sistema'] = $total; if ($row->tipo == 'MO') { $pasa['tipo'] = 'Monedas'; } elseif ($row->tipo == 'BI') { $pasa['tipo'] = 'Billetes'; } else { $pasa['tipo'] = $row->tipo; } $efectivo[] = $pasa; $i++; } $efe_filas = $i; $query->free_result(); $atts['name'] = $atts['id'] = 'TOTRAS'; $atts['onChange'] = "montosolo('" . $atts['name'] . "');tefectivo();"; $total = form_input($atts); $pasa['denom'] = 'Monto'; $pasa['cant'] = ''; $pasa['sistema'] = $total; $pasa['tipo'] = 'Otras Denominaciones'; $efectivo[] = $pasa; $atts['name'] = $atts['id'] = 'TFONDO'; $total = form_input($atts); $pasa['sistema'] = $total; $pasa['tipo'] = 'Fondo de caja (-)'; $efectivo[] = $pasa; $attsr['name'] = $attsr['id'] = 'EFETOTAL'; $total = form_input($attsr); $pasa['denom'] = 'TOTAL'; $pasa['sistema'] = $total; $pasa['tipo'] = 'Total Efectivo'; $efectivo[] = $pasa; $msistema = $this->datasis->dameval("SELECT sum(monto) FROM viepag WHERE caja={$caja} AND cajero={$cajero} AND fecha={$qfecha} AND tipo IN ('EF','DP') AND SUBSTRING(numero,1,1)<>'X' "); $attsr['value'] = number_format($msistema, '2', ',', '.'); $attsr['name'] = $attsr['id'] = 'EFESISTEMA'; $total = form_input($attsr); $pasa['denom'] = 'SISTEMA'; $pasa['sistema'] = $total; $pasa['tipo'] = 'Total Efectivo'; $efectivo[] = $pasa; $attsr['value'] = ''; $query->free_result(); //fin efectivo $mSQL = "SELECT a.concepto, a.descrip, sum(b.monto) sistema\n\t\tFROM tardet a JOIN viepag b ON b.banco=a.concepto\n\t\tWHERE a.tarjeta='CT' AND b.tipo='CT' AND b.caja='{$caja}' AND b.cajero='{$cajero}' AND b.fecha={$qfecha} AND SUBSTRING(b.numero,1,1)<>'X'\n\t\tGROUP BY a.concepto UNION\n\t\tSELECT concepto, descrip, '0' sistema FROM tardet WHERE tarjeta='CT' AND concepto NOT IN (\n\t\tSELECT a.concepto FROM tardet a JOIN viepag b ON b.banco=a.concepto\n\t\tWHERE a.tarjeta='CT' AND b.tipo='CT' AND b.caja='{$caja}' AND b.cajero='{$cajero}' AND b.fecha={$qfecha} AND SUBSTRING(b.numero,1,1)<>'X'\n\t\tGROUP BY a.concepto)\n\t\tORDER BY concepto"; $i = 0; $ctsistema = 0; $js_cesArray = array(); $cestatiket = array(); $query = $this->db->query($mSQL); foreach ($query->result() as $row) { $catts['name'] = $catts['id'] = 'CCESTA' . $row->concepto; $cantidad = form_input($catts); $atts['name'] = $atts['id'] = 'TCESTA' . $row->concepto; $js_cesArray[] = $row->concepto; $atts['onChange'] = "montosolo('" . $atts['name'] . "'); tcestatiket();"; $monto = form_input($atts) . form_hidden('TCESTA_T' . $i, $row->concepto); $attsr['name'] = $attsr['id'] = 'SCESTA' . $row->concepto; $attsr['value'] = number_format($row->sistema, '2', ',', '.'); $sistema = form_input($attsr); $attsr['value'] = ''; $pasa = array(); $pasa['descrip'] = '<b>' . $row->concepto . '</b> ' . $row->descrip; $pasa['cant'] = $cantidad; $pasa['monto'] = $monto; $pasa['sistema'] = $sistema; $i++; $cestatiket[] = $pasa; $ctsistema += $row->sistema; } $ces_filas = $i; $query->free_result(); $mSQL = "SELECT a.tipo,a.nombre, sum(b.monto) sistema\n\t\tFROM tarjeta a JOIN viepag b ON a.tipo=b.tipo\n\t\tWHERE a.tipo NOT IN ('EF','CT','NC','ND', 'DE','IR','DP') AND b.caja='{$caja}' AND b.cajero='{$cajero}' AND b.fecha={$qfecha} AND SUBSTRING(b.numero,1,1)<>'X'\n\t\tGROUP BY a.tipo UNION SELECT tipo,nombre, '0' sistema FROM tarjeta \n\t\tWHERE tipo NOT IN (SELECT tipo FROM viepag WHERE caja='{$caja}' AND cajero='{$cajero}' AND fecha={$qfecha} GROUP BY tipo) \n\t\tAND tipo NOT IN ('EF','CT','NC','ND', 'DE','IR','DP') ORDER BY tipo"; $i = 0; $fpsistema = 0; $tarjetas = array(); $js_ofpArray = array(); $query = $this->db->query($mSQL); foreach ($query->result() as $row) { $catts['name'] = $catts['id'] = 'COFP' . $row->tipo; $cantidad = form_input($catts); $atts['name'] = $atts['id'] = 'TOFP' . $row->tipo; $atts['values'] = 0; $js_ofpArray[] = $row->tipo; $atts['onChange'] = "montosolo('" . $atts['name'] . "'); totrasfpa();"; $monto = form_input($atts) . form_hidden('TOFP_T' . $i, $row->tipo); $attsr['name'] = $attsr['id'] = 'SOFP' . $row->tipo; $attsr['value'] = number_format($row->sistema, '2', ',', '.'); $sistema = form_input($attsr); $attsr['value'] = ''; $pasa = array(); $pasa['descrip'] = '<b>' . $row->tipo . '</b> ' . $row->nombre; $pasa['cant'] = $cantidad; $pasa['monto'] = $monto; $pasa['sistema'] = $sistema; $fpsistema += $row->sistema; $tarjetas[] = $pasa; $i++; } $otr_filas = $i; $query->free_result(); $attsr = array('class' => 'inputnum', 'size' => '20', 'align' => 'right', 'readonly' => 'readonly'); $attRecEfe = $attSisEfe = $attDifEfe = $attsr; $attRecEfe['name'] = $attRecEfe['id'] = 'EFERECI'; $attSisEfe['name'] = $attSisEfe['id'] = 'EFESIST'; $attDifEfe['name'] = $attDifEfe['id'] = 'EFEDIFE'; $attSisEfe['value'] = number_format($msistema, '2', ',', '.'); $attRecCtk = $attSisCtk = $attDifCtk = $attsr; $attRecCtk['name'] = $attRecCtk['id'] = 'CTKRECI'; $attSisCtk['name'] = $attSisCtk['id'] = 'CTKSIST'; $attDifCtk['name'] = $attDifCtk['id'] = 'CTKDIFE'; $attSisCtk['value'] = number_format($ctsistema, '2', ',', '.'); $attRecOtr = $attSisOtr = $attDifOtr = $attsr; $attRecOtr['name'] = $attRecOtr['id'] = 'OTRRECI'; $attSisOtr['name'] = $attSisOtr['id'] = 'OTRSIST'; $attDifOtr['name'] = $attDifOtr['id'] = 'OTRDIFE'; $attSisOtr['value'] = number_format($fpsistema, '2', ',', '.'); $attRecRec = $attSisRec = $attDifRec = $attsr; $attRecRec['name'] = $attRecRec['id'] = 'RECRECI'; $attSisRec['name'] = $attSisRec['id'] = 'RECSIST'; $attDifRec['name'] = $attDifRec['id'] = 'RECDIFE'; $attSisRec['value'] = number_format($fpsistema + $ctsistema + $msistema, '2', ',', '.'); $resumen = array(0 => array('descrip' => 'Efectivo', 'recibido' => form_input($attRecEfe) . form_hidden('QEFEGLOBAL'), 'sistema' => form_input($attSisEfe) . form_hidden('QEFESISTEMA', $msistema), 'diferen' => form_input($attDifEfe)), 1 => array('descrip' => 'Cesta Tickets', 'recibido' => form_input($attRecCtk), 'sistema' => form_input($attSisCtk) . form_hidden('QCESSISTEMA', $ctsistema), 'diferen' => form_input($attDifCtk)), 3 => array('descrip' => 'Otros', 'recibido' => form_input($attRecOtr), 'sistema' => form_input($attSisOtr) . form_hidden('QOTRSISTEMA', $fpsistema), 'diferen' => form_input($attDifOtr)), 4 => array('descrip' => 'Recibido', 'recibido' => form_input($attRecRec), 'sistema' => form_input($attSisRec) . form_hidden('QTOTSISTEMA', $fpsistema + $ctsistema + $msistema), 'diferen' => form_input($attDifRec))); $script = "<script type='text/javascript'>\n\t\tfunction caldiferencia() {\n\t\t\tvar pre=new Array('EFE','CTK','OTR','REC');\n\t\t\tvar i=0,acumulador=0;\n\t\t\tfor(i=0;i<3;i++){\n\t\t\t\trecibid=des_number_format(document.getElementById(pre[i]+'RECI').value,'.',',');\n\t\t\t\tsistema=des_number_format(document.getElementById(pre[i]+'SIST').value,'.',',');\n\t\t\t\tdocument.getElementById(pre[i]+'DIFE').value=number_format(recibid-sistema,'.',',');\n\t\t\t\tacumulador=acumulador+recibid;\n\t\t\t}\n\t\t\tdocument.getElementById(pre[i]+'RECI').value=number_format(acumulador,'.',',');\n\t\t\tsistema=des_number_format(document.getElementById(pre[i]+'SIST').value,'.',',');\n\t\t\tdocument.getElementById(pre[i]+'DIFE').value=number_format(acumulador-sistema,'.',',');\n\t\t}\n\t\t\n\t\tfunction opera(valor,traeid) {\n\t\t\tcantidad=document.getElementById(traeid);\n\t\t\trecibe =document.getElementById('T'+traeid)\n\t\t\trecibe.value= number_format(cantidad.value*valor,'.',',');\n\t\t\ttefectivo();\n\t\t}\n\t\tfunction tefectivo() {\n\t\t\tvar i=0,acumulador=0;\n\t\t\tfor(i=0;i<{$efe_filas};i++){\n\t\t\t\tvalor=des_number_format(document.getElementById('TEFE'+i).value,'.',',');\n\t\t\t\tacumulador=acumulador+valor;\n\t\t\t}\n\t\t\ttotras=des_number_format(document.getElementById('TOTRAS').value,'.',',');\n\t\t\ttfondo=des_number_format(document.getElementById('TFONDO').value,'.',',');\n\t\t\ttotal=document.getElementById('EFETOTAL');\n\t\t\ttotal.value=number_format(acumulador+totras-tfondo,'.',',');\n\t\t\trecibido=document.getElementById('EFERECI');\n\t\t\trecibido.value=number_format(acumulador+totras-tfondo,'.',','); \n\t\t\tcaldiferencia();\n\t\t}\n\t\tfunction montosolo(traeid){\n\t\t\telemento=document.getElementById(traeid);\n\t\t\tvalor=des_number_format(elemento.value,'.',',');\n\t\t\telemento.value=number_format(valor,'.',',');\n\t\t}\n\t\tfunction tcestatiket() {\n\t\t\tvar pre=new Array('" . join("','", $js_cesArray) . "');\n\t\t\tvar i=0,acumulador=0;\n\t\t\tfor(i=0;i<{$ces_filas};i++){\n\t\t\t\tvalor=des_number_format(document.getElementById('TCESTA'+pre[i]).value,'.',',');\n\t\t\t\tacumulador=acumulador+valor;\n\t\t\t}\n\t\t\trecibido=document.getElementById('CTKRECI');\n\t\t\trecibido.value=number_format(acumulador,'.',',');\n\t\t\tcaldiferencia();\n\t\t}\n\t\tfunction totrasfpa() {\n\t\t\tvar pre=new Array('" . join("','", $js_ofpArray) . "');\n\t\t\tvar i=0,acumulador=0;\n\t\t\tfor(i=0;i<{$otr_filas};i++){\n\t\t\t\tvalor=des_number_format(document.getElementById('TOFP'+pre[i]).value,'.',',');\n\t\t\t\tacumulador=acumulador+valor;\n\t\t\t}\n\t\t\trecibido=document.getElementById('OTRRECI');\n\t\t\trecibido.value=number_format(acumulador,'.',',');\n\t\t\tcaldiferencia();\n\t\t}\n\t\t</script>"; $att_pcf = array('class' => 'input', 'size' => '30', 'align' => 'right'); $att_pcf['name'] = 'controlp'; $pcfiscal = form_input($att_pcf); $att_ucf = array('class' => 'input', 'size' => '30', 'align' => 'right'); $att_ucf['name'] = 'controlf'; $ucfiscal = form_input($att_ucf); $att_obs = array('class' => 'input', 'rows' => '2', 'align' => 'right'); $att_obs['name'] = 'observaciones'; $observa = form_textarea($att_obs); $efegrid = new DataGrid2('Efectivo', $efectivo); $efegrid->agrupar(' ', 'tipo'); $efegrid->per_page = count($efectivo); $efegrid->column("Denominacion", "denom", 'align="RIGHT"'); $efegrid->column("Cantidad", "<#cant#>", 'align="RIGHT"'); $efegrid->column("Sub-total", "<#sistema#>", 'align="RIGHT"'); $efegrid->build(); $data['listai'] = $efegrid->output; $targrid = new DataGrid('Otras Formas de Pago', $tarjetas); $targrid->per_page = count($tarjetas); $targrid->column("Descripcion", "<#descrip#>"); $targrid->column("Cantidad", "<#cant#>", 'align="RIGHT"'); $targrid->column("Monto", "<#monto#>", 'align="RIGHT"'); $targrid->column("Sistema", "<#sistema#>", 'align="RIGHT"'); $targrid->build(); $data['listad'] = $targrid->output; $cestagrid = new DataGrid('Cesta Tiket', $cestatiket); $cestagrid->per_page = count($cestatiket); $cestagrid->column("Descripcion", "<#descrip#>"); $cestagrid->column("Cantidad", "<#cant#>", 'align="RIGHT"'); $cestagrid->column("Monto", "<#monto#>", 'align="RIGHT"'); $cestagrid->column("Sistema", "<#sistema#>", 'align="RIGHT"'); $cestagrid->build(); $data['listad'] .= $cestagrid->output; $resugrid = new DataGrid('Resumen', $resumen); $resugrid->per_page = count($resumen); $resugrid->column("Descripcion", "<#descrip#>"); $resugrid->column("Recibido", "<#recibido#>", 'align="RIGHT"'); $resugrid->column("Sistema", "<#sistema#>", 'align="RIGHT"'); $resugrid->column("Diferencia", "<#diferen#>", 'align="RIGHT"'); $resugrid->build(); $data['listab'] = $resugrid->output . 'Primer control Fiscal ' . $pcfiscal . '<br>Ultimo control Fiscal ' . $ucfiscal . '<br>Observaciones<br>' . $observa; $data['submit'] = form_submit('mysubmit', 'Guardar'); $atts = array('onsubmit' => "return confirm('Seguro que desea Guardar')"); $hidden = array('otr_filas' => $otr_filas, 'ces_filas' => $ces_filas); //$data['form']=form_open("supermercado/cierre/guardar/$caja/$cajero/$qfecha",$atts,$hidden); //$data['titulo'] = $script.$this->rapyd->get_head()."<center><h2>Cierre de Caja $caja Cajero $cajero</h2></center>\n"; //$this->layout->buildPage('supermercado/view_cierre', $data); $ddata['content'] = form_open("supermercado/cierre/guardar/{$caja}/{$cajero}/{$qfecha}", $atts, $hidden); $ddata['content'] .= $this->load->view('view_cierre', $data, true); $ddata['content'] .= '<center>' . form_submit('mysubmit', 'Guardar') . '</center>'; $ddata['content'] .= form_close(); $ddata['title'] = "<h1>Cierre de caja {$caja} Cajero {$cajero}</h1>"; $ddata["head"] = $this->rapyd->get_head() . script('nformat.js') . $script; $this->load->view('view_ventanas', $ddata); }
function producto($anio = '', $depto = '', $fami = '', $grupo = '') { $this->rapyd->load("datagrid2"); $this->rapyd->load("dataform"); $this->load->helper('openflash'); if ($this->uri->segment(4)) { $anio = $this->uri->segment(4); } elseif (isset($_POST['anio'])) { $anio = $_POST['anio']; } if (empty($anio)) { $anio = date("Y"); } $fechai = $anio . '0101'; $fechaf = $anio . '1231'; $ajax_onchange = ' function get_familias(){ var url = "' . site_url('supermercado/maes/maesfamilias') . '"; var pars = "dpto="+$F("depto"); var myAjax = new Ajax.Updater("td_familia", url, { method: "post", parameters: pars }); var url = "' . site_url('supermercado/maes/maesgrupos') . '"; var gmyAjax = new Ajax.Updater("td_grupo", url); } function get_grupo(){ var url = "' . site_url('supermercado/maes/maesgrupos') . '"; var pars = "dpto="+$F("depto")+"&fami="+$F("familia"); var myAjax = new Ajax.Updater("td_grupo", url, { method: "post", parameters: pars }); }'; $filter = new DataForm('supermercado/tventas/producto'); $filter->script($ajax_onchange); $filter->title('Filtro de ventas por Producto'); $filter->anio = new inputField("Año", "anio"); $filter->anio->size = 4; $filter->anio->insertValue = $anio; $filter->anio->maxlength = 4; $filter->depto = new dropdownField("Departamento", "depto"); $filter->depto->options("SELECT depto, descrip FROM dpto GROUP BY depto ORDER BY depto"); $filter->depto->insertValue = $depto; $filter->depto->style = 'width:200px;'; $filter->fami = new dropdownField("Familia", "familia"); $filter->fami->options("SELECT familia,descrip FROM fami GROUP BY familia ORDER BY familia"); $filter->fami->insertValue = $fami; $filter->fami->style = 'width:200px;'; $filter->grupo = new dropdownField("Grupo", "grupo"); $filter->grupo->options("SELECT grupo,nom_grup FROM grup GROUP BY grupo ORDER BY grupo"); $filter->grupo->insertValue = $grupo; $filter->grupo->style = 'width:200px;'; $filter->button("btnsubmit", "Buscar", form2uri(site_url('supermercado/tventas/producto'), array('anio', 'depto', 'familia', 'grupo')), $position = "BL"); $filter->build_form(); $grid = new DataGrid2(); $select = array("a.depto", "a.familia", "a.grupo", "b.descrip", "SUM(a.monto) AS grantotal", "SUM(a.costo) AS costo", "SUM(a.cantidad) AS cantidad", "SUM(a.monto)-SUM(a.costo) AS ganancia", "(SUM(a.monto)-SUM(a.costo))*100/SUM(a.monto) AS pganancia"); $grid->db->select($select); $grid->db->from("est_item AS a"); $grid->db->join("maes AS b", "a.codigo=b.codigo"); $grid->db->where('fecha >= ', $fechai); $grid->db->where('fecha <= ', $fechaf); $grid->db->where('a.depto', $depto); $grid->db->where('a.familia', $fami); $grid->db->where('a.grupo', $grupo); $grid->db->groupby("a.codigo"); //$grid->db->limit=10; $grid->column("Producto", "descrip", "align='left'"); $grid->column("Total", "<number_format><#grantotal#>|2|,|.</number_format>", 'align=right'); $grid->column("Ganancia", "<number_format><#ganancia#>|2|,|.</number_format>", 'align=right'); $grid->column("% Ganancia", "<number_format><#pganancia#>|2|,|.</number_format> %", 'align=right'); $grid->column("Cantidad", "cantidad", "align='right'"); $grid->totalizar('grantotal', 'ganancia'); $grid->build(); //echo $grid->db->last_query(); $grafico = open_flash_chart_object(720, 450, site_url("supermercado/tventas/gproducto/{$anio}/{$depto}/{$fami}/{$grupo}")); $data['content'] = $grafico; $data['content'] .= $filter->output . $grid->output; $data["head"] = $this->rapyd->get_head(); $data['title'] = "<h1>Ventas por Producto</h1>"; $this->load->view('view_ventanas', $data); }
function diarias() { $this->rapyd->load("datagrid2"); $this->rapyd->load("dataform"); $this->load->helper('openflash'); $mSPRV = array('tabla' => 'sprv', 'columnas' => array('proveed' => 'Código', 'nombre' => 'Nombre', 'contacto' => 'Contacto'), 'filtro' => array('proveed' => 'Código', 'nombre' => 'Nombre'), 'retornar' => array('proveed' => 'cprv1'), 'titulo' => 'Buscar Proveedor'); $bSPRV = $this->datasis->modbus($mSPRV); if (isset($_POST['anio'])) { $anio = $_POST['anio']; } if (isset($_POST['mes'])) { $mes = $_POST['mes']; } else { $mes = '01'; } if (isset($_POST['ubica'])) { $ubica = $_POST['ubica']; } else { $ubica = NULL; } if (isset($_POST['cprv1'])) { $proveed = $_POST['cprv1']; } else { $cprv1 = NULL; } if (empty($mes)) { $mes = date("m"); } if (empty($anio)) { $anio = date("Y"); } $fechai = $anio . str_pad($mes, 2, "0", STR_PAD_LEFT) . '01'; $fechaf = $anio . str_pad($mes, 2, "0", STR_PAD_LEFT) . '31'; $sinv = array('tabla' => 'sinv', 'columnas' => array('codigo' => 'Código Producto', 'descrip' => 'Nombre'), 'filtro' => array('codigo' => 'Código Producto', 'descrip' => 'Nombre'), 'retornar' => array('codigo' => 'codigo'), 'titulo' => 'Buscar Vendedor'); $cboton = $this->datasis->modbus($sinv); $filter = new DataForm('supermercado/productos/diarias'); //$filter->attributes=array('onsubmit'=>"this.action='index/'+this.form.mes.value+'/'+this.form.anio.value+'/';return FALSE;"); $filter->title('Filtro de Ventas Diarias'); $filter->mes = new dropdownField("Mes/Año", "mes"); for ($i = 1; $i < 13; $i++) { $filter->mes->option(str_pad($i, 2, '0', STR_PAD_LEFT), str_pad($i, 2, '0', STR_PAD_LEFT)); } $filter->mes->size = 2; $filter->mes->style = ''; $filter->mes->insertValue = $mes; //cprv1 $filter->almacen = new dropdownField("Almacen", "ubica"); $filter->almacen->option('', 'Todos'); $filter->almacen->options('SELECT ubica, ubides FROM caub WHERE gasto="N"'); $filter->almacen->dbname = 'a.ubica'; $filter->almacen->insertValue = $ubica; $filter->proveed = new inputField("Proveedor", "cprv1"); $filter->proveed->db_name = "b.cprv1"; $filter->proveed->append($bSPRV); $filter->anio = new inputField("Año", "anio"); $filter->anio->in = 'mes'; $filter->anio->size = 4; $filter->anio->insertValue = $anio; $filter->anio->rule = "max_length[4]"; //$filter->button("btnsubmit", "Buscar", form2uri(site_url('supermercado/productos/diarias/'),array('anio','mes','ubica','cprv1')), $position="BL"); $filter->submit("btnsubmit", "Buscar"); $filter->build_form(); $grid = new DataGrid2(); $select = array("a.codigo AS codigo", "b.descrip AS nombre", "SUM(a.cantidad) AS cantidad", "SUM(a.venta)AS grantotal", "COUNT(*) AS numfac"); $grid->db->select($select); $grid->db->from("costos AS a"); $grid->db->join("maes AS b", "a.codigo=b.codigo"); $grid->db->where('fecha >= ', $fechai); $grid->db->where('fecha <= ', $fechaf); $grid->db->where("origen IN ('3I','3M','3R')"); if (!empty($ubica)) { $grid->db->where('a.ubica', $ubica); } if (!empty($proveed)) { $grid->db->where('b.cprv1', $proveed); } $grid->db->groupby("b.codigo"); $grid->db->orderby("cantidad", 'desc'); $grid->db->limit(500); $grid->column("Codigo", "codigo", "align='left'"); $grid->column("Descripción", "nombre"); $grid->column("Total", "<number_format><#grantotal#>|2|,|.</number_format>", 'align=right'); $grid->column("Cantidad", "<number_format><#cantidad#>|2|,|.</number_format>", 'align=right'); $grid->column("Cant. Fact", "numfac", 'align=right'); $grid->totalizar('grantotal'); $grid->build(); //echo $grid->db->last_query(); $data['content'] = $filter->output . $grid->output; $data["head"] = $this->rapyd->get_head(); $data['title'] = $this->rapyd->get_head() . "<h1>Ventas Diarias</h1>"; $this->load->view('view_ventanas', $data); }
function diarias($anio = '', $vendedor = '', $mes = '') { $this->rapyd->load("datagrid2"); $this->rapyd->load("dataform"); $this->load->helper('openflash'); $script = ' $(function() { $(".inputnum").numeric("."); }); '; if (isset($_POST['anio']) and empty($anio)) { $anio = $_POST['anio']; } if (isset($_POST['mes']) and empty($mes)) { $mes = $_POST['mes']; } if (isset($_POST['vd']) and empty($vendedor)) { $vendedor = $_POST['vd']; } //if(empty($anio) OR ($vendedor)) redirect("ventas/vendedoresanuales/index/$anio"); if (empty($mes)) { redirect("ventas/vendedores/mensuales/{$anio}/{$vendedor}"); } $fechai = $anio . str_pad($mes, 2, "0", STR_PAD_LEFT) . '01'; $fechaf = $anio . str_pad($mes, 2, "0", STR_PAD_LEFT) . '31'; $scli = array('tabla' => 'scli', 'columnas' => array('cliente' => 'C<p align="right">ó</p>digo Vendedor', 'nombre' => 'Nombre', 'contacto' => 'Contacto'), 'filtro' => array('cliente' => 'Código Cliente', 'nombre' => 'Nombre'), 'retornar' => array('cliente' => 'cod_cli'), 'titulo' => 'Buscar Cliente'); $cboton = $this->datasis->modbus($scli); $filter = new DataForm('ventas/vendedores/diarias'); $filter->attributes = array('onsubmit' => "this.action='index/'+this.form.mes.value+'/'+this.form.anio.value+'/';return FALSE;"); $filter->title('Filtro de Ventas Diarias'); $filter->script($script, "create"); $filter->script($script, "modify"); $filter->mes = new dropdownField("Mes/Año", "mes"); for ($i = 1; $i < 13; $i++) { $filter->mes->option(str_pad($i, 2, '0', STR_PAD_LEFT), str_pad($i, 2, '0', STR_PAD_LEFT)); } $filter->mes->size = 2; $filter->mes->style = ''; $filter->mes->insertValue = $mes; $filter->anio = new inputField("Año", "anio"); $filter->anio->in = 'mes'; $filter->anio->size = 4; $filter->anio->insertValue = $anio; $filter->anio->maxlength = 4; $filter->anio->rule = "trim"; $filter->anio->css_class = 'inputnum'; $filter->vendedor = new inputField("Vendedor", "vd"); $filter->vendedor->size = 10; $filter->vendedor->insertValue = $vendedor; $filter->vendedor->rule = "max_length[4]"; $filter->vendedor->append($cboton); $filter->button("btnsubmit", "Buscar", form2uri(site_url('ventas/vendedores/diarias/'), array('anio', 'vd', 'mes')), $position = "BL"); $filter->build_form(); $grid = new DataGrid2(); $select = array("vd", "DATE_FORMAT(fecha,'%d/%m/%Y') AS fecha", "SUM(totalg*IF(tipo_doc='D', -1, 1)) AS grantotal", "SUM(totalg*IF(tipo_doc='D', -1, 1))/ COUNT(*) AS porcentaje", "SUM(totalg*(referen IN ('E', 'M'))*IF(tipo_doc='D', -1, 1)) as contado", "SUM(totalg*(referen NOT IN ('E', 'M'))*IF(tipo_doc='D', -1, 1)) as credito", "FORMAT(sum(totals*IF(tipo_doc='D',-1,1)),2) AS subtotal", "FORMAT(sum(iva*IF(tipo_doc='D',-1,1)),2) AS impuesto", "COUNT(*) AS numfac"); $grid->db->select($select); $grid->db->from("sfac"); $grid->db->where('tipo_doc <> ', 'X'); $grid->db->where('fecha >= ', $fechai); $grid->db->where('fecha <= ', $fechaf); $grid->db->where('vd ', $vendedor); $grid->db->groupby("fecha"); $grid->column("Dia", "fecha", "align='center'"); $grid->column("Sub-Total", "<number_format><#subtotal#>|2|,|.</number_format>", 'align=right'); $grid->column("Impuesto", "<number_format><#impuesto#>|2|,|.</number_format>", 'align=right'); $grid->column("Total", "<number_format><#grantotal#>|2|,|.</number_format>", 'align=right'); $grid->column("Contado", "<number_format><#contado#>|2|,|.</number_format>", 'align=right'); $grid->column("Crédito", "<number_format><#credito#>|2|,|.</number_format>", 'align=right'); $grid->column("Participación", "<number_format><#porcentaje#>|2|,|.</number_format>", 'align=right'); $grid->column("Cant. Fact", "numfac", 'align=right'); $grid->totalizar('subtotal', 'impuesto', 'grantotal', 'contado', 'credito'); $grid->build(); $grafico = open_flash_chart_object(680, 350, site_url("ventas/vendedores/gdiarias/{$anio}/{$vendedor}/{$mes}")); $data['content'] = $grafico; $data['content'] .= $filter->output . $grid->output; $data["head"] = script("jquery.pack.js") . script("plugins/jquery.numeric.pack.js") . script("plugins/jquery.floatnumber.js") . $this->rapyd->get_head(); $data['title'] = $this->rapyd->get_head() . "<h1>Vendedores</h1>"; $this->load->view('view_ventanas', $data); }
function mostrar($data4) { $this->rapyd->load("datagrid2", "dataform"); $form = new DataForm("/supervisor/subexls/actualiza"); $form->free = new freeField("Campos.Archivo xls", "free", "Campos de El Sistema"); //var_dump($data4); //print_r($data4); $grid = new DataGrid2("Archivo Cargado", $data4); $j = 0; $campos .= 'cols="+$("#cols").val()+"&&dir="+$("#dir").val()'; foreach ($cols as $col) { $grid->column("{$col}", "<#{$col}#>"); $campo = "campo{$j}"; $form->{$campo} = new dropdownField("{$col}", "campo{$j}"); $form->{$campo}->option("ignorar", "ignorar"); $form->{$campo}->option("codigo", "codigo"); $form->{$campo}->option("costo", "costo"); $form->{$campo}->option("descrip", "descrip"); $form->{$campo}->option("descrip2", "descrip2"); $form->{$campo}->option("clave", "clave"); $form->{$campo}->option("grupo", "grupo"); $form->{$campo}->option("iva", "iva"); for ($i = 1; $i <= 3; $i++) { $form->{$campo}->option("base{$i}", "Base{$i}"); $form->{$campo}->option("margen{$i}", "Margen{$i}"); $form->{$campo}->option("precio{$i}", "Precio{$i}"); } $form->{$campo}->style = 'width:150px;'; $j++; $campos .= "+" . "\"&&" . $campo . "=\"+\$(\"#" . $campo . "\").val()"; } //echo $campos; $form->cols = new inputField("", "cols"); $form->cols->insertValue = implode(',', $cols); $form->cols->type = 'hidden'; $form->dir = new inputField("", "dir"); $form->dir->insertValue = $dir; $form->dir->type = 'hidden'; //$form->submit("btnsubmit","Actualizar"); $link = site_url('supervisor/subexls/actualiza'); $script = ' function actu(){ a=confirm("�Esta Seguro que de desea Actualizar el Inventario ?"); if(a){ $.ajax({ type: "POST", processData:false, url: "' . $link . '", data: "' . $campos . ', success: function(msg){ if(msg=="s.i"){ alert("El Inventario fue Actualizado."); } else{ alert(msg); } } }); } } '; $form->script($script); $form->button("actualiza", "Actualizar", "javascript:actu();"); $form->build_form(); $grid->build(); $data2['content'] = $form->output . $salida . $grid->output; }
function vista() { $this->rapyd->load("datagrid2"); $f1 = $this->input->post('fechad'); $f2 = $this->input->post('fechah'); $fechad = $this->db->escape(human_to_dbdate($f1)); $fechah = $this->db->escape(human_to_dbdate($f2)); $codigoadm = ''; $fondo = ''; $codigoadm2 = $this->db->escape($this->input->post('codigoadm')); $fondo2 = $this->db->escape($this->input->post('fondo')); function blanco($codigo) { if ($codigo > 0) { $codigo = str_pad($codigo, 8, '0', STR_PAD_LEFT); } return $codigo; } function union($fecha, $codigo) { return date('Ym', strtotime($fecha)) . str_pad($codigo, 8, '0', STR_PAD_LEFT); } $uri = anchor($this->url . 'dataedit/show/<#numero#>', '<str_pad><#numero#>|8|0|STR_PAD_LEFT</str_pad>'); //$cant = $this->datasis->dameval("SELECT COUNT(*) //JOIN pades b ON a.numero = b.pago //JOIN desem c ON b.desem = c.numero //WHERE c.status='D2' AND reten >0 AND fdesem>=$fechad AND fdesem<= $fechah"); $query = "SELECT COUNT(*) FROM ("; $query .= "\r\n\t\tSELECT '',a.numero,a.impmunicipal,c.fdesem,factura,controlfac,fechafac,a.fmunicipal,c.cod_prov FROM odirect a \r\n\t\tJOIN pades b ON a.numero = b.pago\r\n\t\tJOIN desem c ON b.desem = c.numero\r\n\t\tJOIN sprv p ON c.cod_prov = p.proveed\r\n\t\tWHERE c.status='D2' AND impmunicipal >0 AND fdesem>={$fechad} AND fdesem<= {$fechah} AND MID(a.status,1,1)<>'F' AND (a.mmuni IS NULL) "; if (!empty($codigoadm)) { $query .= " AND a.estadmin='{$codigoadm}'"; } if (!empty($fondo)) { $query .= " AND a.fondo='{$fondo}'"; } $query .= "\r\n\t\t)a "; $cant = $this->datasis->dameval($query); $this->db->query("DROP TABLE IF EXISTS MUNICIPAL"); $query = "\r\n\t\tCREATE TABLE MUNICIPAL SELECT * FROM ("; $query .= "\r\n\t\t\r\n\t\tSELECT a.numero,a.impmunicipal,c.fdesem,factura,controlfac,fechafac,a.fmunicipal,c.cod_prov,a.estadmin codigoadm,a.fondo FROM odirect a \r\n\t\tJOIN pades b ON a.numero = b.pago\r\n\t\tJOIN desem c ON b.desem = c.numero\r\n\t\tJOIN sprv p ON c.cod_prov = p.proveed\r\n\t\tWHERE c.status='D2' AND impmunicipal >0 AND fdesem>={$fechad} AND fdesem<= {$fechah} AND MID(a.status,1,1)<>'F' AND (a.mmuni IS NULL)"; if (!empty($codigoadm)) { $query .= " AND a.estadmin='{$codigoadm}'"; } if (!empty($fondo)) { $query .= " AND a.fondo='{$fondo}'"; } $query .= "\r\n\t\t)a JOIN sprv b ON a.cod_prov = b.proveed "; $this->db->query($query); $grid = new DataGrid2("Lista de " . $this->titp); $grid->db->from("MUNICIPAL"); $grid->order_by("numero", "desc"); $grid->per_page = 1000; $grid->use_function('substr', 'str_pad', 'blanco', 'union'); $grid->use_function('sta'); $grid->column("orden de Pago", "<str_pad><#numero#>|8|0|STR_PAD_LEFT</str_pad>"); $grid->column("O. Compra", "<blanco><#ocompra#>|8|0|STR_PAD_LEFT</blanco>"); $grid->column("Emision", "<dbdate_to_human><#fmunicipal#></dbdate_to_human>", "align='center'"); $grid->column("Factura", "factura"); $grid->column("Nro. Control", "controlfac"); $grid->column("Fecha Fac", "<dbdate_to_human><#fechafac#></dbdate_to_human>", "align='center'"); $grid->column("Proveedor", "nombre"); $grid->column("RIF", "rif"); $grid->column("Monto", "<number_format><#impmunicipal#>|2|,|.</number_format>", "align='right'"); $grid->column("Est. Admin", "codigoadm"); $grid->column("Fondo", "fondo"); $grid->totalizar('impmunicipal'); $grid->build(); //echo $grid->db->last_query(); //exit(); $campo = "\r\n \t\t<input size='100' type='hidden' name='fechad' value='{$f1}'>\r\n \t\t<input size='100' type='hidden' name='fechah' value='{$f2}'>\r\n \t\t<input size='100' type='hidden' name='cant' value='{$cant}'>\r\n \t\t<input size='100' type='hidden' name='codigoadm' value='{$codigoadm}'>\r\n \t\t<input size='100' type='hidden' name='fondo' value='{$fondo}'>\r\n \t\t"; $data['content'] = anchor($this->url . "nuevo", 'Ir atras') . $grid->output . form_open($this->url . 'guardar') . $campo . form_submit('mysubmit', 'Guardar') . form_close(); $data['title'] = " {$this->titp} "; $data["head"] = $this->rapyd->get_head(); $this->load->view('view_ventanas', $data); }
function diarias($anio = '', $proveed = '', $mes = '') { $this->rapyd->load('datagrid2'); $this->rapyd->load('dataform'); $this->load->helper('openflash'); $proveed = radecode($proveed); if (isset($_POST['anio']) && empty($anio)) { $anio = $_POST['anio']; } if (isset($_POST['mes']) && empty($mes)) { $mes = $_POST['mes']; } if (isset($_POST['proveed']) && empty($proveed)) { $proveed = $_POST['proveed']; } if (empty($mes)) { redirect("compras/proveedores/mensuales/{$anio}/{$proveed}"); } $fechai = $anio . str_pad($mes, 2, '0', STR_PAD_LEFT) . '01'; $fechaf = $anio . str_pad($mes, 2, '0', STR_PAD_LEFT) . '31'; $scli = array('tabla' => 'sprv', 'columnas' => array('proveed' => 'Codigo proveedor', 'nombre' => 'Nombre'), 'filtro' => array('proveed' => 'Còdigo proveedor', 'nombre' => 'Nombre'), 'retornar' => array('proveed' => 'proveed'), 'titulo' => 'Buscar proveedor'); $cboton = $this->datasis->modbus($scli); $filter = new DataForm('compras/proveedoresdiarios'); $filter->attributes = array('onsubmit' => "this.action='index/'+this.form.mes.value+'/'+this.form.anio.value+'/';return FALSE;"); $filter->title('Filtro de Compras Diarias'); $filter->mes = new dropdownField('Mes/Año', 'mes'); for ($i = 1; $i < 13; $i++) { $filter->mes->option(str_pad($i, 2, '0', STR_PAD_LEFT), str_pad($i, 2, '0', STR_PAD_LEFT)); } $filter->mes->size = 2; $filter->mes->style = ''; $filter->mes->insertValue = $mes; $filter->anio = new inputField('Año', 'anio'); $filter->anio->in = 'mes'; $filter->anio->size = 4; $filter->anio->insertValue = $anio; $filter->anio->rule = 'max_length[4]'; $filter->proveedor = new inputField('Proveedor', 'proveed'); $filter->proveedor->size = 10; $filter->proveedor->insertValue = $proveed; $filter->proveedor->rule = 'max_length[4]'; $filter->proveedor->append($cboton); $filter->button('btnsubmit', 'Buscar', form2uri(site_url('compras/proveedores/diarias/'), array('anio', 'proveed', 'mes')), $position = 'BL'); $filter->build_form(); $grid = new DataGrid2(); $select = array('proveed', "DATE_FORMAT(fecha,'%d/%m/%Y') AS fecha", "SUM(montonet*IF(tipo_doc='NC',-1,1)) AS grantotal", "SUM(inicial*IF( tipo_doc='NC',-1,1)) AS contado", "SUM(credito*IF( tipo_doc='NC',-1,1)) AS credito", "SUM(montotot*IF(tipo_doc='NC',-1,1)) AS subtotal", "SUM(montoiva*IF(tipo_doc='NC',-1,1)) AS impuesto", 'COUNT(*) AS numfac'); $grid->db->select($select); $grid->db->from('scst'); $grid->db->where('tipo_doc <> ', 'NE'); $grid->db->where('fecha >= ', $fechai); $grid->db->where('fecha <= ', $fechaf); $grid->db->where('proveed', $proveed); $grid->db->where('actuali >= fecha'); $grid->db->groupby('fecha'); $grid->column('Fecha', "fecha", "align='center'"); $grid->column('Sub-Total', "<number_format><#subtotal#>|2|,|.</number_format>", 'align=right'); $grid->column('Impuesto', "<number_format><#impuesto#>|2|,|.</number_format>", 'align=right'); $grid->column('Total', "<number_format><#grantotal#>|2|,|.</number_format>", 'align=right'); $grid->column('Contado', "<number_format><#contado#>|2|,|.</number_format>", 'align=right'); $grid->column('Credito', "<number_format><#credito#>|2|,|.</number_format>", 'align=right'); $grid->column('Cant. Fact', "numfac", 'align=right'); $grid->totalizar('impuesto', 'grantotal', 'contado', 'credito', 'subtotal'); $grid->build(); $proveed = raencode($proveed); $grafico = open_flash_chart_object(680, 350, site_url("compras/proveedores/gdiarias/{$anio}/{$proveed}/{$mes}")); $data['content'] = $grafico; $data['content'] .= $filter->output . $grid->output; $data['head'] = $this->rapyd->get_head(); $data['title'] = '<h1>Compras Diarias</h1>'; $this->load->view('view_ventanas', $data); }
function resumen() { $this->rapyd->load('datagrid2', 'datafilter', 'datatable'); $form = new DataForm("finanzas/resumendiario/resumen/process"); $form->fecha = new dateonlyField("Fecha", "fecha"); $form->fecha->insertValue = date("Y-m-d"); $form->fecha->rule = "required|chfecha"; $form->fecha->size = 12; $form->submit("btnsubmit", "Consultar"); $form->build_form(); if ($form->on_success()) { $this->fecha = $form->fecha->newValue; } $dbfecha = $this->db->escape($this->fecha); //*********************************** // RESUMEN DE CAJAS (RCAJ) //*********************************** $grid = new DataGrid2("Resumen de Cajas"); $grid->db->select(array("cajero", "ingreso AS venta", "recibido", "(ingreso - recibido) AS diferencia")); $grid->db->from("rcaj"); $grid->db->where("fecha", $this->fecha); $grid->order_by("caja", "asc"); //$grid->per_page = 15; $grid->column('Caja', 'cajero', "align='center'"); $grid->column('Venta', '<nformat><#venta#></nformat>', "align='right'"); $grid->column('Recibido', '<nformat><#recibido#></nformat>', "align='right'"); $grid->column('Diferencia', '<nformat><#diferencia#></nformat>', "align='right'"); $grid->totalizar("venta", "recibido", "diferencia"); $grid->build(); //*********************************** //DISTRIBUCION DE LA COBRANZA (SFPA) //*********************************** $grid2 = new DataGrid2('Distribución de la cobranza'); $grid2->db->select(array('a.tipo', 'b.nombre', 'sum(a.monto) AS monto', 'COUNT(*) AS cantidad')); $grid2->db->from('sfpa a'); $grid2->db->join('tarjeta b', 'a.tipo=b.tipo'); $grid2->db->where('f_factura', $this->fecha); $grid2->db->groupby('a.tipo'); $grid2->order_by('a.tipo', 'asc'); //$grid2->per_page = 15; $grid2->column('Tipo', '(<#tipo#>) <#nombre#>', "align='left'"); $grid2->column('Cantidad', 'cantidad', "align='right'"); $grid2->column('Monto', '<nformat><#monto#></nformat>', "align='right'"); $grid2->totalizar('monto'); $grid2->build(); //*********************************** // VENTAS Y DEVOLUCIONES //*********************************** function vdnom($tipo_doc, $referen) { $nombre = $tipo_doc == 'D' ? 'Devoluciones ' : 'Ventas '; $nombre .= $referen == 'E' ? 'al Contado' : 'a Credito'; return $nombre; } $grid3 = new DataGrid2("Distribución de la cobranza"); $grid3->db->select(array('tipo_doc', 'referen', 'COUNT(*) AS cana', 'SUM(totals)*IF(tipo_doc = "D" ,-1,1) AS monto')); $grid3->db->from("sfac a"); $grid3->db->where('referen <>', 'P'); $grid3->db->where('fecha', $this->fecha); $grid3->db->groupby('tipo_doc'); $grid3->db->groupby('referen'); $grid3->use_function('vdnom'); $grid3->column('Tipo', '<vdnom><#tipo_doc#>|<#referen#></vdnom>', "align='left'"); $grid3->column('Cantidad', '<nformat><#cana#>|0</nformat>', "align='right'"); $grid3->column('Monto', '<nformat><#monto#></nformat>', "align='right'"); $grid3->totalizar('monto'); $grid3->build(); //*********************************** // RESUMEN DE VENTAS //*********************************** $udia = days_in_month(substr($this->fecha, 4, 2), substr($this->fecha, 0, 4)); $fdesde = substr($this->fecha, 0, 6) . '01'; $fhasta = substr($this->fecha, 0, 6) . $udia; $ano = substr($this->fecha, 0, 4); $row1 = $this->datasis->damerow("SELECT COUNT(*) AS a,SUM(totals*(IF(tipo_doc = 'F',1,-1))) AS b FROM sfac WHERE tipo_doc <>'X' AND YEAR(fecha) = {$ano} AND fecha < {$dbfecha}"); $row2 = $this->datasis->damerow("SELECT COUNT(*) AS a,SUM(totals*(IF(tipo_doc = 'F',1,-1))) AS b FROM sfac WHERE tipo_doc <>'X' AND fecha BETWEEN {$fdesde} AND {$fhasta}"); $row3 = $this->datasis->damerow("SELECT COUNT(*) AS a,SUM(totals*(IF(tipo_doc = 'F',1,-1))) AS b FROM sfac WHERE tipo_doc <>'X' AND fecha = {$dbfecha}"); $cost1 = $this->datasis->dameval("SELECT SUM(costo*cana*(IF(tipoa = 'F',1,-1))) AS a FROM sitems WHERE tipoa <>'X' AND YEAR(fecha) = {$ano} AND fecha < {$dbfecha}"); $cost2 = $this->datasis->dameval("SELECT SUM(costo*cana*(IF(tipoa = 'F',1,-1))) AS a FROM sitems WHERE tipoa <>'X' AND fecha BETWEEN {$fdesde} AND {$dbfecha}"); $cost3 = $this->datasis->dameval("SELECT SUM(costo*cana*(IF(tipoa = 'F',1,-1))) AS a FROM sitems WHERE tipoa <>'X' AND fecha = {$dbfecha}"); if (empty($row1)) { $row1 = array('a' => 0, 'b' => 0); } if (empty($row2)) { $row2 = array('a' => 0, 'b' => 0); } if (empty($row3)) { $row3 = array('a' => 0, 'b' => 0); } $row1['c'] = $cost1; $row2['c'] = $cost2; $row3['c'] = $cost3; $rdata[0] = array('a' => $row1['a'], 'b' => $row1['b'], 'c' => $row1['c'], 'd' => $row1['b'] - $row1['c'], 'razon' => 'Ventas en lo que va de año'); $rdata[1] = array('a' => $row2['a'], 'b' => $row2['b'], 'c' => $row2['c'], 'd' => $row2['b'] - $row2['c'], 'razon' => 'Ventas en lo que va de mes'); $rdata[2] = array('a' => $row3['a'], 'b' => $row3['b'], 'c' => $row3['c'], 'd' => $row3['b'] - $row3['c'], 'razon' => 'Ventas de hoy'); $grid8 = new DataGrid("Resumen de Ventas " . $this->fecha, $rdata); $grid8->column("Razón", "razon"); $grid8->column("Cantidad", "a", "align='right'"); $grid8->column("Costo", "<nformat><#c#></nformat>", "align='right'"); $grid8->column("Monto", "<nformat><#b#></nformat>", "align='right'"); $grid8->column("Margen", "<nformat><#d#></nformat>", "align='right'"); $grid8->build(); $rdata = array(); //*********************************** // CUENTAS POR COBRAR (smov) //*********************************** $grid4 = new DataGrid2('Cuentas por Cobrar'); $grid4->db->select(array("c.gr_desc grupo", "SUM((a.monto-a.abonos)*IF(tipo_doc='AN',-1,1))saldo")); $grid4->db->from('smov a'); $grid4->db->join('scli b', 'a.cod_cli = b.cliente'); $grid4->db->join('grcl c', 'b.grupo = c.grupo'); $grid4->db->where("a.tipo_doc IN ('FC','ND','GI','AN')"); $grid4->db->groupby('c.gr_desc'); $grid4->order_by("c.gr_desc", "asc"); //$grid4->per_page = 15; $grid4->column('Grupo de Clientes', 'grupo', "align='left'"); $grid4->column('Monto', '<nformat><#saldo#></nformat>', "align='right'"); $grid4->totalizar('saldo'); $grid4->build(); //*********************************** // GASTOS //*********************************** $row = $this->datasis->dameval("SELECT SUM(montotot) AS a FROM scst WHERE tipo_doc = 'FC' AND recep = {$dbfecha}"); $row2 = $this->datasis->dameval("SELECT SUM(totbruto) AS a FROM gser WHERE tipo_doc = 'FC' AND fecha = {$dbfecha}"); $rdata[0] = array('nombre' => 'Total de Compras', 'monto' => $row); $rdata[1] = array('nombre' => 'Total de Gastos', 'monto' => $row2); $grid7 = new DataGrid2('Total Compras y Gastos de Hoy', $rdata); $grid7->column('Razón', 'nombre'); $grid7->column('Monto', '<nformat><#monto#></nformat>', "align='right'"); $grid7->totalizar('monto'); $grid7->build(); //*********************************** // CUENTAS POR PAGAR (sprm) //*********************************** $grid5 = new DataGrid2('Cuentas por Pagar'); $grid5->db->select(array('c.gr_desc grupo', "SUM((a.monto-a.abonos)*IF(tipo_doc = 'AN',-1,1)) saldo")); $grid5->db->from('sprm a'); $grid5->db->join('sprv b', 'a.cod_prv = b.proveed'); $grid5->db->join('grpr c', 'b.grupo = c.grupo'); $grid5->db->where("a.tipo_doc IN ('FC','ND','GI','AN')"); $grid5->db->groupby('c.gr_desc'); $grid5->order_by('c.gr_desc', 'asc'); //$grid5->per_page = 15; $grid5->column('Grupo de Proveedoores', 'grupo', "align='left'"); $grid5->column('Monto', '<nformat><#saldo#></nformat>', "align='right'"); $grid5->totalizar('saldo'); $grid5->build(); //*********************************** // PROMEDIO INVENTARIO (sinv) //*********************************** $grid6 = new DataGrid2('Total de Inventario'); $grid6->db->select(array('d.descrip AS descrip', 'SUM(a.pond*a.existen) AS suma')); $grid6->db->from('sinv a'); $grid6->db->join('grup b ', 'a.grupo = b.grupo'); $grid6->db->join('line c ', 'b.linea = c.linea'); $grid6->db->join('dpto d ', 'd.depto = c.depto'); $grid6->db->groupby('c.depto'); $grid6->db->order_by('d.descrip'); //$grid6->per_page = 15; $grid6->column('Departamento', 'descrip', "align='left'"); $grid6->column('Monto', '<nformat><#suma#></nformat>', "align='right'"); $grid6->totalizar('suma'); $grid6->build(); $data['rcaj'] = $grid->output; $data['sfpa'] = $grid2->output; $data['tot'] = $grid3->output; $data['resven'] = $grid8->output; $data['smov'] = $grid4->output; $data['scstgser'] = $grid7->output; $data['sprm'] = $grid5->output; $data['sinv'] = $grid6->output; $data0['content'] = $form->output . $this->load->view('view_resumendiario', $data, TRUE); $data0['head'] = $this->rapyd->get_head(); $data0['title'] = "<h1>" . $this->t**s . " para la fecha " . dbdate_to_human($this->fecha) . "</h1>"; $this->load->view('view_ventanas', $data0); }
function filteredgrid() { $this->rapyd->load('datafilter', 'datagrid2'); $atts = array('width' => '800', 'height' => '600', 'scrollbars' => 'yes', 'status' => 'yes', 'resizable' => 'yes', 'screenx' => '5', 'screeny' => '5'); function convierte($par, $link) { $atts = array('width' => '800', 'height' => '600', 'scrollbars' => 'yes', 'status' => 'yes', 'resizable' => 'yes', 'screenx' => '5', 'screeny' => '5'); switch ($par) { case '3I': return anchor_popup($link, 'Ventas Caja', $atts); break; case '3M': return anchor_popup($link, 'Ventas Mayor', $atts); break; case '1T': return anchor_popup($link, 'Transferencias', $atts); break; case '2C': return anchor_popup($link, 'Compras', $atts); break; case '4N': return anchor_popup($link, 'Nota/Entrega', $atts); break; case '6C': return 'Conversiones'; break; case '5A': return 'Ajustes'; break; case '0F': return 'Inventario'; break; case '9F': return 'Inventario'; break; default: return $par; } } $modbus = array('tabla' => 'maes', 'columnas' => array('codigo' => 'Código', 'descrip' => 'Descripción', 'precio1' => 'Precio 1', 'precio2' => 'Precio 2', 'precio3' => 'Precio 3', 'precio4' => 'Precio 4', 'precio5' => 'Precio 5'), 'filtro' => array('codigo' => 'Código', 'descrip' => 'Descripción'), 'retornar' => array('codigo' => 'codigo'), 'titulo' => 'Buscar en inventario'); $boton = $this->datasis->modbus($modbus); $filter = new DataFilter("Kardex de Inventario (" . anchor_popup('/supermercado/lfisico', 'Resumen de inventarios', $atts) . ')'); $filter->codigo = new inputField("Código De Producto", "codigo"); $filter->codigo->append($boton); $filter->ubica = new dropdownField("Almacen", "ubica"); $filter->ubica->option("", "Todos"); $filter->ubica->db_name = 'a.ubica'; $filter->ubica->options("SELECT ubica,CONCAT(ubica,' ',ubides) descrip FROM caub WHERE gasto='N' "); $filter->ubica->operator = "="; $filter->ubica->clause = "where"; $filter->fechad = new dateonlyField("Desde", "fecha", "d/m/Y"); $filter->fechad->operator = ">="; $filter->fechad->insertValue = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - 30, date("Y"))); $filter->fechah = new dateonlyField("Hasta", "fechah", "d/m/Y"); $filter->fechah->db_name = 'fecha'; $filter->fechah->operator = "<="; $filter->fechah->insertValue = date("Y-m-d"); $filter->fechah->clause = $filter->fechad->clause = $filter->codigo->clause = "where"; $filter->fechah->size = $filter->fechad->size = 10; $filter->buttons("reset", "search"); $filter->build(); $data['content'] = $filter->output; if (isset($_POST['codigo'])) { $code = $_POST['codigo']; $mSQL = "SELECT descrip FROM maes WHERE codigo='{$code}'"; $query = $this->db->query($mSQL); $descrip = ''; if ($query->num_rows() > 0) { $row = $query->row(); $descrip = $row->descrip; } $link = "/supermercado/kardex/grid/<#origen#>/<dbdate_to_human><#fecha#>|Ymd</dbdate_to_human>/<str_replace>/|:slach:|<#codigo#></str_replace>/<#ubica#>"; $grid = new DataGrid2("({$code}) {$descrip}"); $grid->agrupar('Almacen: ', 'almacen'); $grid->use_function('convierte', 'number_format', 'str_replace'); $grid->db->select("IFNULL( b.ubides , a.ubica ) almacen,a.ubica ,a.fecha, a.venta, a.cantidad, a.saldo, a.monto, a.salcant, a.codigo, a.origen, a.promedio"); $grid->db->from('costos a'); $grid->db->join('caub b ', 'b.ubica=a.ubica', 'LEFT'); $grid->db->orderby('almacen, fecha, origen'); $grid->per_page = 20; $grid->column("Fecha", "<dbdate_to_human><#fecha#></dbdate_to_human>"); $grid->column("Orígen", "<convierte><#origen#>|{$link}</convierte>", 'align=left'); $grid->column("Cantidad", "<number_format><#cantidad#>|2|,|.</number_format>", 'align=right'); $grid->column("Acumulado", "<number_format><#salcant#>|2|,|.</number_format>", 'align=right'); $grid->column("Monto", "<number_format><#monto#>|2|,|.</number_format>", 'align=right'); $grid->column("Saldo", "<number_format><#saldo#>|2|,|.</number_format>", 'align=right'); $grid->column("Costo Prom.", "<number_format><#promedio#>|2|,|.</number_format>", 'align=right'); $grid->column("Ventas", "<number_format><#venta#>|2|,|.</number_format>", 'align=right'); $grid->build(); $data['content'] .= $grid->output; //echo $grid->db->last_query(); } $data['title'] = "<h1>Kardex de Inventario</h1>"; $data["head"] = $this->rapyd->get_head(); $this->load->view('view_ventanas', $data); }
function mensuales($anio = '', $mes = '') { $this->rapyd->load("datagrid2"); $this->rapyd->load("dataform"); $this->load->helper('openflash'); if (isset($_POST['anio']) and empty($anio)) { $anio = $_POST['anio']; } if (isset($_POST['mes']) and empty($mes)) { $mes = $_POST['mes']; } if (empty($mes)) { redirect("supermercado/ventas/anuales/{$anio}"); } $script = ' $(function() { $(".inputnum").numeric("."); }); '; $fechai = $anio . str_pad($mes, 2, "0", STR_PAD_LEFT) . '01'; $fechaf = $anio . str_pad($mes, 2, "0", STR_PAD_LEFT) . '31'; $filter = new DataForm('supermercado/ventas/mensuales'); $filter->attributes = array('onsubmit' => "this.action='index/'+this.form.mes.value+'/'+this.form.anio.value+'/';return FALSE;"); $filter->title('Filtro de Ventas Mensuales'); $filter->script($script, "create"); $filter->script($script, "modify"); $filter->mes = new dropdownField("Mes/Año", "mes"); for ($i = 1; $i < 13; $i++) { $filter->mes->option(str_pad($i, 2, '0', STR_PAD_LEFT), str_pad($i, 2, '0', STR_PAD_LEFT)); } $filter->mes->size = 2; $filter->mes->style = ''; $filter->mes->insertValue = $mes; $filter->mes->rule = "trim"; $filter->anio = new inputField("Año", "anio"); $filter->anio->in = 'mes'; $filter->anio->size = 4; $filter->anio->insertValue = $anio; $filter->anio->maxlength = 4; $filter->anio->rule = "trim"; $filter->anio->css_class = 'inputnum'; $filter->button("btnsubmit", "Buscar", form2uri(site_url('supermercado/ventas/mensuales'), array('anio', 'mes')), $position = "BL"); $filter->build_form(); $grid = new DataGrid2(); $select = array("fecha", "DATE_FORMAT(fecha,'%d') AS dia", "SUM(monto)AS grantotal", "SUM(impuesto)AS iva", "SUM(transac)as transacciones"); $grid->db->select($select); $grid->db->from("est_fecha"); $grid->db->where('fecha >= ', $fechai); $grid->db->where('fecha <= ', $fechaf); $grid->db->groupby("fecha"); $grid->db->orderby("fecha ASC"); //$grid->db->limit(15,0); $grid->column("Dia", "dia", "align='left'"); $grid->column("Total", "<number_format><#grantotal#>|2|,|.</number_format>", 'align=right'); $grid->column("Impuesto", "<number_format><#iva#>|2|,|.</number_format>", 'align=right'); $grid->column("Cant.Transac", "transacciones", 'align=right'); $grid->totalizar('iva', 'grantotal'); $grid->build(); $grafico = open_flash_chart_object(680, 350, site_url("supermercado/ventas/gmensuales/{$anio}/{$mes}")); $data['content'] = $grafico; $data['content'] .= $filter->output . $grid->output; $data["head"] = script("jquery.pack.js") . script("plugins/jquery.numeric.pack.js") . script("plugins/jquery.floatnumber.js") . $this->rapyd->get_head(); $data['title'] = $this->rapyd->get_head() . "<h1>Ventas Mensuales</h1>"; $this->load->view('view_ventanas', $data); }
function filteredgrid() { $this->rapyd->load("datafilter", "datagrid2"); $scli = array('tabla' => 'scli', 'columnas' => array('cliente' => 'Código Cliente', 'nombre' => 'Nombre', 'contacto' => 'Contacto'), 'filtro' => array('cliente' => 'Código Cliente', 'nombre' => 'Nombre'), 'retornar' => array('cliente' => 'cliente'), 'titulo' => 'Buscar Cliente'); $boton = $this->datasis->modbus($scli); $filter = new DataFilter("Filtro de Control de Tiket"); $select = array("a.id as idm", "a.sucursal", "a.asignacion", "a.idt as idt", "a.padre", "a.pertenece", "a.prioridad", "a.usuario as usuarios", "a.contenido", "a.estampa", "a.actualizado", "a.estado", "b.id", "b.cliente as clientes", "b.ubicacion", "b.url", "b.basededato", "b.puerto", "b.puerto", "b.usuario", "b.clave", "b.observacion", "c.nombre", "a.minutos"); $filter->db->select($select); $filter->db->from("tiketc AS a"); $filter->db->join("tiketconec AS b", "a.sucursal=b.id"); $filter->db->join("scli AS c", "b.cliente=c.cliente"); $filter->fechad = new dateonlyField("Fecha Desde", "fechad", 'd/m/Y'); $filter->fechad->clause = "where"; $filter->fechad->db_name = "estampa"; $filter->fechad->operator = ">="; $filter->fechad->size = 12; $filter->fechah = new dateonlyField("Fecha Hasta", "fechah", 'd/m/Y'); $filter->fechah->clause = "where"; $filter->fechah->db_name = "estampa"; $filter->fechah->operator = "<="; $filter->fechah->size = 12; $filter->estado = new dropdownField("Estado", "estado"); $filter->estado->option("", "Todos"); $filter->estado->options($this->estado); $filter->prioridad = new dropdownField("Prioridad", "prioridad"); $filter->prioridad->option("", "Todos"); $filter->prioridad->options($this->prioridad); $filter->contenido = new inputField("Contenido", "contenido"); //$filter->contenido->clause ="likesensitive"; //$filter->contenido->append("Sencible a las Mayuscúlas"); $filter->asignacion = new dropdownField("Asignacion", "asignacion"); $filter->asignacion->option("", "Todos"); $filter->asignacion->options("SELECT codigo, codigo as value FROM tiketservi"); $filter->asignacion->style = "width:150px"; $filter->cliente = new inputField("Cliente", "cliente"); $filter->cliente->size = 20; $filter->cliente->db_name = "c.cliente"; $filter->cliente->append($boton); $filter->idt = new inputField("Numero", "idt"); $filter->idt->size = 20; $filter->idt->db_name = "idt"; $filter->buttons("reset", "search"); $filter->build(); $grid = new DataGrid2("Lista de Control de Tiket"); $grid->order_by("a.id", "desc"); $grid->per_page = 20; $link = anchor("supervisor/tiketc/dataedit/modify/<#idm#>", "<#idm#>"); $grid->column("Id", $link); $grid->column("Numero tiket", "idt"); $grid->column("Fecha de Ingreso", "<dbdate_to_human><#estampa#>|d/m/Y h:m:s</dbdate_to_human>"); $grid->column("Cliente", "nombre"); $grid->column("Usuario", "usuarios"); $grid->column("Contenido", "contenido"); $grid->column("Prioridad", "prioridad"); $grid->column("Estado", "estado"); $grid->column("Asignacion", "asignacion"); $grid->column("Tiempo", "minutos"); //$grid->column("URL","url"); //$resp=anchor("http://merida.matloca.com/proteoerp/supervisor/tiket/dataedit/pertenece/<#idt#>/create"", 'IR'); $resp = '<a href="http://<#url#>/proteoerp/supervisor/tiket/dataedit/pertenece/<#idt#>/create">Ir</a>'; //$resp='http://merida.matloca.com/proteoerp/supervisor/tiket/dataedit/pertenece/67/create'; $grid->column("Responder", $resp); $grid->totalizar('minutos'); //$grid->add("supervisor/tiketc/dataedit/create"); $grid->build(); //echo $grid->db->last_query(); $data['content'] = $filter->output . $grid->output; $data["head"] = $this->rapyd->get_head(); $data['title'] = ' Control de Tiket '; $this->load->view('view_ventanas', $data); }
function movimientos() { $this->rapyd->load("dataform", "datagrid2"); if (isset($_POST['fechad']) && $_POST['fechad'] != '') { $fechad = $_POST['fechad']; } else { $fechad = date("Y/m/d"); $date = new DateTime(); $date->setDate(substr($fechad, 0, 4), substr($fechad, 5, 2), substr($fechad, 8, 2)); $date->modify("-6 month"); $fechad = $date->format("Y/n/j"); } if (isset($_POST['fechah']) && $_POST['fechah'] != '') { $fechah = $_POST['fechah']; } else { $fechah = date("Y/m/d"); } if (isset($_POST['cod'])) { $cod = $_POST['cod']; } elseif ($cod = $this->uri->segment(4)) { } else { redirect("finanzas/analisisbanc"); } if (isset($_POST['campo'])) { $campo = $_POST['campo']; } else { $campo = ''; } if (isset($_POST['oper'])) { $oper = $_POST['oper']; if ($oper != '') { $valor = $oper; } } if (isset($_POST['valor'])) { $valor = $_POST['valor']; if ($valor == '') { if (isset($_POST['oper'])) { $oper = $_POST['oper']; if ($oper != '') { $valor = $oper; } else { $campo = ''; } } } } else { $campo = ''; } if (isset($_POST['oper'])) { $oper = $_POST['oper']; if ($oper != '') { $valor = $oper; } } if (isset($_POST['orden'])) { $orden = $_POST['orden']; if ($orden == '') { $orden = 'fecha'; } } else { $orden = 'fecha'; } if (isset($_POST['desc'])) { $desc = $_POST['desc']; if ($desc == '') { $desc = 'asc'; } if ($desc == '0') { $desc = 'asc'; } if ($desc == '1') { $desc = 'desc'; } } else { $desc = 'asc'; } $cod = $this->uri->segment(4); $ano = $this->uri->segment(5); $mes = $this->uri->segment(6); if ($cod == 'process') { if (isset($_POST['cod'])) { $cod = $_POST['cod']; } else { $cod = '|!'; $ano = ''; $mes = ''; } } else { if (!empty($ano) && !empty($mes)) { for ($dia = 28; $dia <= 31; $dia++) { if (checkdate($mes, $dia, $ano)) { $mes = str_pad($mes, 2, '0', STR_PAD_LEFT); $fechah = "{$ano}/{$mes}/{$dia}"; } } $fechad = "{$ano}/{$mes}/01"; } } //echo $cod.'/'.$ano.'/'.$mes; //echo $fechad."---".$fechah; $script = ' function filtro(){ $("#tr_valor").hide(); $("#tr_oper").hide(); campo=$("#campo").val(); valor.value=""; if(campo.length>0){ if(campo=="tipo_op"){ $("#tr_oper").show(); }else{ $("#tr_valor").show(); } } } $(document).ready(function(){ $("#tr_cod").hide(); $(".inputnum").numeric("."); $("#campo").change(function () { filtro(); }).change(); }); '; $filter = new DataForm("finanzas/analisisbanc/movimientos/process"); $filter->title('Filtro de Caja y Bancos'); $filter->script($script, "create"); $filter->script($script, "modify"); $filter->fechad = new dateonlyField("Desde", "fechad", 'm/Y'); $filter->fechah = new dateonlyField("Hasta", "fechah", 'm/Y'); $filter->fechad->clause = $filter->fechah->clause = "where"; $filter->fechad->db_name = $filter->fechah->db_name = "fecha"; $filter->fechad->insertValue = $fechad; $filter->fechah->insertValue = $fechah; $filter->fechah->size = $filter->fechad->size = 10; $filter->fechad->operator = ">="; $filter->fechah->operator = "<="; $filter->cod = new inputField("", "cod"); $filter->cod->insertValue = $cod; $filter->cod->readonly = TRUE; $filter->cod->type = 'hidden'; $filter->campo = new dropdownField("Filtrar por:", "campo"); $filter->campo->option("", ""); $filter->campo->option("numero", "Numero"); $filter->campo->option("tipo_op", "Tipo Operación"); $filter->campo->option("benefi", "Beneficiario"); $filter->campo->style = 'width:150px;'; $filter->oper = new dropdownField("Tipo:", "oper"); $filter->oper->option("", ""); $filter->oper->option('CH', "Cheque"); $filter->oper->option('DE', "Deposito"); $filter->oper->option('NC', "Nota de Crédito"); $filter->oper->option('ND', "Nota de Débito"); $filter->oper->style = 'width:150px;'; $filter->valor = new inputField("", "valor"); $filter->valor->size = 20; $filter->valor->rule = "trim"; $filter->orden = new dropdownField("Ordenar por:", "orden"); $filter->orden->option("fecha", "Fecha"); $filter->orden->option("numero", "Numero"); $filter->orden->option("tipo_op", "Tipo Operación"); $filter->orden->option("benefi", "Beneficiario"); $filter->orden->style = 'width:150px;'; $filter->desc = new radiogroupField("desc", "desc", array("0" => "Ascendente", "1" => "Descendente"), '0'); $filter->desc->in = 'orden'; $filter->submit("btnsubmit", "Buscar"); $filter->build_form(); if ($cod != '|!') { $fila = $this->datasis->damerow("SELECT moneda,banco,numcuent FROM banc WHERE codbanc='{$cod}'"); } else { $fila['moneda'] = ''; $fila['numcuent'] = ''; $fila['banco'] = ''; } //print_r($fila); function blanco($num, $m = '') { if (empty($num) || $num == 0) { return ''; } else { return number_format($num, 2, ',', '.') . $m; } } $atts = array('width' => '800', 'height' => '600', 'scrollbars' => 'yes', 'status' => 'yes', 'resizable' => 'yes', 'screenx' => '5', 'screeny' => '5'); $link = "finanzas/bmovshow/dataedit/show/<#codbanc#>/<#tipo_op#>/<#numero#>"; ////////////////////////consulta grid////////////////////////////// $this->db->select("codbanc,fecha, numero, tipo_op, monto*(tipo_op IN ('DE','NC')) as ingresos,monto*(tipo_op NOT IN ('DE','NC')) as egresos,CONCAT(concepto,' ',concep2,' ',concep3) as concep, \n benefi,monto*(tipo_op IN ('DE','NC'))-monto*(tipo_op NOT IN ('DE','NC')) as saldo,CASE (tipo_op)\n\t\t\tWHEN 'CH' THEN 'Cheque'\n\t\t\tWHEN 'DE' THEN 'Deposito'\n\t\t\tWHEN 'NC' THEN 'Nota de Crédito'\n\t\t\tWHEN 'ND' THEN 'Nota de Débito'\n\t\t \tEND\n\t\t AS tipo"); $this->db->from('bmov as a'); if ($campo && $valor) { $consult = "AND {$campo} LIKE '%{$valor}%'"; } else { $consult = ''; } if ($cod != '|!') { $b = "codbanc='{$cod}' AND "; } else { $b = ''; } if (strpos(substr($fechad, 6, 4), '/') == NULL) { $fechad2 = substr($fechad, 3, 4) . substr($fechad, 0, 2); //.substr($fechad, 0,2); $fechah2 = substr($fechah, 3, 4) . substr($fechah, 0, 2); //.substr($fechah, 0,2)); } else { $fechad2 = substr($fechad, 0, 4) . substr($fechad, 5, 2); $fechah2 = substr($fechah, 0, 4) . substr($fechah, 5, 2); } $this->db->where("{$b} EXTRACT(YEAR_MONTH FROM fecha) BETWEEN '{$fechad2}' AND '{$fechah2}'{$consult}"); //a.fecha like '%-$mm-%' $this->db->orderby($orden . ' ' . $desc); $query = $this->db->get(); //memowrite($this->db->last_query()); ////////////////////////consulta grid////////////////////////////// ///////////////////////SALDO ANTERIOR////////////////////////////// $ddata = array(); $banmes = ''; $anterior = 0; foreach ($query->result_array() as $row) { if ($banmes != substr($row['fecha'], 5, 2)) { $ban = $banmes = substr($row['fecha'], 5, 2); $ano2 = substr($row['fecha'], 0, 4); if (1 * $banmes == 1) { $ban = 13; $ano2 = 1 * $ano2 - 1; } $campo = 'saldo' . str_pad(1 * $ban - 1, 2, '0', STR_PAD_LEFT); $sal = $this->datasis->dameval("SELECT {$campo} FROM bsal WHERE codbanc='{$cod}' AND ano='{$ano2}'"); if ($sal == NULL) { $sal = 0; $row['salAnterior'] = number_format($sal, 2, ',', '.'); } else { $anterior = $sal; $row['salAnterior'] = number_format($anterior, 2, ',', '.'); $anterior = $anterior + $row['saldo']; } } else { $row['salAnterior'] = number_format($anterior, 2, ',', '.'); $anterior = $anterior + $row['saldo']; //$campo=''; } //$campo;// $ddata[] = $row; } ///////////////////////SALDO ANTERIOR////////////////////////////// //print_r($ddata); if ($cod != '|!') { $o = "Movimientos del Banco " . $fila['banco'] . " cuenta #" . $fila['numcuent'] . " desde {$fechad} hasta {$fechah}"; } else { $o = "Todos los Bancos"; } $grid = new DataGrid2($o, $ddata); $grid->use_function('blanco'); if ($cod == '|!') { $grid->column("Banco", "<#codbanc#>", 'align=left'); } $grid->column("Fecha", "<dbdate_to_human><#fecha#></dbdate_to_human>"); $grid->column("Numero", anchor_popup($link, '<#numero#>', $atts), 'nowrap=yes'); $grid->column("Tipo Operación", "<#tipo#>", 'align=left'); $grid->column("Ingresos", "<number_format><#ingresos#>|2|,|.</number_format>", "align=right"); $grid->column("Egresos", "<number_format><#egresos#>|2|,|.</number_format>", "align=right"); $grid->column("Saldo", "<number_format><#saldo#>|2|,|.</number_format>", "align=right"); $grid->column("Saldo Anterior", "<#salAnterior#>", "align=right"); $grid->column("Beneficiario", "<#benefi#>", 'align=left'); $grid->column("Concepto", "<#concep#>", 'align=left'); $grid->totalizar('ingresos', 'egresos', 'saldo'); $grid->build(); //memowrite( $grid->db->last_query()); if (!isset($ano2)) { $ano2 = $ano; } $salida = anchor("finanzas/analisisbanc/meses/{$cod}/{$ano2}", "Atras"); $data['content'] = $salida . $grid->output; $data['title'] = "<h1>Relación de Caja y Bancos</h1>"; $data["head"] = script("jquery.pack.js") . script("plugins/jquery.numeric.pack.js") . script("plugins/jquery.floatnumber.js") . $this->rapyd->get_head(); $this->load->view('view_ventanas', $data); }
function read() { $this->load->library("Spreadsheet_Excel_Reader"); $this->rapyd->load("datagrid2", "dataform"); $salida = anchor('inventario/sinvactu', 'Atras'); $type = ''; if (isset($_FILES['archivoUserFile']['type'])) { $type = $_FILES['archivoUserFile']['type']; } if ($type == 'application/x-msexcel') { $name = $_FILES['archivoUserFile']['name']; $dir = ".././" . $name; if (copy($_FILES['archivoUserFile']['tmp_name'], $dir)) { $tmp = $dir; //$_FILES['archivoUserFile']['tmp_name']; $data = new Spreadsheet_Excel_Reader(); $data->setOutputEncoding('CP1251'); $data->read($tmp); error_reporting(E_ALL ^ E_NOTICE); $cols = array(); for ($i = 0; $i <= $data->sheets[0]['numRows']; $i++) { $ref = 0; for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++) { $cols[$j - 1] = $data->sheets[0]['cells'][$i][$j]; if (!empty($data->sheets[0]['cells'][$i][$j])) { $ref++; } } if ($ref > 2) { break; } } $c = 0; for ($i = 0; $i <= $data->sheets[0]['numRows']; $i++) { $ref = 0; $j = 1; foreach ($cols as $col) { $data3[$i][$col] = $data->sheets[0]['cells'][$i][$j]; if (!empty($data->sheets[0]['cells'][$i][$j])) { $ref++; } $j++; } if ($ref > 2 && implode(' ', $data3[$i]) != implode(' ', $cols)) { $data4[$c] = $data3[$i]; $c++; } } $form = new DataForm("/inventario/sinvactu/actualiza"); $form->free = new freeField("Campos.Archivo xls", "free", "Campos de El Sistema"); $grid = new DataGrid2("Archivo Cargado", $data4); $j = 0; $campos .= 'cols="+$("#cols").val()+"&&dir="+$("#dir").val()'; foreach ($cols as $col) { $grid->column("{$col}", "<#{$col}#>"); $campo = "campo{$j}"; $form->{$campo} = new dropdownField("{$col}", "campo{$j}"); $form->{$campo}->option("ignorar", "ignorar"); $form->{$campo}->option("codigo", "codigo"); $form->{$campo}->option("costo", "costo"); $form->{$campo}->option("descrip", "descrip"); $form->{$campo}->option("descrip2", "descrip2"); $form->{$campo}->option("clave", "clave"); $form->{$campo}->option("grupo", "grupo"); $form->{$campo}->option("iva", "iva"); for ($i = 1; $i <= 3; $i++) { $form->{$campo}->option("base{$i}", "Base{$i}"); $form->{$campo}->option("margen{$i}", "Margen{$i}"); $form->{$campo}->option("precio{$i}", "Precio{$i}"); } $form->{$campo}->style = 'width:150px;'; $j++; $campos .= "+" . "\"&&" . $campo . "=\"+\$(\"#" . $campo . "\").val()"; } //echo $campos; $form->cols = new inputField("", "cols"); $form->cols->insertValue = implode(',', $cols); $form->cols->type = 'hidden'; $form->dir = new inputField("", "dir"); $form->dir->insertValue = $dir; $form->dir->type = 'hidden'; //$form->submit("btnsubmit","Actualizar"); $link = site_url('inventario/sinvactu/actualiza'); $script = ' function actu(){ a=confirm("¿Esta Seguro que de desea Actualizar el Inventario ?"); if(a){ $.ajax({ type: "POST", processData:false, url: "' . $link . '", data: "' . $campos . ', success: function(msg){ if(msg=="s.i"){ alert("El Inventario fue Actualizado."); } else{ alert(msg); } } }); } } '; $form->script($script); $form->button("actualiza", "Actualizar", "javascript:actu();"); $form->build_form(); $grid->build(); $data2['content'] = $form->output . $salida . $grid->output; } } else { $data2['content'] = $salida; } $data2['title'] = "<h1>Actualización de Inventario</h1>"; $data2["head"] = script("jquery.pack.js") . $this->rapyd->get_head(); $this->load->view('view_ventanas', $data2); }
function resumen() { $this->rapyd->load("datafilter", "datagrid2"); $grid = new DataGrid2("Resúmen de Bitacora"); $grid->agrupar('Autor: ', 'usr'); $grid->db->select(array('UPPER(usuario) AS usr', "if(revisado='P','Pendientes',if(revisado='B','Buenos',if(revisado='C','Consultas','Fallos'))) AS resul", 'COUNT(*) AS cant')); $grid->db->from('bitacora'); $grid->db->where('usuario<>', 'coicoi'); $grid->db->groupby('UPPER(usuario),revisado'); $grid->column("Resultado", "resul"); $grid->column("Cantidad", "cant"); $grid->build(); //echo $grid->db->last_query(); //echo '<pre>'; print_r($grid->data); echo '</pre>'; $totales = $buenos = $promedio = array(); foreach ($grid->data as $colum) { $revisado = substr($colum['resul'], 0, 1); if ($revisado == 'B' or $revisado == 'F') { if (!isset($totales[$colum['usr']])) { $totales[$colum['usr']] = 0; } if ($revisado == 'B') { $buenos[$colum['usr']] = $colum['cant']; } $totales[$colum['usr']] += $colum['cant']; } } foreach ($totales as $ind => $tot) { $promedio[$ind] = round($buenos[$ind] / $tot * 100, 2); } $out = '<table align="center">'; foreach ($promedio as $usuario => $prome) { $out .= "<tr><td>{$usuario}:</td><td> {$prome} %</td></tr>"; } $out .= '</table>'; $data['content'] = $grid->output . '<h3>Promedio de Éxitos </h3>' . $out; $data["head"] = $this->rapyd->get_head(); $data['title'] = ''; $this->load->view('view_ventanas', $data); }