db = $db; } /** * Inicia Funciones Pestaña CFDIMX - Emisores */ public function createEmisor(User $user){ global $conf; $num_emisores = $this->fetchEmisores(); if($num_emisores == 0){ $this->emisores_info["predeterminado"] = 1; } $error = 1; if($this->emisores_info["predeterminado"] == 1){ $this->estatusEmisor(); dolibarr_set_const($this->db, "MAIN_INFO_SIREN", $this->emisores_info["rfc"], 'chaine', 1, '', $conf->entity); dolibarr_set_const($this->db, "CFDIMX_HUSO_HORARIO", $this->emisores_info["huso_horario"], 'chaine', 1, '', $conf->entity); dolibarr_set_const($this->db, "CFDIMX_RAZON_SOCIAL", $this->emisores_info["razon_social"], 'chaine', 1, '', $conf->entity); dolibarr_set_const($this->db, "CFDIMX_REGIMEN_FISCAL", $this->emisores_info["regimen_fiscal"], 'chaine', 1, '', $conf->entity); dolibarr_set_const($this->db, "CFDIMX_DIRECCION", $this->emisores_info["direccion"], 'chaine', 1, '', $conf->entity); } // if($this->emisores_info["validacion"] == 1){ // dolibarr_set_const($this->db, "MAIN_INFO_SOCIETE_COUNTRY", $this->emisores_info["pais"], 'chaine', 1, '', $conf->entity); // dolibarr_set_const($this->db, "MAIN_INFO_SOCIETE_STATE", $this->emisores_info["estado"], 'chaine', 1, '', $conf->entity); // dolibarr_set_const($this->db, "MAIN_INFO_SOCIETE_ZIP", $this->emisores_info["codigo_postal"], 'chaine', 1, '', $conf->entity); // } $sql = "INSERT INTO ".MAIN_DB_PREFIX."cfdimx_emisor_datacomp"; $sql .= " (emisor_rfc,razon_social,regimen,pais,estado,codigo_postal,emisor_delompio,emisor_colonia,emisor_calle,emisor_noext,emisor_noint,entity_id,"; $sql .= " cod_municipio,cod_colonia,predeterminado)"; $sql.= ' VALUES'; $sql.= '('; $sql.= '"'.$this->emisores_info["rfc"].'",'; $sql.= '"'.$this->emisores_info["razon_social"].'",'; $sql.= '"'.$this->emisores_info["regimen_fiscal"].'",'; $sql.= '"'.$conf->global->MAIN_INFO_SOCIETE_COUNTRY.'",'; $sql.= '"'.$conf->global->MAIN_INFO_SOCIETE_STATE.'",'; $sql.= '"'.$conf->global->MAIN_INFO_SOCIETE_ZIP.'",'; $sql.= '"'.$this->emisores_info["delmpio"].'",'; $sql.= '"'.$this->emisores_info["colonia"].'",'; $sql.= '"'.$this->emisores_info["calle"].'",'; $sql.= '"'.$this->emisores_info["noext"].'",'; $sql.= '"'.$this->emisores_info["noint"].'",'; $sql.= '"'.$conf->entity.'",'; $sql.= '"'.$this->emisores_info["clave_mpio"].'",'; $sql.= '"'.$this->emisores_info["clave_col"].'",'; $sql.= '"'.$this->emisores_info["predeterminado"].'"'; $sql.= ')'; $resql = $this->db->query($sql); if(!$resql){ $error = -1; $this->errors[] = "Error: No se pudo agregar el Emisor"; $this->errors[] = $sql; } return $error; } public function fetchEmisores(){ global $conf; $num = 0; $condiciones = array(); $sql = "SELECT * FROM ".MAIN_DB_PREFIX."cfdimx_emisor_datacomp"; $sql .= " WHERE"; if($conf->global->CFDIMX_ADMIN_LISTA_EMISORES == 0){ $condiciones[] = " emisor_rfc = '".$conf->global->MAIN_INFO_SIREN."'"; } $condiciones[] = " entity_id = ".$conf->entity; $sql .= implode(" AND ", $condiciones); $resql = $this->db->query($sql); if($resql){ $num = $this->db->num_rows($resql); $i = 0; while ($i < $num) { $obj = $this->db->fetch_object($resql); $this->emisores_list[] = $obj; $i++; } } return $num; } public function fetchEmisor($id){ global $conf; $aux_tmp_country = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY); $aux_tmp_state = explode(":", $conf->global->MAIN_INFO_SOCIETE_STATE); if($conf->global->CFDIMX_DIRECCION != ""){ if(is_numeric($conf->global->CFDIMX_DIRECCION)){ @$aux_tmp_address = $conf->global->MAIN_INFO_SOCIETE_ADDRESS; }else{ @$aux_tmp_address = $conf->global->CFDIMX_DIRECCION; } }else{ $aux_tmp_address = $conf->global->MAIN_INFO_SOCIETE_ADDRESS; } @$this->emisores_info = array( "MAIN_INFO_SOCIETE_COUNTRY" => $conf->global->MAIN_INFO_SOCIETE_COUNTRY, "MAIN_INFO_SOCIETE_COUNTRY_E" => $aux_tmp_country, "MAIN_INFO_SOCIETE_COUNTRY_L" => getCountry($aux_tmp_country[0], 1), "MAIN_INFO_SIREN" => $conf->global->MAIN_INFO_SIREN, "MAIN_INFO_SOCIETE_STATE" => $conf->global->MAIN_INFO_SOCIETE_STATE, "MAIN_INFO_SOCIETE_STATE_E" => $aux_tmp_state, "MAIN_INFO_SOCIETE_STATE_L" => getState($aux_tmp_state[0], 1), "MAIN_INFO_SOCIETE_ZIP" => $conf->global->MAIN_INFO_SOCIETE_ZIP, "MAIN_INFO_SOCIETE_ADDRESS" => $conf->global->MAIN_INFO_SOCIETE_ADDRESS, "CFDIMX_RAZON_SOCIAL" => $conf->global->MAIN_INFO_SOCIETE_NOM, "CFDIMX_REGIMEN_FISCAL" => "601", "CFDIMX_HUSO_HORARIO" => $conf->global->CFDIMX_HUSO_HORARIO, "CFDIMX_DIRECCION" => $conf->global->MAIN_INFO_SOCIETE_ADDRESS, "delmpio" => "", "clave_mpio" => "", "colonia" => "", "clave_col" => "", "calle" => "", "noext" => "", "noint" => "", 'predeterminado' => "" ); $sql = "SELECT * FROM ".MAIN_DB_PREFIX."cfdimx_emisor_datacomp"; $sql .= " WHERE"; $sql .= " rowid = ".$id; $resql = $this->db->query($sql); if($resql){ $num = $this->db->num_rows($resql); $i = 0; while ($i < $num) { $obj = $this->db->fetch_object($resql); @$this->emisores_info = array( "MAIN_INFO_SOCIETE_COUNTRY" => $conf->global->MAIN_INFO_SOCIETE_COUNTRY, "MAIN_INFO_SOCIETE_COUNTRY_E" => $aux_tmp_country, "MAIN_INFO_SOCIETE_COUNTRY_L" => getCountry($aux_tmp_country[0], 1), "MAIN_INFO_SIREN" => $obj->emisor_rfc, "MAIN_INFO_SOCIETE_STATE" => $conf->global->MAIN_INFO_SOCIETE_STATE, "MAIN_INFO_SOCIETE_STATE_E" => $aux_tmp_state, "MAIN_INFO_SOCIETE_STATE_L" => getState($aux_tmp_state[0], 1), "MAIN_INFO_SOCIETE_ZIP" => $obj->codigo_postal, "MAIN_INFO_SOCIETE_ADDRESS" => $conf->global->MAIN_INFO_SOCIETE_ADDRESS, "CFDIMX_RAZON_SOCIAL" => $obj->razon_social, "CFDIMX_REGIMEN_FISCAL" => $obj->regimen, "CFDIMX_HUSO_HORARIO" => $conf->global->CFDIMX_HUSO_HORARIO, "CFDIMX_DIRECCION" => $aux_tmp_address, "delmpio" => $obj->emisor_delompio, "clave_mpio" => $obj->cod_municipio, "colonia" => $obj->emisor_colonia, "clave_col" => $obj->cod_colonia, "calle" => $obj->emisor_calle, "noext" => $obj->emisor_noext, "noint" => $obj->emisor_noint, 'predeterminado' => $obj->predeterminado ); $i++; } } } public function updateEmisor(User $user){ global $conf; $num_emisores = $this->fetchEmisores(); if($num_emisores == 0 || $num_emisores == 1){ $this->emisores_info["predeterminado"] = 1; } $error = 1; print '$this->emisores_info["predeterminado"]::'.$this->emisores_info["predeterminado"].'::'; if($this->emisores_info["predeterminado"] == 1){ dolibarr_set_const($this->db, "MAIN_INFO_SIREN", $this->emisores_info["rfc"], 'chaine', 1, '', $conf->entity); dolibarr_set_const($this->db, "CFDIMX_HUSO_HORARIO", $this->emisores_info["huso_horario"], 'chaine', 1, '', $conf->entity); dolibarr_set_const($this->db, "CFDIMX_RAZON_SOCIAL", $this->emisores_info["razon_social"], 'chaine', 1, '', $conf->entity); dolibarr_set_const($this->db, "CFDIMX_REGIMEN_FISCAL", $this->emisores_info["regimen_fiscal"], 'chaine', 1, '', $conf->entity); dolibarr_set_const($this->db, "CFDIMX_DIRECCION", $this->emisores_info["direccion"], 'chaine', 1, '', $conf->entity); } // if($this->emisores_info["validacion"] == 1){ // dolibarr_set_const($this->db, "MAIN_INFO_SOCIETE_COUNTRY", $this->emisores_info["pais"], 'chaine', 1, '', $conf->entity); // dolibarr_set_const($this->db, "MAIN_INFO_SOCIETE_STATE", $this->emisores_info["estado"], 'chaine', 1, '', $conf->entity); // dolibarr_set_const($this->db, "MAIN_INFO_SOCIETE_ZIP", $this->emisores_info["codigo_postal"], 'chaine', 1, '', $conf->entity); // } $sql = "UPDATE ".MAIN_DB_PREFIX."cfdimx_emisor_datacomp"; $sql .= " SET"; $sql .= ' emisor_rfc = "'.$this->emisores_info["rfc"].'",'; $sql .= ' razon_social = "'.$this->emisores_info["razon_social"].'",'; $sql .= ' regimen = "'.$this->emisores_info["regimen_fiscal"].'",'; $sql .= ' pais = "'.$conf->global->MAIN_INFO_SOCIETE_COUNTRY.'",'; $sql .= ' estado = "'.$conf->global->MAIN_INFO_SOCIETE_STATE.'",'; $sql .= ' codigo_postal ="'.$conf->global->MAIN_INFO_SOCIETE_ZIP.'",'; $sql .= ' emisor_delompio ="'.$this->emisores_info["delmpio"].'",'; $sql .= ' emisor_colonia ="'.$this->emisores_info["colonia"].'",'; $sql .= ' emisor_calle = "'.$this->emisores_info["calle"].'",'; $sql .= ' emisor_noext = "'.$this->emisores_info["noext"].'",'; $sql .= ' emisor_noint = "'.$this->emisores_info["noint"].'",'; $sql .= ' cod_municipio = "'.$this->emisores_info["clave_mpio"].'",'; $sql .= ' cod_colonia = "'.$this->emisores_info["clave_col"].'"'; $sql .= " WHERE"; $sql .= " rowid = ".$this->emisores_info["rowid"]; $resql = $this->db->query($sql); if(!$resql){ $error = -1; $this->errors[] = "No se pudo actualizar la Información del Emisor"; $this->errors[] = $sql; } return $error; } public function deleteEmisor(User $user){ $error = 1; $sql = "DELETE FROM ".MAIN_DB_PREFIX."cfdimx_emisor_datacomp"; $sql .= " WHERE"; $sql .= " rowid = ".$this->emisores_info["rowid"]; $resql = $this->db->query($sql); if(!$resql){ $error = -1; $this->errors[] = "No se pudo elminar el Emisor"; $this->errors[] = $sql; } return $error; } public function estatusEmisor($id = 0, $estatus = -1){ global $conf; $error = 1; $sql = "UPDATE ".MAIN_DB_PREFIX."cfdimx_emisor_datacomp"; $sql .= " SET"; $sql .= " predeterminado = 0"; $sql .= " WHERE"; $sql .= " entity_id = ".$conf->entity; $resql = $this->db->query($sql); if(!$resql){ $error = -1; $this->errors[] = "No se pudo cambiar el estatus del Emisor"; $this->errors[] = $sql; } if($id > 0 && $estatus != -1){ $sql = "UPDATE ".MAIN_DB_PREFIX."cfdimx_emisor_datacomp"; $sql .= " SET"; $sql .= " predeterminado = ".$estatus; $sql .= " WHERE"; $sql .= " rowid = ".$id; $resql = $this->db->query($sql); if(!$resql){ $error = -1; $this->errors[] = "No se pudo cambiar el estatus del Emisor"; $this->errors[] = $sql; } if($estatus == 1){ $this->fetchEmisor($id); $this->changeEmisorPredeterminado($this->emisores_info["MAIN_INFO_SIREN"], '123', 155, $id); } } return $error; } public function getLabelEmisor($id){ global $langs; $label = ""; $this->fetchEmisor($id); $societe = new SocieteCFDIMX($this->db); $lista_regimen = $societe->getInfoCatalogos(2); $label_pais = ""; $label .= ''.$this->emisores_info["MAIN_INFO_SIREN"].'
'; $label .= ''.$this->emisores_info["CFDIMX_RAZON_SOCIAL"].'
'; $label .= ''.$lista_regimen[$this->emisores_info["CFDIMX_REGIMEN_FISCAL"]].'
'; $label .= ''.$this->emisores_info["CFDIMX_DIRECCION"].'
'; $label .= ''.$label_pais.$this->emisores_info["MAIN_INFO_SOCIETE_STATE_L"].'
'; $label .= ''.$this->emisores_info["MAIN_INFO_SOCIETE_COUNTRY_L"].'
'; $label .= ''.$this->emisores_info["MAIN_INFO_SOCIETE_ZIP"].'
'; $label .= ''.$this->emisores_info["delmpio"].'
'; $label .= ''.$this->emisores_info["clave_mpio"].'
'; $label .= ''.$this->emisores_info["colonia"].'
'; $label .= ''.$this->emisores_info["clave_col"].'
'; $label .= ''.$this->emisores_info["calle"].'
'; $label .= ''.$this->emisores_info["noext"].'
'; $label .= ''.$this->emisores_info["noint"].'
'; $label .= ''.$langs->trans($this->emisores_info["CFDIMX_HUSO_HORARIO"]); // $label .= ''.$this->emisores_info->password_timbrado_txt; return $label; } public function changeEmisorPredeterminado($rfc, $webservices_passtimbrado, $webservices_modo, $id_emisor){ global $conf, $user; $num_config = $this->fetchWebServices($rfc); if($num_config == 0){ $this->webservices_passtimbrado = $webservices_passtimbrado; $this->webservices_modo = $webservices_modo; $this->createConfigWebServices($user); } $num_config_ws = $this->fetchModoTimbrado($rfc); if($num_config_ws == 0){ dolibarr_set_const($this->db, "MAIN_INFO_SIREN", $rfc, 'chaine', 1, '', $conf->entity); $this->createModoTimbrado($user); } $this->fetchEmisor($id_emisor); dolibarr_set_const($this->db, "MAIN_INFO_SIREN", $rfc, 'chaine', 1, '', $conf->entity); dolibarr_set_const($this->db, "MAIN_INFO_SOCIETE_NOM", $this->emisores_info["CFDIMX_RAZON_SOCIAL"], 'chaine', 1, '', $conf->entity); dolibarr_set_const($this->db, "CFDIMX_RAZON_SOCIAL", $this->emisores_info["CFDIMX_RAZON_SOCIAL"], 'chaine', 1, '', $conf->entity); dolibarr_set_const($this->db, "MAIN_INFO_SOCIETE_COUNTRY", $this->emisores_info["MAIN_INFO_SOCIETE_COUNTRY"], 'chaine', 1, '', $conf->entity); dolibarr_set_const($this->db, "MAIN_INFO_SOCIETE_STATE", $this->emisores_info["MAIN_INFO_SOCIETE_STATE"], 'chaine', 1, '', $conf->entity); dolibarr_set_const($this->db, "MAIN_INFO_SOCIETE_ZIP", $this->emisores_info["MAIN_INFO_SOCIETE_ZIP"], 'chaine', 1, '', $conf->entity); } /** * Termina Funciones Pestaña CFDIMX - Emisores */ /** * Inicia Funciones Pestaña CFDIMX - Web Services */ public function getModosTimbrado(){ global $conf; $module = new modCFDIMX($this->db); $url_ws_produccion = ($conf->global->CFDIMX_CONF_WS_PRODUCCION != "" ? $conf->global->CFDIMX_CONF_WS_PRODUCCION : $module->ws_produccion); $url_ws_pruebas = ($conf->global->CFDIMX_CONF_WS_PRUEBAS != "" ? $conf->global->CFDIMX_CONF_WS_PRUEBAS : $module->ws_pruebas); // Se definen los modos de timbrado $info_detail_produccion = explode("/",str_replace(array("https:", "http:"), "", implode("", explode("//", $url_ws_produccion)))); $separa_ip_produccion = explode(".", $info_detail_produccion[0]); $this->webservices_list[$separa_ip_produccion[0]] = "Producción - ".$info_detail_produccion[0]; $info_detail_pruebas = explode("/",str_replace(array("https:", "http:"), "", implode("", explode("//", $url_ws_pruebas)))); $separa_ip_pruebas = explode(".", $info_detail_pruebas[0]); $this->webservices_list[$separa_ip_pruebas[0]] = "Pruebas - ".$info_detail_pruebas[0]; } public function createModoTimbrado(User $user){ global $conf; $module = new modCFDIMX($this->db); $error = 1; $sql = "SELECT count(*) as exist FROM ".MAIN_DB_PREFIX."cfdimx_config_ws"; $sql .= " WHERE"; $sql .= " emisor_rfc = '".$conf->global->MAIN_INFO_SIREN."'"; $sql .= " AND entity_id = " . $conf->entity; $resql = $this->db->query($sql); if($resql){ $proceso = 0; $i = 0; $num = $this->db->num_rows($resql); while($i < $num){ $obj = $this->db->fetch_object($resql); $proceso = $obj->exist; $i++; } $url_ws_produccion = ($conf->global->CFDIMX_CONF_WS_PRODUCCION != "" ? $conf->global->CFDIMX_CONF_WS_PRODUCCION : $module->ws_produccion); $url_ws_pruebas = ($conf->global->CFDIMX_CONF_WS_PRUEBAS != "" ? $conf->global->CFDIMX_CONF_WS_PRUEBAS : $module->ws_pruebas); $modo_timbrado = ($this->webservices_modo == 140 ? 1 : 2); $url_ws = ($this->webservices_modo == 140 ? $url_ws_produccion : $url_ws_pruebas); dolibarr_set_const($this->db, "MAIN_MODULE_CFDIMX_WS", $url_ws, 'chaine', 1, '', $conf->entity); if($proceso == 0){ $sql = "INSERT INTO ".MAIN_DB_PREFIX."cfdimx_config_ws"; $sql .= " (emisor_rfc,ws_modo_timbrado,ws_pruebas,ws_produccion,ws_status_conf,entity_id)"; $sql .= " VALUES"; $sql .= "("; $sql .= "'".$conf->global->MAIN_INFO_SIREN."',"; $sql .= "'".$modo_timbrado. "',"; $sql .= "'".$url_ws_produccion."',"; $sql .= "'".$url_ws_pruebas."',"; $sql .= "'',"; $sql .= $conf->entity; $sql .= ")"; $resql = $this->db->query($sql); }else{ $sql = "UPDATE ".MAIN_DB_PREFIX."cfdimx_config_ws"; $sql .= " SET "; $sql .= " ws_modo_timbrado = ".$modo_timbrado.","; $sql .= " ws_pruebas = '".$url_ws_pruebas."',"; $sql .= " ws_produccion = '".$url_ws_produccion."'"; $sql .= " WHERE"; $sql .= " emisor_rfc = '".$conf->global->MAIN_INFO_SIREN."'"; $rs = $this->db->query($sql); } }else{ $error = -1; $this->errors[] = "No se pudo actualizar correctamente el modo de Web Services."; } return $error; } public function fetchModoTimbrado($rfc = ''){ global $conf; $num = 0; if($rfc == ''){ $rfc = $conf->global->MAIN_INFO_SIREN; } // emisor_rfc,ws_modo_timbrado,ws_pruebas,ws_produccion $sql = "SELECT * FROM ".MAIN_DB_PREFIX."cfdimx_config_ws"; $sql .= " WHERE"; $sql .= " emisor_rfc = '".$rfc."'"; $sql .= " AND entity_id = ".$conf->entity; $resql = $this->db->query($sql); if($resql){ $num = $this->db->num_rows($resql); $i = 0; while ($i < $num) { $obj = $this->db->fetch_object($resql); $info_detail_produccion = explode("/",str_replace(array("https:", "http:"), "", implode("", explode("//", $obj->ws_produccion)))); $separa_ip_produccion = explode(".", $info_detail_produccion[0]); if($obj->ws_modo_timbrado == 1){ $this->webservices_modo = $separa_ip_produccion[0]; $this->webservices_url = $obj->ws_produccion; } $info_detail_pruebas = explode("/",str_replace(array("https:", "http:"), "", implode("", explode("//", $obj->ws_pruebas)))); $separa_ip_pruebas = explode(".", $info_detail_pruebas[0]); if($obj->ws_modo_timbrado == 2){ $this->webservices_modo = $separa_ip_pruebas[0]; $this->webservices_url = $obj->ws_pruebas; } $i++; } $this->webservices_num_config = ($num > 0 ? $this->fetchWebServices() : -1); $this->getInfoTimbrado($this->webservices_url); } return $num; } public function createConfigWebServices(User $user){ global $conf; $error = 0; $sql = "INSERT INTO ".MAIN_DB_PREFIX."cfdimx_config"; $sql .= "(emisor_rfc,password_timbrado,password_timbrado_txt,formato_cfdi,modo_timbrado,config_seriefolio,status_conf,entity_id)"; $sql .= " VALUES"; $sql .= "("; $sql .= "'".$conf->global->MAIN_INFO_SIREN."',"; $sql .= "'".md5($this->webservices_passtimbrado)."',"; $sql .= "'".$this->webservices_passtimbrado."',"; $sql .= "'standard',"; $sql .= "'".($this->webservices_modo == 140 ? 1 : 2)."',"; $sql .= "'1',"; $sql .= "'1',"; $sql .= $conf->entity; $sql .= ")"; $resql = $this->db->query($sql); if(!$resql){ $error = -1; $this->errors[] = "No se pudo agregar la información de la configuración."; $this->errors[] = $sql; }else{ dolibarr_set_const($this->db, "CFDIMX_VERSION_SAT", $this->webservices_version_cfdi, 'chaine', 0, '', $conf->entity); } return $error; } public function updateConfigWebServices(User $user){ global $conf; $error = 1; $sql = "UPDATE ".MAIN_DB_PREFIX."cfdimx_config"; $sql .= " SET"; $sql .= " emisor_rfc = '".$conf->global->MAIN_INFO_SIREN."',"; $sql .= " password_timbrado = '".md5($this->webservices_passtimbrado)."',"; $sql .= " password_timbrado_txt = '".$this->webservices_passtimbrado."',"; $sql .= " modo_timbrado ='".($this->webservices_modo == 140 ? 1 : 2)."'"; $sql .= " WHERE"; $sql .= " emisor_rfc = '".$conf->global->MAIN_INFO_SIREN."'"; $sql .= " AND entity_id = '".$conf->entity."'"; $resql = $this->db->query($sql); if(!$resql){ $error = -1; $this->errors[] = "No se pudo actualizar la información de la configuración."; $this->errors[] = $sql; }else{ $sql = "UPDATE ".MAIN_DB_PREFIX."cfdimx_emisor_datacomp"; $sql .= " SET"; $sql .= " password_timbrado = '".md5($this->webservices_passtimbrado)."',"; $sql .= " password_timbrado_txt = '".$this->webservices_passtimbrado."'"; $sql .= " WHERE"; $sql .= " emisor_rfc = '".$conf->global->MAIN_INFO_SIREN."'"; $sql .= " AND entity_id = '".$conf->entity."'"; $resql = $this->db->query($sql); if(!$resql){ $error = -1; $this->errors[] = "Error 2: No se pudo actualizar la información de la configuración."; $this->errors[] = $sql; } dolibarr_set_const($this->db, "CFDIMX_VERSION_SAT", $this->webservices_version_cfdi, 'chaine', 0, '', $conf->entity); } return $error; } public function fetchWebServices($rfc = ''){ global $conf; if($rfc == ""){ $rfc = $conf->global->MAIN_INFO_SIREN; } $num = 0; $sql = "SELECT * FROM ".MAIN_DB_PREFIX."cfdimx_config"; $sql .= " WHERE"; $sql .= " emisor_rfc ='".$rfc."'"; $sql .= " AND entity_id = ".$conf->entity; $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); $i = 0; while ($i < $num) { $obj = $this->db->fetch_object($resql); $this->webservices_estatus = $obj->status_conf; $this->webservices_passtimbrado = $obj->password_timbrado_txt; $i++; } } return $num; } public function getInfoTimbrado($url){ global $conf; if(trim($url) != ""){ $info_timbrado = getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2); if($info_timbrado["content"] != ""){ $client = new nusoap_client($url, 'wsdl'); $datos = array("rfc" => $conf->global->MAIN_INFO_SIREN); $result = $client->call('validaCliente', $datos); if($result["return"] != ""){ $this->webservices_folios_disponibles = $result["return"]["folios_disponibles"]; $this->webservices_folios_timbrados = $result["return"]["folios_timbrados"]; } }else{ if($info_timbrado["curl_error_no"] != ""){ } } } } public function getInfoSellos($url){ global $conf; $info_sellos = getURLContent($url, 'GET', '', 1, array(), array('http', 'https'), 2); if($info_sellos["content"] != ""){ $client_csd = new nusoap_client($url, 'wsdl'); $datos = array( "rfc" => $conf->global->MAIN_INFO_SIREN, "pass" => $this->webservices_passtimbrado ); $result_csd = $client_csd->call('validarCSD', $datos); if($result_csd["return"] != ""){ $this->webservices_mensaje_csd = ""; $this->webservices_num_leyenda = 0; if($result_csd["return"]["status"] == 2){ $this->webservices_mensaje_csd = "Vigente"; $this->webservices_num_leyenda = 4; }else{ if(is_null($result_csd["return"]["status"])){ $this->webservices_mensaje_csd = $result_csd["return"]["mensaje"]; $this->webservices_num_leyenda = 8; } } if($result_csd["return"]["status_cer"] > 0){ $this->webservices_mensaje_csd = "La fecha del certificado esta fuera de vigencia."; $this->webservices_num_leyenda = 8; } if($result_csd["return"]["status_key"] > 0){ $this->webservices_mensaje_csd = "La contraseña es incorrecta."; $this->webservices_num_leyenda = 8; } if($result_csd["return"]["status_cer"] > 998 && $result_csd["return"]["status_key"] > 998){ $this->webservices_mensaje_csd = $result_csd["return"]["mensaje"]; $this->webservices_num_leyenda = 8; } $this->webservices_file_cer = $result_csd["return"]["file_cer"]; $this->webservices_file_key = $result_csd["return"]["file_key"]; $this->webservices_file_fecha_inicial = $result_csd["return"]["fecha_inicio_vigencia"]; $this->webservices_file_fecha_final = $result_csd["return"]["fecha_termino_vigencia"]; } } } /** * Termina Funciones Pestaña CFDIMX - Web Services */ /** * Inicia Funciones Pestaña CFDIMX - Formas de Pago */ public function fetchCatalogoFormasPago(){ global $conf; $sql = "SELECT * FROM ".MAIN_DB_PREFIX."c_cfdimx_formapago"; $sql .= " ORDER BY code ASC"; $resql = $this->db->query($sql); if($resql){ $num = $this->db->num_rows($resql); $i = 0; while ($i < $num) { $obj = $this->db->fetch_object($resql); $this->formaspago_catalogo[$obj->code] = $obj->code." - ".$obj->label; $i++; } } } public function fetchFormasPago($estatus = 1){ global $conf; $num = 0; $sql = "SELECT * FROM ".MAIN_DB_PREFIX."c_paiement"; $sql .= " WHERE"; $sql .= " active = ".$estatus; $sql .= " AND id > 0 "; $sql .= " AND entity = ".$conf->entity; $sql .= " ORDER BY accountancy_code ASC"; $resql = $this->db->query($sql); if($resql){ $num = $this->db->num_rows($resql); $i = 0; while ($i < $num) { $obj = $this->db->fetch_object($resql); $this->formaspago_list[] = $obj; $i++; } } return $num; } public function updateFormasPago(User $user){ $error = 1; $sql = "UPDATE ".MAIN_DB_PREFIX."c_paiement"; $sql .= " SET"; $sql .= " accountancy_code = '".$this->formaspago_clavesat."'"; $sql .= " WHERE"; $sql .= " id = ".$this->formaspago_id; $resql = $this->db->query($sql); if(!$resql){ $error = -1; $this->errors[] = "No se pudo actualizar la Forma de Pago."; $this->errors[] = $sql; } return $error; } public function verificarClavesFormaPago(User $user){ global $conf; $error = 1; $sql = "SELECT id,accountancy_code FROM ".MAIN_DB_PREFIX."c_paiement"; $sql .= " WHERE"; $sql .= " entity = ".$conf->entity; $sql .= " AND accountancy_code IS NOT NULL"; $resql = $this->db->query($sql); if($resql){ $num = $this->db->num_rows($resql); $i = 0; while($i < $num){ $obj = $this->db->fetch_object($resql); $accountancy_code = sprintf("%02d", $obj->accountancy_code); $sql = "UPDATE ".MAIN_DB_PREFIX."c_paiement"; $sql .= " SET"; $sql .= " accountancy_code = '".$accountancy_code."'"; $sql .= " WHERE"; $sql .= " id = ".$obj->id; $res = $this->db->query($sql); $i++; } } return $error; } /** * Termina Funciones Pestaña CFDIMX - Formas de Pago */ /** * Inicia Funciones Pestaña CFDIMX - Retenciones Locales */ public function createRetLocal(User $user){ global $conf; $error = 1; $sql = "INSERT INTO ".MAIN_DB_PREFIX."cfdimx_config_retenciones_locales"; $sql .= "(cod,descripcion,tasa,entity)"; $sql .= " VALUES"; $sql .= "("; $sql .= "'".$this->retlocal_codigo."',"; $sql .= "'".$this->retlocal_desc."',"; $sql .= "'".$this->retlocal_tasa."',"; $sql .= "'".$conf->entity."'"; $sql .= ")"; $resql = $this->db->query($sql); if(!$resql){ $error = -1; $this->errors[] = "No se pudo agregar la Retención Local."; $this->errors[] = $sql; } return $error; } public function fetchRetLocales(){ global $conf; $num = 0; $sql = "SELECT * FROM ".MAIN_DB_PREFIX."cfdimx_config_retenciones_locales"; $sql .= " WHERE"; $sql .= " entity = ".$conf->entity; $resql = $this->db->query($sql); if($resql){ $num = $this->db->num_rows($resql); $i = 0; while ($i < $num) { $obj = $this->db->fetch_object($resql); $this->retlocales_list[] = $obj; $i++; } } return $num; } public function fetchRetLocal($rowid){ global $conf; $num = 0; $sql = "SELECT * FROM ".MAIN_DB_PREFIX."cfdimx_config_retenciones_locales"; $sql .= " WHERE"; $sql .= " rowid = ".$rowid; $resql = $this->db->query($sql); if($resql){ $num = $this->db->num_rows($resql); $i = 0; while ($i < $num) { $obj = $this->db->fetch_object($resql); $this->retlocal_rowid = $obj->rowid; $this->retlocal_codigo = $obj->cod; $this->retlocal_desc = $obj->descripcion; $this->retlocal_tasa = $obj->tasa; $i++; } } return $num; } public function updateRetLocal(User $user){ global $conf; $error = 1; $sql = "UPDATE ".MAIN_DB_PREFIX."cfdimx_config_retenciones_locales"; $sql .= " SET"; $sql .= " cod = '".$this->retlocal_codigo."',"; $sql .= " descripcion = '".$this->retlocal_desc."',"; $sql .= " tasa = '".$this->retlocal_tasa."'"; $sql .= " WHERE"; $sql .= " rowid = ".$this->retlocal_rowid; $resql = $this->db->query($sql); if(!$resql){ $error = -1; $this->errors[] = "No se pudo actualizar la Retención Local."; $this->errors[] = $sql; } return $error; } public function deleteRetLocal(User $user){ global $conf; $error = 1; $sql = "DELETE FROM ".MAIN_DB_PREFIX."cfdimx_config_retenciones_locales"; $sql .= " WHERE"; $sql .= " rowid = ".$this->retlocal_rowid; $resql = $this->db->query($sql); if(!$resql){ $error = -1; $this->errors[] = "No se pudo eliminar la Retención Local."; $this->errors[] = $sql; } return $error; } public function getLabelRetLocal($rowid){ $label = ""; $this->fetchRetLocal($rowid); $label .= ''.$this->retlocal_codigo.'
'; $label .= ''.$this->retlocal_desc.'
'; $label .= ''.$this->retlocal_tasa; return $label; } /** * Termina Funciones Pestaña CFDIMX - Retenciones Locales */ /** * Inicia Funciones Pestaña SAT - Carga Masiva - Claves/Guias de Llenado */ public function getCatalogosSAT($selected = 0){ $num = 0; $sql = "SELECT * FROM ".MAIN_DB_PREFIX."cfdimx_catalogos"; $sql .= " WHERE"; $sql .= " active = 1"; $resql = $this->db->query($sql); if($resql){ $num = $this->db->num_rows($resql); $i = 0; if($num > 0){ while ($i < $num) { $obj = $this->db->fetch_object($resql); $this->cargamasiva_catalogossat[$obj->code] = $obj->label; $i++; } } } return $num; } public function createClaveDiccionario($table, $code, $label, $active, $extrafields1 = '', $extrafields2 = '', $extrafields3 = ''){ $error = 0; $nombres_campos = array(); $valores_campos = array(); $nombres_campos[] = "code"; $nombres_campos[] = "label"; $nombres_campos[] = "active"; $valores_campos[] = "'".$code."'"; $valores_campos[] = "'".$label."'"; $valores_campos[] = "'".$active."'"; if(in_array($table, $this->cargamasiva_table_extrafields1)){ $valores_campos[] = "'".$extrafields1."'"; } if($table == 'c_cfdimx_formapago'){ $nombres_campos[] = "cod_doli"; } if($table == 'c_cfdimx_regimen_aduanero'){ $nombres_campos[] = "impoexpo"; } if(in_array($table, array("c_cfdimx_estaciones", "c_cfdimx_tipo_permiso"))){ $nombres_campos[] = "clave_transporte"; } if($table == 'c_cfdimx_clave_unidad_peso'){ $nombres_campos[] = "descripcion"; } if($table == 'c_cfdimx_clave_prodserv_cp'){ $nombres_campos[] = "materialpeligroso"; } if($table == 'c_cfdimx_material_peligroso'){ $nombres_campos[] = "clasedivision"; } if($table == 'c_cfdimx_config_autotransporte'){ $nombres_campos[] = "numeroejes"; $nombres_campos[] = "numerollantas"; $nombres_campos[] = "remolque"; $valores_campos[] = "'".$extrafields2."'"; $valores_campos[] = "'".$extrafields3."'"; } $sql = "INSERT INTO ".MAIN_DB_PREFIX.$table; $sql .= " ("; $sql .= implode(",", $nombres_campos); $sql .= ")"; $sql .= " VALUES"; $sql .= " ("; $sql .= implode(",", $valores_campos); $sql .= ")"; // print $sql.'
'; $resql = $this->db->query($sql); if(!$resql){ $error++; if($this->db->lasterrno == 'DB_ERROR_RECORD_ALREADY_EXISTS'){ $this->cargamasiva_validaciones[] = img_picto('', 'star')." La clave '".$code."' ya existe y no se registrado."; }else{ $this->cargamasiva_validaciones[] = img_picto('', 'error')." La clave '".$code."' no se a registrado correctamente."; } } if($error == 0){ $this->cargamasiva_validaciones[] = img_picto('', 'check')." La clave '".$code."' se registro correctamente."; } return $error; } public function getInfoTabCargaMasiva(){ $this->getCatalogosSAT(); } public function getInfoTabCargaMasivaPlantillas(){ global $dolibarr_main_document_root, $dolibarr_main_document_root_alt; $this->getCatalogosSAT(); $filedir = $dolibarr_main_document_root.'/cfdimx/doc/'; $file_list = dol_dir_list($filedir,'files',0,'','\.meta$','date',SORT_DESC); if(count($file_list) == 0){ $filedir = $dolibarr_main_document_root_alt.'/cfdimx/doc/'; $file_list = dol_dir_list($filedir,'files',0,'','\.meta$','date',SORT_DESC); } if (is_array($file_list) && count($file_list) > 0){ foreach($file_list as $file){ $this->cargamasiva_plantillas[] = $file; } } return count($file_list); } public function getGuiasLlenado(){ $url_api = "http://api-cfdi.dolibarr.mx/recursos_sat"; $lista_urls_api = getURLContent($url_api, 'GET', '', 1, array(), array('http', 'https'), 2); $this->guiasllenado_list_recursos = json_decode($lista_urls_api['content']); } public function getInfoTabGuiasLlenado(){ global $conf; $this->guiasllenado_list_const[] = array( "valor" => $conf->global->CFDIMX_MARCADORES, "label" => "CFDIMX_MARCADORES", "posicion" => 1, "header" => 1 ); $this->getGuiasLlenado(); } public function updateTabGuiasLllenado(User $user){ global $conf, $user; $error = 1; dolibarr_set_const($this->db, $this->guiasllenado_const, $this->guiasllenado_valor, 'chaine', 0, '', $conf->entity); $this->getGuiasLlenado(); if(!is_null($this->guiasllenado_list_recursos) && count($this->guiasllenado_list_recursos) > 0){ if($this->guiasllenado_valor == 1){ foreach ($this->guiasllenado_list_recursos as $recurso) { $marcador = new Bookmark($this->db); $marcador->fk_user = $user->id; $marcador->url = $recurso->url; $marcador->target = 1; $marcador->title = $recurso->nombre; $marcador->favicon = "none"; $marcador->position = $recurso->posicion; $id_mark = $marcador->create(); } $this->mensaje = "Se agregaron correctamente los marcadores."; }else{ $lista_marcadores = array(); foreach ($this->guiasllenado_list_recursos as $recurso) { $lista_marcadores[] = $recurso->posicion; } if(!is_null($lista_marcadores) && count($lista_marcadores) > 0){ $sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark"; $sql .= " WHERE position IN(".implode(",", $lista_marcadores).")"; $resql = $this->db->query($sql); } $this->mensaje = "Se eliminaron correctamente los marcadores."; } } return $error; } /** * Termina Funciones Pestaña SAT - Carga Masiva - Claves/Guias de Llenado */ /** * Inicia Funciones Pestaña Dolibarr - Factura/Pago */ public function getInfoTabFactura(){ global $conf, $langs; $opc_descuentos = 0; $sql = "SELECT count(*) as exist FROM ".MAIN_DB_PREFIX."cfdimx_descuentos"; $sql .= " WHERE"; $sql .= " entity_id = ".$conf->entity;; $res_descuentos = $this->db->query($sql); if($res_descuentos){ $obj_descuentos = $this->db->fetch_object($res_descuentos); if($obj_descuentos->exist == 0){ $sql_insert_descuentos = "INSERT INTO ".MAIN_DB_PREFIX."cfdimx_descuentos(entity_id,mostrar) VALUES(".$conf->entity.", 1)"; $res_insert_descuentos = $this->db->query($sql_insert_descuentos); } $sql_desc_list = "SELECT * FROM ".MAIN_DB_PREFIX."cfdimx_descuentos"; $sql_desc_list .= " WHERE entity_id = ".$conf->entity; $res_desc_list = $this->db->query($sql_desc_list); if($res_desc_list){ $obj_desc_list = $this->db->fetch_object($res_desc_list); $opc_descuentos = $obj_desc_list->mostrar; } } $this->factura_list_const[] = array( "valor" => $opc_descuentos, "label" => "CFDIMX_DESCUENTOS", "posicion" => 1, "header" => 1, "extrafields" => 0 ); $this->factura_list_const[] = array( "valor" => $conf->global->CFDIMX_DESC_PDF, "label" => "CFDIMX_DESC_PDF", "posicion" => 2, "header" => 1, "extrafields" => 0 ); $this->factura_list_const[] = array( "valor" => $conf->global->CFDIMX_LIM_DESC, "label" => "CFDIMX_LIM_DESC", "posicion" => 3, "header" => 1, "extrafields" => 0 ); $detalle_ret_ind = '

'; $detalle_ret_ind .= 'Se agregaron los siguientes extrafields en el módulo de Productos en el apartado de Campos adicionales y en el módulo de Facturas en el apartado de Campos adicionales (líneas).'; $detalle_ret_ind .= '

'; $detalle_ret_ind .= ''; $detalle_ret_ind .= ''; $detalle_ret_ind .= ''; $detalle_ret_ind .= ''; $detalle_ret_ind .= ''; $detalle_ret_ind .= ''; $detalle_ret_ind .= ''; $detalle_ret_ind .= ''; $detalle_ret_ind .= ''; $detalle_ret_ind .= ''; $detalle_ret_ind .= ''; $detalle_ret_ind .= ''; $detalle_ret_ind .= ''; $detalle_ret_ind .= '
Clave de traducción o cadenaCódigoTipo
Aplicar Retención Individualaplicar_ret_indvidualBoolean
'; $this->factura_list_const[] = array( "valor" => $conf->global->CFDIMX_RET_INDIVIDUALES, "label" => "CFDIMX_RET_INDIVIDUALES", "posicion" => 4, "header" => 1, "extrafields" => 1, "info_extrafields" => $detalle_ret_ind ); $this->factura_list_const[] = array( "valor" => $conf->global->CFDIMX_DEBUG_TIMBRADO, "label" => "CFDIMX_DEBUG_TIMBRADO", "posicion" => 5, "header" => 1, "extrafields" => 0 ); $detalle_extrafields_cce = '

'; $detalle_extrafields_cce .= 'Se agregaron los siguientes extrafields en el módulo de Productos en el apartado de Campos adicionales y en el módulo de Facturas en el apartado de Campos adicionales (líneas).'; $detalle_extrafields_cce .= '

'; $detalle_extrafields_cce .= ''; $detalle_extrafields_cce .= ''; $detalle_extrafields_cce .= ''; $detalle_extrafields_cce .= ''; $detalle_extrafields_cce .= ''; $detalle_extrafields_cce .= ''; $detalle_extrafields_cce .= ''; $detalle_extrafields_cce .= ''; $detalle_extrafields_cce .= ''; $detalle_extrafields_cce .= ''; $detalle_extrafields_cce .= ''; $detalle_extrafields_cce .= ''; $detalle_extrafields_cce .= ''; $detalle_extrafields_cce .= ''; $detalle_extrafields_cce .= ''; $detalle_extrafields_cce .= ''; $detalle_extrafields_cce .= ''; $detalle_extrafields_cce .= ''; $detalle_extrafields_cce .= ''; $detalle_extrafields_cce .= ''; $detalle_extrafields_cce .= ''; $detalle_extrafields_cce .= ''; $detalle_extrafields_cce .= ''; $detalle_extrafields_cce .= '
Clave de traducción o cadenaCódigoTipo
Fracción Arancelariaf_arancelariaLista desde Tabla (c_cfdimx_f_arancelaria)
Unidad AduanauaduanaLista desde Tabla (c_cfdimx_unidad_aduana)
Marca Aduanamarcaaduanavarchar
'; $this->factura_list_const[] = array( "valor" => $conf->global->CFDIMX_EXTRAFIELDS_CCE, "label" => "CFDIMX_EXTRAFIELDS_CCE", "posicion" => 6, "header" => 1, "extrafields" => 1, "info_extrafields" => $detalle_extrafields_cce ); // $this->factura_list_const[] = array( // "valor" => $conf->global->CFDIMX_EXTRAFIELDS_CP, // "label" => "CFDIMX_EXTRAFIELDS_CP", // "posicion" => 7, // "header" => 1 // ); // $alerta_timbres[] = array("valor" => $conf->global->CFDIMX_ALERTA_TIMBRES, "label" => "CFDIMX_ALERTA_TIMBRES"); $alerta_timbres[] = array("valor" => $conf->global->CFDIMX_MIN_TIMBRES, "label" => "CFDIMX_MIN_TIMBRES"); $this->factura_list_const[] = array( "valor" => $conf->global->CFDIMX_ALERTA_TIMBRES, "label" => "CFDIMX_ALERTA_TIMBRES", "posicion" => 8, "header" => 2, "const" => $alerta_timbres, "extrafields" => 0 ); $this->factura_list_const[] = array( "valor" => $conf->global->CFDIMX_FAC_DIAS_CFDI_REL, "label" => "CFDIMX_FAC_DIAS_CFDI_REL", "posicion" => 9, "header" => 2, "extrafields" => 0 ); // $pdf_fac_txt[] = array("valor" => $conf->global->CFDIMX_PDF_FAC_TXT_LIBRE, "label" => "CFDIMX_PDF_FAC_TXT_LIBRE"); // $pdf_fac_txt[] = array("valor" => $conf->global->CFDIMX_PDF_FAC_TXT_LIBRE_TITULO, "label" => "CFDIMX_PDF_FAC_TXT_LIBRE_TITULO"); // $pdf_fac_txt[] = array("valor" => $conf->global->CFDIMX_PDF_FAC_TXT_LIBRE_CONTENIDO, "label" => "CFDIMX_PDF_FAC_TXT_LIBRE_CONTENIDO"); // $this->factura_list_const[] = array( // "valor" => $conf->global->CFDIMX_PDF_FAC_TXT_LIBRE, // "label" => "CFDIMX_PDF_FAC_TXT_LIBRE", // "posicion" => 10, // "header" => 1, // "const" => $pdf_fac_txt // ); $this->factura_list_const[] = array( "valor" => $conf->global->CFDIMX_ADMIN_LISTA_EMISORES, "label" => "CFDIMX_ADMIN_LISTA_EMISORES", "posicion" => 11, "header" => 1, "extrafields" => 2, "info_extrafields" => $langs->trans("CFDIMX_ADMIN_LISTA_EMISORES_DETAIL") ); $this->factura_list_const[] = array( "valor" => $conf->global->CFDIMX_FAC_RET_LOCALES, "label" => "CFDIMX_FAC_RET_LOCALES", "posicion" => 12, "header" => 1, "extrafields" => 0 ); $this->factura_list_const[] = array( "valor" => $conf->global->CFDIMX_NUM_LIST_FAC_TIM_HOME, "label" => "CFDIMX_NUM_LIST_FAC_TIM_HOME", "posicion" => 13, "header" => 2, "extrafields" => 0 ); $this->factura_list_const[] = array( "valor" => $conf->global->CFDIMX_NUM_LIST_FAC_NOTIM_HOME, "label" => "CFDIMX_NUM_LIST_FAC_NOTIM_HOME", "posicion" => 14, "header" => 2, "extrafields" => 0 ); $detalle_numpedimento = '

'; $detalle_numpedimento .= 'Se agregaron los siguientes extrafields en el módulo de Productos en el apartado de Campos adicionales y en el módulo de Facturas en el apartado de Campos adicionales (líneas). Tambien se tomará en cuenta si esta lleno el campo '.$langs->trans("CustomCode").' en la Ficha del Producto.'; $detalle_numpedimento .= '

'; $detalle_numpedimento .= ''; $detalle_numpedimento .= ''; $detalle_numpedimento .= ''; $detalle_numpedimento .= ''; $detalle_numpedimento .= ''; $detalle_numpedimento .= ''; $detalle_numpedimento .= ''; $detalle_numpedimento .= ''; $detalle_numpedimento .= ''; $detalle_numpedimento .= ''; $detalle_numpedimento .= ''; $detalle_numpedimento .= ''; $detalle_numpedimento .= ''; $detalle_numpedimento .= '
Clave de traducción o cadenaCódigoTipo
Información Aduanera - Num. PedimentonumpedimentoCadena (1 línea)
'; $this->factura_list_const[] = array( "valor" => $conf->global->CFDIMX_NUM_PEDIMENTO, "label" => "CFDIMX_NUM_PEDIMENTO", "posicion" => 15, "header" => 1, "extrafields" => 1, "info_extrafields" => $detalle_numpedimento ); $detalle_ish = '

'; $detalle_ish .= 'Se agregaron los siguientes extrafields en el módulo de Productos en el apartado de Campos adicionales y en el módulo de Facturas en el apartado de Campos adicionales (líneas).'; $detalle_ish .= '

'; $detalle_ish .= ''; $detalle_ish .= ''; $detalle_ish .= ''; $detalle_ish .= ''; $detalle_ish .= ''; $detalle_ish .= ''; $detalle_ish .= ''; $detalle_ish .= ''; $detalle_ish .= ''; $detalle_ish .= ''; $detalle_ish .= ''; $detalle_ish .= ''; $detalle_ish .= ''; $detalle_ish .= ''; $detalle_ish .= ''; $detalle_ish .= ''; $detalle_ish .= ''; $detalle_ish .= ''; $detalle_ish .= '
Clave de traducción o cadenaCódigoTipo
Impuesto sobre Hospedaje (ISH)prodcfishCadena (1 línea)
Etiqueta para Impuesto sobre Hospedaje (ISH)prodcfish_labelCadena (1 línea)
'; $this->factura_list_const[] = array( "valor" => $conf->global->CFDIMX_ISH, "label" => "CFDIMX_ISH", "posicion" => 16, "header" => 1, "extrafields" => 1, "info_extrafields" => $detalle_ish ); $detalle_cuentapredial = '

'; $detalle_cuentapredial .= 'Se agregaron los siguientes extrafields en el módulo de Productos en el apartado de Campos adicionales y en el módulo de Facturas en el apartado de Campos adicionales (líneas).'; $detalle_cuentapredial .= '

'; $detalle_cuentapredial .= ''; $detalle_cuentapredial .= ''; $detalle_cuentapredial .= ''; $detalle_cuentapredial .= ''; $detalle_cuentapredial .= ''; $detalle_cuentapredial .= ''; $detalle_cuentapredial .= ''; $detalle_cuentapredial .= ''; $detalle_cuentapredial .= ''; $detalle_cuentapredial .= ''; $detalle_cuentapredial .= ''; $detalle_cuentapredial .= ''; $detalle_cuentapredial .= ''; $detalle_cuentapredial .= '
Clave de traducción o cadenaCódigoTipo
Cuenta PredialcuentapredialCadena (1 línea)
'; $this->factura_list_const[] = array( "valor" => $conf->global->CFDIMX_CUENTA_PREDIAL, "label" => "CFDIMX_CUENTA_PREDIAL", "posicion" => 17, "header" => 1, "extrafields" => 1, "info_extrafields" => $detalle_cuentapredial ); $detalle_facture_pdf = '

'; $detalle_facture_pdf = 'Se habilita una nueva pestaña que se llama Factura - PDF, en la cual se pueden definir los colores del PDF, asi como tambien se puede agregar un campo de texto libre para agregar información adicional en cada Factura.'; $detalle_facture_pdf .= '

'; $detalle_facture_pdf .= ''; // Activar // $this->factura_list_const[] = array( // "valor" => $conf->global->CFDIMX_PDF_FAC_PERSONALIZACION, // "label" => "CFDIMX_PDF_FAC_PERSONALIZACION", // "posicion" => 12, // "header" => 2, // "extrafields" => 1, // "info_extrafields" => $detalle_facture_pdf // ); /** * Variables para el apartado de PDF */ $info = array(); $info[] = array("valor" => $conf->global->CFDIMX_DESC_PROD_CAT_REF, "label" => "CFDIMX_DESC_PROD_CAT_REF"); $this->factura_list_const[] = array( "posicion" => 1, "header" => 3, "const" => $info ); $info = array(); $info[] = array("valor" => $conf->global->CFDIMX_DESC_PROD_CAT_ETIQUETA, "label" => "CFDIMX_DESC_PROD_CAT_ETIQUETA"); $this->factura_list_const[] = array( "posicion" => 2, "header" => 3, "const" => $info ); $info = array(); $info[] = array("valor" => $conf->global->CFDIMX_DESC_PROD_CAT_DESC, "label" => "CFDIMX_DESC_PROD_CAT_DESC"); $info[] = array("valor" => $conf->global->CFDIMX_DESC_PROD_NO_CAT_DESC, "label" => "CFDIMX_DESC_PROD_NO_CAT_DESC"); $this->factura_list_const[] = array( "posicion" => 3, "header" => 3, "const" => $info ); $info = array(); $info[] = array("valor" => $conf->global->CFDIMX_DESC_PROD_CAT_NOIDENTICFDI, "label" => "CFDIMX_DESC_PROD_CAT_NOIDENTICFDI"); $info[] = array("valor" => $conf->global->CFDIMX_DESC_PROD_NO_CAT_NOIDENTICFDI, "label" => "CFDIMX_DESC_PROD_NO_CAT_NOIDENTICFDI"); $this->factura_list_const[] = array( "posicion" => 4, "header" => 3, "const" => $info ); if($conf->global->CFDIMX_CUENTA_PREDIAL == 1){ $info = array(); $info[] = array("valor" => $conf->global->CFDIMX_DESC_PROD_CAT_CTA_PREDIAL, "label" => "CFDIMX_DESC_PROD_CAT_CTA_PREDIAL"); $info[] = array("valor" => $conf->global->CFDIMX_DESC_PROD_NO_CAT_CTA_PREDIAL, "label" => "CFDIMX_DESC_PROD_NO_CAT_CTA_PREDIAL"); $this->factura_list_const[] = array( "posicion" => 5, "header" => 3, "const" => $info ); } $archivo = dol_buildpath('/cfdimx/facture/card_cce20.php'); if(file_exists($archivo) && $conf->global->CFDIMX_EXTRAFIELDS_CCE == 1){ $info = array(); $info[] = array("valor" => $conf->global->CFDIMX_DESC_PROD_CAT_U_ADUANA, "label" => "CFDIMX_DESC_PROD_CAT_U_ADUANA"); $info[] = array("valor" => $conf->global->CFDIMX_DESC_PROD_NO_CAT_U_ADUANA, "label" => "CFDIMX_DESC_PROD_NO_CAT_U_ADUANA"); $this->factura_list_const[] = array( "posicion" => 6, "header" => 3, "const" => $info ); $info = array(); $info[] = array("valor" => $conf->global->CFDIMX_DESC_PROD_CAT_F_ARAN, "label" => "CFDIMX_DESC_PROD_CAT_F_ARAN"); $info[] = array("valor" => $conf->global->CFDIMX_DESC_PROD_NO_CAT_F_ARAN, "label" => "CFDIMX_DESC_PROD_NO_CAT_F_ARAN"); $this->factura_list_const[] = array( "posicion" => 6, "header" => 3, "const" => $info ); $info = array(); $info[] = array("valor" => $conf->global->CFDIMX_DESC_PROD_CAT_NUM_PEDIMENTO, "label" => "CFDIMX_DESC_PROD_CAT_NUM_PEDIMENTO"); $info[] = array("valor" => $conf->global->CFDIMX_DESC_PROD_NO_CAT_NUM_PEDIMENTO, "label" => "CFDIMX_DESC_PROD_NO_CAT_NUM_PEDIMENTO"); $this->factura_list_const[] = array( "posicion" => 6, "header" => 3, "const" => $info ); $info = array(); $info[] = array("valor" => $conf->global->CFDIMX_DESC_PROD_CAT_MARCA_ADUANA, "label" => "CFDIMX_DESC_PROD_CAT_MARCA_ADUANA"); $info[] = array("valor" => $conf->global->CFDIMX_DESC_PROD_NO_CAT_MARCA_ADUANA, "label" => "CFDIMX_DESC_PROD_NO_CAT_MARCA_ADUANA"); $this->factura_list_const[] = array( "posicion" => 6, "header" => 3, "const" => $info ); } } public function updateTabFactura(User $user){ global $conf; $extrafields = new ExtraFields($this->db); $error = 1; if(in_array($this->factura_const, array('CFDIMX_FAC_DIAS_CFDI_REL', 'CFDIMX_NUM_LIST_FAC_TIM_HOME', 'CFDIMX_NUM_LIST_FAC_NOTIM_HOME'))){ $this->factura_valor = $this->factura_limite; } if($this->factura_const == 'CFDIMX_ALERTA_TIMBRES'){ dolibarr_set_const($this->db, 'CFDIMX_MIN_TIMBRES', $this->factura_limite, 'chaine', 0, '', $conf->entity); } // Activacion de variables globales dolibarr_set_const($this->db, $this->factura_const, $this->factura_valor, 'chaine', 0, '', $conf->entity); // Funciones Especificas if($this->factura_const == 'CFDIMX_DESCUENTOS'){ $sql = "UPDATE ".MAIN_DB_PREFIX."cfdimx_descuentos"; $sql .= " SET"; $sql .= " mostrar = ".$this->factura_valor; $sql .= " WHERE entity_id = ".$conf->entity; // print $sql; $res = $this->db->query($sql); } if($this->factura_const == 'CFDIMX_RET_INDIVIDUALES'){ $action = ($this->factura_valor == 0 ? 1 : 2); #Extrafield aplicar_ret_individual - product $sql = "SELECT * FROM ".MAIN_DB_PREFIX."extrafields"; $sql .= " WHERE"; $sql .= ' name LIKE "aplicar_ret_individual" AND elementtype = "product"'; $sql .= " AND entity = ".$conf->entity; $resql = $this->db->query($sql); if($resql){ $num = $this->db->num_rows($resql); if ($num > 0) { $i = 0; while ($i < $num) { $obj = $this->db->fetch_object($resql); $sql = "UPDATE ".MAIN_DB_PREFIX."extrafields"; $sql .= " SET"; $sql .= " list = ".($action == 1 ? 0 : 1); $sql .= " WHERE"; $sql .= " rowid = ".$obj->rowid; // print $sql; $res = $this->db->query($sql); $i++; } }else{ $extrafields->addExtraField('aplicar_ret_individual', 'Aplicar Retención Individual', 'boolean', 104, '', 'product', 0, 0, '', 'a:1:{s:7:"options";a:1:{s:0:"";N;}}',1,'',1); } } #Extrafield aplicar_ret_individual - facturedet $sql = "SELECT * FROM ".MAIN_DB_PREFIX."extrafields"; $sql .= " WHERE"; $sql .= ' name LIKE "aplicar_ret_individual" AND elementtype = "facturedet"'; $sql .= " AND entity = ".$conf->entity; $resql = $this->db->query($sql); if($resql){ $num = $this->db->num_rows($resql); if ($num > 0) { $i = 0; while ($i < $num) { $obj = $this->db->fetch_object($resql); $sql = "UPDATE ".MAIN_DB_PREFIX."extrafields"; $sql .= " SET"; $sql .= " list = ".($action == 1 ? 0 : 1); $sql .= " WHERE"; $sql .= " rowid = ".$obj->rowid; // print $sql; $res = $this->db->query($sql); $i++; } }else{ $extrafields->addExtraField('aplicar_ret_individual', 'Aplicar Retención Individual', 'boolean', 104, '', 'facturedet', 0, 0, '', 'a:1:{s:7:"options";a:1:{s:0:"";N;}}',1,'',1); } } } if($this->factura_const == 'CFDIMX_EXTRAFIELDS_CCE'){ $action = ($this->factura_valor == 0 ? 1 : 2); $sql = "SELECT * FROM ".MAIN_DB_PREFIX."extrafields"; $sql .= " WHERE"; $sql .= ' name LIKE "precio_usd" AND elementtype = "product"'; $sql .= " AND entity = ".$conf->entity; // print $sql.'
'; $resql = $this->db->query($sql); if($resql){ $num = $this->db->num_rows($resql); if($num > 0){ $i = 0; while ($i < $num) { $obj = $this->db->fetch_object($resql); $sql = "UPDATE ".MAIN_DB_PREFIX."extrafields"; $sql .= " SET"; $sql .= " list = ".($action == 1 ? 0 : 1); $sql .= " WHERE"; $sql .= " rowid = ".$obj->rowid; // print $sql; $res = $this->db->query($sql); $i++; } }else{ $extrafields->addExtraField('precio_usd', 'Precio USD', 'varchar', 112, '255', 'product', 0, 0, '', 'a:1:{s:7:"options";a:1:{s:0:"";N;}}',1,'',1); } } ##Campo marca $sql = "SELECT * FROM ".MAIN_DB_PREFIX."extrafields"; $sql .= " WHERE"; $sql .= ' name LIKE "marcaaduana" AND elementtype = "product"'; $sql .= " AND entity = ".$conf->entity; $resql = $this->db->query($sql); if($resql){ $num = $this->db->num_rows($resql); if($num > 0){ $i = 0; while ($i < $num) { $obj = $this->db->fetch_object($resql); $sql = "UPDATE ".MAIN_DB_PREFIX."extrafields"; $sql .= " SET"; $sql .= " list = ".($action == 1 ? 0 : 1); $sql .= " WHERE"; $sql .= " rowid = ".$obj->rowid; // print $sql; $res = $this->db->query($sql); $i++; } }else{ $extrafields->addExtraField('marcaaduana', 'Marca Aduana', 'varchar', 113, '255', 'product', 0, 0, '', 'a:1:{s:7:"options";a:1:{s:0:"";N;}}',1,'',1); } } #Clave Fraccion Arancelaria $sql = 'SELECT * FROM '.MAIN_DB_PREFIX.'extrafields WHERE name LIKE "f_arancelaria" AND elementtype="product" AND entity = '.$conf->entity; //echo $sql; $resql = $this->db->query($sql); if($resql){ $num = $this->db->num_rows($resql); if($num > 0) { $i = 0; while ($i < $num) { $obj = $this->db->fetch_object($resql); if ($obj->type == 'varchar') { $sql = 'UPDATE '.MAIN_DB_PREFIX.'extrafields'; $sql .= ' SET'; $sql .= ' type="sellist", size="", alwayseditable=1, list=1'; $sql .= ' WHERE'; $sql .= " rowid = ".$obj->rowid; //echo $sql."
"; $this->db->query($sql); } $sql = "UPDATE ".MAIN_DB_PREFIX."extrafields"; $sql .= " SET"; $sql .= " list = ".($action == 1 ? 0 : 1); $sql .= " WHERE"; $sql .= " rowid = ".$obj->rowid; // print $sql; $res = $this->db->query($sql); $i++; } }else{ $extrafields->addExtraField('f_arancelaria', 'Fracción Arancelaria', 'sellist', 108, '', 'product', 0, 0, '', 'a:1:{s:7:"options";a:1:{s:43:"c_cfdimx_f_arancelaria:label:code::active=1";N;}}'); } } #Clave Unidad Aduana $sql = 'SELECT * FROM '.MAIN_DB_PREFIX.'extrafields WHERE name LIKE "uaduana" AND elementtype="facturedet" AND entity = '.$conf->entity; //echo $sql; $resql = $this->db->query($sql); if($resql){ $num = $this->db->num_rows($resql); if($num > 0){ $i = 0; while ($i < $num) { $obj = $this->db->fetch_object($resql); if ($obj->type == 'varchar') { $sql = 'UPDATE '.MAIN_DB_PREFIX.'extrafields'; $sql .= ' SET'; $sql .= ' type="sellist", size="255", alwayseditable=1, list=1'; $sql .= ' WHERE'; $sql .= " rowid = ".$obj->rowid; //echo $sql."
"; $this->db->query($sql); } $sql = "UPDATE ".MAIN_DB_PREFIX."extrafields"; $sql .= " SET"; $sql .= " list = ".($action == 1 ? 0 : 1); $sql .= " WHERE"; $sql .= " rowid = ".$obj->rowid; // print $sql; $res = $this->db->query($sql); $i++; } }else{ $extrafields->addExtraField('uaduana', 'Unidad Aduana', 'sellist', 107, '', 'facturedet', 0, 0, '', 'a:1:{s:7:"options";a:1:{s:43:"c_cfdimx_unidad_aduana:label:code::active=1";N;}}'); } } } if($this->factura_const == 'CFDIMX_NUM_PEDIMENTO'){ $sql = "UPDATE ".MAIN_DB_PREFIX."extrafields"; $sql .= " SET "; $sql .= " list = ".$this->factura_valor; $sql .= " WHERE"; $sql .= " elementtype IN('product', 'facturedet')"; $sql .= " AND name = 'numpedimento'"; $sql .= " AND entity = ".$conf->entity; $resql = $this->db->query($sql); } if($this->factura_const == 'CFDIMX_ISH'){ $sql = "UPDATE ".MAIN_DB_PREFIX."extrafields"; $sql .= " SET "; $sql .= " list = ".$this->factura_valor; $sql .= " WHERE"; $sql .= " elementtype IN('product', 'facturedet')"; $sql .= " AND name IN('prodcfish','prodcfish_label')"; $sql .= " AND entity = ".$conf->entity; $resql = $this->db->query($sql); } if($this->factura_const == 'CFDIMX_CUENTA_PREDIAL'){ $sql = "UPDATE ".MAIN_DB_PREFIX."extrafields"; $sql .= " SET "; $sql .= " list = ".$this->factura_valor; $sql .= " WHERE"; $sql .= " elementtype IN('product', 'facturedet')"; $sql .= " AND name IN('cuentapredial')"; $sql .= " AND entity = ".$conf->entity; $resql = $this->db->query($sql); } return $error; } public function getInfoTabPago(){ global $conf; $this->pago_list_const[] = array( "valor" => $conf->global->CFDIMX_PAGOS_DEBUG_TIMBRADO, "label" => "CFDIMX_PAGOS_DEBUG_TIMBRADO", "posicion" => 1, "header" => 1 ); $this->pago_list_const[] = array( "valor" => $conf->global->CFDIMX_PAGOS_C_DESC, "label" => "CFDIMX_PAGOS_C_DESC", "posicion" => 3, "header" => 2, "input" => "descripcion" ); $this->pago_list_const[] = array( "valor" => $conf->global->CFDIMX_PAGOS_C_PRODSERV, "label" => "CFDIMX_PAGOS_C_PRODSERV", "posicion" => 1, "header" => 2, "input" => "claveprodserv" ); $this->pago_list_const[] = array( "valor" => $conf->global->CFDIMX_PAGOS_C_UMED, "label" => "CFDIMX_PAGOS_C_UMED", "posicion" => 2, "header" => 2, "input" => "unidadmedida" ); // $pdf_cp_txt_libre = $conf->global->CFDIMX_PDF_CP_TXT_LIBRE; // $pdf_cp_txt_libre_titulo = $conf->global->CFDIMX_PDF_CP_TXT_LIBRE_TITULO; // $pdf_cp_txt_libre_contenido = $conf->global->CFDIMX_PDF_CP_TXT_LIBRE_CONTENIDO; } public function updateTabPago(User $user){ global $conf; $error = 1; // Activacion de variables globales if($this->pago_const == 'CFDIMX_PAGOS_DEBUG_TIMBRADO'){ dolibarr_set_const($this->db, $this->pago_const, $this->pago_valor, 'chaine', 0, '', $conf->entity); } if($this->pago_const == 'CFDIMX_PAGOS'){ dolibarr_set_const($this->db, 'CFDIMX_PAGOS_C_DESC', $this->pago_descripcion, 'chaine', 0, '', $conf->entity); dolibarr_set_const($this->db, 'CFDIMX_PAGOS_C_PRODSERV', $this->pago_claveprodserv, 'chaine', 0, '', $conf->entity); dolibarr_set_const($this->db, 'CFDIMX_PAGOS_C_UMED', $this->pago_unidadmedida, 'chaine', 0, '', $conf->entity); } return $error; } /** * Termina Funciones Pestaña Dolibarr - Factura/Pago */ } ?>