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