* Copyright (C) 2023 SuperAdmin
*
* 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 almacenvima/admin/about.php
* \ingroup almacenvima
* \brief About page of module Almacenvima.
*/
// 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");
}
// Libraries
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
dol_include_once('/cfdimx/class/admin.class.php');
dol_include_once('/cfdimx/lib/cfdimxadmin.lib.php');
// Translations
$langs->loadLangs(array("errors", "admin", "cfdimx@cfdimx"));
// Access control
if (!$user->admin) {
accessforbidden();
}
// Parameters
$action = GETPOST('action', 'aZ09');
$backtopage = GETPOST('backtopage', 'alpha');
$codigo = GETPOST('codigo');
$etiqueta = GETPOST('etiqueta');
$tasa = GETPOST('tasa');
$config = new ConfiguracionCFDIMX($db);
/*
* Actions
*/
if($action == "confirm_retlocal"){
$tipo_operacion = GETPOST("tipo_operacion");
$config->retlocal_rowid = GETPOST("rowid");
if(in_array($tipo_operacion, array(1, 2))){
$config->retlocal_codigo = trim($codigo);
$config->retlocal_desc = trim($etiqueta);
$config->retlocal_tasa = trim($tasa);
if($config->retlocal_rowid == -1){
$res = $config->createRetLocal($user);
if($res > 0){
// $object->fk_facture = $id;
// $object->getComplemento();
setEventMessage("Se agrego correctamente la Retención Local.", 'mesgs');
}else{
setEventMessage($config->errors, 'errors');
}
}else{
$res = $config->updateRetLocal($user);
if($res > 0){
setEventMessage("Se actualizo correctamente la Retención Local.", 'mesgs');
}else{
setEventMessage($config->errors, 'errors');
}
}
}else{
$res = $config->deleteRetLocal($user);
if($res > 0){
setEventMessage("Se elimino correctamente la Retención Local.", 'mesgs');
}else{
setEventMessage($config->errors, 'errors');
}
}
}
/*
* View
*/
$num_retenciones = $config->fetchRetLocales();
if($num_retenciones == 0){
$action = "retencion_local";
}
$form = new Form($db);
$help_url = '';
$page_name = "Retenciones Locales";
$arrayofjs = array('/cfdimx/js/cfdimx.js.php');
llxHeader('', $langs->trans($page_name), $help_url, '', 0, 0, $arrayofjs);
// Subheader
$linkback = ''.$langs->trans("BackToModuleList").'';
print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup');
// Configuration header
$head = cfdimxAdminPrepareHead();
print dol_get_fiche_head($head, 'cfdimx', $langs->trans($page_name), 0, 'accountancy');
$head = cfdimxAdminConfigPrepareHead();
print dol_get_fiche_head($head, 'ret_locales', $langs->trans($page_name), 0, 'accountancy');
$formconfirm = '';
if($action == "retencion_local"){
$formquestion = array();
$tipo_operacion = GETPOST("tipo_operacion");
$rowid = (GETPOST("rowid") != "" ? GETPOST("rowid") : -1);
$label_retlocal = ($rowid == -1 ? $langs->trans('AddRetLocal') : $langs->trans("UpdateRetLocal"));
$info_detail = $config->getLabelRetLocal($rowid);
if(in_array($tipo_operacion, array(1, 2)) || $rowid == -1){
if($rowid == -1){
$tipo_operacion = 1;
}
$formquestion = array(
array('type' => 'hidden', 'name' => 'tipo_operacion', 'value' => $tipo_operacion),
array('type' => 'hidden', 'name' => 'rowid', 'value' => $rowid),
array('type' => 'text', 'name' => 'codigo', 'label' => 'Código', 'value' => $config->retlocal_codigo, 'tdclass' => 'fieldrequired', 'moreattr' => 'required placeholder="01"'),
array('type' => 'text', 'name' => 'etiqueta', 'label' => 'Etiqueta', 'value' => $config->retlocal_desc, 'tdclass' => 'fieldrequired', 'moreattr' => 'required placeholder="Retencion 1"'),
array('type' => 'text', 'name' => 'tasa', 'label' => 'Tasa', 'value' => $config->retlocal_tasa, 'tdclass' => 'fieldrequired', 'moreattr' => 'required placeholder="0.16"')
);
}else{
$label_retlocal = $langs->trans('DeleteRetLocal');
$formquestion = array(
array('type' => 'hidden', 'name' => 'tipo_operacion', 'value' => $tipo_operacion),
array('type' => 'hidden', 'name' => 'rowid', 'value' => $rowid),
array('type' => 'onecolumn', 'value' => '¿Estas seguro de Eliminar la Informacíón de la Retención Local?'),
array('type' => 'onecolumn', 'value' => $info_detail)
);
}
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"], $label_retlocal, '', 'confirm_retlocal', $formquestion, 1, 1, 235, 500);
}
print $formconfirm;
if($num_retenciones > 0){
print '
';
print '
';
print '
';
print '';
print '| ';
print 'Lista de Retenciones Locales';
print ' ';
$url_add_retlocal = $_SERVER['PHP_SELF'].'?action=retencion_local&tipo_operacion=1';
if((int)DOL_VERSION > 15){
$url_add_retlocal .= "&token=".newToken();
}
print '';
print '';
print '';
print ' | ';
print '
';
print '';
print '| #';
print ' | Código | ';
print 'Etiqueta | ';
print 'Tasa | ';
print ' | ';
print '';
foreach ($config->retlocales_list as $key => $value) {
print '
';
print '| '.($key+1).' | ';
print ''.$value->cod.' | ';
print ''.$value->descripcion.' | ';
print ''.$value->tasa.' | ';
print '';
$url_update = $_SERVER['PHP_SELF'].'?action=retencion_local&rowid='.$value->rowid.'&tipo_operacion=2';
if((int)DOL_VERSION > 15){
$url_update .= "&token=".newToken();
}
print '';
print '';
print '';
print ' ';
$url_delete = $_SERVER['PHP_SELF'].'?action=retencion_local&rowid='.$value->rowid.'&tipo_operacion=3';
if((int)DOL_VERSION > 15){
$url_delete .= "&token=".newToken();
}
print '';
print '';
print '';
print ' | ';
print '
';
}
print '
';
print '
';
print '
';
}
// Page end
print dol_get_fiche_end();
llxFooter();
$db->close();