示例#1
0
 public function InsertHistorical($content, $IdUser, $id_detalle, $id_validacion, $ruta_xml, $ruta_pdf, $tipo_archivo)
 {
     $DB = new DataBase();
     $q = "INSERT INTO historial_{$content} SET id_detalle={$id_detalle},id_validacion={$id_validacion},id_usuario={$IdUser}" . ",fecha_hora=now(),ruta_xml='{$ruta_xml}', ruta_pdf='{$ruta_pdf}', tipo_archivo='{$tipo_archivo}'";
     $NewIdHistorical = $DB->ConsultaInsertReturnId("CFDI", $q);
     if (!($NewIdHistorical > 0)) {
         XML::XmlResponse("Error", 0, "<p><b>Error</b> al insertar el registro en el histórico</p><br>Detalles:<br><br>{$NewIdHistorical}");
         return 0;
     }
     return $NewIdHistorical;
 }
示例#2
0
 private function NewEnterpriseSystem()
 {
     $DB = new DataBase();
     $IdUser = filter_input(INPUT_POST, "IdUser");
     $UserName = filter_input(INPUT_POST, "UserName");
     $ManagerEnterpriseAlias = filter_input(INPUT_POST, "EnterpriseAlias");
     $EnterpriseAlias = filter_input(INPUT_POST, "NewEnterpriseAlias");
     $EnterpriseName = filter_input(INPUT_POST, "NewNameEnterprise");
     $EnterpriseRFC = filter_input(INPUT_POST, "NewRfcEnterprise");
     $EnterprisePassword = filter_input(INPUT_POST, "NewPasswordEnterprise");
     $IdVolume = filter_input(INPUT_POST, "IdVolume");
     $AssignedMemory = filter_input(INPUT_POST, "AssignedMemory");
     $Volume = filter_input(INPUT_POST, "Volume");
     $RoutFile = filter_input(INPUT_SERVER, "DOCUMENT_ROOT");
     /* /var/services/web */
     $CheckVersion = Version::CheckVersion();
     if ($CheckVersion == 0) {
         return 0;
     }
     $QueryDuplicated = "SELECT *FROM Enterprises WHERE Alias COLLATE utf8_bin = '{$EnterpriseAlias}'";
     $ResultDuplicated = $DB->ConsultaSelect($ManagerEnterpriseAlias, $QueryDuplicated);
     if ($ResultDuplicated['Estado'] != 1) {
         XML::XmlResponse("Error", 0, "<p><b>Error</b> al comprobar la no existencia de la nueva empresa</p><br>Detalles:<br><br>" . $ResultDuplicated['Estado']);
         return 0;
     }
     if (count($ResultDuplicated['ArrayDatos']) > 0) {
         XML::XmlResponse("DuplicatedEnterprise", 0, "El alias de la empresa ya existe");
         return 0;
     }
     if (!($ResultCopy = copy("{$RoutFile}/index.html", "{$RoutFile}/{$EnterpriseAlias}.html"))) {
         XML::XmlResponse("Error", 0, "<p><b>Error</b> al generar el documento html de la nueva empresa</p>");
         return 0;
     }
     if ($CreateEnterprise = $DB->CreateEnterpriseInstance($EnterpriseAlias) != 1) {
         $DB->DeleteDataBase($EnterpriseAlias);
         return 0;
     }
     $Now = date("Y-m-d H:i:s");
     $QInsertEnterprise = "INSERT INTO Enterprises (Alias, EnterpriseName, RFC, Password, DischargeDate , IdVolume, AvailableMemory, TotalMemory) VALUES " . "('{$EnterpriseAlias}', '{$EnterpriseName}', '{$EnterpriseRFC}', '{$EnterprisePassword}', '{$Now}',  '{$IdVolume}', {$AssignedMemory} ,{$AssignedMemory})";
     $IdEnterprise = $DB->ConsultaInsertReturnId('Manager', $QInsertEnterprise);
     if (!($IdEnterprise > 0)) {
         $DB->DeleteDataBase($EnterpriseAlias);
         XML::XmlResponse("Error", 0, "<p><b>Error</b> al registrar la nueva empresa</p><br>Detalles:<br><br>{$IdEnterprise}");
         return 0;
     }
     $UpdateMemory = "UPDATE Volumes SET Used = Used + {$AssignedMemory}, Available = Available - {$AssignedMemory} WHERE IdVolume = {$IdVolume}";
     if (($ResultUpdate = $DB->ConsultaQuery('Manager', $UpdateMemory)) != 1) {
         XML::XmlResponse("Error", 0, "<p><b>Error</b> al actualizar el espacio disponible en el volúmen {$Volume}</p><br>Detalles:<br><br>{$ResultUpdate}");
         return 0;
     }
     $doc = new DOMDocument('1.0', 'utf-8');
     $doc->formatOutput = true;
     $root = $doc->createElement("NewEnterprise");
     $doc->appendChild($root);
     $mensaje_ = $doc->createElement('Mensaje', "Empresa {$EnterpriseName} dada de alta con éxito");
     $root->appendChild($mensaje_);
     $IdEnterpriseXml = $doc->createElement("IdEnterprise", $IdEnterprise);
     $root->appendChild($IdEnterpriseXml);
     $EnterpriseAliasXml = $doc->createElement("EnterpriseAlias", $EnterpriseAlias);
     $root->appendChild($EnterpriseAliasXml);
     $EnterpriseNameXml = $doc->createElement("EnterpriseName", $EnterpriseName);
     $root->appendChild($EnterpriseNameXml);
     $RFCXml = $doc->createElement("RFC", $EnterpriseRFC);
     $root->appendChild($RFCXml);
     $DischargeDateXml = $doc->createElement("DischargeDate", $Now);
     $root->appendChild($DischargeDateXml);
     $TotalMemory = $doc->createElement("TotalMemory", $AssignedMemory);
     $root->appendChild($TotalMemory);
     $VolumeXml = $doc->createElement("Volume", $Volume);
     $root->appendChild($VolumeXml);
     $OccupiedMemory = $doc->createElement("OccupiedMemory", 0);
     $root->appendChild($OccupiedMemory);
     $FreeMemory = $doc->createElement("FreeMemory", $AssignedMemory);
     $root->appendChild($FreeMemory);
     header("Content-Type:text/xml");
     echo $doc->saveXML();
 }
示例#3
0
 private function NewUser()
 {
     $DB = new DataBase();
     $EnterpriseAlias = filter_input(INPUT_POST, "EnterpriseAlias");
     $NewUserName = filter_input(INPUT_POST, "NewUsername");
     $LastName = filter_input(INPUT_POST, "LastName");
     $MLastName = filter_input(INPUT_POST, "MLastName");
     $SystemUsername = filter_input(INPUT_POST, "SystemUsername");
     $Password = filter_input(INPUT_POST, "Password");
     $Repeated = "SELECT * FROM Users WHERE UserName COLLATE utf8_bin = '{$SystemUsername}'";
     $ResultRepetaed = $DB->ConsultaSelect($EnterpriseAlias, $Repeated);
     if ($ResultRepetaed['Estado'] != 1) {
         XML::XmlResponse("Error", 0, "<p><b>Error</b> al comprobar que el usuario no estuviera registrado previamente</p><br>Detalles:<br><br>" . $ResultRepetaed['Estado']);
         return;
     }
     if (count($ResultRepetaed['ArrayDatos']) > 0) {
         XML::XmlResponse("RepeatedUser", 1, "El usuario '{$NewUserName}' ya existe");
         return 0;
     }
     $now = date('Y-m-d');
     $Insert = "INSERT INTO Users (UserName, Password, Name, LastName, MLastName, DischargeDate)\n        VALUES ('{$SystemUsername}', '{$Password}', '{$NewUserName}', '{$LastName}', '{$MLastName}', '{$now}')";
     $IdUser = $DB->ConsultaInsertReturnId($EnterpriseAlias, $Insert);
     if (!$IdUser > 0) {
         XML::XmlResponse("Error", 0, "<p><b>Error</b> al registrar el nuevo usuario</p><br>Detalles:<br><br>{$ResultInsert}");
         return 0;
     }
     $doc = new DOMDocument('1.0', 'utf-8');
     $doc->formatOutput = true;
     $root = $doc->createElement("NewUser");
     $doc->appendChild($root);
     $mensaje_ = $doc->createElement('Mensaje', "Usuario '{$NewUserName}' registrado con éxito");
     $root->appendChild($mensaje_);
     $IdUserXml = $doc->createElement("IdUser", $IdUser);
     $root->appendChild($IdUserXml);
     $NewUsernameSystemXml = $doc->createElement("SystemUsername", $SystemUsername);
     $root->appendChild($NewUsernameSystemXml);
     $UserName = $doc->createElement("UserName", $NewUserName);
     $root->appendChild($UserName);
     $LastNameXml = $doc->createElement("LastName", $LastName);
     $root->appendChild($LastNameXml);
     $MLastNameXml = $doc->createElement("MLastName", $MLastName);
     $root->appendChild($MLastNameXml);
     $DischargeDate = $doc->createElement("DischargeDate", $now);
     $root->appendChild($DischargeDate);
     header("Content-Type:text/xml");
     echo $doc->saveXML();
 }
示例#4
0
 private function ProcessingEnterpriseEmail()
 {
     $DB = new DataBase();
     $EnterpriseAlias = filter_input(INPUT_POST, "EnterpriseAlias");
     $IdUser = filter_input(INPUT_POST, "IdUser");
     $UserName = filter_input(INPUT_POST, "UserName");
     $UserNameEmail = filter_input(INPUT_POST, "UserNameEmail");
     $EmailTitle = filter_input(INPUT_POST, "EmailTitle");
     $EmailPassword = filter_input(INPUT_POST, "EmailPassword");
     $Smtp = filter_input(INPUT_POST, "Smtp");
     $SmtpPort = filter_input(INPUT_POST, "SmtpPort");
     $SmtpAuth = filter_input(INPUT_POST, "SmtpAuth");
     $SmtpSecure = filter_input(INPUT_POST, "SmtpSecure");
     $Imap = filter_input(INPUT_POST, "Imap");
     $ImapPort = filter_input(INPUT_POST, "ImapPort");
     $ImapSecure = filter_input(INPUT_POST, "ImapSecure");
     if (strcasecmp($ImapSecure, "ssl") == 0 or strcasecmp($ImapSecure, "tls") == 0) {
         $ImapSecure .= "/";
     } else {
         $ImapSecure = '';
     }
     $Email = array("EnterpriseAlias" => $EnterpriseAlias, "IdUser" => $IdUser, "UserName" => $UserName, "UserNameEmail" => $UserNameEmail, "EmailPassword" => $EmailPassword, "Smtp" => $Smtp, "EmailTitle" => $EmailTitle, "SmtpPort" => $SmtpPort, "SmtpAuth" => $SmtpAuth, "SmtpSecure" => $SmtpSecure, "Imap" => $Imap, "ImapPort" => $ImapPort, "ImapSecure" => $ImapSecure);
     $CheckIfExist = "SELECT *FROM EmailEngine WHERE User COLLATE utf8_bin = '{$UserNameEmail}'";
     $CheckIfExistRes = $DB->ConsultaSelect($EnterpriseAlias, $CheckIfExist);
     if ($CheckIfExistRes['Estado'] != 1) {
         XML::XmlResponse("Error", 0, "<p><b>Error</b> al comprobar existencia del nuevo correo electrónico</p><br>Detalles:<br><br>" . $CheckIfExistRes['Estado']);
         return 0;
     }
     if (count($CheckIfExistRes['ArrayDatos'])) {
         XML::XmlResponse("Duplicated", 1, "<p>El correo electrónico {$UserNameEmail} ya se encuentra registrado</p>");
         return;
     }
     /* Prueba de envio (Envió de email) */
     $Recipients = array();
     $Recipients[] = array("Addressee" => $Email['UserNameEmail'], "Title" => $Email['EmailTitle']);
     $Subject = "Alta de correo electrónico en CSDocs CFDI";
     $Message = "Ha dado de alta su correo electrónico en el sistema CSDocs CFDI, ya puede realizar descargas de <b>Comprobantes Fiscales Digitales por Internet</b> y almacenarlos de forma segura.";
     if (($SendEmail = $this->SendEmail($Email, $Recipients, $Subject, $Message)) != 1) {
         XML::XmlResponse("Error", 0, "<p><b>Error</b> al realizar la prueba de envio de correo electrónico: <br><br>{$SendEmail}</p>");
         return 0;
     }
     $ImapPath = "{" . $Imap . ":" . $ImapPort . "/imap/" . $ImapSecure . "novalidate-cert}";
     if ($mbox = imap_open($ImapPath, $UserNameEmail, $EmailPassword)) {
         imap_close($mbox);
     } else {
         XML::XmlResponse("Error", 0, "<p>Ocurrió el siguiente error. " . imap_last_error() . ". <p>Revise que sus datos sean correctos</p>");
         return 0;
     }
     $InsertEmail = "INSERT INTO EmailEngine " . "(User, Password, Title, Smtp, SmtpPort, SmtpAuth, SmtpSecure, Imap, ImapPort, ImapSecure, EmailType, EmailServerName) " . "VALUES ('{$UserNameEmail}', '{$EmailPassword}', '{$EmailTitle}', '{$Smtp}', {$SmtpPort}, '{$SmtpAuth}', '{$SmtpSecure}', '{$Imap}', {$ImapPort}, '{$ImapSecure}', 'Enterprise', 'otro')";
     $InsertEmailResult = $DB->ConsultaInsertReturnId($EnterpriseAlias, $InsertEmail);
     if (!($InsertEmailResult > 0)) {
         XML::XmlResponse("Error", 0, "<p><b>Error</b> al registrar el correo electrónico</p><br>Detalles:<br><br>{$InsertEmailResult}");
         return 0;
     }
     $doc = new DOMDocument('1.0', 'utf-8');
     $doc->formatOutput = true;
     $root = $doc->createElement("NewEmail");
     $doc->appendChild($root);
     $Mensaje = $doc->createElement("Mensaje", "El correo {$UserNameEmail} fué dado de alta con éxito");
     $root->appendChild($Mensaje);
     $EmailXml = $doc->createElement("UserNameEmail", $UserNameEmail);
     $root->appendChild($EmailXml);
     $IdEmail = $doc->createElement("IdEmail", $InsertEmailResult);
     $root->appendChild($IdEmail);
     header("Content-Type:text/xml");
     echo $doc->saveXML();
 }
示例#5
0
 function InsertValidationCfdi($EnterpriseAlias, $content, $validacion, $ReceiptPath)
 {
     $DB = new DataBase();
     $webService = $validacion->getElementsByTagName("WebService")->item(0)->nodeValue;
     $EmisorRfc = $validacion->getElementsByTagName("EmisorRfc")->item(0)->nodeValue;
     $ReceptorRfc = $validacion->getElementsByTagName("ReceptorRFC")->item(0)->nodeValue;
     $FechaHoraEnvio = $validacion->getElementsByTagName("FechaHoraEnvio")->item(0)->nodeValue;
     $FechaHoraRespuesta = $validacion->getElementsByTagName("FechaHoraRespuesta")->item(0)->nodeValue;
     $TotalFactura = $validacion->getElementsByTagName("TotalFactura")->item(0)->nodeValue;
     $uuid = $validacion->getElementsByTagName("UUID")->item(0)->nodeValue;
     $CodigoEstatus = $validacion->getElementsByTagName("CodigoEstatus")->item(0)->nodeValue;
     $Estado = $validacion->getElementsByTagName("Estado")->item(0)->nodeValue;
     $md5 = $validacion->getElementsByTagName("AcuseRecibo")->item(0)->nodeValue;
     $q = "INSERT INTO validacion_{$content} (FechaHora_envio, FechaHora_respuesta, emisor_rfc," . "receptor_rfc, total_factura, uuid, codigo_estatus, estado, md5, web_service, ruta_acuse)" . " VALUES ('{$FechaHoraEnvio}', '{$FechaHoraRespuesta}', '{$EmisorRfc}', '{$ReceptorRfc}'" . ", {$TotalFactura}, '{$uuid}', '{$CodigoEstatus}', '{$Estado}', '{$md5}', '{$webService}', '{$ReceiptPath}')";
     $NewIdReceipt = $DB->ConsultaInsertReturnId($EnterpriseAlias, $q);
     if (!$NewIdReceipt > 0) {
         XML::XmlResponse("Error", 0, "<p><b>Error</b> al registrar la validación del nuevo Cfdi</p><br>Detalles:<br><br>{$NewIdReceipt}");
         return 0;
     }
     return $NewIdReceipt;
 }
示例#6
0
 private function InsertReceptor($EnterpriseAlias, $ReceiverRfc, $ReceiverName, $CfdiPath)
 {
     $DB = new DataBase();
     $IdReceptor = 0;
     $CheckExistReceiver = "SELECT IdReceptor FROM Receptor WHERE RFC COLLATE utf8_bin = '{$ReceiverRfc}'";
     $CheckExistReceiverResult = $DB->ConsultaSelect($EnterpriseAlias, $CheckExistReceiver);
     if ($CheckExistReceiverResult['Estado'] != 1) {
         echo "\n Error al comprobar existencia del receptor en el documento " . basename($CfdiPath) . ". Error: " . $CheckExistReceiverResult['Estado'];
         return 0;
     }
     if (count($CheckExistReceiverResult['ArrayDatos']) == 0) {
         $InsertReceiver = "INSERT INTO Receptor (RFC, Nombre) VALUES ('{$ReceiverRfc}', '{$ReceiverName}')";
         if (!($InsertReceiverResult = $DB->ConsultaInsertReturnId($EnterpriseAlias, $InsertReceiver)) > 0) {
             echo "\n Error al intentar insertar el Receptor del documento " . basename($CfdiPath) . ". Error: {$InsertReceiverResult}";
             return 0;
         }
     } else {
         $IdReceptor = $CheckExistReceiverResult['ArrayDatos'][0]['IdReceptor'];
     }
     return $IdReceptor;
 }