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