1 | <?php |
||
2 | /* Copyright (C) 2004-2005 Rodolphe Quiedeville <[email protected]> |
||
3 | * Copyright (C) 2005 Laurent Destailleur <[email protected]> |
||
4 | * Copyright (C) 2013 Olivier Geffroy <[email protected]> |
||
5 | * Copyright (C) 2013 Florian Henry <[email protected]> |
||
6 | * Copyright (C) 2013-2018 Alexandre Spangaro <[email protected]> |
||
7 | * Copyright (C) 2018 Frédéric France <[email protected]> |
||
8 | * Copyright (C) 2018-2019 Alxarafe <[email protected]> |
||
9 | * |
||
10 | * This program is free software; you can redistribute it and/or modify |
||
11 | * it under the terms of the GNU General Public License as published by |
||
12 | * the Free Software Foundation; either version 3 of the License, or |
||
13 | * (at your option) any later version. |
||
14 | * |
||
15 | * This program is distributed in the hope that it will be useful, |
||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
18 | * GNU General Public License for more details. |
||
19 | * |
||
20 | * You should have received a copy of the GNU General Public License |
||
21 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
||
22 | * |
||
23 | */ |
||
24 | |||
25 | /** |
||
26 | * \file htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php |
||
27 | * \ingroup accountancy |
||
28 | * \brief Tab to manage customer lettering |
||
29 | */ |
||
30 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
||
31 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
||
32 | require DOL_BASE_PATH . '/main.inc.php'; |
||
33 | require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; |
||
34 | require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; |
||
35 | require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php'; |
||
36 | require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; |
||
37 | require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; |
||
38 | |||
39 | // Load translation files required by the page |
||
40 | $langs->loadLangs(array("compta", "accountancy")); |
||
41 | |||
42 | $action = GETPOST('action', 'aZ09'); |
||
43 | $massaction = GETPOST('massaction', 'alpha'); |
||
44 | $show_files = GETPOST('show_files', 'int'); |
||
45 | $confirm = GETPOST('confirm', 'alpha'); |
||
46 | $toselect = GETPOST('toselect', 'array'); |
||
47 | |||
48 | $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; |
||
49 | $sortfield = GETPOST("sortfield", 'alpha'); |
||
50 | $sortorder = GETPOST("sortorder", 'alpha'); |
||
51 | $page = GETPOST("page", 'int'); |
||
52 | if (empty($page) || $page == - 1) { |
||
53 | $page = 0; |
||
54 | } // If $page is not defined, or '' or -1 |
||
55 | $offset = $limit * $page; |
||
56 | $pageprev = $page - 1; |
||
57 | $pagenext = $page + 1; |
||
58 | if ($sortorder == "") { |
||
59 | $sortorder = "DESC"; |
||
60 | } |
||
61 | if ($sortfield == "") { |
||
62 | $sortfield = "bk.doc_date"; |
||
63 | } |
||
64 | |||
65 | $search_year = GETPOST("search_year", 'int'); |
||
66 | $search_doc_type = GETPOST("search_doc_type", 'alpha'); |
||
67 | $search_doc_ref = GETPOST("search_doc_ref", 'alpha'); |
||
68 | |||
69 | $lettering = GETPOST('lettering', 'alpha'); |
||
70 | if (!empty($lettering)) { |
||
71 | $action = $lettering; |
||
72 | } |
||
73 | |||
74 | // Did we click on purge search criteria ? |
||
75 | // All tests are required to be compatible with all browsers |
||
76 | if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { |
||
77 | $search_year = ''; |
||
78 | $search_doc_type = ''; |
||
79 | $search_doc_ref = ''; |
||
80 | } |
||
81 | |||
82 | // Security check |
||
83 | $socid = GETPOST("socid", 'int'); |
||
84 | // if ($user->societe_id) $socid=$user->societe_id; |
||
85 | |||
86 | $lettering = new Lettering($db); |
||
87 | $object = new Societe($db); |
||
88 | $object->id = $socid; |
||
0 ignored issues
–
show
|
|||
89 | $result = $object->fetch($socid); |
||
90 | if ($result < 0) { |
||
91 | setEventMessages($object->error, $object->errors, 'errors'); |
||
92 | } |
||
93 | |||
94 | |||
95 | /* |
||
96 | * Action |
||
97 | */ |
||
98 | |||
99 | if ($action == 'lettering') { |
||
100 | |||
101 | $result = $lettering->updateLettering($toselect); |
||
102 | |||
103 | if ($result < 0) { |
||
104 | setEventMessages('', $lettering->errors, 'errors'); |
||
105 | $error++; |
||
106 | } |
||
107 | } |
||
108 | |||
109 | if ($action == 'autolettrage') { |
||
110 | |||
111 | $result = $lettering->letteringThirdparty($socid); |
||
112 | |||
113 | if ($result < 0) { |
||
114 | setEventMessages('', $lettering->errors, 'errors'); |
||
115 | $error++; |
||
116 | } |
||
117 | } |
||
118 | |||
119 | |||
120 | /* |
||
121 | * View |
||
122 | */ |
||
123 | |||
124 | $form = new Form($db); |
||
125 | $formaccounting = new FormAccounting($db); |
||
126 | |||
127 | $title = $object->name . " - " . $langs->trans('TabLetteringCustomer'); |
||
128 | $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; |
||
129 | llxHeader('', $title, $help_url); |
||
130 | |||
131 | $head = societe_prepare_head($object); |
||
132 | |||
133 | dol_htmloutput_mesg(is_numeric($error) ? '' : $error, $errors, 'error'); |
||
134 | |||
135 | dol_fiche_head($head, 'lettering_customer', $langs->trans("ThirdParty"), 0, 'company'); |
||
136 | |||
137 | //$linkback = '<a href="' . DOL_URL_ROOT . '/societe/list.php?restore_lastsearch_values=1">' . $langs->trans("BackToList") . '</a>'; |
||
138 | $linkback = '<a href="' . BASE_URI . '?controller=societe&method=list&restore_lastsearch_values=1">' . $langs->trans("BackToList") . '</a>'; |
||
139 | |||
140 | dol_banner_tab($object, 'socid', $linkback, ($user->societe_id ? 0 : 1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom'); |
||
141 | |||
142 | dol_fiche_end(); |
||
143 | |||
144 | print '<br>'; |
||
145 | |||
146 | $sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, "; |
||
147 | $sql .= " bk.subledger_account, bk.numero_compte , bk.label_compte, bk.debit, "; |
||
148 | $sql .= " bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.lettering_code "; |
||
149 | $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as bk"; |
||
150 | $sql .= " WHERE (bk.subledger_account = '" . $object->code_compta . "' AND bk.numero_compte = '" . $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER . "' )"; |
||
151 | |||
152 | if (dol_strlen($search_year)) { |
||
153 | $date_start = dol_mktime(0, 0, 0, 1, 1, $search_year); |
||
154 | $date_end = dol_mktime(23, 59, 59, 12, 31, $search_year); |
||
155 | $sql .= " AND ( bk.doc_date BETWEEN '" . $db->idate($date_start) . "' AND '" . $db->idate($date_end) . "' )"; |
||
156 | } |
||
157 | |||
158 | $sql .= $db->order($sortfield, $sortorder); |
||
159 | |||
160 | $debit = 0; |
||
161 | $credit = 0; |
||
162 | $solde = 0; |
||
163 | // Count total nb of records and calc total sum |
||
164 | $nbtotalofrecords = ''; |
||
165 | $resql = $db->query($sql); |
||
166 | if (!$resql) { |
||
167 | dol_print_error($db); |
||
168 | exit(); |
||
169 | } |
||
170 | $nbtotalofrecords = $db->num_rows($resql); |
||
171 | |||
172 | while ($obj = $db->fetch_object($resql)) { |
||
173 | $debit += $obj->debit; |
||
174 | $credit += $obj->credit; |
||
175 | |||
176 | $solde += ($obj->credit - $obj->debit); |
||
177 | } |
||
178 | |||
179 | $sql .= $db->plimit($limit + 1, $offset); |
||
180 | |||
181 | dol_syslog("/accountancy/bookkeeping/thirdparty_lettering_customer.php", LOG_DEBUG); |
||
182 | $resql = $db->query($sql); |
||
183 | if (!$resql) { |
||
184 | dol_print_error($db); |
||
185 | exit(); |
||
186 | } |
||
187 | |||
188 | $num = $db->num_rows($resql); |
||
189 | |||
190 | dol_syslog("/accountancy/bookkeeping/thirdparty_lettering_customer.php", LOG_DEBUG); |
||
191 | if ($resql) { |
||
192 | $i = 0; |
||
193 | |||
194 | // print '<form name="add" action="' . $_SERVER["PHP_SELF"] . '?socid=' . $object->id . '" method="POST">'; |
||
195 | print '<form name="add" action="' . BASE_URI . '?controller=accountancy/bookkeeping&method=thirdparty_lettering_customer&socid=' . $object->id . '" method="POST">'; |
||
196 | print '<input type="hidden" name="socid" value="' . $object->id . '">'; |
||
197 | |||
198 | print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit); |
||
199 | |||
200 | print "<table class=\"noborder\" width=\"100%\">"; |
||
201 | print '<tr class="liste_titre">'; |
||
202 | print_liste_field_titre("Doctype", $_SERVER["PHP_SELF"], "bk.doc_type", "", $param, "", $sortfield, $sortorder); |
||
203 | print_liste_field_titre("Docdate", $_SERVER["PHP_SELF"], "bk.doc_date", "", $param, "", $sortfield, $sortorder); |
||
204 | print_liste_field_titre("Docref", $_SERVER["PHP_SELF"], "bk.doc_ref", "", $param, "", $sortfield, $sortorder); |
||
205 | print_liste_field_titre("LabelAccount", $_SERVER["PHP_SELF"], "bk.label_compte", "", $param, "", $sortfield, $sortorder); |
||
206 | print_liste_field_titre("Debit", $_SERVER["PHP_SELF"], "bk.debit", "", $param, "", $sortfield, $sortorder); |
||
207 | print_liste_field_titre("Credit", $_SERVER["PHP_SELF"], "bk.credit", "", $param, "", $sortfield, $sortorder); |
||
208 | print_liste_field_titre("Balancing", $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder); |
||
209 | print_liste_field_titre("Codejournal", $_SERVER["PHP_SELF"], "bk.code_journal", "", $param, "", $sortfield, $sortorder); |
||
210 | print_liste_field_titre("LetteringCode", $_SERVER["PHP_SELF"], "bk.lettering_code", "", $param, "", $sortfield, $sortorder); |
||
211 | print "</tr>\n"; |
||
212 | |||
213 | print '<tr class="liste_titre">'; |
||
214 | print '<td><input type="text" name="search_doc_type" value="' . $search_doc_type . '"></td>'; |
||
215 | print '<td><input type="text" name="search_year" value="' . $search_year . '"></td>'; |
||
216 | print '<td><input type="text" name="search_doc_refe" value="' . $search_doc_ref . '"></td>'; |
||
217 | print '<td colspan="5"> </td>'; |
||
218 | print '<td align="right">'; |
||
219 | $searchpicto = $form->showFilterButtons(); |
||
220 | print $searchpicto; |
||
221 | print '</td>'; |
||
222 | print '</tr>'; |
||
223 | |||
224 | $solde = 0; |
||
225 | $tmp = ''; |
||
226 | while ($obj = $db->fetch_object($resql)) { |
||
227 | |||
228 | if ($tmp != $obj->lettering_code || empty($tmp)) |
||
229 | $tmp = $obj->lettering_code; |
||
230 | /* if ($tmp != $obj->lettering_code || empty($obj->lettering_code)) */ $solde += ($obj->credit - $obj->debit); |
||
231 | |||
232 | print '<tr class="oddeven">'; |
||
233 | |||
234 | if (empty($obj->lettering_code)) { |
||
235 | //print '<td><a href="' . dol_buildpath('/accountancy/bookkeeping/card.php', 1) . '?piece_num=' . $obj->piece_num . '">'; |
||
236 | print '<td><a href="' . BASE_PATH . '?controller=accountancy/bookkeeping&method=card&piece_num=' . $obj->piece_num . '">'; |
||
237 | print img_edit(); |
||
238 | print '</a> ' . $obj->doc_type . '</td>' . "\n"; |
||
239 | } else { |
||
240 | print '<td>' . $obj->doc_type . '</td>' . "\n"; |
||
241 | } |
||
242 | |||
243 | print '<td>' . dol_print_date($db->jdate($obj->doc_date), 'day') . '</td>'; |
||
244 | print '<td>' . $obj->doc_ref . '</td>'; |
||
245 | print '<td>' . $obj->label_compte . '</td>'; |
||
246 | print '<td align="right">' . price($obj->debit) . '</td>'; |
||
247 | print '<td align="right">' . price($obj->credit) . '</td>'; |
||
248 | print '<td align="right">' . price(round($solde, 2)) . '</td>'; |
||
249 | print '<td align="center">' . $obj->code_journal . '</td>'; |
||
250 | |||
251 | if (empty($obj->lettering_code)) { |
||
252 | print '<td class="nowrap" align="center"><input type="checkbox" class="flat checkforselect" name="toselect[]" id="toselect[]" value="' . $obj->rowid . '" /></td>'; |
||
253 | } else |
||
254 | print '<td align="center">' . $obj->lettering_code . '</td>'; |
||
255 | |||
256 | print "</tr>\n"; |
||
257 | } |
||
258 | |||
259 | print '<tr class="oddeven">'; |
||
260 | print '<td align="right" colspan="4">' . $langs->trans("Total") . ':</td>' . "\n"; |
||
261 | print '<td align="right"><strong>' . price($debit) . '</strong></td>'; |
||
262 | print '<td align="right"><strong>' . price($credit) . '</strong></td>'; |
||
263 | print '<td colspan="5"></td>'; |
||
264 | print "</tr>\n"; |
||
265 | |||
266 | print '<tr class="oddeven">'; |
||
267 | print '<td align="right" colspan="4">' . $langs->trans("Balancing") . ':</td>' . "\n"; |
||
268 | print '<td colspan="2"> </td>'; |
||
269 | print '<td align="right"><strong>' . price($credit - $debit) . '</strong></td>'; |
||
270 | print '<td colspan="3"></td>'; |
||
271 | print "</tr>\n"; |
||
272 | |||
273 | print "</table>"; |
||
274 | |||
275 | print '<input class="butAction" type="submit" value="lettering" name="lettering" id="lettering">'; |
||
276 | //print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?socid=' . $object->id . '&action=autolettering">' . $langs->trans('AccountancyAutoLettering') . '</a>'; |
||
277 | print "</form>"; |
||
278 | $db->free($resql); |
||
279 | } else { |
||
280 | dol_print_error($db); |
||
281 | } |
||
282 | |||
283 | // End of page |
||
284 | llxFooter(); |
||
285 | $db->close(); |
||
286 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..