dolibarr 24.0.0-beta
card.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2002-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2018 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2011-2020 Juanjo Menent <jmenent@2byte.es>
6 * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
7 * Copyright (C) 2014-2018 Ferran Marcet <fmarcet@2byte.es>
8 * Copyright (C) 2014-2026 Charlene Benke <charlene@patas-monkey.com>
9 * Copyright (C) 2015-2016 Abbes Bahfir <bafbes@gmail.com>
10 * Copyright (C) 2018-2022 Philippe Grand <philippe.grand@atoo-net.com>
11 * Copyright (C) 2020-2026 Frédéric France <frederic.france@free.fr>
12 * Copyright (C) 2023 Benjamin Grembi <benjamin@oarces.fr>
13 * Copyright (C) 2023-2024 William Mead <william.mead@manchenumerique.fr>
14 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
15 * Copyright (C) 2024-2026 Alexandre Spangaro <alexandre@inovea-conseil.com>
16 * Copyright (C) 2025 Pierre Ardoin <developpeur@lesmetiersdubatiment.fr>
17 *
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 3 of the License, or
21 * (at your option) any later version.
22 *
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
27 *
28 * You should have received a copy of the GNU General Public License
29 * along with this program. If not, see <https://www.gnu.org/licenses/>.
30 */
31
38// Load Dolibarr environment
39require '../main.inc.php';
48require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
49require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
50require_once DOL_DOCUMENT_ROOT.'/core/modules/fichinter/modules_fichinter.php';
51require_once DOL_DOCUMENT_ROOT.'/core/lib/fichinter.lib.php';
52require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
53if (isModEnabled('project')) {
54 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
55 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
56}
57if (isModEnabled('contract')) {
58 require_once DOL_DOCUMENT_ROOT."/core/class/html.formcontract.class.php";
59 require_once DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php";
60}
61if (getDolGlobalString('FICHEINTER_ADDON') && is_readable(DOL_DOCUMENT_ROOT."/core/modules/fichinter/mod_" . getDolGlobalString('FICHEINTER_ADDON').".php")) {
62 require_once DOL_DOCUMENT_ROOT."/core/modules/fichinter/mod_" . getDolGlobalString('FICHEINTER_ADDON').'.php';
63}
64if (isModEnabled('category')) {
65 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
66}
67require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
68
69// Load translation files required by the page
70$langs->loadLangs(array('bills', 'companies', 'interventions', 'stocks'));
71
72$id = GETPOSTINT('id');
73$ref = GETPOST('ref', 'alpha');
74$ref_client = GETPOST('ref_client', 'alpha');
75$socid = GETPOSTINT('socid');
76$contratid = GETPOSTINT('contratid');
77$action = GETPOST('action', 'alpha');
78$cancel = GETPOST('cancel', 'alpha');
79$confirm = GETPOST('confirm', 'alpha');
80$backtopage = GETPOST('backtopage', 'alpha');
81
82$mesg = GETPOST('msg', 'alpha');
83$origin = GETPOST('origin', 'alpha');
84$originid = (GETPOSTINT('originid') ? GETPOSTINT('originid') : GETPOSTINT('origin_id')); // For backward compatibility
85$note_public = GETPOST('note_public', 'restricthtml');
86$note_private = GETPOST('note_private', 'restricthtml');
87$lineid = GETPOSTINT('line_id');
88
89$error = 0;
90
91// PDF
92$hidedetails = (GETPOSTINT('hidedetails') ? GETPOSTINT('hidedetails') : (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS') ? 1 : 0));
93$hidedesc = (GETPOSTINT('hidedesc') ? GETPOSTINT('hidedesc') : (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_DESC') ? 1 : 0));
94$hideref = (GETPOSTINT('hideref') ? GETPOSTINT('hideref') : (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_REF') ? 1 : 0));
95
96// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
97$hookmanager->initHooks(array('fichintercard', 'interventioncard', 'globalcard'));
98
99$object = new Fichinter($db);
100
101$objectsrc = null;
102
103$extrafields->fetch_name_optionals_label($object->table_element);
104
105// Load object
106if ($id > 0 || !empty($ref)) {
107 $ret = $object->fetch($id, $ref);
108 if ($ret > 0) {
109 $ret = $object->fetch_thirdparty();
110 }
111 if ($ret < 0) {
112 dol_print_error(null, $object->error);
113 }
114}
115
116// Security check
117if ($user->isExternalUser()) {
118 $socid = $user->isExternalUser();
119}
120$result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
121
122$permissionnote = $user->hasRight('ficheinter', 'creer'); // Used by the include of actions_setnotes.inc.php
123$permissiondellink = $user->hasRight('ficheinter', 'creer'); // Used by the include of actions_dellink.inc.php
124$permissiontodelete = (($object->status == Fichinter::STATUS_DRAFT && $user->hasRight('ficheinter', 'creer')) || $user->hasRight('ficheinter', 'supprimer'));
125$permissiontoadd = $user->hasRight('ficheinter', 'creer');
126$permissiontoeditextra = $permissiontoadd;
127if (GETPOST('attribute', 'aZ09') && isset($extrafields->attributes[$object->table_element]['perms'][GETPOST('attribute', 'aZ09')])) {
128 // For action 'update_extras', is there a specific permission set for the attribute to update
129 $permissiontoeditextra = dol_eval((string) $extrafields->attributes[$object->table_element]['perms'][GETPOST('attribute', 'aZ09')]);
130}
131
132
133$classname = '';
134
135/*
136 * Actions
137 */
138
139$parameters = array('socid' => $socid);
140$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
141if ($reshook < 0) {
142 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
143}
144
145if (empty($reshook)) {
146 $backurlforlist = DOL_URL_ROOT.'/fichinter/list.php';
147
148 if (empty($backtopage) || ($cancel && empty($id))) {
149 if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
150 if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
151 $backtopage = $backurlforlist;
152 } else {
153 $backtopage = DOL_URL_ROOT.'/fichinter/card.php?id='.((!empty($id) && $id > 0) ? $id : '__ID__');
154 }
155 }
156 }
157
158 if ($cancel) {
159 if (!empty($backtopageforcancel)) {
160 header("Location: ".$backtopageforcancel);
161 exit;
162 } elseif (!empty($backtopage)) {
163 header("Location: ".$backtopage);
164 exit;
165 }
166 $action = '';
167 }
168
169 include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be 'include', not 'include_once'
170
171 include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be 'include', not 'include_once'
172
173 // Action clone object
174 if ($action == 'confirm_clone' && $confirm == 'yes' && $permissiontoadd) {
175 if (false && !GETPOST('clone_content') && !GETPOST('clone_receivers')) {
176 setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors');
177 } else {
178 if ($object->id > 0) {
179 // Because createFromClone modifies the object, we must clone it so that we can restore it later
180 $orig = clone $object;
181 $clone_notes = false;
182 if (GETPOSTISSET('clone_notes') && GETPOST('clone_notes') === 'on') {
183 $clone_notes = true;
184 }
185 $clone_contacts = false;
186 if (GETPOSTISSET('clone_contacts') && GETPOST('clone_contacts') === 'on') {
187 $clone_contacts = true;
188 }
189
190 $result = $object->createFromClone($user, $socid, $clone_contacts, $clone_notes);
191 if ($result > 0) {
192 header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result);
193 exit;
194 } else {
195 setEventMessages($object->error, $object->errors, 'errors');
196 $object = $orig;
197 $action = '';
198 }
199 }
200 }
201 }
202
203 if ($action == 'confirm_validate' && $confirm == 'yes' && $permissiontoadd) {
204 $result = $object->setValid($user);
205
206 if ($result >= 0) {
207 if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) {
208 // Define output language
209 $outputlangs = $langs;
210 $newlang = '';
211 if (getDolGlobalInt('MAIN_MULTILANGS') /* && empty($newlang) */ && GETPOST('lang_id', 'aZ09')) {
212 $newlang = GETPOST('lang_id', 'aZ09');
213 }
214 if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) {
215 $newlang = $object->thirdparty->default_lang;
216 }
217 if (!empty($newlang)) {
218 $outputlangs = new Translate("", $conf);
219 $outputlangs->setDefaultLang($newlang);
220 }
221 $result = fichinter_create($db, $object, (!GETPOST('model', 'alpha')) ? $object->model_pdf : GETPOST('model', 'alpha'), $outputlangs);
222 }
223
224 header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
225 exit;
226 } else {
227 $mesg = $object->error;
228 }
229 } elseif ($action == 'confirm_sign' && $confirm == 'yes' && $permissiontoadd) {
230 $result = $object->setSignedStatus($user, GETPOSTINT('signed_status'), 0, 'FICHINTER_MODIFY');
231 if ($result >= 0) {
232 if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) {
233 // Define output language
234 $outputlangs = $langs;
235 $newlang = '';
236 if (getDolGlobalInt('MAIN_MULTILANGS') /* && empty($newlang) */ && GETPOST('lang_id', 'aZ09')) {
237 $newlang = GETPOST('lang_id', 'aZ09');
238 }
239 if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) {
240 $newlang = $object->thirdparty->default_lang;
241 }
242 if (!empty($newlang)) {
243 $outputlangs = new Translate("", $conf);
244 $outputlangs->setDefaultLang($newlang);
245 }
246 $result = fichinter_create($db, $object, (!GETPOST('model', 'alpha')) ? $object->model_pdf : GETPOST('model', 'alpha'), $outputlangs);
247 }
248
249 header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id);
250 exit;
251 } else {
252 $mesg = $object->error;
253 }
254 } elseif ($action == 'confirm_unsign' && $confirm == 'yes' && $permissiontoadd) {
255 $result = $object->setSignedStatus($user, Fichinter::$SIGNED_STATUSES['STATUS_NO_SIGNATURE'], 0, 'FICHINTER_MODIFY');
256 if ($result >= 0) {
257 if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) {
258 // Define output language
259 $outputlangs = $langs;
260 $newlang = '';
261 if (getDolGlobalInt('MAIN_MULTILANGS') /* && empty($newlang) */ && GETPOST('lang_id', 'aZ09')) {
262 $newlang = GETPOST('lang_id', 'aZ09');
263 }
264 if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) {
265 $newlang = $object->thirdparty->default_lang;
266 }
267 if (!empty($newlang)) {
268 $outputlangs = new Translate("", $conf);
269 $outputlangs->setDefaultLang($newlang);
270 }
271 $result = fichinter_create($db, $object, (!GETPOST('model', 'alpha')) ? $object->model_pdf : GETPOST('model', 'alpha'), $outputlangs);
272 }
273
274 header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id);
275 exit;
276 } else {
277 $mesg = $object->error;
278 }
279 } elseif ($action == 'confirm_modify' && $confirm == 'yes' && $permissiontoadd) {
280 $result = $object->setDraft($user);
281 if ($result >= 0) {
282 if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) {
283 // Define output language
284 $outputlangs = $langs;
285 $newlang = '';
286 if (getDolGlobalInt('MAIN_MULTILANGS') /* && empty($newlang) */ && GETPOST('lang_id', 'aZ09')) {
287 $newlang = GETPOST('lang_id', 'aZ09');
288 }
289 if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) {
290 $newlang = $object->thirdparty->default_lang;
291 }
292 if (!empty($newlang)) {
293 $outputlangs = new Translate("", $conf);
294 $outputlangs->setDefaultLang($newlang);
295 }
296 $result = fichinter_create($db, $object, (!GETPOST('model', 'alpha')) ? $object->model_pdf : GETPOST('model', 'alpha'), $outputlangs);
297 }
298
299 header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id);
300 exit;
301 } else {
302 $mesg = $object->error;
303 }
304 } elseif ($action == 'confirm_done' && $confirm == 'yes' && $permissiontoadd) {
305 $result = $object->setClose($user);
306
307 if ($result >= 0) {
308 if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) {
309 // Define output language
310 $outputlangs = $langs;
311 $newlang = '';
312 if (getDolGlobalInt('MAIN_MULTILANGS') /* && empty($newlang) */ && GETPOST('lang_id', 'aZ09')) {
313 $newlang = GETPOST('lang_id', 'aZ09');
314 }
315 if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) {
316 $newlang = $object->thirdparty->default_lang;
317 }
318 if (!empty($newlang)) {
319 $outputlangs = new Translate("", $conf);
320 $outputlangs->setDefaultLang($newlang);
321 }
322 $result = fichinter_create($db, $object, (!GETPOST('model', 'alpha')) ? $object->model_pdf : GETPOST('model', 'alpha'), $outputlangs);
323 }
324
325 header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
326 exit;
327 } else {
328 $mesg = $object->error;
329 }
330 } elseif ($action == 'add' && $permissiontoadd) {
331 $selectedLines = GETPOST('toselect', 'array:int');
332 $object->socid = $socid;
333 $object->duration = GETPOSTINT('duration');
334 $object->fk_project = GETPOSTINT('projectid');
335 $object->fk_contrat = GETPOSTINT('contratid');
336 $object->user_author_id = $user->id;
337 $object->description = GETPOST('description', 'restricthtml');
338 $object->ref = $ref;
339 $object->ref_client = $ref_client;
340 $object->model_pdf = GETPOST('model', 'alpha');
341 $object->note_private = GETPOST('note_private', 'restricthtml');
342 $object->note_public = GETPOST('note_public', 'restricthtml');
343
344 if ($object->socid > 0) {
345 // If creation from another object of another module (Example: origin=propal, originid=1)
346 if (!empty($origin) && !empty($originid)) {
347 // Parse element/subelement (ex: project_task)
348 $regs = array();
349 $element = $subelement = GETPOST('origin', 'alphanohtml');
350 if (preg_match('/^([^_]+)_([^_]+)/i', GETPOST('origin', 'alphanohtml'), $regs)) {
351 $element = $regs[1];
352 $subelement = $regs[2];
353 }
354
355 // For compatibility
356 if ($element == 'order') {
357 $element = $subelement = 'commande';
358 }
359 if ($element == 'propal') {
360 $element = 'comm/propal';
361 $subelement = 'propal';
362 }
363 if ($element == 'contract') {
364 $element = $subelement = 'contrat';
365 }
366
367 $object->origin = $origin;
368 $object->origin_id = $originid;
369
370 // Possibility to add external linked objects with hooks
371 $object->linked_objects[$object->origin] = $object->origin_id;
372 if (GETPOSTISARRAY('other_linked_objects')) {
373 $object->linked_objects = array_merge($object->linked_objects, GETPOST('other_linked_objects', 'array:int'));
374 }
375
376 // Extrafields
377
378 // Fill array 'array_options' with data from add form
379 $ret = $extrafields->setOptionalsFromPost(null, $object);
380 if ($ret < 0) {
381 $error++;
382 $action = 'create';
383 }
384 //$array_options = $extrafields->getOptionalsFromPost($object->table_element);
385
386 //$object->array_options = $array_options;
387
388 $id = $object->create($user);
389
390 if ($id > 0) {
391 dol_include_once('/'.$element.'/class/'.$subelement.'.class.php');
392
393 $classname = ucfirst($subelement);
394 $srcobject = new $classname($db);
395 '@phan-var-force Commande|Propal|Contrat $srcobject'; // Can be other class, but CommonObject is too generic
398 dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines");
399 $result = $srcobject->fetch($object->origin_id);
400 if ($result > 0) {
401 $srcobject->fetch_thirdparty();
402 $lines = $srcobject->lines;
403 if (empty($lines) && method_exists($srcobject, 'fetch_lines')) {
404 $srcobject->fetch_lines();
405 $lines = $srcobject->lines;
406 }
407
408 if (is_array($lines)) {
409 $num = count($lines);
410
411 for ($i = 0; $i < $num; $i++) {
412 if (!in_array($lines[$i]->id, $selectedLines)) {
413 continue; // Skip unselected lines
414 }
415
416 $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : Product::TYPE_PRODUCT);
417
418 if ($product_type == Product::TYPE_SERVICE || getDolGlobalString('FICHINTER_PRINT_PRODUCTS')) { //only services except if config includes products
419 $duration = 3600; // Default to one hour
420 $desc = '';
421 // Predefined products & services
422 if ($lines[$i]->fk_product > 0) {
423 $prod = new Product($db);
424 $prod->id = $lines[$i]->fk_product;
425
426 // Define output language
427 if (getDolGlobalInt('MAIN_MULTILANGS') && getDolGlobalString('PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE')) {
428 $prod->getMultiLangs();
429 // We show if duration is present on service (so we get it)
430 $prod->fetch($lines[$i]->fk_product);
431 $outputlangs = $langs;
432 $newlang = '';
433 if (/* empty($newlang) && */ GETPOST('lang_id', 'aZ09')) {
434 $newlang = GETPOST('lang_id', 'aZ09');
435 }
436 if (empty($newlang)) {
437 $newlang = $srcobject->thirdparty->default_lang;
438 }
439 if (!empty($newlang)) {
440 $outputlangs = new Translate("", $conf);
441 $outputlangs->setDefaultLang($newlang);
442 }
443 $label = (!empty($prod->multilangs[$outputlangs->defaultlang]["libelle"])) ? $prod->multilangs[$outputlangs->defaultlang]["libelle"] : $lines[$i]->product_label;
444 } else {
445 $prod->fetch($lines[$i]->fk_product);
446 $label = $lines[$i]->product_label;
447 }
448
449 if ($prod->duration_value && getDolGlobalString('FICHINTER_USE_SERVICE_DURATION')) {
450 switch ($prod->duration_unit) {
451 default:
452 case 'h':
453 $mult = 3600;
454 break;
455 case 'd':
456 $mult = 3600 * 24;
457 break;
458 case 'w':
459 $mult = 3600 * 24 * 7;
460 break;
461 case 'm':
462 $mult = (int) (3600 * 24 * (365 / 12)); // Average month duration
463 break;
464 case 'y':
465 $mult = 3600 * 24 * 365;
466 break;
467 }
468 $duration = (int) $prod->duration_value * $mult * $lines[$i]->qty;
469 }
470
471 $desc = $lines[$i]->product_ref;
472 $desc .= ' - ';
473 $desc .= $label;
474 $desc .= '<br>';
475 }
476 // Common part (predefined or free line)
477 $desc .= dol_htmlentitiesbr($lines[$i]->desc);
478 $desc .= '<br>';
479 $desc .= ' ('.$langs->trans('Quantity').': '.$lines[$i]->qty.')';
480
481 $timearray = dol_getdate(dol_now());
482 $date_intervention = dol_mktime(0, 0, 0, $timearray['mon'], $timearray['mday'], $timearray['year']);
483
484 if ($product_type == Product::TYPE_PRODUCT) {
485 $duration = 0;
486 }
487
488 $predef = '';
489
490 // Extrafields
491 $extrafields->fetch_name_optionals_label($object->table_element_line);
492 $array_options = $extrafields->getOptionalsFromPost($object->table_element_line, $predef);
493
494 $result = $object->addline(
495 $user,
496 $id,
497 $desc,
498 $date_intervention,
499 $duration,
500 $array_options
501 );
502
503 if ($result < 0) {
504 $error++;
505 break;
506 }
507 }
508 }
509 }
510 } else {
511 $langs->load("errors");
512 setEventMessages($srcobject->error, $srcobject->errors, 'errors');
513 $action = 'create';
514 $error++;
515 }
516 } else {
517 $langs->load("errors");
518 setEventMessages($object->error, $object->errors, 'errors');
519 $action = 'create';
520 $error++;
521 }
522 } else {
523 // Fill array 'array_options' with data from add form
524 $ret = $extrafields->setOptionalsFromPost(null, $object);
525 if ($ret < 0) {
526 $error++;
527 $action = 'create';
528 }
529
530 if (!$error) {
531 // Extrafields
532 $array_options = $extrafields->getOptionalsFromPost($object->table_element);
533
534 $object->array_options = $array_options;
535
536 $result = $object->create($user);
537
538 if ($result > 0) {
539 $id = $result; // Force refresh on a newly created record
540
541 // Category association
542 $categories = GETPOST('categories', 'array');
543 $object->setCategories($categories);
544 } else {
545 $langs->load("errors");
546 setEventMessages($object->error, $object->errors, 'errors');
547 $action = 'create';
548 $error++;
549 }
550 }
551 }
552 } else {
553 $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ThirdParty"));
554 $action = 'create';
555 $error++;
556 }
557 } elseif ($action == 'update' && $permissiontoadd) {
558 $object->socid = $socid;
559 $object->fk_project = GETPOSTINT('projectid');
560 $object->fk_contrat = GETPOSTINT('contratid');
561 $object->user_author_id = $user->id;
562 $object->description = GETPOST('description', 'restricthtml');
563 $object->ref = $ref;
564 $object->ref_client = $ref_client;
565
566 $result = $object->update($user);
567 if ($result < 0) {
568 setEventMessages($object->error, $object->errors, 'errors');
569 }
570 } elseif ($action == 'classin' && $permissiontoadd) {
571 // Set into a project
572 $result = $object->setProject(GETPOSTINT('projectid'));
573 if ($result < 0) {
574 dol_print_error($db, $object->error);
575 }
576 } elseif ($action == 'setcontract' && $permissiontoadd) {
577 // Set into a contract
578 $result = $object->set_contrat($user, GETPOSTINT('contratid'));
579 if ($result < 0) {
580 dol_print_error($db, $object->error);
581 }
582 } elseif ($action == 'settags' && isModEnabled('category') && $permissiontoadd) {
583 // Set tags
584 $result = $object->setCategories(GETPOST('categories', 'array'));
585 if ($result < 0) {
586 setEventMessages($object->error, $object->errors, 'errors');
587 }
588 } elseif ($action == 'setref_client' && $permissiontoadd) {
589 // Set customer reference
590 $result = $object->setRefClient($user, GETPOST('ref_client', 'alpha'));
591 if ($result < 0) {
592 setEventMessages($object->error, $object->errors, 'errors');
593 }
594 } elseif ($action == 'confirm_delete' && $confirm == 'yes' && $permissiontodelete) {
595 $result = $object->delete($user);
596 if ($result < 0) {
597 setEventMessages($object->error, $object->errors, 'errors');
598 }
599
600 header('Location: '.DOL_URL_ROOT.'/fichinter/list.php?leftmenu=ficheinter&restore_lastsearch_values=1');
601 exit;
602 } elseif ($action == 'setdescription' && $permissiontoadd) {
603 $result = $object->set_description($user, GETPOST('description'));
604 if ($result < 0) {
605 dol_print_error($db, $object->error);
606 }
607 } elseif ($action == "addline" && $permissiontoadd) {
608 // Add line
609 if (!GETPOST('np_desc', 'restricthtml') && !getDolGlobalString('FICHINTER_EMPTY_LINE_DESC')) {
610 $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description"));
611 $error++;
612 }
613 if (!getDolGlobalString('FICHINTER_WITHOUT_DURATION') && !GETPOSTINT('durationhour') && !GETPOSTINT('durationmin')) {
614 $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Duration"));
615 $error++;
616 }
617 if (!getDolGlobalString('FICHINTER_WITHOUT_DURATION') && GETPOSTINT('durationhour') >= 24 && GETPOSTINT('durationmin') > 0) {
618 $mesg = $langs->trans("ErrorValueTooHigh");
619 $error++;
620 }
621 if (!$error) {
622 $db->begin();
623
624 $desc = GETPOST('np_desc', 'restricthtml');
625 $date_intervention = dol_mktime(GETPOSTINT('dihour'), GETPOSTINT('dimin'), 0, GETPOSTINT('dimonth'), GETPOSTINT('diday'), GETPOSTINT('diyear'));
626 $duration = !getDolGlobalString('FICHINTER_WITHOUT_DURATION') ? convertTime2Seconds(GETPOSTINT('durationhour'), GETPOSTINT('durationmin')) : 0;
627
628 // Extrafields
629 $extrafields->fetch_name_optionals_label($object->table_element_line);
630 $array_options = $extrafields->getOptionalsFromPost($object->table_element_line);
631
632 $result = $object->addline(
633 $user,
634 $id,
635 $desc,
636 $date_intervention,
637 $duration,
638 $array_options
639 );
640
641 // Define output language
642 $outputlangs = $langs;
643 $newlang = '';
644 if (getDolGlobalInt('MAIN_MULTILANGS') /* && empty($newlang) */ && GETPOST('lang_id', 'aZ09')) {
645 $newlang = GETPOST('lang_id', 'aZ09');
646 }
647 if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) {
648 $newlang = $object->thirdparty->default_lang;
649 }
650 if (!empty($newlang)) {
651 $outputlangs = new Translate("", $conf);
652 $outputlangs->setDefaultLang($newlang);
653 }
654
655 if ($result >= 0) {
656 $db->commit();
657
658 if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) {
659 fichinter_create($db, $object, $object->model_pdf, $outputlangs);
660 }
661 header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
662 exit;
663 } else {
664 $mesg = $object->error;
665 $db->rollback();
666 }
667 }
668 } elseif ($action == 'confirm_addtitleline' && $permissiontoadd) {
669 // Handling adding a new title line for subtotals module
670
671 $langs->load('subtotals');
672
673 $desc = GETPOST('subtotallinedesc', 'alphanohtml');
674 $depth = GETPOSTINT('subtotallinelevel') ?? 1;
675
676 $subtotal_options = array();
677
678 foreach (Fichinter::$TITLE_OPTIONS as $option) {
679 $value = GETPOST($option, 'alphanohtml');
680 if ($value) {
681 $subtotal_options[$option] = $value == 'on' ? 1 : $value;
682 }
683 }
684
685 // Insert line
686 $result = $object->addSubtotalLine($langs, $desc, (int) $depth, $subtotal_options);
687
688 if ($result >= 0) {
689 if ($result == 0) {
690 setEventMessages($object->error, $object->errors, 'warnings');
691 }
692 $ret = $object->fetch($object->id); // Reload to get new records
693 $object->fetch_thirdparty();
694
695 if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) {
696 // Define output language
697 $outputlangs = $langs;
698 $newlang = GETPOST('lang_id', 'alpha');
699 if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) {
700 $newlang = $object->thirdparty->default_lang;
701 }
702 if (!empty($newlang)) {
703 $outputlangs = new Translate("", $conf);
704 $outputlangs->setDefaultLang($newlang);
705 }
706
707 $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
708 }
709 } else {
710 setEventMessages($object->error, $object->errors, 'errors');
711 }
712 header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
713 exit();
714 } elseif ($action == 'classifybilled' && $permissiontoadd) {
715 // Classify Billed
716 $result = $object->setStatut(Fichinter::STATUS_BILLED);
717 if ($result > 0) {
718 header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
719 exit;
720 } else {
721 setEventMessages($object->error, $object->errors, 'errors');
722 }
723 } elseif ($action == 'classifyunbilled' && $permissiontoadd) {
724 // Classify unbilled
725 $result = $object->setStatut(Fichinter::STATUS_VALIDATED);
726 if ($result > 0) {
727 header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
728 exit;
729 } else {
730 $mesg = $object->error;
731 }
732 } elseif ($action == 'confirm_reopen' && $permissiontoadd) {
733 // Reopen
734 $result = $object->setStatut(Fichinter::STATUS_VALIDATED);
735 if ($result > 0) {
736 header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
737 exit;
738 } else {
739 $mesg = $object->error;
740 }
741 } elseif ($action == 'updateline' && $permissiontoadd && GETPOST('save', 'alpha')) {
742 // Update an intervention line
743 $objectline = new FichinterLigne($db);
744 if ($objectline->fetch($lineid) <= 0) {
746 exit;
747 }
748
749 if ($object->fetch($objectline->fk_fichinter) <= 0) {
751 exit;
752 }
753 $object->fetch_thirdparty();
754
755 $desc = GETPOST('np_desc', 'restricthtml');
756 $date_inter = dol_mktime(GETPOSTINT('dihour'), GETPOSTINT('dimin'), 0, GETPOSTINT('dimonth'), GETPOSTINT('diday'), GETPOSTINT('diyear'));
757 $duration = convertTime2Seconds(GETPOSTINT('durationhour'), GETPOSTINT('durationmin'));
758
759 $objectline->date = $date_inter;
760 $objectline->desc = $desc;
761 $objectline->duration = $duration;
762
763 // Extrafields
764 $extrafields->fetch_name_optionals_label($object->table_element_line);
765 $array_options = $extrafields->getOptionalsFromPost($object->table_element_line);
766 if (is_array($array_options)) {
767 $objectline->array_options = array_merge($objectline->array_options, $array_options);
768 }
769
770 $result = $objectline->update($user);
771 if ($result < 0) {
772 // Surface validation errors (e.g. mandatory extrafield left empty) as an
773 // event message on the same page instead of breaking with a full Dolibarr
774 // error screen that loses the user's edit context.
775 setEventMessages($objectline->error, $objectline->errors, 'errors');
776 }
777
778 // Define output language
779 $outputlangs = $langs;
780 $newlang = '';
781 if (getDolGlobalInt('MAIN_MULTILANGS') /* && empty($newlang) */ && GETPOST('lang_id', 'aZ09')) {
782 $newlang = GETPOST('lang_id', 'aZ09');
783 }
784 if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) {
785 $newlang = $object->thirdparty->default_lang;
786 }
787 if (!empty($newlang)) {
788 $outputlangs = new Translate("", $conf);
789 $outputlangs->setDefaultLang($newlang);
790 }
791 if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) {
792 fichinter_create($db, $object, $object->model_pdf, $outputlangs);
793 }
794
795 header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
796 exit;
797 } elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $permissiontoadd) {
798 // Delete an intervention line WITH confirmation
799 $objectline = new FichinterLigne($db);
800 if ($objectline->fetch($lineid) <= 0) {
802 exit;
803 }
804 $result = $objectline->deleteLine($user);
805
806 if ($object->fetch($objectline->fk_fichinter) <= 0) {
808 exit;
809 }
810
811 // Define output language
812 $outputlangs = $langs;
813 $newlang = '';
814 if (getDolGlobalInt('MAIN_MULTILANGS') /* && empty($newlang) */ && GETPOST('lang_id', 'aZ09')) {
815 $newlang = GETPOST('lang_id', 'aZ09');
816 }
817 if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) {
818 $newlang = $object->thirdparty->default_lang;
819 }
820 if (!empty($newlang)) {
821 $outputlangs = new Translate("", $conf);
822 $outputlangs->setDefaultLang($newlang);
823 }
824 if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) {
825 fichinter_create($db, $object, $object->model_pdf, $outputlangs);
826 }
827 } elseif ($action == 'up' && $permissiontoadd) {
828 // Set position of lines
829 $object->line_up($lineid);
830
831 // Define output language
832 $outputlangs = $langs;
833 $newlang = '';
834 if (getDolGlobalInt('MAIN_MULTILANGS') /* && empty($newlang) */ && GETPOST('lang_id', 'aZ09')) {
835 $newlang = GETPOST('lang_id', 'aZ09');
836 }
837 if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) {
838 $newlang = $object->thirdparty->default_lang;
839 }
840 if (!empty($newlang)) {
841 $outputlangs = new Translate("", $conf);
842 $outputlangs->setDefaultLang($newlang);
843 }
844 if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) {
845 fichinter_create($db, $object, $object->model_pdf, $outputlangs);
846 }
847
848 header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.$lineid);
849 exit;
850 } elseif ($action == 'down' && $permissiontoadd) {
851 $object->line_down($lineid);
852
853 // Define output language
854 $outputlangs = $langs;
855 $newlang = '';
856 if (getDolGlobalInt('MAIN_MULTILANGS') /* && empty($newlang) */ && GETPOST('lang_id', 'aZ09')) {
857 $newlang = GETPOST('lang_id', 'aZ09');
858 }
859 if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) {
860 $newlang = $object->thirdparty->default_lang;
861 }
862 if (!empty($newlang)) {
863 $outputlangs = new Translate("", $conf);
864 $outputlangs->setDefaultLang($newlang);
865 }
866 if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) {
867 fichinter_create($db, $object, $object->model_pdf, $outputlangs);
868 }
869
870 header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.$lineid);
871 exit;
872 }
873
874 // Actions when printing a doc from card
875 include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
876
877 // Actions to send emails
878 $triggersendname = 'FICHINTER_SENTBYMAIL';
879 $autocopy = 'MAIN_MAIL_AUTOCOPY_FICHINTER_TO';
880 $trackid = 'int'.$object->id;
881 include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
882
883 // Actions to build doc
884 $upload_dir = $conf->ficheinter->dir_output;
885 include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
886
887 if ($action == 'update_extras' && $permissiontoeditextra) {
888 $object->oldcopy = dol_clone($object, 2); // @phan-suppress-current-line PhanTypeMismatchProperty
889
890 $attribute_name = GETPOST('attribute', 'aZ09');
891
892 // Fill array 'array_options' with data from update form
893 $ret = $extrafields->setOptionalsFromPost(null, $object, $attribute_name);
894 if ($ret < 0) {
895 $error++;
896 }
897
898 if (!$error) {
899 // Actions on extra fields
900 $result = $object->updateExtraField($attribute_name, 'INTERVENTION_MODIFY');
901 if ($result < 0) {
902 setEventMessages($object->error, $object->errors, 'errors');
903 $error++;
904 }
905 }
906
907 if ($error) {
908 $action = 'edit_extras';
909 }
910 }
911
912 if (getDolGlobalString('MAIN_DISABLE_CONTACTS_TAB')) {
913 if ($action == 'addcontact' && $permissiontoadd) {
914 if ($result > 0 && $id > 0) {
915 $contactid = (GETPOSTINT('userid') ? GETPOSTINT('userid') : GETPOSTINT('contactid'));
916 $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
917 $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
918 }
919
920 if ($result >= 0) {
921 header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
922 exit;
923 } else {
924 if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
925 $langs->load("errors");
926 $mesg = $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType");
927 } else {
928 $mesg = $object->error;
929 }
930 }
931 } elseif ($action == 'swapstatut' && $permissiontoadd) {
932 // Toggle the status of a contact
933 $result = $object->swapContactStatus(GETPOSTINT('ligne'));
934 } elseif ($action == 'deletecontact' && $permissiontoadd) {
935 // Delete a contact
936 $result = $object->delete_contact(GETPOSTINT('lineid'));
937
938 if ($result >= 0) {
939 header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
940 exit;
941 } else {
943 }
944 }
945 }
946}
947
948
949/*
950 * View
951 */
952
953$form = new Form($db);
954$formfile = new FormFile($db);
955$formcontract = null;
956$formproject = null;
957if (isModEnabled('contract')) {
958 $formcontract = new FormContract($db);
959}
960if (isModEnabled('project')) {
961 $formproject = new FormProjets($db);
962}
963
964$title = $object->ref . " - " . $langs->trans('Card');
965if ($action == 'create') {
966 $title = $langs->trans("NewIntervention");
967}
968$help_url = 'EN:Module_Interventions|FR:Module_Fiches_d\'interventions';
969
970llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-fichinter page-card');
971
972// Create new intervention
973if ($action == 'create') {
974 $soc = new Societe($db);
975 if ($socid > 0) {
976 $soc->fetch($socid);
977 }
978
979 print load_fiche_titre($langs->trans("NewIntervention"), '', 'intervention');
980
981 if ($error > 0) {
983 } else {
984 dol_htmloutput_mesg($mesg);
985 }
986
987 if (GETPOST('origin', 'alphanohtml') && GETPOSTINT('originid')) {
988 // Parse element/subelement (ex: project_task)
989 $regs = array();
990 $element = $subelement = GETPOST('origin', 'alphanohtml');
991 if (preg_match('/^([^_]+)_([^_]+)/i', GETPOST('origin', 'alphanohtml'), $regs)) {
992 $element = $regs[1];
993 $subelement = $regs[2];
994 }
995
996 if ($element == 'project') {
997 $projectid = GETPOSTINT('originid');
998 } else {
999 // For compatibility
1000 if ($element == 'order' || $element == 'commande') {
1001 $element = $subelement = 'commande';
1002 }
1003 if ($element == 'propal') {
1004 $element = 'comm/propal';
1005 $subelement = 'propal';
1006 }
1007 if ($element == 'contract') {
1008 $element = $subelement = 'contrat';
1009 }
1010
1011 dol_include_once('/'.$element.'/class/'.$subelement.'.class.php');
1012
1013 $classname = ucfirst($subelement);
1014 $objectsrc = new $classname($db);
1015 '@phan-var-force Commande|Propal|Contrat $objectsrc';
1016 $objectsrc->fetch(GETPOSTINT('originid'));
1017 if (empty($objectsrc->lines) && method_exists($objectsrc, 'fetch_lines')) {
1018 $objectsrc->fetch_lines();
1019 $lines = $objectsrc->lines;
1020 }
1021 $objectsrc->fetch_thirdparty();
1022
1023 $projectid = (int) $objectsrc->fk_project;
1024
1025 $soc = $objectsrc->thirdparty;
1026
1027 $note_private = (!empty($objectsrc->note) ? $objectsrc->note : (!empty($objectsrc->note_private) ? $objectsrc->note_private : GETPOST('note_private', 'restricthtml')));
1028 $note_public = (!empty($objectsrc->note_public) ? $objectsrc->note_public : GETPOST('note_public', 'restricthtml'));
1029
1030 // Replicate extrafields
1031 $objectsrc->fetch_optionals();
1032 $object->array_options = $objectsrc->array_options;
1033
1034 // Object source contacts list
1035 $srccontactslist = $objectsrc->liste_contact(-1, 'external', 1);
1036 }
1037 } else {
1038 $projectid = GETPOSTINT('projectid');
1039 $note_private = GETPOST("note_private", "alpha");
1040 $note_public = GETPOST("note_public", "alpha");
1041 }
1042
1043 if (!$conf->global->FICHEINTER_ADDON) {
1044 dol_print_error($db, $langs->trans("Error")." ".$langs->trans("Error_FICHEINTER_ADDON_NotDefined"));
1045 exit;
1046 }
1047
1048 $object->datec = dol_now();
1049
1050 $obj = getDolGlobalString('FICHEINTER_ADDON');
1051 $obj = "mod_".$obj;
1052
1053 //$modFicheinter = new $obj;
1054 //$numpr = $modFicheinter->getNextValue($soc, $object);
1055
1056 print '<form name="fichinter" action="'.$_SERVER['PHP_SELF'].'" method="POST">';
1057 print '<input type="hidden" name="token" value="'.newToken().'">';
1058 print '<input type="hidden" name="socid" value='.$soc->id.'>';
1059 print '<input type="hidden" name="action" value="add">';
1060 print '<input type="hidden" name="socid" value="'.$soc->id.'">'."\n";
1061 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
1062
1063 print dol_get_fiche_head([]);
1064
1065 print '<table class="border centpercent">';
1066
1067 // Ref
1068 print '<tr><td class="fieldrequired">'.$langs->trans('Ref').'</td><td>'.$langs->trans("Draft").'</td></tr>';
1069
1070 // Ref customer
1071 print '<tr class="field_ref_client"><td class="titlefieldcreate">'.$langs->trans('RefCustomer').'</td><td class="valuefieldcreate">';
1072 print '<input type="text" name="ref_client" value="'.GETPOST('ref_client').'"></td>';
1073 print '</tr>';
1074
1075 // Thirdparty
1076 print '<tr>';
1077 print '<td class="fieldrequired">'.$langs->trans('ThirdParty').'</td>';
1078 if ($socid > 0) {
1079 print '<td>';
1080 print $soc->getNomUrl(1);
1081 print '<input type="hidden" name="socid" value="'.$soc->id.'">';
1082 print '</td>';
1083 } else {
1084 print '<td>';
1085 print img_picto('', 'company', 'class="pictofixedwidth"');
1086 $filter = '(s.status:=:1)';
1087 print $form->select_company('', 'socid', $filter, 'SelectThirdParty', 1, 0, array(), 0, 'minwidth150 widthcentpercentminusxx maxwidth500');
1088 print ' <a href="'.dolBuildUrl(DOL_URL_ROOT . '/societe/card.php', ['action' => 'create', 'customer' => 3, 'backtopage' => dolBuildUrl($_SERVER["PHP_SELF"], ['action' => 'create'])]).'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans("AddThirdParty").'"></span></a>';
1089 print '</td>';
1090 }
1091 print '</tr>'."\n";
1092
1093 // Description (must be a textarea and not html must be allowed (used in list view)
1094 print '<tr><td class="tdtop">'.$langs->trans("Description").'</td>';
1095 print '<td>';
1096 print '<textarea name="description" class="quatrevingtpercent" rows="'.ROWS_3.'">'.GETPOST('description').'</textarea>';
1097 print '</td></tr>';
1098
1099 // Project
1100 if (isModEnabled('project')) {
1101 $formproject = new FormProjets($db);
1102
1103 $langs->load("project");
1104
1105 print '<tr><td>'.$langs->trans("Project").'</td><td>';
1106 print img_picto('', 'project', 'class="pictofixedwidth"');
1107 /* Fix: If a project must be linked to any companies (suppliers or not), project must be not be set as limited to customer but must be not linked to any particular thirdparty
1108 if ($societe->fournisseur==1)
1109 $numprojet=select_projects(-1, GETPOST("projectid", 'int'), 'projectid');
1110 else
1111 $numprojet=select_projects($societe->id, GETPOST("projectid", 'int'), 'projectid');
1112 */
1113 $numprojet = $formproject->select_projects($soc->id, $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, 'maxwidth500 widthcentpercentminusxx');
1114 if ($numprojet == 0) {
1115 print ' &nbsp; <a href="' . dolBuildUrl(DOL_URL_ROOT . '/projet/card.php', ['socid' => $soc->id, 'action' => 'create', 'status' => 1, 'backtopage' => dolBuildUrl($_SERVER["PHP_SELF"], ['action' => 'create', 'socid' => $soc->id])]) . '"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans("AddProject").'"></span></a>';
1116 }
1117 print '</td></tr>';
1118 }
1119
1120 // Category
1121 if (isModEnabled('category')) {
1122 // Categories
1123 print '<tr><td>'.$langs->trans("Categories").'</td><td colspan="3">';
1124 print $form->selectCategories(Categorie::TYPE_FICHINTER, 'categories', $object);
1125 print "</td></tr>";
1126 }
1127
1128 // Contract
1129 if (isModEnabled('contract') && is_object($formcontract)) {
1130 // This feature hang the application on large list of contracts, because the select component is not complete: it does not work like select of thirdparty or product to support large lists
1131 // So we add a hidden option to avoid to have it used and the application locked, until the select_contract is fixed.
1132 if (getDolGlobalString("CONTRACT_CAN_USE_THE_BUGGED_SELECT_COMPONENT")) {
1133 $langs->load("contracts");
1134 print '<tr><td>'.$langs->trans("Contract").'</td><td>';
1135 $numcontrat = $formcontract->select_contract($soc->id, GETPOSTINT('contratid'), 'contratid', 0, 1, 1);
1136 if ($numcontrat == 0) {
1137 print ' &nbsp; <a href="'.DOL_URL_ROOT.'/contrat/card.php?socid='.$soc->id.'&action=create"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans("AddContract").'"></span></a>';
1138 }
1139 print '</td></tr>';
1140 }
1141 }
1142
1143 // Model
1145 if (count($liste) > 0) {
1146 print '<tr>';
1147 print '<td>'.$langs->trans("DefaultModel").'</td>';
1148 print '<td>';
1149 print $form->selectarray('model', $liste, getDolGlobalString('FICHEINTER_ADDON_PDF'));
1150 print "</td></tr>";
1151 }
1152
1153 // Public note
1154 print '<tr>';
1155 print '<td class="tdtop">'.$langs->trans('NotePublic').'</td>';
1156 print '<td>';
1157 $doleditor = new DolEditor('note_public', (string) $note_public, '', 80, 'dolibarr_notes', 'In', false, false, !getDolGlobalString('FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3, '90%');
1158 print $doleditor->Create(1);
1159 //print '<textarea name="note_public" cols="80" rows="'.ROWS_3.'">'.$note_public.'</textarea>';
1160 print '</td></tr>';
1161
1162 // Private note
1163 if (empty($user->socid)) {
1164 print '<tr>';
1165 print '<td class="tdtop">'.$langs->trans('NotePrivate').'</td>';
1166 print '<td>';
1167 $doleditor = new DolEditor('note_private', (string) $note_private, '', 80, 'dolibarr_notes', 'In', false, false, !getDolGlobalString('FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3, '90%');
1168 print $doleditor->Create(1);
1169 //print '<textarea name="note_private" cols="80" rows="'.ROWS_3.'">'.$note_private.'</textarea>';
1170 print '</td></tr>';
1171 }
1172
1173 // Other attributes
1174 $parameters = array();
1175 $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1176 print $hookmanager->resPrint;
1177 if (empty($reshook)) {
1178 print $object->showOptionals($extrafields, 'create');
1179 }
1180
1181 // Show link to origin object
1182 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
1183 $newclassname = $classname;
1184 if ($newclassname == 'Propal') {
1185 $langs->load('propal');
1186 $newclassname = 'CommercialProposal';
1187 }
1188 print '<tr><td>'.$langs->trans($newclassname).'</td><td colspan="2">'.$objectsrc->getNomUrl(1).'</td></tr>';
1189
1190 // Amount
1191 /* Hide amount because we only copy services so amount may differ than source
1192 print '<tr><td>' . $langs->trans('AmountHT') . '</td><td>' . price($objectsrc->total_ht) . '</td></tr>';
1193 print '<tr><td>' . $langs->trans('AmountVAT') . '</td><td>' . price($objectsrc->total_tva) . "</td></tr>";
1194 if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) // Localtax1 RE
1195 {
1196 print '<tr><td>' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '</td><td>' . price($objectsrc->total_localtax1) . "</td></tr>";
1197 }
1198
1199 if ($mysoc->localtax2_assuj == "1" || $objectsrc->total_localtax2 != 0) // Localtax2 IRPF
1200 {
1201 print '<tr><td>' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '</td><td>' . price($objectsrc->total_localtax2) . "</td></tr>";
1202 }
1203
1204 print '<tr><td>' . $langs->trans('AmountTTC') . '</td><td>' . price($objectsrc->total_ttc) . "</td></tr>";
1205
1206 if (isModEnabled("multicurrency"))
1207 {
1208 print '<tr><td>' . $langs->trans('MulticurrencyAmountHT') . '</td><td>' . price($objectsrc->multicurrency_total_ht) . '</td></tr>';
1209 print '<tr><td>' . $langs->trans('MulticurrencyAmountVAT') . '</td><td>' . price($objectsrc->multicurrency_total_tva) . "</td></tr>";
1210 print '<tr><td>' . $langs->trans('MulticurrencyAmountTTC') . '</td><td>' . price($objectsrc->multicurrency_total_ttc) . "</td></tr>";
1211 }
1212 */
1213 }
1214
1215 print '</table>';
1216
1217 if (is_object($objectsrc)) {
1218 print '<input type="hidden" name="origin" value="'.$objectsrc->element.'">';
1219 print '<input type="hidden" name="originid" value="'.$objectsrc->id.'">';
1220 } elseif ($origin == 'project' && !empty($projectid)) {
1221 print '<input type="hidden" name="projectid" value="'.$projectid.'">';
1222 }
1223
1224 print dol_get_fiche_end();
1225
1226 print $form->buttonsSaveCancel("CreateDraftIntervention");
1227
1228 // Show origin lines
1229 if (!empty($origin) && !empty($originid) && is_object($objectsrc) && !getDolGlobalInt('FICHINTER_DISABLE_DETAILS')) {
1230 $title = $langs->trans('Services');
1231 print load_fiche_titre($title);
1232
1233 print '<div class="div-table-responsive-no-min">';
1234 print '<table class="noborder centpercent">';
1235
1236 $objectsrc->printOriginLinesList(!getDolGlobalString('FICHINTER_PRINT_PRODUCTS') ? 'services' : ''); // Show only service, except if option FICHINTER_PRINT_PRODUCTS is on
1237
1238 print '</table>';
1239 print '</div>';
1240 }
1241
1242 print '</form>';
1243} elseif ($id > 0 || !empty($ref)) {
1244 // View mode
1245
1246 $object->fetch($id, $ref);
1247 $object->fetch_thirdparty();
1248
1249 $soc = new Societe($db);
1250 $soc->fetch($object->socid);
1251
1252 if ($error > 0) {
1253 dol_htmloutput_errors($mesg);
1254 } else {
1255 dol_htmloutput_mesg($mesg);
1256 }
1257
1258 $head = fichinter_prepare_head($object);
1259
1260 print dol_get_fiche_head($head, 'card', $langs->trans("InterventionCard"), -1, $object->picto, 0, '', '', 0, '', 1);
1261
1262 $formconfirm = '';
1263
1264 // Confirm deletion of intervention
1265 if ($action == 'delete') {
1266 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteIntervention'), $langs->trans('ConfirmDeleteIntervention'), 'confirm_delete', '', 0, 1);
1267 }
1268
1269 // Confirm validation
1270 if ($action == 'validate') {
1271 // Verify if the object's number os temporary
1272 $ref = substr($object->ref, 1, 4);
1273 if ($ref == 'PROV') {
1274 $numref = $object->getNextNumRef($soc);
1275 if (empty($numref)) {
1276 $error++;
1277 setEventMessages($object->error, $object->errors, 'errors');
1278 }
1279 } else {
1280 $numref = (string) $object->ref;
1281 }
1282 $text = $langs->trans('ConfirmValidateIntervention', $numref);
1283 if (isModEnabled('notification')) {
1284 require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php';
1285 $notify = new Notify($db);
1286 $text .= '<br>';
1287 $text .= $notify->confirmMessage('FICHINTER_VALIDATE', $object->socid, $object);
1288 }
1289
1290 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateIntervention'), $text, 'confirm_validate', '', 1, 1);
1291 }
1292
1293 // Confirm sign
1294 if ($action == 'sign') {
1295 $text = $langs->trans('ConfirmSignIntervention');
1296 if (isModEnabled('notification')) {
1297 require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php';
1298 $notify = new Notify($db);
1299 $text .= '<br>';
1300 $text .= $notify->confirmMessage('FICHINTER_MODIFY', $object->socid, $object);
1301 }
1302 $formquestion = [];
1303 $formquestion[] = [
1304 'type' => 'select',
1305 'name' => 'signed_status',
1306 'select_show_empty' => 0,
1307 'label' => '<span class="fieldrequired">'.$langs->trans('SignStatus').'</span>',
1308 'values' => $object->getSignedStatusLocalisedArray()
1309 ];
1310 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('SignIntervention'), $text, 'confirm_sign', $formquestion, 0, 1);
1311 }
1312
1313 // Confirm unsign
1314 if ($action == 'unsign') {
1315 $text = $langs->trans('ConfirmUnsignIntervention');
1316 if (isModEnabled('notification')) {
1317 require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php';
1318 $notify = new Notify($db);
1319 $text .= '<br>';
1320 $text .= $notify->confirmMessage('FICHINTER_MODIFY', $object->socid, $object);
1321 }
1322 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('UnsignIntervention'), $text, 'confirm_unsign', '', 0, 1);
1323 }
1324
1325 // Confirm done
1326 if ($action == 'classifydone') {
1327 $text = $langs->trans('ConfirmCloseIntervention');
1328 if (isModEnabled('notification')) {
1329 require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php';
1330 $notify = new Notify($db);
1331 $text .= '<br>';
1332 $text .= $notify->confirmMessage('FICHINTER_CLOSE', $object->socid, $object);
1333 }
1334 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('CloseIntervention'), $text, 'confirm_done', '', 0, 1);
1335 }
1336
1337 // Confirm back to draft
1338 if ($action == 'modify') {
1339 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ModifyIntervention'), $langs->trans('ConfirmModifyIntervention'), 'confirm_modify', '', 0, 1);
1340 }
1341
1342 // Confirm back to open
1343 if ($action == 'reopen') {
1344 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ReOpen'), $langs->trans('ConfirmReopenIntervention', $object->ref), 'confirm_reopen', '', 0, 1);
1345 }
1346
1347 // Confirm deletion of line
1348 if ($action == 'ask_deleteline') {
1349 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&line_id='.$lineid, $langs->trans('DeleteInterventionLine'), $langs->trans('ConfirmDeleteInterventionLine'), 'confirm_deleteline', '', 0, 1);
1350 }
1351
1352 // Clone confirmation
1353 if ($action == 'clone') {
1354 // Create an array for form
1355 $formquestion = array(
1356 // 'text' => $langs->trans("ConfirmClone"),
1357 // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
1358 array(
1359 'type' => 'other',
1360 'name' => 'socid',
1361 'label' => $langs->trans("SelectThirdParty"),
1362 'value' => $form->select_company(GETPOSTINT('socid'), 'socid', '', '', 0, 0, array(), 0, 'minwidth200')
1363 ),
1364 array(
1365 'type' => 'checkbox',
1366 'name' => 'clone_contacts',
1367 'label' => $langs->trans("CloneContacts"),
1368 'value' => 1
1369 ),
1370 array(
1371 'type' => 'checkbox',
1372 'name' => 'clone_notes',
1373 'label' => $langs->trans("CloneNotes"),
1374 'value' => 1
1375 )
1376 );
1377
1378 // Paiement incomplet. On demande si motif = escompte ou autre
1379 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneIntervention', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
1380 }
1381
1382 // Subtotal line form
1383 if ($action == 'add_title_line') {
1384 $langs->load('subtotals');
1385 $type = 'title';
1386 $depth_array = $object->getPossibleLevels($langs);
1387 require dol_buildpath('/core/tpl/subtotal_create.tpl.php');
1388 } elseif ($action == 'add_subtotal_line') {
1389 $langs->load('subtotals');
1390 $type = 'subtotal';
1391 $titles = $object->getPossibleTitles();
1392 require dol_buildpath('/core/tpl/subtotal_create.tpl.php');
1393 }
1394
1395 if (!$formconfirm) {
1396 $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
1397 $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1398 if (empty($reshook)) {
1399 $formconfirm .= $hookmanager->resPrint;
1400 } elseif ($reshook > 0) {
1401 $formconfirm = $hookmanager->resPrint;
1402 }
1403 }
1404
1405 // Print form confirm
1406 print $formconfirm;
1407
1408
1409 // Intervention card
1410 $linkback = '<a href="'.DOL_URL_ROOT.'/fichinter/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
1411
1412
1413 $morehtmlref = '<div class="refidno">';
1414 // Ref customer
1415 $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $permissiontoadd, 'string', '', 0, 1);
1416 $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $permissiontoadd, 'string', '', null, null, '', 1);
1417 // Thirdparty
1418 $morehtmlref .= '<br>'.$object->thirdparty->getNomUrl(1, 'customer');
1419 // Project
1420 if (isModEnabled('project')) {
1421 $langs->load("projects");
1422 $morehtmlref .= '<br>';
1423 if ($permissiontoadd) {
1424 $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
1425 if ($action != 'classify') {
1426 $morehtmlref .= '<a class="editfielda" href="'.dolBuildUrl($_SERVER['PHP_SELF'], ['action' => 'classify', 'id' => $object->id], true).'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
1427 }
1428 $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, (string) $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
1429 } else {
1430 if (!empty($object->fk_project)) {
1431 $proj = new Project($db);
1432 $proj->fetch($object->fk_project);
1433 $morehtmlref .= $proj->getNomUrl(1);
1434 if ($proj->title) {
1435 $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
1436 }
1437 }
1438 }
1439 }
1440 $morehtmlref .= '</div>';
1441
1442 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
1443
1444
1445 print '<div class="fichecenter">';
1446 print '<div class="fichehalfleft">';
1447 print '<div class="underbanner clearboth"></div>';
1448
1449 print '<table class="border tableforfield centpercent">';
1450
1451 if (getDolGlobalString('FICHINTER_USE_PLANNED_AND_DONE_DATES')) {
1452 // Date Start
1453 print '<tr><td class="titlefield">'.$langs->trans("Dateo").'</td>';
1454 print '<td>';
1455 print $object->dateo ? dol_print_date($object->dateo, 'daytext') : '&nbsp;';
1456 print '</td>';
1457 print '</tr>';
1458
1459 // Date End
1460 print '<tr><td>'.$langs->trans("Datee").'</td>';
1461 print '<td>';
1462 print $object->datee ? dol_print_date($object->datee, 'daytext') : '&nbsp;';
1463 print '</td>';
1464 print '</tr>';
1465
1466 // Date Terminate/close
1467 print '<tr><td>'.$langs->trans("Datet").'</td>';
1468 print '<td>';
1469 print $object->datet ? dol_print_date($object->datet, 'daytext') : '&nbsp;';
1470 print '</td>';
1471 print '</tr>';
1472 }
1473
1474 // Description (must be a textarea and not html must be allowed (used in list view)
1475 print '<tr><td class="titlefield">';
1476 print $form->editfieldkey("Description", 'description', $object->description, $object, $permissiontoadd, 'textarea');
1477 print '</td><td>';
1478 print $form->editfieldval("Description", 'description', $object->description, $object, $permissiontoadd, 'textarea:8');
1479 print '</td>';
1480 print '</tr>';
1481
1482 // Categories
1483 if (isModEnabled('category')) {
1484 print '<tr><td>';
1485 print '<table class="nobordernopadding centpercent"><tr><td>';
1486 print $langs->trans("Categories");
1487 print '<td><td class="right">';
1488 if ($permissiontoadd) {
1489 print '<a class="editfielda" href="'.DOL_URL_ROOT.'/fichinter/card.php?id='.$object->id.'&action=edittags&token='.newToken().'">'.img_edit().'</a>';
1490 } else {
1491 print '&nbsp;';
1492 }
1493 print '</td></tr></table>';
1494 print '</td>';
1495 print '<td>';
1496 if ($action == 'edittags') {
1497 print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
1498 print '<input type="hidden" name="action" value="settags">';
1499 print '<input type="hidden" name="token" value="'.newToken().'">';
1500 print $form->selectCategories(Categorie::TYPE_FICHINTER, 'categories', $object);
1501 print '<input type="submit" class="button valignmiddle smallpaddingimp" value="'.$langs->trans("Modify").'">';
1502 print '</form>';
1503 } else {
1504 print $form->showCategories($object->id, Categorie::TYPE_FICHINTER, 1);
1505 }
1506 print "</td></tr>";
1507 }
1508
1509 // Contract
1510 if (isModEnabled('contract')) {
1511 // This feature hang the application on large list of contracts, because the select component is not complete: it does not work like select of thirdparty or product to support large lists
1512 // So we add a hidden option to avoid to have it used and the application locked, until the select_contract is fixed.
1513 if (getDolGlobalString("CONTRACT_CAN_USE_THE_BUGGED_SELECT_COMPONENT")) {
1514 $langs->load('contracts');
1515 print '<tr>';
1516 print '<td>';
1517
1518 print '<table class="nobordernopadding centpercent"><tr><td>';
1519 print $langs->trans('Contract');
1520 print '</td>';
1521 if ($action != 'editcontract') {
1522 print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editcontract&id='.$object->id.'">';
1523 print img_edit($langs->trans('SetContract'), 1);
1524 print '</a></td>';
1525 }
1526 print '</tr></table>';
1527 print '</td><td>';
1528 if ($action == 'editcontract') {
1529 $formcontract = new FormContract($db);
1530 $formcontract->formSelectContract($_SERVER["PHP_SELF"].'?id='.$object->id, $object->socid, $object->fk_contrat, 'contratid', 0, 1, 1);
1531 } else {
1532 if ($object->fk_contrat) {
1533 $contratstatic = new Contrat($db);
1534 $contratstatic->fetch($object->fk_contrat);
1535 //print '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$selected.'">'.$projet->title.'</a>';
1536 print $contratstatic->getNomUrl(0, 0, 1);
1537 } else {
1538 print "&nbsp;";
1539 }
1540 }
1541 print '</td>';
1542 print '</tr>';
1543 }
1544 }
1545
1546 // Other attributes
1547 $cols = 2;
1548 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
1549
1550 print '</table>';
1551
1552 print '</div>';
1553 print '<div class="fichehalfright">';
1554 print '<div class="underbanner clearboth"></div>';
1555
1556 print '<table class="border tableforfield centpercent">';
1557
1558 if (!getDolGlobalString('FICHINTER_DISABLE_DETAILS') || getDolGlobalString('FICHINTER_DISABLE_DETAILS') == '2') {
1559 // Duration in time
1560 print '<tr><td class="titlefield">'.$langs->trans("TotalDuration").'</td>';
1561 print '<td>'.convertSecondToTime($object->duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY).' ('.convertDurationtoHour($object->duration, "s").' '.$langs->trans("HourShort").')</td>';
1562 print '</tr>';
1563 }
1564
1565 print "</table>";
1566
1567 print '</div>';
1568 print '</div>';
1569
1570 print '<div class="clearboth"></div><br>';
1571
1572
1573 if (getDolGlobalString('MAIN_DISABLE_CONTACTS_TAB')) {
1574 $blocname = 'contacts';
1575 $title = $langs->trans('ContactsAddresses');
1576 include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php';
1577 }
1578
1579 if (getDolGlobalString('MAIN_DISABLE_NOTES_TAB')) {
1580 $blocname = 'notes';
1581 $title = $langs->trans('Notes');
1582 include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php';
1583 }
1584
1585 // Line of interventions
1586 if (!getDolGlobalString('FICHINTER_DISABLE_DETAILS') || getDolGlobalString('FICHINTER_DISABLE_DETAILS') == '2') {
1587 print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" name="addinter" method="post">';
1588 print '<input type="hidden" name="token" value="'.newToken().'">';
1589 print '<input type="hidden" name="id" value="'.$object->id.'">';
1590 if ($action == 'editline') {
1591 print '<input type="hidden" name="action" value="updateline">';
1592 print '<input type="hidden" name="line_id" value="'.GETPOSTINT('line_id').'">';
1593 } else {
1594 print '<input type="hidden" name="action" value="addline">';
1595 }
1596 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
1597
1598 // Intervention lines
1599 $sql = 'SELECT ft.rowid, ft.description, ft.fk_fichinter, ft.duree, ft.rang,';
1600 $sql .= ' ft.special_code, ft.product_type,';
1601 $sql .= ' ft.date as date_intervention';
1602 $sql .= ' FROM '.MAIN_DB_PREFIX.'fichinterdet as ft';
1603 $sql .= ' WHERE ft.fk_fichinter = '.((int) $object->id);
1604 if (getDolGlobalString('FICHINTER_HIDE_EMPTY_DURATION')) {
1605 $sql .= ' AND ft.duree <> 0';
1606 }
1607 $sql .= ' ORDER BY ft.rang ASC, ft.date ASC, ft.rowid';
1608
1609 $resql = $db->query($sql);
1610 if ($resql) {
1611 $num = $db->num_rows($resql);
1612 $i = 0;
1613
1614 if ($num) {
1615 print '<br>';
1616 print '<table class="noborder centpercent">';
1617 print '<tr class="liste_titre">';
1618
1619 // No.
1620 if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER')) {
1621 print '<td width="5" class="center linecolnum"></td>';
1622 }
1623
1624 print '<td class="liste_titre">'.$langs->trans('Description').'</td>';
1625 print '<td class="liste_titre center">'.$langs->trans('Date').'</td>';
1626 print '<td class="liste_titre right">'.(!getDolGlobalString('FICHINTER_WITHOUT_DURATION') ? $langs->trans('Duration') : '').'</td>';
1627 print '<td class="liste_titre">&nbsp;</td>';
1628 print '<td class="liste_titre">&nbsp;</td>';
1629 print "</tr>\n";
1630 }
1631 while ($i < $num) {
1632 $objp = $db->fetch_object($resql);
1633
1634 // Line in view mode
1635 if ($action != 'editline' || GETPOSTINT('line_id') != $objp->rowid) {
1636 print '<tr class="oddeven">';
1637
1638 // No.
1639 if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER')) {
1640 print '<td class="center linecolnum">'.($i + 1).'</td>';
1641 }
1642 if (!empty($objp->special_code) || $objp->product_type == 9) {
1643 $line_color = $object->getSubtotalColors($objp->duree);
1644 $line_options = json_decode($objp->extraparams, true);
1645 $line_options = is_array($line_options) ? $line_options['subtotal'] : array();
1646 print '<td colspan="3" ><strong>'.dol_htmlentitiesbr($objp->description).'</strong>';
1647 if (array_key_exists('titleshowuponpdf', $line_options)) {
1648 echo '&nbsp;' . img_picto($langs->trans("ShowUPOnPDF"), 'invoicing');
1649 }
1650 if (array_key_exists('titleshowtotalexludingvatonpdf', $line_options)) {
1651 echo '&nbsp; <span title="' . $langs->trans("ShowTotalExludingVATOnPDF") . '">%</span>';
1652 }
1653 if (array_key_exists('titleforcepagebreak', $line_options)) {
1654 echo '&nbsp;' . img_picto($langs->trans("ForcePageBreak"), 'file');
1655 }
1656 print "</td>";
1657 } else {
1658 print '<td>';
1659 print '<a name="'.$objp->rowid.'"></a>'; // Anchor to return to the line
1660 print dol_htmlentitiesbr($objp->description);
1661
1662 $objectline = new FichinterLigne($db);
1663 $objectline->fetch($objp->rowid);
1664 $objectline->fetch_optionals();
1665
1666 $extrafields->fetch_name_optionals_label($objectline->table_element);
1667
1668 $temps = $objectline->showOptionals($extrafields, 'view', array(), '', '', '1', 'line');
1669 if (!empty($temps)) {
1670 print '<div style="padding-top: 10px" id="extrafield_lines_area_'.$objp->rowid.'" name="extrafield_lines_area_'.$objp->rowid.'">';
1671 print $temps;
1672 print '</div>';
1673 }
1674
1675 print '</td>';
1676
1677 // Date
1678 print '<td class="center" width="150">'.(!getDolGlobalString('FICHINTER_DATE_WITHOUT_HOUR') ? dol_print_date($db->jdate($objp->date_intervention), 'dayhour') : dol_print_date($db->jdate($objp->date_intervention), 'day')).'</td>';
1679
1680 // Duration
1681 print '<td class="right" width="150">'.(!getDolGlobalString('FICHINTER_WITHOUT_DURATION') ? convertSecondToTime($objp->duree) : '').'</td>';
1682
1683 print "</td>\n";
1684 }
1685 // Icon to edit and delete
1686 if ($object->status == 0 && $permissiontoadd) {
1687 print '<td class="center">';
1688 print '<a class="editfielda marginrightonly" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=editline&token='.newToken().'&line_id='.$objp->rowid.'#'.$objp->rowid.'">';
1689 print img_edit();
1690 print '</a>';
1691 print '<a class="marginleftonly" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=ask_deleteline&token='.newToken().'&line_id='.$objp->rowid.'">';
1692 print img_delete();
1693 print '</a></td>';
1694 print '<td class="center">';
1695 if ($num > 1) {
1696 if ($i > 0) {
1697 print '<a class="marginleftonly" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=up&token='.newToken().'&line_id='.$objp->rowid.'">';
1698 print img_up();
1699 print '</a>';
1700 }
1701 if ($i < $num - 1) {
1702 print '<a class="marginleftonly" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=down&token='.newToken().'&line_id='.$objp->rowid.'">';
1703 print img_down();
1704 print '</a>';
1705 }
1706 }
1707 print '</td>';
1708 } else {
1709 print '<td colspan="2">&nbsp;</td>';
1710 }
1711
1712 print '</tr>';
1713 }
1714
1715 // Line in update mode
1716 if ($object->status == 0 && $action == 'editline' && $permissiontoadd && GETPOSTINT('line_id') == $objp->rowid) {
1717 print '<tr class="oddeven nohover">';
1718
1719 // No.
1720 if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER')) {
1721 print '<td class="center linecolnum">'.($i + 1).'</td>';
1722 }
1723
1724 print '<td>';
1725 print '<a name="'.$objp->rowid.'"></a>'; // Anchor to return to the line
1726
1727 // Editeur wysiwyg
1728 require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
1729 $doleditor = new DolEditor('np_desc', $objp->description, '', 164, 'dolibarr_details', '', false, true, getDolGlobalInt('FCKEDITOR_ENABLE_DETAILS'), ROWS_2, '90%');
1730 $doleditor->Create();
1731
1732 $objectline = new FichinterLigne($db);
1733 $objectline->fetch($objp->rowid);
1734 $objectline->fetch_optionals();
1735
1736 $extrafields->fetch_name_optionals_label($objectline->table_element);
1737
1738 $temps = $objectline->showOptionals($extrafields, 'edit', array(), '', '', '1', 'line');
1739 if (!empty($temps)) {
1740 print '<div style="padding-top: 10px" id="extrafield_lines_area_'.$objectline->id.'" name="extrafield_lines_area_'.$objectline->id.'">';
1741 print $temps;
1742 print '</div>';
1743 }
1744
1745 print '</td>';
1746
1747 // Date d'intervention
1748 print '<td class="center nowrap">';
1749 if (getDolGlobalString('FICHINTER_DATE_WITHOUT_HOUR')) {
1750 print $form->selectDate($db->jdate($objp->date_intervention), 'di', 0, 0, 0, "date_intervention");
1751 } else {
1752 print $form->selectDate($db->jdate($objp->date_intervention), 'di', 1, 1, 0, "date_intervention");
1753 }
1754 print '</td>';
1755
1756 // Duration
1757 print '<td class="right">';
1758 if (!getDolGlobalString('FICHINTER_WITHOUT_DURATION')) {
1759 $selectmode = 'select';
1760 if (getDolGlobalString('INTERVENTION_ADDLINE_FREEDUREATION')) {
1761 $selectmode = 'text';
1762 }
1763 $form->select_duration('duration', $objp->duree, 0, $selectmode);
1764 }
1765 print '</td>';
1766
1767 print '<td class="center" colspan="5" valign="center">';
1768 print '<input type="submit" class="button buttongen marginbottomonly button-save" name="save" value="'.$langs->trans("Save").'">';
1769 print '<input type="submit" class="button buttongen marginbottomonly button-cancel" name="cancel" value="'.$langs->trans("Cancel").'"></td>';
1770 print '</tr>'."\n";
1771 }
1772
1773 $i++;
1774 }
1775
1776 $db->free($resql);
1777
1778 // Add new line
1779 if ($object->status == 0 && $permissiontoadd && $action != 'editline' && (!getDolGlobalString('FICHINTER_DISABLE_DETAILS') || getDolGlobalString('FICHINTER_DISABLE_DETAILS') == '2')) {
1780 if (!$num) {
1781 print '<br>';
1782 print '<table class="noborder centpercent">';
1783 print '<tr class="liste_titre">';
1784
1785 // No.
1786 if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER')) {
1787 print '<td width="5" class="center linecolnum"></td>';
1788 }
1789
1790 print '<td>';
1791 print '<a name="add"></a>'; // ancre
1792 print $langs->trans('Description').'</td>';
1793 print '<td class="center">'.$langs->trans('Date').'</td>';
1794 print '<td class="right">'.(!getDolGlobalString('FICHINTER_WITHOUT_DURATION') ? $langs->trans('Duration') : '').'</td>';
1795 print '<td colspan="3">&nbsp;</td>';
1796 print "</tr>\n";
1797 }
1798
1799 print '<tr class="oddeven nohover">'."\n";
1800
1801 // No.
1802 if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER')) {
1803 print '<td class="center linecolnum">'.($i + 1).'</td>';
1804 }
1805
1806 print '<td>';
1807 // editeur wysiwyg
1808 if (!getDolGlobalString('FICHINTER_EMPTY_LINE_DESC')) {
1809 require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
1810 $doleditor = new DolEditor('np_desc', GETPOST('np_desc', 'restricthtml'), '', 100, 'dolibarr_details', '', false, true, getDolGlobalString('FCKEDITOR_ENABLE_DETAILS'), ROWS_2, '90%');
1811 $doleditor->Create();
1812 }
1813
1814 $objectline = new FichinterLigne($db);
1815 $extrafields->fetch_name_optionals_label($objectline->table_element);
1816
1817 if (is_object($objectline)) {
1818 $temps = $objectline->showOptionals($extrafields, 'create', array(), '', '', '1', 'line');
1819
1820 if (!empty($temps)) {
1821 print '<div style="padding-top: 10px" id="extrafield_lines_area_create" name="extrafield_lines_area_create">';
1822 print $temps;
1823 print '</div>';
1824 }
1825 }
1826
1827 print '</td>';
1828
1829 // Date intervention
1830 print '<td class="center nowrap">';
1831 $now = dol_now();
1832 $timearray = dol_getdate($now);
1833 if (!GETPOSTINT('diday')) {
1834 if (getDolGlobalInt('FICHINTER_DATE_WITHOUT_HOUR')) {
1835 $timewithnohour = dol_mktime(0, 0, 0, $timearray['mon'], $timearray['mday'], $timearray['year']);
1836 } else {
1837 $timewithnohour = dol_mktime($timearray['hours'], $timearray['minutes'], 0, $timearray['mon'], $timearray['mday'], $timearray['year']);
1838 }
1839 } else {
1840 $timewithnohour = dol_mktime(GETPOSTINT('dihour'), GETPOSTINT('dimin'), 0, GETPOSTINT('dimonth'), GETPOSTINT('diday'), GETPOSTINT('diyear'));
1841 }
1842 if (getDolGlobalInt('FICHINTER_DATE_WITHOUT_HOUR')) {
1843 print $form->selectDate($timewithnohour, 'di', 0, 0, 0, "addinter");
1844 } else {
1845 print $form->selectDate($timewithnohour, 'di', 1, 1, 0, "addinter");
1846 }
1847 print '</td>';
1848
1849 // Duration
1850 print '<td class="right">';
1851 if (!getDolGlobalString('FICHINTER_WITHOUT_DURATION')) {
1852 $selectmode = 'select';
1853 if (getDolGlobalString('INTERVENTION_ADDLINE_FREEDUREATION')) {
1854 $selectmode = 'text';
1855 }
1856 $form->select_duration('duration', (!GETPOSTINT('durationhour') && !GETPOSTINT('durationmin')) ? 3600 : (60 * 60 * GETPOSTINT('durationhour') + 60 * GETPOSTINT('durationmin')), 0, $selectmode);
1857 }
1858 print '</td>';
1859
1860 print '<td class="center" valign="middle" colspan="3"><input type="submit" class="button button-add" value="'.$langs->trans('Add').'" name="addline"></td>';
1861 print '</tr>';
1862
1863 if (!$num) {
1864 print '</table>';
1865 }
1866 }
1867
1868 if ($num) {
1869 print '</table>';
1870 }
1871 } else {
1873 }
1874
1875 print '</form>'."\n";
1876 }
1877
1878 print dol_get_fiche_end();
1879
1880 print "\n";
1881
1882
1883 /*
1884 * Actions buttons
1885 */
1886
1887 print '<div class="tabsAction">';
1888
1889 $parameters = array();
1890 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
1891 // modified by hook
1892 if (empty($reshook)) {
1893 $params = array();
1894 if ($user->socid == 0) {
1895 if ($action != 'editdescription' && ($action != 'presend')) {
1896 // Subtotal
1897 if ($object->status == Fichinter::STATUS_DRAFT && isModEnabled('subtotals') && getDolGlobalString('SUBTOTAL_TITLE_'.strtoupper($object->element))) {
1898 $langs->load('subtotals');
1899
1900 $url_button = array();
1901 $url_button[] = array(
1902 'lang' => 'subtotals',
1903 'enabled' => (isModEnabled('intervention') && $object->status == Fichinter::STATUS_DRAFT),
1904 'perm' => (bool) $permissiontoadd,
1905 'label' => $langs->trans('AddTitleLine'),
1906 'url' => '/fichinter/card.php?id='.$object->id.'&action=add_title_line&token='.newToken()
1907 );
1908
1909 $url_button[] = array(
1910 'lang' => 'subtotals',
1911 'enabled' => (isModEnabled('intervention') && $object->status == Fichinter::STATUS_DRAFT),
1912 'perm' => (bool) $permissiontoadd,
1913 'label' => $langs->trans('AddSubtotalLine'),
1914 'url' => '/fichinter/card.php?id='.$object->id.'&action=add_subtotal_line&token='.newToken()
1915 );
1916 print dolGetButtonAction('', $langs->trans('Subtotal'), 'default', $url_button, '', true);
1917 }
1918
1919 // Validate
1920 if ($object->status == Fichinter::STATUS_DRAFT && (count($object->lines) > 0 || getDolGlobalString('FICHINTER_DISABLE_DETAILS') == '1')) {
1921 if ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $permissiontoadd) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('ficheinter', 'ficheinter_advance', 'validate'))) {
1922 print '<div class="inline-block divButAction"><a class="butAction" href="card.php?id='.$object->id.'&action=validate&token='.newToken().'">'.$langs->trans("Validate").'</a></div>';
1923 } else {
1924 print '<div class="inline-block divButActionRefused"><span class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("Validate").'</span></div>';
1925 }
1926 }
1927
1928 // Modify
1929 if ($object->status == Fichinter::STATUS_VALIDATED && ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $permissiontoadd) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('ficheinter', 'ficheinter_advance', 'unvalidate')))) {
1930 print '<div class="inline-block divButAction"><a class="butAction" href="card.php?id='.$object->id.'&action=modify&token='.newToken().'">';
1931 if (!getDolGlobalString('FICHINTER_DISABLE_DETAILS') || getDolGlobalString('FICHINTER_DISABLE_DETAILS') == '2') {
1932 print $langs->trans("Modify");
1933 } else {
1934 print $langs->trans("SetToDraft");
1935 }
1936 print '</a></div>';
1937 }
1938
1939 // Reopen
1940 if ($object->status >= Fichinter::STATUS_CLOSED) {
1941 if ($permissiontoadd) {
1942 print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen&token='.newToken().'">'.$langs->trans('ReOpen').'</a></div>';
1943 } else {
1944 print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans('ReOpen').'</a></div>';
1945 }
1946 }
1947
1948 // Send
1949 if (empty($user->socid)) {
1950 if ($object->status > Fichinter::STATUS_DRAFT) {
1951 if (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') || $user->hasRight('ficheinter', 'ficheinter_advance', 'send')) {
1952 print dolGetButtonAction('', $langs->trans('SendMail'), 'email', dolBuildUrl($_SERVER["PHP_SELF"], ['id' => $object->id, 'action' => 'presend', 'mode' => 'init'], true).'#formmailbeforetitle', '');
1953 } else {
1954 print dolGetButtonAction('', $langs->trans('SendMail'), 'email', '#', '', false);
1955 }
1956 }
1957 }
1958
1959 // Create intervention model
1960 if ($object->status == Fichinter::STATUS_DRAFT && $permissiontoadd && (count($object->lines) > 0)) {
1961 print '<div class="inline-block divButAction">';
1962 print '<a class="butAction" href="'.DOL_URL_ROOT.'/fichinter/card-rec.php?id='.$object->id.'&action=create&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$object->id).'">'.$langs->trans("ChangeIntoRepeatableIntervention").'</a>';
1963 print '</div>';
1964 }
1965
1966 $arrayofcreatebutton = array();
1967 // Proposal
1968 if (isModEnabled("service") && isModEnabled("propal") && $object->status > Fichinter::STATUS_DRAFT) {
1969 $langs->load("propal");
1970 if ($object->status < Fichinter::STATUS_BILLED) {
1971 $arrayofcreatebutton[] = array(
1972 'url' => '/comm/propal/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid,
1973 'label' => $langs->trans('AddProp'),
1974 'lang' => 'propal',
1975 'perm' => $user->hasRight('propal', 'creer'),
1976 'enabled' => true,
1977 );
1978 }
1979 }
1980
1981 // Invoicing
1982 if (isModEnabled('invoice') && $object->status > Fichinter::STATUS_DRAFT) {
1983 $langs->load("bills");
1984 if ($object->status < Fichinter::STATUS_BILLED) {
1985 $arrayofcreatebutton[] = array(
1986 'url' => '/compta/facture/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid,
1987 'label' => $langs->trans('AddBill'),
1988 'lang' => 'bills',
1989 'perm' => $user->hasRight('facture', 'creer') ? true : false,
1990 'enabled' => true,
1991 );
1992 }
1993
1994 if (getDolGlobalString('FICHINTER_CLASSIFY_BILLED')) { // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1
1995 if ($object->status != Fichinter::STATUS_BILLED) {
1996 print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=classifybilled&token='.newToken().'">'.$langs->trans("InterventionClassifyBilled").'</a></div>';
1997 } else {
1998 print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=classifyunbilled&token='.newToken().'">'.$langs->trans("InterventionClassifyUnBilled").'</a></div>';
1999 }
2000 }
2001 }
2002
2003 if (count($arrayofcreatebutton)) {
2004 print dolGetButtonAction('', $langs->trans("Create"), 'default', $arrayofcreatebutton, '', true, $params);
2005 }
2006
2007 // Sign
2008 if ($object->status > Fichinter::STATUS_DRAFT) {
2009 if ($object->signed_status != Fichinter::$SIGNED_STATUSES['STATUS_SIGNED_ALL']) {
2010 print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=sign&token=' . newToken() . '">' . $langs->trans("InterventionSign") . '</a></div>';
2011 } else {
2012 print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=unsign&token=' . newToken() . '">' . $langs->trans("InterventionUnsign") . '</a></div>';
2013 }
2014 }
2015
2016 // Done
2017 if (!getDolGlobalString('FICHINTER_CLASSIFY_BILLED') && $object->status > Fichinter::STATUS_DRAFT && $object->status < Fichinter::STATUS_CLOSED) {
2018 print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=classifydone&token='.newToken().'">'.$langs->trans("InterventionClassifyDone").'</a></div>';
2019 }
2020
2021 // Clone
2022 if ($permissiontoadd) {
2023 print '<div class="inline-block divButAction"><a class="butAction butActionClone" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&token='.newToken().'&object=ficheinter">'.$langs->trans("ToClone").'</a></div>';
2024 }
2025
2026 // Delete
2027 print '<div class="inline-block divButAction">';
2028 print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $permissiontodelete);
2029 print '</div>';
2030 }
2031 }
2032 }
2033
2034 print '</div>';
2035
2036 if ($action != 'presend') {
2037 print '<div class="fichecenter"><div class="fichehalfleft">';
2038
2039 /*
2040 * Built documents
2041 */
2042 $filename = dol_sanitizeFileName($object->ref);
2043 $filedir = $conf->ficheinter->dir_output."/".$filename;
2044 $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
2045 $genallowed = $user->hasRight('ficheinter', 'lire');
2046 $delallowed = $permissiontoadd;
2047 print $formfile->showdocuments('ficheinter', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang);
2048
2049 // Show links to link elements
2050 $tmparray = $form->showLinkToObjectBlock($object, array(), array('fichinter'), 1);
2051 $linktoelem = $tmparray['linktoelem'];
2052 $htmltoenteralink = $tmparray['htmltoenteralink'];
2053 print $htmltoenteralink;
2054
2055 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
2056
2057 // Show direct download link
2058 if ($object->status != Fichinter::STATUS_DRAFT && getDolGlobalString('FICHINTER_ALLOW_EXTERNAL_DOWNLOAD')) {
2059 print '<br><!-- Link to download main doc -->'."\n";
2060 print showDirectDownloadLink($object).'<br>';
2061 }
2062
2063 // Show online signature link
2064 if ($object->status != Fichinter::STATUS_DRAFT && getDolGlobalString('FICHINTER_ALLOW_ONLINE_SIGN')) {
2065 print '<br><!-- Link to sign -->';
2066 require_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php';
2067
2068 print showOnlineSignatureUrl('fichinter', $object->ref, $object).'<br>';
2069 }
2070
2071 print '</div><div class="fichehalfright">';
2072
2073 $MAXEVENT = 10;
2074
2075 $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/fichinter/agenda.php?id='.$object->id);
2076
2077 // List of actions on element
2078 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
2079 $formactions = new FormActions($db);
2080 $somethingshown = $formactions->showactions($object, 'fichinter', $socid, 1, '', $MAXEVENT, '', $morehtmlcenter); // Show all action for thirdparty
2081
2082 print '</div></div>';
2083 }
2084
2085
2086 // Select mail models is same action as presend
2087 if (GETPOST('modelselected')) {
2088 $action = 'presend';
2089 }
2090
2091 // Presend form
2092 $modelmail = 'fichinter_send';
2093 $defaulttopic = 'SendInterventionRef';
2094 $diroutput = $conf->ficheinter->dir_output;
2095 $trackid = 'int'.$object->id;
2096
2097 include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
2098}
2099
2100
2101llxFooter();
2102
2103$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage a WYSIWYG editor.
const STATUS_BILLED
Billed.
const STATUS_DRAFT
Draft status.
const STATUS_VALIDATED
Validated status.
const STATUS_CLOSED
Closed.
Class to manage intervention lines.
Class to manage building of HTML components.
Class to manage generation of HTML components for contract module.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class to manage building of HTML components.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
Class to manage the table of subscription to notifications.
Class to manage products or services.
const TYPE_PRODUCT
Regular product.
const TYPE_SERVICE
Service.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage translations.
convertDurationtoHour($duration_value, $duration_unit)
Convert duration to hour.
Definition date.lib.php:342
convertTime2Seconds($iHours=0, $iMinutes=0, $iSeconds=0)
Convert hours and minutes into seconds.
Definition date.lib.php:219
convertSecondToTime($iSecond, $format='all', $lengthOfDay=86400, $lengthOfWeek=7)
Return, in clear text, value of a number of seconds in days, hours and minutes.
Definition date.lib.php:248
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
fichinter_prepare_head($object)
Prepare array with list of tabs.
dol_now($mode='gmt')
Return date for now.
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
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, $morecssdiv='')
Show tabs of a record.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
img_down($titlealt='default', $selected=0, $moreclass='')
Show down arrow logo.
GETPOSTISARRAY($paramname, $method=0)
Return true if the parameter $paramname is submit from a POST OR GET as an array.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_htmloutput_mesg($mesgstring='', $mesgarray=array(), $style='ok', $keepembedded=0)
Print formatted messages to output (Used to show messages on html output).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
img_up($titlealt='default', $selected=0, $moreclass='')
Show top arrow logo.
dol_htmloutput_errors($mesgstring='', $mesgarray=array(), $keepembedded=0)
Print formatted error messages to output (Used to show messages on html output).
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
fichinter_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Create an intervention document on disk using template defined into FICHEINTER_ADDON_PDF.
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.