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