����JFIF��H�H����Exif��MM�*���� ��3����V�����3������3�(��������������������3�����
Server IP : 74.208.127.88 / Your IP : 18.227.228.218 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/appsae/report/ |
Upload File : |
<?php session_start(); ini_set('display_errors', TRUE); ini_set('display_startup_errors', TRUE); include "../core/autoload.php"; include "../core/app/model/ConfigurationData.php"; setlocale(LC_TIME, 'es_MX.UTF-8'); date_default_timezone_set("America/Mexico_City"); // header('Content-Type: application/json'); require_once ("../../application/model/dbconn.php"); require_once ("../../application/model/pos.php"); //////////configuracion de servidor y ruta////////////////// $tipoServer = ConfigurationData::getByPreffix('server')->val; if($tipoServer=='W'){ $server = ConfigurationData::getByPreffix('directorioWin')->val; $rutasdk = ConfigurationData::getByPreffix('sdk')->val; $dominio = 'http://localhost/'; }else{ $server = ConfigurationData::getByPreffix('directorioLinux')->val; $rutasdk = ConfigurationData::getByPreffix('sdk')->val; //$dominio = ConfigurationData::getByPreffix('dominio')->val; } /////////////////////////////// $hoy = date("F j, Y, g:i a"); $method=$_POST['method']; $sell_id=$_POST['id']; $sale_id=$_POST['sale_id']; //datos del cliente $client_name= $_POST['client_name']; $client_rfc= $_POST['rfc']; $uso_cfdi= $_POST['uso_cfdi']; $FormaPago = $_POST['forma_id']; $notapdf = $_POST['note']; //$client_id = $_POST['client_id']; $user_id = $_SESSION['user_id']; /* $sell_id=12493; $sale_id='J221209026'; $client_name="VENTAS AL PUBLICO EN GENERAL"; $client_rfc = 'XAXX010101000'; $uso_cfdi= 'S01'; $FormaPago = '01'; $notapdf = 'NA'; $client_id = 1; */ $respuesta=''; $nombre_fichero = ''.$rutasdk.'timbrados/cfdi_factura_'.$sell_id.'.xml'; // Obtenemos la ruta al archivo de tu BD if (!file_exists($nombre_fichero)) { 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']; //folio de tabla facturacion $posFolioF = new pos(); $FolioF = $posFolioF->getByFacturaMax(); //verificamos el folio de venta en tabla facturas para ver si ya existe $facturado=new pos(); $facturado1 = $facturado->getByFacturaSellExist($sell_id); //print_r($facturado1); if(empty($facturado1[1]['id'])){ echo 'folio nuevo: '; //timbre nuevo ya que no existe registro $FolioFactura = $FolioF[1]['id'] + 1; $nuevof= true; }else{ echo 'mismo folio: '; //si existe actualizamos uuid $FolioFactura = $facturado1[1]['id']; $nuevof= false; } //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']; //consultamos los datos del cliente en tabla person $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']; //forma de pago $posForma= new pos(); $FormaPago = $posForma->getFormakId($FormaPago)[1]['def']; //**************************MULTIFACTURAS*************************// 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(); $operation1 = $operations->getOperations($sale_id); //print_r($operation1); $i=0; $impuesto=0; $subtotal=0; $subtotal0=0; $subtotal8=0; $subtotal16=0; $banderaCero = 1; foreach($operation1[1] as $operation){ if($operation['item_name'] != null){ $pos = new pos(); $result = array(); $query = $pos->getItem($operation['id_item']); $data = $query[1]; $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){ $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'; $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'] = '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 = number_format( $price_sin*$operation['qty'],2); $valor = 0.00; $banderaCero=2; echo 'tasa ceroooooooo'; $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); $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'] = 'Tasa'; $datos['conceptos'][$i]['Impuestos']['Traslados'][0]['TasaOCuota'] = '0.080000'; $datos['conceptos'][$i]['Impuestos']['Traslados'][0]['Importe'] = $valor1; $impuesto = number_format($impuesto + $valor1,2); $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); $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'] = 'Tasa'; $datos['conceptos'][$i]['Impuestos']['Traslados'][0]['TasaOCuota'] = '0.160000'; $datos['conceptos'][$i]['Impuestos']['Traslados'][0]['Importe'] = $valor1; $impuesto = number_format($impuesto + $valor1,2); $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'; } } //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'; $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; */ $posClient= new pos(); if(empty($mailC)){ $mailC = $emailPrincipal; } $uuid = 0; $total = $subtotal + $impuesto; if($nuevof == true){ $pos = new pos(); $insert = $pos->saveFacturaSell($mailC,$uuid,$client_rfc,$sell_id,$sale_id, $subtotal, $impuesto ,$total,8,$client_name,$user_id); $result['result'] = $insert[0]; $result['error'] = $insert[1]; } //generamos XML $res = mf_genera_cfdi4($datos); $codigo_error= $res['codigo_mf_numero']; $name_codigo= $res['codigo_mf_texto']; $uuid= $res['uuid']; $total=$subtotal + $impuesto; $iva=$impuestoBD; $name = $client_name; $rfc = $_POST['rfc']; if($res['codigo_mf_numero'] != 0){ foreach ($res AS $variable => $valor) { $valor = htmlentities($valor); $valor = str_replace('<br/>', '<br/>', $valor); if($variable == 'codigo_mf_texto'){ echo "<b>[$variable]=</b>$valor<hr>"; } } } //generar el pdf $datosHTML['RESPUESTA_UTF8'] = "SI"; $datosHTML['PAC']['usuario'] = ''.$userMulti.''; $datosHTML['PAC']['pass'] = ''.$passMulti.''; $datosHTML['PAC']['produccion'] = "".$FacturacionReal.""; //MODULO MULTIFACTURAS : CONVIERTE UN XML CFDI A HTML $datosHTML['modulo']="cfdi2html"; //NOMBRE MODULO $datosHTML['rutaxml']=$datos['cfdi']; //RUTA DEL XML CFDI $MombreEmisor= $settingsEmisor->val; $datosHTML['titulo']=''.$MombreEmisor.''; //TITULO DE FACTURA $datosHTML['tipo']="FACTURA"; //TIPO DE FACTURA VENTA,NOMINA,ARRENDAMIENTO, $datosHTML['path_logo']="../storage/configuration/".$logo; //RUTA DE LOGOTIPO DE FACTURA $datosHTML['notas']=$_POST['note']; //NOTA IMPRESA EN FACTURA $datosHTML['color_marco']="#324273"; //COLOR DEL MARCO DE LA FACTURA $datosHTML['color_marco_texto']="#24B7C8"; //COLOR DEL TEXTO DEL MARCO DE LA FACTURA $datosHTML['color_texto']="#042125"; //COLOR DEL TEXTO EN GENERAL $datosHTML['fuente_texto']="monospace"; //FUENTE DEL TEXTO EN GENERAL $res = mf_ejecuta_modulo($datosHTML); //FUNCION QUE CARGA EL MODULO cfdi2html $HTML=$res['html']; //HTML DEL XML //RESPUESTA DE LA FUNCION CARGAR MODULO ////////////////////////////////////////////////////////////////////////////// //CONVERTIR EL HTML DEL XML CFDI A PDF $datosPDF['PAC']['usuario'] = ''.$userMulti.''; $datosPDF['PAC']['pass'] = ''.$passMulti.''; $datosPDF['PAC']['produccion'] = "".$FacturacionReal.""; $datosPDF['modulo']="html2pdf"; //NOMBRE MODULO $datosPDF['html']="$HTML"; // HTML DE XML CFDI A CONVERTIR A PDF $datosPDF['archivo_html']=""; // OPCION SI SE TIENE UN ARCHIVO .HTML $datosPDF['archivo_pdf']="../../../sdk2/timbrados/cfdi_factura_".$sell_id.".pdf"; //$datosPDF['archivo_pdf']="RUTA DONDE SE CREARA EL PDF/nombrearhivo.pdf"; //RUTA DONDE SE GUARDARA EL PDF $res = mf_ejecuta_modulo($datosPDF); //*****************TERMINA FUNCIONES MULTIFACTURAS*************// //generamos error log de falla $test_object = new stdClass(); $test_object->var = $respuesta.'-'.$hoy; $test_object->nombre = " Factura, venta_Folio".$sell_id; error_log(print_r($test_object, true), 3, "Dental_log.log"); //guardamos la factura generada if($codigo_error == 0){ $result['result'] = true; $result['respuesta'] = $respuesta; $result['codigo_error'] = $codigo_error; $result['error'] = $name_codigo; //print_r($updateFact[0]); //echo json_encode($result); echo "<script>window.location='http://18.217.242.216/pos36/application/salesFactura4.0S1/facturaGen2.php?uuid=$respuesta&sale_id=$sale_id&rfc=client_rfc&name=$client_name';</script>"; }else{ $result['guarda_factura'] = false; $respuesta = $result['error']; echo json_encode($result); $result['result'] = false; //generamos error log de falla $test_object = new stdClass(); $test_object->var = $respuesta.'-'.$hoy; $test_object->nombre = " Factura, Error: "; error_log(print_r($test_object, true), 3, "Dental_log.log"); //print "<script>window.location='http://localhost/dentalAvil/pos11/index.php?view=errFact&error=$respuesta';</script>"; } }else{ $result['result'] = false; $result['error'] = 'folio de venta desconocido y/o no recibido'; $respuesta = $result['error']; echo json_encode($result); } }else{ //error de folio de venta no encontrado $result['result'] = false; $result['error'] = 'No se Puede Timbrar dos veces un folio, ACHIVOS XML,PDF ya recibidos'; $respuesta = $result['error']; echo json_encode($result); $test_object = new stdClass(); $test_object->var = $result['error'].'-'.$hoy; $test_object->nombre = " Factura+".$sell_id; error_log(print_r($test_object, true), 3, "Dental_log.log"); print "<script>window.location='http://18.217.242.216/pos36/pos11/index.php?view=errFact&uuid=$respuesta&sale_id=$sale_id';</script>"; } ?>