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