function index() { $this->load->library('PDFReporte'); $this->rapyd->load("datafilter2"); $repo = $this->uri->segment(3); $esta = $this->uri->segment(4); //************************** $mSPRV = array('tabla' => 'sprv', 'columnas' => array('proveed' => 'Código', 'nombre' => 'Nombre', 'contacto' => 'Contacto'), 'filtro' => array('proveed' => 'Código', 'nombre' => 'Nombre'), 'retornar' => array('proveed' => 'proveed'), 'titulo' => 'Buscar Proveedor'); $bSPRV = $this->datasis->modbus($mSPRV); $mGRUP = array('tabla' => 'grup', 'columnas' => array('grupo' => 'Código', 'nom_grup' => 'Nombre'), 'filtro' => array('grupo' => 'Código', 'nom_grup' => 'Nombre'), 'retornar' => array('grupo' => 'grupo'), 'titulo' => 'Buscar Grupo'); $bGRUP = $this->datasis->modbus($mGRUP); $filter = new DataFilter2("Filtro del Reporte"); $filter->attributes = array('onsubmit' => 'is_loaded()'); $select = array("codigo", "descrip", "fechav", "IF(pfecha1>pfecha2,IF(pfecha1>pfecha3,pfecha1,pfecha3),IF(pfecha2>pfecha3,pfecha2,pfecha3)) AS cfecha", "existen", "ultimo*existen as monto", "grupo"); $filter->db->select($select); $filter->db->from('sinv as a'); $filter->db->where('existen>', '0'); $filter->dias = new inputField("Estancados desde los ultimos", "dias"); $filter->dias->clause = ''; $filter->dias->append("días"); $filter->dias->rule = "required"; $filter->dias->insertValue = 150; $filter->dias->size = 5; $filter->proveed = new inputField("Proveedor", "proveed"); $filter->proveed->clause = "where"; $filter->proveed->db_name = '(prov1,prov2,prov3)'; $filter->proveed->append($bSPRV); $filter->proveed->clause = 'in'; $filter->grupo = new inputField("Grupo", "grupo"); $filter->grupo->db_name = "grupo"; $filter->grupo->append($bGRUP); $filter->grupo->clause = "where"; $filter->grupo->operator = "="; $filter->buttons("search"); $filter->build(); if ($this->rapyd->uri->is_set("search") and $filter->is_valid()) { $dias = $filter->dias->value; $fecha = date("Ymd", mktime(0, 0, 0, date('m'), date('d') - $dias, date('Y'))); $filter->db->where('fechav <', $fecha); $filter->db->where('IF(pfecha1>pfecha2,IF(pfecha1>pfecha3,pfecha1,pfecha3),IF(pfecha2>pfecha3,pfecha2,pfecha3))<', $fecha); $mSQL = $filter->db->_compile_select(); //echo $mSQL; $sobretabla = ''; if (!empty($filter->proveed->newValue)) { $sobretabla .= ' Proveedor: (' . $filter->proveed->newValue . ') ' . $this->datasis->dameval('SELECT nombre FROM sprv WHERE proveed="' . $filter->proveed->newValue . '"'); } if (!empty($filter->grupo->newValue)) { $sobretabla .= ' Grupo: (' . $filter->grupo->newValue . ') ' . $this->datasis->dameval('SELECT nom_grup FROM grup WHERE grupo="' . $filter->grupo->newValue . '"'); } $pdf = new PDFReporte($mSQL, 'L'); $pdf->setType('cfecha', 'date'); $pdf->setHeadValores('TITULO1'); $pdf->setSubHeadValores('TITULO2', 'TITULO3'); $pdf->setTitulo("Articulos sin Ventas"); $pdf->setSobreTabla($sobretabla, 10); $pdf->AddPage(); $pdf->setTableTitu(12, 'Times'); $pdf->AddCol('codigo', 35, array('Código', ''), 'L', 10); $pdf->AddCol('descrip', 90, array('Descripción', ''), 'L', 10); $pdf->AddCol('fechav', 25, array('Ultima', 'Venta'), 'C', 10); $pdf->AddCol('cfecha', 25, array('Ultima', 'Compra'), 'C', 10); $pdf->AddCol('existen', 25, array('Cantidad', ''), 'R', 10); $pdf->AddCol('monto', 30, array('Monto', ''), 'R', 10); $pdf->Table(); $pdf->Output(); } else { if (strlen($filter->error_string)) { $data["error"] = $filter->error_string; } $data["filtro"] = $filter->output; $data["titulo"] = '<h2 class="mainheader">Articulos sin Ventas<h2>'; $data["head"] = $this->rapyd->get_head(); $this->load->view('view_freportes', $data); } //************************** //************************** }
function index() { $this->load->library('PDFReporte'); $this->rapyd->load("datafilter2"); $repo = $this->uri->segment(3); $esta = $this->uri->segment(4); //************************** $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); $opciones = array(); $mSQL = 'SELECT SQL_BIG_RESULT fecha FROM maesfisico GROUP BY fecha ORDER BY fecha DESC LIMIT 5'; $query = $this->db->query($mSQL); foreach ($query->result() as $row) { $opciones[$row->fecha] = dbdate_to_human($row->fecha); } $filter = new DataFilter2("Filtro del Reporte"); $filter->attributes = array('onsubmit' => 'is_loaded()'); $select = array("a.ubica", "b.descrip", "a.venta", "a.cantidad", "a.anteri", "a.saldo", "a.monto", "a.salcant", "a.codigo", "a.origen", "a.promedio", "a.cantidad-a.anteri AS diferencia", " (a.cantidad*b.fracxuni+b.fracci)*b.ultimo AS costo"); $filter->db->select($select); $filter->db->from('costos AS a'); $filter->db->join('maes AS b', 'a.codigo=b.codigo'); $filter->ubica = new dropdownField("Almacen", "ubica"); $filter->ubica->option("", "Todos"); $filter->ubica->db_name = '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 = 'fecha'; $filter->fecha->options($opciones); $filter->fecha->operator = "="; $filter->fecha->clause = "where"; $filter->dif = new checkboxField("Solo diferencia distinta a cero", 'dif', "0"); $filter->dif->db_name = 'a.cantidad-a.anteri'; $filter->dif->operator = "!="; $filter->dif->clause = "where"; $filter->buttons("search"); $filter->build(); if ($this->rapyd->uri->is_set("search") and $filter->is_valid()) { $fecha = dbdate_to_human($filter->fecha->value); $mSQL = $filter->db->_compile_select(); //echo $mSQL; $pdf = new PDFReporte($mSQL, 'L'); $pdf->setType('cfecha', 'date'); $pdf->setHeadValores('TITULO1'); $pdf->setSubHeadValores('TITULO2', 'TITULO3'); $pdf->setTitulo("Resumen de inventario físico del {$fecha}"); $pdf->AddPage(); $pdf->setTableTitu(12, 'Times'); $pdf->AddCol('codigo', 35, array('Código', ''), 'L', 10); $pdf->AddCol('descrip', 80, array('Descripción', ''), 'L', 10); $pdf->AddCol('cantidad', 30, array('Cantidad', 'Contada'), 'R', 10); $pdf->AddCol('anteri', 30, array('Cantidad', 'anterior'), 'R', 10); $pdf->AddCol('diferencia', 30, array('Diferencia', ''), 'R', 10); $pdf->AddCol('costo', 40, array('Costo', ''), 'R', 10); $pdf->Table(); $pdf->Output(); } else { if (strlen($filter->error_string)) { $data["error"] = $filter->error_string; } $data["filtro"] = $filter->output; $data["titulo"] = '<h2 class="mainheader">Resumen de inventario<h2>'; $data["head"] = $this->rapyd->get_head(); $this->load->view('view_freportes', $data); } //************************** //************************** }