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