· 5 years ago · May 22, 2020, 03:56 PM
1<?php
2/**^M
3 * Invoice has been fully paid^M
4 * Following variable is available to use in this file: $details This array of invoice details contains following keys:
5 * $details["id"]; // Invoice id
6 * $details["status"]; //Current invoice status
7 * $details["client_id"]; //Owner of invoice
8 * $details["date"]; //Invoice generation date
9 * $details["subtotal"]; //Subtotal
10 * $details["credit"]; //Credit applied to invoice
11 * $details["tax"]; //Tax applied to invoice
12 * $details["total"]; //Invoice total
13 * $details["payment_module"]; //ID of gateway used with invoice
14 * $details["currency_id"]; //ID of invoice currency, default =0
15 * $details["notes"]; //Invoice notes
16 * $details["items"]; // Invoice items are listed under this key, sample item:
17 * $details["items"][0]["type"]; //Item type (ie. Hosting, Domain)
18 * $details["items"][0]["item_id"]; //Item id, for type=Hosting this relates to hb_accounts.id field
19 * $details["items"][0]["description"]; //Item line text
20 * $details["items"][0]["amount"]; //Item price
21 * $details["items"][0]["taxed"]; //Is item taxed? 1/0
22 * $details["items"][0]["qty"]; //Item quantitiy^M
23 */
24 /* Use this method to access HostBill api from HostBill modules */
25 //$cero = "0.00";
26 if ($details['tax'] > 0 ) {
27 $api = new ApiWrapper();
28 $parametros = array(
29 'id'=>$details["client_id"]
30 );
31 $datos = $api->getClientDetails($parametros);
32 $params = array(
33 'client_id'=>$details["client_id"],
34 'dept_id'=>3,
35 'subject'=>"Pago recibido - Emisión {$datos['client']['documentotributario']} Electrónica - Orden de Compra {$details['id']}",
36 'body'=>"Estimado/a,
37
38Le informamos que hemos recibido su pago y se ha iniciado el proceso de emisión de su {$datos['client']['documentotributario']} electrónica, la cual estará disponible en las próximas 72 horas hábiles a contar de este momento, de no tener sus datos de facturación registrados, le solicitaremos la información a través de este ticket.
39
40Datos del pago recibido:
41Orden de Compra Web : {$details['id']}
42Valor neto: \${$details['subtotal']} CLP
43IVA (19%) : \${$details['tax']} CLP
44TOTAL : \${$details['total']} CLP
45
46Documento a emitir: {$datos['client']['documentotributario']}
47
48Cualquier duda puede responder este mail indicando su consulta o enviar directamente un correo a comercial@hnd.cl
49
50--
51HOSTEDNODE SPA
52SERVICIOS WEB, SOFTWARE Y TECNOLOGIA
53+56 9 51231988 - online@hostednode.cl
54Alfredo Barros Errazuriz 1900 of 402, Providencia
55
56",
57 );
58 $return = $api->addTicket($params);
59
60 if ($datos['client']['autofacturacion'][0] == "si"){
61 $autofactu=1;
62 }else{
63 $autofactu=0;
64 }
65
66 if (!empty($datos['client']['documentotributario']) && $datos['client']['documentotributario'] == 'Factura' )
67 {
68 $rutfact = $datos['client']['rut'];
69 }else{
70 $rutfact = '66666666-6';
71 }
72
73 $enlaceBASE = mysqli_connect("localhost","portal_hbuser", "4Y3gREN5vr","portal_hb");
74 mysqli_set_charset($enlaceBASE,"utf-8");
75
76 $query_mysql = "INSERT INTO autofacturacion (clienteID, RUT, Documento, InvoiceID, TicketID, TimeStamp, autofacturacion) VALUES";
77 $query_mysql .= "('".$details['client_id']."', '".$datos['client']['rut']."', '".$datos['client']['documentotributario']."', '".$details['id']."', '".$return['ticket_id']."', ";
78 $query_mysql .= " '".$return['server_time']."', '".$datos['client']['autofacturacion'][0]."' )" ;
79
80 $q=mysqli_query($enlaceBASE , $query_mysql);
81 if (!$q) {
82 echo ("Error Mysql: %s\n".mysqli_error($enlaceBASE)."");
83 }
84
85 }
86 ?>