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