dolibarr  16.0.5
card-rec.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
6  * Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
7  * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
8  * Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
9  * Copyright (C) 2015 Alexandre Spangaro <aspangaro@open-dsi.fr>
10  * Copyright (C) 2016 Meziane Sof <virtualsof@yahoo.fr>
11  * Copyright (C) 2017-2018 Frédéric France <frederic.france@netlogic.fr>
12  *
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 3 of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program. If not, see <https://www.gnu.org/licenses/>.
25  */
26 
33 require '../../main.inc.php';
34 require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
35 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
36 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
37 if (isModEnabled('project')) {
38  include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
39  //include_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
40 }
41 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
42 require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
43 require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php';
44 require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
45 
46 // Load translation files required by the page
47 $langs->loadLangs(array('bills', 'companies', 'compta', 'admin', 'other', 'products', 'banks'));
48 
49 $action = GETPOST('action', 'alpha');
50 $massaction = GETPOST('massaction', 'alpha');
51 $show_files = GETPOST('show_files', 'int');
52 $confirm = GETPOST('confirm', 'alpha');
53 $cancel = GETPOST('cancel', 'alpha');
54 $toselect = GETPOST('toselect', 'array');
55 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'invoicetemplatelist'; // To manage different context of search
56 
57 // Security check
58 $id = (GETPOST('facid', 'int') ?GETPOST('facid', 'int') : GETPOST('id', 'int'));
59 $lineid = GETPOST('lineid', 'int');
60 $ref = GETPOST('ref', 'alpha');
61 if ($user->socid) {
62  $socid = $user->socid;
63 }
64 $objecttype = 'facture_rec';
65 if ($action == "create" || $action == "add") {
66  $objecttype = '';
67 }
68 $projectid = GETPOST('projectid', 'int');
69 
70 $year_date_when = GETPOST('year_date_when');
71 $month_date_when = GETPOST('month_date_when');
72 
73 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
74 $sortfield = GETPOST('sortfield', 'aZ09comma');
75 $sortorder = GETPOST('sortorder', 'aZ09comma');
76 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
77 if (empty($page) || $page == -1) {
78  $page = 0;
79 } // If $page is not defined, or '' or -1
80 $offset = $limit * $page;
81 if (!$sortorder) {
82  $sortorder = 'DESC';
83 }
84 if (!$sortfield) {
85  $sortfield = 'f.titre';
86 }
87 $pageprev = $page - 1;
88 $pagenext = $page + 1;
89 
90 $object = new FactureRec($db);
91 if (($id > 0 || $ref) && $action != 'create' && $action != 'add') {
92  $ret = $object->fetch($id, $ref);
93  if (!$ret) {
94  setEventMessages($langs->trans("ErrorRecordNotFound"), null, 'errors');
95  }
96 }
97 
98 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
99 $hookmanager->initHooks(array('invoicereccard', 'globalcard'));
100 $extrafields = new ExtraFields($db);
101 
102 // fetch optionals attributes and labels
103 $extrafields->fetch_name_optionals_label($object->table_element);
104 
105 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
106 
107 $permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php
108 $permissiondellink = $user->rights->facture->creer; // Used by the include of actions_dellink.inc.php
109 $permissiontoedit = $user->rights->facture->creer; // Used by the include of actions_lineupdonw.inc.php
110 
111 $usercanread = $user->rights->facture->lire;
112 $usercancreate = $user->rights->facture->creer;
113 $usercanissuepayment = $user->rights->facture->paiement;
114 $usercandelete = $user->rights->facture->supprimer;
115 $usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->validate)));
116 $usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->facture->invoice_advance->send);
117 $usercanreopen = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->facture->invoice_advance->reopen);
118 $usercanunvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($usercancreate)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->facture->invoice_advance->unvalidate)));
119 
120 $usercanproductignorepricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS));
121 $usercancreatemargin = $user->rights->margins->creer;
122 $usercanreadallmargin = $user->rights->margins->liretous;
123 $usercancreatewithdrarequest = $user->rights->prelevement->bons->creer;
124 
125 $now = dol_now();
126 
127 $error = 0;
128 
129 $result = restrictedArea($user, 'facture', $object->id, $objecttype);
130 
131 
132 /*
133  * Actions
134  */
135 
136 if (GETPOST('cancel', 'alpha')) {
137  $action = 'list';
138  $massaction = '';
139 }
140 if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
141  $massaction = '';
142 }
143 
144 $parameters = array('socid' => $socid);
145 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
146 if ($reshook < 0) {
147  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
148 }
149 
150 if (empty($reshook)) {
151  if (GETPOST('cancel', 'alpha')) {
152  $action = '';
153  }
154 
155  // Selection of new fields
156  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
157 
158  // Set note
159  include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
160 
161  include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once
162 
163  include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once
164 
165  // Mass actions
166  /*$objectclass='MyObject';
167  $objectlabel='MyObject';
168  $permissiontoread = $user->rights->mymodule->read;
169  $permissiontodelete = $user->rights->mymodule->delete;
170  $uploaddir = $conf->mymodule->dir_output;
171  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';*/
172 
173  // Create predefined invoice
174  if ($action == 'add') {
175  if (!GETPOST('title', 'alphanohtml')) {
176  setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->trans("Title")), null, 'errors');
177  $action = "create";
178  $error++;
179  }
180 
181  $frequency = GETPOST('frequency', 'int');
182  $reyear = GETPOST('reyear', 'int');
183  $remonth = GETPOST('remonth', 'int');
184  $reday = GETPOST('reday', 'int');
185  $rehour = GETPOST('rehour', 'int');
186  $remin = GETPOST('remin', 'int');
187  $nb_gen_max = GETPOST('nb_gen_max', 'int');
188  //if (empty($nb_gen_max)) $nb_gen_max =0;
189 
190  if (GETPOST('frequency', 'int')) {
191  if (empty($reyear) || empty($remonth) || empty($reday)) {
192  setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->trans("Date")), null, 'errors');
193  $action = "create";
194  $error++;
195  }
196  /*if ($nb_gen_max === '') {
197  setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->trans("MaxPeriodNumber")), null, 'errors');
198  $action = "create";
199  $error++;
200  }*/
201  }
202 
203  if (!$error) {
204  $object->titre = GETPOST('title', 'alphanohtml'); // deprecated
205  $object->title = GETPOST('title', 'alphanohtml');
206  $object->note_private = GETPOST('note_private', 'restricthtml');
207  $object->note_public = GETPOST('note_public', 'restricthtml');
208  $object->model_pdf = GETPOST('modelpdf', 'alphanohtml');
209  $object->usenewprice = GETPOST('usenewprice', 'alphanohtml');
210 
211  $object->mode_reglement_id = GETPOST('mode_reglement_id', 'int');
212  $object->cond_reglement_id = GETPOST('cond_reglement_id', 'int');
213 
214  $object->frequency = $frequency;
215  $object->unit_frequency = GETPOST('unit_frequency', 'alpha');
216  $object->nb_gen_max = $nb_gen_max;
217  $object->auto_validate = GETPOST('auto_validate', 'int');
218  $object->generate_pdf = GETPOST('generate_pdf', 'int');
219  $object->fk_project = $projectid;
220 
221  $date_next_execution = dol_mktime($rehour, $remin, 0, $remonth, $reday, $reyear);
222  $object->date_when = $date_next_execution;
223 
224  // Get first contract linked to invoice used to generate template (facid is id of source invoice)
225  if (GETPOST('facid', 'int') > 0) {
226  $srcObject = new Facture($db);
227  $srcObject->fetch(GETPOST('facid', 'int'));
228 
229  $srcObject->fetchObjectLinked();
230 
231  if (!empty($srcObject->linkedObjectsIds['contrat'])) {
232  $contractidid = reset($srcObject->linkedObjectsIds['contrat']);
233 
234  $object->origin = 'contrat';
235  $object->origin_id = $contractidid;
236  $object->linked_objects[$object->origin] = $object->origin_id;
237  }
238  }
239 
240  $db->begin();
241 
242  $oldinvoice = new Facture($db);
243  $oldinvoice->fetch(GETPOST('facid', 'int'));
244 
245  $result = $object->create($user, $oldinvoice->id);
246  if ($result > 0) {
247  $result = $oldinvoice->delete($user, 1);
248  if ($result < 0) {
249  $error++;
250  setEventMessages($oldinvoice->error, $oldinvoice->errors, 'errors');
251  $action = "create";
252  }
253  } else {
254  $error++;
255  setEventMessages($object->error, $object->errors, 'errors');
256  $action = "create";
257  }
258 
259  if (!$error) {
260  $db->commit();
261 
262  header("Location: ".$_SERVER['PHP_SELF'].'?facid='.$object->id);
263  exit;
264  } else {
265  $db->rollback();
266 
267  $action = "create";
268  }
269  }
270  }
271 
272  // Delete
273  if ($action == 'confirm_deleteinvoice' && $confirm == 'yes' && $user->rights->facture->supprimer) {
274  $object->delete($user);
275 
276  header("Location: ".DOL_URL_ROOT.'/compta/facture/invoicetemplate_list.php');
277  exit;
278  }
279 
280 
281  // Update field
282  // Set condition
283  if ($action == 'setconditions' && $user->rights->facture->creer) {
284  $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int'));
285  } elseif ($action == 'setmode' && $user->rights->facture->creer) {
286  // Set mode
287  $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int'));
288  } elseif ($action == 'classin' && $user->rights->facture->creer) {
289  // Set project
290  $object->setProject(GETPOST('projectid', 'int'));
291  } elseif ($action == 'setref' && $user->rights->facture->creer) {
292  // Set bank account
293  //var_dump(GETPOST('ref', 'alpha'));exit;
294  $result = $object->setValueFrom('titre', $ref, '', null, 'text', '', $user, 'BILLREC_MODIFY');
295  if ($result > 0) {
296  $object->titre = $ref; // deprecated
297  $object->title = $ref;
298  $object->ref = $object->title;
299  } else {
300  $error++;
301  if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
302  $langs->load("errors");
303  setEventMessages($langs->trans('ErrorRefAlreadyExists', $ref), null, 'errors');
304  } else {
305  setEventMessages($object->error, $object->errors, 'errors');
306  }
307  }
308  } elseif ($action == 'setbankaccount' && $user->rights->facture->creer) {
309  // Set bank account
310  $result = $object->setBankAccount(GETPOST('fk_account', 'int'));
311  } elseif ($action == 'setfrequency' && $user->rights->facture->creer) {
312  // Set frequency and unit frequency
313  $object->setFrequencyAndUnit(GETPOST('frequency', 'int'), GETPOST('unit_frequency', 'alpha'));
314  } elseif ($action == 'setdate_when' && $user->rights->facture->creer) {
315  // Set next date of execution
316  $date = dol_mktime(GETPOST('date_whenhour'), GETPOST('date_whenmin'), 0, GETPOST('date_whenmonth'), GETPOST('date_whenday'), GETPOST('date_whenyear'));
317  if (!empty($date)) {
318  $object->setNextDate($date);
319  }
320  } elseif ($action == 'setnb_gen_max' && $user->rights->facture->creer) {
321  // Set max period
322  $object->setMaxPeriod(GETPOST('nb_gen_max', 'int'));
323  } elseif ($action == 'setauto_validate' && $user->rights->facture->creer) {
324  // Set auto validate
325  $object->setAutoValidate(GETPOST('auto_validate', 'int'));
326  } elseif ($action == 'setgenerate_pdf' && $user->rights->facture->creer) {
327  // Set generate pdf
328  $object->setGeneratepdf(GETPOST('generate_pdf', 'int'));
329  } elseif ($action == 'setmodelpdf' && $user->rights->facture->creer) {
330  // Set model pdf
331  $object->setModelpdf(GETPOST('modelpdf', 'alpha'));
332  } elseif ($action == 'disable' && $user->rights->facture->creer) {
333  // Set status disabled
334  $db->begin();
335 
336  $object->fetch($id);
337 
338  $res = $object->setValueFrom('suspended', 1);
339  if ($res <= 0) {
340  $error++;
341  }
342 
343  if (!$error) {
344  $db->commit();
345  } else {
346  $db->rollback();
347  setEventMessages($object->error, $object->errors, 'errors');
348  }
349  } elseif ($action == 'enable' && $user->rights->facture->creer) {
350  // Set status enabled
351  $db->begin();
352 
353  $object->fetch($id);
354 
355  $res = $object->setValueFrom('suspended', 0);
356  if ($res <= 0) {
357  $error++;
358  }
359 
360  if (!$error) {
361  $db->commit();
362  } else {
363  $db->rollback();
364  setEventMessages($object->error, $object->errors, 'errors');
365  }
366  } elseif ($action == 'setmulticurrencycode' && $usercancreate) {
367  // Multicurrency Code
368  $result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha'));
369  } elseif ($action == 'setmulticurrencyrate' && $usercancreate) {
370  // Multicurrency rate
371  $result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx')), GETPOST('calculation_mode', 'int'));
372  }
373 
374  // Delete line
375  if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->facture->creer) {
376  $object->fetch($id);
377  $object->fetch_thirdparty();
378 
379  $db->begin();
380 
381  $line = new FactureLigneRec($db);
382 
383  // For triggers
384  $line->id = $lineid;
385 
386  if ($line->delete($user) > 0) {
387  $result = $object->update_price(1);
388 
389  if ($result > 0) {
390  $db->commit();
391  $object->fetch($object->id); // Reload lines
392  } else {
393  $db->rollback();
394  setEventMessages($db->lasterror(), null, 'errors');
395  }
396  } else {
397  $db->rollback();
398  setEventMessages($line->error, $line->errors, 'errors');
399  }
400  } elseif ($action == 'update_extras') {
401  $object->oldcopy = dol_clone($object);
402 
403  // Fill array 'array_options' with data from update form
404  $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml'));
405  if ($ret < 0) {
406  $error++;
407  }
408 
409  if (!$error) {
410  $result = $object->insertExtraFields('BILLREC_MODIFY');
411  if ($result < 0) {
412  setEventMessages($object->error, $object->errors, 'errors');
413  $error++;
414  }
415  }
416  }
417 
418  // Add a new line
419  if ($action == 'addline' && $user->rights->facture->creer) {
420  $langs->load('errors');
421  $error = 0;
422 
423  // Set if we used free entry or predefined product
424  $predef = '';
425  $product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
426  $price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
427  $price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
428  $prod_entry_mode = GETPOST('prod_entry_mode', 'alpha');
429  if ($prod_entry_mode == 'free') {
430  $idprod = 0;
431  $tva_tx = (GETPOST('tva_tx', 'alpha') ? GETPOST('tva_tx', 'alpha') : 0);
432  } else {
433  $idprod = GETPOST('idprod', 'int');
434  $tva_tx = '';
435  }
436 
437  $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS', 2);
438  $remise_percent = price2num(GETPOST('remise_percent'.$predef), '', 2);
439 
440  // Extrafields
441  $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
442  $array_options = $extrafields->getOptionalsFromPost($object->table_element_line, $predef);
443  // Unset extrafield
444  if (is_array($extralabelsline)) {
445  // Get extra fields
446  foreach ($extralabelsline as $key => $value) {
447  unset($_POST["options_".$key.$predef]);
448  }
449  }
450 
451  if ((empty($idprod) || $idprod < 0) && ($price_ht < 0) && ($qty < 0)) {
452  setEventMessages($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), null, 'errors');
453  $error++;
454  }
455  if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && GETPOST('type') < 0) {
456  setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors');
457  $error++;
458  }
459  if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && (!($price_ht >= 0) || $price_ht == '')) { // Unit price can be 0 but not ''
460  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors');
461  $error++;
462  }
463  if ($qty == '') {
464  setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors');
465  $error++;
466  }
467  if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && empty($product_desc)) {
468  setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), null, 'errors');
469  $error++;
470  }
471  if ($qty < 0) {
472  $langs->load("errors");
473  setEventMessages($langs->trans('ErrorQtyForCustomerInvoiceCantBeNegative'), null, 'errors');
474  $error++;
475  }
476 
477  if (!$error && ($qty >= 0) && (!empty($product_desc) || (!empty($idprod) && $idprod > 0))) {
478  $ret = $object->fetch($id);
479  if ($ret < 0) {
480  dol_print_error($db, $object->error);
481  exit();
482  }
483  $ret = $object->fetch_thirdparty();
484 
485  // Clean parameters
486  $date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year'));
487  $date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year'));
488  $price_base_type = (GETPOST('price_base_type', 'alpha') ? GETPOST('price_base_type', 'alpha') : 'HT');
489 
490  // Define special_code for special lines
491  $special_code = 0;
492  // if (!GETPOST('qty')) $special_code=3; // Options should not exists on invoices
493 
494  // Ecrase $pu par celui du produit
495  // Ecrase $desc par celui du produit
496  // Ecrase $tva_tx par celui du produit
497  // Ecrase $base_price_type par celui du produit
498  // Replaces $fk_unit with the product's
499  if (!empty($idprod) && $idprod > 0) {
500  $prod = new Product($db);
501  $prod->fetch($idprod);
502 
503  $label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : '');
504 
505  // Update if prices fields are defined
506  $tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id);
507  $tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id);
508  if (empty($tva_tx)) {
509  $tva_npr = 0;
510  }
511 
512  // Search the correct price into loaded array product_price_by_qty using id of array retrieved into POST['pqp'].
513  $pqp = (GETPOST('pbq', 'int') ? GETPOST('pbq', 'int') : 0);
514 
515  $datapriceofproduct = $prod->getSellPrice($mysoc, $object->thirdparty, $pqp);
516 
517  $pu_ht = $datapriceofproduct['pu_ht'];
518  $pu_ttc = $datapriceofproduct['pu_ttc'];
519  $price_min = $datapriceofproduct['price_min'];
520  $price_base_type = empty($datapriceofproduct['price_base_type']) ? 'HT' : $datapriceofproduct['price_base_type'];
521  $tva_tx = $datapriceofproduct['tva_tx'];
522  $tva_npr = $datapriceofproduct['tva_npr'];
523 
524  $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx));
525  $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx));
526 
527  // if price ht was forced (ie: from gui when calculated by margin rate and cost price). TODO Why this ?
528  if (!empty($price_ht)) {
529  $pu_ht = price2num($price_ht, 'MU');
530  $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU');
531  } elseif ($tmpvat != $tmpprodvat) {
532  // On reevalue prix selon taux tva car taux tva transaction peut etre different
533  // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur).
534  if ($price_base_type != 'HT') {
535  $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU');
536  } else {
537  $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU');
538  }
539  }
540 
541  $desc = '';
542 
543  // Define output language
544  if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
545  $outputlangs = $langs;
546  $newlang = '';
547  if (empty($newlang) && GETPOST('lang_id', 'aZ09')) {
548  $newlang = GETPOST('lang_id', 'aZ09');
549  }
550  if (empty($newlang)) {
551  $newlang = $object->thirdparty->default_lang;
552  }
553  if (!empty($newlang)) {
554  $outputlangs = new Translate("", $conf);
555  $outputlangs->setDefaultLang($newlang);
556  }
557 
558  $desc = (!empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description;
559  } else {
560  $desc = $prod->description;
561  }
562 
563  $desc = dol_concatdesc($desc, $product_desc);
564 
565  // Add custom code and origin country into description
566  if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (!empty($prod->customcode) || !empty($prod->country_code))) {
567  $tmptxt = '(';
568  // Define output language
569  if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
570  $outputlangs = $langs;
571  $newlang = '';
572  if (empty($newlang) && GETPOST('lang_id', 'alpha')) {
573  $newlang = GETPOST('lang_id', 'alpha');
574  }
575  if (empty($newlang)) {
576  $newlang = $object->thirdparty->default_lang;
577  }
578  if (!empty($newlang)) {
579  $outputlangs = new Translate("", $conf);
580  $outputlangs->setDefaultLang($newlang);
581  $outputlangs->load('products');
582  }
583  if (!empty($prod->customcode)) {
584  $tmptxt .= $outputlangs->transnoentitiesnoconv("CustomCode").': '.$prod->customcode;
585  }
586  if (!empty($prod->customcode) && !empty($prod->country_code)) {
587  $tmptxt .= ' - ';
588  }
589  if (!empty($prod->country_code)) {
590  $tmptxt .= $outputlangs->transnoentitiesnoconv("CountryOrigin").': '.getCountry($prod->country_code, 0, $db, $outputlangs, 0);
591  }
592  } else {
593  if (!empty($prod->customcode)) {
594  $tmptxt .= $langs->transnoentitiesnoconv("CustomCode").': '.$prod->customcode;
595  }
596  if (!empty($prod->customcode) && !empty($prod->country_code)) {
597  $tmptxt .= ' - ';
598  }
599  if (!empty($prod->country_code)) {
600  $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin").': '.getCountry($prod->country_code, 0, $db, $langs, 0);
601  }
602  }
603  $tmptxt .= ')';
604  $desc = dol_concatdesc($desc, $tmptxt);
605  }
606 
607  $type = $prod->type;
608  $fk_unit = $prod->fk_unit;
609  } else {
610  $pu_ht = price2num($price_ht, 'MU');
611  $pu_ttc = price2num(GETPOST('price_ttc'), 'MU');
612  $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0);
613  $tva_tx = str_replace('*', '', $tva_tx);
614  if (empty($tva_tx)) {
615  $tva_npr = 0;
616  }
617  $label = (GETPOST('product_label') ? GETPOST('product_label') : '');
618  $desc = $product_desc;
619  $type = GETPOST('type');
620  $fk_unit = GETPOST('units', 'alpha');
621  }
622 
623  $date_start_fill = GETPOST('date_start_fill', 'int');
624  $date_end_fill = GETPOST('date_end_fill', 'int');
625 
626  // Margin
627  $fournprice = price2num(GETPOST('fournprice'.$predef) ? GETPOST('fournprice'.$predef) : '');
628  $buyingprice = price2num(GETPOST('buying_price'.$predef) != '' ? GETPOST('buying_price'.$predef) : ''); // If buying_price is '0', we must keep this value
629 
630  // Local Taxes
631  $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty, $mysoc, $tva_npr);
632  $localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty, $mysoc, $tva_npr);
633 
634  $info_bits = 0;
635  if ($tva_npr) {
636  $info_bits |= 0x01;
637  }
638 
639  if ($usercanproductignorepricemin && (!empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min)))) {
640  $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency));
641  setEventMessages($mesg, null, 'errors');
642  } else {
643  // Insert line
644  $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $info_bits, '', $pu_ttc, $type, -1, $special_code, $label, $fk_unit, 0, $date_start_fill, $date_end_fill, $fournprice, $buyingprice);
645 
646  if ($result > 0) {
647  // Define output language and generate document
648  /*if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
649  {
650  // Define output language
651  $outputlangs = $langs;
652  $newlang = '';
653  if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09');
654  if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
655  if (! empty($newlang)) {
656  $outputlangs = new Translate("", $conf);
657  $outputlangs->setDefaultLang($newlang);
658  }
659  $model=$object->model_pdf;
660  $ret = $object->fetch($id); // Reload to get new records
661 
662  $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
663  if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
664  }*/
665  $object->fetch($object->id); // Reload lines
666 
667  unset($_POST['prod_entry_mode']);
668 
669  unset($_POST['qty']);
670  unset($_POST['type']);
671  unset($_POST['remise_percent']);
672  unset($_POST['price_ht']);
673  unset($_POST['multicurrency_price_ht']);
674  unset($_POST['price_ttc']);
675  unset($_POST['tva_tx']);
676  unset($_POST['product_ref']);
677  unset($_POST['product_label']);
678  unset($_POST['product_desc']);
679  unset($_POST['fournprice']);
680  unset($_POST['buying_price']);
681  unset($_POST['np_marginRate']);
682  unset($_POST['np_markRate']);
683  unset($_POST['dp_desc']);
684  unset($_POST['idprod']);
685  unset($_POST['units']);
686 
687  unset($_POST['date_starthour']);
688  unset($_POST['date_startmin']);
689  unset($_POST['date_startsec']);
690  unset($_POST['date_startday']);
691  unset($_POST['date_startmonth']);
692  unset($_POST['date_startyear']);
693  unset($_POST['date_endhour']);
694  unset($_POST['date_endmin']);
695  unset($_POST['date_endsec']);
696  unset($_POST['date_endday']);
697  unset($_POST['date_endmonth']);
698  unset($_POST['date_endyear']);
699 
700  unset($_POST['date_start_fill']);
701  unset($_POST['date_end_fill']);
702 
703  unset($_POST['situations']);
704  unset($_POST['progress']);
705  } else {
706  setEventMessages($object->error, $object->errors, 'errors');
707  }
708 
709  $action = '';
710  }
711  }
712  } elseif ($action == 'updateline' && $usercancreate && !GETPOST('cancel', 'alpha')) {
713  if (!$object->fetch($id) > 0) {
714  dol_print_error($db);
715  }
716  $object->fetch_thirdparty();
717 
718  // Clean parameters
719  $date_start = '';
720  $date_end = '';
721  //$date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));
722  //$date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
723  $description = dol_htmlcleanlastbr(GETPOST('product_desc', 'restricthtml') ? GETPOST('product_desc', 'restricthtml') : GETPOST('desc', 'restricthtml'));
724  $pu_ht = price2num(GETPOST('price_ht'), '', 2);
725  $vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
726  $qty = GETPOST('qty');
727  $pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), '', 2);
728 
729  // Define info_bits
730  $info_bits = 0;
731  if (preg_match('/\*/', $vat_rate)) {
732  $info_bits |= 0x01;
733  }
734 
735  // Define vat_rate
736  $vat_rate = str_replace('*', '', $vat_rate);
737  $localtax1_rate = get_localtax($vat_rate, 1, $object->thirdparty);
738  $localtax2_rate = get_localtax($vat_rate, 2, $object->thirdparty);
739 
740  // Add buying price
741  $fournprice = price2num(GETPOST('fournprice') ? GETPOST('fournprice') : '');
742  $buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value
743 
744  // Extrafields
745  $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
746  $array_options = $extrafields->getOptionalsFromPost($object->table_element_line);
747 
748  $objectline = new FactureLigneRec($db);
749  if ($objectline->fetch(GETPOST('lineid', 'int'))) {
750  $objectline->array_options = $array_options;
751  $result = $objectline->insertExtraFields();
752  if ($result < 0) {
753  setEventMessages($langs->trans('Error').$result, null, 'errors');
754  }
755  }
756 
757  $position = ($objectline->rang >= 0 ? $objectline->rang : 0);
758 
759  // Unset extrafield
760  if (is_array($extralabelsline)) {
761  // Get extra fields
762  foreach ($extralabelsline as $key => $value) {
763  unset($_POST["options_".$key]);
764  }
765  }
766 
767  // Define special_code for special lines
768  $special_code = GETPOST('special_code', 'int');
769  if ($special_code == 3) {
770  $special_code = 0; // Options should not exists on invoices
771  }
772 
773  /*$line = new FactureLigne($db);
774  $line->fetch(GETPOST('lineid', 'int'));
775  $percent = $line->get_prev_progress($object->id);
776 
777  if (GETPOST('progress') < $percent)
778  {
779  $mesg = '<div class="warning">' . $langs->trans("CantBeLessThanMinPercent") . '</div>';
780  setEventMessages($mesg, null, 'warnings');
781  $error++;
782  $result = -1;
783  }*/
784 
785  $remise_percent = price2num(GETPOST('remise_percent'), '', 2);
786 
787  // Check minimum price
788  $productid = GETPOST('productid', 'int');
789  if (!empty($productid)) {
790  $product = new Product($db);
791  $product->fetch($productid);
792 
793  $type = $product->type;
794 
795  $price_min = $product->price_min;
796  if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($object->thirdparty->price_level)) {
797  $price_min = $product->multiprices_min[$object->thirdparty->price_level];
798  }
799 
800  $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : '');
801 
802  // Check price is not lower than minimum (check is done only for standard or replacement invoices)
803  if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS)) && (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) && $price_min && (price2num($pu_ht) * (1 - $remise_percent / 100) < price2num($price_min)))) {
804  setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors');
805  $error++;
806  }
807  } else {
808  $type = GETPOST('type', 'int');
809  $label = (GETPOST('product_label') ? GETPOST('product_label') : '');
810 
811  // Check parameters
812  if (GETPOST('type', 'int') < 0) {
813  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors');
814  $error++;
815  }
816  }
817  if ($qty < 0) {
818  $langs->load("errors");
819  setEventMessages($langs->trans('ErrorQtyForCustomerInvoiceCantBeNegative'), null, 'errors');
820  $error++;
821  }
822 
823  $date_start_fill = GETPOST('date_start_fill', 'int');
824  $date_end_fill = GETPOST('date_end_fill', 'int');
825 
826  // Update line
827  if (!$error) {
828  $result = $object->updateline(
829  GETPOST('lineid', 'int'),
830  $description,
831  $pu_ht,
832  $qty,
833  $vat_rate,
834  $localtax1_rate,
835  $localtax1_rate,
836  GETPOST('productid', 'int'),
837  $remise_percent,
838  'HT',
839  $info_bits,
840  0,
841  0,
842  $type,
843  $position,
844  $special_code,
845  $label,
846  GETPOST('units'),
847  $pu_ht_devise,
848  0,
849  $date_start_fill,
850  $date_end_fill,
851  $fournprice,
852  $buyingprice
853  );
854 
855  if ($result >= 0) {
856  /*if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
857  // Define output language
858  $outputlangs = $langs;
859  $newlang = '';
860  if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09'))
861  $newlang = GETPOST('lang_id','aZ09');
862  if ($conf->global->MAIN_MULTILANGS && empty($newlang))
863  $newlang = $object->thirdparty->default_lang;
864  if (! empty($newlang)) {
865  $outputlangs = new Translate("", $conf);
866  $outputlangs->setDefaultLang($newlang);
867  }
868 
869  $ret = $object->fetch($id); // Reload to get new records
870  $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
871  }*/
872 
873  $object->fetch($object->id); // Reload lines
874 
875  unset($_POST['qty']);
876  unset($_POST['type']);
877  unset($_POST['productid']);
878  unset($_POST['remise_percent']);
879  unset($_POST['price_ht']);
880  unset($_POST['multicurrency_price_ht']);
881  unset($_POST['price_ttc']);
882  unset($_POST['tva_tx']);
883  unset($_POST['product_ref']);
884  unset($_POST['product_label']);
885  unset($_POST['product_desc']);
886  unset($_POST['fournprice']);
887  unset($_POST['buying_price']);
888  unset($_POST['np_marginRate']);
889  unset($_POST['np_markRate']);
890 
891  unset($_POST['dp_desc']);
892  unset($_POST['idprod']);
893  unset($_POST['units']);
894 
895  unset($_POST['date_starthour']);
896  unset($_POST['date_startmin']);
897  unset($_POST['date_startsec']);
898  unset($_POST['date_startday']);
899  unset($_POST['date_startmonth']);
900  unset($_POST['date_startyear']);
901  unset($_POST['date_endhour']);
902  unset($_POST['date_endmin']);
903  unset($_POST['date_endsec']);
904  unset($_POST['date_endday']);
905  unset($_POST['date_endmonth']);
906  unset($_POST['date_endyear']);
907 
908  unset($_POST['situations']);
909  unset($_POST['progress']);
910  } else {
911  setEventMessages($object->error, $object->errors, 'errors');
912  }
913  }
914  }
915 }
916 
917 
918 /*
919  * View
920  */
921 
922 $help_url = '';
923 llxHeader('', $langs->trans("RepeatableInvoices"), $help_url);
924 
925 $form = new Form($db);
926 $formother = new FormOther($db);
927 if (isModEnabled('project')) {
928  $formproject = new FormProjets($db);
929 }
930 $companystatic = new Societe($db);
931 $invoicerectmp = new FactureRec($db);
932 
933 $now = dol_now();
934 $nowlasthour = dol_get_last_hour($now);
935 
936 
937 /*
938  * Create mode
939  */
940 if ($action == 'create') {
941  print load_fiche_titre($langs->trans("CreateRepeatableInvoice"), '', 'bill');
942 
943  $object = new Facture($db); // Source invoice
944  $product_static = new Product($db);
945 
946  if ($object->fetch($id, $ref) > 0) {
947  $result = $object->getLinesArray();
948 
949  print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
950  print '<input type="hidden" name="token" value="'.newToken().'">';
951  print '<input type="hidden" name="action" value="add">';
952  print '<input type="hidden" name="facid" value="'.$object->id.'">';
953 
954  print dol_get_fiche_head(null, '', '', 0);
955 
956  $rowspan = 4;
957  if (isModEnabled('project')) {
958  $rowspan++;
959  }
960  if ($object->fk_account > 0) {
961  $rowspan++;
962  }
963 
964  print '<table class="border centpercent">';
965 
966  $object->fetch_thirdparty();
967 
968  // Title
969  print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Title").'</td><td>';
970  print '<input class="flat quatrevingtpercent" type="text" name="title" value="'.dol_escape_htmltag(GETPOST("title", 'alphanohtml')).'" autofocus>';
971  print '</td></tr>';
972 
973  // Third party
974  print '<tr><td class="titlefieldcreate">'.$langs->trans("Customer").'</td><td>'.$object->thirdparty->getNomUrl(1, 'customer').'</td>';
975  print '</tr>';
976 
977  $note_public = GETPOSTISSET('note_public') ? GETPOST('note_public', 'restricthtml') : $object->note_public;
978  $note_private = GETPOSTISSET('note_private') ? GETPOST('note_private', 'restricthtml') : $object->note_private;
979 
980  // Help of substitution key
981  $substitutionarray = getCommonSubstitutionArray($langs, 2, null, $object);
982 
983  $substitutionarray['__INVOICE_PREVIOUS_MONTH__'] = $langs->trans("PreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'm'), '%m').')';
984  $substitutionarray['__INVOICE_MONTH__'] = $langs->trans("MonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date, '%m').')';
985  $substitutionarray['__INVOICE_NEXT_MONTH__'] = $langs->trans("NextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'm'), '%m').')';
986  $substitutionarray['__INVOICE_PREVIOUS_MONTH_TEXT__'] = $langs->trans("TextPreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'm'), '%B').')';
987  $substitutionarray['__INVOICE_MONTH_TEXT__'] = $langs->trans("TextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date, '%B').')';
988  $substitutionarray['__INVOICE_NEXT_MONTH_TEXT__'] = $langs->trans("TextNextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'm'), '%B').')';
989  $substitutionarray['__INVOICE_PREVIOUS_YEAR__'] = $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, -1, 'y'), '%Y').')';
990  $substitutionarray['__INVOICE_YEAR__'] = $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($object->date, '%Y').')';
991  $substitutionarray['__INVOICE_NEXT_YEAR__'] = $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date, 1, 'y'), '%Y').')';
992  // Only on template invoices
993  $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = $langs->trans("DateNextInvoiceBeforeGen").' ('.$langs->trans("Example").': '.dol_print_date($object->date_when, 'dayhour').')';
994  $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__'] = $langs->trans("DateNextInvoiceAfterGen").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($object->date_when, $object->frequency, $object->unit_frequency), 'dayhour').')';
995  $substitutionarray['__INVOICE_COUNTER_CURRENT__'] = $langs->trans("Count");
996  $substitutionarray['__INVOICE_COUNTER_MAX__'] = $langs->trans("MaxPeriodNumber");
997 
998  $htmltext = '<i>'.$langs->trans("FollowingConstantsWillBeSubstituted").':<br>';
999  foreach ($substitutionarray as $key => $val) {
1000  $htmltext .= $key.' = '.$langs->trans($val).'<br>';
1001  }
1002  $htmltext .= '</i>';
1003 
1004  // Public note
1005  print '<tr>';
1006  print '<td class="tdtop">';
1007  print $form->textwithpicto($langs->trans('NotePublic'), $htmltext, 1, 'help', '', 0, 2, 'notepublic');
1008  print '</td>';
1009  print '<td>';
1010  $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3, '90%');
1011  print $doleditor->Create(1);
1012 
1013  // Private note
1014  if (empty($user->socid)) {
1015  print '<tr>';
1016  print '<td class="tdtop">';
1017  print $form->textwithpicto($langs->trans('NotePrivate'), $htmltext, 1, 'help', '', 0, 2, 'noteprivate');
1018  print '</td>';
1019  print '<td>';
1020  $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3, '90%');
1021  print $doleditor->Create(1);
1022  // print '<textarea name="note_private" wrap="soft" cols="70" rows="'.ROWS_3.'">'.$note_private.'.</textarea>
1023  print '</td></tr>';
1024  }
1025 
1026  // Author
1027  print "<tr><td>".$langs->trans("Author")."</td><td>".$user->getFullName($langs)."</td></tr>";
1028 
1029  // Payment term
1030  print "<tr><td>".$langs->trans("PaymentConditions")."</td><td>";
1031  print $form->getSelectConditionsPaiements(GETPOSTISSET('cond_reglement_id') ? GETPOST('cond_reglement_id', 'int') : $object->cond_reglement_id, 'cond_reglement_id', -1, 0, 0, '');
1032  //$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'cond_reglement_id');
1033  print "</td></tr>";
1034 
1035  // Payment mode
1036  print "<tr><td>".$langs->trans("PaymentMode")."</td><td>";
1037  print img_picto('', 'payment', 'class="pictofixedwidth"');
1038  print $form->select_types_paiements(GETPOSTISSET('mode_reglement_id') ? GETPOST('mode_reglement_id', 'int') : $object->mode_reglement_id, 'mode_reglement_id', '', 0, 1, 0, 0, 1, '', 1);
1039  //$form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', '', 1);
1040  print "</td></tr>";
1041 
1042  // Bank account
1043  if ($object->fk_account > 0) {
1044  print "<tr><td>".$langs->trans('BankAccount')."</td><td>";
1045  $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none');
1046  print "</td></tr>";
1047  }
1048 
1049  // Project
1050  if (isModEnabled('project') && is_object($object->thirdparty) && $object->thirdparty->id > 0) {
1051  $projectid = GETPOST('projectid') ?GETPOST('projectid') : $object->fk_project;
1052  $langs->load('projects');
1053  print '<tr><td>'.$langs->trans('Project').'</td><td>';
1054  print img_picto('', 'project', 'class="pictofixedwidth"');
1055  $numprojet = $formproject->select_projects($object->thirdparty->id, $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, '');
1056  print ' &nbsp; <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$object->thirdparty->id.'&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$object->thirdparty->id.(!empty($id) ? '&id='.$id : '')).'">'.img_object($langs->trans("AddProject"), 'add').'</a>';
1057  print '</td></tr>';
1058  }
1059 
1060  // Model pdf
1061  print "<tr><td>".$langs->trans('Model')."</td><td>";
1062  include_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php';
1063  $list = ModelePDFFactures::liste_modeles($db);
1064  print img_picto('', 'generic', 'class="pictofixedwidth"');
1065  print $form->selectarray('modelpdf', $list, $conf->global->FACTURE_ADDON_PDF);
1066  print "</td></tr>";
1067 
1068  print "</table>";
1069 
1070  print dol_get_fiche_end();
1071 
1072 
1073  // Autogeneration
1074  $title = $langs->trans("Recurrence");
1075  print load_fiche_titre(img_picto('', 'recurring', 'class="pictofixedwidth"').$title, '', '');
1076 
1077  print dol_get_fiche_head(null, '', '', 0);
1078 
1079  print '<table class="border centpercent">';
1080 
1081  // Frequency + unit
1082  print '<tr><td class="titlefieldcreate">'.$form->textwithpicto($langs->trans("Frequency"), $langs->transnoentitiesnoconv('toolTipFrequency'))."</td><td>";
1083  print "<input type='text' name='frequency' value='".GETPOST('frequency', 'int')."' size='4' />&nbsp;";
1084  print $form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), (GETPOST('unit_frequency') ?GETPOST('unit_frequency') : 'm'));
1085  print "</td></tr>";
1086 
1087  // Date next run
1088  print "<tr><td>".$langs->trans('NextDateToExecution')."</td><td>";
1089  $date_next_execution = isset($date_next_execution) ? $date_next_execution : (GETPOST('remonth') ? dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')) : -1);
1090  print $form->selectDate($date_next_execution, '', 1, 1, '', "add", 1, 1);
1091  print "</td></tr>";
1092 
1093  // Number max of generation
1094  print "<tr><td>".$langs->trans("MaxPeriodNumber")."</td><td>";
1095  print '<input type="text" name="nb_gen_max" value="'.GETPOST('nb_gen_max').'" size="5" />';
1096  print "</td></tr>";
1097 
1098  // Auto validate the invoice
1099  print "<tr><td>".$langs->trans("StatusOfGeneratedInvoices")."</td><td>";
1100  $select = array('0'=>$langs->trans('BillStatusDraft'), '1'=>$langs->trans('BillStatusValidated'));
1101  print $form->selectarray('auto_validate', $select, GETPOST('auto_validate'));
1102  print "</td></tr>";
1103 
1104  // Auto generate document
1105  if (!empty($conf->global->INVOICE_REC_CAN_DISABLE_DOCUMENT_FILE_GENERATION)) {
1106  print "<tr><td>".$langs->trans("StatusOfGeneratedDocuments")."</td><td>";
1107  $select = array('0'=>$langs->trans('DoNotGenerateDoc'), '1'=>$langs->trans('AutoGenerateDoc'));
1108  print $form->selectarray('generate_pdf', $select, GETPOST('generate_pdf'));
1109  print "</td></tr>";
1110  } else {
1111  print '<input type="hidden" name="generate_pdf" value="1">';
1112  }
1113 
1114  print "</table>";
1115 
1116  print dol_get_fiche_end();
1117 
1118 
1119  $title = $langs->trans("ProductsAndServices");
1120  if (!isModEnabled('service')) {
1121  $title = $langs->trans("Products");
1122  } elseif (!isModEnabled('product')) {
1123  $title = $langs->trans("Services");
1124  }
1125 
1126  print load_fiche_titre($title, '', '');
1127 
1128  /*
1129  * Invoice lines
1130  */
1131  print '<div class="div-table-responsive-no-min">';
1132  print '<table id="tablelines" class="noborder noshadow" width="100%">';
1133  // Show object lines
1134  if (!empty($object->lines)) {
1135  $disableedit = 1;
1136  $disablemove = 1;
1137  $disableremove = 1;
1138  $object->printObjectLines('', $mysoc, $object->thirdparty, $lineid, 0); // No date selector for template invoice
1139  }
1140 
1141  print "</table>\n";
1142  print '<div>';
1143 
1144  print '</td></tr>';
1145 
1146  if ($flag_price_may_change) {
1147  print '<tr><td colspan="3" class="left">';
1148  print '<select name="usenewprice" class="flat">';
1149  print '<option value="0">'.$langs->trans("AlwaysUseFixedPrice").'</option>';
1150  print '<option value="1" disabled>'.$langs->trans("AlwaysUseNewPrice").'</option>';
1151  print '</select>';
1152  print '</td></tr>';
1153  }
1154  print "</table>\n";
1155 
1156  print $form->buttonsSaveCancel("Create");
1157 
1158  print "</form>\n";
1159  } else {
1160  dol_print_error('', "Error, no invoice ".$object->id);
1161  }
1162 } else {
1163  /*
1164  * View mode
1165  */
1166  if ($object->id > 0) {
1167  $object->fetch_thirdparty();
1168 
1169  // Confirmation de la suppression d'une ligne produit
1170  if ($action == 'ask_deleteline') {
1171  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 'no', 1);
1172  }
1173 
1174  // Confirm delete of repeatable invoice
1175  if ($action == 'ask_deleteinvoice') {
1176  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteRepeatableInvoice'), $langs->trans('ConfirmDeleteRepeatableInvoice'), 'confirm_deleteinvoice', '', 'no', 1);
1177  }
1178 
1179  print $formconfirm;
1180 
1181  $author = new User($db);
1182  $author->fetch($object->user_author);
1183 
1184  $head = invoice_rec_prepare_head($object);
1185 
1186  print dol_get_fiche_head($head, 'card', $langs->trans("RepeatableInvoice"), -1, 'bill'); // Add a div
1187 
1188  // Recurring invoice content
1189 
1190  $linkback = '<a href="'.DOL_URL_ROOT.'/compta/facture/invoicetemplate_list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
1191 
1192  $morehtmlref = '';
1193  if ($action != 'editref') {
1194  $morehtmlref .= $form->editfieldkey($object->ref, 'ref', $object->ref, $object, $user->rights->facture->creer, '', '', 0, 2);
1195  } else {
1196  $morehtmlref .= $form->editfieldval('', 'ref', $object->ref, $object, $user->rights->facture->creer, 'string');
1197  }
1198 
1199  $morehtmlref .= '<div class="refidno">';
1200  // Ref customer
1201  //$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->facture->creer, 'string', '', 0, 1);
1202  //$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->facture->creer, 'string', '', null, null, '', 1);
1203  // Thirdparty
1204  $morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
1205  // Project
1206  if (isModEnabled('project')) {
1207  $langs->load("projects");
1208  $morehtmlref .= '<br>'.$langs->trans('Project').' ';
1209  if ($user->rights->facture->creer) {
1210  if ($action != 'classify') {
1211  $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
1212  }
1213  if ($action == 'classify') {
1214  //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
1215  $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
1216  $morehtmlref .= '<input type="hidden" name="action" value="classin">';
1217  $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
1218  $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
1219  $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
1220  $morehtmlref .= '</form>';
1221  } else {
1222  $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
1223  }
1224  } else {
1225  if (!empty($object->fk_project)) {
1226  $proj = new Project($db);
1227  $proj->fetch($object->fk_project);
1228  $morehtmlref .= ' : '.$proj->getNomUrl(1);
1229  if ($proj->title) {
1230  $morehtmlref .= ' - '.$proj->title;
1231  }
1232  } else {
1233  $morehtmlref .= '';
1234  }
1235  }
1236  }
1237  $morehtmlref .= '</div>';
1238 
1239  $morehtmlright = '';
1240 
1241  dol_banner_tab($object, 'ref', $linkback, 1, 'title', 'none', $morehtmlref, '', 0, '', $morehtmlright);
1242 
1243  print '<div class="fichecenter">';
1244  print '<div class="fichehalfleft">';
1245  print '<div class="underbanner clearboth"></div>';
1246 
1247  print '<table class="border centpercent tableforfield">';
1248 
1249  print '<tr><td class="titlefield">'.$langs->trans("Author").'</td><td>';
1250  print $author->getNomUrl(-1);
1251  print "</td></tr>";
1252 
1253  print '<tr><td>'.$langs->trans("AmountHT").'</td>';
1254  print '<td>'.price($object->total_ht, '', $langs, 1, -1, -1, $conf->currency).'</td>';
1255  print '</tr>';
1256 
1257  print '<tr><td>'.$langs->trans("AmountVAT").'</td><td>'.price($object->total_tva, '', $langs, 1, -1, -1, $conf->currency).'</td>';
1258  print '</tr>';
1259 
1260  // Amount Local Taxes
1261  if (($mysoc->localtax1_assuj == "1" && $mysoc->useLocalTax(1)) || $object->total_localtax1 != 0) { // Localtax1
1262  print '<tr><td>'.$langs->transcountry("AmountLT1", $mysoc->country_code).'</td>';
1263  print '<td class="nowrap">'.price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>';
1264  }
1265  if (($mysoc->localtax2_assuj == "1" && $mysoc->useLocalTax(2)) || $object->total_localtax2 != 0) { // Localtax2
1266  print '<tr><td>'.$langs->transcountry("AmountLT2", $mysoc->country_code).'</td>';
1267  print '<td class=nowrap">'.price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>';
1268  }
1269 
1270  print '<tr><td>'.$langs->trans("AmountTTC").'</td><td colspan="3">'.price($object->total_ttc, '', $langs, 1, -1, -1, $conf->currency).'</td>';
1271  print '</tr>';
1272 
1273 
1274  // Payment term
1275  print '<tr><td>';
1276  print '<table class="nobordernopadding centpercent"><tr><td>';
1277  print $langs->trans('PaymentConditionsShort');
1278  print '</td>';
1279  if ($action != 'editconditions' && $user->rights->facture->creer) {
1280  print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editconditions&token='.newToken().'&facid='.$object->id.'">'.img_edit($langs->trans('SetConditions'), 1).'</a></td>';
1281  }
1282  print '</tr></table>';
1283  print '</td><td>';
1284  if ($object->type != Facture::TYPE_CREDIT_NOTE) {
1285  if ($action == 'editconditions') {
1286  $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->cond_reglement_id, 'cond_reglement_id');
1287  } else {
1288  $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->cond_reglement_id, 'none');
1289  }
1290  } else {
1291  print '&nbsp;';
1292  }
1293  print '</td></tr>';
1294 
1295  // Payment mode
1296  print '<tr><td>';
1297  print '<table class="nobordernopadding" width="100%"><tr><td>';
1298  print $langs->trans('PaymentMode');
1299  print '</td>';
1300  if ($action != 'editmode' && $user->rights->facture->creer) {
1301  print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editmode&token='.newToken().'&facid='.$object->id.'">'.img_edit($langs->trans('SetMode'), 1).'</a></td>';
1302  }
1303  print '</tr></table>';
1304  print '</td><td>';
1305  if ($action == 'editmode') {
1306  $form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT', 1, 1);
1307  } else {
1308  $form->form_modes_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->mode_reglement_id, 'none');
1309  }
1310  print '</td></tr>';
1311 
1312  // Multicurrency
1313  if (isModEnabled('multicurrency')) {
1314  // Multicurrency code
1315  print '<tr>';
1316  print '<td>';
1317  print '<table class="nobordernopadding" width="100%"><tr><td>';
1318  print $form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0);
1319  print '</td>';
1320  if ($usercancreate && $action != 'editmulticurrencycode' && !empty($object->brouillon)) {
1321  print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editmulticurrencycode&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'</a></td>';
1322  }
1323  print '</tr></table>';
1324  print '</td><td>';
1325  $htmlname = (($usercancreate && $action == 'editmulticurrencycode') ? 'multicurrency_code' : 'none');
1326  $form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, $htmlname);
1327  print '</td></tr>';
1328 
1329  // Multicurrency rate
1330  if ($object->multicurrency_code != $conf->currency || $object->multicurrency_tx != 1) {
1331  print '<tr>';
1332  print '<td>';
1333  print '<table class="nobordernopadding" width="100%"><tr><td>';
1334  print $form->editfieldkey('CurrencyRate', 'multicurrency_tx', '', $object, 0);
1335  print '</td>';
1336  if ($usercancreate && $action != 'editmulticurrencyrate' && !empty($object->brouillon) && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) {
1337  print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editmulticurrencyrate&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'</a></td>';
1338  }
1339  print '</tr></table>';
1340  print '</td><td>';
1341  if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') {
1342  if ($action == 'actualizemulticurrencyrate') {
1343  list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code);
1344  }
1345  $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_tx, ($usercancreate ? 'multicurrency_tx' : 'none'), $object->multicurrency_code);
1346  } else {
1347  $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code);
1348  if ($object->statut == $object::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) {
1349  print '<div class="inline-block"> &nbsp; &nbsp; &nbsp; &nbsp; ';
1350  print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=actualizemulticurrencyrate">'.$langs->trans("ActualizeCurrency").'</a>';
1351  print '</div>';
1352  }
1353  }
1354  print '</td></tr>';
1355  }
1356  }
1357 
1358  // Help of substitution key
1359  $dateexample = dol_now();
1360  if (!empty($object->frequency) && !empty($object->date_when)) {
1361  $dateexample = $object->date_when;
1362  }
1363 
1364  // Help of substitution key
1365  $substitutionarray = getCommonSubstitutionArray($langs, 2, null, $object);
1366 
1367  $substitutionarray['__INVOICE_PREVIOUS_MONTH__'] = $langs->trans("PreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'm'), '%m').')';
1368  $substitutionarray['__INVOICE_MONTH__'] = $langs->trans("MonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample, '%m').')';
1369  $substitutionarray['__INVOICE_NEXT_MONTH__'] = $langs->trans("NextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'm'), '%m').')';
1370  $substitutionarray['__INVOICE_PREVIOUS_MONTH_TEXT__'] = $langs->trans("TextPreviousMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'm'), '%B').')';
1371  $substitutionarray['__INVOICE_MONTH_TEXT__'] = $langs->trans("TextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample, '%B').')';
1372  $substitutionarray['__INVOICE_NEXT_MONTH_TEXT__'] = $langs->trans("TextNextMonthOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'm'), '%B').')';
1373  $substitutionarray['__INVOICE_PREVIOUS_YEAR__'] = $langs->trans("PreviousYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, -1, 'y'), '%Y').')';
1374  $substitutionarray['__INVOICE_YEAR__'] = $langs->trans("YearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date($dateexample, '%Y').')';
1375  $substitutionarray['__INVOICE_NEXT_YEAR__'] = $langs->trans("NextYearOfInvoice").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree($dateexample, 1, 'y'), '%Y').')';
1376  // Only on template invoices
1377  $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_BEFORE_GEN__'] = $langs->trans("DateNextInvoiceBeforeGen").' ('.$langs->trans("Example").': '.dol_print_date(($object->date_when ? $object->date_when : dol_now()), 'dayhour').')';
1378  $substitutionarray['__INVOICE_DATE_NEXT_INVOICE_AFTER_GEN__'] = $langs->trans("DateNextInvoiceAfterGen").' ('.$langs->trans("Example").': '.dol_print_date(dol_time_plus_duree(($object->date_when ? $object->date_when : dol_now()), $object->frequency, $object->unit_frequency), 'dayhour').')';
1379  $substitutionarray['__INVOICE_COUNTER_CURRENT__'] = $object->nb_gen_done;
1380  $substitutionarray['__INVOICE_COUNTER_MAX__'] = $object->nb_gen_max;
1381 
1382  $htmltext = '<i>'.$langs->trans("FollowingConstantsWillBeSubstituted").':<br>';
1383  foreach ($substitutionarray as $key => $val) {
1384  $htmltext .= $key.' = '.$langs->trans($val).'<br>';
1385  }
1386  $htmltext .= '</i>';
1387 
1388  // Note public
1389  print '<tr><td>';
1390  print $form->editfieldkey($form->textwithpicto($langs->trans('NotePublic'), $htmltext, 1, 'help', '', 0, 2, 'notepublic'), 'note_public', $object->note_public, $object, $user->rights->facture->creer);
1391  print '</td><td class="wordbreak">';
1392  print $form->editfieldval($langs->trans("NotePublic"), 'note_public', $object->note_public, $object, $user->rights->facture->creer, 'textarea:'.ROWS_4.':90%', '', null, null, '', 1);
1393  print '</td>';
1394  print '</tr>';
1395 
1396  // Note private
1397  print '<tr><td>';
1398  print $form->editfieldkey($form->textwithpicto($langs->trans("NotePrivate"), $htmltext, 1, 'help', '', 0, 2, 'noteprivate'), 'note_private', $object->note_private, $object, $user->rights->facture->creer);
1399  print '</td><td class="wordbreak">';
1400  print $form->editfieldval($langs->trans("NotePrivate"), 'note_private', $object->note_private, $object, $user->rights->facture->creer, 'textarea:'.ROWS_4.':90%', '', null, null, '', 1);
1401  print '</td>';
1402  print '</tr>';
1403 
1404  // Bank Account
1405  print '<tr><td class="nowrap">';
1406  print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
1407  print $langs->trans('BankAccount');
1408  print '<td>';
1409  if (($action != 'editbankaccount') && $user->rights->facture->creer && $object->statut == FactureRec::STATUS_DRAFT) {
1410  print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'</a></td>';
1411  }
1412  print '</tr></table>';
1413  print '</td><td>';
1414  if ($action == 'editbankaccount') {
1415  $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1);
1416  } else {
1417  $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none');
1418  }
1419  print "</td>";
1420  print '</tr>';
1421 
1422  // Model pdf
1423  print '<tr><td class="nowrap">';
1424  print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
1425  print $langs->trans('Model');
1426  print '<td>';
1427  if (($action != 'editmodelpdf') && $user->rights->facture->creer && $object->statut == FactureRec::STATUS_DRAFT) {
1428  print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editmodelpdf&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->trans('SetModel'), 1).'</a></td>';
1429  }
1430  print '</tr></table>';
1431  print '</td><td>';
1432  if ($action == 'editmodelpdf') {
1433  include_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php';
1434  $list = array();
1435  $models = ModelePDFFactures::liste_modeles($db);
1436  foreach ($models as $k => $model) {
1437  $list[] = str_replace(':', '|', $k).':'.$model;
1438  }
1439  $select = 'select;'.implode(',', $list);
1440  print $form->editfieldval($langs->trans("Model"), 'modelpdf', $object->model_pdf, $object, $user->rights->facture->creer, $select);
1441  } else {
1442  print $object->model_pdf;
1443  }
1444  print "</td>";
1445  print '</tr>';
1446 
1447  // Other attributes
1448  $cols = 2;
1449  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
1450 
1451  print '</table>';
1452 
1453  print '</div>';
1454  print '<div class="fichehalfright">';
1455  print '<div class="underbanner clearboth"></div>';
1456 
1457 
1458  /*
1459  * Recurrence
1460  */
1461  $title = $langs->trans("Recurrence");
1462  //print load_fiche_titre($title, '', 'calendar');
1463 
1464  print '<table class="border centpercent tableforfield">';
1465 
1466  print '<tr><td colspan="2">'.img_picto('', 'recurring', 'class="pictofixedwidth"').$title.'</td></tr>';
1467 
1468  // if "frequency" is empty or = 0, the reccurence is disabled
1469  print '<tr><td style="width: 50%">';
1470  print '<table class="nobordernopadding" width="100%"><tr><td>';
1471  print $langs->trans('Frequency');
1472  print '</td>';
1473  if ($action != 'editfrequency' && $user->rights->facture->creer) {
1474  print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editfrequency&token='.newToken().'&facid='.$object->id.'">'.img_edit($langs->trans('Edit'), 1).'</a></td>';
1475  }
1476  print '</tr></table>';
1477  print '</td><td>';
1478  if ($action == 'editfrequency') {
1479  print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?facid='.$object->id.'">';
1480  print '<input type="hidden" name="action" value="setfrequency">';
1481  print '<input type="hidden" name="token" value="'.newToken().'">';
1482  print '<table class="nobordernopadding">';
1483  print '<tr><td>';
1484  print "<input type='text' name='frequency' value='".$object->frequency."' size='5' />&nbsp;";
1485  print $form->selectarray('unit_frequency', array('d'=>$langs->trans('Day'), 'm'=>$langs->trans('Month'), 'y'=>$langs->trans('Year')), ($object->unit_frequency ? $object->unit_frequency : 'm'));
1486  print '</td>';
1487  print '<td class="left"><input type="submit" class="button button-edit smallpaddingimp" value="'.$langs->trans("Modify").'"></td>';
1488  print '</tr></table></form>';
1489  } else {
1490  if ($object->frequency > 0) {
1491  print $langs->trans('FrequencyPer_'.$object->unit_frequency, $object->frequency);
1492  } else {
1493  print '<span class="opacitymedium">'.$langs->trans("NotARecurringInvoiceTemplate").'</span>';
1494  }
1495  }
1496  print '</td></tr>';
1497 
1498  // Date when (next invoice generation)
1499  print '<tr><td>';
1500  if ($action == 'date_when' || $object->frequency > 0) {
1501  print $form->editfieldkey($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->rights->facture->creer, 'day');
1502  } else {
1503  print $langs->trans("NextDateToExecution");
1504  }
1505  print '</td><td>';
1506  if ($action == 'date_when' || $object->frequency > 0) {
1507  print $form->editfieldval($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->rights->facture->creer, 'day', $object->date_when, null, '', '', 0, 'strikeIfMaxNbGenReached');
1508  }
1509  //var_dump(dol_print_date($object->date_when+60, 'dayhour').' - '.dol_print_date($now, 'dayhour'));
1510  if (!$object->isMaxNbGenReached()) {
1511  if (!$object->suspended && $action != 'editdate_when' && $object->frequency > 0 && $object->date_when && $object->date_when < $now) {
1512  print img_warning($langs->trans("Late"));
1513  }
1514  } else {
1515  print img_info($langs->trans("MaxNumberOfGenerationReached"));
1516  }
1517  print '</td>';
1518  print '</tr>';
1519 
1520  // Max period / Rest period
1521  print '<tr><td>';
1522  if ($action == 'nb_gen_max' || $object->frequency > 0) {
1523  print $form->editfieldkey($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max, $object, $user->rights->facture->creer);
1524  } else {
1525  print $langs->trans("MaxPeriodNumber");
1526  }
1527  print '</td><td>';
1528  if ($action == 'nb_gen_max' || $object->frequency > 0) {
1529  print $form->editfieldval($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max ? $object->nb_gen_max : '', $object, $user->rights->facture->creer);
1530  } else {
1531  print '';
1532  }
1533  print '</td>';
1534  print '</tr>';
1535 
1536  // Status of generated invoices
1537  print '<tr><td>';
1538  if ($action == 'auto_validate' || $object->frequency > 0) {
1539  print $form->editfieldkey($langs->trans("StatusOfGeneratedInvoices"), 'auto_validate', $object->auto_validate, $object, $user->rights->facture->creer);
1540  } else {
1541  print $langs->trans("StatusOfGeneratedInvoices");
1542  }
1543  print '</td><td>';
1544  $select = 'select;0:'.$langs->trans('BillStatusDraft').',1:'.$langs->trans('BillStatusValidated');
1545  if ($action == 'auto_validate' || $object->frequency > 0) {
1546  print $form->editfieldval($langs->trans("StatusOfGeneratedInvoices"), 'auto_validate', $object->auto_validate, $object, $user->rights->facture->creer, $select);
1547  }
1548  print '</td>';
1549  // Auto generate documents
1550  if (!empty($conf->global->INVOICE_REC_CAN_DISABLE_DOCUMENT_FILE_GENERATION)) {
1551  print '<tr>';
1552  print '<td>';
1553  if ($action == 'generate_pdf' || $object->frequency > 0) {
1554  print $form->editfieldkey($langs->trans("StatusOfGeneratedDocuments"), 'generate_pdf', $object->generate_pdf, $object, $user->rights->facture->creer);
1555  } else {
1556  print $langs->trans("StatusOfGeneratedDocuments");
1557  }
1558  print '</td>';
1559  print '<td>';
1560  $select = 'select;0:'.$langs->trans('DoNotGenerateDoc').',1:'.$langs->trans('AutogenerateDoc');
1561  if ($action == 'generate_pdf' || $object->frequency > 0) {
1562  print $form->editfieldval($langs->trans("StatusOfGeneratedDocuments"), 'generate_pdf', $object->generate_pdf, $object, $user->rights->facture->creer, $select);
1563  }
1564  print '</td>';
1565  print '</tr>';
1566  } else {
1567  print '<input type="hidden" name="generate_pdf" value="1">';
1568  }
1569 
1570  print '</table>';
1571 
1572  // Frequencry/Recurring section
1573  if ($object->frequency > 0) {
1574  print '<br>';
1575 
1576  if (!isModEnabled('cron')) {
1577  print info_admin($langs->trans("EnableAndSetupModuleCron", $langs->transnoentitiesnoconv("Module2300Name")));
1578  }
1579 
1580  print '<div class="underbanner clearboth"></div>';
1581  print '<table class="border centpercent tableforfield">';
1582 
1583  // Nb of generation already done
1584  print '<tr><td style="width: 50%">'.$langs->trans("NbOfGenerationDone").'</td>';
1585  print '<td>';
1586  print $object->nb_gen_done ? $object->nb_gen_done : '0';
1587  print '</td>';
1588  print '</tr>';
1589 
1590  // Date last
1591  print '<tr><td>';
1592  print $langs->trans("DateLastGeneration");
1593  print '</td><td>';
1594  print dol_print_date($object->date_last_gen, 'dayhour');
1595  print '</td>';
1596  print '</tr>';
1597 
1598  print '</table>';
1599 
1600  print '<br>';
1601  }
1602 
1603  print '</div>';
1604  print '</div>';
1605 
1606  print '<div class="clearboth"></div><br>';
1607 
1608 
1609  // Lines
1610  print '<form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '#add' : '#line_'.GETPOST('lineid', 'int')).'" method="POST">';
1611  print '<input type="hidden" name="token" value="' . newToken().'">';
1612  print '<input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'">';
1613  print '<input type="hidden" name="mode" value="">';
1614  print '<input type="hidden" name="id" value="' . $object->id.'">';
1615  print '<input type="hidden" name="page_y" value="">';
1616 
1617  if (!empty($conf->use_javascript_ajax) && $object->statut == 0) {
1618  include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
1619  }
1620 
1621  print '<div class="div-table-responsive-no-min">';
1622  print '<table id="tablelines" class="noborder noshadow centpercent">';
1623  // Show object lines
1624  if (!empty($object->lines)) {
1625  $canchangeproduct = 1;
1626  $ret = $object->printObjectLines($action, $mysoc, $object->thirdparty, $lineid, 0); // No date selector for template invoice
1627  }
1628 
1629  // Form to add new line
1630  if ($object->statut == $object::STATUS_DRAFT && $user->rights->facture->creer && $action != 'valid' && $action != 'editline') {
1631  if ($action != 'editline') {
1632  // Add free products/services
1633 
1634  $parameters = array();
1635  $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1636  if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1637  if (empty($reshook))
1638  $object->formAddObjectLine(0, $mysoc, $object->thirdparty); // No date selector for template invoice
1639  }
1640  }
1641 
1642  print "</table>\n";
1643  print '</div>';
1644 
1645  print "</form>\n";
1646 
1647  print dol_get_fiche_end();
1648 
1649 
1650  /*
1651  * Action bar
1652  */
1653  print '<div class="tabsAction">';
1654 
1655  if (empty($object->suspended)) {
1656  if ($user->rights->facture->creer) {
1657  if (!empty($object->frequency) && $object->nb_gen_max > 0 && ($object->nb_gen_done >= $object->nb_gen_max)) {
1658  print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("MaxGenerationReached")).'">'.$langs->trans("CreateBill").'</a></div>';
1659  } else {
1660  if (empty($object->frequency) || $object->date_when <= $nowlasthour) {
1661  print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture/card.php?action=create&socid='.$object->thirdparty->id.'&fac_rec='.$object->id.'">'.$langs->trans("CreateBill").'</a></div>';
1662  } else {
1663  print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("DateIsNotEnough")).'">'.$langs->trans("CreateBill").'</a></div>';
1664  }
1665  }
1666  } else {
1667  print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans("CreateBill").'</a></div>';
1668  }
1669  }
1670 
1671  if ($user->rights->facture->creer) {
1672  if (empty($object->suspended)) {
1673  print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=disable&id='.$object->id.'&token='.newToken().'">'.$langs->trans("Disable").'</a></div>';
1674  } else {
1675  print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=enable&id='.$object->id.'&token='.newToken().'">'.$langs->trans("Enable").'</a></div>';
1676  }
1677  }
1678 
1679  //if ($object->statut == Facture::STATUS_DRAFT && $user->rights->facture->supprimer)
1680  if ($user->rights->facture->supprimer) {
1681  print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=ask_deleteinvoice&id='.$object->id.'&token='.newToken().'">'.$langs->trans('Delete').'</a></div>';
1682  }
1683 
1684  print '</div>';
1685 
1686 
1687 
1688  print '<div class="fichecenter"><div class="fichehalfleft">';
1689  print '<a name="builddoc"></a>'; // ancre
1690 
1691 
1692  // Show links to link elements
1693  $linktoelem = $form->showLinkToObjectBlock($object, null, array('invoice'));
1694 
1695  $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
1696 
1697 
1698  print '</div>';
1699  print '<div class="fichehalfright">';
1700 
1701  $MAXEVENT = 10;
1702 
1703  //$morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', dol_buildpath('/mymodule/myobject_agenda.php', 1).'?id='.$object->id);
1704 
1705  // List of actions on element
1706  include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
1707  $formactions = new FormActions($db);
1708  $somethingshown = $formactions->showactions($object, $object->element, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlcenter);
1709 
1710  print '</div>';
1711  print '</div>';
1712  }
1713 }
1714 
1715 // End of page
1716 llxFooter();
1717 $db->close();
Societe
Class to manage third parties objects (customers, suppliers, prospects...)
Definition: societe.class.php:48
dol_get_last_hour
dol_get_last_hour($date, $gm='tzserver')
Return GMT time for last hour of a given GMT date (it replaces hours, min and second part to 23:59:59...
Definition: date.lib.php:597
restrictedArea
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
Definition: security.lib.php:234
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
Project
Class to manage projects.
Definition: project.class.php:35
invoice_rec_prepare_head
invoice_rec_prepare_head($object)
Return array head with list of tabs to view object informations.
Definition: invoice.lib.php:198
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
img_info
img_info($titlealt='default')
Show info logo.
Definition: functions.lib.php:4502
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
FormActions
Class to manage building of HTML components.
Definition: html.formactions.class.php:30
Translate
Class to manage translations.
Definition: translate.class.php:30
FactureRec
Class to manage invoice templates.
Definition: facture-rec.class.php:40
img_warning
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
Definition: functions.lib.php:4521
ModelePDFFactures\liste_modeles
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
Definition: modules_facture.php:61
FormProjets
Class to manage building of HTML components.
Definition: html.formprojet.class.php:30
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
FactureLigneRec
Class to manage invoice lines of templates.
Definition: facture-rec.class.php:2076
FormOther
Classe permettant la generation de composants html autre Only common components are here.
Definition: html.formother.class.php:39
Facture
Class to manage invoices.
Definition: facture.class.php:60
dol_clone
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
Definition: functions.lib.php:1158
img_edit
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
Definition: functions.lib.php:4389
dol_banner_tab
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
Definition: functions.lib.php:2046
$help_url
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:116
price2num
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
Definition: functions.lib.php:5661
dol_print_date
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Definition: functions.lib.php:2514
dol_concatdesc
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
Definition: functions.lib.php:7248
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:3880
Facture\TYPE_REPLACEMENT
const TYPE_REPLACEMENT
Replacement invoice.
Definition: facture.class.php:387
$formactions
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action=='set') elseif($action=='specimen') elseif($action=='setmodel') elseif($action=='del') elseif($action=='setdoc') $formactions
View.
Definition: agenda_other.php:178
$formconfirm
$formconfirm
if ($action == 'delbookkeepingyear') {
Definition: listbyaccount.php:576
get_default_npr
get_default_npr(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Fonction qui renvoie si tva doit etre tva percue recuperable.
Definition: functions.lib.php:6405
get_localtax
get_localtax($vatrate, $local, $thirdparty_buyer="", $thirdparty_seller="", $vatnpr=0)
Return localtax rate for a particular vat, when selling a product with vat $vatrate,...
Definition: functions.lib.php:5837
CommonInvoice\STATUS_DRAFT
const STATUS_DRAFT
Draft status.
Definition: commoninvoice.class.php:70
getCommonSubstitutionArray
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null)
Return array of possible common substitutions.
Definition: functions.lib.php:7275
MultiCurrency\getIdAndTxFromCode
static getIdAndTxFromCode($dbs, $code, $date_document='')
Get id and rate of currency from code.
Definition: multicurrency.class.php:526
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
dol_htmlcleanlastbr
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
Definition: functions.lib.php:7036
get_default_tva
get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that return vat rate of a product line (according to seller, buyer and product vat rate) VAT...
Definition: functions.lib.php:6304
info_admin
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
Definition: functions.lib.php:4800
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:10878
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:105
Facture\TYPE_CREDIT_NOTE
const TYPE_CREDIT_NOTE
Credit note invoice.
Definition: facture.class.php:392
dol_time_plus_duree
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
Definition: date.lib.php:121
User
Class to manage Dolibarr users.
Definition: user.class.php:44
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:386
Facture\TYPE_STANDARD
const TYPE_STANDARD
Standard invoice.
Definition: facture.class.php:382
ExtraFields
Class to manage standard extra fields.
Definition: extrafields.class.php:39
Product
Class to manage products or services.
Definition: product.class.php:46
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
img_object
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
Definition: functions.lib.php:4211
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:2845
price
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.
Definition: functions.lib.php:5541
getCountry
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
Definition: company.lib.php:489
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
dol_mktime
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
Definition: functions.lib.php:2757
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59
DolEditor
Class to manage a WYSIWYG editor.
Definition: doleditor.class.php:30