dolibarr  7.0.0-beta
list.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
3  * Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro@zendsi.com>
4  * Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com>
5  * Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
6  * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
7  * Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
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 <http://www.gnu.org/licenses/>.
21  */
22 
28 require '../../main.inc.php';
29 
30 // Class
31 require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
32 require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
33 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
34 require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
35 require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
36 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
37 require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
38 
39 // Langs
40 $langs->load("compta");
41 $langs->load("bills");
42 $langs->load("other");
43 $langs->load("main");
44 $langs->load("accountancy");
45 $langs->load("productbatch");
46 
47 $action=GETPOST('action','alpha');
48 $massaction=GETPOST('massaction','alpha');
49 $show_files=GETPOST('show_files','int');
50 $confirm=GETPOST('confirm','alpha');
51 $toselect = GETPOST('toselect', 'array');
52 
53 // Select Box
54 $mesCasesCochees = GETPOST('toselect', 'array');
55 
56 // Search Getpost
57 $search_lineid = GETPOST('search_lineid', 'int');
58 $search_invoice = GETPOST('search_invoice', 'alpha');
59 $search_ref = GETPOST('search_ref', 'alpha');
60 $search_label = GETPOST('search_label', 'alpha');
61 $search_desc = GETPOST('search_desc', 'alpha');
62 $search_amount = GETPOST('search_amount', 'alpha');
63 $search_account = GETPOST('search_account', 'alpha');
64 $search_vat = GETPOST('search_vat', 'alpha');
65 $search_day=GETPOST("search_day","int");
66 $search_month=GETPOST("search_month","int");
67 $search_year=GETPOST("search_year","int");
68 
69 $btn_ventil = GETPOST('ventil', 'alpha');
70 
71 // Load variable for pagination
72 $limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
73 $sortfield = GETPOST('sortfield', 'alpha');
74 $sortorder = GETPOST('sortorder', 'alpha');
75 $page = GETPOST('page','int');
76 if (empty($page) || $page < 0) { $page = 0; }
77 $offset = $limit * $page;
78 $pageprev = $page - 1;
79 $pagenext = $page + 1;
80 if (! $sortfield)
81  $sortfield = "f.datef, f.facnumber, l.rowid";
82 if (! $sortorder) {
83  if ($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO > 0) {
84  $sortorder = "DESC";
85  }
86 }
87 
88 // Security check
89 if ($user->societe_id > 0)
91 if (! $user->rights->accounting->bind->write)
93 
94 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
95 $hookmanager->initHooks(array('accountancycustomerlist'));
96 
97 $formaccounting = new FormAccounting($db);
98 $accounting = new AccountingAccount($db);
99 $aarowid_s = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT, 1);
100 $aarowid_p = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT, 1);
101 
102 $chartaccountcode = dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'accounting_system', 'rowid', 'pcg_version');
103 
104 
105 /*
106  * Action
107  */
108 
109 if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; }
110 if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
111 
112 $parameters=array();
113 $reshook=$hookmanager->executeHooks('doActions',$parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
114 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
115 
116 if (empty($reshook))
117 {
118  // Purge search criteria
119  if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers
120  {
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_day = '';
130  $search_month = '';
131  $search_year = '';
132  }
133 
134  // Mass actions
135  $objectclass='AccountingAccount';
136  $permtoread = $user->rights->accounting->read;
137  $permtodelete = $user->rights->accounting->delete;
138  $uploaddir = $conf->accounting->dir_output;
139  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
140 }
141 
142 
143 if ($massaction == 'ventil') {
144  $msg='';
145 
146  //print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>';
147  if (! empty($mesCasesCochees)) {
148  $msg = '<div>' . $langs->trans("SelectedLines") . ': '.count($mesCasesCochees).'</div>';
149  $msg.='<div class="detail">';
150  $cpt = 0;
151  $ok=0;
152  $ko=0;
153 
154  foreach ($mesCasesCochees as $maLigneCochee) {
155  $maLigneCourante = explode("_", $maLigneCochee);
156  $monId = $maLigneCourante[0];
157  $monCompte = GETPOST('codeventil'.$monId);
158 
159  if ($monCompte <= 0)
160  {
161  $msg.= '<div><font color="red">' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("NoAccountSelected") . '</font></div>';
162  $ko++;
163  }
164  else
165  {
166  $sql = " UPDATE " . MAIN_DB_PREFIX . "facturedet";
167  $sql .= " SET fk_code_ventilation = " . $monCompte;
168  $sql .= " WHERE rowid = " . $monId;
169 
170  $accountventilated = new AccountingAccount($db);
171  $accountventilated->fetch($monCompte, '');
172 
173  dol_syslog("accountancy/customer/list.php sql=" . $sql, LOG_DEBUG);
174  if ($db->query($sql)) {
175  $msg.= '<div><font color="green">' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("VentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '</font></div>';
176  $ok++;
177  } else {
178  $msg.= '<div><font color="red">' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("NotVentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '<br> <pre>' . $sql . '</pre></font></div>';
179  $ko++;
180  }
181  }
182 
183  $cpt++;
184  }
185  $msg.='</div>';
186  $msg.= '<div>' . $langs->trans("EndProcessing") . '</div>';
187  //} else {
188  // setEventMessages($langs->trans("NoRecordSelected"), null, 'warnings');
189  }
190 }
191 
192 
193 
194 /*
195  * View
196  */
197 
198 $form = new Form($db);
199 $formother = new FormOther($db);
200 
201 llxHeader('', $langs->trans("Ventilation"));
202 
203 if (empty($chartaccountcode))
204 {
205  print $langs->trans("ErrorChartOfAccountSystemNotSelected");
206  llxFooter();
207  $db->close();
208  exit;
209 }
210 
211 // Customer Invoice lines
212 $sql = "SELECT f.rowid as facid, f.facnumber, f.datef, f.type as ftype,";
213 $sql.= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,";
214 $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_sell as code_sell, p.tva_tx as tva_tx_prod,";
215 $sql.= " aa.rowid as aarowid";
216 $parameters=array();
217 $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook
218 $sql.=$hookmanager->resPrint;
219 $sql.= " FROM " . MAIN_DB_PREFIX . "facture as f";
220 $sql.= " INNER JOIN " . MAIN_DB_PREFIX . "facturedet as l ON f.rowid = l.fk_facture";
221 $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
222 $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_sell = aa.account_number AND aa.fk_pcg_version = '" . $chartaccountcode."'";
223 $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa2 ON p.accountancy_code_sell_intra = aa2.account_number AND aa2.fk_pcg_version = '" . $chartaccountcode."'";
224 $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa3 ON p.accountancy_code_sell_export = aa3.account_number AND aa3.fk_pcg_version = '" . $chartaccountcode."'";
225 $sql.= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0";
226 $sql.= " AND product_type <= 2";
227 // Add search filter like
228 if ($search_lineid) {
229  $sql .= natural_search("l.rowid", $search_lineid, 1);
230 }
231 if (strlen(trim($search_invoice))) {
232  $sql .= natural_search("f.facnumber",$search_invoice);
233 }
234 if (strlen(trim($search_ref))) {
235  $sql .= natural_search("p.ref",$search_ref);
236 }
237 if (strlen(trim($search_label))) {
238  $sql .= natural_search("p.label",$search_label);
239 }
240 if (strlen(trim($search_desc))) {
241  $sql .= natural_search("l.description",$search_desc);
242 }
243 if (strlen(trim($search_amount))) {
244  $sql .= natural_search("l.total_ht",$search_amount,1);
245 }
246 if (strlen(trim($search_account))) {
247  $sql .= natural_search("aa.account_number",$search_account);
248 }
249 if (strlen(trim($search_vat))) {
250  $sql .= natural_search("l.tva_tx",$search_vat,1);
251 }
252 if ($search_month > 0)
253 {
254  if ($search_year > 0 && empty($search_day))
255  $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($search_year,$search_month,false))."' AND '".$db->idate(dol_get_last_day($search_year,$search_month,false))."'";
256  else if ($search_year > 0 && ! empty($search_day))
257  $sql.= " AND f.datef BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month, $search_day, $search_year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month, $search_day, $search_year))."'";
258  else
259  $sql.= " AND date_format(f.datef, '%m') = '".$db->escape($search_month)."'";
260 }
261 else if ($search_year > 0)
262 {
263  $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($search_year,1,false))."' AND '".$db->idate(dol_get_last_day($search_year,12,false))."'";
264 }
265 if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
266  $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
267 } else {
268  $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")";
269 }
270 $sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy
271 
272 // Add where from hooks
273 $parameters=array();
274 $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
275 $sql.=$hookmanager->resPrint;
276 
277 $sql .= $db->order($sortfield, $sortorder);
278 
279 // Count total nb of records
280 $nbtotalofrecords = '';
281 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
282 {
283  $result = $db->query($sql);
284  $nbtotalofrecords = $db->num_rows($result);
285 }
286 
287 $sql .= $db->plimit($limit + 1, $offset);
288 
289 dol_syslog("accountancy/customer/list.php", LOG_DEBUG);
290 $result = $db->query($sql);
291 if ($result) {
292  $num_lines = $db->num_rows($result);
293  $i = 0;
294 
295  $arrayofselected=is_array($toselect)?$toselect:array();
296 
297  $param='';
298  if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
299  if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
300  if ($search_lineid) $param.='&search_lineid='.urlencode($search_lineid);
301  if ($search_day) $param.='&search_day='.urlencode($search_day);
302  if ($search_month) $param.='&search_month='.urlencode($search_month);
303  if ($search_year) $param.='&search_year='.urlencode($search_year);
304  if ($search_invoice) $param.='&search_invoice='.urlencode($search_invoice);
305  if ($search_ref) $param.='&search_ref='.urlencode($search_ref);
306  if ($search_desc) $param.='&search_desc='.urlencode($search_desc);
307  if ($search_amount) $param.='&search_amount='.urlencode($search_amount);
308  if ($search_vat) $param.='&search_vat='.urlencode($search_vat);
309 
310  $arrayofmassactions = array(
311  'ventil'=>$langs->trans("Ventilate")
312  //'presend'=>$langs->trans("SendByMail"),
313  //'builddoc'=>$langs->trans("PDFMerge"),
314  );
315  //if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete");
316  //if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
317  $massactionbutton=$form->selectMassAction('ventil', $arrayofmassactions, 1);
318 
319  print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n";
320  print '<input type="hidden" name="action" value="ventil">';
321  if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
322  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
323  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
324  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
325  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
326  print '<input type="hidden" name="page" value="'.$page.'">';
327 
328  print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit);
329 
330  print $langs->trans("DescVentilTodoCustomer") . '</br><br>';
331 
332  /*$topicmail="Information";
333  $modelmail="project";
334  $objecttmp=new Project($db);
335  $trackid='prj'.$object->id;
336  include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';*/
337 
338  if ($msg) print $msg.'<br>';
339 
340  $moreforfilter = '';
341 
342  print '<div class="div-table-responsive">';
343  print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
344 
345  // We add search filter
346  print '<tr class="liste_titre_filter">';
347  print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_lineid" value="' . dol_escape_htmltag($search_lineid) . '""></td>';
348  print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="' . dol_escape_htmltag($search_invoice) . '"></td>';
349  print '<td class="liste_titre center">';
350  if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="search_day" value="'.$search_day.'">';
351  print '<input class="flat" type="text" size="1" maxlength="2" name="search_month" value="'.$search_month.'">';
352  $formother->select_year($search_year,'search_year',1, 20, 5);
353  print '</td>';
354  print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_ref" value="' . dol_escape_htmltag($search_ref) . '"></td>';
355  //print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_label" value="' . dol_escape_htmltag($search_label) . '"></td>';
356  print '<td class="liste_titre"><input type="text" class="flat maxwidthonsmartphone" name="search_desc" value="' . dol_escape_htmltag($search_desc) . '"></td>';
357  print '<td class="liste_titre" align="right"><input type="text" class="flat maxwidth50 right" name="search_amount" value="' . dol_escape_htmltag($search_amount) . '"></td>';
358  print '<td class="liste_titre" align="right"><input type="text" class="flat maxwidth50 right" name="search_vat" placeholder="%" size="1" value="' . dol_escape_htmltag($search_vat) . '"></td>';
359  print '<td class="liste_titre"></td>';
360  print '<td class="liste_titre"></td>';
361  print '<td align="center" class="liste_titre">';
362  $searchpicto=$form->showFilterButtons();
363  print $searchpicto;
364  print '</td>';
365  print '</tr>';
366 
367  print '<tr class="liste_titre">';
368  print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "l.rowid", "", $param, '', $sortfield, $sortorder);
369  print_liste_field_titre("Invoice", $_SERVER["PHP_SELF"], "f.facnumber", "", $param, '', $sortfield, $sortorder);
370  print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "f.datef, f.facnumber, l.rowid", "", $param, 'align="center"', $sortfield, $sortorder);
371  print_liste_field_titre("ProductRef", $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
372  //print_liste_field_titre("ProductLabel", $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder);
373  print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "l.description", "", $param, '', $sortfield, $sortorder);
374  print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "l.total_ht", "", $param, 'align="right"', $sortfield, $sortorder);
375  print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, 'align="right"', $sortfield, $sortorder);
376  print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', 'align="center"');
377  print_liste_field_titre("IntoAccount", '', '', '', '', 'align="center"');
378  $checkpicto='';
379  if ($massactionbutton) $checkpicto=$form->showCheckAddButtons('checkforselect', 1);
380  print_liste_field_titre($checkpicto, '', '', '', '', 'align="center"');
381  print "</tr>\n";
382 
383  $facture_static = new Facture($db);
384  $product_static = new Product($db);
385  $form = new Form($db);
386 
387  $var = true;
388  while ( $i < min($num_lines, $limit) ) {
389  $objp = $db->fetch_object($result);
390 
391  $objp->code_sell_l = '';
392  $objp->code_sell_p = '';
393  $objp->aarowid_suggest = '';
394 
395  $product_static->ref = $objp->product_ref;
396  $product_static->id = $objp->product_id;
397  $product_static->type = $objp->type;
398  $product_static->label = $objp->product_label;
399 
400  $facture_static->ref = $objp->facnumber;
401  $facture_static->id = $objp->facid;
402  $facture_static->type = $objp->ftype;
403 
404  $code_sell_p_notset = '';
405  $objp->aarowid_suggest = $objp->aarowid;
406 
407  if ($objp->type_l == 1) {
408  $objp->code_sell_l = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : '');
409  if ($objp->aarowid == '') {
410  $objp->aarowid_suggest = $aarowid_s;
411  }
412  } elseif ($objp->type_l == 0) {
413  $objp->code_sell_l = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : '');
414  if ($objp->aarowid == '') {
415  $objp->aarowid_suggest = $aarowid_p;
416  }
417  }
418  if ($objp->code_sell_l == -1) $objp->code_sell_l='';
419 
420  if (! empty($objp->code_sell)) {
421  $objp->code_sell_p = $objp->code_sell; // Code on product
422  } else {
423  $code_sell_p_notset = 'color:orange';
424  }
425  if (empty($objp->code_sell_l) && empty($objp->code_sell_p)) $code_sell_p_notset = 'color:red';
426 
427  // $objp->code_sell_p is now code of product/service
428  // $objp->code_sell_l is now default code of product/service
429 
430  print '<tr class="oddeven">';
431 
432  // Line id
433  print '<td>' . $objp->rowid . '</td>';
434 
435  // Ref Invoice
436  print '<td>' . $facture_static->getNomUrl(1) . '</td>';
437 
438  print '<td align="center">' . dol_print_date($db->jdate($objp->datef), 'day') . '</td>';
439 
440  // Ref Product
441  print '<td>';
442  if ($product_static->id)
443  print $product_static->getNomUrl(1);
444  if ($objp->product_label) print '<br>'.$objp->product_label;
445  print '</td>';
446 
447  print '<td class="tdoverflowonsmartphone">';
448  $text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description));
449  $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
450  print $form->textwithtooltip(dol_trunc($text,$trunclength), $objp->description);
451  print '</td>';
452 
453  print '<td align="right">';
454  print price($objp->total_ht);
455  print '</td>';
456 
457  // Vat rate
458  if ($objp->vat_tx_l != $objp->vat_tx_p)
459  $code_vat_differ = 'font-weight:bold; text-decoration:blink; color:red';
460  print '<td style="' . $code_vat_differ . '" align="right">';
461  print vatrate($objp->tva_tx_line.($objp->vat_src_code?' ('.$objp->vat_src_code.')':''));
462  print '</td>';
463 
464  // Current account
465  print '<td align="center" style="' . $code_sell_p_notset . '">';
466  print (($objp->type_l == 1)?$langs->trans("DefaultForService"):$langs->trans("DefaultForProduct")) . ' = ' . ($objp->code_sell_l > 0 ? length_accountg($objp->code_sell_l) : $langs->trans("Unknown"));
467  if ($objp->product_id > 0)
468  {
469  print '<br>';
470  print (($objp->type_l == 1)?$langs->trans("ThisService"):$langs->trans("ThisProduct")) . ' = ' . (empty($objp->code_sell_p) ? $langs->trans("Unknown") : length_accountg($objp->code_sell_p));
471  }
472  print '</td>';
473 
474  // Suggested accounting account
475  print '<td align="center">';
476  print $formaccounting->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'codeventil maxwidth300 maxwidthonsmartphone', 'cachewithshowemptyone');
477  print '</td>';
478 
479  // Column with checkbox
480  print '<td align="center">';
481  print '<input type="checkbox" class="flat checkforselect checkforselect'.$objp->rowid.'" name="toselect[]" value="' . $objp->rowid . "_" . $i . '"' . ($objp->aarowid ? "checked" : "") . '/>';
482  print '</td>';
483 
484  print '</tr>';
485  $i ++;
486  }
487  print '</table>';
488  print "</div>";
489 
490  print '</form>';
491 } else {
492  print $db->error();
493 }
494 
495 // Add code to auto check the box when we select an account
496 print '<script type="text/javascript" language="javascript">
497 jQuery(document).ready(function() {
498  jQuery(".codeventil").change(function() {
499  var s=$(this).attr("id").replace("codeventil", "")
500  console.log(s+" "+$(this).val());
501  if ($(this).val() == -1) jQuery(".checkforselect"+s).prop("checked", false);
502  else jQuery(".checkforselect"+s).prop("checked", true);
503  });
504 });
505 </script>';
506 
507 llxFooter();
508 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:58
const TYPE_STANDARD
Standard invoice.
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
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.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm=false, $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
Class to manage products or services.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0)
Return an id or code from a code or id.
const TYPE_REPLACEMENT
Replacement invoice.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
Definition: date.lib.php:445
if(empty($reshook)) $form
View.
Definition: perms.php:103
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...
const TYPE_SITUATION
Situation invoice.
const TYPE_CREDIT_NOTE
Credit note invoice.
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Class to manage generation of HTML components Only common components must be here.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='title_generic.png', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0)
Print a title with navigation controls for pagination.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
Classe permettant la generation de composants html autre Only common components are here...
llxHeader()
Empty header.
Definition: wrapper.php:46
getEntity($element, $shared=1, $forceentity=null)
Get list of entity id to use.
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...
dolGetFirstLineOfText($text, $nboflines=1)
Return first line of text.
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0)
Return a string with VAT rate label formated for view output Used into pdf and HTML pages...
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8')
Clean a string from all HTML tags and entities.
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...
dol_print_date($time, $format='', $tzoutput='tzserver', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
const TYPE_DEPOSIT
Deposit invoice.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Definition: date.lib.php:459
print
Draft customers invoices.
Definition: index.php:91
Class to manage generation of HTML components for accounting management.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="")
Show title line of an array.
Class to manage accounting accounts.
Class to manage invoices.
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous) ...