dolibarr  13.0.2
productaccount.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
3  * Copyright (C) 2013-2020 Alexandre Spangaro <aspangaro@open-dsi.fr>
4  * Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
5  * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
6  * Copyright (C) 2015 Ari Elbaz (elarifr) <github@accedinfo.com>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
27 require '../../main.inc.php';
28 
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.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.'/product/class/product.class.php';
36 
37 // Load translation files required by the page
38 $langs->loadLangs(array("companies", "compta", "accountancy", "products"));
39 
40 // Security check
41 if (empty($conf->accounting->enabled)) {
43 }
44 if (!$user->rights->accounting->bind->write)
46 
47 // search & action GETPOST
48 $action = GETPOST('action', 'aZ09');
49 $codeventil_buy = GETPOST('codeventil_buy', 'array');
50 $codeventil_sell = GETPOST('codeventil_sell', 'array');
51 $chk_prod = GETPOST('chk_prod', 'array');
52 $account_number_buy = GETPOST('account_number_buy');
53 $account_number_sell = GETPOST('account_number_sell');
54 $changeaccount = GETPOST('changeaccount', 'array');
55 $changeaccount_buy = GETPOST('changeaccount_buy', 'array');
56 $changeaccount_sell = GETPOST('changeaccount_sell', 'array');
57 $search_ref = GETPOST('search_ref', 'alpha');
58 $search_label = GETPOST('search_label', 'alpha');
59 $search_desc = GETPOST('search_desc', 'alpha');
60 $search_vat = GETPOST('search_vat', 'alpha');
61 $search_current_account = GETPOST('search_current_account', 'alpha');
62 $search_current_account_valid = GETPOST('search_current_account_valid', 'alpha');
63 if ($search_current_account_valid == '') $search_current_account_valid = 'withoutvalidaccount';
64 $search_onsell = GETPOST('search_onsell', 'alpha');
65 $search_onpurchase = GETPOST('search_onpurchase', 'alpha');
66 
67 $accounting_product_mode = GETPOST('accounting_product_mode', 'alpha');
68 $btn_changeaccount = GETPOST('changeaccount', 'alpha');
69 $btn_changetype = GETPOST('changetype', 'alpha');
70 
71 if (empty($accounting_product_mode)) $accounting_product_mode = 'ACCOUNTANCY_SELL';
72 
73 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
74 $sortfield = GETPOST("sortfield", 'alpha');
75 $sortorder = GETPOST("sortorder", 'alpha');
76 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
77 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
78 $offset = $limit * $page;
79 $pageprev = $page - 1;
80 $pagenext = $page + 1;
81 if (!$sortfield) $sortfield = "p.ref";
82 if (!$sortorder) $sortorder = "ASC";
83 
84 if (empty($action)) $action = 'list';
85 
86 $arrayfields = array();
87 
88 
89 /*
90  * Actions
91  */
92 
93 if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
94 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
95 
96 $parameters = array();
97 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
98 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
99 
100 // Purge search criteria
101 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
102 {
103  $search_ref = '';
104  $search_label = '';
105  $search_desc = '';
106  $search_vat = '';
107  $search_onsell = '';
108  $search_onpurchase = '';
109  $search_current_account = '';
110  $search_current_account_valid = '-1';
111 }
112 
113 // Sales or Purchase mode ?
114 if ($action == 'update') {
115  if (!empty($btn_changetype)) {
116  $error = 0;
117 
118  $accounting_product_modes = array(
119  'ACCOUNTANCY_SELL',
120  'ACCOUNTANCY_SELL_INTRA',
121  'ACCOUNTANCY_SELL_EXPORT',
122  'ACCOUNTANCY_BUY',
123  'ACCOUNTANCY_BUY_INTRA',
124  'ACCOUNTANCY_BUY_EXPORT'
125  );
126 
127  if (in_array($accounting_product_mode, $accounting_product_modes)) {
128  if (!dolibarr_set_const($db, 'ACCOUNTING_PRODUCT_MODE', $accounting_product_mode, 'chaine', 0, '', $conf->entity)) {
129  $error++;
130  }
131  } else {
132  $error++;
133  }
134  }
135 
136  if (!empty($btn_changeaccount)) {
137  //$msg = '<div><span class="accountingprocessing">' . $langs->trans("Processing") . '...</span></div>';
138  if (!empty($chk_prod)) {
139  $accounting = new AccountingAccount($db);
140 
141  //$msg .= '<div><span class="accountingprocessing">' . count($chk_prod) . ' ' . $langs->trans("SelectedLines") . '</span></div>';
142  $arrayofdifferentselectedvalues = array();
143 
144  $cpt = 0; $ok = 0; $ko = 0;
145  foreach ($chk_prod as $productid)
146  {
147  $accounting_account_id = GETPOST('codeventil_'.$productid);
148 
149  $result = 0;
150  if ($accounting_account_id > 0)
151  {
152  $arrayofdifferentselectedvalues[$accounting_account_id] = $accounting_account_id;
153  $result = $accounting->fetch($accounting_account_id, null, 1);
154  }
155  if ($result <= 0) {
156  // setEventMessages(null, $accounting->errors, 'errors');
157  $msg .= '<div><span style="color:red">'.$langs->trans("ErrorDB").' : '.$langs->trans("Product").' '.$productid.' '.$langs->trans("NotVentilatedinAccount").' : id='.$accounting_account_id.'<br/> <pre>'.$sql.'</pre></span></div>';
158  $ko++;
159  } else {
160  $db->begin();
161 
162  $sql = " UPDATE ".MAIN_DB_PREFIX."product";
163  if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
164  $sql .= " SET accountancy_code_buy = ".$accounting->account_number;
165  }
166  if ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') {
167  $sql .= " SET accountancy_code_buy_intra = ".$accounting->account_number;
168  }
169  if ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') {
170  $sql .= " SET accountancy_code_buy_export = ".$accounting->account_number;
171  }
172  if ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
173  $sql .= " SET accountancy_code_sell = ".$accounting->account_number;
174  }
175  if ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
176  $sql .= " SET accountancy_code_sell_intra = ".$accounting->account_number;
177  }
178  if ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') {
179  $sql .= " SET accountancy_code_sell_export = ".$accounting->account_number;
180  }
181  $sql .= " WHERE rowid = ".((int) $productid);
182 
183  dol_syslog("/accountancy/admin/productaccount.php sql=".$sql, LOG_DEBUG);
184  if ($db->query($sql))
185  {
186  $ok++;
187  $db->commit();
188  } else {
189  $ko++;
190  $db->rollback();
191  }
192  }
193 
194  $cpt++;
195  }
196  }
197 
198  if ($ko) setEventMessages($langs->trans("XLineFailedToBeBinded", $ko), null, 'errors');
199  if ($ok) setEventMessages($langs->trans("XLineSuccessfullyBinded", $ok), null, 'mesgs');
200  }
201 }
202 
203 
204 
205 /*
206  * View
207  */
208 
209 $form = new FormAccounting($db);
210 
211 // Default AccountingAccount RowId Product / Service
212 // at this time ACCOUNTING_SERVICE_SOLD_ACCOUNT & ACCOUNTING_PRODUCT_SOLD_ACCOUNT are account number not accountingacount rowid
213 // so we need to get those the rowid of those default value first
214 $accounting = new AccountingAccount($db);
215 // TODO: we should need to check if result is already exists accountaccount rowid.....
216 $aarowid_servbuy = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT, 1);
217 $aarowid_servbuy_intra = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT, 1);
218 $aarowid_servbuy_export = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT, 1);
219 $aarowid_prodbuy = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT, 1);
220 $aarowid_prodbuy_intra = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT, 1);
221 $aarowid_prodbuy_export = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT, 1);
222 $aarowid_servsell = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT, 1);
223 $aarowid_servsell_intra = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT, 1);
224 $aarowid_servsell_export = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT, 1);
225 $aarowid_prodsell = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT, 1);
226 $aarowid_prodsell_intra = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT, 1);
227 $aarowid_prodsell_export = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT, 1);
228 
229 $aacompta_servbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
230 $aacompta_servbuy_intra = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef"));
231 $aacompta_servbuy_export = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT : $langs->trans("CodeNotDef"));
232 $aacompta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
233 $aacompta_prodbuy_intra = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef"));
234 $aacompta_prodbuy_export = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT : $langs->trans("CodeNotDef"));
235 $aacompta_servsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
236 $aacompta_servsell_intra = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef"));
237 $aacompta_servsell_export = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef"));
238 $aacompta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
239 $aacompta_prodsell_intra = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef"));
240 $aacompta_prodsell_export = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef"));
241 
242 llxHeader('', $langs->trans("ProductsBinding"));
243 
244 $pcgverid = $conf->global->CHARTOFACCOUNTS;
245 $pcgvercode = dol_getIdFromCode($db, $pcgverid, 'accounting_system', 'rowid', 'pcg_version');
246 if (empty($pcgvercode)) $pcgvercode = $pcgverid;
247 
248 $sql = "SELECT p.rowid, p.ref, p.label, p.description, p.tosell, p.tobuy, p.tva_tx,";
249 $sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,";
250 $sql .= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,";
251 $sql .= " p.tms, p.fk_product_type as product_type,";
252 $sql .= " aa.rowid as aaid";
253 $sql .= " FROM ".MAIN_DB_PREFIX."product as p";
254 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON";
255 if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
256  $sql .= " p.accountancy_code_buy = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'";
257 } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA')
258 {
259  $sql .= " p.accountancy_code_buy_intra = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'";
260 } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT')
261 {
262  $sql .= " p.accountancy_code_buy_export = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'";
263 } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL')
264 {
265  $sql .= " p.accountancy_code_sell = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'";
266 } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA')
267 {
268  $sql .= " p.accountancy_code_sell_intra = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'";
269 } else {
270  $sql .= " p.accountancy_code_sell_export = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'";
271 }
272 $sql .= ' WHERE p.entity IN ('.getEntity('product').')';
273 if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
274  if (strlen(trim($search_current_account))) {
275  $sql .= natural_search("p.accountancy_code_buy", $search_current_account);
276  }
277 } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') {
278  if (strlen(trim($search_current_account))) {
279  $sql .= natural_search("p.accountancy_code_buy_intra", $search_current_account);
280  }
281 } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') {
282  if (strlen(trim($search_current_account))) {
283  $sql .= natural_search("p.accountancy_code_buy_export", $search_current_account);
284  }
285 } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
286  if (strlen(trim($search_current_account))) {
287  $sql .= natural_search("p.accountancy_code_sell", $search_current_account);
288  }
289 } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
290  if (strlen(trim($search_current_account))) {
291  $sql .= natural_search("p.accountancy_code_sell_intra", $search_current_account);
292  }
293 } else {
294  if (strlen(trim($search_current_account))) {
295  $sql .= natural_search("p.accountancy_code_sell_export", $search_current_account);
296  }
297 }
298 if ($search_current_account_valid == 'withoutvalidaccount')
299 {
300  $sql .= " AND aa.account_number IS NULL";
301 }
302 if ($search_current_account_valid == 'withvalidaccount')
303 {
304  $sql .= " AND aa.account_number IS NOT NULL";
305 }
306 // Add search filter like
307 if (strlen(trim($search_ref))) {
308  $sql .= natural_search("p.ref", $search_ref);
309 }
310 if (strlen(trim($search_label))) {
311  $sql .= natural_search("p.label", $search_label);
312 }
313 if (strlen(trim($search_desc))) {
314  $sql .= natural_search("p.description", $search_desc);
315 }
316 if (strlen(trim($search_vat))) {
317  $sql .= natural_search("p.tva_tx", price2num($search_vat), 1);
318 }
319 if ($search_onsell != '' && $search_onsell != '-1') $sql .= natural_search('p.tosell', $search_onsell, 1);
320 if ($search_onpurchase != '' && $search_onpurchase != '-1') $sql .= natural_search('p.tobuy', $search_onpurchase, 1);
321 
322 $sql .= $db->order($sortfield, $sortorder);
323 
324 $nbtotalofrecords = '';
325 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
326 {
327  $result = $db->query($sql);
328  $nbtotalofrecords = $db->num_rows($result);
329  if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
330  {
331  $page = 0;
332  $offset = 0;
333  }
334 }
335 
336 $sql .= $db->plimit($limit + 1, $offset);
337 
338 dol_syslog("/accountancy/admin/productaccount.php:: sql=".$sql, LOG_DEBUG);
339 $result = $db->query($sql);
340 if ($result)
341 {
342  $num = $db->num_rows($result);
343  $i = 0;
344 
345  $param = '';
346  if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
347  if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
348  if ($search_ref > 0) $param .= "&search_desc=".urlencode($search_ref);
349  if ($search_label > 0) $param .= "&search_desc=".urlencode($search_label);
350  if ($search_desc > 0) $param .= "&search_desc=".urlencode($search_desc);
351  if ($search_vat > 0) $param .= '&search_vat='.urlencode($search_vat);
352  if ($search_current_account > 0) $param .= "&search_current_account=".urlencode($search_current_account);
353  if ($search_current_account_valid && $search_current_account_valid != '-1') $param .= "&search_current_account_valid=".urlencode($search_current_account_valid);
354  if ($accounting_product_mode) $param .= '&accounting_product_mode='.urlencode($accounting_product_mode);
355 
356  print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
357  if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
358  print '<input type="hidden" name="token" value="'.newToken().'">';
359  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
360  print '<input type="hidden" name="action" value="update">';
361  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
362  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
363 
364  print load_fiche_titre($langs->trans("ProductsBinding"), '', 'title_accountancy');
365  print '<br>';
366 
367  print '<span class="opacitymedium">'.$langs->trans("InitAccountancyDesc").'</span><br>';
368  print '<br>';
369 
370  // Select mode
371  print '<table class="noborder centpercent">';
372  print '<tr class="liste_titre">';
373  print '<td>'.$langs->trans('Options').'</td><td>'.$langs->trans('Description').'</td>';
374  print "</tr>\n";
375  print '<tr class="oddeven"><td><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_SELL"'.($accounting_product_mode == 'ACCOUNTANCY_SELL' ? ' checked' : '').'> '.$langs->trans('OptionModeProductSell').'</td>';
376  print '<td>'.$langs->trans('OptionModeProductSellDesc');
377  print "</td></tr>\n";
378  if ($mysoc->isInEEC())
379  {
380  print '<tr class="oddeven"><td><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_SELL_INTRA"'.($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA' ? ' checked' : '').'> '.$langs->trans('OptionModeProductSellIntra').'</td>';
381  print '<td>'.$langs->trans('OptionModeProductSellIntraDesc');
382  print "</td></tr>\n";
383  }
384  print '<tr class="oddeven"><td><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_SELL_EXPORT"'.($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT' ? ' checked' : '').'> '.$langs->trans('OptionModeProductSellExport').'</td>';
385  print '<td>'.$langs->trans('OptionModeProductSellExportDesc');
386  print "</td></tr>\n";
387  print '<tr class="oddeven"><td><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_BUY"'.($accounting_product_mode == 'ACCOUNTANCY_BUY' ? ' checked' : '').'> '.$langs->trans('OptionModeProductBuy').'</td>';
388  print '<td>'.$langs->trans('OptionModeProductBuyDesc')."</td></tr>\n";
389  if ($mysoc->isInEEC())
390  {
391  print '<tr class="oddeven"><td><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_BUY_INTRA"'.($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA' ? ' checked' : '').'> '.$langs->trans('OptionModeProductBuyIntra').'</td>';
392  print '<td>'.$langs->trans('OptionModeProductBuyDesc')."</td></tr>\n";
393  }
394  print '<tr class="oddeven"><td><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_BUY_EXPORT"'.($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT' ? ' checked' : '').'> '.$langs->trans('OptionModeProductBuyExport').'</td>';
395  print '<td>'.$langs->trans('OptionModeProductBuyDesc')."</td></tr>\n";
396  print "</table>\n";
397 
398  print '<div class="center"><input type="submit" class="button" value="'.$langs->trans('Refresh').'" name="changetype"></div>';
399 
400  print "<br>\n";
401 
402 
403  // Filter on categories
404  $moreforfilter = '';
405  $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
406  $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
407 
408  $buttonsave = '<input type="submit" class="button button-save" id="changeaccount" name="changeaccount" value="'.$langs->trans("Save").'">';
409  //print '<br><div class="center">'.$buttonsave.'</div>';
410 
411  $texte = $langs->trans("ListOfProductsServices");
412  print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $buttonsave, $num, $nbtotalofrecords, '', 0, '', '', $limit, 0, 0, 1);
413 
414  print '<div class="div-table-responsive">';
415  print '<table class="liste '.($moreforfilter ? "listwithfilterbefore" : "").'">';
416 
417  print '<tr class="liste_titre_filter">';
418  print '<td class="liste_titre"><input type="text" class="flat" size="8" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>';
419  print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_label" value="'.dol_escape_htmltag($search_label).'"></td>';
420  print '<td class="liste_titre right"><input type="text" class="flat maxwidth50 right" size="5" name="search_vat" placeholder="%" value="'.dol_escape_htmltag($search_vat).'"></td>';
421 
422  if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>';
423  // On sell
424  if ($accounting_product_mode == 'ACCOUNTANCY_SELL' || $accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') {
425  print '<td class="liste_titre center">'.$form->selectyesno('search_onsell', $search_onsell, 1, false, 1).'</td>';
426  }
427  // On buy
428  elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY' || $accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') {
429  print '<td class="liste_titre center">'.$form->selectyesno('search_onpurchase', $search_onpurchase, 1, false, 1).'</td>';
430  }
431  // Current account
432  print '<td class="liste_titre">';
433  print '<input type="text" class="flat" size="6" name="search_current_account" id="search_current_account" value="'.dol_escape_htmltag($search_current_account).'">';
434  $listofvals = array('withoutvalidaccount'=>$langs->trans("WithoutValidAccount"), 'withvalidaccount'=>$langs->trans("WithValidAccount"));
435  print ' '.$langs->trans("or").' '.$form->selectarray('search_current_account_valid', $listofvals, $search_current_account_valid, 1);
436  print '</td>';
437  print '<td class="liste_titre">&nbsp;</td>';
438  print '<td class="center liste_titre">';
439  $searchpicto = $form->showFilterButtons();
440  print $searchpicto;
441  print '</td>';
442  print '</tr>';
443 
444  print '<tr class="liste_titre">';
445  print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
446  print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder);
447  if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "p.description", "", $param, '', $sortfield, $sortorder);
448  print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "p.tva_tx", "", $param, '', $sortfield, $sortorder, 'right ');
449  // On sell / On purchase
450  if ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
451  print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center ');
452  $fieldtosortaccount = "p.accountancy_code_sell";
453  } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
454  print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center ');
455  $fieldtosortaccount = "p.accountancy_code_sell_intra";
456  } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') {
457  print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center ');
458  $fieldtosortaccount = "p.accountancy_code_sell_export";
459  } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
460  print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center ');
461  $fieldtosortaccount = "p.accountancy_code_buy";
462  } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') {
463  print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center ');
464  $fieldtosortaccount = "p.accountancy_code_buy_intra";
465  } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') {
466  print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center ');
467  $fieldtosortaccount = "p.accountancy_code_buy_export";
468  }
469  print_liste_field_titre("CurrentDedicatedAccountingAccount", $_SERVER["PHP_SELF"], $fieldtosortaccount, "", $param, '', $sortfield, $sortorder);
470  print_liste_field_titre("AssignDedicatedAccountingAccount");
471  $clickpitco = $form->showCheckAddButtons('checkforselect', 1);
472  print_liste_field_titre($clickpitco, '', '', '', '', '', '', '', 'center ');
473  print '</tr>';
474 
475  $product_static = new Product($db);
476 
477  $i = 0;
478  while ($i < min($num, $limit))
479  {
480  $obj = $db->fetch_object($result);
481 
482  // Ref produit as link
483  $product_static->ref = $obj->ref;
484  $product_static->id = $obj->rowid;
485  $product_static->type = $obj->product_type;
486  $product_static->label = $obj->label;
487  $product_static->description = $obj->description;
488  $product_static->status = $obj->tosell;
489  $product_static->status_buy = $obj->tobuy;
490 
491  // Sales
492  if ($obj->product_type == 0) {
493  if ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
494  $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
495  $compta_prodsell_id = $aarowid_prodsell;
496  } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
497  $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef"));
498  $compta_prodsell_id = $aarowid_prodsell_intra;
499  } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') {
500  $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef"));
501  $compta_prodsell_id = $aarowid_prodsell_export;
502  } else {
503  $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
504  $compta_prodsell_id = $aarowid_prodsell;
505  }
506  } else {
507  if ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
508  $compta_prodsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
509  $compta_prodsell_id = $aarowid_servsell;
510  } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
511  $compta_prodsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef"));
512  $compta_prodsell_id = $aarowid_servsell_intra;
513  } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') {
514  $compta_prodsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef"));
515  $compta_prodsell_id = $aarowid_servsell_export;
516  } else {
517  $compta_prodsell = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
518  $compta_prodsell_id = $aarowid_servsell;
519  }
520  }
521 
522  // Purchases
523  if ($obj->product_type == 0) {
524  if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
525  $compta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
526  $compta_prodbuy_id = $aarowid_prodbuy;
527  } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') {
528  $compta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef"));
529  $compta_prodbuy_id = $aarowid_prodbuy_intra;
530  } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') {
531  $compta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT : $langs->trans("CodeNotDef"));
532  $compta_prodbuy_id = $aarowid_prodbuy_export;
533  } else {
534  $compta_prodbuy = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
535  $compta_prodbuy_id = $aarowid_prodbuy;
536  }
537  } else {
538  if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
539  $compta_prodbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
540  $compta_prodbuy_id = $aarowid_servbuy;
541  } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') {
542  $compta_prodbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef"));
543  $compta_prodbuy_id = $aarowid_servbuy_intra;
544  } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') {
545  $compta_prodbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT : $langs->trans("CodeNotDef"));
546  $compta_prodbuy_id = $aarowid_servbuy_export;
547  } else {
548  $compta_prodbuy = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef"));
549  $compta_prodbuy_id = $aarowid_servbuy;
550  }
551  }
552 
553  print '<tr class="oddeven">';
554 
555  print '<td>';
556  print $product_static->getNomUrl(1);
557  print '</td>';
558 
559  print '<td class="left">'.$obj->label.'</td>';
560 
561  if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC))
562  {
563  // TODO ADJUST DESCRIPTION SIZE
564  // print '<td class="left">' . $obj->description . '</td>';
565  // TODO: we should set a user defined value to adjust user square / wide screen size
566  $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
567  print '<td>'.nl2br(dol_trunc($obj->description, $trunclength)).'</td>';
568  }
569 
570  // VAT
571  print '<td class="right">';
572  print vatrate($obj->tva_tx);
573  print '</td>';
574 
575  if ($accounting_product_mode == 'ACCOUNTANCY_SELL' || $accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT')
576  print '<td class="center">'.$product_static->getLibStatut(3, 0).'</td>';
577 
578  if ($accounting_product_mode == 'ACCOUNTANCY_BUY' || $accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT')
579  print '<td class="center">'.$product_static->getLibStatut(3, 1).'</td>';
580 
581  // Current accounting account
582  print '<td class="left">';
583  if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
584  print length_accountg($obj->accountancy_code_buy);
585  if ($obj->accountancy_code_buy && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount"));
586  } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') {
587  print length_accountg($obj->accountancy_code_buy_intra);
588  if ($obj->accountancy_code_buy_intra && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount"));
589  } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') {
590  print length_accountg($obj->accountancy_code_buy_export);
591  if ($obj->accountancy_code_buy_export && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount"));
592  } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
593  print length_accountg($obj->accountancy_code_sell);
594  if ($obj->accountancy_code_sell && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount"));
595  } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
596  print length_accountg($obj->accountancy_code_sell_intra);
597  if ($obj->accountancy_code_sell_intra && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount"));
598  } else {
599  print length_accountg($obj->accountancy_code_sell_export);
600  if ($obj->accountancy_code_sell_export && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount"));
601  }
602  print '</td>';
603 
604  // New account to set
605  $defaultvalue = '';
606  if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
607  // Accounting account buy
608  print '<td class="left">';
609  //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code
610  if (empty($defaultvalue)) $defaultvalue = $compta_prodbuy;
611  $codesell = length_accountg($obj->accountancy_code_buy);
612  if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid
613  print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1, 0, 'maxwidth300 maxwidthonsmartphone productforselect');
614  print '</td>';
615  } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') {
616  // Accounting account buy intra (In EEC)
617  print '<td class="left">';
618  //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code
619  if (empty($defaultvalue)) $defaultvalue = $compta_prodbuy;
620  $codesell = length_accountg($obj->accountancy_code_buy_intra);
621  //var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell);
622  if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid
623  print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1, 0, 'maxwidth300 maxwidthonsmartphone productforselect');
624  print '</td>';
625  } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') {
626  // Accounting account buy export (Out of EEC)
627  print '<td class="left">';
628  //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code
629  if (empty($defaultvalue)) $defaultvalue = $compta_prodbuy;
630  $codesell = length_accountg($obj->accountancy_code_buy_export);
631  //var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell);
632  if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid
633  print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1, 0, 'maxwidth300 maxwidthonsmartphone productforselect');
634  print '</td>';
635  } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
636  // Accounting account sell
637  print '<td class="left">';
638  //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code
639  if (empty($defaultvalue)) $defaultvalue = $compta_prodsell;
640  $codesell = length_accountg($obj->accountancy_code_sell);
641  //var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell);
642  if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid
643  print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1, 0, 'maxwidth300 maxwidthonsmartphone productforselect');
644  print '</td>';
645  } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
646  // Accounting account sell intra (In EEC)
647  print '<td class="left">';
648  //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code
649  if (empty($defaultvalue)) $defaultvalue = $compta_prodsell;
650  $codesell = length_accountg($obj->accountancy_code_sell_intra);
651  //var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell);
652  if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid
653  print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1, 0, 'maxwidth300 maxwidthonsmartphone productforselect');
654  print '</td>';
655  } else {
656  // Accounting account sell export (Out of EEC)
657  print '<td class="left">';
658  //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code
659  if (empty($defaultvalue)) $defaultvalue = $compta_prodsell;
660  $codesell = length_accountg($obj->accountancy_code_sell_export);
661  if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid
662  print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1, 0, 'maxwidth300 maxwidthonsmartphone productforselect');
663  print '</td>';
664  }
665 
666  // Checkbox select
667  print '<td class="center">';
668  print '<input type="checkbox" class="checkforselect productforselectcodeventil_'.$product_static->id.'" name="chk_prod[]" value="'.$obj->rowid.'"/></td>';
669  print "</tr>";
670  $i++;
671  }
672  print '</table>';
673  print '</div>';
674 
675  print '<script type="text/javascript" language="javascript">
676  jQuery(document).ready(function() {
677  function init_savebutton()
678  {
679  console.log("We check if at least one line is checked")
680 
681  atleastoneselected=0;
682  jQuery(".checkforselect").each(function( index ) {
683  /* console.log( index + ": " + $( this ).text() ); */
684  if ($(this).is(\':checked\')) atleastoneselected++;
685  });
686 
687  if (atleastoneselected) jQuery("#changeaccount").removeAttr(\'disabled\');
688  else jQuery("#changeaccount").attr(\'disabled\',\'disabled\');
689  if (atleastoneselected) jQuery("#changeaccount").attr(\'class\',\'button\');
690  else jQuery("#changeaccount").attr(\'class\',\'button\');
691  }
692 
693  jQuery(".checkforselect").change(function() {
694  init_savebutton();
695  });
696  jQuery(".productforselect").change(function() {
697  console.log($(this).attr("id")+" "+$(this).val());
698  if ($(this).val() && $(this).val() != -1) {
699  $(".productforselect"+$(this).attr("id")).prop(\'checked\', true);
700  } else {
701  $(".productforselect"+$(this).attr("id")).prop(\'checked\', false);
702  }
703  init_savebutton();
704  });
705 
706  init_savebutton();
707 
708  jQuery("#search_current_account").keyup(function() {
709  if (jQuery("#search_current_account").val() != \'\')
710  {
711  console.log("We set a value of account to search "+jQuery("#search_current_account").val()+", so we disable the other search criteria on account");
712  jQuery("#search_current_account_valid").val(-1);
713  }
714  });
715  });
716  </script>';
717 
718  print '</form>';
719 
720  $db->free($result);
721 } else {
722  dol_print_error($db);
723 }
724 
725 // End of page
726 llxFooter();
727 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage products or services.
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).
Definition: admin.lib.php:575
llxHeader()
Empty header.
Definition: wrapper.php:45
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options= '', $sortfield= '', $sortorder= '', $morehtmlcenter= '', $num=-1, $totalnboflines= '', $picto= 'generic', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow= '')
Print a title with navigation controls for pagination.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is &#39;...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
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...
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...
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_getIdFromCode($db, $key, $tablename, $fieldkey= 'code', $fieldid= 'id', $entityfilter=0)
Return an id or code from a code or id.
print
Draft customers invoices.
Definition: index.php:89
Class to manage generation of HTML components for accounting management.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_trunc($string, $size=40, $trunc= 'right', $stringencoding= 'UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding &#39;...&#39; if string larger than length.
Class to manage accounting accounts.
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous) ...
llxFooter()
Empty footer.
Definition: wrapper.php:59