Exemple #1
0
 function procesar()
 {
     $this->datasis->modulo_id($this->modulo, 1);
     $this->load->library('validation');
     $fechai = $this->input->post('fechai');
     $fechaf = $this->input->post('fechaf');
     $fechamin = $this->datasis->dameval('SELECT inicio FROM cemp LIMIT 1');
     if ($fechamin > substr(human_to_dbdate($fechai), 0, 10)) {
         echo 'Error: Fecha inicial menor a la permitida ' . substr(human_to_dbdate($fechai), 0, 10);
         return false;
     }
     $ban = 0;
     $ban += $this->validation->chfecha($fechai);
     $ban += $this->validation->chfecha($fechaf);
     if ($ban != 2) {
         echo 'Error: Fechas erroneas';
         return false;
     }
     session_write_close();
     $qfechai = date("Ymd", timestampFromInputDate($fechai, 'd/m/Y'));
     $qfechaf = date("Ymd", timestampFromInputDate($fechaf, 'd/m/Y'));
     $generar = $this->input->post('genera');
     $salida = $this->_procesar($qfechai, $qfechaf, $generar);
     echo $salida;
     return true;
     //redirect('contabilidad/generar/index/completo');
 }
Exemple #2
0
 function _getNewValue()
 {
     parent::_getNewValue();
     if (isset($this->request[$this->name])) {
         $this->newValue = human_to_dbdate($this->newValue, $this->format);
     }
 }
Exemple #3
0
 function inserta($codbanc, $tipo_doc, $cheque, $fecha, $observa = '', $debe = 0, $haber = 0, $saldo = 0)
 {
     $fecha = human_to_dbdate($fecha);
     $data = array('codbanc' => $codbanc, 'fecha' => $fecha, 'cheque' => $cheque, 'observa' => $observa, 'debe' => $debe, 'haber' => $haber, 'saldo' => $saldo, 'tipo_doc' => $tipo_doc);
     $this->db->delete('concilia', array('codbanc' => $codbanc, 'cheque' => $cheque));
     $this->db->insert('concilia', $data);
 }
Exemple #4
0
 function procesar()
 {
     //$this->datasis->modulo_id($this->modulo,1);
     $this->load->library('validation');
     $fechai = $this->input->post('fechai');
     $fechaf = $this->input->post('fechaf');
     $ban = 0;
     $ban += $this->validation->chfecha($fechai);
     $ban += $this->validation->chfecha($fechaf);
     if ($ban != 2) {
         echo 'Error: Fechas erroneas';
         return false;
     }
     $c = $this->datasis->dameval("SELECT COUNT(*) FROM casise\n\t\tWHERE 1*CONCAT(ano,mes) >=EXTRACT(YEAR_MONTH FROM '" . human_to_dbdate($fechai) . "')\n\t\t\tAND \n\t\t\t1*CONCAT(ano,mes)<= EXTRACT(YEAR_MONTH FROM '" . human_to_dbdate($fechaf) . "')");
     if ($c > 0) {
         echo 'Error: El Mes ya esta cerrado';
         return false;
     }
     $qfechai = date("Ymd", timestampFromInputDate($fechai, 'd/m/Y'));
     $qfechaf = date("Ymd", timestampFromInputDate($fechaf, 'd/m/Y'));
     $generar = $this->input->post('genera');
     $salida = $this->_procesar($qfechai, $qfechaf, $generar);
     echo $salida;
     return true;
     //redirect('contabilidad/generar/index/completo');
 }
Exemple #5
0
 function chlitros($litros, $ind)
 {
     $bufala = round(floatval($this->input->post('itbufala_' . $ind)), 2);
     $vaca = round(floatval($this->input->post('itlitros_' . $ind)), 2);
     $litros = $vaca + $bufala;
     $ruta = $this->input->post('codrut_' . $ind);
     $fecha = human_to_dbdate($this->input->post('fecha'));
     $id = $this->input->post('itid_' . $ind);
     if (!empty($id)) {
         $ww = 'AND a.id <> ' . $this->db->escape($id);
     } else {
         $ww = '';
     }
     $dbfecha = $this->db->escape($fecha);
     $dbruta = $this->db->escape($ruta);
     $usados = round($this->datasis->dameval("SELECT SUM(a.litros) FROM itlprod AS a JOIN lprod AS b ON a.id_lprod=b.id WHERE a.codrut={$dbruta} AND b.fecha={$dbfecha} {$ww}"), 2);
     $recibi = round($this->datasis->dameval("SELECT SUM(litros)   FROM lrece   WHERE ruta={$dbruta} AND fecha={$dbfecha}"), 2);
     $disponible = $recibi - $usados - $litros;
     if ($disponible < 0) {
         if ($recibi - $usados < 0) {
             $disponible = 0;
         } else {
             $disponible = $recibi - $usados;
         }
         $this->validation->set_message('chlitros', "No hay suficiente leche recibida de la ruta {$ruta} para producir, disponible: " . nformat(abs($disponible)));
         return false;
     } else {
         return true;
     }
 }
Exemple #6
0
 function guardar()
 {
     $this->rapyd->load('dataobject');
     $fechad = $this->input->post('fechad');
     $fechah = $this->input->post('fechah');
     $fechad2 = $this->db->escape(human_to_dbdate($fechad));
     $fechah2 = $this->db->escape(human_to_dbdate($fechah));
     $cant = $this->input->post('cant');
     $codigoadm = $this->input->post('codigoadm');
     $fondo = $this->input->post('fondo');
     $do = new DataObject("mbanc");
     $error = '';
     $query = "SELECT numero,ocompra,reten FROM ISLR";
     $retenciones = $this->db->query($query);
     $cant2 = $retenciones->num_rows();
     $pagos = $compras = array();
     $reten = 0;
     foreach ($retenciones->result() as $row) {
         $reten += $row->reten;
         if ($row->ocompra > 0) {
             $compras[] = $row->ocompra;
         } else {
             $pagos[] = $row->numero;
         }
     }
     if (round($cant, 2) != round($cant2, 2)) {
         $error .= "<div class='alert'>Los montos Previsualizados ({$cant}) y los actuales no parecen ser iguales ({$cant2}) </div>";
     }
     if (empty($error)) {
         if ($reten > 0) {
             $do->set("monto", $reten);
             $do->set("status", "J");
             $do->set("tipo", "R");
             $do->set("tipo_doc", "ND");
             $do->set("observa", ".Se cancelo el ISLR desde {$fechad} hasta {$fechah} actividad {$codigoadm} fondo {$fondo}");
             $do->set('rel', implode(',', $pagos) . '|' . implode(',', $compras));
             $do->save();
             $id = $do->get('id');
             if (!$id > 0) {
                 $error .= "Ocurrio error al momento de Crear la orden de pago";
             }
             if (empty($error)) {
                 echo $query = "UPDATE  ocompra d\r\n\t\t\t\t\tJOIN pacom e ON d.numero = e.compra\r\n\t\t\t\t\tJOIN odirect a ON e.pago = a.numero\r\n\t\t\t\t\tJOIN pades b ON a.numero = b.pago\r\n\t\t\t\t\tJOIN desem c ON b.desem = c.numero\r\n\t\t\t\t\tSET d.mislr ={$id} \tWHERE c.status='D2' AND d.reten >0 AND fdesem>={$fechad2} AND fdesem <={$fechah2} AND (a.mislr IS NULL)";
             }
             if (!empty($codigoadm)) {
                 $query .= " AND d.estadmin='{$codigoadm}'";
             }
             if (!empty($fondo)) {
                 $query .= " AND d.fondo='{$fondo}'";
             }
             $bool = $this->db->simple_query($query);
             if (!$bool) {
                 $error .= "Ocurrio error al momento de actualizar la tabla de compras</br>";
             }
             $query = "UPDATE odirect a \r\n\t\t\t\t\tJOIN pades b ON a.numero = b.pago\r\n\t\t\t\t\tJOIN desem c ON b.desem = c.numero\r\n\t\t\t\t\tJOIN sprv p ON c.cod_prov = p.proveed\r\n\t\t\t\t\tSET a.mislr={$id}\r\n\t\t\t\t\tWHERE c.status='D2' AND reten >0 AND fdesem>={$fechad2} AND fdesem<= {$fechah2} AND MID(a.status,1,1)<>'F' AND (a.mislr IS NULL)";
             if (!empty($codigoadm)) {
                 $query .= " AND a.estadmin='{$codigoadm}'";
             }
             if (!empty($fondo)) {
                 $query .= " AND a.fondo='{$fondo}'";
             }
             $bool = $this->db->simple_query($query);
             if (!$bool) {
                 $error .= "Ocurrio error al momento de actualizar la tabla pagos</br>";
             }
         } else {
             $error .= "<div class='alert'><p>No hay ISLR por pagar desde {$fechad} hasta {$fechah} </p></div>";
         }
     }
     if (empty($error)) {
         logusu('ISLR', "Creo Movimiento de ISLR {$id}");
         redirect("tesoreria/mbanc/dataedit/modify/" . $id);
     } else {
         logusu('ISLR', "Intento crear Movimiento Bancario de ISLR  con error {$error}");
         $data['content'] = '<div class="alert" >' . $error . '</div></br>' . anchor($this->url . "nuevo", 'Regresar');
         $data['title'] = " " . $this->t**s . " ";
         $data["head"] = $this->rapyd->get_head();
         $this->load->view('view_ventanas', $data);
     }
 }
Exemple #7
0
 function cconci()
 {
     $error = '';
     $data = $this->input->post('data');
     $accion = $this->input->post('accion');
     $fconci = human_to_dbdate($this->input->post('fconci'));
     if ($data !== false) {
         $pk = unserialize($data);
         $pk[2] = radecode($pk[2]);
         if ($accion == 'true') {
             $ddata = array('fconcilia' => $fconci, 'concilia' => 'S');
         } else {
             $ddata = array('fconcilia' => null, 'concilia' => 'N');
         }
         $where = ' codbanc             = ' . $this->db->escape($pk[0]);
         $where .= ' AND tipo_doc        = ' . $this->db->escape($pk[1]);
         $where .= ' AND cheque          = ' . $this->db->escape($pk[2]);
         $where .= ' AND id              = ' . $this->db->escape($pk[4]);
         //$where .= ' AND MID(status,2,1) = "2"';
         $fechas = $this->datasis->damerow("SELECT replace(fecha,'-','') fecha,fecha f FROM mbanc WHERE {$where}");
         $error .= $this->chbanse($pk[0], $fconci);
         //			$error  .=$this->chbanse($pk[0],$fechas['f']);
         if ($fechas['fecha'] > $pk[3] && $accion == 'true') {
             $error .= 'La fecha de Conciliacion no puede ser menor a la fecha del documento';
         }
         $mSQL = $this->db->update_string('mbanc', $ddata, $where);
         if (empty($error)) {
             logusu("conci", $mSQL);
             if ($this->db->query($mSQL)) {
                 echo '1';
             } else {
                 echo 'Hubo un error, comuniquese con soporte tecnico';
             }
         } else {
             echo $error;
         }
     }
 }
Exemple #8
0
 function g_patente($d, $c)
 {
     $id = $d['id'];
     $data = $d;
     $data['contribu'] = $c['codigo'];
     $data['nombre_pro'] = $c['nombre'];
     $data['cedula'] = $c['rifci'];
     $data['nacionali'] = $c['nacionali'];
     $data['dir_pro'] = $c['direccion'];
     $data['telefonos'] = $c['telefono'];
     $data['fecha_es'] = human_to_dbdate($data['fecha_es']);
     $data['fvencimiento'] = human_to_dbdate($data['fvencimiento']);
     $data['fexpedicion'] = human_to_dbdate($data['fexpedicion']);
     if ($id > 0) {
         $this->db->where('id', $id);
         $this->db->update('patente', $data);
     } else {
         $this->db->insert('patente', $data);
         $id = $this->db->insert_id();
     }
     return $id;
 }
Exemple #9
0
 function chexiste($codigo)
 {
     $codigo = $this->input->post('codigo');
     $fecha = human_to_dbdate($this->input->post('fecha'));
     $hora = $this->input->post('hora');
     $dbcodigo = $this->db->escape($codigo);
     $dbfecha = $this->db->escape($fecha);
     $dbhora = $this->db->escape($hora);
     $chek = $this->datasis->dameval("SELECT COUNT(*) AS cana FROM cacc WHERE codigo={$dbcodigo} AND fecha={$dbfecha} AND hora={$dbhora}");
     if ($chek > 0) {
         $nombre = $this->datasis->dameval("SELECT cedula FROM cacc WHERE codigo={$dbcodigo} AND fecha={$dbfecha} AND hora={$dbhora}");
         $this->validation->set_message('chexiste', "Acceso para {$nombre} CODIGO {$codigo} FECHA {$fecha} HORA {$hora} ya existe");
         return false;
     } else {
         return true;
     }
 }
Exemple #10
0
 function getfac()
 {
     $numero = $this->input->post('numero');
     $fecha = $this->input->post('fecha');
     $caja = $this->input->post('caja');
     $retArray = array();
     if ($numero * $fecha * $caja == false) {
         echo json_encode($retArray);
         return '';
     } else {
         $fecha = human_to_dbdate($fecha);
     }
     $dbnumero = $this->db->escape($numero);
     $dbfecha = $this->db->escape($fecha);
     $dbcaja = $this->db->escape($caja);
     $mSQL = "SELECT cliente, CONCAT_WS(' ',nombres,apellidos) AS nombres, gtotal,impuesto\n\t\tFROM viefac\n\t\tWHERE numero={$dbnumero} AND fecha={$dbfecha} AND caja={$dbcaja} LIMIT 1";
     $query = $this->db->query($mSQL);
     if ($query->num_rows() > 0) {
         $row = $query->row_array();
         $retArray['cliente'] = $row['cliente'];
         $retArray['nombres'] = utf8_encode($row['nombres']);
         $retArray['gtotal'] = $row['gtotal'];
         $retArray['impuestos'] = $row['impuesto'];
     }
     echo json_encode($retArray);
     return true;
 }
Exemple #11
0
 function chabono($monto, $i)
 {
     $tipo = $this->input->post('tipo_doc_' . $i);
     $ppago = $this->input->post('ppago_' . $i);
     $numero = $this->input->post('numero_' . $i);
     $cod_cli = $this->input->post('cod_cli');
     $fecha = human_to_dbdate($this->input->post('fecha_' . $i));
     $this->db->select(array('monto - abonos AS saldo'));
     $this->db->from('smov');
     $this->db->where('tipo_doc', $tipo);
     $this->db->where('numero', $numero);
     $this->db->where('fecha', $fecha);
     $this->db->where('cod_cli', $cod_cli);
     $query = $this->db->get();
     $row = $query->row();
     if ($query->num_rows() == 0) {
         return false;
     }
     $saldo = $row->saldo;
     if ($monto + $ppago <= $saldo) {
         return true;
     } else {
         $this->validation->set_message('chabono', "No se le puede abonar al efecto {$tipo}-{$numero} un monto mayor al saldo");
         return false;
     }
 }
Exemple #12
0
 function cambiatipo()
 {
     $id = intval($this->input->post('mid'));
     $fecha = human_to_dbdate($this->input->post('fecha'));
     $hoy = intval(date('Ymd'));
     $fc = intval(str_replace('-', '', $fecha));
     $tipo = strtoupper(trim($this->datasis->dameval("SELECT tipo FROM reparto WHERE id={$id}")));
     $oper = trim($this->input->post('oper'));
     if ($oper == 'carga') {
         if ($tipo == 'P') {
             if ($fc > $hoy) {
                 echo 'No puede cargar a una fecha futura';
             } else {
                 $cana = intval($this->datasis->dameval('SELECT COUNT(*) AS cana FROM sfac WHERE reparto=' . $id));
                 if ($cana > 0) {
                     $rep = $this->datasis->dameval('SELECT GROUP_CONCAT(id) FROM sfac WHERE reparto=' . $id);
                     $this->db->where('id', $id);
                     $this->db->update('reparto', array('tipo' => 'C', 'carga' => $fecha, 'eliminadas' => $rep));
                     echo 'Guardada';
                     logusu('reparto', "Reparto {$id} estatus modificado {$oper}");
                 } else {
                     echo 'No puede cargar un reparto sin facturas asociadas';
                 }
             }
         } else {
             echo 'No esta Pendiente';
         }
     } elseif ($oper == 'entrega') {
         if ($tipo == 'C') {
             if ($fc > $hoy) {
                 echo 'No puede entregar a una fecha futura';
             } else {
                 $this->db->where('id', $id);
                 $this->db->update('reparto', array('tipo' => 'E', 'entregado' => $fecha));
                 echo 'Guardada';
                 logusu('reparto', "Reparto {$id} estatus modificado {$oper}");
             }
         } else {
             echo 'No esta Cargada';
         }
     } elseif ($oper == 'cierre') {
         if ($tipo == 'E') {
             if ($fc > $hoy) {
                 echo 'No puede cierre a una fecha futura';
             } else {
                 $this->db->where('id', $id);
                 $this->db->update('reparto', array('tipo' => 'F', 'retorno' => $fecha, 'tcierre' => date('Y-m-d H:i:s')));
                 $entrega = $this->datasis->dameval("SELECT entregado FROM reparto WHERE id={$id}");
                 $dbentrega = $this->db->escape($entrega);
                 $this->db->query("UPDATE sfac SET entregado={$dbentrega} WHERE reparto={$id} AND COALESCE(repcob,'') NOT IN ('EF','MI','CH','FP')");
                 echo 'Guardada';
                 logusu('reparto', "Reparto {$id} estatus modificado {$oper}");
             }
         } else {
             echo 'No esta Entregada';
         }
     } elseif ($oper == 'anular') {
         if ($tipo != 'F') {
             $razon = $this->input->post('razon');
             $mSQL = "SELECT COUNT(*) AS cana FROM sfac WHERE reparto={$id} AND repcob IN ('EF','MI','CH','FP')";
             $cana = intval($this->datasis->dameval($mSQL));
             if ($cana == 0) {
                 $upd = array('tipo' => 'A');
                 if ($razon !== false) {
                     $upd['razon'] = $razon;
                 }
                 $this->db->where('id', $id);
                 $this->db->update('reparto', $upd);
                 $this->db->query("UPDATE sfac SET entregado=0, reparto=0 WHERE reparto={$id}");
                 echo 'Reparto Anulado';
                 logusu('reparto', "Reparto {$id} anulado");
             } else {
                 echo 'No se puede anular el reparto por tener efectos cobrados';
             }
         } else {
             echo 'Reparto ya fue cerrado o finalizado, no se puede anular';
         }
     } elseif ($oper == 'finalizar') {
         if ($tipo == 'F') {
             $this->db->where('id', $id);
             $this->db->update('reparto', array('tipo' => 'I'));
             echo 'Reparto Finalizado';
             logusu('reparto', "Reparto {$id} estatus modificado {$oper}");
         } else {
             echo 'Reparto no se puede finalizar';
         }
     } else {
         echo 'Operacion invalidad ' . $oper;
     }
 }
Exemple #13
0
 function chexiste($codigo)
 {
     $codigo = $this->input->post('codigo');
     $fecha = human_to_dbdate($this->input->post('fecha'));
     $hora = $this->input->post('hora');
     $chek = $this->datasis->dameval("SELECT COUNT(*) FROM cacc WHERE codigo='{$codigo}' AND fecha='{$fecha}' AND hora='{$hora}'");
     if ($chek > 0) {
         $nombre = $this->datasis->dameval("SELECT cedula FROM cacc WHERE codigo='{$codigo}' AND fecha='{$fecha}' AND hora='{$hora}'");
         $this->validation->set_message('chexiste', "Acceso para {$nombre} CODIGO {$codigo} FECHA {$fecha} HORA {$hora} ya existe");
         return FALSE;
     } else {
         return TRUE;
     }
 }
Exemple #14
0
 function vista()
 {
     $this->rapyd->load("datagrid2");
     $f1 = $this->input->post('fechad');
     $f2 = $this->input->post('fechah');
     $fechad = $this->db->escape(human_to_dbdate($f1));
     $fechah = $this->db->escape(human_to_dbdate($f2));
     $codigoadm = '';
     $fondo = '';
     $codigoadm2 = $this->db->escape($this->input->post('codigoadm'));
     $fondo2 = $this->db->escape($this->input->post('fondo'));
     function blanco($codigo)
     {
         if ($codigo > 0) {
             $codigo = str_pad($codigo, 8, '0', STR_PAD_LEFT);
         }
         return $codigo;
     }
     function union($fecha, $codigo)
     {
         return date('Ym', strtotime($fecha)) . str_pad($codigo, 8, '0', STR_PAD_LEFT);
     }
     $uri = anchor($this->url . 'dataedit/show/<#numero#>', '<str_pad><#numero#>|8|0|STR_PAD_LEFT</str_pad>');
     $query = "SELECT COUNT(*) FROM (";
     $query .= "\n\t\t\tSELECT a.numero,d.numero ocompra,d.imptimbre,c.fdesem,d.factura,d.controlfac,d.fechafac,d.ftimbre,d.cod_prov,d.estadmin codigoadm,d.fondo \n\t\t\tFROM ocompra d \n\t\t\tJOIN pacom e ON d.numero = e.compra\n\t\t\tJOIN odirect a ON a.numero = e.pago\n\t\t\tJOIN pades b ON a.numero = b.pago \n\t\t\tJOIN desem c ON b.desem = c.numero \n\t\t\tJOIN sprv p ON c.cod_prov = p.proveed \n\t\t\tWHERE c.status='D2' AND d.imptimbre >0 AND fdesem>={$fechad} AND fdesem<= {$fechah} AND MID(a.status,1,1)='F' AND d.mtimbre IS NULL \n\t\t\t";
     if (!empty($codigoadm)) {
         $query .= " AND a.estadmin={$codigoadm2}";
     }
     if (!empty($fondo)) {
         $query .= " AND a.fondo={$fondo2}";
     }
     $query .= "\n\t\t\tUNION ALL\n\t\t\t\n\t\t\tSELECT a.numero,'',a.imptimbre,c.fdesem,factura,controlfac,fechafac,a.ftimbre,c.cod_prov,a.estadmin codigoadm,a.fondo \n\t\t\tFROM odirect a \n\t\t\tJOIN pades b ON a.numero = b.pago \n\t\t\tJOIN desem c ON b.desem = c.numero \n\t\t\tJOIN sprv p ON c.cod_prov = p.proveed \n\t\t\tWHERE c.status='D2' AND imptimbre >0 AND fdesem>={$fechad} AND fdesem<= {$fechah} AND MID(a.status,1,1)<>'F'  AND mtimbre IS NULL \n\t\t";
     if (!empty($codigoadm)) {
         $query .= " AND a.estadmin={$codigoadm2}";
     }
     if (!empty($fondo)) {
         $query .= " AND a.fondo={$fondo2}";
     }
     $query .= "\n\t\t)a ";
     $cant = $this->datasis->dameval($query);
     $this->db->query("DROP TABLE IF EXISTS TIMBRE");
     $query = "\n\t\tCREATE TABLE TIMBRE SELECT a.* FROM (";
     $query .= "\t\t\n\t\t\tSELECT a.numero,d.numero compra,d.imptimbre,c.fdesem,d.factura,d.controlfac,d.fechafac,d.ftimbre,d.cod_prov,d.estadmin codigoadm,d.fondo \n\t\t\tFROM ocompra d \n\t\t\tJOIN pacom e ON d.numero = e.compra\n\t\t\tJOIN odirect a ON a.numero = e.pago\n\t\t\tJOIN pades b ON a.numero = b.pago \n\t\t\tJOIN desem c ON b.desem = c.numero \n\t\t\tJOIN sprv p ON c.cod_prov = p.proveed \n\t\t\tWHERE c.status='D2' AND d.imptimbre >0 AND fdesem>={$fechad} AND fdesem<= {$fechah} AND MID(a.status,1,1)='F'  AND d.mtimbre IS NULL\n\t\t\t";
     if (!empty($codigoadm)) {
         $query .= " AND a.estadmin={$codigoadm2}";
     }
     if (!empty($fondo)) {
         $query .= " AND a.fondo={$fondo2}";
     }
     $query .= "\n\t\t\tUNION ALL\n\t\t\t\n\t\t\tSELECT a.numero,0,a.imptimbre,c.fdesem,factura,controlfac,fechafac,a.ftimbre,c.cod_prov,a.estadmin codigoadm,a.fondo \n\t\t\tFROM odirect a \n\t\t\tJOIN pades b ON a.numero = b.pago \n\t\t\tJOIN desem c ON b.desem = c.numero \n\t\t\tJOIN sprv p ON c.cod_prov = p.proveed \n\t\t\tWHERE c.status='D2' AND imptimbre >0 AND fdesem>={$fechad} AND fdesem<= {$fechah} AND MID(a.status,1,1)<>'F' AND mtimbre IS NULL\n\t\t";
     if (!empty($codigoadm)) {
         $query .= " AND a.estadmin={$codigoadm2}";
     }
     if (!empty($fondo)) {
         $query .= " AND a.fondo={$fondo2}";
     }
     $query .= "\n\t\t)a JOIN sprv b ON a.cod_prov = b.proveed ";
     $this->db->query($query);
     $grid = new DataGrid2("Lista de " . $this->titp);
     $grid->db->from("TIMBRE");
     $grid->order_by("numero", "desc");
     $grid->per_page = 1000;
     $grid->use_function('substr', 'str_pad', 'blanco', 'union');
     $grid->use_function('sta');
     $grid->column("orden de Pago", "<str_pad><#numero#>|8|0|STR_PAD_LEFT</str_pad>");
     $grid->column("O. Compra", "<blanco><#compra#>|8|0|STR_PAD_LEFT</blanco>");
     $grid->column("Emision", "<dbdate_to_human><#ftimbre#></dbdate_to_human>", "align='center'");
     $grid->column("Factura", "factura");
     $grid->column("Nro. Control", "controlfac");
     $grid->column("Fecha Fac", "<dbdate_to_human><#fechafac#></dbdate_to_human>", "align='center'");
     $grid->column("Proveedor", "nombre");
     $grid->column("RIF", "rif");
     $grid->column("Monto", "<number_format><#imptimbre#>|2|,|.</number_format>", "align='right'");
     $grid->column("Est. Admin", "codigoadm");
     $grid->column("Fondo", "fondo");
     $grid->totalizar('imptimbre');
     $grid->build();
     //echo $grid->db->last_query();
     //exit();
     $campo = "\n \t\t<input size='100' type='hidden' name='fechad' value={$f1}>\n \t\t<input size='100' type='hidden' name='fechah' value={$f2}>\n \t\t<input size='100' type='hidden' name='cant' value='{$cant}'>\n \t\t<input size='100' type='hidden' name='codigoadm' value='{$codigoadm}'>\n \t\t<input size='100' type='hidden' name='fondo' value='{$fondo}'>\n \t\t";
     $data['content'] = anchor($this->url . "nuevo", 'Ir atras') . $grid->output . form_open($this->url . 'guardar') . $campo . form_submit('mysubmit', 'Guardar') . form_close();
     $data['title'] = " {$this->titp} ";
     $data["head"] = $this->rapyd->get_head();
     $this->load->view('view_ventanas', $data);
 }
Exemple #15
0
 function getval($obj)
 {
     if (isset($this->{$obj})) {
         $name = $this->{$obj}->name;
         $requestValue = $this->ci->input->post($name);
         if ($requestValue === false && $this->_dataobject->loaded) {
             if ($this->{$obj}->pointer) {
                 $requestValue = $this->_dataobject->get_pointer($this->{$obj}->db_name);
             } else {
                 $requestValue = $this->_dataobject->get($this->{$obj}->db_name);
             }
             if (empty($requestValue)) {
                 $requestValue = false;
             }
         } else {
             if ($this->{$obj}->type == 'date') {
                 $requestValue = human_to_dbdate($requestValue, $this->{$obj}->format);
             }
         }
     } elseif ($this->_dataobject->loaded) {
         $requestValue = $this->_dataobject->get($obj);
     } else {
         return false;
     }
     return empty($requestValue) ? false : $requestValue;
 }
Exemple #16
0
 function selecciona($numero = '')
 {
     $this->rapyd->load("datagrid", "dataobject", "fields");
     $fecha = $this->input->post('fecha');
     $fondo = $this->input->post('fondo');
     $fondo2 = $this->input->post('fondo2');
     $destino = $this->input->post('destino');
     $destino2 = $this->input->post('destino2');
     $usuario = $this->input->post('usuario');
     $fecha = human_to_dbdate($fecha);
     if (!empty($numero)) {
         $numeroe = $this->db->escape($numero);
         $row = $this->datasis->damerow("SELECT fecha,destino,fondo FROM  relch WHERE id={$numero}");
         $fecha = $row['fecha'];
         $fondo = $row['fondo'];
         //$destino = $row['destino'];
     }
     function asigna($id, $value = "A")
     {
         $campo = new dropdownField("Title", "gt[{$id}]");
         $campo->status = "modify";
         $campo->option("A", "Agregar");
         $campo->option("P", "Pendiente");
         $campo->value = $value;
         $campo->style = "width:100px";
         $campo->build();
         return $campo->output;
     }
     $tabla = form_open("tesoreria/relch/carga/{$numero}");
     $ddata = array('fecha' => $fecha, 'usuario' => $usuario, 'destino' => $destino, 'destino2' => $destino2, 'fondo2' => $fondo2, 'fondo' => $fondo);
     $grid = new DataGrid("Lista de Cheque por Relacionar");
     $grid->db->select(array("a.id", "a.cheque", "b.banco", "a.fecha", "IF(a.tipo_doc='CH','Cheque',IF(a.tipo_doc='ND','Nota de Debito',a.tipo_doc)) tipo_doc", "a.benefi", "a.monto"));
     $grid->db->from('mbanc a');
     $grid->db->join('banc b', 'a.codbanc=b.codbanc');
     if (empty($numero)) {
         $grid->db->where("relch IS NULL");
     } else {
         $grid->db->where("(relch IS NULL OR relch={$numeroe})");
     }
     $grid->db->where("status in ('E2','J2','A2','NC')");
     $grid->db->where("tipo_doc in ('NC','CH','ND')");
     $grid->db->where("tipo_doc in ('NC','CH','ND')");
     $grid->db->where("fecha ", $fecha);
     if ($destino == 'C' || $destino == 'I') {
         $grid->db->where("destino ", $destino);
     }
     if (!empty($fondo)) {
         $grid->db->where("fondo ", $fondo);
     }
     if (!empty($usuario)) {
         $grid->db->where("usuario ", $usuario);
     }
     $grid->use_function('asigna');
     $grid->column("Banco", "banco", 'align=left');
     $grid->column("Tipo Documento", "tipo_doc", 'align=left');
     $grid->column("Documento", "cheque", 'align=left');
     $grid->column("Fecha", "fecha", 'align=left');
     $grid->column("A nombre de", "benefi", 'align=left');
     $grid->column("Monto", "<nformat><#monto#>|2|,|.</nformat>", "align='right'");
     $grid->column("Accio&oacute;n", "<asigna><#id#></asigna>", "align='right'");
     $grid->build();
     $tabla .= $salida = anchor("tesoreria/relch/busca/{$numero}", 'Regresar');
     $tabla .= $grid->output . form_submit('mysubmit', 'Guardar') . form_hidden($ddata);
     $tabla .= form_close();
     if ($grid->recordCount == 0) {
         $tabla = "<p>No hay cheques por relacionar</p>";
         $tabla .= $salida = anchor("tesoreria/relch/busca/{$numero}", 'Regresar');
     }
     $data['content'] = $tabla;
     $data['title'] = " Creacion de Relacion de Ordenes Pagadas ";
     $data["head"] = $this->rapyd->get_head();
     $this->load->view('view_ventanas', $data);
 }
Exemple #17
0
 function arreglanfiscaldev()
 {
     $cajero = $this->input->post('cajero');
     $fecha = $this->input->post('fecha');
     $numero = $this->input->post('numero');
     $nulos = $this->input->post('nulos');
     $usr = $this->input->post('usuario');
     if ($cajero === false || $fecha === false || $numero === false || $usr === false) {
         echo 'Error en los parametros';
         return false;
     }
     $noresp = $this->input->post('noresp');
     $cajero = $this->db->escape(trim($cajero));
     $fecha = $this->db->escape(human_to_dbdate($fecha));
     $dbusr = $this->db->escape($usr);
     $numero = trim($numero);
     $nnumero = ltrim($numero, '0');
     $wwhere = "`fecha` = {$fecha} AND `cajero` = {$cajero} AND `tipo_doc`= 'D'";
     if (!empty($usr)) {
         $wwhere .= " AND `usuario`={$dbusr} ";
     }
     if (strtolower($nulos) == 's') {
         $wwhere .= ' AND maqfiscal IS NOT NULL';
     }
     $mSQL = "SELECT TRIM(nfiscal) AS nfiscal,tipo_doc,numero FROM (`sfac`) WHERE {$wwhere} ORDER BY `numero`";
     $query = $this->db->query($mSQL);
     if ($query->num_rows() > 0) {
         $c = false;
         foreach ($query->result() as $row) {
             if ($numero == $row->nfiscal) {
                 $c = true;
                 continue;
             }
             if ($c) {
                 $nnumero++;
                 if (empty($row->nfiscal) || $noresp) {
                     $nnnumero = str_pad($nnumero, 8, '0', STR_PAD_LEFT);
                     $data = array('nfiscal' => $nnnumero);
                     $where = 'tipo_doc = ' . $this->db->escape($row->tipo_doc) . ' AND numero=' . $this->db->escape($row->numero);
                     $str = $this->db->update_string('sfac', $data, $where);
                     //echo $str."\n";
                     $this->db->simple_query($str);
                 }
             }
         }
     }
     $c = false;
     $nnumero = ltrim($numero, '0');
     $mSQL = "SELECT TRIM(nfiscal) AS nfiscal,tipo_doc,numero FROM (`sfac`) WHERE {$wwhere} ORDER BY `numero` DESC";
     $query = $this->db->query($mSQL);
     if ($query->num_rows() > 0) {
         $c = false;
         foreach ($query->result() as $row) {
             if ($numero == $row->nfiscal) {
                 $c = true;
                 continue;
             }
             if ($c) {
                 $nnumero--;
                 if (empty($row->nfiscal) || $noresp) {
                     $nnnumero = str_pad($nnumero, 8, '0', STR_PAD_LEFT);
                     $data = array('nfiscal' => $nnnumero);
                     $where = 'tipo_doc = ' . $this->db->escape($row->tipo_doc) . ' AND numero=' . $this->db->escape($row->numero);
                     $str = $this->db->update_string('sfac', $data, $where);
                     //echo $str."\n";
                     $this->db->simple_query($str);
                 }
             }
         }
     }
     echo 'Cambio realizado';
 }
Exemple #18
0
 function ajaxmonto()
 {
     $fecha = $this->input->post('fecha');
     if ($fecha !== false) {
         $fecha = human_to_dbdate($fecha);
         $monto = $this->_montoautotranf($this->cajas['cobranzas'], $fecha);
     } else {
         $monto = 0;
     }
     echo $monto;
 }
Exemple #19
0
    function creaprod()
    {
        $mdesde = $this->input->post('desde');
        $mhasta = $this->input->post('hasta');
        $fecha = $mhasta;
        $mdesde = substr(human_to_dbdate($mdesde), 0, 10);
        $mhasta = substr(human_to_dbdate($mhasta), 0, 10);
        $dbmdesde = $this->db->escape($mdesde);
        $dbmhasta = $this->db->escape($mhasta);
        $this->_url = $this->url . 'dataedit/insert';
        $_POST = array('btn_submit' => 'Guardar', 'fecha' => $fecha, 'envia' => 'PROD', 'recibe' => '0001', 'observ1' => "PRODUCCION  " . $mdesde . ' AL ' . $mhasta);
        $mSQL = 'SELECT a.codigoa, b.descrip, sum(a.cana*IF(a.tipoa="F",1,-1)) cana, b.existen
		FROM sitems AS a
		JOIN sinv AS b ON b.codigo=a.codigoa
		AND a.fecha >= ' . $dbmdesde . '
		AND a.fecha <= ' . $dbmhasta . ' AND tipoa <> "X" AND mid(b.tipo,1,1) <> "S"
		GROUP BY a.codigoa
		HAVING cana > 0 AND b.existen < 0';
        //echo inputDateFromTimestamp(mktime(0,0,0));
        $qquery = $this->db->query($mSQL);
        $i = 0;
        foreach ($qquery->result() as $itrow) {
            $_POST["codigo_{$i}"] = rtrim($itrow->codigoa);
            $_POST["descrip_{$i}"] = rtrim($itrow->descrip);
            $_POST["cantidad_{$i}"] = $itrow->cana;
            $i++;
        }
        $this->dataedit();
    }
Exemple #20
0
 function itfac2($data, $numero, $retorna)
 {
     //print_r($data);
     //		exit();
     $this->rapyd->load("dataobject");
     $do = new DataObject("ocompra");
     $do->rel_one_to_many('itfac', 'itfac', array('numero' => 'nocompra'));
     $do->load($numero);
     $reteiva_prov = $do->get('reteiva_prov');
     $creten = $do->get('creten');
     $total2 = $do->get('total2');
     $ivag = $do->get('ivag');
     $ivar = $do->get('ivar');
     $ivaa = $do->get('ivaa');
     $i = $ttotal2 = $ttemp = 0;
     $error = '';
     $ivaplica = $this->datasis->ivaplica();
     foreach ($data as $row) {
         $temp = array();
         foreach ($row as $cols) {
             $temp[] = $cols;
         }
         if (strlen($temp[3]) > 0) {
             $do->set_rel('itfac', 'nocompra', $numero, $i);
             $do->set_rel('itfac', 'factura', $temp[3], $i);
             $do->set_rel('itfac', 'controlfac', $temp[4], $i);
             $do->set_rel('itfac', 'fechafac', human_to_dbdate($temp[2]), $i);
             $temp[11] = 1 * $temp[11];
             $do->set_rel('itfac', 'exento', 0, $i);
             $do->set_rel('itfac', 'ivar', 0, $i);
             $do->set_rel('itfac', 'ivaa', 0, $i);
             $do->set_rel('itfac', 'ivag', 0, $i);
             $do->set_rel('itfac', 'uivar', 'N', $i);
             $do->set_rel('itfac', 'uivaa', 'N', $i);
             $do->set_rel('itfac', 'uivag', 'N', $i);
             $do->set_rel('itfac', 'ureten', 'N', $i);
             $do->set_rel('itfac', 'uimptimbre', 'N', $i);
             $ttemp = $temp[11] + round($ttemp, 2);
             $temp[9] = str_replace(',', '', $temp[9]);
             $temp[11] = str_replace(',', '', $temp[11]);
             switch (1 * $temp[10] * 100) {
                 case $ivaplica['redutasa']:
                     $do->set_rel('itfac', 'ivar', 1 * $temp[11], $i);
                     $do->set_rel('itfac', 'uivar', 'S', $i);
                     break;
                 case $ivaplica['tasa']:
                     $do->set_rel('itfac', 'ivag', 1 * $temp[11], $i);
                     $do->set_rel('itfac', 'uivag', 'S', $i);
                     break;
                 case $ivaplica['sobretasa']:
                     $do->set_rel('itfac', 'ivaa', 1 * $temp[11], $i);
                     $do->set_rel('itfac', 'uivag', 'S', $i);
                     break;
             }
             $reteiva = 1 * $temp[11] * $reteiva_prov / 100;
             $total2_t = 1 * $temp[9] + 1 * $temp[11];
             $ttotal2 = $total2_t + round($ttotal2, 2);
             $do->set_rel('itfac', 'reteiva', $reteiva, $i);
             $do->set_rel('itfac', 'subtotal', 1 * $temp[9], $i);
             $do->set_rel('itfac', 'total2', $total2_t, $i);
             $rete = $this->datasis->damerow("SELECT base1,tari1,pama1 FROM rete WHERE codigo='{$creten}'");
             if (substr($creten, 0, 1) == '1') {
                 $reten = round($temp[9] * $rete['base1'] * $rete['tari1'] / 10000, 2);
             } else {
                 $reten = round(($temp[9] - $rete['pama1']) * $rete['base1'] * $rete['tari1'] / 10000, 2);
             }
             if ($reten < 0) {
                 $reten = 0;
             }
             $do->set_rel('itfac', 'reten', $reten, $i);
             $do->set_rel('itfac', 'ureten', 'S', $i);
             $do->set_rel('itfac', 'total', $total2_t - $reten - $reteiva, $i);
             $i++;
         }
     }
     //exit("ttotal2:".$ttemp);
     //if(abs($ttotal2-$total2)>=0.4)
     //$error.="El monto total cargado ($ttotal2) es diferente al Comprometido ($total2) ";
     //if(((round((round($s,2) -round($subtotal,2)),2) > 0.02))|| (round(round($subtotal,2)-(round($s ,2)),2) > 0.02) )$error.="<div class='alert'><p>La Suma de los Subtotales ($subtotal) de las facturas es diferente al subtotal ($s) de la orden de pago</p></div>";
     if (empty($error)) {
         $do->save();
         redirect("presupuesto/{$retorna}/dataedit/modify/{$numero}");
     } else {
         //logusu('ocompra',"Comprometio Orden de Compra Nro $id. con ERROR:$error ");
         $data['content'] = "<div class='alert'>" . $error . "</div>" . anchor("presupuesto/{$retorna}/load/{$numero}", 'Regresar');
         $data['title'] = " Error al cargar archivo de facturas ";
         $data["head"] = $this->rapyd->get_head() . script('jquery.js') . script("plugins/jquery.numeric.pack.js");
         $this->load->view('view_ventanas', $data);
     }
 }
Exemple #21
0
 function guardar()
 {
     $this->rapyd->load('dataobject');
     $fechad = $this->input->post('fechad');
     $fechah = $this->input->post('fechah');
     $fechad2 = $this->db->escape(human_to_dbdate($fechad));
     $fechah2 = $this->db->escape(human_to_dbdate($fechah));
     $cant = $this->input->post('cant');
     $codigoadm = $this->input->post('codigoadm');
     $fondo = $this->input->post('fondo');
     $do = new DataObject("mbanc");
     $error = '';
     $query = "SELECT numero,impmunicipal FROM MUNICIPAL";
     $retenciones = $this->db->query($query);
     $cant2 = $retenciones->num_rows();
     $pagos = $compras = array();
     $reten = 0;
     foreach ($retenciones->result() as $row) {
         $reten += $row->impmunicipal;
         if ('' > 0) {
             $compras[] = '';
         } else {
             $pagos[] = $row->numero;
         }
     }
     if ($cant != $cant2) {
         $error .= "<div class='alert'>Los montos Previsualizados y los actuales no parecen ser iguales</div>";
     }
     if (empty($error)) {
         if ($reten > 0) {
             $do->set("monto", $reten);
             $do->set("status", "J");
             $do->set("tipo", "M");
             $do->set("tipo_doc", "ND");
             $do->set("observa", ".Se cancelo el Impuesto Municipal desde {$fechad} hasta {$fechah} actividad {$codigoadm} fondo {$fondo}");
             $do->set('rel', implode(',', $pagos) . '|' . implode(',', $compras));
             $do->save();
             $id = $do->get('id');
             if (!$id > 0) {
                 $error .= "Ocurrio error al momento de Crear el movimiento bancario";
             }
             if (empty($error)) {
                 $query = "UPDATE odirect a \r\n\t\t\t\t\tJOIN pades b ON a.numero = b.pago\r\n\t\t\t\t\tJOIN desem c ON b.desem = c.numero\r\n\t\t\t\t\tSET a.mmuni={$id}\r\n\t\t\t\t\tWHERE c.status='D2' AND impmunicipal >0 AND fdesem>={$fechad2} AND fdesem<= {$fechah2} AND MID(a.status,1,1)<>'F' AND (a.mmuni IS NULL)";
                 if (!empty($codigoadm)) {
                     $query .= " AND a.estadmin='{$codigoadm}'";
                 }
                 if (!empty($fondo)) {
                     $query .= " AND a.fondo='{$fondo}'";
                 }
                 $bool = $this->db->simple_query($query);
                 if (!$bool) {
                     $error .= "Ocurrio error al momento de actualizar la tabla pagos";
                 }
             }
         } else {
             $error .= "<div class='alert'><p>No hay IMPUESTO MUNICIPAL por pagar desde {$fechad} hasta {$fechah} </p></div>";
         }
     }
     if (empty($error)) {
         logusu('MUNICIPAL', "Creo movimiento bancario de Pago de IMPUESTO MUNICIPAL {$id}");
         redirect("tesoreria/mbanc/dataedit/modify/" . $id);
     } else {
         logusu('MUNICIPAL', "intento crear movimiento bancario de Pago de IMPUESTO MUNICIPAL  con error {$error}");
         $data['content'] = $error . anchor($this->url . "nuevo", 'Regresar');
         $data['title'] = " " . $this->t**s . " ";
         $data["head"] = $this->rapyd->get_head();
         $this->load->view('view_ventanas', $data);
     }
 }
Exemple #22
0
 function fpositiva($valor)
 {
     $codigo = $this->input->post('codigo');
     $dbcodigo = $this->db->escape($codigo);
     $maxfecha = intval(str_replace('-', '', $this->datasis->dameval("SELECT MAX(fecha) FROM nomina WHERE codigo={$dbcodigo}")));
     $valor = intval(str_replace('-', '', substr(human_to_dbdate($valor), 0, 10)));
     if ($maxfecha >= $valor) {
         $this->validation->set_message('fpositiva', "No puede aumentarle el sueldo con una fecha posterior a una nomina ya pagada");
         return false;
     }
     return true;
 }