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-2017 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>s
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 . '/fourn/class/fournisseur.facture.class.php';
32 require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.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.ref, 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('accountancysupplierlist'));
96 
97 $formaccounting = new FormAccounting($db);
98 $accounting = new AccountingAccount($db);
99 // TODO: we should need to check if result is a really exist accountaccount rowid.....
100 $aarowid_s = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT, 1);
101 $aarowid_p = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT, 1);
102 
103 $chartaccountcode = dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'accounting_system', 'rowid', 'pcg_version');
104 
105 
106 /*
107  * Action
108  */
109 
110 if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; }
111 if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
112 
113 $parameters=array();
114 $reshook=$hookmanager->executeHooks('doActions',$parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
115 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
116 
117 if (empty($reshook))
118 {
119  // Purge search criteria
120  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
121  {
122  $search_lineid = '';
123  $search_ref = '';
124  $search_invoice = '';
125  $search_label = '';
126  $search_desc = '';
127  $search_amount = '';
128  $search_account = '';
129  $search_vat = '';
130  $search_day = '';
131  $search_month = '';
132  $search_year = '';
133  }
134 
135  // Mass actions
136  $objectclass='AccountingAccount';
137  $permtoread = $user->rights->accounting->read;
138  $permtodelete = $user->rights->accounting->delete;
139  $uploaddir = $conf->accounting->dir_output;
140  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
141 }
142 
143 
144 if ($massaction == 'ventil') {
145  $msg='';
146 
147  //print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>';
148  if (! empty($mesCasesCochees)) {
149  $msg = '<div>' . $langs->trans("SelectedLines") . ': '.count($mesCasesCochees).'</div>';
150  $msg.='<div class="detail">';
151  $cpt = 0;
152  $ok=0;
153  $ko=0;
154 
155  foreach ($mesCasesCochees as $maLigneCochee) {
156  $maLigneCourante = explode("_", $maLigneCochee);
157  $monId = $maLigneCourante[0];
158  $monCompte = GETPOST('codeventil'.$monId);
159 
160  if ($monCompte <= 0)
161  {
162  $msg.= '<div><font color="red">' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("NoAccountSelected") . '</font></div>';
163  $ko++;
164  }
165  else
166  {
167  $sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det";
168  $sql .= " SET fk_code_ventilation = " . $monCompte;
169  $sql .= " WHERE rowid = " . $monId;
170 
171  $accountventilated = new AccountingAccount($db);
172  $accountventilated->fetch($monCompte, '');
173 
174  dol_syslog('accountancy/supplier/list.php:: sql=' . $sql, LOG_DEBUG);
175  if ($db->query($sql)) {
176  $msg.= '<div><font color="green">' . $langs->trans("Lineofinvoice") . ' ' . $monId . ' - ' . $langs->trans("VentilatedinAccount") . ' : ' . length_accountg($accountventilated->account_number) . '</font></div>';
177  $ok++;
178  } else {
179  $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>';
180  $ko++;
181  }
182  }
183 
184  $cpt++;
185  }
186  $msg.='</div>';
187  $msg.= '<div>' . $langs->trans("EndProcessing") . '</div>';
188  //} else {
189  // setEventMessages($langs->trans("NoRecordSelected"), null, 'warnings');
190  }
191 }
192 
193 
194 
195 /*
196  * View
197  */
198 
199 $form = new Form($db);
200 $formother = new FormOther($db);
201 
202 llxHeader('', $langs->trans("SuppliersVentilation"));
203 
204 if (empty($chartaccountcode))
205 {
206  print $langs->trans("ErrorChartOfAccountSystemNotSelected");
207  llxFooter();
208  $db->close();
209  exit;
210 }
211 
212 // Supplier Invoice Lines
213 $sql = "SELECT f.rowid as facid, f.ref, f.ref_supplier, f.libelle as invoice_label, f.datef, f.type as ftype,";
214 $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,";
215 $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_buy as code_buy, p.tva_tx as tva_tx_prod,";
216 $sql.= " aa.rowid as aarowid";
217 $parameters=array();
218 $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook
219 $sql.=$hookmanager->resPrint;
220 $sql.= " FROM " . MAIN_DB_PREFIX . "facture_fourn as f";
221 $sql.= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn_det as l ON f.rowid = l.fk_facture_fourn";
222 $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = l.fk_product";
223 $sql.= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accountancy_code_buy = aa.account_number AND aa.fk_pcg_version = '" . $chartaccountcode."'";
224 $sql.= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0";
225 $sql.= " AND product_type <= 2";
226 // Add search filter like
227 if ($search_lineid) {
228  $sql .= natural_search("l.rowid", $search_lineid, 1);
229 }
230 if (strlen(trim($search_invoice))) {
231  $sql .= natural_search("f.ref",$search_invoice);
232 }
233 if (strlen(trim($search_ref))) {
234  $sql .= natural_search("p.ref",$search_ref);
235 }
236 if (strlen(trim($search_label))) {
237  $sql .= natural_search("p.label",$search_label);
238 }
239 if (strlen(trim($search_desc))) {
240  $sql .= natural_search("l.description",$search_desc);
241 }
242 if (strlen(trim($search_amount))) {
243  $sql .= natural_search("l.total_ht",$search_amount,1);
244 }
245 if (strlen(trim($search_account))) {
246  $sql .= natural_search("aa.account_number",$search_account);
247 }
248 if (strlen(trim($search_vat))) {
249  $sql .= natural_search("l.tva_tx",$search_vat,1);
250 }
251 if ($search_month > 0)
252 {
253  if ($search_year > 0 && empty($search_day))
254  $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))."'";
255  else if ($search_year > 0 && ! empty($search_day))
256  $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))."'";
257  else
258  $sql.= " AND date_format(f.datef, '%m') = '".$db->escape($search_month)."'";
259 }
260 else if ($search_year > 0)
261 {
262  $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))."'";
263 }
264 if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
266 } else {
268 }
269 $sql .= " AND f.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy
270 
271 // Add where from hooks
272 $parameters=array();
273 $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
274 $sql.=$hookmanager->resPrint;
275 
276 $sql .= $db->order($sortfield, $sortorder);
277 
278 // Count total nb of records
279 $nbtotalofrecords = '';
280 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
281 {
282  $result = $db->query($sql);
283  $nbtotalofrecords = $db->num_rows($result);
284 }
285 
286 $sql .= $db->plimit($limit + 1, $offset);
287 
288 dol_syslog('accountancy/supplier/list.php');
289 $result = $db->query($sql);
290 if ($result) {
291  $num_lines = $db->num_rows($result);
292  $i = 0;
293 
294  $arrayofselected=is_array($toselect)?$toselect:array();
295 
296  $param='';
297  if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
298  if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
299  if ($search_lineid) $param.='&search_lineid='.urlencode($search_lineid);
300  if ($search_day) $param.='&search_day='.urlencode($search_day);
301  if ($search_month) $param.='&search_month='.urlencode($search_month);
302  if ($search_year) $param.='&search_year='.urlencode($search_year);
303  if ($search_invoice) $param.='&search_invoice='.urlencode($search_invoice);
304  if ($search_ref) $param.='&search_ref='.urlencode($search_ref);
305  if ($search_desc) $param.='&search_desc='.urlencode($search_desc);
306  if ($search_amount) $param.='&search_amount='.urlencode($search_amount);
307  if ($search_vat) $param.='&search_vat='.urlencode($search_vat);
308 
309  $arrayofmassactions = array(
310  'ventil'=>$langs->trans("Ventilate")
311  //'presend'=>$langs->trans("SendByMail"),
312  //'builddoc'=>$langs->trans("PDFMerge"),
313  );
314  //if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete");
315  //if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
316  $massactionbutton=$form->selectMassAction('ventil', $arrayofmassactions, 1);
317 
318  print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n";
319  print '<input type="hidden" name="action" value="ventil">';
320  if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
321  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
322  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
323  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
324  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
325  print '<input type="hidden" name="page" value="'.$page.'">';
326 
327  print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit);
328 
329  print $langs->trans("DescVentilTodoCustomer") . '</br><br>';
330 
331  /*$topicmail="Information";
332  $modelmail="project";
333  $objecttmp=new Project($db);
334  $trackid='prj'.$object->id;
335  include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';*/
336 
337  if ($msg) print $msg.'<br>';
338 
339  $moreforfilter = '';
340 
341  print '<div class="div-table-responsive">';
342  print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
343 
344  // We add search filter
345  print '<tr class="liste_titre_filter">';
346  print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_lineid" value="' . dol_escape_htmltag($search_lineid) . '""></td>';
347  print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="' . dol_escape_htmltag($search_invoice) . '"></td>';
348  print '<td class="liste_titre"></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="right flat maxwidth50" name="search_amount" value="' . dol_escape_htmltag($search_amount) . '"></td>';
358  print '<td class="liste_titre" align="right"><input type="text" class="right flat maxwidth50" 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.ref", "", $param, '', $sortfield, $sortorder);
370  print_liste_field_titre("InvoiceLabel", $_SERVER["PHP_SELF"], "f.libelle", "", $param, '', $sortfield, $sortorder);
371  print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "f.datef, f.ref, l.rowid", "", $param, 'align="center"', $sortfield, $sortorder);
372  print_liste_field_titre("ProductRef", $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
373  //print_liste_field_titre("ProductLabel", $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder);
374  print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "l.description", "", $param, '', $sortfield, $sortorder);
375  print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "l.total_ht", "", $param, 'align="right"', $sortfield, $sortorder);
376  print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, 'align="right"', $sortfield, $sortorder);
377  print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', 'align="center"');
378  print_liste_field_titre("IntoAccount", '', '', '', '', 'align="center"');
379  $checkpicto='';
380  if ($massactionbutton) $checkpicto=$form->showCheckAddButtons('checkforselect', 1);
381  print_liste_field_titre($checkpicto, '', '', '', '', 'align="center"');
382  print "</tr>\n";
383 
384  $facturefourn_static = new FactureFournisseur($db);
385  $productfourn_static = new ProductFournisseur($db);
386  $form = new Form($db);
387 
388  $var = true;
389  while ( $i < min($num_lines, $limit) ) {
390  $objp = $db->fetch_object($result);
391 
392  // product_type: 0 = service ? 1 = product
393  // if product does not exist we use the value of product_type provided in facturedet to define if this is a product or service
394  // issue : if we change product_type value in product DB it should differ from the value stored in facturedet DB !
395  $objp->code_buy_l = '';
396  $objp->code_buy_p = '';
397  $objp->aarowid_suggest = '';
398 
399  $productfourn_static->ref = $objp->product_ref;
400  $productfourn_static->id = $objp->product_id;
401  $productfourn_static->type = $objp->type;
402  $productfourn_static->label = $objp->product_label;
403 
404  $facturefourn_static->ref = $objp->ref;
405  $facturefourn_static->id = $objp->facid;
406  $facturefourn_static->type = $objp->type;
407 
408  $code_buy_p_notset = '';
409  $objp->aarowid_suggest = $objp->aarowid;
410 
411  if ($objp->type_l == 1) {
412  $objp->code_buy_l = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : '');
413  if ($objp->aarowid == '')
414  $objp->aarowid_suggest = $aarowid_s;
415  } elseif ($objp->type_l == 0) {
416  $objp->code_buy_l = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : '');
417  if ($objp->aarowid == '')
418  $objp->aarowid_suggest = $aarowid_p;
419  }
420  if ($objp->code_buy_l == -1) $objp->code_buy_l='';
421 
422  if (! empty($objp->code_buy)) {
423  $objp->code_buy_p = $objp->code_buy; // Code on product
424  } else {
425  $code_buy_p_notset = 'color:orange';
426  }
427  if (empty($objp->code_buy_l) && empty($objp->code_buy_p)) $code_buy_p_notset = 'color:red';
428 
429  // $objp->code_buy_p is now code of product/service
430  // $objp->code_buy_l is now default code of product/service
431 
432  print '<tr class="oddeven">';
433 
434  // Line id
435  print '<td>' . $objp->rowid . '</td>';
436 
437  // Ref Invoice
438  print '<td>' . $facturefourn_static->getNomUrl(1) . '</td>';
439 
440  print '<td class="tdoverflowonsmartphone">';
441  print $objp->invoice_label;
442  print '</td>';
443 
444  print '<td align="center">' . dol_print_date($db->jdate($objp->datef), 'day') . '</td>';
445 
446  // Ref product
447  print '<td>';
448  if ($productfourn_static->id)
449  print $productfourn_static->getNomUrl(1);
450  if ($objp->product_label) print '<br>'.$objp->product_label;
451  print '</td>';
452 
453  // Description
454  print '<td>';
455  $text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->description));
456  $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
457  print $form->textwithtooltip(dol_trunc($text,$trunclength), $objp->description);
458  print '</td>';
459 
460  print '<td align="right">';
461  print price($objp->total_ht);
462  print '</td>';
463 
464  // Vat rate
465  if ($objp->vat_tx_l != $objp->vat_tx_p)
466  $code_vat_differ = 'font-weight:bold; text-decoration:blink; color:red';
467  print '<td style="' . $code_vat_differ . '" align="right">';
468  print vatrate($objp->tva_tx_line.($objp->vat_src_code?' ('.$objp->vat_src_code.')':''));
469  print '</td>';
470 
471  // Current account
472  print '<td align="center" style="' . $code_buy_p_notset . '">';
473  print (($objp->type_l == 1)?$langs->trans("DefaultForService"):$langs->trans("DefaultForProduct")) . ' = ' . ($objp->code_buy_l > 0 ? length_accountg($objp->code_buy_l) : $langs->trans("Unknown"));
474  if ($objp->product_id > 0)
475  {
476  print '<br>';
477  print (($objp->type_l == 1)?$langs->trans("ThisService"):$langs->trans("ThisProduct")) . ' = ' . (empty($objp->code_buy_p) ? $langs->trans("Unknown") : length_accountg($objp->code_buy_p));
478  }
479  print '</td>';
480 
481  // Suggested accounting account
482  print '<td align="center">';
483  print $formaccounting->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'codeventil maxwidth300 maxwidthonsmartphone', 'cachewithshowemptyone');
484  print '</td>';
485 
486  // Column with checkbox
487  print '<td align="center">';
488  print '<input type="checkbox" class="flat checkforselect checkforselect'.$objp->rowid.'" name="toselect[]" value="' . $objp->rowid . "_" . $i . '"' . ($objp->aarowid ? "checked" : "") . '/>';
489  print '</td>';
490 
491  print '</tr>';
492  $i ++;
493  }
494 
495  print '</table>';
496  print "</div>";
497 
498  print '</form>';
499 } else {
500  print $db->error();
501 }
502 
503 // Add code to auto check the box when we select an account
504 print '<script type="text/javascript" language="javascript">
505 jQuery(document).ready(function() {
506  jQuery(".codeventil").change(function() {
507  var s=$(this).attr("id").replace("codeventil", "")
508  console.log(s+" "+$(this).val());
509  if ($(this).val() == -1) jQuery(".checkforselect"+s).prop("checked", false);
510  else jQuery(".checkforselect"+s).prop("checked", true);
511  });
512 });
513 </script>';
514 
515 llxFooter();
516 $db->close();
const TYPE_STANDARD
Standard invoice.
llxFooter()
Empty footer.
Definition: wrapper.php:58
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.
const TYPE_DEPOSIT
Deposit invoice.
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...
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0)
Return an id or code from a code or id.
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
const TYPE_REPLACEMENT
Replacement invoice.
Class to manage suppliers invoices.
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...
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_CREDIT_NOTE
Credit note 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.
const TYPE_SITUATION
Situation invoice.
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.
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous) ...
Class to manage predefined suppliers products.