����JFIF��H�H����Exif��MM�*���� ��3����V�����3������3�(��������������������3�����
Server IP : 74.208.127.88 / Your IP : 13.59.48.34 Web Server : Apache/2.4.41 (Ubuntu) System : Linux ubuntu 5.4.0-163-generic #180-Ubuntu SMP Tue Sep 5 13:21:23 UTC 2023 x86_64 User : www-data ( 33) PHP Version : 7.4.3-4ubuntu2.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/html/goldencar/sae/application/salesHonorarios/ |
Upload File : |
<?php ini_set('display_errors', 1); error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE); require_once 'nusoap/nusoap.php'; include 'heredoc_txt.php'; session_start(); setlocale(LC_TIME, 'es_MX.UTF-8'); date_default_timezone_set("America/Mexico_City"); require_once ("../model/dbconn.php"); require_once ("../model/pos.php"); $sale1= $_POST['id_sales']; //datos del cliente $client_name = $_POST['client_name']; $client_rfc = $_POST['rfc']; $FormaPago = $_POST['FormaPago']; $uso_cfdi= $_POST['uso_cfdi']; $notapdf = $_POST['nota']; $posForma= new pos(); $FormaPago = $posForma->getFormakId($FormaPago)[1]['def']; $hoy = date("F j, Y, g:i a"); //consultamos los datos del cliente en tabla customer /* $sell_id=6342; $sale1='J221221013'; $client_name="XOCHILT CASAS CHAVEZ"; $client_rfc = 'CACX7605101P8'; $uso_cfdi= 'G03'; $FormaPago = '01'; $notapdf = 'NA'; $client_id = 1; $hoy = date("F j, Y, g:i a"); */ $client = new pos(); $client_regimen = $client->getClientByRFC($client_rfc)[1]['phone']; $client_codigo = $client->getClientByRFC($client_rfc)[1]['country']; $mailC = $client->getClientByRFC($client_rfc)[1]['email1']; //print_r($client->getClientByRFC($client_rfc)); //revisamos el id de sell $posSell_id = new pos(); $sell_id = $posSell_id->getlistSell($sale1); //print_r($sell_id[1]['id']); $sell_id=$sell_id[1]['id']; echo $sale_id=$sale1; if(isset($sell_id) && isset($sale_id)) { //ajustamos saldo updateSettingSaldo $updateSaldo = new pos(); $saldox = $updateSaldo->updateSettingSaldo('Saldo-Fact'); //revisamos saldo $posConfig = new pos(); $saldo = $posConfig->getByPreffix("Saldo-Fact")[1]['val']; //libreria de sdk2.php multifacturas $posSDK = new pos(); $lib_sdk = $posSDK->getByPreffix("lib_sdk")[1]['val']; //folio de tabla facturacion $posFolioF = new pos(); $FolioF = $posFolioF->getByFacturaMax(); if($FolioF[1]['id'] > 0){ $FolioFactura = $FolioF[1]['id'] + 1; }else{ $FolioFactura = 1; } //solicitamos timbrado de factura $posConfig = new pos(); //impuesto general $impuestoBD = $posConfig->getByPreffix('imp-val')[1]['val']; //usuario multifacturas real $userMulti = $posConfig->getByPreffix('Usuario_Factura')[1]['val']; //pass multifacturas real $passMulti = $posConfig->getByPreffix('pass_fac')[1]['val']; //detalles $ArchCerDemo = $posConfig->getByPreffix('archivo_cer_demo')[1]['val']; $ArchKeyDemo = $posConfig->getByPreffix('archivo_key_demo')[1]['val']; $settingsEmisor = $posConfig->getByPreffix('name_val')[1]['val']; $settingsCP = $posConfig->getByPreffix('cp_val')[1]['val']; $RegimenDemo = $posConfig->getByPreffix('Regimen_sat')[1]['val']; $CodigoSatGenerico = $posConfig->getByPreffix('Sat_val')[1]['val']; $settingsUnidadSat = $posConfig->getByPreffix('Sat_val_Unidad')[1]['val']; $RFC_demo_Emisor = $posConfig->getByPreffix('rfc_val')[1]['val']; $RFC_nombre_Emisor = $posConfig->getByPreffix('name_val')[1]['val']; $PassDemoMulti= $posConfig->getByPreffix('Pass_Sat_demo')[1]['val']; $logo = $posConfig->getByPreffix('report_image')[1]['val']; $emailPrincipal = $posConfig->getByPreffix('admin_email')[1]['val']; //facturacion real SI(real)/NO(demo) $FacturacionReal = $posConfig->getByPreffix('demo_fac')[1]['val']; //***************** INICIA FUNCIONES MULTIFACTURAS*********************// //ejemplo factura cfdi 4.0 // Se desactivan los mensajes de debug //error_reporting(0); //error_reporting(0); // Se especifica la zona horaria date_default_timezone_set('America/Mexico_City'); // Se incluye el SDK require_once '../../../sdk2/sdk2.php'; // Se especifica la version de CFDi 4.0 $datos['version_cfdi'] = '4.0'; // Ruta del XML Timbrado $datos['cfdi']='../../../sdk2/timbrados/cfdi_factura_'.$sell_id.'.xml'; // Ruta del XML de Debug $datos['xml_debug']='../../../sdk2/timbrados/sin_timbrar_factura_'.$sell_id.'.xml'; // Credenciales de Timbrado $datos['PAC']['usuario'] = ''.$userMulti.''; $datos['PAC']['pass'] = ''.$passMulti.''; $datos['PAC']['produccion'] = ''.$FacturacionReal.''; $datos['conf']['cer'] = '../../../sdk2/certificados/'.$ArchCerDemo.''; $datos['conf']['key'] = '../../../sdk2/certificados/'.$ArchKeyDemo.''; $datos['conf']['pass'] = ''.$PassDemoMulti.''; //datos de Emisor $datos['emisor']['rfc'] = ''.$RFC_demo_Emisor.''; //RFC DE PRUEBA $datos['emisor']['nombre'] = "".$settingsEmisor.""; // EMPRESA DE PRUEBA $datos['emisor']['RegimenFiscal'] = ''.$RegimenDemo.''; // Datos del Receptor $datos['receptor']['UsoCFDI'] = $uso_cfdi; $datos['receptor']['rfc'] = $client_rfc; $datos['receptor']['nombre'] = utf8_encode($client_name); $datos['receptor']['DomicilioFiscalReceptor'] = $client_codigo; $datos['receptor']['RegimenFiscalReceptor'] = $client_regimen; // Se agregan los conceptos $operations=new pos(); $operation23 = array(); $operation23 = $operations->getOperations($sale_id); //print_r($operation23); foreach($operation23[1] as $operation){ $price_sin = number_format($operation['price'],2); $price_sin = floatval(preg_replace('/[^\d.]/', '', $price_sin)); $concepto['ClaveProdServ'] = '85122000'; $concepto['cantidad'] = $operation['qty']; $concepto['unidad'] = 'NO APLICA'; $concepto['ClaveUnidad'] = "E48"; //ID, REF, CODIGO O SKU DEL PRODUCTO $concepto['descripcion'] = $operation['item_name']; $concepto['valorunitario'] = $price_sin; // SIN IVA $concepto['importe'] = $price_sin; // agregado 4.0 2023 $concepto['ObjetoImp'] = '02'; } $datos['conceptos'][0] = $concepto; $iva_tras =0.00; $datos['conceptos'][0]['Impuestos']['Traslados'][0]['Base'] = $price_sin; $datos['conceptos'][0]['Impuestos']['Traslados'][0]['Impuesto'] = '002'; $datos['conceptos'][0]['Impuestos']['Traslados'][0]['TasaOCuota'] = '0.000000'; $datos['conceptos'][0]['Impuestos']['Traslados'][0]['Importe'] = $iva_tras; $datos['conceptos'][0]['Impuestos']['Traslados'][0]['TipoFactor'] = 'Tasa'; $iva_ret = 0.00; $datos['conceptos'][0]['Impuestos']['Retenciones'][0]['Impuesto'] = '002'; $datos['conceptos'][0]['Impuestos']['Retenciones'][0]['Importe'] = $iva_ret; // iva de los productos facturados $datos['conceptos'][0]['Impuestos']['Retenciones'][0]['Base'] = $price_sin; $datos['conceptos'][0]['Impuestos']['Retenciones'][0]['TasaOCuota'] = '0.000000'; $datos['conceptos'][0]['Impuestos']['Retenciones'][0]['TipoFactor'] = 'Tasa'; echo ".........................Tipo de cliente: "; print_r($_POST['TypeClient']); echo "......................................"; if($_POST['TypeClient']== 2){ $ISR = 0.00; $impuestos = 0; }else{ $ISR = $price_sin * 0.10; $datos['conceptos'][0]['Impuestos']['Retenciones'][1]['Impuesto'] = '001'; $datos['conceptos'][0]['Impuestos']['Retenciones'][1]['Importe'] = $ISR; // iva de los productos facturados $datos['conceptos'][0]['Impuestos']['Retenciones'][1]['Base'] = $price_sin; $datos['conceptos'][0]['Impuestos']['Retenciones'][1]['TasaOCuota'] = '0.100000'; $datos['conceptos'][0]['Impuestos']['Retenciones'][1]['TipoFactor'] = 'Tasa'; $retenido2['impuesto'] = '001'; $retenido2['importe'] = $ISR; // iva de los productos facturados $datos['impuestos']['retenciones'][1] = $retenido2; $impuestos = $ISR; } $datos['impuestos']['TotalImpuestosTrasladados']= $iva_tras; $datos['impuestos']['TotalImpuestosRetenidos']=$iva_ret + $ISR; //agregado 4.0 enero 2023 $translado1['Base'] = $price_sin; $translado1['Impuesto'] = '002'; $translado1['TasaOCuota'] = '0.000000'; $translado1['Importe'] = $iva_tras; // iva de los productos facturados $translado1['TipoFactor'] = 'Tasa'; $datos['impuestos']['translados'][0] = $translado1; $retenido['impuesto'] = '002'; $retenido['importe'] = $iva_ret; // iva de los productos facturados $datos['impuestos']['retenciones'][0] = $retenido; $total =$price_sin - $ISR; $subtotal = $price_sin; $datos['factura']['subtotal'] = $subtotal; // sin impuestos $datos['factura']['total'] = $total; // total incluyendo impuestos // Datos de la Factura $datos['factura']['condicionesDePago'] = 'CONTADO'; $datos['factura']['descuento'] = '0.00'; $datos['factura']['fecha_expedicion'] = date('Y-m-d\TH:i:s', time() - 120); $datos['factura']['folio'] = $FolioFactura; $datos['factura']['forma_pago'] = $FormaPago; $datos['factura']['LugarExpedicion'] = $settingsCP; $datos['factura']['metodo_pago'] = 'PUE'; $datos['factura']['moneda'] = 'MXN'; $datos['factura']['serie'] = 'H'; $datos['factura']['tipocambio'] = 1; $datos['factura']['tipocomprobante'] = 'I'; $datos['factura']['Exportacion'] = '01'; echo '<pre>'; print_r($datos); echo '</pre>'; # CREACIÓN DEL OBJETO DEL API DE CONEXION try{ $url = 'https://dev.timbradorxpress.mx/ws/servicio.do?wsdl'; // EndPoint del servicio //generamos el txt generateTxt($datos, $uuid=uniqid('', true));} catch (Exception $e){ echo "Error: "; echo $e->getMessage(); } $objConexion = new SoapClient($url); // Creación del objeto de conexión /* $txtB64 = base64_encode( file_get_contents('rsc/ejemplo_cfdi.txt') ); $keyPEM = file_get_contents('rsc/CSD_EKU9003173C9_key.pem'); $cerPEM = file_get_contents('rsc/CSD_EKU9003173C9_cer.pem'); $plantilla = '1'; $logoB64 = base64_encode( file_get_contents('rsc/logo.png') ); echo $objConexion->operacion_timbrarTXT2($apikey, $txtB64, $keyPEM, $cerPEM, $plantilla, $logoB64); */ # PARÁMETROS DEL MÉTODO $apikey = 'b6ee27710a6747beb96bc51fbe047dcf'; // Credencial o apikye del servicio pruebas $arc_JSON2 = file_get_contents($uuid.'.txt'); //Mandamos a traer el archivo TXT $jsonBase64 = base64_encode($arc_JSON2); //agregamos el nombre del archivo txt para despues guardarlo en la base de datos $nombreArchTXT = $uuid; //ruta CERTIFICADOS NAVA $keyPEM = file_get_contents('rsc_txt/NAVA/'.$ArchKeyDemo.''); // Archivo .key en formato PEM $cerPEM = file_get_contents('rsc_txt/NAVA/'.$ArchCerDemo.''); // Archivo .cer en formato PEM //ruta CETIFICADOS 16% //$keyPEM = file_get_contents('rsc/CSD_EKU9003173C9_key.pem'); //$cerPEM = file_get_contents('rsc/CSD_EKU9003173C9_cer.pem'); $plantilla = '1'; //Indicamos el numero de plantilla para la representación grafica PDF $logo = file_get_contents('rsc_txt/log.jpg'); $logo64 = base64_encode($logo); //Consumimos el metodo JSON2 del Servicio WEB $res = $objConexion->timbrarTXT2($apikey, $jsonBase64, $keyPEM, $cerPEM, $plantilla, $logo64); //NO CONSUME TIMBRES $saldo = $objConexion->consultarCreditosDisponibles($apikey); echo 'Saldo: ' . $saldo->code . '<br>'; echo 'message Saldo: ' . $saldo->message . '<br><br>'; # RESPUESTA DEL SERVICIO echo 'code: ' . $res->code . '<br>'; echo 'message: ' . $res->message . '<br><br>'; /* 200 - Solicitud procesada con éxito. 307 - El CFDI contiene un timbre previo. */ $codigo= $res->code; $name_codigo= $res->message; $id=$sell_id; //Cuando sea codigo "200" o "307"(timbre duplicado) se guardaran los archivos XML y PDF if ($res->code == '200' ) { $mail=$posConfig->getByPreffix('admin_email')[1]['val']; ; $rfc=$client_rfc; $sell_id=$id; $sale_id=$sale1; $total=$subtotal + $impuesto; $iva=$impuestoBD; $name=$client_name; $user_id = $_SESSION['pos_id']; // Se crea el objeto de la respuesta del Servicio. $dataOBJ = json_decode($res->data); //definimos los nameSpace para remplazarlos $namespaces_remplazo = array( 'cfdi:', 'xmlns:', 'xsi:', 'oxml:', 'ns3:', 'ns9:', 'ns8:', 'S:', 'dig:', 'res:', 'wsu:', 'wsse:', 'ns3:', 'wsu:', 'soapenv:', 'env:', 'oxml:', '<![CDATA[', ']]>', 'tfd:', 'divisas:', 'ine:', 'iedu:', 'detallista:', 'ventavehiculos:', 'cce11:', 'leyendasFisc:', 'aerolineas:', 'donat:', 'notariospublicos:', 'servicioparcial:', 'vehiculousado:', 'detallista:', 'terceros:', 'implocal:', 'pfic:'); //Se realiza el remplazo de los nameSpace del atributo XML $xmlclean = str_replace($namespaces_remplazo, "", $dataOBJ->xml); $xml = simplexml_load_string($xmlclean); $json = json_encode($xml); $obj = json_decode($json); //recorremos el objeto de datos para extraer la informacion del atributo UUID echo $uuid = $obj->{'Complemento'}->{'TimbreFiscalDigital'}->{'@attributes'}->{'UUID'}; // Creamos los archivos con la extencion .xml y .pdf de la respuesta obtenida del parametro "date" file_put_contents('../../../../timbrados/cfdi_factura_' . $sell_id . '.xml', $dataOBJ->xml); //archivo XML file_put_contents('../../../../timbrados/cfdi_factura_' . $sell_id . '.pdf', base64_decode($dataOBJ->pdf)); //Archivo PDF $id=$sell_id; $mail=$emailPrincipal; $rfc=$client_rfc; $sell_id=$id; $sale_id=$sale1; $total=$total; $iva=$impuestoBD; $name=$client_name; $user_id = $_SESSION['pos_id']; $pos = new pos(); $insert = $pos->saveFacturaHono($mail,$uuid,$rfc,$sell_id,$sale_id , $subtotal, $impuestos ,$total,$iva,$name,$user_id); $retval['result'] = $insert[0]; $retval['error'] = $insert[1]; $retval['xsale_id'] = $insert[2]; if($retval['result'] == 1){ //print "<script>window.location='./basica11.php?uuid=$uuid&id=$sell_id&rfc=$client_rfc&name=$client_name&sale1=$sale_id';</script>"; $result['result'] = true; }else{ echo json_encode($retval); } }else{ //error sale id $sale_id=$sale1; //enviamos el error que se registro $codigo= $res->code; $name_codigo= $res->message; $pos = new pos(); $insert = $pos->saveErrorCFDI( $sale_id,$codigo,$name_codigo ); $retval['result'] = $insert[0]; $retval['error'] = $insert[1]; echo "<h1>Respuesta Error </h1>"; //print "<script>window.location='./errFact.php?uuid=$codigo&name_codigo=$name_codigo&id=$id';</script>"; } }else{ echo "error venta"; } ?>