|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* Copyright (C) 2021 Joe Nilson <[email protected]> |
|
4
|
|
|
* |
|
5
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
6
|
|
|
* it under the terms of the GNU Lesser General Public License as |
|
7
|
|
|
* published by the Free Software Foundation, either version 3 of the |
|
8
|
|
|
* License, or (at your option) any later version. |
|
9
|
|
|
* |
|
10
|
|
|
* This program is distributed in the hope that it will be useful, |
|
11
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13
|
|
|
* GNU Lesser General Public License for more details. |
|
14
|
|
|
* You should have received a copy of the GNU Lesser General Public License |
|
15
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
16
|
|
|
*/ |
|
17
|
|
|
require_once 'plugins/residentes/extras/residentes_pdf.php'; |
|
18
|
|
|
require_once 'plugins/residentes/extras/residentesEnviarMail.php'; |
|
19
|
|
|
|
|
20
|
|
|
class ResidentesEstadoCuenta |
|
21
|
|
|
{ |
|
22
|
|
|
public $archivo; |
|
23
|
|
|
public $empresa; |
|
24
|
|
|
public $emailHelper; |
|
25
|
|
|
public $cliente_residente; |
|
26
|
|
|
public $documento; |
|
27
|
|
|
public $info_accion; |
|
28
|
|
|
public $user; |
|
29
|
|
|
public $rc; |
|
30
|
|
|
public function __construct($empresa, $cliente_residente, $user, $archivo, $info_accion) |
|
31
|
|
|
{ |
|
32
|
|
|
$this->archivo = $archivo; |
|
33
|
|
|
$this->empresa = $empresa; |
|
34
|
|
|
$this->cliente_residente = $cliente_residente; |
|
35
|
|
|
$this->user = $user; |
|
36
|
|
|
$this->info_accion = $info_accion; |
|
37
|
|
|
$this->documento = new residentes_pdf('letter', 'portrait'); |
|
38
|
|
|
$this->emailHelper = new ResidentesEnviarMail(); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function crearEstadoCuenta($pendiente, $pagado) |
|
42
|
|
|
{ |
|
43
|
|
|
$this->documento->cliente_residente = $this->cliente_residente; |
|
44
|
|
|
$this->documento->pdf->addInfo('Title', 'Pagos Residente ' . |
|
45
|
|
|
$this->cliente_residente->codcliente); |
|
46
|
|
|
$this->documento->pdf->addInfo('Subject', 'Pagos del Residente ' . |
|
47
|
|
|
$this->cliente_residente->codcliente); |
|
48
|
|
|
$this->documento->pdf->addInfo('Author', $this->empresa->nombre); |
|
49
|
|
|
$this->documento->pdf->ezSetMargins(10, 10, 10, 10); |
|
50
|
|
|
$this->crear_documento_cobros($pendiente, $pagado); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public function crear_documento_cobros($pendiente, $pagado) |
|
54
|
|
|
{ |
|
55
|
|
|
// $this->pendiente = $this->pagosFactura(false); |
|
56
|
|
|
// $this->pagado = $this->pagosFactura(true); |
|
57
|
|
|
$linea_actual = 0; |
|
58
|
|
|
$pagina = 1; |
|
59
|
|
|
$lppag = 32; /// líneas por página |
|
60
|
|
|
while ($linea_actual < count($pendiente)) { |
|
61
|
|
|
/// salto de página |
|
62
|
|
|
if ($linea_actual > 0) { |
|
63
|
|
|
$this->documento->pdf->ezNewPage(); |
|
64
|
|
|
} |
|
65
|
|
|
$this->documento->generar_pdf_cabecera($this->empresa, $lppag); |
|
66
|
|
|
$this->documento->generar_datos_residente($this->documento, 'informe_cobros', $lppag); |
|
67
|
|
|
$this->documento->generar_pdf_lineas( |
|
68
|
|
|
$this->documento, |
|
69
|
|
|
$pendiente, |
|
70
|
|
|
$linea_actual, |
|
71
|
|
|
$lppag, |
|
72
|
|
|
'pendiente' |
|
73
|
|
|
); |
|
74
|
|
|
$this->documento->set_y($this->documento->pdf->y - 16); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
$linea_actual2 = 0; |
|
78
|
|
|
while ($linea_actual2 < count($pagado)) { |
|
79
|
|
|
if ($linea_actual2 > 0) { |
|
80
|
|
|
$this->documento->pdf->ezNewPage(); |
|
81
|
|
|
} elseif ($linea_actual === 0) { |
|
82
|
|
|
$this->documento->generar_pdf_cabecera($this->empresa, $lppag); |
|
83
|
|
|
$this->documento->generar_datos_residente($this->documento, 'informe_cobros', $lppag); |
|
84
|
|
|
} |
|
85
|
|
|
$this->documento->generar_pdf_lineas( |
|
86
|
|
|
$this->documento, |
|
87
|
|
|
$pagado, |
|
88
|
|
|
$linea_actual2, |
|
89
|
|
|
$lppag, |
|
90
|
|
|
'pagado' |
|
91
|
|
|
); |
|
92
|
|
|
$pagina++; |
|
93
|
|
|
} |
|
94
|
|
|
$this->documento->set_y(80); |
|
95
|
|
|
if ($this->empresa->pie_factura) { |
|
96
|
|
|
$this->documento->pdf->addText(20, 40, 8, fs_fix_html('<b>Generado por:</b> ' . |
|
97
|
|
|
$this->user->get_agente_fullname()), 0); |
|
98
|
|
|
$this->documento->pdf->addText( |
|
99
|
|
|
10, |
|
100
|
|
|
30, |
|
101
|
|
|
8, |
|
102
|
|
|
$this->documento->center_text(fs_fix_html($this->empresa->pie_factura), 180) |
|
103
|
|
|
); |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
if ($this->info_accion === 'enviar') { |
|
107
|
|
|
$this->documento->save('tmp/' . FS_TMP_NAME . 'enviar/' . $this->archivo); |
|
108
|
|
|
$this->emailHelper->accountStatusEmail( |
|
109
|
|
|
$this->empresa, |
|
110
|
|
|
$this->cliente_residente, |
|
111
|
|
|
$this->user, |
|
112
|
|
|
$this->archivo |
|
113
|
|
|
); |
|
114
|
|
|
} else { |
|
115
|
|
|
$this->documento->show('documento_cobros_' . \date('dmYhis') . '.pdf'); |
|
116
|
|
|
} |
|
117
|
|
|
} |
|
118
|
|
|
} |