Exemplo n.º 1
0
 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&iacute;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);
 }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
 function resumen()
 {
     $this->rapyd->load("datafilter", "datagrid2");
     $grid = new DataGrid2("Res&uacute;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 &Eacute;xitos </h3>' . $out;
     $data["head"] = $this->rapyd->get_head();
     $data['title'] = '';
     $this->load->view('view_ventanas', $data);
 }
Exemplo n.º 4
0
 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&oacute;digo', 'descrip' => 'Descripci&oacute;n', 'precio1' => 'Precio 1', 'precio2' => 'Precio 2', 'precio3' => 'Precio 3', 'precio4' => 'Precio 4', 'precio5' => 'Precio 5'), 'filtro' => array('codigo' => 'C&oacute;digo', 'descrip' => 'Descripci&oacute;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&oacute;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&iacute;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);
 }
Exemplo n.º 5
0
    function cdatos()
    {
        $this->rapyd->uri->keep_persistence();
        $this->rapyd->load('datagrid2', 'fields');
        function ctipo($id, $tipo, $ejecuta)
        {
            if ($tipo == 'C') {
                return 'Calculado';
            } else {
                $rt = str_replace('return', '', $ejecuta);
                $rt = str_replace(';', '', $rt);
                $name = "pvalor[{$id}]";
                $data = array('name' => $name, 'id' => $name, 'value' => trim($rt), 'maxlength' => '100', 'size' => '15', 'class' => 'inputnum');
                return form_input($data);
            }
        }
        //echo date('Y-m-d H:i:s',mktime(0, 0, 0, date('n')-1, 1)).' - '.date('Y-m-d H:i:s',mktime(0, 0, 0, date('n')  , 0));
        $fdesde = new dateonlyField('Fecha de inicio: ', 'fdesde');
        $fhasta = new dateonlyField('Fecha Final: ', 'fhasta');
        $fdesde->insertValue = date('Y-m-d H:i:s', mktime(0, 0, 0, date('n') - 1, 1));
        $fhasta->insertValue = date('Y-m-d H:i:s', mktime(0, 0, 0, date('n'), 0));
        $fdesde->status = $fhasta->status = 'create';
        $fdesde->size = $fhasta->size = 8;
        $fdesde->dbformat = $fhasta->dbformat = 'Ymd';
        $fdesde->build();
        $fhasta->build();
        $fcorte1 = new dateonlyField('Fecha de Corte: ', 'fcorte1');
        $fcorte1->insertValue = date('Y-m-d H:i:s', mktime(0, 0, 0, date('n') - 1, 15));
        $fcorte1->dbformat = 'Ymd';
        $fcorte1->status = 'create';
        $fcorte1->size = 8;
        $fcorte1->build();
        $error = $msj = '';
        if ($this->input->post('pros') !== false) {
            $fdesde->_getNewValue();
            $fhasta->_getNewValue();
            $fcorte1->_getNewValue();
            $url = $this->url . 'ejecutor/' . $fdesde->newValue . '/' . $fcorte1->newValue . '/' . $fhasta->newValue;
            redirect($url);
            $pmargen = $this->input->post('pmargen');
            $pobject = $this->input->post('pobjetivo');
            $pvalor = $this->input->post('pvalor');
            if (is_array($pmargen)) {
                if (array_sum($pmargen) == 100) {
                    foreach ($pmargen as $id => $pm) {
                        if (is_numeric($pobject[$id])) {
                            $po = $pobject[$id];
                        } else {
                            $po = 0;
                        }
                        if (isset($pvalor[$id]) && is_numeric($pvalor[$id])) {
                            $pv = 'return ' . $pvalor[$id] . ';';
                        } else {
                            $pv = null;
                        }
                        if (is_numeric($pm) && $pm >= 0) {
                            $this->db->where('id', $id);
                            $data = array();
                            $data['puntos'] = $pm;
                            $data['objetivo'] = $po;
                            if (!empty($pv)) {
                                $data['ejecuta'] = $pv;
                            }
                            $this->db->update('gestion_indicador', $data);
                        } else {
                            $error .= 'Valor no num&eacute;rico o negativo ' . $id;
                        }
                    }
                } else {
                    $error .= 'La suma de los valores debe dar exactamente 100';
                }
            } else {
                $error = 'No se puede procesar el requerimiento';
            }
        }
        $ggrid = form_open('/finanzas/gestion/cdatos') . '<p align="center">';
        $ggrid .= '<b>' . $fdesde->label . '</b>' . $fdesde->output;
        $ggrid .= '<b>' . $fhasta->label . '</b>' . $fhasta->output;
        $ggrid .= br() . '<b>' . $fcorte1->label . '</b>' . $fcorte1->output;
        $ggrid .= '</p>';
        $grid = new DataGrid2('Selecci&oacute;n de indicadores');
        $grid->agrupar(' ', 'nomgrup');
        $grid->use_function('ctipo');
        $select = array('a.descrip', 'a.indicador', 'a.tipo', 'a.puntos', 'a.id', 'a.objetivo', 'a.ejecuta', 'b.nombre AS nomgrup', 'unidad');
        $grid->db->select($select);
        $grid->db->from('gestion_indicador AS a');
        $grid->db->join('gestion_grupo AS b', 'a.id_gestion_grupo=b.id');
        $grid->db->where('a.activo', 'S');
        $grid->order_by('nomgrup');
        $campo = new inputField('Campo', 'puntos');
        $campo->grid_name = 'pmargen[<#id#>]';
        $campo->status = 'modify';
        $campo->size = 6;
        $campo->autocomplete = false;
        $campo->css_class = 'inputnum';
        $campo->disable_paste = true;
        $meta = new inputField('Meta', 'objetivo');
        $meta->grid_name = 'pobjetivo[<#id#>]';
        $meta->status = 'modify';
        $meta->size = 15;
        $meta->autocomplete = false;
        $meta->css_class = 'inputnum';
        $meta->disable_paste = true;
        $grid->column_orderby('Indicador', 'indicador', 'indicador');
        $grid->column('Puntos %', $campo, 'align=\'center\'');
        $grid->column('Objetivo', $meta, 'align=\'center\'');
        $grid->column('Unidad', 'unidad');
        $grid->column('Tipo', "<ctipo><#id#>|<#tipo#>|<#ejecuta#></ctipo>");
        $action = "javascript:window.location='" . site_url('ventas/metas/filteredgrid') . "'";
        $grid->button('btn_regresa', 'Regresar', $action, 'TR');
        $grid->submit('pros', 'Generar', 'BR');
        $grid->build();
        $ggrid .= $grid->output;
        $ggrid .= form_close();
        $script = '<script language="javascript" type="text/javascript">
		$(function(){
			$(".inputnum").numeric(".");

			$(\'input[name^="pmargen"]\').focus(function() {
				obj  = $(this);
				vval = Number(obj.val());

				tota=0;
				$(\'input[name^="pmargen"]\').each(function (i) {
					tota+=Number(this.value);
				});
				val=roundNumber(100-(tota-vval),2);
				obj.val(val);
				obj.select();
			});
		});
		</script>';
        $data['content'] = '<div class="alert">' . $error . '</div>';
        $data['content'] .= '<div>' . $msj . '</div>';
        $data['content'] .= $ggrid;
        $data['title'] = heading('Indicadores de Gesti&oacute;n');
        $data['script'] = $script;
        $data['script'] .= phpscript('nformat.js');
        $data['head'] = $this->rapyd->get_head() . script('jquery.pack.js') . script('plugins/jquery.numeric.pack.js') . script('plugins/jquery.floatnumber.js');
        $data['head'] .= style('estilos.css');
        $data['head'] .= phpscript('nformat.js');
        $this->load->view('view_ventanas', $data);
    }
Exemplo n.º 6
0
 function filteredgrid()
 {
     $this->rapyd->load('datafilter', 'datagrid2');
     function convierte($par, $link)
     {
         $atts = array('width' => '800', 'height' => '600', 'scrollbars' => 'yes', 'status' => 'yes', 'resizable' => 'yes', 'screenx' => '5', 'screeny' => '5', 'style' => 'text-decoration:none;font-weight: bold;font-size:0.85em;color:#2357B5');
         switch ($par) {
             case '3I':
                 return anchor_popup($link, 'Ventas Caja', $atts);
                 break;
             case '3R':
                 return anchor_popup($link, 'Ventas Restaurante', $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 anchor_popup($link, 'Conversión', $atts);
                 break;
             case '5C':
                 return anchor_popup($link, 'Ajuste', $atts);
                 break;
             case '5D':
                 return anchor_popup($link, 'Consignación', $atts);
                 break;
             case '0F':
                 return anchor_popup($link, 'Inventario', $atts);
                 break;
             case '9F':
                 return anchor_popup($link, 'Inventario', $atts);
                 break;
             default:
                 return $par;
         }
     }
     function colorgal($par)
     {
         switch ($par) {
             case '3I':
                 return '(  0,163,  0, 0.4)';
                 break;
             case '3R':
                 return '(  0,163,  0, 0.4)';
                 break;
             case '3M':
                 return '(  0,163,  0, 0.4)';
                 break;
             case '1T':
                 return '(255, 34,  5, 0.4)';
                 break;
             case '2C':
                 return '(183, 84, 35, 0.4)';
                 break;
             case '4N':
                 return '( 17, 19,148, 0.4)';
                 break;
             case '6C':
                 return '(  0,  0,  0, 0.4)';
                 break;
             case '5C':
                 return '( 65,185,255, 0.4)';
                 break;
             case '5D':
                 return '(144,  0,255, 0.4)';
                 break;
             case '0F':
                 return '(255,221,  0, 0.4)';
                 break;
             case '9F':
                 return '(255,221,  0, 0.4)';
                 break;
             default:
                 return '(255,255,255, 0.4)';
         }
     }
     $modbus = array('tabla' => 'sinv', 'columnas' => array('codigo' => 'C&oacute;digo', 'descrip' => 'Descripci&oacute;n', 'precio1' => 'Precio 1', 'precio2' => 'Precio 2', 'precio3' => 'Precio 3', 'precio4' => 'Precio 4'), 'filtro' => array('codigo' => 'C&oacute;digo', 'descrip' => 'Descripci&oacute;n'), 'retornar' => array('codigo' => 'codigo'), 'titulo' => 'Buscar en inventario');
     $boton = $this->datasis->modbus($modbus);
     $maxfecha = $this->datasis->dameval("SELECT MAX(fecha) AS fecha FROM costos");
     if (!empty($maxfecha)) {
         $corte = ' corte: <b>' . dbdate_to_human($maxfecha) . '</b>';
     } else {
         $corte = '';
     }
     $filter = new DataFilter('Kardex de Inventario ' . $corte);
     //$script= '$(function(){ $("#kardextabla").columnHover(); });';
     //$filter->script($script);
     $filter->codigo = new inputField('C&oacute;digo ', 'codigo');
     $filter->codigo->db_name = 'a.codigo';
     $filter->codigo->rule = 'required';
     $filter->codigo->operator = '=';
     $filter->codigo->size = 25;
     $filter->codigo->clause = 'where';
     $filter->codigo->append($boton);
     $filter->codigo->group = 'UNO';
     $filter->ubica = new dropdownField('Almac&eacute;n', '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->ubica->group = 'UNO';
     $filter->origen = new dropdownField('Or&iacute;gen', 'origen');
     $filter->origen->option('', 'Todos');
     $filter->origen->option('3I', 'Ventas Caja');
     $filter->origen->option('3R', 'Ventas Restaurante');
     $filter->origen->option('3M', 'Ventas Mayor');
     $filter->origen->option('1T', 'Transferencias');
     $filter->origen->option('2C', 'Compras');
     $filter->origen->option('4N', 'Nota/Entrega');
     $filter->origen->option('6C', 'Conversión');
     $filter->origen->option('5C', 'Ajuste de inventario');
     $filter->origen->option('5D', 'Consignación');
     $filter->origen->option('0F', 'Inv. Físico comienzo del día');
     $filter->origen->option('9F', 'Inv. Físico final del día');
     //$filter->origen->style = 'width:120px';
     $filter->origen->group = 'UNO';
     $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->fechad->group = 'DOS';
     $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->group = 'DOS';
     $filter->fechah->clause = $filter->fechad->clause = $filter->codigo->clause = 'where';
     $filter->fechah->size = $filter->fechad->size = 10;
     $filter->fechah->rule = $filter->fechad->rule = 'required|chfecha';
     $filter->buttons('reset', 'search');
     $filter->build('dataformfiltro');
     $data['filtro'] = $filter->output;
     $code = $this->input->post('codigo');
     $data['content'] = '';
     $cana = 0;
     if ($code && $filter->is_valid()) {
         $dbcode = $this->db->escape($code);
         $mSQL = "SELECT CONCAT_WS(' ',TRIM(descrip),TRIM(descrip2)) descrip,existen,activo FROM sinv WHERE codigo={$dbcode}";
         $query = $this->db->query($mSQL);
         if ($query->num_rows() > 0) {
             $row = $query->row();
             $descrip = $row->descrip;
             $activo = $row->activo;
             $existen = floatval($row->existen);
             $actual = $this->datasis->dameval("SELECT SUM(existen) AS cana FROM itsinv WHERE codigo={$dbcode}");
             if (floatval($actual) != $existen) {
                 $this->db->simple_query("UPDATE sinv SET existen={$actual} WHERE codigo={$dbcode}");
             }
         } else {
             $activo = 'N';
             $descrip = 'No encontrado.';
             $existen = 0;
         }
         $link = "/inventario/kardex/grid/<#origen#>/<dbdate_to_human><#fecha#>|Ymd</dbdate_to_human>/<raencode><#codigo#></raencode>/<raencode><#ubica#></raencode>";
         $grid = new DataGrid2("Producto: ({$code}) {$descrip}");
         $grid->table_id = 'kardextabla';
         $grid->agrupar(' ', 'almacen');
         $grid->use_function('convierte', 'str_replace', 'colorgal');
         $grid->db->select(array('IFNULL( b.ubides , a.ubica ) almacen', 'a.ubica', 'a.fecha', 'a.venta', 'a.cantidad', 'a.saldo', 'a.monto', 'a.salcant', 'TRIM(a.codigo) AS codigo', 'a.origen', 'a.promedio', '(a.venta/a.cantidad)*(a.cantidad>0) AS vpromedio', 'ROUND(100-(a.promedio*100/(a.venta/a.cantidad)),2)*(a.origen="3I") AS vmargen', '((a.venta/a.cantidad)-a.promedio)*a.cantidad*(a.origen="3I") AS vutil', 'c.activo', 'c.grupo'));
         $grid->db->from('costos a');
         $grid->db->join('caub b', 'b.ubica=a.ubica', 'LEFT');
         $grid->db->join('sinv c', 'a.codigo=c.codigo', 'LEFT');
         $grid->db->orderby('almacen, fecha, origen');
         $grid->per_page = 60;
         $grid->column('Or&iacute;gen', '<p style="background-color: rgba<colorgal><#origen#></colorgal>;font-size:1.3em;font-weight: bold;margin:0px;padding:0px;border:0px;"><convierte><#origen#>|' . $link . '</convierte></p>', 'align=\'left\' nowrap');
         $grid->column('Fecha', '<dbdate_to_human><#fecha#></dbdate_to_human>');
         $grid->column('Cantidad', '<nformat><#cantidad#></nformat>', 'align=\'right\'');
         $grid->column('<b style="color:#FFFFFF">Acumulado</b>', '<b style="font-size:1.3em"><nformat><#salcant#></nformat></b>', 'align=\'right\'');
         $grid->column('Monto', '<nformat><#monto#></nformat>', 'align=\'right\'');
         $grid->column('Saldo', '<nformat><#saldo#></nformat>', 'align=\'right\'');
         $grid->column('Costo Prom.', '<nformat><#promedio#></nformat>', 'align=\'right\'');
         $grid->column('Ventas', '<nformat><#venta#></nformat>', 'align=\'right\'');
         $grid->column('Precio Prom.', '<nformat><#vpromedio#></nformat>', 'align=\'right\'');
         $grid->column('Margen %', '<nformat><#vmargen#></nformat>', 'align=\'right\'');
         $grid->column('Margen Bs.', '<nformat><#vutil#></nformat>', 'align=\'right\'');
         $grid->build();
         $data['content'] = '<h4 style="text-align:center;padding:0px;margin:0px;">Movimiento comprendido desde la fecha <b style="color:#000000; font-size:1.2em">' . $filter->fechad->value . '</b> Hasta <b style="color:#000000; font-size:1.2em">' . $filter->fechah->value . '</b></h4>';
         $data['content'] .= $grid->output;
         $ffinal = $this->datasis->dameval("SELECT MAX(fecha) AS fecha FROM costos WHERE codigo={$dbcode}");
         if (!empty($ffinal)) {
             $dbfinal = $this->db->escape($ffinal);
             $ventas = $this->datasis->dameval("SELECT SUM(IF(tipoa='D',-1,1)*cana) AS cana FROM sitems WHERE codigoa={$dbcode} AND fecha>{$dbfinal} AND MID(numa,1,1)<>'_' AND tipoa IN ('F','D')");
             $compras = $this->datasis->dameval("SELECT SUM(IF(b.tipo_doc='ND',-1,1)*a.cantidad) AS cana FROM itscst AS a JOIN scst AS b ON a.control=b.control WHERE a.codigo={$dbcode} AND b.actuali>=b.fecha AND b.recep>{$dbfinal}");
             $nentreg = $this->datasis->dameval("SELECT SUM(a.cana) AS cana FROM itsnte AS a JOIN snte AS b ON a.numero=b.numero WHERE a.codigo={$dbcode} AND estampa>{$dbfinal}");
             $ajustes = $this->datasis->dameval("SELECT SUM(IF(b.tipo='E',1,-1)*cantidad) AS cana FROM itssal AS a JOIN ssal AS b ON a.numero = b.numero WHERE a.codigo = {$dbcode} AND b.fecha>{$dbfinal}");
             $conver = $this->datasis->dameval("SELECT SUM(a.entrada-a.salida) AS cana FROM itconv AS a JOIN conv AS b ON a.numero = b.numero WHERE a.codigo = {$dbcode} AND b.fecha>{$dbfinal}");
             if ($this->db->table_exists('itscon')) {
                 $consi = $this->datasis->dameval("SELECT SUM(IF(tipod='E',-1,1)*a.cana) AS cana FROM itscon AS a JOIN scon AS b ON a.id_scon=b.id WHERE a.codigo = {$dbcode} AND b.fecha>{$dbfinal}");
             } else {
                 $consi = 0;
             }
             $ventas = empty($ventas) ? htmlnformat(0) : htmlnformat($ventas);
             $compras = empty($compras) ? htmlnformat(0) : htmlnformat($compras);
             $nentreg = empty($nentreg) ? htmlnformat(0) : htmlnformat($nentreg);
             $actual = empty($actual) ? htmlnformat(0) : htmlnformat($actual);
             $ajustes = empty($ajustes) ? htmlnformat(0) : htmlnformat($ajustes);
             $conver = empty($conver) ? htmlnformat(0) : htmlnformat($conver);
             $consi = empty($consi) ? htmlnformat(0) : htmlnformat($consi);
             if ($activo == 'S') {
                 $sactivo = '<span style=\'font-size:0.7em;color:green;\'>ACTIVO</span>';
             } else {
                 $sactivo = '<span style=\'font-size:0.7em;color:red;\'>INACTIVO</span>';
             }
             $optadd = '<div style="">';
             $optadd .= ' <table>';
             $optadd .= '  <tr><td colspan=\'5\'><b style="text-size:1.4em;font-weight:bold;">Movimientos posteriores a la fecha ' . dbdate_to_human($ffinal) . ' para todos los almacenes</b></td></tr>';
             $optadd .= "  <tr><td>Ventas   </td><td style='text-align:right' ><b> {$ventas}</b></td><td style='padding-left:50px;'>Ajustes       </td><td style='text-align:right' ><b>{$ajustes}</b></td><td rowspan='3' style='text-align:center'>Existencia actual <p style='font-size:2em;padding:0 0 0 0;margin: 0 0 0 0;font-weight:bold;'>{$actual}</p>{$sactivo}</td></tr>";
             $optadd .= "  <tr><td>Compras  </td><td style='text-align:right' ><b>{$compras}</b></td><td style='padding-left:50px;'>Conversiones  </td><td style='text-align:right' ><b> {$conver}</b></td></tr>";
             $optadd .= "  <tr><td>N.Entrega</td><td style='text-align:right' ><b>{$nentreg}</b></td><td style='padding-left:50px;'>Consignaciones</td><td style='text-align:right' ><b>  {$consi}</b></td></tr>";
             $optadd .= ' </table>';
             $optadd .= '</div>';
         } else {
             $optadd = '';
         }
         $data['content'] .= $optadd;
         //echo $grid->db->last_query();
         $cana = $grid->recordCount;
     }
     if ($cana <= 0) {
         $data['content'] .= '<script type="text/javascript"> $(function(){ $("#cajafiltro").show(); }); </script>';
     }
     $data['forma'] = '';
     $data['script'] = script('jquery.js') . '<style type="text/css">#kardextabla tr:hover { background-color: #ffff99; }</style>';
     //$data['script'].= script('plugins/jquery.columnhover.pack.js');
     $data['title'] = heading('Kardex de Inventario');
     $data['head'] = $this->rapyd->get_head();
     $this->load->view('view_ventanas', $data);
 }
Exemplo n.º 7
0
 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&oacute;digo', 'descrip' => 'Descripci&oacute;n', 'precio1' => 'Precio 1', 'precio2' => 'Precio 2', 'precio3' => 'Precio 3', 'precio4' => 'Precio 4', 'precio5' => 'Precio 5'), 'filtro' => array('codigo' => 'C&oacute;digo', 'descrip' => 'Descripci&oacute;n'), 'retornar' => array('codigo' => 'codigo'), 'titulo' => 'Buscar en inventario');
     $boton = $this->datasis->modbus($modbus);
     $maxfecha = $this->datasis->dameval("SELECT MAX(fecha) AS fecha FROM costos");
     if (!empty($maxfecha)) {
         $corte = ' corte: <b>' . dbdate_to_human($maxfecha) . '</b>';
     } else {
         $corte = '';
     }
     $filter = new DataFilter('Kardex de Inventario (' . anchor_popup('/supermercado/lfisico', 'Resumen de inventarios', $atts) . ') ' . $corte);
     $filter->codigo = new inputField('C&oacute;digo de Producto', 'codigo');
     $filter->codigo->size = '10';
     $filter->codigo->rule = 'required';
     $filter->codigo->append($boton);
     $filter->codigo->group = 'UNO';
     $filter->ubica = new dropdownField('Almac&eacute;n', '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->ubica->group = 'UNO';
     $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->fechad->group = 'DOS';
     $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->group = 'DOS';
     $filter->fechah->clause = $filter->fechad->clause = $filter->codigo->clause = 'where';
     $filter->fechah->rule = $filter->fechad->rule = 'required|chfecha';
     $filter->fechah->size = $filter->fechad->size = 10;
     $filter->buttons('reset', 'search');
     $filter->build('dataformfiltro');
     $data['content'] = $filter->output;
     $code = $this->input->post('codigo');
     if ($code && $filter->is_valid()) {
         $dbcode = $this->db->escape($code);
         $mSQL = "SELECT descrip FROM maes WHERE codigo={$dbcode}";
         $ffinal = $this->datasis->dameval("SELECT MAX(fecha) AS fecha FROM costos WHERE codigo={$dbcode}");
         $query = $this->db->query($mSQL);
         $descrip = '';
         if ($query->num_rows() > 0) {
             $row = $query->row();
             $descrip = trim($row->descrip);
             //$activo =trim($row->activo);
             $actual = $this->datasis->dameval("SELECT SUM(cantidad) AS cana FROM ubic WHERE codigo={$dbcode}");
             $fracci = $this->datasis->dameval("SELECT SUM(fraccion) AS cana FROM ubic WHERE codigo={$dbcode}");
         } else {
             //$activo ='';
         }
         $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('Almac&eacute;n: ', '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&iacute;gen', "<convierte><#origen#>|{$link}</convierte>", 'align=left');
         $grid->column('Cantidad', '<nformat><#cantidad#></nformat>', 'align=right');
         $grid->column('Acumulado', '<nformat><#salcant#></nformat>', 'align=right');
         $grid->column('Monto', '<nformat><#monto#></nformat>', 'align=right');
         $grid->column('Saldo', '<nformat><#saldo#></nformat>', 'align=right');
         $grid->column('Costo Prom.', '<nformat><#promedio#></nformat>', 'align=right');
         $grid->column('Ventas', '<nformat><#venta#></nformat>', 'align=right');
         $grid->build();
         $data['content'] .= $grid->output;
         //echo $grid->db->last_query();
     }
     if (!empty($ffinal)) {
         $dbfinal = $this->db->escape($ffinal);
         $mayor = $this->datasis->dameval("SELECT SUM(cantidad) AS cana FROM itfmay WHERE codigo={$dbcode} AND fecha>{$dbfinal}");
         $ventas = $this->datasis->dameval("SELECT SUM(cantidad) AS cana FROM positfact WHERE codigo={$dbcode} AND fecha>{$dbfinal}");
         $compras = $this->datasis->dameval("SELECT SUM(IF(b.tipo_doc='ND',-1,1)*a.cantidad) AS cana FROM itscst AS a JOIN scst AS b ON a.control=b.control WHERE a.codigo={$dbcode} AND b.actuali>=b.fecha AND b.actuali>{$dbfinal}");
         $nentreg = $this->datasis->dameval("SELECT SUM(a.cana) AS cana FROM itsnte AS a JOIN snte AS b ON a.numero=b.numero WHERE a.codigo={$dbcode} AND b.fecha>{$dbfinal}");
         $ajustes = $this->datasis->dameval("SELECT SUM(IF(b.tipo='E',1,-1)*cantidad) AS cana FROM itssal AS a JOIN ssal AS b ON a.numero = b.numero WHERE a.codigo = {$dbcode} AND b.fecha>{$dbfinal}");
         $conver = $this->datasis->dameval("SELECT SUM(a.entrada-a.salida) AS cana FROM itconv AS a JOIN conv AS b ON a.numero = b.numero WHERE a.codigo = {$dbcode} AND b.fecha>{$dbfinal}");
         $ventas = empty($ventas) ? htmlnformat(0) : htmlnformat($ventas);
         $compras = empty($compras) ? htmlnformat(0) : htmlnformat($compras);
         $nentreg = empty($nentreg) ? htmlnformat(0) : htmlnformat($nentreg);
         $actual = empty($actual) ? htmlnformat(0) : htmlnformat($actual);
         $ajustes = empty($ajustes) ? htmlnformat(0) : htmlnformat($ajustes);
         $conver = empty($conver) ? htmlnformat(0) : htmlnformat($conver);
         $consi = empty($consi) ? htmlnformat(0) : htmlnformat($consi);
         $mayor = empty($mayor) ? htmlnformat(0) : htmlnformat($mayor);
         //if($activo=='S'){
         //	$sactivo='<span style=\'font-size:0.7em;color:green;\'>ACTIVO</span>';
         //}else{
         //	$sactivo='<span style=\'font-size:0.7em;color:red;\'>INACTIVO</span>';
         //}
         $optadd = '<div style="">';
         $optadd .= ' <table>';
         $optadd .= '  <tr><td colspan=\'5\'><b style="text-size:1.4em;font-weight:bold;">Movimientos posteriores a la fecha ' . dbdate_to_human($ffinal) . ' para todos los almacenes</b></td></tr>';
         $optadd .= "  <tr><td>Ventas   </td><td style='text-align:right' ><b> {$ventas}</b></td><td style='padding-left:50px;'>Ajustes      </td><td style='text-align:right' ><b>{$ajustes}</b></td><td rowspan='3' style='text-align:center'>Existencia actual <p style='font-size:2em;padding:0 0 0 0;margin: 0 0 0 0;font-weight:bold;'>{$actual} / {$fracci}</p></td></tr>";
         $optadd .= "  <tr><td>Compras  </td><td style='text-align:right' ><b>{$compras}</b></td><td style='padding-left:50px;'>Conversiones </td><td style='text-align:right' ><b> {$conver}</b></td></tr>";
         $optadd .= "  <tr><td>N.Entrega</td><td style='text-align:right' ><b>{$nentreg}</b></td><td style='padding-left:50px;'>Mayor        </td><td style='text-align:right' ><b>  {$mayor}</b></td></tr>";
         $optadd .= ' </table>';
         $optadd .= '</div>';
     } else {
         $optadd = '';
     }
     $data['content'] .= $optadd;
     $data['title'] = heading('Kardex de Inventario');
     $data['head'] = $this->rapyd->get_head();
     $this->load->view('view_ventanas', $data);
 }