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