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