* Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2015 Jean-François Ferry * * 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 cfdimx/cfdimxindex.php * \ingroup cfdimx * \brief Home page of cfdimx top menu */ // 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 && file_exists("../../../main.inc.php")) { $res = @include "../../../main.inc.php"; } if (!$res) { die("Include of main fails"); } require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT."/core/lib/company.lib.php"; require_once DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"; dol_include_once('/cfdimx/class/societe.class.php'); // Load translation files required by the page $langs->loadLangs(array("cfdimx@cfdimx", "main", "admin")); $action = GETPOST('action', 'aZ09'); /* * Actions */ if($action == "guardar"){ // Ajuste Logo $error = 0; $ruta = GETPOST('rfc')."_".date("Ymd").date("His"); $ruta_server = $conf->cfdimx->multidir_output[$conf->entity]."/sellos/".$ruta; $rfc = GETPOST('rfc'); $pass = trim(GETPOST('pass')); $pass_confirm = trim(GETPOST('pass_confirm')); $file_cer = $_FILES['cer']['name']; $source_cer = $_FILES['cer']['tmp_name']; $file_key = $_FILES['key']['name']; $source_key = $_FILES['key']['tmp_name']; if($pass == "" && $pass_confirm == ""){ setEventMessage("Error: Las contraseñas ingresadas no contienen información valida", 'errors'); $error++; } if(strcmp($pass, $pass_confirm) != 0){ setEventMessage("Error: Las contraseñas no coinciden", 'errors'); $error++; } if($file_cer == "" && $source_cer == ""){ setEventMessage("Error: El archivo .cer es requerido y no se a seleccionado ninguno", 'errors'); $error++; } if($file_key == "" && $source_key == ""){ setEventMessage("Error: El archivo .key es requerido y no se a seleccionado ninguno", 'errors'); $error++; } if($error == 0){ dol_mkdir($ruta_server); $newcer = $ruta_server.'/'.dol_sanitizeFileName($_FILES['cer']['name']); if (!dol_move_uploaded_file($_FILES['cer']['tmp_name'], $newcer, 1, 0, $_FILES['cer']['error']) > 0) { setEventMessage("Error: El archivo .cer no se pudo agregar a la Plataforma, contacta al área de soporte", 'errors'); } $newkey = $ruta_server.'/'.dol_sanitizeFileName($_FILES['key']['name']); if (!dol_move_uploaded_file($_FILES['key']['tmp_name'], $newkey, 1, 0, $_FILES['key']['error']) > 0) { setEventMessage("Error: El archivo .key no se pudo agregar a la Plataforma, contacta al área de soporte", 'errors'); } $sql = "INSERT INTO ".MAIN_DB_PREFIX."cfdimx_infocsd"; $sql .= "(entity, rfc, filecer, filekey, pass, fk_user_create, date_create)"; $sql .= " VALUES"; $sql .= " ("; $sql .= "'".$conf->entity."',"; $sql .= "'".$rfc."',"; $sql .= "'".$file_cer."',"; $sql .= "'".$file_key."',"; $sql .= "'".$pass."',"; $sql .= $user->id.","; $sql .= "now()"; $sql .= " )"; $resql = $db->query($sql); if($resql){ setEventMessage('Proceso de Sellos Digialtes Terminado.', 'mesgs'); setEventMessage('La activación de Sellos Digitales tiene un plazo no mayor a 72 horas.', 'warnings'); $lista_correos = array(); $lista_correos[] = "Soporte CSD"; // $email_clie = implode(",", $lista_correos); $email_clie = $conf->global->CFDIMX_FE_CORREO_SOPORTE; $from = $conf->global->CFDIMX_FE_CORREO_FROM; $texttosend = "Carga Sellos Digitales :: ".$pass; $subjecttosend = "Registro nuevo Emisor"; //print $texttosend.'
'; $filename_list=array(); $mimetype_list=array(); $mimefilename_list=array(); $filedir = $ruta_server; $archivo_cer = $file_cer; $archivo_key = $file_key; $filename_list[] = $filedir.$archivo_cer; $filename_list[] = $filedir.$archivo_key; $mimetype_list[] = ".pdf"; $mimetype_list[] = ".xml"; $mimefilename_list[] = $archivo_cer; $mimefilename_list[] = $archivo_key; $addr_cc = ""; $addr_bcc = ""; $deliveryreceipt = 0; $msgishtml = 1; $trackid = ''; $moreinheader = ''; $mailfile = new CMailFile($subjecttosend, $email_clie, $from, $texttosend, $filename_list, $mimetype_list, $mimefilename_list, $addr_cc, $addr_bcc, $deliveryreceipt, $msgishtml, '', '', $trackid, $moreinheader); if ($mailfile->sendfile()) { setEventMessage('Correo Enviado.', 'mesgs'); }else{ setEventMessage('Error de envio de Sellos.'.$langs->trans("ErrorFailedToSendMail", $from, $email_clie).'. '.$mailfile->error, 'warnings'); } }else{ dol_print_error($db); } } } /* * View */ $form = new Form($db); $formfile = new FormFile($db); $formcompany = new FormCompany($db); $societe_static = new SocieteCFDIMX($db); $help_url = ''; $arrayofjs = array('/cfdimx/js/cfdimx.js.php'); llxHeader("", $langs->trans("Sellos Digitales"), $help_url, '', 0, 0, $arrayofjs); print load_fiche_titre($langs->trans("Sellos Digitales"), '', 'fa-globe-americas'); // Datos iniciales $rfc = $conf->global->MAIN_INFO_SIREN; if($rfc == ''){ $action = 'error'; } $cer = ''; $key = ''; if($action == '' || $action == 'guardar'){ print '
'; if((int)DOL_VERSION > 15){ print ''; } print ''; print '
'; print '
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print '
'; print ''; print 'Datos CSD'; print '
R.F.C.'; print ''; print $rfc; print '
Archivo .cer'; print '
'; print '
'; print ''; print ''; print '
'; print '
'; if($cer != ''){ print '
'; print $cer; print '
'; } print '
Archivo .key'; print '
'; print '
'; print ''; print ''; print '
'; print '
'; if($key != ''){ print '
'; print $key; print '
'; } print '
Contraseña'; print ''; print ''; print '
Confirmar Contraseña'; print ''; print ''; print '
'; print '
'; print ''; print '
'; print '
'; print '
'; print '
'; print '
'; print '
'; } if($action == 'error'){ print '
'; print 'Error: Primero debe llenar la Información Fiscal para cargar los Sellos (CSD).'; print '
'; } // End of page llxFooter(); $db->close();