function dataeditordp($numero, $esta) { if (!isset($_POST['codigo_0'])) { //SELECT c.codigo //,COALESCE(b.cantidad*IF(tipoordp='E',-1,1),0) AS tracana //,c.cantidad //FROM stra AS a //JOIN itstra AS b ON a.numero=b.numero //RIGHT JOIN ordpitem AS c ON a.ordp=c.numero AND b.codigo=c.codigo //WHERE c.numero='00000019' } $id_ordp = $this->datasis->dameval('SELECT id FROM ordp WHERE numero=' . $this->db->escape($numero)); $this->back_dataedit = 'inventario/ordp/dataedit/show/' . $id_ordp; $this->rapyd->load('dataobject', 'datadetails'); $modbus = array('tabla' => 'sinv', 'columnas' => array('codigo' => 'Código', 'descrip' => 'Descripción', 'precio1' => 'Precio 1', 'precio2' => 'Precio 2', 'precio3' => 'Precio 3', 'existen' => 'Existencia', 'peso' => 'Peso'), 'filtro' => array('codigo' => 'Código', 'descrip' => 'Descripción'), 'retornar' => array('codigo' => 'codigo_<#i#>', 'descrip' => 'descrip_<#i#>'), 'where' => 'activo = "S" AND tipo="Articulo"', 'script' => array('post_modbus("<#i#>")'), 'p_uri' => array(4 => '<#i#>'), 'titulo' => 'Busqueda de producto en inventario'); $btn = $this->datasis->p_modbus($modbus, '<#i#>'); $script = "\n\t\tfunction post_add_itstra(id){\n\t\t\t\$('#cantidad_'+id).numeric('.');\n\t\t\treturn true;\n\t\t}"; $do = new DataObject('stra'); $do->rel_one_to_many('itstra', 'itstra', 'numero'); //$do->rel_pointer('itstra','sinv','itstra.codigo=sinv.codigo','sinv.descrip as sinvdescrip'); $edit = new DataDetails('Transferencia', $do); $edit->back_url = $this->back_dataedit; $edit->set_rel_title('itstra', 'Producto <#o#>'); $edit->script($script, 'create'); $edit->script($script, 'modify'); $edit->pre_process('insert', '_pre_ordp_insert'); $edit->pre_process('update', '_pre_update'); $edit->pre_process('delete', '_pre_delete'); $edit->post_process('insert', '_post_insert'); $edit->numero = new inputField('Número', 'numero'); $edit->numero->mode = 'autohide'; $edit->numero->size = 10; $edit->numero->apply_rules = false; //necesario cuando el campo es clave y no se pide al usuario $edit->numero->when = array('show', 'modify'); $edit->ordp = new inputField('Orden de producción', 'ordp'); $edit->ordp->mode = 'autohide'; $edit->ordp->size = 10; $edit->ordp->rule = 'required|callback_chordp'; $edit->ordp->insertValue = $numero; $edit->ordp->when = array('show', 'modify'); $edit->fecha = new dateonlyField('Fecha', 'fecha'); $edit->fecha->rule = 'required|chfecha'; $edit->fecha->insertValue = date('Y-m-d'); $edit->fecha->size = 12; $edit->esta = new dropdownField('Estación', 'esta'); $edit->esta->option('', 'Seleccionar'); $edit->esta->options('SELECT estacion,CONCAT(estacion,\'-\',nombre) AS lab FROM esta ORDER BY estacion'); $edit->esta->rule = 'required'; $edit->esta->insertValue = $esta; $edit->esta->style = 'width:150px;'; $edit->tipoordp = new dropdownField('Tipo de movimiento', 'tipoordp'); $edit->tipoordp->option('', 'Seleccionar'); $edit->tipoordp->option('E', 'Entrega'); $edit->tipoordp->option('R', 'Retiro'); $edit->tipoordp->rule = 'required|enum[E,R]'; $edit->tipoordp->style = 'width:150px;'; $edit->observ1 = new inputField('Observación', 'observ1'); $edit->observ1->rule = 'max_length[60]|trim'; $edit->observ1->size = 32; $edit->observ1->maxlength = 30; //comienza el detalle $edit->codigo = new inputField('Código <#o#>', 'codigo_<#i#>'); $edit->codigo->db_name = 'codigo'; $edit->codigo->append($btn); $edit->codigo->rule = 'trim|required|sinvexiste'; $edit->codigo->rel_id = 'itstra'; $edit->codigo->maxlength = 15; $edit->codigo->size = 15; $edit->descrip = new inputField('Descripción', 'descrip_<#i#>'); $edit->descrip->db_name = 'descrip'; $edit->descrip->type = 'inputhidden'; $edit->descrip->rel_id = 'itstra'; $edit->descrip->maxlength = 45; $edit->descrip->size = 40; $edit->cantidad = new inputField('Cantidad', 'cantidad_<#i#>'); $edit->cantidad->db_name = 'cantidad'; $edit->cantidad->css_class = 'inputnum'; $edit->cantidad->rel_id = 'itstra'; $edit->cantidad->rule = 'numeric|mayorcero|required'; $edit->cantidad->maxlength = 10; $edit->cantidad->autocomplete = false; $edit->cantidad->size = 10; //Fin del detalle $edit->estampa = new autoUpdateField('estampa', date('Ymd'), date('Ymd')); $edit->hora = new autoUpdateField('hora', date('H:i:s'), date('H:i:s')); $edit->usuario = new autoUpdateField('usuario', $this->session->userdata('usuario'), $this->session->userdata('usuario')); $accion = "javascript:buscaprod()"; $edit->button_status('btn_terminar', 'Traer insumos', $accion, 'TR', 'create'); $edit->buttons('save', 'undo', 'back', 'add_rel'); if ($this->genesal) { $edit->build(); $conten['form'] =& $edit; $data['content'] = $this->load->view('view_stra_ordp', $conten, true); $data['style'] = style('redmond/jquery-ui.css'); $data['script'] = script('jquery.js'); $data['script'] .= script('jquery-ui.js'); $data['script'] .= script("jquery-impromptu.js"); $data['script'] .= script('plugins/jquery.numeric.pack.js'); $data['script'] .= script('plugins/jquery.ui.autocomplete.autoSelectOne.js'); $data['script'] .= script('plugins/jquery.floatnumber.js'); $data['script'] .= phpscript('nformat.js'); $data['content'] = $this->load->view('view_stra_ordp', $conten, true); $data['head'] = $this->rapyd->get_head(); $data['title'] = heading('Transferencias de inventario para producción'); $this->load->view('view_ventanas', $data); } else { $edit->on_save_redirect = false; $edit->build(); if ($edit->on_success()) { $rt = 'Transferencia Guardada'; } elseif ($edit->on_error()) { $rt = html_entity_decode(preg_replace('/<[^>]*>/', '', $edit->error_string)); } return $rt; } }
function dataedit() { $this->rapyd->load('dataobject', 'datadetails'); $modbus = array('tabla' => 'sinv', 'columnas' => array('codigo' => 'Código', 'descrip' => 'Descripción', 'precio1' => 'Precio 1', 'precio2' => 'Precio 2', 'precio3' => 'Precio 3', 'existen' => 'Existencia'), 'filtro' => array('codigo' => 'Código', 'descrip' => 'Descripción'), 'retornar' => array('codigo' => 'codigoa_<#i#>', 'descrip' => 'desca_<#i#>'), 'p_uri' => array(4 => '<#i#>'), 'titulo' => 'Buscar Artículo', 'where' => '`activo` = "S"'); $btn = $this->datasis->p_modbus($modbus, '<#i#>'); $mSCLId = array('tabla' => 'scli', 'columnas' => array('cliente' => 'Código Cliente', 'nombre' => 'Nombre', 'cirepre' => 'Rif/Cedula', 'dire11' => 'Dirección', 'tipo' => 'Tipo'), 'filtro' => array('cliente' => 'Código Cliente', 'nombre' => 'Nombre'), 'retornar' => array('cliente' => 'cod_cli', 'nombre' => 'nombre', 'rifci' => 'rifci', 'dire11' => 'direc', 'tipo' => 'sclitipo'), 'titulo' => 'Buscar Cliente'); $boton = $this->datasis->modbus($mSCLId); $do = new DataObject('sfac'); $do->rel_one_to_many('sitems', 'sitems', array('id' => 'id_sfac')); $do->rel_one_to_many('sfpa', 'sfpa', array('numero', 'transac')); $do->pointer('scli', 'scli.cliente=sfac.cod_cli', 'scli.tipo AS sclitipo', 'left'); $do->rel_pointer('sitems', 'sinv', 'sitems.codigoa=sinv.codigo', 'sinv.descrip AS sinvdescrip, sinv.base1 AS sinvprecio1, sinv.base2 AS sinvprecio2, sinv.base3 AS sinvprecio3, sinv.base4 AS sinvprecio4, sinv.iva AS sinviva, sinv.peso AS sinvpeso,sinv.tipo AS sinvtipo'); $edit = new DataDetails('Facturas', $do); $edit->back_url = !empty($this->back_url) ? $this->back_url : site_url('ventas/sfac/index'); $edit->set_rel_title('sitems', 'Producto <#o#>'); $edit->set_rel_title('sfpa', 'Forma de pago <#o#>'); $edit->pre_process('insert', '_pre_insert'); $edit->pre_process('update', '_pre_update'); $edit->pre_process('delete', '_pre_delete'); $edit->post_process('insert', '_post_insert'); $edit->post_process('update', '_post_update'); $edit->post_process('delete', '_post_delete'); $edit->sclitipo = new hiddenField('', 'sclitipo'); $edit->sclitipo->db_name = 'sclitipo'; $edit->sclitipo->pointer = true; $edit->sclitipo->insertValue = 1; $edit->fecha = new DateonlyField('Fecha', 'fecha', 'd/m/Y'); $edit->fecha->insertValue = date('Y-m-d'); $edit->fecha->rule = 'required'; $edit->fecha->mode = 'autohide'; $edit->fecha->size = 10; $edit->tipo_doc = new dropdownField('Documento', 'tipo_doc'); $edit->tipo_doc->option('F', 'Factura'); $edit->tipo_doc->option('D', 'Devolución'); $edit->tipo_doc->style = 'width:120px;'; $edit->tipo_doc->size = 5; $edit->tipo_doc->rule = 'required'; $edit->vd = new dropdownField('Vendedor', 'vd'); $edit->vd->options('SELECT vendedor, CONCAT(vendedor,\' \',nombre) nombre FROM vend ORDER BY vendedor'); $edit->vd->style = 'width:120px;'; $edit->vd->insertValue = $this->secu->getvendedor(); $edit->almacen = new dropdownField('Almacén', 'almacen'); $edit->almacen->options('SELECT ubica,ubides FROM caub WHERE gasto="N" ORDER BY ubides'); $edit->almacen->rule = 'required'; $alma = $this->secu->getalmacen(); if (strlen($alma) <= 0) { $alma = $this->datasis->traevalor('ALMACEN'); } $edit->almacen->insertValue = $alma; $edit->almacen->style = 'width:120px;'; $edit->numero = new inputField('Número', 'numero'); $edit->numero->size = 10; $edit->numero->mode = 'autohide'; $edit->numero->maxlength = 8; $edit->numero->apply_rules = false; //necesario cuando el campo es clave y no se pide al usuario $edit->numero->when = array('show', 'modify'); $edit->factura = new inputField('Factura', 'factura'); $edit->factura->size = 10; $edit->factura->mode = 'autohide'; $edit->factura->maxlength = 8; $edit->factura->rule = 'condi_required|callback_chfactura'; $edit->peso = new inputField('Peso', 'peso'); $edit->peso->css_class = 'inputnum'; $edit->peso->readonly = true; $edit->peso->size = 10; $edit->cliente = new inputField('Cliente', 'cod_cli'); $edit->cliente->size = 6; $edit->cliente->autocomplete = false; $edit->cliente->rule = 'required|existescli'; //$edit->cliente->append($boton); $edit->nombre = new hiddenField('Nombre', 'nombre'); $edit->nombre->size = 25; $edit->nombre->maxlength = 40; $edit->nombre->readonly = true; $edit->nombre->autocomplete = false; $edit->nombre->rule = 'required'; $edit->upago = new hiddenField('Ultimo pago de servicio', 'upago'); $edit->upago->readonly = true; $edit->upago->autocomplete = false; $edit->rifci = new hiddenField('RIF/CI', 'rifci'); $edit->rifci->autocomplete = false; $edit->rifci->readonly = true; $edit->rifci->size = 15; $edit->direc = new hiddenField('Dirección', 'direc'); $edit->direc->readonly = true; $edit->direc->size = 40; $edit->cajero = new dropdownField('Cajero', 'cajero'); $edit->cajero->options('SELECT cajero,nombre FROM scaj ORDER BY nombre'); $edit->cajero->rule = 'required|cajerostatus'; $edit->cajero->style = 'width:120px;'; $edit->cajero->insertValue = $this->secu->getcajero(); $edit->descuento = new hiddenField('Desc.', 'descuento'); $edit->descuento->insertValue = '0'; //*********************************** // Campos para el detalle 1 sitems //*********************************** $edit->codigoa = new inputField('Código <#o#>', 'codigoa_<#i#>'); $edit->codigoa->size = 12; $edit->codigoa->db_name = 'codigoa'; $edit->codigoa->rel_id = 'sitems'; $edit->codigoa->rule = 'required'; $edit->desca = new inputField('Descripción <#o#>', 'desca_<#i#>'); $edit->desca->size = 36; $edit->desca->db_name = 'desca'; $edit->desca->maxlength = 50; $edit->desca->readonly = true; $edit->desca->rel_id = 'sitems'; $edit->cana = new inputField('Cantidad <#o#>', 'cana_<#i#>'); $edit->cana->db_name = 'cana'; $edit->cana->css_class = 'inputnum'; $edit->cana->rel_id = 'sitems'; $edit->cana->maxlength = 10; $edit->cana->size = 6; $edit->cana->rule = 'required|positive|callback_chcanadev[<#i#>]'; $edit->cana->autocomplete = false; $edit->cana->onkeyup = 'importe(<#i#>)'; $edit->cana->showformat = 'decimal'; $edit->cana->disable_paste = true; $edit->preca = new inputField('Precio <#o#>', 'preca_<#i#>'); $edit->preca->db_name = 'preca'; $edit->preca->css_class = 'inputnum'; $edit->preca->rel_id = 'sitems'; $edit->preca->size = 10; $edit->preca->rule = 'required|positive|callback_chpreca[<#i#>]'; $edit->preca->readonly = true; $edit->preca->showformat = 'decimal'; $edit->detalle = new hiddenField('', 'detalle_<#i#>'); $edit->detalle->db_name = 'detalle'; $edit->detalle->rel_id = 'sitems'; $edit->tota = new inputField('Importe <#o#>', 'tota_<#i#>'); $edit->tota->db_name = 'tota'; $edit->tota->type = 'inputhidden'; $edit->tota->size = 10; $edit->tota->css_class = 'inputnum'; $edit->tota->rel_id = 'sitems'; $edit->tota->showformat = 'decimal'; for ($i = 1; $i < 4; $i++) { $obj = 'precio' . $i; $edit->{$obj} = new hiddenField('Precio <#o#>', $obj . '_<#i#>'); $edit->{$obj}->db_name = 'sinv' . $obj; $edit->{$obj}->rel_id = 'sitems'; $edit->{$obj}->pointer = true; } $edit->precio4 = new hiddenField('', 'precio4_<#i#>'); $edit->precio4->db_name = 'precio4'; $edit->precio4->rel_id = 'sitems'; $edit->combo = new hiddenField('', 'combo_<#i#>'); $edit->combo->db_name = 'combo'; $edit->combo->rel_id = 'sitems'; $edit->itiva = new hiddenField('', 'itiva_<#i#>'); $edit->itiva->db_name = 'iva'; $edit->itiva->rel_id = 'sitems'; $edit->sinvpeso = new hiddenField('', 'sinvpeso_<#i#>'); $edit->sinvpeso->db_name = 'sinvpeso'; $edit->sinvpeso->rel_id = 'sitems'; $edit->sinvpeso->pointer = true; $edit->sinvtipo = new hiddenField('', 'sinvtipo_<#i#>'); $edit->sinvtipo->db_name = 'sinvtipo'; $edit->sinvtipo->rel_id = 'sitems'; $edit->sinvtipo->pointer = true; //************************************************ //fin de campos para detalle,inicio detalle2 sfpa //************************************************ $edit->tipo = new dropdownField('Tipo <#o#>', 'tipo_<#i#>'); $edit->tipo->option('', 'CREDITO'); $edit->tipo->options('SELECT tipo, nombre FROM tarjeta WHERE activo=\'S\' ORDER BY nombre'); $edit->tipo->db_name = 'tipo'; $edit->tipo->rel_id = 'sfpa'; $edit->tipo->insertValue = 'EF'; $edit->tipo->style = 'width:150px;'; $edit->tipo->onchange = 'sfpatipo(<#i#>)'; //$edit->tipo->rule = 'required'; $edit->sfpafecha = new dateonlyField('Fecha', 'sfpafecha_<#i#>'); $edit->sfpafecha->rel_id = 'sfpa'; $edit->sfpafecha->db_name = 'fecha'; $edit->sfpafecha->size = 10; $edit->sfpafecha->maxlength = 8; $edit->sfpafecha->rule = 'condi_required|callback_chtipo[<#i#>]'; $edit->numref = new inputField('Numero <#o#>', 'num_ref_<#i#>'); $edit->numref->size = 12; $edit->numref->db_name = 'num_ref'; $edit->numref->rel_id = 'sfpa'; $edit->numref->rule = 'condi_required|callback_chtipo[<#i#>]'; $edit->banco = new dropdownField('Banco <#o#>', 'banco_<#i#>'); $edit->banco->option('', 'Ninguno'); $edit->banco->options('SELECT cod_banc,nomb_banc FROM tban WHERE cod_banc<>\'CAJ\' UNION ALL SELECT codbanc,CONCAT_WS(\' \',TRIM(banco),numcuent) FROM banc WHERE tbanco <> \'CAJ\' ORDER BY nomb_banc'); $edit->banco->db_name = 'banco'; $edit->banco->rel_id = 'sfpa'; $edit->banco->style = 'width:180px;'; $edit->banco->rule = 'condi_required|callback_chtipo[<#i#>]'; $edit->monto = new inputField('Monto <#o#>', 'monto_<#i#>'); $edit->monto->db_name = 'monto'; $edit->monto->css_class = 'inputnum'; $edit->monto->rel_id = 'sfpa'; $edit->monto->size = 10; $edit->monto->rule = 'required|mayorcero'; $edit->monto->showformat = 'decimal'; //************************************************ // Fin detalle 2 (sfpa) //************************************************ $edit->ivat = new hiddenField('I.V.A', 'iva'); $edit->ivat->css_class = 'inputnum'; $edit->ivat->readonly = true; $edit->ivat->size = 10; $edit->totals = new hiddenField('Sub-Total', 'totals'); $edit->totals->css_class = 'inputnum'; $edit->totals->readonly = true; $edit->totals->size = 10; $edit->totalg = new hiddenField('Total', 'totalg'); $edit->totalg->css_class = 'inputnum'; $edit->totalg->readonly = true; $edit->totalg->size = 10; $edit->observa = new inputField('Observacion', 'observa'); $edit->nfiscal = new inputField('No.Fiscal', 'nfiscal'); $edit->observ1 = new inputField('Observacion', 'observ1'); $edit->zona = new inputField('Zona', 'zona'); $edit->ciudad = new inputField('Ciudad', 'ciudad'); $edit->exento = new inputField('Exento', 'exento'); $edit->maqfiscal = new inputField('Mq.Fiscal', 'maqfiscal'); $edit->referen = new inputField('Referencia', 'referen'); $edit->pfac = new hiddenField('Presupuesto', 'pfac'); $edit->reiva = new inputField('Retencion de IVA', 'reiva'); $edit->creiva = new inputField('Comprobante', 'creiva'); $edit->freiva = new inputField('Fecha', 'freiva'); $edit->ereiva = new inputField('Emision', 'ereiva'); $edit->manual = new hiddenField('Manual', 'manual'); $edit->manual->insertValue = 'N'; $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:i:s'), date('H:i:s')); if ($edit->_status == 'show') { $print_url = site_url('ventas/sfac_add/dataprint/modify') . $edit->pk_URI(); $action = "javascript:window.location='{$print_url}'"; $edit->button('btn_print', 'Imprimir', $action, 'TR'); } $edit->buttons('save', 'back', 'add_rel'); if (!empty($this->_url)) { $edit->_process_uri = $this->_url; } if (!empty($this->back_url)) { $edit->buttons('undo'); } if ($this->genesal) { $edit->build(); $conten['form'] =& $edit; $data['style'] = style('redmond/jquery-ui.css'); //$data['style'] .= style('gt_grid.css'); //$data['style'] .= style('impromptu.css'); $data['script'] = script('jquery.js'); $data['script'] .= script('jquery-ui.js'); $data['script'] .= script("jquery-impromptu.js"); $data['script'] .= script("plugins/jquery.blockUI.js"); $data['script'] .= script('plugins/jquery.numeric.pack.js'); $data['script'] .= script('plugins/jquery.ui.autocomplete.autoSelectOne.js'); $data['script'] .= phpscript('nformat.js'); $data['script'] .= script('plugins/jquery.floatnumber.js'); $data['script'] .= script('gt_msg_en.js'); $data['script'] .= script('gt_grid_all.js'); $data['content'] = $this->load->view('view_sfac_add', $conten, true); $data['head'] = $this->rapyd->get_head(); $data['title'] = heading($this->titp); $this->load->view('view_ventanas', $data); } else { $edit->on_save_redirect = false; $edit->build(); if ($edit->on_success()) { $this->claves = $edit->_dataobject->pk; $this->claves['numero'] = $edit->_dataobject->get('numero'); $this->claves['tipo_doc'] = $edit->_dataobject->get('tipo_doc'); $rt = 'Venta Guardada ' . $this->datasis->dameval("SELECT id FROM sfac WHERE numero=" . $edit->_dataobject->get('numero') . " AND tipo_doc='F'"); } elseif ($edit->on_error()) { $rt = html_entity_decode(preg_replace('/<[^>]*>/', '', $edit->error_string)); } return $rt; } }
function ccli($id_scli) { $id_scli = intval($id_scli); $row = $this->datasis->damerow("SELECT cliente,nombre,rifci FROM scli WHERE id={$id_scli}"); if (empty($row)) { echo 'Cliente inexistente'; return ''; } $cliente = $row['cliente']; $dbcliente = $this->db->escape($cliente); $scli_nombre = $row['nombre']; $scli_rif = $row['rifci']; $cajero = $this->secu->getcajero(); if (empty($cajero)) { echo 'El usuario debe tener registrado un cajero para poder usar este modulo'; exit; } $this->rapyd->load('dataobject', 'datadetails'); $this->rapyd->uri->keep_persistence(); $do = new DataObject('smov'); $do->rel_one_to_many('itccli', 'itccli', array('tipo_doc' => 'tipoccli', 'numero' => 'numccli', 'cod_cli' => 'cod_cli', 'transac' => 'transac')); $do->rel_one_to_many('sfpa', 'sfpa', array('transac' => 'transac', 'numero' => 'numero', 'tipo_doc' => 'tipo_doc')); $do->order_by('itccli', 'itccli.fecha'); $edit = new DataDetails('Cobro a cliente', $do); $edit->on_save_redirect = false; $edit->back_url = site_url('finanzas/ccli/filteredgrid'); $edit->set_rel_title('itccli', 'Efecto <#o#>'); $edit->set_rel_title('sfpa', 'Forma de pago <#o#>'); $edit->pre_process('insert', '_pre_ccli_insert'); $edit->pre_process('update', '_pre_ccli_update'); $edit->pre_process('delete', '_pre_ccli_delete'); $edit->post_process('insert', '_post_ccli_insert'); //$edit->post_process('delete', '_post_delete'); $edit->cod_cli = new hiddenField('Cliente', 'cod_cli'); $edit->cod_cli->rule = 'max_length[5]'; $edit->cod_cli->size = 7; $edit->cod_cli->insertValue = $cliente; $edit->cod_cli->maxlength = 5; $edit->nombre = new inputField('Nombre', 'nombre'); $edit->nombre->rule = 'max_length[40]'; $edit->nombre->size = 42; $edit->nombre->maxlength = 40; $edit->codigo = new dropdownField('Motivo', 'codigo'); $edit->codigo->option('', 'Seleccionar'); $edit->codigo->options('SELECT TRIM(codigo) AS cod, nombre FROM botr WHERE tipo=\'C\' ORDER BY nombre'); $edit->codigo->style = 'width:200px;'; $edit->codigo->rule = ''; $edit->vendedor = new dropdownField('Cobrador', 'vd'); $edit->vendedor->option('', 'Seleccione cobrador'); $edit->vendedor->options('SELECT TRIM(vendedor) AS vendedor, CONCAT(vendedor,\' \',nombre) nombre FROM vend WHERE tipo <> "V" ORDER BY vendedor'); $edit->vendedor->style = 'width:200px;'; $edit->vendedor->insertValue = trim($this->secu->getvendedor()); $edit->vendedor->db_name = 'vendedor'; $edit->numero = new inputField('Número', 'numero'); $edit->numero->rule = 'max_length[8]'; $edit->numero->size = 10; $edit->numero->maxlength = 8; $edit->fecdoc = new dateonlyField('Fecha', 'fecdoc'); $edit->fecdoc->db_name = 'fecha'; $edit->fecdoc->size = 12; $edit->fecdoc->maxlength = 8; $edit->fecdoc->insertValue = date('Y-m-d'); $edit->fecdoc->calendar = false; $edit->fecdoc->rule = 'chfecha|chfechafut|required|callback_chcierre'; $edit->monto = new inputField('Total', 'monto'); $edit->monto->rule = 'max_length[17]|numeric'; $edit->monto->css_class = 'inputnum'; $edit->monto->size = 19; $edit->monto->maxlength = 17; $edit->monto->type = 'inputhidden'; $edit->observa1 = new textareaField('Concepto:', 'observa1'); $edit->observa1->cols = 70; $edit->observa1->rows = 2; $edit->observa1->style = 'width:100%;'; $edit->observa2 = new textareaField('', 'observa2'); $edit->observa2->cols = 70; $edit->observa2->rows = 2; $edit->observa2->style = 'width:100%;'; $edit->observa2->when = array('show'); $edit->codigo = new dropdownField('Motivo', 'codigo'); $edit->codigo->option('', 'Ninguno'); $edit->codigo->options('SELECT TRIM(codigo) AS cod, nombre FROM botr WHERE tipo=\'C\' ORDER BY nombre'); $edit->codigo->style = 'width:200px;'; $edit->codigo->rule = 'condi_required|callback_chobligatipo[NC]'; $edit->nroex = new inputField('Referencia Externa', 'nroex'); $edit->nroex->rule = 'max_length[15]'; $edit->nroex->size = 15; $edit->nroex->maxlength = 15; $edit->usuario = new autoUpdateField('usuario', $this->secu->usuario(), $this->secu->usuario()); $edit->estampa = new autoUpdateField('estampa', date('Ymd'), date('Ymd')); $edit->hora = new autoUpdateField('hora', date('H:i:s'), date('H:i:s')); //$edit->fecha = new autoUpdateField('fecha' ,date('Ymd'), date('Ymd')); //************************************************************** //inicio detalle itccli // $i = 0; $arr_ivas = array(); $edit->detail_expand_except('itccli'); $sel = array('a.tipo_doc', 'a.numero', 'a.fecha', 'a.monto', 'a.abonos', 'a.monto - a.abonos AS saldo'); $this->db->select($sel); $this->db->from('smov AS a'); $this->db->where('a.cod_cli', $cliente); $transac = $edit->get_from_dataobjetct('transac'); if ($transac !== false) { $tipo_doc = $edit->get_from_dataobjetct('tipo_doc'); $dbtransac = $this->db->escape($transac); $this->db->join('itccli AS b', 'a.tipo_doc = b.tipoccli AND a.numero=b.numccli AND a.transac=' . $dbtransac); $this->db->where('a.tipo_doc', $tipo_doc); } else { $this->db->where('a.monto > a.abonos'); $this->db->where_in('a.tipo_doc', array('FC', 'ND', 'GI')); } $this->db->order_by('a.fecha'); $query = $this->db->get(); //echo $this->db->last_query(); foreach ($query->result() as $row) { //$arr_ivas[$i]=array(''); $obj = 'cod_cli_' . $i; $edit->{$obj} = new autoUpdateField('cod_cli', $cliente, $cliente); $edit->{$obj}->rel_id = 'itccli'; $edit->{$obj}->ind = $i; $obj = 'tipo_doc_' . $i; $edit->{$obj} = new inputField('Tipo_doc', $obj); $edit->{$obj}->db_name = 'tipo_doc'; $edit->{$obj}->rel_id = 'itccli'; $edit->{$obj}->rule = 'max_length[2]'; $edit->{$obj}->insertValue = $row->tipo_doc; $edit->{$obj}->size = 4; $edit->{$obj}->maxlength = 2; $edit->{$obj}->ind = $i; $edit->{$obj}->type = 'inputhidden'; $obj = 'numero_' . $i; $edit->{$obj} = new inputField('Numero', $obj); $edit->{$obj}->db_name = 'numero'; $edit->{$obj}->rel_id = 'itccli'; $edit->{$obj}->rule = 'max_length[8]'; $edit->{$obj}->insertValue = $row->numero; $edit->{$obj}->size = 10; $edit->{$obj}->maxlength = 8; $edit->{$obj}->ind = $i; $edit->{$obj}->type = 'inputhidden'; $obj = 'fecha_' . $i; $edit->{$obj} = new dateonlyField('Fecha', $obj); $edit->{$obj}->db_name = 'fecha'; $edit->{$obj}->rel_id = 'itccli'; $edit->{$obj}->rule = 'chfecha'; $edit->{$obj}->insertValue = $row->fecha; $edit->{$obj}->size = 10; $edit->{$obj}->maxlength = 8; $edit->{$obj}->ind = $i; $edit->{$obj}->type = 'inputhidden'; $obj = 'monto_' . $i; $edit->{$obj} = new inputField('Monto', $obj); $edit->{$obj}->db_name = 'monto'; $edit->{$obj}->rel_id = 'itccli'; $edit->{$obj}->rule = 'max_length[18]|numeric'; $edit->{$obj}->css_class = 'inputnum'; $edit->{$obj}->size = 20; $edit->{$obj}->insertValue = $row->monto; $edit->{$obj}->maxlength = 18; $edit->{$obj}->ind = $i; $edit->{$obj}->showformat = 'decimal'; $edit->{$obj}->type = 'inputhidden'; $obj = 'saldo_' . $i; $edit->{$obj} = new freeField($obj, $obj, nformat($row->saldo)); $edit->{$obj}->ind = $i; $obj = 'abono_' . $i; $edit->{$obj} = new inputField('Abono', $obj); $edit->{$obj}->db_name = 'abono'; $edit->{$obj}->rel_id = 'itccli'; $edit->{$obj}->rule = "max_length[18]|numeric|positive|callback_chabono[{$i}]"; $edit->{$obj}->css_class = 'inputnum'; $edit->{$obj}->showformat = 'decimal'; $edit->{$obj}->autocomplete = false; $edit->{$obj}->disable_paste = true; $edit->{$obj}->size = 15; $edit->{$obj}->maxlength = 18; $edit->{$obj}->ind = $i; $edit->{$obj}->onfocus = 'itsaldo(this,' . round($row->saldo, 2) . ');'; $obj = 'ppago_' . $i; $edit->{$obj} = new inputField('Pronto Pago', $obj); $edit->{$obj}->db_name = 'ppago'; $edit->{$obj}->rel_id = 'itccli'; $edit->{$obj}->rule = "max_length[18]|numeric|positive|callback_chppago[{$i}]"; $edit->{$obj}->css_class = 'inputnum'; $edit->{$obj}->showformat = 'decimal'; $edit->{$obj}->autocomplete = false; $edit->{$obj}->disable_paste = true; $edit->{$obj}->size = 15; $edit->{$obj}->maxlength = 18; $edit->{$obj}->ind = $i; $edit->{$obj}->onchange = "itppago(this,'{$i}');"; $i++; } $edit->tipo_doc = new dropdownField('Tipo doc.', 'tipo_doc'); if ($i > 0) { $edit->tipo_doc->option('AB', 'Abono'); $edit->tipo_doc->option('NC', 'Nota de credito'); } else { $edit->tipo_doc->insertValue = 'AN'; } $edit->tipo_doc->option('AN', 'Anticipo'); $edit->tipo_doc->style = 'width:140px;'; $edit->tipo_doc->onchange = 'chtipodoc()'; $edit->tipo_doc->rule = 'enum[AB,NC,AN]|required'; //************************************************************** //fin de campos para detalle,inicio detalle2 sfpa // $edit->tipo = new dropdownField('Tipo <#o#>', 'tipo_<#i#>'); $edit->tipo->option('', 'Ninguno'); $edit->tipo->options('SELECT tipo, nombre FROM tarjeta WHERE activo=\'S\' ORDER BY nombre'); $edit->tipo->db_name = 'tipo'; $edit->tipo->rel_id = 'sfpa'; $edit->tipo->style = 'width:160px;'; $edit->tipo->rule = 'condi_required|callback_chsfpatipo[<#i#>]'; $edit->tipo->insertValue = 'EF'; $edit->tipo->onchange = 'sfpatipo(<#i#>)'; $edit->tipo->rule = 'callback_chbmovrep[<#i#>]'; $edit->sfpafecha = new dateonlyField('Fecha', 'sfpafecha_<#i#>'); $edit->sfpafecha->rel_id = 'sfpa'; $edit->sfpafecha->db_name = 'fecha'; $edit->sfpafecha->size = 12; $edit->sfpafecha->maxlength = 8; $edit->sfpafecha->calendar = false; $edit->sfpafecha->rule = 'condi_required|chitfecha|callback_chtipo[<#i#>]'; $edit->numref = new inputField('Numero <#o#>', 'num_ref_<#i#>'); $edit->numref->size = 15; $edit->numref->db_name = 'num_ref'; $edit->numref->rel_id = 'sfpa'; $edit->numref->rule = 'trim|condi_required|callback_chtipo[<#i#>]|callback_chnumrep[<#i#>]'; $edit->banco = new dropdownField('Banco <#o#>', 'banco_<#i#>'); $edit->banco->option('', 'Ninguno'); $edit->banco->options('SELECT cod_banc,nomb_banc FROM tban WHERE cod_banc<>\'CAJ\' UNION ALL SELECT codbanc,CONCAT_WS(\' \',TRIM(banco),numcuent) FROM banc WHERE tbanco <> \'CAJ\' ORDER BY nomb_banc'); $edit->banco->db_name = 'banco'; $edit->banco->rel_id = 'sfpa'; $edit->banco->style = 'width:200px;'; $edit->banco->rule = 'condi_required|callback_chtipo[<#i#>]'; $edit->itmonto = new inputField('Monto <#o#>', 'itmonto_<#i#>'); $edit->itmonto->db_name = 'monto'; $edit->itmonto->css_class = 'inputnum'; $edit->itmonto->rel_id = 'sfpa'; $edit->itmonto->size = 14; $edit->itmonto->rule = 'condi_required|positive|callback_chmontosfpa[<#i#>]'; $edit->itmonto->showformat = 'decimal'; $edit->itmonto->autocomplete = false; //************************************************************** // Fin detalle 2 (sfpa) // $edit->buttons('add_rel'); $edit->build(); if ($edit->on_success()) { $rt = array('status' => 'A', 'mensaje' => 'Registro guardado', 'pk' => $edit->_dataobject->pk); echo json_encode($rt); } else { if ($this->genesal) { $conten['cana'] = $i; $conten['form'] =& $edit; $conten['title'] = heading("Cobro a cliente: ({$cliente}) {$scli_nombre} {$scli_rif}"); $data['content'] = $this->load->view('view_ccli.php', $conten); } else { if ($edit->on_error()) { $rt = array('status' => 'B', 'mensaje' => preg_replace('/<[^>]*>/', '', $edit->error_string), 'pk' => null); echo json_encode($rt); } if ($edit->on_success()) { $rt = array('status' => 'A', 'mensaje' => 'Registro guardado', 'pk' => null); echo json_encode($rt); } } } }
function dataedit() { $this->rapyd->load('dataobject', 'datadetails'); $modbus = array('tabla' => 'sinv', 'columnas' => array('codigo' => 'Código', 'descrip' => 'Descripción'), 'filtro' => array('codigo' => 'Código', 'descrip' => 'Descripción'), 'retornar' => array('codigo' => 'codigo_<#i#>', 'descrip' => 'descrip_<#i#>', 'pond' => 'costo_<#i#>', 'iva' => 'iva_<#i#>', 'peso' => 'sinvpeso_<#i#>'), 'p_uri' => array(4 => '<#i#>'), 'script' => array('post_modbus_sinv(<#i#>)'), 'titulo' => 'Buscar Artículo', 'where' => 'activo = "S"'); $sprvbus = array('tabla' => 'sprv', 'columnas' => array('proveed' => 'Código Proveedor', 'nombre' => 'Nombre', 'rif' => 'RIF'), 'filtro' => array('proveed' => 'Código Proveedor', 'nombre' => 'Nombre'), 'retornar' => array('proveed' => 'proveed', 'nombre' => 'nombre'), 'script' => array('post_modbus_sprv()'), 'titulo' => 'Buscar Proveedor'); $do = new DataObject('scst'); $do->rel_one_to_many('itscst', 'itscst', 'control'); $do->rel_one_to_many('gereten', 'gereten', array('id' => 'idd')); $do->rel_one_to_many('scstordc', 'scstordc', array('control' => 'compra')); $do->pointer('sprv', 'sprv.proveed=scst.proveed', 'sprv.nombre AS sprvnombre,sprv.reteiva AS sprvreteiva', 'left'); $do->rel_pointer('itscst', 'sinv', 'itscst.codigo=sinv.codigo', 'sinv.descrip AS sinvdescrip, sinv.base1 AS sinvprecio1, sinv.base2 AS sinvprecio2, sinv.base3 AS sinvprecio3, sinv.base4 AS sinvprecio4, sinv.iva AS sinviva, sinv.peso AS sinvpeso,sinv.tipo AS sinvtipo'); $do->where_rel_one_to_many('gereten', array('gereten.origen', 'SCST')); $edit = new DataDetails('Compras', $do); $edit->set_rel_title('itscst', 'Producto <#o#>'); $edit->pre_process('insert', '_pre_insert'); $edit->pre_process('update', '_pre_update'); $edit->pre_process('delete', '_pre_delete'); $edit->post_process('insert', '_post_insert'); $edit->post_process('update', '_post_update'); $edit->post_process('delete', '_post_delete'); $edit->on_save_redirect = false; //$edit->back_url = $this->back_dataedit; $edit->fecha = new DateonlyField('Fecha', 'fecha'); $edit->fecha->insertValue = date('Y-m-d'); $edit->fecha->size = 10; $edit->fecha->rule = 'required|chfecha'; $edit->fecha->calendar = false; //$transac=$edit->get_from_dataobjetct('transac'); $edit->vence = new DateonlyField('Vence', 'vence'); $edit->vence->insertValue = date('Y-m-d'); $edit->vence->size = 10; $edit->vence->rule = 'required|chfecha'; $edit->vence->calendar = false; $edit->actuali = new DateonlyField('Actualizado', 'actuali'); //$edit->actuali->insertValue = date('Y-m-d'); $edit->actuali->when = array('show'); $edit->actuali->size = 10; $edit->actuali->mode = 'autohide'; $edit->actuali->calendar = false; $edit->recep = new DateonlyField('recibido', 'recibido'); //$edit->recep->insertValue = date('Y-m-d'); $edit->recep->size = 10; $edit->recep->mode = 'autohide'; $edit->recep->when = array('show'); $edit->recep->calendar = false; $edit->serie = new inputField('Número', 'serie'); $edit->serie->size = 15; $edit->serie->autocomplete = false; $edit->serie->rule = 'required|callback_chdupli'; $edit->serie->mode = 'autohide'; $edit->serie->maxlength = 20; $edit->fafecta = new inputField('Fact.Afectada', 'fafecta'); $edit->fafecta->size = 15; $edit->fafecta->autocomplete = false; $edit->fafecta->rule = 'condi_required|callback_chproveeddev'; $edit->fafecta->maxlength = 10; $edit->proveed = new inputField('Proveedor', 'proveed'); $edit->proveed->size = 7; $edit->proveed->autocomplete = false; $edit->proveed->rule = 'required'; $edit->proveed->append($this->datasis->modbus($sprvbus)); $edit->nombre = new hiddenField('Nombre', 'nombre'); $edit->nombre->size = 50; $edit->nombre->maxlength = 40; $edit->aplrete = new hiddenField('aplrete', 'aplrete'); $edit->sprvreteiva = new hiddenField('', 'sprvreteiva'); $edit->sprvreteiva->pointer = true; $contribu = $this->datasis->traevalor('CONTRIBUYENTE'); $rif = $this->datasis->traevalor('RIF'); if ($contribu == 'ESPECIAL' && strtoupper($rif[0]) != 'V') { $edit->sprvreteiva->insertValue = '75'; $tipo_doc = $edit->get_from_dataobjetct('tipo_doc'); if ($tipo_doc == 'NC') { $reteiva = floatval($edit->get_from_dataobjetct('reteiva')); if ($reteiva > 0) { $edit->aplrete->insertValue = '1'; } else { $edit->aplrete->insertValue = '0'; } } else { $edit->aplrete->insertValue = '1'; } } else { $edit->aplrete->insertValue = '0'; } $edit->cfis = new inputField('Nro.Fiscal', 'nfiscal'); $edit->cfis->size = 15; $edit->cfis->autocomplete = false; //$edit->cfis->rule = 'required'; $edit->cfis->maxlength = 12; $edit->almacen = new dropdownField('Almacén', 'depo'); $edit->almacen->options('SELECT ubica, CONCAT(ubica," ",ubides) nombre FROM caub WHERE gasto<>"S" AND invfis="N" ORDER BY ubica'); $edit->almacen->rule = 'required'; $edit->almacen->style = 'width:130px;'; $edit->almacen->insertValue = trim($this->datasis->traevalor('ALMACEN')); $edit->tipo = new dropdownField('Tipo', 'tipo_doc'); $edit->tipo->option('FC', 'Factura a Crédito'); $edit->tipo->option('NC', 'Nota de Crédito'); $edit->tipo->option('NE', 'Nota de Entrega'); $edit->tipo->rule = 'required'; $edit->tipo->style = 'width:130px;'; $edit->tipo->onchange = 'chtipodoc()'; $edit->peso = new hiddenField('Peso', 'peso'); $edit->peso->size = 20; $edit->peso->css_class = 'inputnum'; $edit->orden = new inputField('Orden', 'orden'); $edit->orden->when = array('show'); $edit->orden->size = 15; $edit->credito = new inputField('Crédito', 'credito'); $edit->credito->size = 12; $edit->credito->css_class = 'inputnum'; $edit->credito->when = array('show'); $edit->montotot = new inputField('Subtotal', 'montotot'); $edit->montotot->size = 12; $edit->montotot->autocomplete = false; $edit->montotot->css_class = 'inputnum'; $edit->montoiva = new inputField('IVA', 'montoiva'); $edit->montoiva->size = 12; $edit->montoiva->autocomplete = false; $edit->montoiva->css_class = 'inputnum'; $edit->montonet = new hiddenField('Total', 'montonet'); $edit->anticipo = new inputField('Anticipo', 'anticipo'); $edit->anticipo->size = 12; $edit->anticipo->css_class = 'inputnum'; $edit->anticipo->when = array('show'); $edit->inicial = new inputField('Contado', 'inicial'); $edit->inicial->size = 12; $edit->inicial->css_class = 'inputnum'; $edit->inicial->when = array('show'); $edit->rislr = new inputField('Retención ISLR', 'reten'); $edit->rislr->size = 12; $edit->rislr->css_class = 'inputnum'; $edit->rislr->when = array('show'); $edit->riva = new inputField('Retención IVA', 'reteiva'); $edit->riva->size = 11; $edit->riva->css_class = 'inputnum'; $edit->mdolar = new inputField('Monto US $', 'mdolar'); $edit->mdolar->size = 12; $edit->mdolar->css_class = 'inputnum'; $edit->mdolar->when = array('show'); $edit->observa1 = new textareaField('Observación', 'observa1'); $edit->observa1->cols = 50; $edit->observa1->rows = 2; $edit->observa2 = new textareaField('Observación', 'observa2'); $edit->observa2->when = array('show'); $edit->observa2->rows = 3; $edit->observa3 = new textareaField('Observación', 'observa3'); $edit->observa3->when = array('show'); $edit->observa3->rows = 3; //**************************** //Campos para el detalle // $edit->codigo = new inputField('Código', 'codigo_<#i#>'); $edit->codigo->size = 12; $edit->codigo->autocomplete = false; $edit->codigo->rule = 'required|callback_chcodigoa'; $edit->codigo->db_name = 'codigo'; $edit->codigo->rel_id = 'itscst'; $edit->descrip = new hiddenField('Descripción', 'descrip_<#i#>'); $edit->descrip->size = 30; $edit->descrip->db_name = 'descrip'; $edit->descrip->maxlength = 12; $edit->descrip->rel_id = 'itscst'; $edit->cantidad = new inputField('Cantidad', 'cantidad_<#i#>'); $edit->cantidad->db_name = 'cantidad'; $edit->cantidad->css_class = 'inputnum'; $edit->cantidad->rel_id = 'itscst'; $edit->cantidad->maxlength = 10; $edit->cantidad->size = 8; $edit->cantidad->autocomplete = false; $edit->cantidad->onkeyup = 'importe(<#i#>)'; $edit->cantidad->rule = 'required|positive'; $edit->cantidad->showformat = 'decimal'; $edit->costo = new inputField('Costo', 'costo_<#i#>'); $edit->costo->css_class = 'inputnum'; $edit->costo->rule = 'required|positive'; $edit->costo->onkeyup = 'importe(<#i#>)'; $edit->costo->size = 9; $edit->costo->autocomplete = false; $edit->costo->db_name = 'costo'; $edit->costo->rel_id = 'itscst'; $edit->costo->showformat = 'decimal'; $edit->importe = new inputField('Importe', 'importe_<#i#>'); $edit->importe->rule = 'numeric'; $edit->importe->db_name = 'importe'; $edit->importe->size = 12; $edit->importe->rel_id = 'itscst'; $edit->importe->autocomplete = false; $edit->importe->onkeyup = 'costo(<#i#>)'; $edit->importe->css_class = 'inputnum'; $edit->importe->showformat = 'decimal'; $edit->precio1 = new inputField('PVP', 'precio1_<#i#>'); $edit->precio1->rule = 'numeric'; $edit->precio1->db_name = 'precio1'; $edit->precio1->size = 9; $edit->precio1->rel_id = 'itscst'; $edit->precio1->autocomplete = false; $edit->precio1->css_class = 'inputnum'; $edit->precio1->showformat = 'decimal'; $edit->sinvpeso = new hiddenField('', 'sinvpeso_<#i#>'); $edit->sinvpeso->db_name = 'sinvpeso'; $edit->sinvpeso->rel_id = 'itscst'; $edit->sinvpeso->pointer = true; $edit->sinvpeso->showformat = 'decimal'; $edit->iva = new hiddenField('Impuesto', 'iva_<#i#>'); $edit->iva->db_name = 'iva'; $edit->iva->rel_id = 'itscst'; $edit->iva->showformat = 'decimal'; $edit->nentrega = new hiddenField('Nota de entrega', 'nentrega_<#i#>'); $edit->nentrega->autocomplete = false; $edit->nentrega->rule = 'callback_chnentrega[<#i#>]'; $edit->nentrega->db_name = 'nentrega'; $edit->nentrega->rel_id = 'itscst'; //fin de campos para detalle $edit->usuario = new autoUpdateField('usuario', $this->session->userdata('usuario'), $this->session->userdata('usuario')); //***************************** //Campos para el detalle reten // $edit->codigorete = new dropdownField('', 'codigorete_<#i#>'); $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->db_name = 'codigorete'; $edit->codigorete->rule = 'max_length[4]'; $edit->codigorete->style = 'width: 320px'; $edit->codigorete->rel_id = 'gereten'; $edit->codigorete->onchange = 'post_codigoreteselec(<#i#>,this.value)'; $edit->base = new inputField('base', 'base_<#i#>'); $edit->base->db_name = 'base'; $edit->base->rule = 'max_length[10]|numeric|positive'; $edit->base->css_class = 'inputnum'; $edit->base->size = 12; $edit->base->autocomplete = false; $edit->base->rel_id = 'gereten'; $edit->base->maxlength = 10; $edit->base->onkeyup = 'importerete(<#i#>)'; $edit->base->showformat = 'decimal'; $edit->porcen = new inputField('porcen', 'porcen_<#i#>'); $edit->porcen->db_name = 'porcen'; $edit->porcen->rule = 'max_length[5]|numeric|positive'; $edit->porcen->css_class = 'inputnum'; $edit->porcen->size = 7; $edit->porcen->rel_id = 'gereten'; $edit->porcen->readonly = true; $edit->porcen->maxlength = 5; $edit->porcen->showformat = 'decimal'; $edit->porcen->type = 'inputhidden'; $edit->monto = new inputField('monto', 'monto_<#i#>'); $edit->monto->db_name = 'monto'; $edit->monto->rule = 'max_length[10]|numeric|positive'; $edit->monto->css_class = 'inputnum'; $edit->monto->rel_id = 'gereten'; $edit->monto->size = 12; $edit->monto->readonly = true; $edit->monto->maxlength = 8; $edit->monto->showformat = 'decimal'; $edit->monto->type = 'inputhidden'; // //Fin de campos para detalle //***************************** //***************************** //Campos relacionados con ordc // $edit->ordc = new hiddenField('', 'ordc_<#i#>'); $edit->ordc->db_name = 'orden'; $edit->ordc->rel_id = 'scstordc'; // //Fin de campos ordc //***************************** $recep = strtotime($edit->get_from_dataobjetct('recep')); $fecha = strtotime($edit->get_from_dataobjetct('fecha')); $actuali = strtotime($edit->get_from_dataobjetct('actuali')); if ($actuali < $fecha) { $control = $this->rapyd->uri->get_edited_id(); $accion = "javascript:window.location='" . site_url('compras/scst/actualizar/' . $control) . "'"; $accio2 = "javascript:window.location='" . site_url('compras/scst/cprecios/' . $control) . "'"; $accio3 = "javascript:window.location='" . site_url('compras/scst/montoscxp/modify/' . $control) . "'"; $edit->button_status('btn_actuali', 'Actualizar', $accion, 'TR', 'show'); $edit->button_status('btn_precio', 'Asignar precios', $accio2, 'TR', 'show'); $edit->button_status('btn_cxp', 'Ajuste CxP', $accio3, 'TR', 'show'); $edit->buttons('save', 'delete', 'modify', 'exit', 'add_rel', 'add'); } else { $control = $this->rapyd->uri->get_edited_id(); $accion = "javascript:window.location='" . site_url('compras/scst/reversar/' . $control) . "'"; $edit->button_status('btn_reversar', 'Reversar', $accion, 'TR', 'show'); $edit->buttons('save', 'exit', 'add_rel'); } if ($this->genesal) { $edit->build(); $smenu['link'] = barra_menu('201'); $data['smenu'] = $this->load->view('view_sub_menu', $smenu, true); $conten['form'] =& $edit; $conten['solo'] = $this->solo; $ffecha = $edit->get_from_dataobjetct('fecha'); $conten['alicuota'] = $this->datasis->ivaplica($ffecha == false ? null : $ffecha); if ($this->solo) { $this->load->view('view_compras', $conten); } else { $data['script'] = script('jquery.js'); $data['script'] .= script('jquery-ui.js'); $data['script'] .= script('plugins/jquery.numeric.pack.js'); $data['script'] .= script('plugins/jquery.floatnumber.js'); $data['script'] .= script('plugins/jquery.ui.autocomplete.autoSelectOne.js'); $data['script'] .= phpscript('nformat.js'); $data['head'] = $this->rapyd->get_head(); $data['head'] .= style('redmond/jquery-ui-1.8.1.custom.css'); $data['content'] = $this->load->view('view_compras', $conten, true); $data['title'] = heading('Compras'); $this->load->view('view_ventanas', $data); } } else { $edit->on_save_redirect = false; $edit->build(); if ($edit->on_success()) { $this->claves = $edit->_dataobject->pk; $this->claves['control'] = $edit->_dataobject->get('control'); $rt = 'Compra Guardada'; } elseif ($edit->on_error()) { $rt = html_entity_decode(preg_replace('/<[^>]*>/', '', $edit->error_string)); } return $rt; } }
function dataedit($cliente = '', $status = '', $id = '') { $this->datasis->modulo_id(143, 1); if (!$this->_exitescli($cliente)) { redirect($this->url . 'filterscli'); } $this->db->select_sum('a.monto*IF(tipo_doc IN ("FC","ND","GI"),1,-1)', 'saldo'); $this->db->from('smov AS a'); $this->db->where('a.cod_cli', $cliente); $q = $this->db->get(); $row = $q->row_array(); $saldo = empty($row['saldo']) ? 0 : $row['saldo']; $this->rapyd->load('dataobject', 'datadetails'); $this->load->helper('form'); $vd = $this->secu->getvendedor(); $dbvd = $this->db->escape($vd); $do = new DataObject('pfac'); $do->rel_one_to_many('itpfac', 'itpfac', array('numero' => 'numa')); $do->pointer('scli', 'scli.cliente=pfac.cod_cli', 'scli.tipo AS sclitipo', 'left'); $do->rel_pointer('itpfac', 'sinv', 'itpfac.codigoa=sinv.codigo', ' sinv.iva AS sinviva, sinv.existen AS pexisten, sinv.marca AS pmarca, sinv.descrip AS pdesca, sinv.peso AS ppeso'); $do->order_by('itpfac', 'sinv.marca', ' '); $do->order_by('itpfac', 'sinv.descrip', ' '); $edit = new DataDetails('Pedidos', $do); $edit->back_url = site_url('ventas/pfaclite/filteredgrid'); $edit->set_rel_title('itpfac', 'Producto <#o#>'); $edit->pre_process('insert', '_pre_insert'); $edit->pre_process('update', '_pre_update'); $edit->pre_process('delete', '_pre_delete'); $edit->post_process('insert', '_post_insert'); $edit->post_process('update', '_post_update'); $edit->post_process('delete', '_post_delete'); $fenvia = strtotime($edit->get_from_dataobjetct('fenvia')); $faplica = strtotime($edit->get_from_dataobjetct('faplica')); $hoy = strtotime(date('Y-m-d')); $edit->fecha = new inputField('Fecha', 'fecha'); $edit->fecha->insertValue = date('Y-m-d'); $edit->fecha->mode = 'autohide'; $edit->fecha->size = 10; $edit->mmargen = new inputField('mmargen', 'mmargen'); $edit->numero = new inputField('Número', 'numero'); $edit->numero->size = 10; $edit->numero->mode = 'autohide'; $edit->numero->maxlength = 8; $edit->numero->apply_rules = false; //necesario cuando el campo es clave y no se pide al usuario $edit->numero->when = array('show', 'modify'); $edit->cliente = new hiddenField('Cliente', 'cod_cli'); $edit->cliente->insertValue = $cliente; $edit->cliente->rule = 'required'; $dbcliente = $this->db->escape($cliente); $nombre = $this->datasis->dameval("SELECT nombre FROM scli WHERE cliente={$dbcliente}"); $edit->nombre = new freeField('Nombre', 'nombre', $nombre); $edit->observa = new inputField('Observaciones', 'observa'); $edit->observa->size = 40; // Campos para el detalle $edit->codigoa = new inputField('Código <#o#>', 'codigoa_<#i#>'); $edit->codigoa->size = 12; $edit->codigoa->db_name = 'codigoa'; $edit->codigoa->rel_id = 'itpfac'; $edit->codigoa->rule = 'callback_chcodigoa'; $edit->codigoa->type = 'inputhidden'; $edit->pdesca = new inputField('Descripción <#o#>', 'pdesca_<#i#>'); $edit->pdesca->size = 32; $edit->pdesca->db_name = 'desca'; $edit->pdesca->maxlength = 50; $edit->pdesca->readonly = true; $edit->pdesca->rel_id = 'itpfac'; $edit->pdesca->type = 'inputhidden'; $edit->pdesca->pointer = true; $edit->itdesca = new hiddenField('descrip', 'itdesca_<#i#>'); $edit->itdesca->insertValue = ''; $edit->itdesca->db_name = 'desca'; $edit->itdesca->rel_id = 'itpfac'; $edit->pexisten = new inputField('Existencia <#o#>', 'pexisten_<#i#>'); $edit->pexisten->size = 10; $edit->pexisten->db_name = 'pexisten'; $edit->pexisten->rel_id = 'itpfac'; $edit->pexisten->type = 'inputhidden'; $edit->pexisten->pointer = true; $edit->cana = new inputField('Cantidad <#o#>', 'cana_<#i#>'); $edit->cana->db_name = 'cana'; $edit->cana->css_class = 'inputnum'; $edit->cana->rel_id = 'itpfac'; $edit->cana->maxlength = 10; $edit->cana->size = 4; $edit->cana->rule = 'positive|callback_chcana[<#i#>]'; $edit->cana->autocomplete = false; $edit->cana->onkeyup = 'total(\'<#i#>\')'; $edit->cana->style = "height: 30px; font-size: 18px;"; $edit->preca = new dropdownField('Precio <#o#>', 'preca_<#i#>'); $edit->preca->db_name = 'preca'; $edit->preca->css_class = 'inputnum'; $edit->preca->rel_id = 'itpfac'; $edit->preca->rule = 'positive|callback_chpreca[<#i#>]'; $edit->itiva = new hiddenField('', 'itiva_<#i#>'); $edit->itiva->db_name = 'iva'; $edit->itiva->rel_id = 'itpfac'; $edit->pmarca = new inputField('', 'pmarca_<#i#>'); $edit->pmarca->db_name = 'pmarca'; $edit->pmarca->rel_id = 'itpfac'; $edit->pmarca->pointer = true; // fin de campos para detalle $edit->totalg = new hiddenField('Monto Total', 'totalg'); $edit->totalg->css_class = 'inputnum'; $edit->totalg->readonly = true; $edit->totalg->size = 10; $edit->iva = new hiddenField('Impuesto', 'iva'); $edit->iva->css_class = 'inputnum'; $edit->iva->readonly = true; $edit->iva->size = 10; $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:i:s'), date('H:i:s')); $control = $this->rapyd->uri->get_edited_id(); if ($edit->getstatus() == 'show') { $action = "javascript:window.location='" . site_url($this->url . 'filterscli') . "'"; $edit->button('btn_add', 'Incluir nuevo pedido', $action, 'TR'); } $iusr = $edit->get_from_dataobjetct('usuario'); if ($fenvia < $hoy && $iusr == $this->secu->usuario()) { $edit->buttons('modify', 'save', 'delete', 'undo', 'back', 'add_rel'); $PFACRESERVA = $this->datasis->traevalor('PFACRESERVA', 'indica si un pedido descuenta de inventario los producto'); if ($PFACRESERVA == 'S') { $accion = "javascript:window.location='" . site_url('ventas/pfaclite/reserva/' . $control) . "/pfaclite'"; $edit->button_status('btn_envia', 'Enviar Pedido', $accion, 'TR', 'show'); } } else { $edit->buttons('save', 'undo', 'back', 'add_rel'); } //$edit->button_status('btn_load','Subir desde Excel',$accion,'TL','show'); //$edit->button_status('btn_load','Subir desde Excel',$accion,'TL','create'); //$edit->button_status('btn_load','Subir desde Excel',$accion,'TL','modify'); $alma = $this->secu->getalmacen(); $dbalma = $this->db->escape($alma); $tiposcli = $this->datasis->dameval("SELECT tipo FROM scli WHERE cliente={$dbcliente}"); if ($tiposcli < 1) { $tiposcli = 1; } elseif ($tiposcli > 4) { $tiposcli = 4; } $sel = array('TRIM(a.codigo) AS codigo', 'a.descrip', 'a.precio1', 'a.precio2', 'a.precio3', 'a.precio4', 'a.exdes', 'a.marca', 'b.existen', 'a.iva', 'a.peso'); $this->db->from('sinv AS a'); $this->db->where('a.activo', 'S'); $this->db->where('a.tipo', 'Articulo'); $this->db->group_by('a.codigo'); $this->db->order_by('a.marca , a.descrip , a.peso'); $this->db->limit($this->limit); $act_meta = false; if ($status == 'create' || $status == 'insert') { $this->db->join('itsinv AS b', 'a.codigo=b.codigo AND b.alma=' . $dbalma); $this->db->where('b.existen > 0'); if ($this->db->table_exists('metas')) { $pmargen = $this->datasis->dameval('SELECT pmargen FROM vend WHERE vendedor=' . $dbvd); if (empty($pmargen)) { $pmargen = 0; } else { $pmargen = $pmargen / 100; } $mmes = date('Ym'); $uday = days_in_month(substr($mmes, 4), substr($mmes, 0, 4)); $this->db->join('metas AS c', 'a.codigo=c.codigo AND c.fecha=' . $mmes, 'left'); $this->db->join('sitems AS d', 'd.codigoa=c.codigo AND vendedor=' . $dbvd . ' AND d.fecha BETWEEN ' . $mmes . '01 AND ' . $mmes . $uday, 'left'); $sel[] = "COALESCE(c.cantidad,0)*{$pmargen} AS meta"; $sel[] = 'COALESCE(SUM(d.cana*IF(tipoa=\'D\',-1,1)),0) AS vendido'; $act_meta = true; } } elseif ($status == 'show') { $this->db->join('itsinv AS b', 'a.codigo=b.codigo'); } else { $this->db->where('b.existen > 0'); $this->db->join('itsinv AS b', 'a.codigo=b.codigo AND b.alma=' . $dbalma); } $this->db->select($sel); $sinv = $this->db->get(); $sinv = $sinv->result_array(); $sinv_arr = array(); foreach ($sinv as $k => $v) { $sinv_arr[$v['codigo']] = array('descrip' => $v['descrip'], 'precio1' => $v['precio1'] * 100 / (100 + $v['iva']), 'precio2' => $v['precio2'] * 100 / (100 + $v['iva']), 'precio3' => $v['precio3'] * 100 / (100 + $v['iva']), 'precio4' => $v['precio4'] * 100 / (100 + $v['iva']), 'marca' => $v['marca'], 'existen' => $v['existen'], 'iva' => $v['iva'], 'peso' => $v['peso'], 'codigo' => $v['codigo'], 'exdes' => $v['exdes']); if ($act_meta) { $sinv_arr[$v['codigo']]['meta'] = $v['meta']; $sinv_arr[$v['codigo']]['vendido'] = $v['vendido']; } } $pedido = array(); if ($status == 'create' || $status == 'insert' || $status == 'modify' || $status == 'update') { $vds = array(); $mmSQL = "SELECT TRIM(vendedor) AS vd FROM usuario WHERE almacen={$dbalma}"; $qquery = $this->db->query($mmSQL); foreach ($qquery->result() as $rrow) { $vds[] = $this->db->escape($rrow->vd); } $vds = implode(',', $vds); $mmSQL = "SELECT TRIM(a.codigoa) AS codigo,SUM(a.cana) AS cana\n\t\t\t\tFROM itpfac AS a\n\t\t\t\tJOIN pfac AS b ON b.numero=a.numa\n\t\t\tWHERE b.status='P' AND b.vd IN ({$vds})\n\t\t\tGROUP BY a.codigoa"; $qquery = $this->db->query($mmSQL); foreach ($qquery->result() as $rrow) { $pedido[$rrow->codigo] = $rrow->cana; } } if ($edit->getstatus() == 'update') { $pfacnum = $edit->get_from_dataobjetct('numero'); $dbpfacnum = $this->db->escape($pfacnum); $mmSQL = "SELECT TRIM(a.codigoa) AS codigo,SUM(a.cana) AS cana\n\t\t\t\tFROM itpfac AS a\n\t\t\tWHERE a.numa={$dbpfacnum}\n\t\t\tGROUP BY a.codigoa"; $qquery = $this->db->query($mmSQL); foreach ($qquery->result() as $rrow) { $lleva[$rrow->codigo] = floatval($rrow->cana); } } else { $lleva = array(); } if ($this->genesal) { $edit->build(); $conten['lleva'] = $lleva; $conten['status'] = $status; $conten['pedido'] = $pedido; $conten['saldo'] = $saldo; $conten['act_meta'] = $act_meta; $conten['tiposcli'] = $tiposcli; $conten['form'] =& $edit; $conten['sinv'] = $sinv_arr; $data['content'] = $this->load->view('view_pfaclite', $conten, true); $data['head'] = style('mayor/estilo.css'); //$data['title'] = heading('Pedidos No. '.$edit->numero->value); $data['title'] = heading('Pedidos ligeros'); $this->load->view('view_ventanas_lite', $data); } else { $edit->on_save_redirect = false; $edit->build(); if ($edit->on_success()) { $numero = $edit->_dataobject->get('numero'); $rt = 'Pedido del cliente ' . $edit->cliente->value . ' - ' . $edit->nombre->value . ' ha sido guardado bajo el número ' . $numero . '.'; } elseif ($edit->on_error()) { $rt = html_entity_decode(preg_replace('/<[^>]*>/', '', $edit->error_string)); } else { $rt = ''; } return $rt; } }