function dataedit($action = '', $id = '') { $this->rapyd->load('datadetails', 'dataobject'); $mCONTRIBU = array('tabla' => 'contribu', 'columnas' => array('codigo' => 'Código', 'nacionali' => '', 'rifci' => 'RIF', 'nombre' => 'Nombre', 'direccion' => 'Dirección', 'telefono' => 'Telefono'), 'filtro' => array('codigo' => 'Código', 'rifci' => 'RIF', 'nacionali' => 'Nacionalidad', 'nombre' => 'Nombre', 'direccion' => 'Dirección', 'telefono' => 'Telefono'), 'retornar' => array('codigo' => 'contribu', 'nombre' => 'nombre', 'rifci' => 'rifci', 'direccion' => 'direccion', 'telefono' => 'telefono', 'nacionali' => 'nacionalit'), 'script' => array('cal_nacionali()'), 'titulo' => 'Buscar Contribuyente'); $bCONTRIBU = $this->datasis->modbus($mCONTRIBU); $mPATENTE = array('tabla' => 'v_patente_contri', 'columnas' => array('id' => 'Ref.', 'tarjeta' => 'Tarjeta', 'local' => 'Local', 'licencia' => 'Licencia', 'razon' => 'Razon', 'dir_neg' => 'Direccion Negocio'), 'filtro' => array('id' => 'Ref.', 'tarjeta' => 'Tarjeta', 'licencia' => 'Licencia', 'razon' => 'Razon', 'dir_neg' => 'Direccion Negocio'), 'retornar' => array('id' => 'patente', 'tarjeta' => 'p_tarjeta', 'licencia' => 'p_licencia', 'razon' => 'p_razon', 'dir_neg' => 'p_dir_neg', 'oficio' => 'p_oficio', 'observa' => 'p_observa', 'capital' => 'p_capital', 'catastro' => 'p_catastro', 'publicidad' => 'p_publicidad', 'DATE_FORMAT(FECHA_ES,"%d/%m/%Y")' => 'p_fecha_es', 'local' => 'p_localt', 'clase' => 'p_claset', 'negocio' => 'p_negociot', 'tipo' => 'p_tipot', 'repre' => 'p_repre', 'repreced' => 'p_repreced', 'expclasi' => 'p_expclasi', 'exphor' => 'p_exphor', 'nro' => 'p_nro', 'c_codigo' => 'contribu', 'c_nombre' => 'nombre', 'c_rifci' => 'rifci', 'c_direccion' => 'direccion', 'c_telefono' => 'telefono', 'c_nacionali' => 'nacionalit'), 'p_uri' => array(4 => '<#contri#>'), 'where' => 'IF(<#contri#> = ".....", contribu LIKE "%" ,contribu LIKE <#contri#>)', 'script' => array('cal_patente()', 'cal_nacionali()'), 'titulo' => 'Buscar Patente'); $bPATENTE = $this->datasis->p_modbus($mPATENTE, '<#contri#>'); $bPATENTE = '<img src="/tortuga/assets/default/images/system-search.png" alt="Busqueda de Patentes" title="Busqueda de Patentes" border="0" onclick="modbusdepenp()"/>'; $mINMUEBLE = array('tabla' => 'v_inmueble_contri', 'columnas' => array('id' => 'Ref.', 'ctainos' => 'CtaInos', 'direccion' => 'Direccion', 'tipo_in' => 'Tipo'), 'filtro' => array('id' => 'Ref.', 'ctainos' => 'CtaInos', 'direccion' => 'Direccion', 'tipo_in' => 'Tipo'), 'retornar' => array('id' => 'inmueble', 'ctainos' => 'i_ctainos', 'direccion' => 'i_direccion', 'tipo_in' => 'i_tipo_int', 'no_predio' => 'i_no_predio', 'sector' => 'i_sectort', 'clase' => 'i_claset', 'tipo' => 'i_tipot', 'no_predio' => 'i_monto', 'c_codigo' => 'contribu', 'c_nombre' => 'nombre', 'c_rifci' => 'rifci', 'c_direccion' => 'direccion', 'c_telefono' => 'telefono', 'c_nacionali' => 'nacionalit'), 'p_uri' => array(4 => '<#contri#>'), 'where' => 'IF(<#contri#> = ".....", contribu LIKE "%" ,contribu LIKE <#contri#>)', 'script' => array('cal_inmueble()', 'cal_nacionali()'), 'titulo' => 'Buscar Inmueble'); $bINMUEBLE = $this->datasis->p_modbus($mINMUEBLE, '<#contri#>'); $bINMUEBLE = '<img src="/tortuga/assets/default/images/system-search.png" alt="Busqueda de Inmuebles" title="Busqueda de Inmuebles" border="0" onclick="modbusdepeni()"/>'; $mVEHICULO = array('tabla' => 'v_vehiculo_contri', 'columnas' => array('id' => 'Ref.', 'placa_act' => 'Placa', 'marca' => 'Marca', 'modelo' => 'Modelo', 'color' => 'Color'), 'filtro' => array('id' => 'Ref.', 'placa_act' => 'Placa', 'marca' => 'Marca', 'modelo' => 'Modelo', 'color' => 'Color'), 'retornar' => array('id' => 'vehiculo', 'clase' => 'v_claset', 'marca' => 'v_marca', 'tipo' => 'v_tipo', 'modelo' => 'v_modelo', 'color' => 'v_color', 'capaci' => 'v_capaci', 'serial_m' => 'v_serial_m', 'placa_act' => 'v_placa_act', 'ano' => 'v_ano', 'peso' => 'v_peso', 'serial_c' => 'v_serial_c', 'codigo' => 'contribu', 'nombre' => 'nombre', 'rifci' => 'rifci', 'direccion' => 'direccion', 'telefono' => 'telefono', 'nacionali' => 'nacionalit'), 'p_uri' => array(4 => '<#contri#>'), 'where' => 'IF(<#contri#> = ".....", contribu LIKE "%" ,contribu LIKE <#contri#>)', 'script' => array('cal_vehiculo()', 'cal_nacionali()'), 'titulo' => 'Buscar Vehiculo'); $bVEHICULO = $this->datasis->p_modbus($mVEHICULO, '<#contri#>'); $bVEHICULO = '<img src="/tortuga/assets/default/images/system-search.png" alt="Busqueda de Vehiculos" title="Busqueda de Vehiculos" border="0" onclick="modbusdepenv()"/>'; $do = new DataObject("recibo"); $do->rel_one_to_many('itrecibo', 'itrecibo', array('id' => 'id_recibo')); $do->pointer('patente', 'recibo.patente=patente.id', 'patente.tarjeta AS p_tarjeta,patente.licencia AS p_licencia,patente.razon AS p_razon,patente.dir_neg AS p_dir_neg,patente.capital AS p_capital,patente.monto AS p_monto,patente.fecha_es AS p_fecha_es,patente.oficio AS p_oficio,patente.local AS p_local,patente.negocio AS p_negocio,patente.registrado AS p_registrado,patente.observa AS p_observa,patente.clase AS p_clase,patente.tipo AS p_tipo,patente.catastro AS p_catastro,patente.publicidad AS p_publicidad,patente.recibo AS p_recibo,patente.repre AS p_repre,patente.repreced AS p_repreced,patente.expclasi AS p_expclasi,patente.exphor AS p_exphor,patente.nro AS p_nro,patente.fexpedicion p_fexpedicion,patente.fvencimiento p_fvencimiento', 'LEFT'); $do->pointer('inmueble', 'recibo.inmueble=inmueble.id', 'inmueble.ctainos AS i_ctainos,inmueble.direccion AS i_direccion,inmueble.no_predio AS i_no_predio,inmueble.sector AS i_sector,inmueble.tipo_in AS i_tipo_in,inmueble.no_hab AS i_no_hab,inmueble.clase AS i_clase,inmueble.tipo AS i_tipo', 'LEFT'); $do->pointer('vehiculo', 'recibo.vehiculo=vehiculo.id', 'vehiculo.clase AS v_clase,vehiculo.marca AS v_marca,vehiculo.tipo AS v_tipo,vehiculo.modelo AS v_modelo,vehiculo.color AS v_color,vehiculo.capaci AS v_capaci,vehiculo.serial_m AS v_serial_m,vehiculo.placa_ant AS v_placa_ant,vehiculo.placa_act AS v_placa_act,vehiculo.ano AS v_ano,vehiculo.peso AS v_peso,vehiculo.serial_c AS v_serial_c,vehiculo.monto AS v_monto,vehiculo.asovehi AS v_asovehi', 'LEFT'); $edit = new DataDetails($this->t**s, $do); $edit->back_url = site_url($this->url . "filteredgrid"); $edit->pre_process('insert', '_valida'); $edit->pre_process('update', '_valida'); $edit->post_process('insert', '_post_insert'); $edit->post_process('update', '_post_update'); $edit->post_process('delete', '_post_delete'); $edit->numero = new inputField('Recibo Número', 'numero'); $edit->numero->when = array('show'); $edit->numero->type = 'inputhidden'; $edit->id = new inputField('', 'id'); $edit->id->mode = 'autohide'; $edit->id->when = array('show'); $edit->id->db_name = 'recibo.id'; $edit->id->type = 'inputhidden'; $edit->contribu = new inputField('Código', 'contribu'); $edit->contribu->rule = 'max_length[6]'; $edit->contribu->size = 8; $edit->contribu->maxlength = 6; $edit->contribu->append($bCONTRIBU); if ($this->recibomodificontribu != 'S') { $edit->contribu->readonly = true; $edit->contribu->rule = 'required|max_length[6]'; } $edit->fecha = new dateonlyField('Fecha', 'fecha'); $edit->fecha->rule = 'chfecha'; $edit->fecha->size = 10; $edit->fecha->maxlength = 8; $edit->fecha->insertValue = date('Y-m-d'); $edit->tipo = new dropdownField('Concepto', 'tipo'); $edit->tipo->options("SELECT codigo,CONCAT(codigo,'-',descrip) FROM tingresos ORDER BY grupo,descrip"); //WHERE activo='S' $edit->tipo->onchange = "cal_concepto()"; $edit->tipo->style = "width:350px;"; $edit->monto = new inputField('Monto', 'monto'); $edit->monto->rule = 'required|max_length[19]|numeric_positive'; $edit->monto->css_class = 'inputnum'; $edit->monto->size = 21; $edit->monto->maxlength = 19; $edit->monto->value = 0; $edit->declaracion = new inputField('Declaración', 'declaracion'); $edit->declaracion->rule = 'required'; $edit->declaracion->css_class = 'inputnum'; $edit->declaracion->size = 21; $edit->declaracion->maxlength = 19; $edit->declaracion->value = 0; $edit->declaracion->onchange = "cal_claseo()"; $edit->observa = new textareaField('Observación', 'observa'); $edit->observa->cols = 80; $edit->observa->rows = 1; //INICIO CONTRIBUYENTES $edit->direccion = new textareaField('Dirección', 'direccion'); $edit->direccion->cols = 40; $edit->direccion->rows = 1; $edit->nombre = new inputField('Nombre', 'nombre'); $edit->nombre->rule = 'required|max_length[200]'; $edit->nombre->size = 50; $edit->nombre->maxlength = 200; $edit->nombre->autocomplete = false; $crea = '<a href="javascript:creacontribu();" title="Agregar Contribuyente">' . image('add.png', '#', array("border" => 0)) . '</a>'; $edit->rifci = new inputField('Rif/CI', 'rifci'); $edit->rifci->rule = 'required|max_length[13]'; $edit->rifci->size = 15; $edit->rifci->maxlength = 13; $edit->rifci->append($crea); $edit->nacionali = new dropdownField('Nacionalidad', 'nacionali'); $edit->nacionali->option('V', 'VENEZOLANA'); $edit->nacionali->option('E', 'EXTRANJERA'); $edit->nacionali->style = "width:120px;"; $edit->telefono = new textareaField('Telefono', 'telefono'); $edit->telefono->rule = 'max_length[50]'; $edit->telefono->cols = 20; $edit->telefono->rows = 1; $edit->oper = new dropdownField('Tipo Solvencia', 'oper'); $edit->oper->option('', ''); $edit->oper->option('TRAMITES', 'TRAMITES o ADMINISTRATIVA'); $edit->oper->option('REGISTRO', 'REGISTRO'); $edit->oper->style = "width:250px;"; $edit->razonsocial = new dropdownField('Razon Social', 'razonsocial'); $edit->razonsocial->option('COMERCIAL', 'COMERCIAL'); $edit->razonsocial->option('DOMICILIARIO', 'DOMICILIARIO'); $edit->razonsocial->style = "width:120px;"; $edit->tasam = new inputField('Tasa Mensual', 'tasam'); $edit->tasam->rule = 'max_length[19]'; //$edit->tasam->css_class ='inputnum'; $edit->tasam->size = 21; $edit->tasam->maxlength = 19; $edit->tasam->value = 0; $edit->rif = new inputField('Rif', 'rif'); $edit->rif->rule = 'max_length[200]'; $edit->rif->size = 20; $edit->rif->maxlength = 200; $edit->nomfis = new inputField('Empresa', 'nomfis'); $edit->nomfis->rule = 'max_length[200]'; $edit->nomfis->size = 30; $edit->nomfis->maxlength = 200; $edit->efectos = new inputField('Efectos', 'efectos'); $edit->efectos->rule = 'max_length[200]'; $edit->efectos->size = 80; $edit->efectos->maxlength = 200; $edit->efectos2 = new inputField('Efectos Linea 2', 'efectos2'); $edit->efectos2->rule = 'max_length[200]'; $edit->efectos2->size = 80; $edit->efectos2->maxlength = 200; //INICIO DETALLE $edit->d_ano = new inputField('Año', 'd_ano_<#i#>'); $edit->d_ano->size = 6; $edit->d_ano->maxlength = 6; $edit->d_ano->db_name = 'ano'; $edit->d_ano->rel_id = 'itrecibo'; $edit->d_ano->style = 'width:100%'; $edit->d_ano->readonly = true; $edit->d_tipo = new inputField('Tipo', 'd_tipo_<#i#>'); $edit->d_tipo->size = 10; $edit->d_tipo->maxlength = 20; $edit->d_tipo->db_name = 'tipo'; $edit->d_tipo->rel_id = 'itrecibo'; $edit->d_tipo->style = 'width:100%'; $edit->d_tipo->readonly = true; $edit->d_nro = new inputField('Nro', 'd_nro_<#i#>'); $edit->d_nro->size = 2; $edit->d_nro->maxlength = 2; $edit->d_nro->db_name = 'nro'; $edit->d_nro->rel_id = 'itrecibo'; $edit->d_nro->style = 'width:100%'; $edit->d_nro->readonly = true; $edit->d_descrip = new inputField('Descripcion', 'd_descrip_<#i#>'); $edit->d_descrip->size = 20; $edit->d_descrip->db_name = 'descrip'; $edit->d_descrip->rel_id = 'itrecibo'; $edit->d_descrip->style = 'width:100%'; $edit->d_descrip->readonly = true; $edit->d_monto = new inputField('Monto', 'd_monto_<#i#>'); $edit->d_monto->size = 15; $edit->d_monto->maxlength = 10; $edit->d_monto->db_name = 'monto'; $edit->d_monto->rel_id = 'itrecibo'; $edit->d_monto->style = 'width:100%;text-align:right;'; $edit->d_monto->value = 0; $edit->d_monto->onchange = 'cal_total();'; //INICIO PATENTE $edit->patente = new inputField('Patente', 'patente'); $edit->patente->size = 6; $edit->patente->maxlength = 6; $edit->patente->append($bPATENTE); $edit->patente->db_name = 'patente'; $edit->p_tarjeta = new inputField('Tarjeta', 'p_tarjeta'); $edit->p_tarjeta->size = 6; $edit->p_tarjeta->maxlength = 6; //$edit->p_tarjeta->db_name ='tarjeta'; //$edit->p_tarjeta->rel_id ='patente'; $edit->p_tarjeta->pointer = true; $edit->p_licencia = new inputField('Licencia', 'p_licencia'); $edit->p_licencia->size = 5; $edit->p_licencia->maxlength = 6; //$edit->p_licencia->db_name ='licencia'; //$edit->p_licencia->rel_id ='patente'; $edit->p_licencia->pointer = true; $edit->p_razon = new inputField('Razón', 'p_razon'); $edit->p_razon->size = 100; //$edit->p_razon->db_name ='licencia'; //$edit->p_razon->rel_id ='patente'; $edit->p_razon->pointer = true; $edit->p_dir_neg = new inputField('Dirección', 'p_dir_neg'); $edit->p_dir_neg->size = 100; //$edit->p_dir_neg->db_name ='dir_neg'; //$edit->p_dir_neg->rel_id ='patente'; $edit->p_dir_neg->pointer = true; $edit->p_local = new dropdownField('Localización', 'p_local'); $edit->p_local->options("SELECT codigo,nombre FROM local ORDER BY nombre"); $edit->p_local->style = "width:180px;"; //$edit->p_local->rel_id ='patente'; //$edit->p_local->db_name ='tarjeta'; $edit->p_local->pointer = true; $edit->p_negocio = new dropdownField('Negocio', 'p_negocio'); $edit->p_negocio->options("SELECT codigo,nombre FROM negocio ORDER BY nombre"); $edit->p_negocio->style = "width:180px;"; //$edit->p_negocio->rel_id ='patente'; //$edit->p_negocio->db_name ='tarjeta'; $edit->p_negocio->pointer = true; $edit->p_clase = new dropdownField('Clase', 'p_clase'); $edit->p_clase->options("SELECT codigo,nombre FROM claseo ORDER BY nombre"); $edit->p_clase->style = "width:120px;"; //$edit->p_clase->rel_id ='patente'; //$edit->p_clase->db_name ='tarjeta'; $edit->p_clase->pointer = true; $edit->p_clase->onchange = "cal_claseo()"; $edit->p_tipo = new dropdownField('Tipo', 'p_tipo'); $edit->p_tipo->options(array('' => '', 'A' => 'A', 'B' => 'B')); $edit->p_tipo->style = "width:120px;"; //$edit->p_tipo->rel_id ='patente'; //$edit->p_tipo->db_name ='tarjeta'; $edit->p_tipo->pointer = true; $edit->p_oficio = new inputField('Oficio', 'p_oficio'); $edit->p_oficio->size = 20; //$edit->p_oficio->db_name ='oficio'; //$edit->p_oficio->rel_id ='patente'; $edit->p_oficio->pointer = true; $edit->p_catastro = new inputField('Catastro', 'p_catastro'); $edit->p_catastro->size = 20; //$edit->p_catastro->db_name ='catastro'; //$edit->p_catastro->rel_id ='patente'; $edit->p_catastro->pointer = true; $edit->p_publicidad = new inputField('Publicidad', 'p_publicidad'); $edit->p_publicidad->size = 20; //$edit->p_publicidad->db_name ='publicidad'; //$edit->p_publicidad->rel_id ='patente'; $edit->p_publicidad->pointer = true; $edit->p_observa = new inputField('Observación', 'p_observa'); $edit->p_observa->size = 100; //$edit->p_observa->db_name ='oficio'; //$edit->p_observa->rel_id ='patente'; $edit->p_observa->pointer = true; $edit->p_repre = new inputField('Representante', 'p_repre'); $edit->p_repre->size = 20; $edit->p_repre->pointer = true; $edit->p_expclasi = new dropdownField('Clasificacion Expendido', 'p_expclasi'); $edit->p_expclasi->option("EXPENDIDO AL MAYOR Y DETAL", "EXPENDIDO AL MAYOR Y DETAL"); $edit->p_expclasi->option("EXPENDIDO DE CONSUMO", "EXPENDIDO DE CONSUMO"); $edit->p_expclasi->size = 20; $edit->p_expclasi->pointer = true; $edit->p_exphor = new inputField('Horario Espendido', 'p_exphor'); $edit->p_exphor->size = 20; $edit->p_exphor->pointer = true; $edit->p_repre = new inputField('Representante', 'p_repre'); $edit->p_repre->size = 20; $edit->p_repre->pointer = true; $edit->p_repreced = new inputField('Ced. Representante', 'p_repreced'); $edit->p_repreced->size = 20; $edit->p_repreced->pointer = true; $edit->p_capital = new inputField('Capital', 'p_capital'); $edit->p_capital->size = 20; //$edit->p_capital->db_name ='capital'; //$edit->p_capital->rel_id ='patente'; $edit->p_capital->css_class = 'inputnum'; $edit->p_capital->pointer = true; $edit->p_fecha_es = new dateonlyField('Fecha_es', 'p_fecha_es'); $edit->p_fecha_es->rule = 'chfecha'; $edit->p_fecha_es->size = 10; $edit->p_fecha_es->maxlength = 8; $edit->p_fecha_es->insertValue = date('Y-m-d'); //$edit->p_fecha_es->db_name ='fecha_es'; //$edit->p_fecha_es->rel_id ='patente'; $edit->p_fecha_es->pointer = true; /* $edit->p_kardex = new inputField('Código Kardex','p_kardex'); $edit->p_kardex->size =20; $edit->p_kardex->css_class ='inputnum'; $edit->p_kardex->pointer =true; */ $edit->p_nro = new inputField('Nro', 'p_nro'); $edit->p_nro->size = 5; //$edit->p_nro->css_class ='inputnum'; $edit->p_nro->pointer = true; $edit->p_fexpedicion = new dateonlyField('Fecha Expedición', 'p_fexpedicion'); $edit->p_fexpedicion->rule = 'chfecha'; $edit->p_fexpedicion->size = 10; $edit->p_fexpedicion->maxlength = 8; $edit->p_fexpedicion->insertValue = date('Y-m-d'); $edit->p_fexpedicion->pointer = true; $edit->p_fvencimiento = new dateonlyField('Fecha Vencimiento', 'p_fvencimiento'); $edit->p_fvencimiento->rule = 'chfecha'; $edit->p_fvencimiento->size = 10; $edit->p_fvencimiento->maxlength = 8; $edit->p_fvencimiento->insertValue = date('Y-m-d'); $edit->p_fvencimiento->pointer = true; //INICIO INMUEBLE $edit->inmueble = new inputField('Inmueble', 'inmueble'); $edit->inmueble->size = 6; $edit->inmueble->maxlength = 6; $edit->inmueble->append($bINMUEBLE); $edit->inmueble->db_name = 'inmueble'; $edit->i_ctainos = new inputField('Cuenta Inos', 'i_ctainos'); $edit->i_ctainos->rule = 'max_length[7]'; $edit->i_ctainos->size = 9; $edit->i_ctainos->maxlength = 7; //$edit->i_ctainos->db_name ='ctainos'; //$edit->i_ctainos->rel_id ='inmueble'; $edit->i_ctainos->pointer = true; $edit->i_direccion = new inputField('Dirección', 'i_direccion'); $edit->i_direccion->rule = 'max_length[50]'; $edit->i_direccion->size = 100; $edit->i_direccion->maxlength = 50; //$edit->i_direccion->db_name ='direccion'; //$edit->i_direccion->rel_id ='inmueble'; $edit->i_direccion->pointer = true; $edit->i_no_predio = new inputField('Nro. Promedio', 'i_no_predio'); $edit->i_no_predio->rule = 'max_length[10]'; $edit->i_no_predio->size = 12; $edit->i_no_predio->maxlength = 10; //$edit->i_no_predio->db_name ='no_predio'; //$edit->i_no_predio->rel_id ='inmueble'; $edit->i_no_predio->pointer = true; $edit->i_sector = new dropdownField('Sector', 'i_sector'); $edit->i_sector->options("SELECT codigo,nombre FROM local ORDER BY nombre"); //$edit->i_sector->db_name ='sector'; //$edit->i_sector->rel_id ='inmueble'; $edit->i_sector->pointer = true; $edit->i_tipo_in = new dropdownField('Tipo Inmueble', 'i_tipo_in'); $edit->i_tipo_in->options("SELECT tipoin,tipoin d FROM tipoin ORDER BY tipoin"); //$edit->i_tipo_in->db_name ='tipo_in'; //$edit->i_tipo_in->rel_id ='inmueble'; $edit->i_tipo_in->pointer = true; $edit->i_no_hab = new inputField('Nro.Habitacion', 'i_no_hab'); $edit->i_no_hab->rule = 'max_length[11]'; $edit->i_no_hab->size = 13; $edit->i_no_hab->maxlength = 11; //$edit->i_no_hab->db_name ='no_hab'; //$edit->i_no_hab->rel_id ='inmueble'; $edit->i_no_hab->pointer = true; $edit->i_clase = new dropdownField('Clase', 'i_clase'); $edit->i_clase->options("SELECT codigo,nombre FROM claseo ORDER BY nombre"); //$edit->i_clase->db_name ='clase'; //$edit->i_clase->rel_id ='inmueble'; $edit->i_clase->pointer = true; $edit->i_clase->onchange = "cal_claseo()"; $edit->i_tipo = new dropdownField('Tipo', 'i_tipo'); $edit->i_tipo->options(array('' => '', 'A' => 'A', 'B' => 'B')); $edit->i_tipo->style = "width:120px;"; //$edit->i_tipo->db_name ='tipo'; //$edit->i_tipo->rel_id ='inmueble'; $edit->i_tipo->pointer = true; $edit->i_monto = new inputField('Monto', 'i_monto'); $edit->i_monto->rule = 'max_length[8]'; $edit->i_monto->size = 10; $edit->i_monto->maxlength = 8; //$edit->i_monto->db_name ='monto'; //$edit->i_monto->rel_id ='inmueble'; $edit->i_monto->pointer = true; //INICIO VEHICULO $edit->vehiculo = new inputField('Vehiculo', 'vehiculo'); $edit->vehiculo->size = 6; $edit->vehiculo->maxlength = 6; $edit->vehiculo->append($bVEHICULO); $edit->vehiculo->db_name = 'vehiculo'; $edit->vehiculo->readonly = true; $edit->v_clase = new dropdownField('Clase', 'v_clase'); $edit->v_clase->options("SELECT codigo,nombre FROM clase ORDER BY nombre"); $edit->v_clase->style = "width:200px;"; //$edit->v_clase->db_name ='clase'; //$edit->v_clase->rel_id ='vehiculo'; $edit->v_clase->pointer = true; $edit->v_marca = new inputField('Marca', 'v_marca'); //$edit->v_marca->options("SELECT trim(marca),marca m FROM marca ORDER BY marca"); //$edit->v_marca->style="width:120px;"; //$edit->v_marca->db_name ='marca'; //$edit->v_marca->rel_id ='vehiculo'; $edit->v_marca->pointer = true; $edit->v_marca->size = 20; $edit->v_marca->maxlength = 30; $edit->v_tipo = new inputField('Tipo', 'v_tipo'); //$edit->v_tipo->options("SELECT tipo,tipo m FROM tipo ORDER BY tipo"); //$edit->v_tipo->style="width:120px;"; //$edit->v_tipo->db_name ='tipo'; //$edit->v_tipo->rel_id ='vehiculo'; $edit->v_tipo->pointer = true; $edit->v_tipo->size = 20; $edit->v_tipo->maxlength = 30; $edit->v_modelo = new inputField('Modelo', 'v_modelo'); $edit->v_modelo->rule = 'max_length[10]'; $edit->v_modelo->size = 12; $edit->v_modelo->maxlength = 10; //$edit->v_modelo->db_name ='modelo'; //$edit->v_modelo->rel_id ='vehiculo'; $edit->v_modelo->pointer = true; $edit->v_color = new inputField('Color', 'v_color'); $edit->v_color->rule = 'max_length[20]'; $edit->v_color->size = 22; $edit->v_color->maxlength = 20; //$edit->v_color->db_name ='color'; //$edit->v_color->rel_id ='vehiculo'; $edit->v_color->pointer = true; $edit->v_capaci = new inputField('Capacidad', 'v_capaci'); $edit->v_capaci->rule = 'max_length[11]'; $edit->v_capaci->size = 13; $edit->v_capaci->maxlength = 11; //$edit->v_capaci->db_name ='capaci'; //$edit->v_capaci->rel_id ='vehiculo'; $edit->v_capaci->pointer = true; $edit->v_serial_m = new inputField('Serial Motor', 'v_serial_m'); $edit->v_serial_m->size = 40; //$edit->v_serial_m->db_name ='serial_m'; //$edit->v_serial_m->rel_id ='vehiculo'; $edit->v_serial_m->pointer = true; $edit->v_placa_ant = new inputField('Placa Anterior', 'v_placa_ant'); $edit->v_placa_ant->rule = 'max_length[7]'; $edit->v_placa_ant->size = 9; $edit->v_placa_ant->maxlength = 7; //$edit->v_placa_ant->db_name ='placa_ant'; //$edit->v_placa_ant->rel_id ='vehiculo'; $edit->v_placa_ant->pointer = true; $edit->v_placa_act = new inputField('Placa', 'v_placa_act'); $edit->v_placa_act->rule = 'max_length[9]'; $edit->v_placa_act->size = 11; $edit->v_placa_act->maxlength = 9; //$edit->v_placa_act->db_name ='placa_act'; //$edit->v_placa_act->rel_id ='vehiculo'; $edit->v_placa_act->pointer = true; $edit->v_ano = new inputField('Año', 'v_ano'); $edit->v_ano->rule = 'max_length[4]'; $edit->v_ano->size = 6; $edit->v_ano->maxlength = 4; //$edit->v_ano->db_name ='ano'; //$edit->v_ano->rel_id ='vehiculo'; $edit->v_ano->pointer = true; $edit->v_peso = new inputField('Peso', 'v_peso'); $edit->v_peso->rule = 'max_length[8]'; $edit->v_peso->size = 10; $edit->v_peso->maxlength = 8; //$edit->v_peso->db_name ='peso'; //$edit->v_peso->rel_id ='vehiculo'; $edit->v_peso->pointer = true; $edit->v_serial_c = new inputField('Serial Carroceria', 'v_serial_c'); $edit->v_serial_c->size = 40; //$edit->v_serial_c->db_name ='serial_c'; //$edit->v_serial_c->rel_id ='vehiculo'; $edit->v_serial_c->pointer = true; $edit->ano = new inputField('Año', 'ano'); $edit->ano->insertValue = $this->datasis->traevalor('EJERCICIO'); $edit->ano->size = 4; $edit->ano->maxlength = 4; $m = array('Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'); for ($i = 1; $i <= 12; $i++) { $campo = 'm_' . str_pad($i, 2, '0', STR_PAD_LEFT); $edit->{$campo} = new checkboxField($m[$i - 1], $campo, 'S', 'N'); $edit->{$campo}->insertValue = "N"; $edit->{$campo}->onchange = "cal_ch('" . str_pad($i, 2, '0', STR_PAD_LEFT) . "')"; } $m = array('Trimestre 1', 'Trimestre 2', 'Trimestre 3', 'Trimestre 4'); for ($i = 1; $i <= 4; $i++) { $campo = 't_' . str_pad($i, 2, '0', STR_PAD_LEFT); $edit->{$campo} = new checkboxField($m[$i - 1], $campo, 'S', 'N'); $edit->{$campo}->insertValue = "N"; $edit->{$campo}->onchange = "cal_ch2('" . str_pad($i, 2, '0', STR_PAD_LEFT) . "')"; } //TEMPORALES foreach ($this->temp as $k => $v) { $edit->{$v} = new hiddenField('', $v); } if ($edit->_status == 'show') { $id = $edit->get_from_dataobjetct('id'); $tipo = $edit->get_from_dataobjetct('tipo'); if ($tipo == '15') { $action = "javascript:window.location='" . site_url($this->url . '/calcomania/' . $edit->rapyd->uri->get_edited_id()) . "'"; $edit->button_status("btn_calcomania", 'Pagar Calcomania', $action, "TL", "show"); } } $status = $edit->get_from_dataobjetct('status'); if ($this->datasis->puede(387)) { $print_url = site_url($this->url . 'datarecibo/modify/' . $id); $action = "javascript:window.location='{$print_url}'"; $edit->button('btn_recibo', 'Modificar Recibo', $action, 'TR'); } if ($status == 'P') { $edit->buttons('modify', 'delete'); if ($this->datasis->traevalor('RECIBOUSABTNIMPRIMIR') == 'S') { if ($edit->_status == 'show') { $print_url = site_url($this->url . 'dataprint/modify/' . $id); $action = "javascript:window.location='{$print_url}'"; $edit->button('btn_print', 'Imprimir Recibo', $action, 'TR'); $print_url = site_url($this->url . 'dataprint_solvencia/modify/' . $id); $action = "javascript:window.location='{$print_url}'"; $edit->button('btn_print', 'Imprimir Solvencia', $action, 'TR'); } } $action = "javascript:window.location='" . site_url($this->url . '/anular/' . $edit->rapyd->uri->get_edited_id()) . "'"; $edit->button_status("btn_anular", 'Anular', $action, "TR", "show"); if ($this->datasis->puede(389)) { $edit->buttons('delete'); } } $edit->buttons('add', 'save', 'undo', 'back'); $edit->build(); $conten["form"] =& $edit; $smenu['link'] = barra_menu('80B'); $data['smenu'] = $this->load->view('view_sub_menu', $smenu, true); $conten['temp'] = $this->temp; $data['content'] = $this->load->view('view_recibo', $conten, true); $data['title'] = $this->t**s; $data["head"] = script('jquery.js') . script('jquery-ui.js') . script('plugins/jquery.numeric.pack.js') . script('plugins/jquery.floatnumber.js') . script('plugins/jquery.meiomask.js') . style('vino/jquery-ui.css') . $this->rapyd->get_head(); $this->load->view('view_ventanas', $data); }
function dataedit() { $this->rapyd->load('dataobject', 'datadetails'); $do = new DataObject('edcont'); $do->pointer('scli', 'scli.cliente=edcont.cliente', 'scli.tipo AS sclitipo, scli.nombre AS nombre, dire11 AS direc, scli.rifci AS rifci', 'left'); //$do->pointer('edres' ,'edres.id=edcont.id_edres','scli.tipo AS sclitipo, scli.nombre AS edresnumero','left'); $do->rel_one_to_many('itedcont', 'itedcont', array('id' => 'id_edcont')); $do->order_rel_one_to_many('itedcont', 'id'); $edit = new DataDetails('', $do); /* $script= ' $(function() { $("#fecha").datepicker({dateFormat:"dd/mm/yy"}); $(".inputnum").numeric("."); $(".inputonlynum").numeric(); }); '; $edit->script($script,'modify'); $edit->script($script,'create'); */ $edit->on_save_redirect = false; $id = $edit->get_from_dataobjetct('id'); if ($id !== false) { $action = "javascript:window.location='" . site_url($this->url . 'formato/' . $id . '/contrato.xml') . "'"; $edit->button('btn_formato', 'Descargar formato', $action, 'TR'); } $status = $edit->get_from_dataobjetct('status'); if ($status == 'P') { $action = "javascript:window.location='" . site_url($this->url . 'actualizar/' . $id) . "'"; $edit->button('btn_actuali', 'Actualizar', $action, 'TR'); } //$edit->back_url = site_url($this->url.'filteredgrid'); $edit->post_process('insert', '_post_insert'); $edit->post_process('update', '_post_update'); $edit->post_process('delete', '_post_delete'); $edit->pre_process('insert', '_pre_insert'); $edit->pre_process('update', '_pre_update'); $edit->pre_process('delete', '_pre_delete'); $edit->id_edres = new inputField('Id_edres', 'id_edres'); $edit->id_edres->rule = 'max_length[11]|integer'; $edit->id_edres->css_class = 'inputonlynum'; $edit->id_edres->size = 13; $edit->id_edres->maxlength = 11; $edit->numero = new inputField('Número', 'numero'); $edit->numero->rule = 'max_length[8]'; $edit->numero->size = 10; $edit->numero->maxlength = 8; $edit->status = new dropdownField('Estatus', 'status'); $edit->status->option('P', 'Pendiente'); $edit->status->option('A', 'Aprobado'); $edit->status->style = 'width:180px;'; $edit->status->rule = 'max_length[1]'; $edit->status->when = array('show'); $edit->numero_edres = new inputField('Reservación', 'numero_edres'); $edit->numero_edres->rule = 'max_length[8]'; $edit->numero_edres->size = 10; $edit->numero_edres->maxlength = 8; $edit->numero = new inputField('Número', 'numero'); $edit->numero->size = 10; $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->fecha = new dateField('Fecha', 'fecha'); $edit->fecha->rule = 'chfecha'; $edit->fecha->size = 10; $edit->fecha->insertValue = date('Y-m-d'); $edit->fecha->maxlength = 8; $edit->fecha->calendar = false; $edit->cliente = new inputField('Cliente', 'cliente'); $edit->cliente->rule = 'max_length[5]|required'; $edit->cliente->size = 7; $edit->cliente->maxlength = 5; $edit->sclitipo = new hiddenField('', 'sclitipo'); $edit->sclitipo->db_name = 'sclitipo'; $edit->sclitipo->pointer = true; $edit->sclitipo->insertValue = 1; $edit->nombre = new inputField('Nombre', 'nombre'); $edit->nombre->size = 25; $edit->nombre->maxlength = 40; $edit->nombre->readonly = true; $edit->nombre->autocomplete = false; $edit->nombre->rule = 'required'; $edit->nombre->type = 'inputhidden'; $edit->nombre->pointer = true; $edit->rifci = new inputField('RIF/CI', 'rifci'); $edit->rifci->autocomplete = false; $edit->rifci->readonly = true; $edit->rifci->size = 15; $edit->rifci->type = 'inputhidden'; $edit->rifci->pointer = true; $edit->direc = new inputField('Dirección', 'direc'); $edit->direc->readonly = true; $edit->direc->size = 40; $edit->direc->type = 'inputhidden'; $edit->direc->pointer = true; $edit->edificacion = new dropdownField('Edificación', 'edificacion'); $edit->edificacion->option('', 'Seleccionar'); $edit->edificacion->options('SELECT id,TRIM(nombre) AS nombre FROM edif ORDER BY nombre'); $edit->edificacion->style = 'width:150px;'; $edit->edificacion->rule = 'max_length[11]|required'; $edit->inmueble = new dropdownField('Inmueble', 'inmueble'); $edit->inmueble->option('', 'Seleccionar'); $edif = $edit->getval('edificacion'); if ($edif !== false) { $dbedif = $this->db->escape($edif); $edit->inmueble->option('', 'Seleccionar'); $edit->inmueble->options("SELECT id,TRIM(descripcion) AS nombre FROM edinmue WHERE status='D' AND edificacion={$dbedif} ORDER BY descripcion"); } else { $edit->inmueble->option('', 'Seleccione una edificacion'); } $edit->inmueble->style = 'width:150px;'; $edit->inmueble->rule = 'max_length[11]|required'; $edit->reserva = new inputField('Reserva', 'reserva'); $edit->reserva->rule = 'max_length[17]|numeric'; $edit->reserva->css_class = 'inputnum'; $edit->reserva->size = 10; $edit->reserva->maxlength = 17; $edit->precioxmt2 = new inputField('Precio m2', 'precioxmt2'); $edit->precioxmt2->rule = 'max_length[17]|numeric|mayorcero|required'; $edit->precioxmt2->css_class = 'inputnum'; $edit->precioxmt2->size = 10; $edit->precioxmt2->maxlength = 17; $edit->precioxmt2->showformat = 'decimal'; $edit->mt2 = new inputField('Área m2', 'mt2'); $edit->mt2->rule = 'max_length[17]|numeric|mayorcero|required'; $edit->mt2->css_class = 'inputnum'; $edit->mt2->size = 7; $edit->mt2->maxlength = 17; $edit->mt2->showformat = 'decimal'; $edit->uso = new dropdownField('Uso', 'uso'); $edit->uso->option('', 'Seleccionar'); $edit->uso->options('SELECT id,uso FROM `eduso` ORDER BY uso'); $edit->uso->style = 'width:180px;'; $edit->uso->rule = 'required'; $edit->inicial = new inputField('Inicial', 'inicial'); $edit->inicial->rule = 'max_length[17]|numeric|mayorcero'; $edit->inicial->css_class = 'inputnum'; $edit->inicial->size = 19; $edit->inicial->maxlength = 17; $edit->inicial->showformat = 'decimal'; $edit->financiable = new inputField('Monto financiable', 'financiable'); $edit->financiable->rule = 'max_length[17]|numeric'; $edit->financiable->css_class = 'inputnum'; $edit->financiable->size = 19; $edit->financiable->maxlength = 17; $edit->financiable->showformat = 'decimal'; $edit->firma = new inputField('Pago final (firma)', 'firma'); $edit->firma->rule = 'max_length[17]|numeric|mayorcero'; $edit->firma->css_class = 'inputnum'; $edit->firma->size = 19; $edit->firma->type = 'inputhidden'; $edit->firma->maxlength = 17; $edit->firma->showformat = 'decimal'; $edit->monto = new inputField('Monto total', 'monto'); $edit->monto->rule = 'max_length[17]|numeric|mayorcero'; $edit->monto->css_class = 'inputnum'; $edit->monto->size = 19; $edit->monto->type = 'inputhidden'; $edit->monto->maxlength = 17; $edit->monto->showformat = 'decimal'; $edit->notas = new textareaField('Notas', 'notas'); $edit->notas->rule = 'max_length[8]'; $edit->notas->cols = 70; $edit->notas->rows = 4; //******************************* // Inicio del detalle //******************************* $edit->it_vencimiento = new dateField('Vencimiento <#o#>', 'it_vencimiento_<#i#>'); $edit->it_vencimiento->rule = 'chfecha|required'; $edit->it_vencimiento->size = 10; $edit->it_vencimiento->insertValue = date('Y-m-d'); $edit->it_vencimiento->db_name = 'vencimiento'; $edit->it_vencimiento->rel_id = 'itedcont'; $edit->it_vencimiento->maxlength = 8; $edit->it_vencimiento->calendar = false; $edit->it_especial = new dropdownField('Especial <#o#>', 'it_especial_<#i#>'); $edit->it_especial->rule = 'max_length[1]|enum[S,N]'; $edit->it_especial->db_name = 'especial'; $edit->it_especial->rel_id = 'itedcont'; $edit->it_especial->style = 'width:80px;'; $edit->it_especial->option('N', 'Normal'); $edit->it_especial->option('S', 'Especial'); $edit->it_monto = new inputField('Monto <#o#>', 'it_monto_<#i#>'); $edit->it_monto->rule = 'max_length[10]|numeric'; $edit->it_monto->db_name = 'monto'; $edit->it_monto->rel_id = 'itedcont'; //$edit->it_monto->on_keyup = 'totagiro()'; //$edit->it_monto->on_keyup ='distrib()'; $edit->it_monto->css_class = 'inputnum'; $edit->it_monto->size = 12; $edit->it_monto->maxlength = 10; $edit->it_monto->showformat = 'decimal'; //****************************** // Fin del detalle //****************************** if ($status != 'A') { $edit->buttons('modify', 'delete', 'add_rel'); //$edit->buttons('modify', 'save', 'undo', 'delete','add_rel'); } //$edit->buttons('back', 'add'); $edit->build(); if ($edit->on_success()) { $rt = array('status' => 'A', 'mensaje' => 'Registro guardado', 'pk' => $edit->_dataobject->pk); echo json_encode($rt); } else { $conten['form'] =& $edit; $data['content'] = $this->load->view('view_edcont', $conten, false); //$data['content'] = $this->load->view('view_edcont', $conten,true); //echo $edit->output; } /* $conten['form'] =& $edit; $data['content'] = $this->load->view('view_edcont', $conten,true); $data['title'] = heading($this->t**s); $data['head'] = $this->rapyd->get_head(); $data['head'] .= script('jquery.js'); $data['head'] .= script('jquery-ui.js'); $data['head'] .= script('plugins/jquery.numeric.pack.js'); $data['head'] .= script('plugins/jquery.floatnumber.js'); $data['head'] .= script('plugins/jquery.meiomask.js'); $data['head'] .= phpscript('nformat.js'); $data['head'] .= style('redmond/jquery-ui-1.8.1.custom.css'); $this->load->view('view_ventanas', $data); */ }
function dataedit($recibo = null) { $this->rapyd->load('datadetails', 'dataobject'); $this->load->helper('form'); $mBANC = array('tabla' => 'banc', 'columnas' => array('codbanc' => 'Cóodigo', 'tbanco' => 'T Banco', 'banco' => 'Banco', 'numcuent' => 'Cuenta', 'saldo' => 'Saldo'), 'filtro' => array('tbanco' => 'T Banco', 'banco' => 'Banco', 'numcuent' => 'Cuenta'), 'p_uri' => array(4 => '<#i#>'), 'retornar' => array('codbanc' => 'codbanc_<#i#>'), 'where' => 'activo = "S" ', 'titulo' => 'Buscar Bancos'); $bBANC = $this->datasis->p_modbus($mBANC, "<#i#>"); $mRECIBO = array('tabla' => 'r_v_xcobrar', 'columnas' => array('id' => 'Ref.', 'numero' => 'Numero', 'fecha' => 'Fecha', 'monto' => 'Monto', 'rifci' => 'RIF/CI', 'nombre' => 'Nombre'), 'filtro' => array('id' => 'Ref.', 'numero' => 'Numero', 'fecha' => 'Fecha', 'monto' => 'Monto', 'rifci' => 'RIF/CI', 'nombre' => 'Nombre'), 'p_uri' => array(4 => '<#i#>'), 'retornar' => array('id' => 'recibo_<#i#>', 'numero' => 'numerop_<#i#>', 'DATE_FORMAT(fecha,"%d/%m/%Y")' => 'fechap_<#i#>', 'monto' => 'montop_<#i#>', 'nombre' => 'nombrep_<#i#>'), 'script' => array('cal_totr()'), 'titulo' => 'Buscar Recibos por Pagar'); $bRECIBO = $this->datasis->p_modbus($mRECIBO, "<#i#>"); $ABONOCODBANCDEFECTO = $this->datasis->traevalor('ABONOCODBANCDEFECTO'); $user = $this->session->userdata('usuario'); $usere = $this->db->escape($user); $r_caja = $this->datasis->damerow("SELECT r_caja.id,punto_codbanc,defecto_codbanc FROM r_caja JOIN usuario ON r_caja.id=usuario.caja WHERE us_codigo ={$usere}"); if (count($r_caja) > 0) { $caja = $r_caja['id']; $punto_codbanc = $r_caja['punto_codbanc']; if (strlen($r_caja['defecto_codbanc']) > 0) { $ABONOCODBANCDEFECTO = $r_caja['defecto_codbanc']; } } else { $caja = 0; $punto_codbanc = ''; } $do = new DataObject("r_abonos"); $do->rel_one_to_many('r_abonosit', 'r_abonosit', array('id' => 'abono')); $do->rel_one_to_many('r_mbanc', 'r_mbanc', array('id' => 'abono')); $do->rel_pointer('r_abonosit', 'r_recibo', 'r_abonosit.recibo=r_recibo.id', 'r_recibo.numero AS numerop,r_recibo.fecha AS fechap,r_recibo.monto AS montop,r_recibo.nombre AS nombrep,r_recibo.id AS idp', 'LEFT'); $edit = new DataDetails($this->t**s, $do); $edit->back_url = site_url($this->url . "filteredgrid"); $edit->set_rel_title('r_abonosit', 'Rubro <#o#>'); $edit->set_rel_title('r_mbanc', 'Rubro <#o#>'); $edit->back_url = site_url($this->url . "filteredgrid"); $edit->pre_process('insert', '_valida'); $edit->pre_process('update', '_valida'); $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->id = new inputField('id', 'id'); $edit->id->rule = 'max_length[11]'; $edit->id->size = 13; $edit->id->maxlength = 11; $edit->id->mode = 'autohide'; $edit->id->when = array('show', 'modify'); $edit->totrecibos = new inputField("Total Recibos", 'totrecibos'); $edit->totrecibos->size = 10; $edit->totrecibos->readonly = true; $edit->totrecibos->css_class = 'inputnum'; $edit->totmbanc = new inputField("Total Bancos", 'totmbanc'); $edit->totmbanc->size = 10; $edit->totmbanc->readonly = true; $edit->totmbanc->css_class = 'inputnum'; $edit->estampa = new autoUpdateField('estampa', date('Ymd'), date('Ymd')); /******** RECIBOS *************/ $edit->itrecibo = new inputField("(<#o#>) Ref. Recibo", 'recibo_<#i#>'); $edit->itrecibo->db_name = 'recibo'; $edit->itrecibo->size = 5; $edit->itrecibo->rel_id = 'r_abonosit'; //$edit->itrecibo->readonly =true; $edit->itrecibo->append($bRECIBO); $edit->itrecibo->rule = 'required'; $edit->itnumerop = new inputField("(<#o#>) Numero", 'numerop_<#i#>'); $edit->itnumerop->db_name = 'numerop'; $edit->itnumerop->size = 10; $edit->itnumerop->rel_id = 'r_abonosit'; $edit->itnumerop->pointer = true; $edit->itnumerop->readonly = true; $edit->itfechap = new inputField("(<#o#>) Fecha", 'fechap_<#i#>'); $edit->itfechap->db_name = 'fechap'; $edit->itfechap->size = 10; $edit->itfechap->rel_id = 'r_abonosit'; $edit->itfechap->pointer = true; $edit->itfechap->readonly = true; $edit->itmontop = new inputField("(<#o#>) Monto", 'montop_<#i#>'); $edit->itmontop->db_name = 'montop'; $edit->itmontop->size = 10; $edit->itmontop->rel_id = 'r_abonosit'; $edit->itmontop->pointer = true; $edit->itmontop->readonly = true; $edit->itmontop->value = 0; $edit->itmontop->rule = 'numeric'; $edit->itmontop->css_class = 'inputnum'; $edit->itnombrep = new inputField("(<#o#>) Nombre", 'nombrep_<#i#>'); $edit->itnombrep->db_name = 'nombrep'; $edit->itnombrep->size = 30; $edit->itnombrep->rel_id = 'r_abonosit'; $edit->itnombrep->pointer = true; $edit->itnombrep->readonly = true; /****** CHEQUES *********************/ $edit->itcodbanc = new inputField("(<#o#>) Banco", 'codbanc_<#i#>'); $edit->itcodbanc->db_name = 'codbanc'; $edit->itcodbanc->size = 4; $edit->itcodbanc->rel_id = 'r_mbanc'; $edit->itcodbanc->rule = "required|callback_banco"; $edit->itcodbanc->append($bBANC); $edit->itcodbanc->value = $ABONOCODBANCDEFECTO; $edit->ittipo_doc = new dropdownField("(<#o#>) Tipo Documento", "tipo_doc_<#i#>"); $edit->ittipo_doc->db_name = 'tipo_doc'; $edit->ittipo_doc->rel_id = 'r_mbanc'; $edit->ittipo_doc->style = "width:130px;"; if ($this->datasis->traevalor('ABONOS_EF_DEFECTO') == 'S') { $edit->ittipo_doc->option("EF", "Efectivo"); $edit->ittipo_doc->option("DP", "Deposito"); $edit->ittipo_doc->option("DB", "Tarjeta Débito"); $edit->ittipo_doc->option("CR", "Tarjeta Credito"); $edit->ittipo_doc->option("DF", "Diferencia"); } else { $edit->ittipo_doc->option("DP", "Deposito"); $edit->ittipo_doc->option("DB", "Tarjeta Débito"); $edit->ittipo_doc->option("CR", "Tarjeta Credito"); $edit->ittipo_doc->option("DF", "Diferencia"); $edit->ittipo_doc->option("EF", "Efectivo"); } $edit->itcheque = new inputField("(<#o#>) Transacción", 'cheque_<#i#>'); $edit->itcheque->db_name = 'cheque'; $edit->itcheque->size = 20; $edit->itcheque->rel_id = 'r_mbanc'; $edit->itfecha = new dateonlyField("(<#o#>) Fecha Cheque", "fecha_<#i#>"); $edit->itfecha->db_name = 'fecha'; $edit->itfecha->size = 10; $edit->itfecha->rel_id = 'r_mbanc'; $edit->itfecha->insertValue = date('Ymd'); $edit->itfecha->rule = 'required'; $edit->itmonto = new inputField("(<#o#>) Total", 'monto_<#i#>'); $edit->itmonto->db_name = 'monto'; $edit->itmonto->size = 10; $edit->itmonto->rel_id = 'r_mbanc'; $edit->itmonto->css_class = 'inputnum'; $edit->itmonto->onchange = "cal_totm();"; $edit->itmonto->value = 0; $edit->itid_mbancrel = new hiddenField('Id', 'id_mbancrel<#i#>'); $edit->itid_mbancrel->rel_id = 'r_mbanc'; $edit->itid_mbancrel->db_name = 'id_mbancrel'; /**************** POR COBRAR ******************************************/ if ($caja > 0) { $query = "select a.id AS id,a.id_contribu AS id_contribu,a.fecha AS fecha,a.numero AS numero,a.rifci AS rifci,a.nombre AS nombre,a.telefono AS telefono,a.monto AS monto,a.id_parroquia AS id_parroquia,a.parroquia AS parroquia,a.id_zona AS id_zona,a.zona AS zona,a.dir1 AS dir1,a.dir2 AS dir2,a.dir3 AS dir3,a.dir4 AS dir4,a.razon AS razon,a.solvencia AS solvencia,a.solvenciab AS solvenciab,a.licores AS licores,a.caja AS caja \n\t\t\tfrom \n\t\t\tr_recibo a \n\t\t\tleft join r_abonosit b on a.id = b.recibo\n\t\t\twhere isnull(b.recibo) AND a.caja={$caja}\n\t\t\tORDER BY id desc"; } else { $query = "select a.id AS id,a.id_contribu AS id_contribu,a.fecha AS fecha,a.numero AS numero,a.rifci AS rifci,a.nombre AS nombre,a.telefono AS telefono,a.monto AS monto,a.id_parroquia AS id_parroquia,a.parroquia AS parroquia,a.id_zona AS id_zona,a.zona AS zona,a.dir1 AS dir1,a.dir2 AS dir2,a.dir3 AS dir3,a.dir4 AS dir4,a.razon AS razon,a.solvencia AS solvencia,a.solvenciab AS solvenciab,a.licores AS licores,a.caja AS caja \n\t\t\tfrom \n\t\t\tr_recibo a \n\t\t\tleft join r_abonosit b on a.id = b.recibo\n\t\t\twhere isnull(b.recibo)\n\t\t\tORDER BY id desc"; } $porcobrar = $this->db->query($query); $porcobrar = $porcobrar->result_array(); foreach ($porcobrar as $key => $value) { $porcobrar[$key]['fecha'] = dbdate_to_human($value['fecha']); } $edit->button_status("btn_add_sfpa", 'Agregar Pago', "javascript:add_r_mbanc()", "MB", 'modify', "button_add_rel"); $edit->button_status("btn_add_sfpa2", 'Agregar Pago', "javascript:add_r_mbanc()", "MB", 'create', "button_add_rel"); $edit->button_status("btn_add_itabonos", 'Agregar Recibo', "javascript:add_r_abonosit()", "PA", 'modify', "button_add_rel"); $edit->button_status("btn_add_itabonos2", 'Agregar Recibo', "javascript:add_r_abonosit()", "PA", 'create', "button_add_rel"); if ($this->datasis->puede(429)) { $edit->buttons('modify'); } if ($this->datasis->puede(430)) { $edit->buttons('delete'); } $edit->buttons('add', 'save', 'undo', 'back'); $action = "javascript:location.href='" . site_url('recaudacion/r_recibo/dataedit/create') . "'"; $edit->button("add_r_recibo", "Agregar Recibo", $action, "TL"); $edit->build(); $conten["recibo"] = $recibo; $conten["form"] =& $edit; $conten['porcobrar'] = $porcobrar; $conten["punto_codbanc"] = $punto_codbanc; $conten["ABONOCODBANCDEFECTO"] = $ABONOCODBANCDEFECTO; $conten['porcobrarj'] = json_encode($porcobrar); $data['content'] = $this->load->view('recaudacion/r_abonos', $conten, true); $data['title'] = $this->t**s . ($this->cajan ? " CAJA {$this->cajan}" : ""); $data["head"] = $this->rapyd->get_head() . script('jquery.js') . script('jquery-ui.js') . script("plugins/jquery.numeric.pack.js") . script('plugins/jquery.meiomask.js') . style('vino/jquery-ui.css'); $this->load->view('view_ventanas', $data); }
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 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; } }