dolibarr 21.0.0-beta
lines.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
3 * Copyright (C) 2013-2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
4 * Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com>
5 * Copyright (C) 2014-2016 Florian Henry <florian.henry@open-concept.pro>
6 * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
7 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
29require '../../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
31require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
32require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
33require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
34require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
35require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
36require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
37require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
38require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
39
49// Load translation files required by the page
50$langs->loadLangs(array("bills", "compta", "accountancy", "productbatch", "products"));
51
52$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
53
54$account_parent = GETPOST('account_parent');
55$changeaccount = GETPOST('changeaccount');
56// Search Getpost
57$search_societe = GETPOST('search_societe', 'alpha');
58$search_lineid = GETPOST('search_lineid', 'alpha');
59$search_ref = GETPOST('search_ref', 'alpha');
60$search_invoice = GETPOST('search_invoice', 'alpha');
61$search_label = GETPOST('search_label', 'alpha');
62$search_desc = GETPOST('search_desc', 'alpha');
63$search_amount = GETPOST('search_amount', 'alpha');
64$search_account = GETPOST('search_account', 'alpha');
65$search_vat = GETPOST('search_vat', 'alpha');
66$search_date_startday = GETPOSTINT('search_date_startday');
67$search_date_startmonth = GETPOSTINT('search_date_startmonth');
68$search_date_startyear = GETPOSTINT('search_date_startyear');
69$search_date_endday = GETPOSTINT('search_date_endday');
70$search_date_endmonth = GETPOSTINT('search_date_endmonth');
71$search_date_endyear = GETPOSTINT('search_date_endyear');
72$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver
73$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
74$search_country = GETPOST('search_country', 'aZ09');
75$search_tvaintra = GETPOST('search_tvaintra', 'alpha');
76
77// Load variable for pagination
78$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : getDolGlobalString('ACCOUNTING_LIMIT_LIST_VENTILATION', $conf->liste_limit);
79$sortfield = GETPOST('sortfield', 'aZ09comma');
80$sortorder = GETPOST('sortorder', 'aZ09comma');
81$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
82if (empty($page) || $page < 0) {
83 $page = 0;
84}
85$offset = $limit * $page;
86$pageprev = $page - 1;
87$pagenext = $page + 1;
88if (!$sortfield) {
89 $sortfield = "f.datef, f.ref, fd.rowid";
90}
91if (!$sortorder) {
92 if (getDolGlobalInt('ACCOUNTING_LIST_SORT_VENTILATION_DONE') > 0) {
93 $sortorder = "DESC";
94 } else {
95 $sortorder = "ASC";
96 }
97}
98
99// Security check
100if (!isModEnabled('accounting')) {
102}
103if ($user->socid > 0) {
105}
106if (!$user->hasRight('accounting', 'bind', 'write')) {
108}
109
110
111$formaccounting = new FormAccounting($db);
112
113
114/*
115 * Actions
116 */
117
118// Purge search criteria
119if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
120 $search_societe = '';
121 $search_lineid = '';
122 $search_ref = '';
123 $search_invoice = '';
124 $search_label = '';
125 $search_desc = '';
126 $search_amount = '';
127 $search_account = '';
128 $search_vat = '';
129 $search_date_startday = '';
130 $search_date_startmonth = '';
131 $search_date_startyear = '';
132 $search_date_endday = '';
133 $search_date_endmonth = '';
134 $search_date_endyear = '';
135 $search_date_start = '';
136 $search_date_end = '';
137 $search_country = '';
138 $search_tvaintra = '';
139}
140
141if (is_array($changeaccount) && count($changeaccount) > 0 && $user->hasRight('accounting', 'bind', 'write')) {
142 $error = 0;
143
144 if (!(GETPOSTINT('account_parent') >= 0)) {
145 $error++;
146 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Account")), null, 'errors');
147 }
148
149 if (!$error) {
150 $db->begin();
151
152 $sql1 = "UPDATE ".MAIN_DB_PREFIX."facturedet";
153 $sql1 .= " SET fk_code_ventilation = ".(GETPOSTINT('account_parent') > 0 ? GETPOSTINT('account_parent') : 0);
154 $sql1 .= ' WHERE rowid IN ('.$db->sanitize(implode(',', $changeaccount)).')';
155
156 dol_syslog('accountancy/customer/lines.php::changeaccount sql= '.$sql1);
157 $resql1 = $db->query($sql1);
158 if (!$resql1) {
159 $error++;
160 setEventMessages($db->lasterror(), null, 'errors');
161 }
162 if (!$error) {
163 $db->commit();
164 setEventMessages($langs->trans("Save"), null, 'mesgs');
165 } else {
166 $db->rollback();
167 setEventMessages($db->lasterror(), null, 'errors');
168 }
169
170 $account_parent = ''; // Protection to avoid to mass apply it a second time
171 }
172}
173
174if (GETPOST('sortfield') == 'f.datef, f.ref, fd.rowid') {
175 $value = (GETPOST('sortorder') == 'asc,asc,asc' ? 0 : 1);
176 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
177 $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_DONE", $value, 'yesno', 0, '', $conf->entity);
178}
179
180
181/*
182 * View
183 */
184
185$form = new Form($db);
186$formother = new FormOther($db);
187
188$help_url = 'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilit&eacute;_en_Partie_Double#Liaisons_comptables';
189
190llxHeader('', $langs->trans("CustomersVentilation").' - '.$langs->trans("Dispatched"), $help_url, '', 0, 0, '', '', '', 'mod-accountancy accountancy-customer page-lines');
191
192print '<script type="text/javascript">
193 $(function () {
194 $(\'#select-all\').click(function(event) {
195 // Iterate each checkbox
196 $(\':checkbox\').each(function() {
197 this.checked = true;
198 });
199 });
200 $(\'#unselect-all\').click(function(event) {
201 // Iterate each checkbox
202 $(\':checkbox\').each(function() {
203 this.checked = false;
204 });
205 });
206 });
207 </script>';
208
209/*
210 * Customer Invoice lines
211 */
212$sql = "SELECT f.rowid as facid, f.ref as ref, f.type as ftype, f.situation_cycle_ref, f.datef, f.ref_client,";
213$sql .= " fd.rowid, fd.description, fd.product_type as line_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.vat_src_code, fd.total_ttc, fd.situation_percent,";
214$sql .= " s.rowid as socid, s.nom as name, s.code_client,";
215if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) {
216 $sql .= " spe.accountancy_code_customer as code_compta_client,";
217 $sql .= " spe.accountancy_code_supplier as code_compta_fournisseur,";
218} else {
219 $sql .= " s.code_compta as code_compta_client,";
220 $sql .= " s.code_compta_fournisseur,";
221}
222$sql .= " p.rowid as product_id, p.fk_product_type as product_type, p.ref as product_ref, p.label as product_label, p.tobuy, p.tosell,";
223if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) {
224 $sql .= " ppe.accountancy_code_sell, ppe.accountancy_code_sell_intra, ppe.accountancy_code_sell_export,";
225} else {
226 $sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,";
227}
228$sql .= " aa.rowid as fk_compte, aa.account_number, aa.label as label_account, aa.labelshort as labelshort_account,";
229$sql .= " fd.situation_percent,";
230$sql .= " co.code as country_code, co.label as country,";
231$sql .= " s.rowid as socid, s.nom as name, s.tva_intra, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur";
232$parameters = array();
233$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
234$sql .= $hookmanager->resPrint;
235$sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd";
236$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = fd.fk_product";
237if (getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) {
238 $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity);
239}
240$sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
241$sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture";
242$sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc";
243if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) {
244 $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
245}
246$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays ";
247$sql .= " WHERE fd.fk_code_ventilation > 0";
248$sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy
249$sql .= " AND f.fk_statut > 0";
250if (getDolGlobalString('FACTURE_DEPOSITS_ARE_JUST_PAYMENTS')) {
251 $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_SITUATION.")";
252} else {
253 $sql .= " AND f.type IN (".Facture::TYPE_STANDARD.",".Facture::TYPE_REPLACEMENT.",".Facture::TYPE_CREDIT_NOTE.",".Facture::TYPE_DEPOSIT.",".Facture::TYPE_SITUATION.")";
254}
255// Add search filter like
256if ($search_societe) {
257 $sql .= natural_search('s.nom', $search_societe);
258}
259if ($search_lineid) {
260 $sql .= natural_search("fd.rowid", $search_lineid, 1);
261}
262if (strlen(trim($search_invoice))) {
263 $sql .= natural_search("f.ref", $search_invoice);
264}
265if (strlen(trim($search_ref))) {
266 $sql .= natural_search("p.ref", $search_ref);
267}
268if (strlen(trim($search_label))) {
269 $sql .= natural_search("p.label", $search_label);
270}
271if (strlen(trim($search_desc))) {
272 $sql .= natural_search("fd.description", $search_desc);
273}
274if (strlen(trim($search_amount))) {
275 $sql .= natural_search("fd.total_ht", $search_amount, 1);
276}
277if (strlen(trim($search_account))) {
278 $sql .= natural_search("aa.account_number", $search_account);
279}
280if (strlen(trim($search_vat))) {
281 $sql .= natural_search("fd.tva_tx", price2num($search_vat), 1);
282}
283if ($search_date_start) {
284 $sql .= " AND f.datef >= '".$db->idate($search_date_start)."'";
285}
286if ($search_date_end) {
287 $sql .= " AND f.datef <= '".$db->idate($search_date_end)."'";
288}
289if (strlen(trim($search_country))) {
290 $arrayofcode = getCountriesInEEC();
291 $country_code_in_EEC = $country_code_in_EEC_without_me = '';
292 foreach ($arrayofcode as $key => $value) {
293 $country_code_in_EEC .= ($country_code_in_EEC ? "," : "")."'".$value."'";
294 if ($value != $mysoc->country_code) {
295 $country_code_in_EEC_without_me .= ($country_code_in_EEC_without_me ? "," : "")."'".$value."'";
296 }
297 }
298 if ($search_country == 'special_allnotme') {
299 $sql .= " AND co.code <> '".$db->escape($mysoc->country_code)."'";
300 } elseif ($search_country == 'special_eec') {
301 $sql .= " AND co.code IN (".$db->sanitize($country_code_in_EEC, 1).")";
302 } elseif ($search_country == 'special_eecnotme') {
303 $sql .= " AND co.code IN (".$db->sanitize($country_code_in_EEC_without_me, 1).")";
304 } elseif ($search_country == 'special_noteec') {
305 $sql .= " AND co.code NOT IN (".$db->sanitize($country_code_in_EEC, 1).")";
306 } else {
307 $sql .= natural_search("co.code", $search_country);
308 }
309}
310if (strlen(trim($search_tvaintra))) {
311 $sql .= natural_search("s.tva_intra", $search_tvaintra);
312}
313$sql .= " AND f.entity IN (".getEntity('invoice', 0).")"; // We don't share object for accountancy
314$sql .= $db->order($sortfield, $sortorder);
315
316// Count total nb of records
317$nbtotalofrecords = '';
318if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
319 $result = $db->query($sql);
320 $nbtotalofrecords = $db->num_rows($result);
321 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
322 $page = 0;
323 $offset = 0;
324 }
325}
326
327$sql .= $db->plimit($limit + 1, $offset);
328
329dol_syslog("/accountancy/customer/lines.php", LOG_DEBUG);
330$result = $db->query($sql);
331if ($result) {
332 $num_lines = $db->num_rows($result);
333 $i = 0;
334
335 $param = '';
336 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
337 $param .= '&contextpage='.urlencode($contextpage);
338 }
339 if ($limit > 0 && $limit != $conf->liste_limit) {
340 $param .= '&limit='.((int) $limit);
341 }
342 if ($search_societe) {
343 $param .= "&search_societe=".urlencode($search_societe);
344 }
345 if ($search_invoice) {
346 $param .= "&search_invoice=".urlencode($search_invoice);
347 }
348 if ($search_ref) {
349 $param .= "&search_ref=".urlencode($search_ref);
350 }
351 if ($search_label) {
352 $param .= "&search_label=".urlencode($search_label);
353 }
354 if ($search_desc) {
355 $param .= "&search_desc=".urlencode($search_desc);
356 }
357 if ($search_account) {
358 $param .= "&search_account=".urlencode($search_account);
359 }
360 if ($search_vat) {
361 $param .= "&search_vat=".urlencode($search_vat);
362 }
363 if ($search_date_startday) {
364 $param .= '&search_date_startday='.urlencode((string) ($search_date_startday));
365 }
366 if ($search_date_startmonth) {
367 $param .= '&search_date_startmonth='.urlencode((string) ($search_date_startmonth));
368 }
369 if ($search_date_startyear) {
370 $param .= '&search_date_startyear='.urlencode((string) ($search_date_startyear));
371 }
372 if ($search_date_endday) {
373 $param .= '&search_date_endday='.urlencode((string) ($search_date_endday));
374 }
375 if ($search_date_endmonth) {
376 $param .= '&search_date_endmonth='.urlencode((string) ($search_date_endmonth));
377 }
378 if ($search_date_endyear) {
379 $param .= '&search_date_endyear='.urlencode((string) ($search_date_endyear));
380 }
381 if ($search_country) {
382 $param .= "&search_country=".urlencode($search_country);
383 }
384 if ($search_tvaintra) {
385 $param .= "&search_tvaintra=".urlencode($search_tvaintra);
386 }
387
388 print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'."\n";
389 print '<input type="hidden" name="action" value="ventil">';
390 if ($optioncss != '') {
391 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
392 }
393 print '<input type="hidden" name="token" value="'.newToken().'">';
394 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
395 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
396 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
397 print '<input type="hidden" name="page" value="'.$page.'">';
398
399 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
400 print_barre_liste($langs->trans("InvoiceLinesDone").'<br><span class="opacitymedium small">'.$langs->trans("DescVentilDoneCustomer").'</span>', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit, 0, 0, 1);
401
402 print '<br>'.$langs->trans("ChangeAccount").' <div class="inline-block paddingbottom marginbottomonly">';
403 print $formaccounting->select_account($account_parent, 'account_parent', 2, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone valignmiddle');
404 print '<input type="submit" class="button small smallpaddingimp valignmiddle" value="'.$langs->trans("ChangeBinding").'"/></div>';
405
406 $moreforfilter = '';
407
408 print '<div class="div-table-responsive">';
409 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
410
411 print '<tr class="liste_titre_filter">';
412 print '<td class="liste_titre"><input type="text" class="flat maxwidth40" name="search_lineid" value="'.dol_escape_htmltag($search_lineid).'"></td>';
413 print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="'.dol_escape_htmltag($search_invoice).'"></td>';
414 print '<td class="liste_titre center">';
415 print '<div class="nowrapfordate">';
416 print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
417 print '</div>';
418 print '<div class="nowrapfordate">';
419 print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
420 print '</div>';
421 print '</td>';
422 print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>';
423 //print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="' . dol_escape_htmltag($search_label) . '"></td>';
424 print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>';
425 print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>';
426 print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" placeholder="%" name="search_vat" size="1" value="'.dol_escape_htmltag($search_vat).'"></td>';
427 print '<td class="liste_titre"><input type="text" class="flat maxwidth75imp" name="search_societe" value="'.dol_escape_htmltag($search_societe).'"></td>';
428 print '<td class="liste_titre">';
429 print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth150', 'code2', 1, 0, 1);
430 //print '<input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '">';
431 print '</td>';
432 print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_tvaintra" value="'.dol_escape_htmltag($search_tvaintra).'"></td>';
433 print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_account" value="'.dol_escape_htmltag($search_account).'"></td>';
434 print '<td class="liste_titre center">';
435 $searchpicto = $form->showFilterButtons();
436 print $searchpicto;
437 print "</td></tr>\n";
438
439 print '<tr class="liste_titre">';
440 print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "fd.rowid", "", $param, '', $sortfield, $sortorder);
441 print_liste_field_titre("Invoice", $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder);
442 print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "f.datef, f.ref, fd.rowid", "", $param, '', $sortfield, $sortorder, 'center ');
443 print_liste_field_titre("ProductRef", $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
444 //print_liste_field_titre("ProductLabel", $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder);
445 print_liste_field_titre("ProductDescription", $_SERVER["PHP_SELF"], "fd.description", "", $param, '', $sortfield, $sortorder);
446 print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "fd.total_ht", "", $param, '', $sortfield, $sortorder, 'right ');
447 print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "fd.tva_tx", "", $param, '', $sortfield, $sortorder, 'right ');
448 print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder);
449 print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder);
450 print_liste_field_titre("VATIntra", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder);
451 print_liste_field_titre("AccountAccounting", $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder);
452 $checkpicto = $form->showCheckAddButtons();
453 print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center ');
454 print "</tr>\n";
455
456 $thirdpartystatic = new Societe($db);
457 $facturestatic = new Facture($db);
458 $productstatic = new Product($db);
459 $accountingaccountstatic = new AccountingAccount($db);
460
461 $i = 0;
462 while ($i < min($num_lines, $limit)) {
463 $objp = $db->fetch_object($result);
464
465 $facturestatic->ref = $objp->ref;
466 $facturestatic->id = $objp->facid;
467 $facturestatic->type = $objp->ftype;
468
469 $thirdpartystatic->id = $objp->socid;
470 $thirdpartystatic->name = $objp->name;
471 $thirdpartystatic->client = $objp->client;
472 $thirdpartystatic->fournisseur = $objp->fournisseur;
473 $thirdpartystatic->code_client = $objp->code_client;
474 $thirdpartystatic->code_compta_client = $objp->code_compta_client;
475 $thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
476 $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
477 $thirdpartystatic->email = $objp->email;
478 $thirdpartystatic->country_code = $objp->country_code;
479
480 $productstatic->ref = $objp->product_ref;
481 $productstatic->id = $objp->product_id;
482 $productstatic->label = $objp->product_label;
483 $productstatic->type = $objp->line_type;
484 $productstatic->status = $objp->tosell;
485 $productstatic->status_buy = $objp->tobuy;
486 $productstatic->accountancy_code_sell = $objp->accountancy_code_sell;
487 $productstatic->accountancy_code_sell_intra = $objp->accountancy_code_sell_intra;
488 $productstatic->accountancy_code_sell_export = $objp->accountancy_code_sell_export;
489
490 $accountingaccountstatic->rowid = $objp->fk_compte;
491 $accountingaccountstatic->label = $objp->label_account;
492 $accountingaccountstatic->labelshort = $objp->labelshort_account;
493 $accountingaccountstatic->account_number = $objp->account_number;
494
495 print '<tr class="oddeven">';
496
497 // Line id
498 print '<td>'.$objp->rowid.'</td>';
499
500 // Ref Invoice
501 print '<td class="nowraponall tdoverflowmax125">'.$facturestatic->getNomUrl(1).'</td>';
502
503 // Date invoice
504 print '<td class="center">'.dol_print_date($db->jdate($objp->datef), 'day').'</td>';
505
506 // Ref Product
507 print '<td class="tdoverflowmax100">';
508 if ($productstatic->id > 0) {
509 print $productstatic->getNomUrl(1);
510 } else {
511 print '&nbsp;';
512 }
513 //if ($productstatic->id > 0 && $objp->product_label) {
514 print '<br>';
515 //}
516 if ($objp->product_label) {
517 print '<span class="opacitymedium">'.$objp->product_label.'</span>';
518 } else {
519 print '&nbsp;';
520 }
521 print '</td>';
522
523 $text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description, 1));
524 print '<td class="tdoverflowmax200 small" title="'.dol_escape_htmltag($text).'">';
525 $trunclength = getDolGlobalInt('ACCOUNTING_LENGTH_DESCRIPTION', 32);
526 print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->description);
527 print '</td>';
528
529 // Amount
530 print '<td class="right nowraponall amount">';
531
532 // Create a compensation rate for old situation invoice feature.
533 $situation_ratio = 1;
534 if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1) {
535 if ($objp->situation_cycle_ref) {
536 // Avoid divide by 0
537 if ($objp->situation_percent == 0) {
538 $situation_ratio = 0;
539 } else {
540 $line = new FactureLigne($db);
541 $line->fetch($objp->rowid);
542
543 // Situation invoices handling
544 $prev_progress = $line->get_prev_progress($objp->facid);
545
546 $situation_ratio = ($objp->situation_percent - $prev_progress) / $objp->situation_percent;
547 }
548 }
549 print price($objp->total_ht * $situation_ratio);
550 } else {
551 print price($objp->total_ht);
552 }
553 print '</td>';
554
555 // Vat rate
556 print '<td class="right">'.vatrate($objp->tva_tx.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')).'</td>';
557
558 // Thirdparty
559 print '<td class="tdoverflowmax100">'.$thirdpartystatic->getNomUrl(1, 'customer').'</td>';
560
561 // Country
562 print '<td>';
563 if ($objp->country_code) {
564 print $langs->trans("Country".$objp->country_code).' ('.$objp->country_code.')';
565 }
566 print '</td>';
567
568 print '<td class="tdoverflowmax80" title="'.dol_escape_htmltag($objp->tva_intra).'">'.dol_escape_htmltag($objp->tva_intra).'</td>';
569
570 print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($accountingaccountstatic->label).'">';
571 print '<a class="editfielda" href="./card.php?id='.$objp->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($param ? '?'.$param : '')).'">';
572 print img_edit();
573 print '</a> ';
574 print $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1);
575 print '</td>';
576
577 print '<td class="center"><input type="checkbox" class="checkforaction" name="changeaccount[]" value="'.$objp->rowid.'"/></td>';
578
579 print '</tr>';
580 $i++;
581 }
582 if ($num_lines == 0) {
583 print '<tr><td colspan="12"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
584 }
585
586 print '</table>';
587 print "</div>";
588
589 if ($nbtotalofrecords > $limit) {
590 print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1);
591 }
592
593 print '</form>';
594} else {
595 print $db->lasterror();
596}
597
598// End of page
599llxFooter();
600$db->close();
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:71
Class to manage accounting accounts.
Class to manage invoices.
const TYPE_REPLACEMENT
Replacement invoice.
const TYPE_SITUATION
Situation invoice.
const TYPE_DEPOSIT
Deposit invoice.
const TYPE_CREDIT_NOTE
Credit note invoice.
Class to manage invoice lines.
Class to manage generation of HTML components for accounting management.
Class to manage generation of HTML components Only common components must be here.
Class permettant la generation de composants html autre Only common components are here.
Class to manage products or services.
Class to manage third parties objects (customers, suppliers, prospects...)
getCountriesInEEC()
Return list of countries that are inside the EEC (European Economic Community) Note: Try to keep this...
llxFooter()
Footer empty.
Definition document.php:107
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolGetFirstLineOfText($text, $nboflines=1, $charset='UTF-8')
Return first line of text.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.