Example #1
0
 function sfac_add()
 {
     parent::Controller();
     $this->load->library('rapyd');
     $this->datasis->modulo_id('103', 1);
     $this->genesal = true;
     $this->back_url = 'ventas/pfaclitemayor/filteredgrid';
 }
Example #2
0
 function venta()
 {
     parent::Controller();
     $this->back_dataedit = 'compras/scst/datafilter';
     $this->load->library('rapyd');
     $this->vnega = trim(strtoupper($this->datasis->traevalor('VENTANEGATIVA')));
     //$this->datasis->modulo_id(216,1);
 }
Example #3
0
 function lote($status = null, $grupo, $upago, $tarifa)
 {
     $this->load->helper('download');
     $this->genesal = false;
     $this->back_url = $this->url . 'filteredgrid';
     $dbgrupo = $this->db->escape($grupo);
     $dbupago = $this->db->escape($upago);
     $dbtarifa = $this->db->escape($tarifa);
     $data = '';
     if ($status == 'insert') {
         $codigo = $this->datasis->traevalor('SINVTARIFA');
         $iva = $this->datasis->dameval("SELECT iva FROM sinv WHERE codigo=" . $this->db->escape($codigo));
         $descrip = $this->datasis->dameval("SELECT descrip FROM sinv WHERE codigo=" . $this->db->escape($codigo));
         $ut = $this->datasis->dameval("SELECT valor FROM utributa ORDER BY fecha DESC LIMIT 1");
         $cana = 1;
         $mSQL = "SELECT TRIM(a.nombre) AS nombre, TRIM(a.rifci) AS rifci, a.cliente, a.tipo , a.dire11 AS direc, round(b.minimo*{$ut},2) precio1, a.upago, a.telefono, b.id codigo\n\t\t\t\tFROM scli AS a\n\t\t\t\tJOIN tarifa AS b ON a.tarifa=b.id\n\t\t\t\tWHERE a.grupo={$dbgrupo} AND a.upago={$dbupago} AND a.tarifa={$dbtarifa}\n\t\t\t\tORDER BY rifci";
         $query = $this->db->query($mSQL);
         foreach ($query->result() as $row) {
             $dbcliente = $this->db->escape($row->cliente);
             $sql = "SELECT SUM(monto*(tipo_doc IN ('FC','GI','ND'))) AS debe, SUM(monto*(tipo_doc IN ('NC','AB','AN'))) AS haber FROM smov WHERE cod_cli={$dbcliente}";
             $qquery = $this->db->query($sql);
             if ($qquery->num_rows() > 0) {
                 $rrow = $qquery->row();
                 $saldo = $rrow->debe - $rrow->haber;
             } else {
                 $saldo = 0;
             }
             $saldo += $row->precio1 * (1 + $iva / 100);
             $sql = "UPDATE scli SET credito='S',tolera=10,maxtole=10,limite={$saldo},formap=30 WHERE cliente={$dbcliente}";
             $this->db->simple_query($sql);
             $desde = dbdate_to_human($row->upago . '01', 'm/Y');
             $_POST['pfac'] = '';
             $_POST['fecha'] = date('d/m/Y');
             $_POST['cajero'] = $this->secu->getcajero();
             $_POST['vd'] = $this->secu->getvendedor();
             $_POST['almacen'] = $this->secu->getalmacen();
             $_POST['tipo_doc'] = 'F';
             $_POST['factura'] = '';
             $_POST['cod_cli'] = $row->cliente;
             $_POST['sclitipo'] = '1';
             $_POST['nombre'] = $row->nombre;
             $_POST['rifci'] = $row->rifci;
             $_POST['direc'] = $row->direc;
             $_POST['upago'] = $row->upago;
             $_POST['codigoa_0'] = $codigo;
             $_POST['desca_0'] = $descrip;
             $_POST['detalle_0'] = "Desde {$desde}";
             $_POST['cana_0'] = $cana;
             $_POST['preca_0'] = $row->precio1;
             $_POST['tota_0'] = $row->precio1;
             $_POST['precio1_0'] = 0;
             $_POST['precio2_0'] = 0;
             $_POST['precio3_0'] = 0;
             $_POST['precio4_0'] = 0;
             $_POST['itiva_0'] = round($iva, 2);
             $_POST['sinvpeso_0'] = 0;
             $_POST['sinvtipo_0'] = 'Servicio';
             $_POST['tipo_0'] = '';
             $_POST['sfpafecha_0'] = '';
             $_POST['num_ref_0'] = '';
             $_POST['banco_0'] = '';
             $_POST['monto_0'] = $row->precio1 * (1 + $iva / 100);
             ob_start();
             parent::dataedit();
             $rt = ob_get_contents();
             @ob_end_clean();
             $getdata = json_decode($rt, true);
             if ($getdata['status'] == 'A') {
                 $id = $getdata['pk']['id'];
                 $url = $this->_direccion = 'http://localhost/' . site_url('formatos/descargartxt/FACTSER/' . $id);
                 $data .= file_get_contents($url);
                 $data .= "<FIN>\r\n";
             }
         }
         force_download('inprin.prn', preg_replace("/[\r]*\n/", "\r\n", $data));
     }
 }