Heray-Was-Here
Server : Apache
System : Linux mail.lomejor.cr 6.8.0-1059-azure #65~22.04.1-Ubuntu SMP Thu May 28 16:59:19 UTC 2026 x86_64
User : www-data ( 33)
PHP Version : 8.2.31
Disable Function : NONE
Directory :  /var/www/erp/htdocs/custom/crfact/admin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/erp/htdocs/custom/crfact/admin/config.php
<?php
/* crindicadores: send SMS to thirdparties by crindicadores.com
/* Copyright (C) 2012 Maxime MANGIN <maxime@tuxserv.fr>
 *
 * 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 <http://www.gnu.org/licenses/>.
 */
 
/**
 * \file    admin/setup.php
 * \ingroup crfact
 * \brief   crfact setup page.
 *
 * Based on smsdecanet module.
 */

define('ERROR_NO_VALID_USER', "-300");
define('ERROR_USER_WRONG_LOGIN_INFO', "-301");
define('ERROR_USER_NO_VALID_SESSION', "-302");
define('ERROR_USER_ACCESS_DENIED', "-303");
define('ERROR_USER_EXISTS', "-304");
define('ERROR_DB_NO_RESULTS_FOUND', "-200");
define('ERROR_BAD_REQUEST', "-1");

define('ERROR_CLAVE_REQUEST', "-140");
define('ERROR_CONSULTAR_REQUEST', "-150");
define('ERROR_FACTURADOR_REQUEST', "-180");
define('ERROR_FILEUPLOADER_REQUEST', "-190");
define('ERROR_GENXML_REQUEST', "-191");
define('ERROR_SEND_REQUEST', "-193");
define('ERROR_SIGNXML_REQUEST', "-195");
define('ERROR_TOKEN_REQUEST', "-196");



// Load Dolibarr environment
//require(DOL_DOCUMENT_ROOT."/main.inc.php");
if (false === (@include '../../main.inc.php')) {  // From htdocs directory
	require '../../../main.inc.php'; // From "custom" directory
}

global $langs, $user;

// Libraries
require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php";
require_once("../core/modules/modCRFact.class.php");
include_once('../class/crfact.class.php');
dol_include_once('/crfact/lib/crfact.lib.php');


// Translations
//$langs->load("admin");
$langs->load("crfact@CRFact");


// Access control
if (! $user->admin) {
	accessforbidden();
}


// Parameters
$action = GETPOST('action', 'alpha');


/*
 * Actions
 */
$errors = [];
$error = 0;

if ($action == 'setdallowfreeprods') {	
    $setdallowfreeprods= GETPOST('value', 'int');
    $res = dolibarr_set_const($db, "CRFACT_ALLOW_FREE_PRODUCT", $setdallowfreeprods, 'yesno', 0, '', $conf->entity);
    if (!$res > 0)
        $error++;
}

if ($action == 'setaddqrcode') {	
    $setaddqrcode= GETPOST('value', 'int');
    $res = dolibarr_set_const($db, "CRFACT_ADD_QR_CODE", $setaddqrcode, 'yesno', 0, '', $conf->entity);
    if (!$res > 0)
        $error++;
}

if ($action == 'set_crfact_options') {
    $value = GETPOST('FACTURE_DUE_INTERVAL_VALITATION', "alpha");
    $res = dolibarr_set_const($db, 'FACTURE_DUE_INTERVAL_VALITATION', $value, 'chaine', 0, '', $conf->entity);
    if (!($res > 0)) {
        $errors[] = $db->lasterror();
        $error++;
    }

	$value = GETPOST('CRFACT_TIPO_CODCOMERCIAL', "alpha");
    $res = dolibarr_set_const($db, 'CRFACT_TIPO_CODCOMERCIAL', $value, 'chaine', 0, '', $conf->entity);
    if (!($res > 0)) {
        $errors[] = $db->lasterror();
        $error++;
    }

	$value = GETPOST('DEFAULT_CONDICION_VENTAS', "alpha");
    $res = dolibarr_set_const($db, 'DEFAULT_CONDICION_VENTAS', $value, 'chaine', 0, '', $conf->entity);
    if (!($res > 0)) {
        $errors[] = $db->lasterror();
        $error++;
    }

	$value = GETPOST('CRFACT_MASK_INVOICE_TE', "alpha");
    $res = dolibarr_set_const($db, 'CRFACT_MASK_INVOICE_TE', $value, 'chaine', 0, '', $conf->entity);
    if (!($res > 0)) {
        $errors[] = $db->lasterror();
        $error++;
    }
	
	$value = GETPOST('CRFACT_MASK_INVOICE_FEE', "alpha");
    $res = dolibarr_set_const($db, 'CRFACT_MASK_INVOICE_FEE', $value, 'chaine', 0, '', $conf->entity);
    if (!($res > 0)) {
        $errors[] = $db->lasterror();
        $error++;
    }

	$value = GETPOST('CRFACT_FE_EMAIL_DEFAULT', "alpha");
    $res = dolibarr_set_const($db, 'CRFACT_FE_EMAIL_DEFAULT', $value, 'chaine', 0, '', $conf->entity);
    if (!($res > 0)) {
        $errors[] = $db->lasterror();
        $error++;
    }
}

/*
 * View
 */
 
$page_name = "CRFactSetup";
llxHeader('', $langs->trans($page_name));

// Subheader
$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">' . $langs->trans("BackToModuleList") . '</a>';
print load_fiche_titre($langs->trans($page_name), $linkback,'title_setup');
print "<br>\n";

// Configuration header

$head=crfact_admin_prepare_head();
//dol_get_fiche_head( $head, 'settings', $langs->trans("Module500998Name"), 0, "crfact@CRFact");

dol_fiche_head($head, 'config', $langs->trans("Module500998Name"), 0, 'crfact@CRFact');

$var=true;

	if ( $conf->global->CRFACT_USERNAME && $conf->global->CRFACT_PASSWORD && $conf->global->CRFACT_URL ){
		$crfactparam = array(
			'userName' => $conf->global->CRFACT_USERNAME,
			'pwd' => $conf->global->CRFACT_PASSWORD
		);
		$CRFact = new crfact($db);
		$response = $CRFact->Request('users','users_log_me_in',$crfactparam,$conf->global->CRFACT_URL);

		if ( $response->resp == ERROR_USER_WRONG_LOGIN_INFO ){
			$errormsg = $response->resp;
		}else{
			dolibarr_set_const($db, "CRFACT_MASTERID",$response->resp->idUser,'chaine',0,'Master ID del API CRFact',$conf->entity,0);
			dolibarr_set_const($db, "CRFACT_MASTERKEY", $response->resp->sessionKey,'chaine',0,'Password Maestro registrado en el API CRFact',$conf->entity,0);
		}
		echo '<br>'.$langs->trans('Connected').' - (<a href="https://'.parse_url($conf->global->CRFACT_URL)["host"].'/Facturador/adminDash/" target="_blank"><strong>'.$langs->trans('ViewAPIAcount').'</strong></a>)';
	}else{
		echo '<br>'.$errormsg .' - (<a href="https://'.parse_url($conf->global->CRFACT_URL)["host"].'/Facturador/adminDash/" target="_blank"><strong>'.$langs->trans('CreateAPIAcount').'</strong></a>)';
	}

	print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
	print '<input type="hidden" name="action" value="set_crfact_options">';

	print '<div class="div-table-responsive-no-min">';
	print '<table class="noborder centpercent">';
	print '<tr class="liste_titre">';
	print '<td width="20%">'.$langs->trans("Parameters").'</td>'."\n";
	print '<td>'.$langs->trans("Description").'</td>'."\n";
	print '<td width="30%">'.$langs->trans("Value").'</td>'."\n";
	print "</tr>\n";

	// FACTURE_DUE_INTERVAL_VALITATION
	print '<tr class="oddeven">';
	print '<td>'.$langs->trans("Plazo Validacion de Vencimiento").'</td>';
	print '<td>'.$langs->trans("Cantidad de dias para vaidacion de facturas vencidas (dias)").'</td>';
	print '<td class="nowrap">';
	print '<input type="number" name="FACTURE_DUE_INTERVAL_VALITATION" value="'.htmlspecialchars($conf->global->FACTURE_DUE_INTERVAL_VALITATION).'">';
	print '</td>';
	print '</tr>' ;

	// CRFACT_ALLOW_FREE_PRODUCT
	print '<tr class="oddeven">';
	print '<td>'.$langs->trans("Facturar entrada libre de producto").'</td>';
	print '<td>'.$langs->trans("Permitir facturar la entrada libre de productos").'</td>';
	if (!empty($conf->global->CRFACT_ALLOW_FREE_PRODUCT)) {
		print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setdallowfreeprods&value=0">';
		print img_picto($langs->trans("Activated"), 'switch_on');
		print '</a></td>';
	} else {
		print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setdallowfreeprods&value=1">';
		print img_picto($langs->trans("Disabled"), 'switch_off');
		print '</a></td>';
	}
	print '</tr>' ;

	// CRFACT_TIPO_CODCOMERCIAL
	print '<tr class="oddeven">';
	print '<td>'.$langs->trans("Tipo Codigo Comercial").'</td>';
	print '<td>'.$langs->trans("Tipo de Codigo Comercial a utilizar en la factura").'</td>';
	print '<td class="nowrap">';
	$values=array(
		'01'=>"C贸digo del producto del vendedor",
		'02'=>"C贸digo del producto del comprador",
		'03'=>"C贸digo del producto asignado por la industria",
		'04'=>"C贸digo uso interno",
		'99'=>"Otros"
	);
	print Form::selectarray("CRFACT_TIPO_CODCOMERCIAL", $values, $conf->global->CRFACT_TIPO_CODCOMERCIAL, 1);
	print '</td>';
	print '</tr>' ;

	// DEFAULT_CONDICION_VENTAS
	print '<tr class="oddeven">';
	print '<td>'.$langs->trans("Condicion de Venta Default").'</td>';
	print '<td>'.$langs->trans("Condiciones de la venta a utilizar en la factura").'</td>';
	print '<td class="nowrap">';
	$values=array(
		'01'=>"Contado",
		'02'=>"Cr茅dito",
		'03'=>"Consignaci贸n",
		'04'=>"Apartado",
		'05'=>"Arrendamiento con opci贸n de compra",
		'06'=>"Arrendamiento en funci贸n financiera",
		'07'=>"Cobro a favor de un tercero",
		'08'=>"Servicios prestados al Estado a cr茅dito",
		'09'=>"Pago del servicios prestado al Estado",
		'99'=>"Otros"
	);
	print Form::selectarray("DEFAULT_CONDICION_VENTAS", $values, $conf->global->DEFAULT_CONDICION_VENTAS, 1);
	print '</td>';
	print '</tr>' ;

	// CRFACT_ADD_QR_CODE
	print '<tr class="oddeven">';
	print '<td>'.$langs->trans("Agregar QR a la factura").'</td>';
	print '<td>'.$langs->trans("Incluir QR con el URL de acceso en el PDF de factura").'</td>';
	if (!empty($conf->global->CRFACT_ADD_QR_CODE)) { //INVOICE_ADD_SWISS_QR_CODE //INVOICE_ADD_ZATCA_QR_CODE
		print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaddqrcode&value=0">';
		print img_picto($langs->trans("Activated"), 'switch_on');
		print '</a></td>';
	} else {
		print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setaddqrcode&value=1">';
		print img_picto($langs->trans("Disabled"), 'switch_off');
		print '</a></td>';
	}
	print '</tr>' ;

	// CRFACT_MASK_INVOICE_TE
	print '<tr class="oddeven">';
	print '<td>'.$langs->trans("Formato Mascara Tiquete Electronico").'</td>';
	print '<td>'.$langs->trans("Formato para mascara (TE{0000000000})").'</td>';
	print '<td class="nowrap">';
	print '<input type="text" name="CRFACT_MASK_INVOICE_TE" value="'.htmlspecialchars($conf->global->CRFACT_MASK_INVOICE_TE).'">';
	print '</td>';
	print '</tr>' ;

	// CRFACT_MASK_INVOICE_FEE
	print '<tr class="oddeven">';
	print '<td>'.$langs->trans("Formato Mascara Factura Electronica de Exportacion").'</td>';
	print '<td>'.$langs->trans("Formato para mascara (FE{0000000000})").'</td>';
	print '<td class="nowrap">';
	print '<input type="text" name="CRFACT_MASK_INVOICE_FEE" value="'.htmlspecialchars($conf->global->CRFACT_MASK_INVOICE_FEE).'">';
	print '</td>';
	print '</tr>' ;

	// CRFACT_FE_EMAIL_DEFAULT
	print '<tr class="oddeven">';
	print '<td>'.$langs->trans("Direccion de correo a enviar si el cliente no tiene email").'</td>';
	print '<td>'.$langs->trans("Direccion de correo default").'</td>';
	print '<td class="nowrap">';
	print '<input type="email" name="CRFACT_FE_EMAIL_DEFAULT" value="'.htmlspecialchars($conf->global->CRFACT_FE_EMAIL_DEFAULT).'">';
	print '</td>';
	print '</tr>' ;

	print '</table>';
	print '</div>';
	
	print '<br>';
	print '<div align="center">';
	print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
	print '</div>';
	
	print '</form>';
	
	print dol_get_fiche_end();
	
	llxFooter();
	
	$db->close();
?>







Hry