* Copyright (C) 2022 Alice Adminson * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file cfdixml/admin/setup.php * \ingroup cfdixml * \brief Cfdixml setup page. */ // Load Dolibarr environment $res = 0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; } // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; } if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; } // Try main.inc.php using relative path if (!$res && file_exists("../../main.inc.php")) { $res = @include "../../main.inc.php"; } if (!$res && file_exists("../../../main.inc.php")) { $res = @include "../../../main.inc.php"; } if (!$res) { die("Include of main fails"); } global $langs, $user; // Libraries require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; require_once '../lib/cfdixml.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; //require_once "../class/myclass.class.php"; // Translations $langs->loadLangs(array("admin", "cfdixml@cfdixml")); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('cfdixmlsetup', 'globalsetup')); // Access control if (!$user->admin) { accessforbidden(); } // Parameters $action = GETPOST('action', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); $modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php $value = GETPOST('value', 'alpha'); $label = GETPOST('label', 'alpha'); $scandir = GETPOST('scan_dir', 'alpha'); $type = 'myobject'; $typeEndpoint = 0; $error = 0; $setupnotempty = 0; // Set this to 1 to use the factory to manage constants. Warning, the generated module will be compatible with version v15+ only $useFormSetup = 1; if (!class_exists('FormSetup')) { // For retrocompatibility Dolibarr < 16.0 if (floatval(DOL_VERSION) < 16.0 && !class_exists('FormSetup')) { require_once __DIR__.'/../backport/v16/core/class/html.formsetup.class.php'; } else { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php'; } } $formSetup = new FormSetup($db); $formcompany = new FormCompany($db); // Hôte $item = $formSetup->newItem('NO_PARAM_JUST_TEXT'); $item->fieldOverride = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST']; $item->cssClass = 'minwidth500'; /* * Actions */ // For retrocompatibility Dolibarr < 15.0 if ( versioncompare(explode('.', DOL_VERSION), array(15)) < 0 && $action == 'update' && !empty($user->admin)) { $formSetup->saveConfFromPost(); } include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if($action == 'save'){ //Upload files // if ($_FILES["csd"] || $_FILES["key"]) { // $upload_dir = $conf->cfdixml->dir_output . '/' . get_exdir(0, 0, 0, 1, $object, 'cfdimx'); // $flag = 0; // $cer_file = $_FILES["csd"]["name"] ? $upload_dir . basename($_FILES["csd"]["name"]) : null; // $key_file = $_FILES["key"]["name"] ? $upload_dir . basename($_FILES["key"]["name"]) : null; // if($cer_file){ // if(move_uploaded_file($_FILES["csd"]["tmp_name"],$cer_file)) $flag++; // } // if($flag > 0) dolibarr_set_const($db, "CFDIXML_CER_FILE", $cer_file, 'chaine', 1, '', $conf->entity); // if($key_file){ // if(move_uploaded_file($_FILES["key"]["tmp_name"],$key_file)) $flag++; // } // if($flag > 0) dolibarr_set_const($db, "CFDIXML_KEY_FILE", $key_file, 'chaine', 1, '', $conf->entity); // } if(GETPOST('resico_tax')) dolibarr_set_const($db, "CFDIXML_RESICO_TAX", GETPOST('resico_tax'), 'chaine', 1, '', $conf->entity); // if(GETPOST('setep')) dolibarr_set_const($db, "CFDIXML_WS_MODE", GETPOST('setep'), 'chaine', 1, '', $conf->entity); // if(GETPOST('epprod')) dolibarr_set_const($db, "CFDIXML_WS_PRODUCTION", GETPOST('epprod'), 'chaine', 1, '', $conf->entity); // if(GETPOST('eptest')) dolibarr_set_const($db, "CFDIXML_WS_TEST", GETPOST('eptest'), 'chaine', 1, '', $conf->entity); // if(GETPOST('passtoken')) dolibarr_set_const($db, "CFDIXML_WS_TOKEN", GETPOST('passtoken'), 'chaine', 1, '', $conf->entity); // if(GETPOST('typent_id')) dolibarr_set_const($db, "CFDIXML_RESICO", GETPOST('typent_id'), 'chaine', 1, '', $conf->entity); } if($conf->global->CFDIXML_WS_MODE == 'PRODUCTION') $epprod = 'checked'; if($conf->global->CFDIXML_WS_MODE == 'TEST') $eptest = 'checked'; if(!$conf->global->CFDIXML_WS_MODE) $eptest = 'checked'; if($conf->global->CFDIXML_WS_MODE){ if($conf->global->CFDIXML_WS_MODE == 'PRODUCTION') $endpoint = $conf->global->CFDIXML_WS_PRODUCTION; if($conf->global->CFDIXML_WS_MODE == 'TEST') $endpoint = $conf->global->CFDIXML_WS_TEST; $check = curl_init($endpoint); if(!$check) setEventMessage('Error en el webservice seleccionado','warnings'); } $emisor = getEmisor($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE); $rfiscal = $emisor['RegimenFiscal']; /* * View */ $form = new Form($db); $help_url = ''; $page_name = "CfdixmlSetupTax"; llxHeader('', $langs->trans($page_name), $help_url); // Subheader $linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup_tax'); // Configuration header $head = cfdixmlAdminPrepareHead(); print dol_get_fiche_head($head, 'taxes', $langs->trans($page_name), -1, "cfdixml@cfdixml"); // Setup page goes here echo '' . $langs->trans("CfdiutilsSetupPage") . '

'; print '
'; print ''; print ''; print ''; print ''; print ''; // print ''; // print ''; // print ''; // if ($csd) { // print ''; // } // print ''; // if ($key) { // print ''; // } // print ''; // print ''; // // print '
';print_r(getEmisor($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE));exit;
// echo $rfiscal;
// if($rfiscal == 626){
// 	print '
'; // } print '
' . $langs->trans("Parameter") . '' . $langs->trans("Value") . '
Impuesto Resico
Endpoint Pruebas
'; // print 'Seleccione el endpoint:'; // print '
'; // print '
'; // print '
Archivo CSD CER
Ruta CSD CER' . $csd . '
Archivo CSD KEY
Ruta CSD KEY' . $key . '
Contraseña de los certificados
Token
Seleccionar tipo de RESICO'.$form->selectarray("typent_id", $formcompany->typent_array(0), $conf->global->CFDIXML_RESICO, 1, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1).'
'; print '
'; print ''; print '
'; print '
'; print '
'; // Page end print dol_get_fiche_end(); llxFooter(); $db->close(); //a4f2ebbb97f82871f509c579f8ea9f0cb2efab7f0126af4846e9edda4565