Esempio n. 1
0
 function ejecutor()
 {
     $fcorte = func_get_args();
     $fdesde = array_shift($fcorte);
     $fhasta = $fcorte[count($fcorte) - 1];
     $query = $this->db->query("SELECT b.nombre AS grupo,a.unidad,a.descrip,a.indicador,a.puntos,a.objetivo,a.ejecuta\n\t\tFROM gestion_indicador AS a\n\t\tJOIN gestion_grupo AS b ON a.id_gestion_grupo=b.id\n\t\tWHERE a.puntos > 0 AND a.activo='S'\n\t\tORDER BY b.nombre");
     $content = '<table  width=100%>';
     $content .= '<col>';
     $content .= '<col>';
     $content .= '<col>';
     foreach ($fcorte as $id => $corte) {
         $v = $id % 2 + 1;
         $content .= '<col class="colbg' . $v . '">';
         $content .= '<col class="colbg' . $v . '">';
         $content .= '<col class="colbg' . $v . '">';
     }
     $content .= '<thead><tr><th rowspan=2 >Concepto</th><th rowspan=2>Puntos</th><th rowspan=2>Objetivo</th>';
     foreach ($fcorte as $corte) {
         $content .= '<td colspan="3" align="center">Corte ' . dbdate_to_human($corte) . '</td>';
     }
     $content .= '<th rowspan=2 >Medida</th></tr>';
     $content .= '<tr>';
     foreach ($fcorte as $corte) {
         $content .= '<td align="center">Objetivo logrado</td>';
         $content .= '<td align="center">% Logrado</td>';
         $content .= '<td align="center">Puntos Ganados</td>';
     }
     $content .= '</tr></thead>';
     $grupo = '';
     $pinta = true;
     $puntos_porce = 0;
     $puntos_total = array();
     foreach ($query->result() as $__row) {
         $resul = $this->_resultado($fdesde, $fcorte, $__row->ejecuta);
         $objetivo = $__row->objetivo;
         $unidad = $__row->unidad;
         $puntos = $__row->puntos;
         $ccana = count($resul);
         if ($grupo != $__row->grupo) {
             $grupo = $__row->grupo;
             $cspan = $ccana * 3 + 4;
             $content .= '<tr class=\'rowgroup\' style=\'background-color:#FFAD28;\'><td colspan=' . $cspan . '>' . $__row->grupo . '</td></tr>';
         }
         $puntos_porce += $puntos;
         $content .= '<tr ';
         $content .= $pinta ? 'class="odd"' : '';
         $pinta = !$pinta;
         $content .= '>';
         $content .= '<td><p class=\'miniblanco\'>' . $__row->descrip . '</p>' . $__row->indicador . '</td>';
         $content .= '<td align="center">' . $puntos . '</td>';
         $content .= '<td align="right">' . htmlnformat($objetivo) . ' ' . $unidad . '</td>';
         foreach ($resul as $pos => $val) {
             if (!is_array($val)) {
                 $pp = $val * 100 / $objetivo;
                 $acumulado = ceil($this->_escalas($pp) * $puntos);
                 $content .= '<td align="right">' . htmlnformat($val) . ' ' . $unidad . '</td>';
                 $content .= '<td align="right">' . htmlnformat($pp) . '%</td>';
                 $content .= '<td align="right">' . $acumulado . '</td>';
                 if (!isset($puntos_total[$pos])) {
                     $puntos_total[$pos] = 0;
                 }
                 $puntos_total[$pos] += $acumulado;
                 if ($pos == $ccana - 1) {
                     $content .= '<td align="center">' . img($this->url . 'gauge/' . round($pp, 1)) . '</td>';
                 }
             } else {
                 foreach ($val as $detalle) {
                 }
             }
         }
         $content .= '</tr>';
     }
     $content .= '<tr style="font-size: 28pt;background-color:#5846FF;">';
     $content .= '<td><b>Totales</b></td>';
     $content .= '<td align="center">' . $puntos_porce . '</td>';
     $content .= '<td></td>';
     for ($i = 0; $i < $ccana; $i++) {
         $content .= '<td colspan=2></td>';
         $content .= '<td align="right">' . $puntos_total[$i] . '</td>';
     }
     $content .= '<td align="center">' . img($this->url . 'gauge/' . round($puntos_total[$i - 1], 1)) . '</td>';
     $content .= '</table>';
     $content .= '</tr>';
     $content .= anchor($this->url . 'cdatos', 'Regresar');
     $data['head'] = style('mayor/estilo.css');
     $data['script'] = script('jquery.js');
     $data['script'] .= phpscript('nformat.js');
     $data['content'] = $content;
     $data['title'] = '<h1>Indicadores de Gesti&oacute;n desde el ' . dbdate_to_human($fdesde) . ' hasta el ' . dbdate_to_human($fhasta) . '</h1>';
     $this->load->view('view_ventanas_lite', $data);
 }
Esempio n. 2
0
 function dataedit()
 {
     $this->rapyd->load('dataedit');
     $mgas = array('tabla' => 'mgas', 'columnas' => array('codigo' => 'Codigo', 'descrip' => 'Descripcion', 'tipo' => 'Tipo'), 'filtro' => array('descrip' => 'Descripcion'), 'retornar' => array('codigo' => 'codigo', 'descrip' => 'descrip'), 'titulo' => 'Buscar enlace administrativo');
     $bcodigo = $this->datasis->modbus($mgas);
     $ivas = $this->datasis->ivaplica();
     $tasa = $ivas['tasa'] / 100;
     $redutasa = $ivas['redutasa'] / 100;
     $sobretasa = $ivas['sobretasa'] / 100;
     $consulrif = $this->datasis->traevalor('CONSULRIF');
     $url = site_url('ajax/ajaxsprv');
     $script = "\n\t\tfunction consulrif(){\n\t\t\tvrif=\$('#rif').val();\n\t\t\tif(vrif.length==0){\n\t\t\t\talert('Debe introducir primero un RIF');\n\t\t\t}else{\n\t\t\t\tvrif=vrif.toUpperCase();\n\t\t\t\t\$('#rif').val(vrif);\n\t\t\t\twindow.open('{$consulrif}'+'?p_rif='+vrif,'CONSULRIF','height=350,width=410');\n\t\t\t}\n\t\t}\n\n\t\tfunction poneiva(tipo){\n\t\t\tif(tipo==1){\n\t\t\t\tptasa = {$redutasa};\n\t\t\t\tcampo = 'reducida';\n\t\t\t\tmonto = 'monredu';\n\t\t\t} else if (tipo==3){\n\t\t\t\tptasa = {$sobretasa};\n\t\t\t\tcampo = 'sobretasa';\n\t\t\t\tmonto = 'monadic'\n\t\t\t} else {\n\t\t\t\tptasa = {$tasa};\n\t\t\t\tcampo = 'tasa';\n\t\t\t\tmonto = 'montasa';\n\t\t\t}\n\t\t\tif(\$('#'+monto).val().length>0)  base=parseFloat(\$('#'+monto).val());   else  base  =0;\n\t\t\t\$('#'+campo).val(roundNumber(base*ptasa,2));\n\t\t\ttotaliza();\n\t\t}\n\n\t\tfunction totaliza(){\n\t\t\tif(\$('#montasa').val().length>0)   montasa  = parseFloat(\$('#montasa').val());   else  montasa  = 0;\n\t\t\tif(\$('#tasa').val().length>0)      tasa     = parseFloat(\$('#tasa').val());      else  tasa     = 0;\n\t\t\tif(\$('#monredu').val().length>0)   monredu  = parseFloat(\$('#monredu').val());   else  monredu  = 0;\n\t\t\tif(\$('#reducida').val().length>0)  reducida = parseFloat(\$('#reducida').val());  else  reducida = 0;\n\t\t\tif(\$('#monadic').val().length>0)   monadic  = parseFloat(\$('#monadic').val());   else  monadic  = 0;\n\t\t\tif(\$('#sobretasa').val().length>0) sobretasa= parseFloat(\$('#sobretasa').val()); else  sobretasa= 0;\n\t\t\tif(\$('#exento').val().length>0)    exento   = parseFloat(\$('#exento').val());    else  exento   = 0;\n\t\t\t//if(\$('#reten').val().length>0)     reten    = parseFloat(\$('#reten').val());     else  reten    = 0;\n\n\t\t\ttotal=roundNumber(montasa+tasa+monredu+reducida+monadic+sobretasa+exento,2);\n\t\t\t\$('#importe').val(total);\n\t\t\t\$('#importe_val').text(nformat(total,2));\n\n\t\t\t//tapagar = roundNumber(total - reten,2);\n\t\t\t//\$('#apagar').val(tapagar);\n\t\t\t//\$('#apagar_val').text(nformat(tapagar,2));\n\n\t\t}\n\n\t\t\$(function(){\n\t\t\t\$('#codigo').autocomplete({\n\t\t\t\tsource: function( req, add){\n\t\t\t\t\t\$.ajax({\n\t\t\t\t\t\turl:  '" . site_url('ajax/automgas') . "',\n\t\t\t\t\t\ttype: 'POST',\n\t\t\t\t\t\tdataType: 'json',\n\t\t\t\t\t\tdata: 'q='+encodeURIComponent(req.term),\n\t\t\t\t\t\tsuccess:\n\t\t\t\t\t\t\tfunction(data){\n\t\t\t\t\t\t\t\tvar sugiere = [];\n\n\t\t\t\t\t\t\t\tif(data.length==0){\n\t\t\t\t\t\t\t\t\t\$('#codigo').val('');\n\t\t\t\t\t\t\t\t\t\$('#descrip').val('');\n\t\t\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\t\t\t\$.each(data,\n\t\t\t\t\t\t\t\t\t\tfunction(i, val){\n\t\t\t\t\t\t\t\t\t\t\tsugiere.push( val );\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tadd(sugiere);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t})\n\t\t\t\t},\n\t\t\t\tminLength: 1,\n\t\t\t\tselect: function( event, ui ) {\n\t\t\t\t\t\$('#codigo').attr('readonly', 'readonly');\n\n\t\t\t\t\t\$('#codigo').val(ui.item.codigo);\n\t\t\t\t\t\$('#descrip').val(ui.item.descrip);\n\t\t\t\t\tsetTimeout(function() {  \$('#codigo').removeAttr('readonly'); }, 1500);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t\$('#fechafac').datepicker({ dateFormat: 'dd/mm/yy' });\n\t\t\t\$('#importe_val').css('font-size','1.5em');\n\t\t\t\$('#importe_val').css('font-weight','bold');\n\n\t\t\t\$('#apagar_val').css('font-size','1.5em');\n\t\t\t\$('#apagar_val').css('font-weight','bold');\n\n\n\t\t\t\$('.inputnum').numeric('.');\n\t\t\t\$('#exento'   ).bind('keyup',function() { totaliza(); });\n\t\t\t\$('#montasa'  ).bind('keyup',function() { poneiva(2); });\n\t\t\t\$('#tasa'     ).bind('keyup',function() { totaliza(); });\n\t\t\t\$('#monredu'  ).bind('keyup',function() { poneiva(1); });\n\t\t\t\$('#reducida' ).bind('keyup',function() { totaliza(); });\n\t\t\t\$('#monadic'  ).bind('keyup',function() { poneiva(3); });\n\t\t\t\$('#sobretasa').bind('keyup',function() { totaliza(); });\n\n\t\t\t\$('#rif').focusout(function(){\n\t\t\t\trif=\$('#rif').val().toUpperCase();\n\t\t\t\t\$('#rif').val(rif);\n\t\t\t\tif(rif.length > 0){\n\t\t\t\t\t\$.post('{$url}', { rif: rif },function(data){\n\t\t\t\t\t\t\$('#proveedor').val(data);\n\t\t\t\t\t});\n\t\t\t\t}else{\n\t\t\t\t\talert('Debe introducir un rif');\n\t\t\t\t}\n\t\t\t});\n\n\t\t\ttotaliza();\n\t\t});";
     $edit = new DataEdit('', 'gserchi');
     $edit->back_url = site_url('finanzas/gser/gserchi');
     $edit->on_save_redirect = false;
     $edit->script($script, 'create');
     $edit->script($script, 'modify');
     $edit->post_process('insert', '_post_insert');
     $edit->post_process('update', '_post_update');
     $edit->post_process('delete', '_post_delete');
     $edit->pre_process('insert', '_pre_insert');
     $edit->pre_process('update', '_pre_update');
     $edit->pre_process('delete', '_pre_delete');
     $edit->codbanc = new dropdownField('Caja', 'codbanc');
     $edit->codbanc->option('', 'Seleccionar');
     $edit->codbanc->options("SELECT TRIM(codbanc) AS codbanc, CONCAT_WS('-',codbanc,banco) AS label FROM banc WHERE tbanco IN ('CAJ','CHI') AND codbanc!='00' AND tipocta='Q' ORDER BY codbanc");
     $edit->codbanc->rule = 'max_length[2]|required';
     $edit->codbanc->style = 'width:100px';
     $edit->fechafac = new dateField('Fecha', 'fechafac');
     $edit->fechafac->rule = 'max_length[10]|required';
     $edit->fechafac->size = 12;
     $edit->fechafac->insertValue = date('Y-m-d');
     $edit->fechafac->maxlength = 10;
     $edit->fechafac->calendar = false;
     $edit->numfac = new inputField('Factura', 'numfac');
     $edit->numfac->rule = 'max_length[20]|required';
     $edit->numfac->size = 20;
     $edit->numfac->maxlength = 20;
     $edit->numfac->autocomplete = false;
     $edit->nfiscal = new inputField('Control fiscal', 'nfiscal');
     $edit->nfiscal->rule = 'max_length[20]|required';
     $edit->nfiscal->size = 18;
     $edit->nfiscal->maxlength = 20;
     $edit->nfiscal->autocomplete = false;
     $edit->rif = new inputField('RIF del Proveedor', 'rif');
     $edit->rif->rule = 'max_length[13]|required';
     $edit->rif->size = 13;
     $edit->rif->maxlength = 13;
     $edit->rif->group = 'Datos del proveedor';
     $edit->proveedor = new inputField('Nombre', 'proveedor');
     $edit->proveedor->rule = 'max_length[40]|strtoupper';
     $edit->proveedor->size = 52;
     $edit->proveedor->group = 'Datos del proveedor';
     $edit->proveedor->maxlength = 40;
     $edit->codigo = new inputField('Concepto de Gasto', 'codigo');
     $edit->codigo->rule = 'max_length[6]|required';
     $edit->codigo->size = 6;
     $edit->codigo->maxlength = 8;
     $edit->codigo->append($bcodigo);
     $edit->descrip = new inputField('Descripci&oacute;n', 'descrip');
     $edit->descrip->rule = 'max_length[50]|strtoupper';
     $edit->descrip->size = 50;
     $edit->descrip->maxlength = 50;
     $alicuota = $this->datasis->ivaplica(date('Y-m-d'));
     $arr = array('exento' => 'Monto <b>Exento</b>|Monto exento', 'montasa' => 'Base Tasa G. ' . htmlnformat($ivas['tasa']) . '%|Base imponible', 'tasa' => 'IVA G. ' . htmlnformat($ivas['tasa']) . '%|Monto del IVA', 'monredu' => 'Base Tasa R. ' . htmlnformat($ivas['redutasa']) . '%|Base imponible', 'reducida' => 'IVA R. ' . htmlnformat($ivas['redutasa']) . '%|Monto del IVA', 'monadic' => 'Base Tasa A. ' . htmlnformat($ivas['sobretasa']) . '%|Base imponible', 'sobretasa' => 'IVA A. ' . htmlnformat($ivas['sobretasa']) . '%|Monto del IVA', 'importe' => 'Importe total', 'apagar' => 'Total a Pagar');
     foreach ($arr as $obj => $label) {
         $pos = strrpos($label, '|');
         if ($pos !== false) {
             $piv = explode('|', $label);
             $label = $piv[0];
             $grupo = $piv[0];
         } else {
             $grupo = '';
         }
         $edit->{$obj} = new inputField($label, $obj);
         $edit->{$obj}->rule = 'max_length[17]|numeric';
         $edit->{$obj}->css_class = 'inputnum';
         $edit->{$obj}->insertValue = 0;
         $edit->{$obj}->size = 12;
         $edit->{$obj}->maxlength = 12;
         $edit->{$obj}->autocomplete = false;
     }
     $edit->{$obj}->readonly = true;
     $edit->tasa->rule = 'condi_required|max_length[17]|callback_chtasa';
     $edit->reducida->rule = 'condi_required|max_length[17]|callback_chreducida';
     $edit->sobretasa->rule = 'condi_required|max_length[17]|callback_chsobretasa';
     $edit->importe->rule = 'max_length[17]|numeric|positive';
     $edit->importe->type = 'inputhidden';
     $edit->importe->label = '<b style="font-size:1.5em">Total Factura</b>';
     $edit->importe->showformat = 'decimal';
     $edit->sucursal = new dropdownField('Sucursal', 'sucursal');
     $edit->sucursal->options('SELECT codigo,sucursal FROM sucu ORDER BY sucursal');
     $edit->sucursal->rule = 'max_length[2]|required';
     $edit->sucursal->style = "width:100px";
     $edit->departa = new dropdownField('Departamento', 'departa');
     $edit->departa->options("SELECT TRIM(depto) AS codigo, CONCAT_WS('-',depto,TRIM(descrip)) AS label FROM dpto WHERE tipo='G' ORDER BY depto");
     $edit->departa->rule = 'max_length[2]';
     $edit->departa->style = "width:180px";
     /*
     		$edit->codigorete = new dropdownField('Retencion','codigorete');
     		$edit->codigorete->option('','Seleccionar');
     		$edit->codigorete->options('SELECT TRIM(codigo) AS codigo,TRIM(CONCAT_WS("-",tipo,codigo,activida)) AS activida FROM rete ORDER BY tipo,codigo');
     		$edit->codigorete->rule   ='max_length[4]';
     		$edit->codigorete->style  ='width: 250px';
     		$edit->codigorete->onchange='post_codigoreteselec(this.value)';
     
     		$edit->base = new inputField('Base','base');
     		$edit->base->rule='max_length[10]|numeric|positive';
     		$edit->base->css_class='inputnum';
     		$edit->base->size =12;
     		$edit->base->autocomplete=false;
     		$edit->base->maxlength =10;
     		$edit->base->onkeyup   ='importerete()';
     		$edit->base->showformat ='decimal';
     
     		$edit->porcen = new inputField('%','porcen');
     		$edit->porcen->rule='max_length[5]|numeric|positive';
     		$edit->porcen->css_class='inputnum';
     		$edit->porcen->size =7;
     		$edit->porcen->readonly  = true;
     		$edit->porcen->maxlength =5;
     		$edit->porcen->showformat ='decimal';
     		$edit->porcen->type='inputhidden';
     
     		$edit->reten = new inputField('Monto','reten');
     		$edit->reten->rule='max_length[10]|numeric|positive';
     		$edit->reten->css_class='inputnum';
     		$edit->reten->size =12;
     		$edit->reten->maxlength =8;
     		$edit->reten->readonly  = true;
     		$edit->reten->showformat ='decimal';
     
     		$edit->apagar->rule       = 'max_length[17]|numeric|positive';
     		$edit->apagar->type       = 'inputhidden';
     		$edit->apagar->label      = '<b style="font-size:1.5em">Total a Pagar</b>';
     		$edit->apagar->showformat = 'decimal';
     */
     $edit->usuario = new autoUpdateField('usuario', $this->session->userdata('usuario'), $this->session->userdata('usuario'));
     $edit->estampa = new autoUpdateField('estampa', date('YmD'), date('Ymd'));
     $edit->hora = new autoUpdateField('hora', date('H:m:s'), date('H:m:s'));
     //$edit->buttons('modify', 'save', 'undo', 'delete', 'back');
     $edit->build();
     if ($edit->on_success()) {
         $rt = array('status' => 'A', 'mensaje' => 'Registro guardado', 'pk' => $edit->_dataobject->pk);
         echo json_encode($rt);
     } else {
         $conten['form'] =& $edit;
         $data['content'] = $this->load->view('view_gserchi', $conten);
     }
 }
Esempio n. 3
0
	<tr>
		<td><?php 
    echo $form->numero->value . '-' . $form->nombre->value . $form->cliente->output;
    ?>
</td>
		<td align='right'><?php 
    echo $container_tl . $container_tr;
    ?>
</td>
	</tr>
	<?php 
    if (isset($saldo) && $saldo > 0) {
        ?>
	<tr>
		<td colspan='2' align='center'>Saldo vencido: <b id='saldoven' style='font-size:1.7em;color:#FF0800;'><?php 
        echo htmlnformat($saldo);
        ?>
</b></td>
	</tr>
	<?php 
    }
    ?>

</table>

<table width='100%' <?php 
    echo $form->_status != 'show' ? ' border="0" cellpadding="0" cellspacing="0"' : '';
    ?>
>
	<col>
	<?php 
Esempio n. 4
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);
 }
Esempio n. 5
0
    function dataeditit()
    {
        $this->rapyd->load('dataedit', 'dataobject');
        $id = intval($this->rapyd->uri->get_edited_id());
        $mSQL = "SELECT\n\t\t\ta.proveed,a.nombre,a.fecha,a.montotot,a.montoiva,a.montonet,a.serie,a.vence,a.tipo_doc,a.nfiscal,\n\t\t\tb.costo,b.cantidad,b.iva,b.codigo,c.descrip,\n\t\t\tc.pond AS sinvpond,c.existen AS sinvexisten,c.standard AS sinvstandard,c.formcal AS sinvformcal,\n\t\t\tc.margen1,c.margen2,c.margen3,c.margen4,c.ultimo,c.standard\n\t\t\tFROM scst   AS a\n\t\t\tJOIN itscst AS b ON a.control=b.control\n\t\t\tJOIN sinv   AS c ON b.codigo=c.codigo\n\t\t\tWHERE b.id={$id}";
        $scstrow = $this->datasis->damerow($mSQL);
        if (!empty($scstrow)) {
            $formcal = $scstrow['sinvformcal'];
            $pon = floatval(($scstrow['sinvpond'] * $scstrow['sinvexisten'] + $scstrow['costo'] * $scstrow['cantidad']) / ($scstrow['sinvexisten'] + $scstrow['cantidad']));
            if ($formcal == 'U') {
                $cformcal = '&Uacute;ltimo';
                $vcosto = $scstrow['costo'];
            } elseif ($formcal == 'P') {
                $cformcal = 'Ponderado';
                $vcosto = $pon;
            } elseif ($formcal == 'S') {
                $cformcal = 'Est&aacute;ndar';
                $vcosto = $scstrow['sinvstandard'];
            } else {
                $cformcal = 'Mayor';
                $ult = floatval($scstrow['costo']);
                if ($ult > $pon) {
                    $vcosto = $ult;
                } else {
                    $vcosto = $pon;
                }
            }
            $script = '
			function calculamar(){
				var costo  = ' . $vcosto . ';
				var iva    = ' . (100 + $scstrow['iva']) . ';
				var precio1= Number($("#precio1").val());
				var precio2= Number($("#precio2").val());
				var precio3= Number($("#precio3").val());
				var precio4= Number($("#precio4").val());

				var margen1=nformat(100-(costo*112)/precio1,2);
				var margen2=nformat(100-(costo*112)/precio2,2);
				var margen3=nformat(100-(costo*112)/precio3,2);
				var margen4=nformat(100-(costo*112)/precio4,2);

				$("#m1").text(margen1);
				$("#m2").text(margen2);
				$("#m3").text(margen3);
				$("#m4").text(margen4);

			}

			$(function(){
				$(".inputnum").keyup(function(e) { calculamar(); });
				calculamar();
				$(".inputnum").numeric(".");

				$("#rmargen").click(function (){
					var thisCheck = $(this);
					if(!thisCheck.is(":checked")){
						$("#precio1").removeAttr("disabled");
						$("#precio2").removeAttr("disabled");
						$("#precio3").removeAttr("disabled");
						$("#precio4").removeAttr("disabled");
						calculamar();
					}else{
						$("#precio1").attr("disabled", "disabled");
						$("#precio2").attr("disabled", "disabled");
						$("#precio3").attr("disabled", "disabled");
						$("#precio4").attr("disabled", "disabled");
						$("#m1").text("");
						$("#m2").text("");
						$("#m3").text("");
						$("#m4").text("");
					}
				});
				$("#rmargen").click();
				$("#rmargen").click();
			});';
            $htmltabla = "<table width='100%' style='background-color:#FBEC88;font-size:12px'>\n\t\t\t\t<tr>\n\t\t\t\t\t<td colspan='6' style='text-align:center;font-size:18px'><b>Detalles del documento</b></td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>Documento:</td>\n\t\t\t\t\t<td><b>" . htmlspecialchars($scstrow['tipo_doc'] . $scstrow['serie']) . "</b></td>\n\t\t\t\t\t<td>Proveedor:</td>\n\t\t\t\t\t<td><b>(" . htmlspecialchars($scstrow['proveed']) . ") " . htmlspecialchars($scstrow['nombre']) . "</b></td>\n\t\t\t\t\t<td>Fecha: </td>\n\t\t\t\t\t<td><b>" . dbdate_to_human($scstrow['fecha']) . "</b></td>\n\t\t\t\t</tr><tr>\n\t\t\t\t\t<td>C.Fiscal</td>\n\t\t\t\t\t<td>" . htmlspecialchars($scstrow['nfiscal']) . "</td>\n\t\t\t\t\t<td>Producto:</td>\n\t\t\t\t\t<td><b>" . htmlspecialchars('(' . $scstrow['codigo'] . ') ' . $scstrow['descrip']) . "</b></td>\n\t\t\t\t\t<td>Cantidad: </td>\n\t\t\t\t\t<td><b>" . nformat($scstrow['cantidad']) . "</b></td>\n\t\t\t\t</tr><tr>\n\t\t\t\t\t<td>IVA: </td>\n\t\t\t\t\t<td><b>" . nformat($scstrow['iva']) . "%</b></td>\n\t\t\t\t\t<td>Forma de C&aacute;lculo: </td>\n\t\t\t\t\t<td><b>" . $cformcal . "</b></td>\n\t\t\t\t\t<td>Costo: </td>\n\t\t\t\t\t<td><b>" . nformat($scstrow['costo']) . "</b></td>\n\t\t\t\t</tr>\n\t\t\t</table>\n\t\t\t<table width='100%' style='background-color:#7DC2FF;text-align:center;font-size:18px'>\n\t\t\t\t<tr>\n\t\t\t\t\t<td colspan='4'><b>Detalles del producto:</b></td>\n\t\t\t\t</tr><tr>\n\t\t\t\t\t<td>Ultimo Costo:   <b style='font-size:1.3em'>" . htmlnformat($scstrow['ultimo']) . "</b></td>\n\t\t\t\t\t<td>Costo Promedio: <b style='font-size:1.3em'>" . htmlnformat($scstrow['sinvpond']) . "</b></td>\n\t\t\t\t\t<td>Costo Estandar: <b style='font-size:1.3em'>" . htmlnformat($scstrow['standard']) . "</b></td>\n\t\t\t\t\t<td>Costo actual:   <b style='font-size:1.3em'>" . htmlnformat($scstrow['costo']) . "</b></td>\n\t\t\t\t</tr><tr>\n\t\t\t\t\t<td>Margen 1: <b style='font-size:1.3em'>" . htmlnformat($scstrow['margen1']) . "%</b></td>\n\t\t\t\t\t<td>Margen 2: <b style='font-size:1.3em'>" . htmlnformat($scstrow['margen2']) . "%</b></td>\n\t\t\t\t\t<td>Margen 3: <b style='font-size:1.3em'>" . htmlnformat($scstrow['margen3']) . "%</b></td>\n\t\t\t\t\t<td>Margen 4: <b style='font-size:1.3em'>" . htmlnformat($scstrow['margen4']) . "%</b></td>\n\t\t\t\t</tr>\n\t\t\t</table>";
        } else {
            $htmltabla = $script = '';
        }
        $edit = new DataEdit('', 'itscst');
        $edit->script($script, 'modify');
        $edit->on_save_redirect = false;
        $edit->post_process('insert', '_post_it_insert');
        $edit->post_process('update', '_post_it_update');
        $edit->post_process('delete', '_post_it_delete');
        $edit->pre_process('update', '_pre_it_update');
        $edit->tablafo = new containerField('tablafo', $htmltabla);
        $edit->rmargen = new checkboxField('<span style="font-size:1.5em">Respetar Margen</span>', 'rmargen', 'S', 'N');
        $edit->rmargen->insertValue = 'S';
        $edit->rmargen->append('<b style="color:red">Si se selecciona esta opci&oacute;n NO se modificaran los margenes al
			momento de actualizar la compra con opci&oacute;n de cambio de precio. En caso contrario se usar&aacute;n los precios
			abajo mostrados si se actualiza con opci&oacute;n de cambio de precio.
			</b>');
        $edit->precio1 = new inputField('<span style="font-size:1.5em">Precio 1</span>', 'precio1');
        $edit->precio1->rule = 'numeric';
        $edit->precio1->css_class = 'inputnum';
        $edit->precio1->size = 12;
        $edit->precio1->maxlength = 15;
        $edit->precio1->style = 'font-size: 2em;font-weight:bold;';
        $edit->precio2 = new inputField('<span style="font-size:1.5em">Precio 2</span>', 'precio2');
        $edit->precio2->rule = 'numeric';
        $edit->precio2->css_class = 'inputnum';
        $edit->precio2->size = 12;
        $edit->precio2->maxlength = 15;
        $edit->precio2->style = 'font-size: 2em;font-weight:bold;';
        $edit->precio3 = new inputField('<span style="font-size:1.5em">Precio 3</span>', 'precio3');
        $edit->precio3->rule = 'numeric';
        $edit->precio3->css_class = 'inputnum';
        $edit->precio3->size = 12;
        $edit->precio3->maxlength = 15;
        $edit->precio3->style = 'font-size: 2em;font-weight:bold;';
        $edit->precio4 = new inputField('<span style="font-size:1.5em">Precio 4</span>', 'precio4');
        $edit->precio4->rule = 'numeric';
        $edit->precio4->css_class = 'inputnum';
        $edit->precio4->size = 12;
        $edit->precio4->maxlength = 15;
        $edit->precio4->style = 'font-size: 2em;font-weight:bold;';
        $edit->margen1 = new freeField('', 'total', '<span style="font-size:1.7em;" id="m1">0,00</span>% (*IVA incluido)');
        $edit->margen1->in = 'precio1';
        $edit->margen2 = new freeField('', 'total', '<span style="font-size:1.7em;" id="m2">0,00</span>% (*IVA incluido)');
        $edit->margen2->in = 'precio2';
        $edit->margen3 = new freeField('', 'total', '<span style="font-size:1.7em;" id="m3">0,00</span>% (*IVA incluido)');
        $edit->margen3->in = 'precio3';
        $edit->margen4 = new freeField('', 'total', '<span style="font-size:1.7em;" id="m4">0,00</span>% (*IVA incluido)');
        $edit->margen4->in = 'precio4';
        $edit->build();
        if ($edit->on_success()) {
            $rt = array('status' => 'A', 'mensaje' => 'Registro guardado', 'pk' => $edit->_dataobject->pk);
            echo json_encode($rt);
        } else {
            echo $edit->output;
        }
    }
Esempio n. 6
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);
 }
Esempio n. 7
0
 function filterscli()
 {
     $this->datasis->modulo_id(143, 1);
     $vd = trim($this->secu->getvendedor());
     $caub = trim($this->secu->getalmacen());
     if (empty($vd) || empty($caub)) {
         show_error('Usuario no tiene asignado vendedor, cajero o almacen, debe asignarlo primero para poder usar este modulo');
     }
     $url = $this->url . 'filteredgrid';
     $this->rapyd->uri->keep_persistence();
     $persistence = $this->rapyd->session->get_persistence($url, $this->rapyd->uri->gfid);
     $back = isset($persistence['back_uri']) ? $persistence['back_uri'] : $url;
     $vd = $this->secu->getvendedor();
     $this->rapyd->load('datafilter', 'datagrid');
     $filter = new DataFilter('Lista de clientes asignados al vendedor ' . $vd);
     $filter->button('btn_back', RAPYD_BUTTON_BACK, "javascript:window.location='" . site_url($back) . "'", 'BL');
     $dbvd = $this->db->escape($vd);
     $dbfini = $this->db->escape(date('Y-m-d', mktime(0, 0, 0, date('n'), 1)));
     $sel = array('a.cliente', 'a.nombre', 'a.rifci', 'COUNT(DISTINCT b.numero)  AS rayado');
     $filter->db->select($sel);
     $filter->db->from('scli     AS a');
     $filter->db->join('sfac     AS b', "b.cod_cli=a.cliente AND b.vd={$dbvd} AND b.fecha>={$dbfini} AND b.tipo_doc='F' AND b.entregable = 'S'", 'left');
     $filter->db->join('sclitrut AS c', 'a.cliente=c.cliente', 'left');
     $filter->db->join('sclirut  AS d', 'c.ruta=d.ruta', 'left');
     $filter->db->where("( a.vendedor = {$dbvd} OR a.cobrador={$dbvd} OR d.vende={$dbvd})");
     $filter->db->where('a.tipo <>', '0');
     $filter->db->groupby('a.cliente');
     $filter->cliente = new inputField('C&oacute;digo', 'cliente');
     $filter->cliente->size = 8;
     $filter->cliente->db_name = 'a.cliente';
     $filter->nombre = new inputField('Nombre', 'nombre');
     $filter->nombre->db_name = 'a.nombre';
     $filter->rifci = new inputField('CI/RIF', 'rifci');
     $filter->rifci->db_name = 'a.rifci';
     $filter->rifci->size = 15;
     $filter->buttons('reset', 'search');
     $filter->build();
     if (!empty($vd)) {
         $mSQL = "SELECT COUNT(DISTINCT a.cliente) AS cana\n\t\t\t\tFROM scli AS a\n\t\t\t\tLEFT JOIN sclitrut AS c ON a.cliente=c.cliente\n\t\t\t\tLEFT JOIN sclirut  AS d ON c.ruta=d.ruta\n\t\t\t\tWHERE ( vendedor = {$dbvd} OR cobrador={$dbvd} OR d.vende={$dbvd}) AND a.tipo<>0";
         $clientes = intval($this->datasis->dameval($mSQL));
         $mSQL = "SELECT COUNT(*) AS cana\n\t\t\t\tFROM sfac\n\t\t\t\tWHERE vd = {$dbvd} AND fecha>={$dbfini} AND referen<>'P' AND tipo_doc<>'X' AND tipo_doc='F' AND entregable='S' AND MID(numero,1,1) <> '_'";
         $facturas = intval($this->datasis->dameval($mSQL));
         $mSQL = "SELECT COUNT(DISTINCT aa.cliente) AS cca FROM (\n\t\t\t\tSELECT a.cliente\n\t\t\t\tFROM scli AS a\n\t\t\t\tJOIN sfac AS b ON b.cod_cli=a.cliente\n\t\t\t\tLEFT JOIN sclitrut AS d ON a.cliente=d.cliente\n\t\t\t\tLEFT JOIN sclirut  AS e ON d.ruta=e.ruta AND e.vende=b.vd\n\t\t\t\tWHERE b.fecha>={$dbfini} AND b.vd={$dbvd} AND (b.vd IN (a.vendedor,a.cobrador) OR e.ruta IS NOT NULL)\n\t\t\t\t\tAND b.tipo_doc='F' AND b.entregable='S' AND MID(b.numero,1,1) <> '_'\n\t\t\t\tGROUP BY a.cliente\n\t\t\t) AS aa";
         $atendidos = intval($this->datasis->dameval($mSQL));
         $mSQL = "SELECT SUM(c.peso*a.cana*IF(a.tipoa='F',1,-1)) AS peso\n\t\t\t\tFROM sitems AS a\n\t\t\t\tJOIN sfac AS b ON a.numa=b.numero AND a.tipoa=b.tipo_doc\n\t\t\t\tJOIN sinv AS c ON a.codigoa=c.codigo\n\t\t\t\tWHERE b.vd = {$dbvd} AND a.tipoa<>'X' AND b.fecha>={$dbfini} AND MID(b.numero,1,1) <> '_'";
         $ttpeso = nformat(floatval($this->datasis->dameval($mSQL)) / 1000, 3);
         $vmonto = $this->datasis->traevalor('PFACLITEMONTO', 'Muestra o no el monto que ha facturado el vendedor');
         if ($vmonto == 'S') {
             $mSQL = "SELECT SUM(totals*IF(tipo_doc='F',1,-1)) AS total FROM sfac WHERE vd = {$dbvd} AND fecha>={$dbfini} AND tipo_doc<>'X' AND MID(numero,1,1) <> '_'";
             $monto = nformat(floatval($this->datasis->dameval($mSQL)));
             $smonto = "Monto: {$monto}";
         } else {
             $smonto = '';
         }
         if ($clientes > 0) {
             $efe = htmlnformat($atendidos * 100 / $clientes);
         } else {
             $efe = htmlnformat(0);
         }
         $frace = "<p style='text-align:center;font-weight: bold;'>Clientes atendidos: <span style='font-size:1.5em; color:#000063'>{$atendidos}</span>/{$clientes} Efectividad: <span style='font-size:1.5em; color:#000063'>{$efe}%</span> Facturas: {$facturas} Peso: {$ttpeso}T {$smonto}</p>";
     } else {
         $frace = '';
     }
     $uri = anchor($this->url . 'dataedit/<raencode><#cliente#></raencode>/create', '<#cliente#>');
     $grid = new DataGrid('Seleccione el cliente al cual se le va a realizar el pedido');
     $grid->use_function('htmlspecialchars');
     $grid->table_id = 'sclilist';
     $grid->order_by('nombre', 'asc');
     $grid->per_page = 20;
     $grid->column_orderby('#Fact.', 'rayado', 'rayado', 'align=\'right\'');
     $grid->column_orderby('Cliente', $uri, 'cliente');
     $grid->column_orderby('Nombre', '<htmlspecialchars><#nombre#>|2|ISO-8859-1</htmlspecialchars>', 'nombre');
     $grid->column_orderby('RIF/CI', 'rifci');
     $grid->build();
     $data['script'] = '<style type="text/css">#sclilist tr:hover { background-color: #ffff99; }</style>';
     $data['content'] = $filter->output . $frace . $grid->output;
     $data['title'] = heading('Clientes');
     $data['head'] = $this->rapyd->get_head();
     $data['extras'] = '';
     $this->load->view('view_ventanas', $data);
 }