dolibarr 22.0.5
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');
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 && $conf->global->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 == 'classifybilled' && $permissiontoadd) {
654 // Classify Billed
655 $result = $object->setStatut(Fichinter::STATUS_BILLED);
656 if ($result > 0) {
657 header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
658 exit;
659 } else {
660 setEventMessages($object->error, $object->errors, 'errors');
661 }
662 } elseif ($action == 'classifyunbilled' && $permissiontoadd) {
663 // Classify unbilled
664 $result = $object->setStatut(Fichinter::STATUS_VALIDATED);
665 if ($result > 0) {
666 header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
667 exit;
668 } else {
669 $mesg = $object->error;
670 }
671 } elseif ($action == 'confirm_reopen' && $permissiontoadd) {
672 // Reopen
673 $result = $object->setStatut(Fichinter::STATUS_VALIDATED);
674 if ($result > 0) {
675 header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
676 exit;
677 } else {
678 $mesg = $object->error;
679 }
680 } elseif ($action == 'updateline' && $permissiontoadd && GETPOST('save', 'alpha')) {
681 // Mise a jour d'une ligne d'intervention
682 $objectline = new FichinterLigne($db);
683 if ($objectline->fetch($lineid) <= 0) {
684 dol_print_error($db);
685 exit;
686 }
687
688 if ($object->fetch($objectline->fk_fichinter) <= 0) {
689 dol_print_error($db);
690 exit;
691 }
692 $object->fetch_thirdparty();
693
694 $desc = GETPOST('np_desc', 'restricthtml');
695 $date_inter = dol_mktime(GETPOSTINT('dihour'), GETPOSTINT('dimin'), 0, GETPOSTINT('dimonth'), GETPOSTINT('diday'), GETPOSTINT('diyear'));
696 $duration = convertTime2Seconds(GETPOSTINT('durationhour'), GETPOSTINT('durationmin'));
697
698 $objectline->date = $date_inter;
699 $objectline->desc = $desc;
700 $objectline->duration = $duration;
701
702 // Extrafields
703 $extrafields->fetch_name_optionals_label($object->table_element_line);
704 $array_options = $extrafields->getOptionalsFromPost($object->table_element_line);
705 if (is_array($array_options)) {
706 $objectline->array_options = array_merge($objectline->array_options, $array_options);
707 }
708
709 $result = $objectline->update($user);
710 if ($result < 0) {
711 // Surface validation errors (e.g. mandatory extrafield left empty) as an
712 // event message on the same page instead of breaking with a full Dolibarr
713 // error screen that loses the user's edit context.
714 setEventMessages($objectline->error, $objectline->errors, 'errors');
715 }
716
717 // Define output language
718 $outputlangs = $langs;
719 $newlang = '';
720 if (getDolGlobalInt('MAIN_MULTILANGS') /* && empty($newlang) */ && GETPOST('lang_id', 'aZ09')) {
721 $newlang = GETPOST('lang_id', 'aZ09');
722 }
723 if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) {
724 $newlang = $object->thirdparty->default_lang;
725 }
726 if (!empty($newlang)) {
727 $outputlangs = new Translate("", $conf);
728 $outputlangs->setDefaultLang($newlang);
729 }
730 if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) {
731 fichinter_create($db, $object, $object->model_pdf, $outputlangs);
732 }
733
734 header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
735 exit;
736 } elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $permissiontoadd) {
737 // Supprime une ligne d'intervention AVEC confirmation
738 $objectline = new FichinterLigne($db);
739 if ($objectline->fetch($lineid) <= 0) {
740 dol_print_error($db);
741 exit;
742 }
743 $result = $objectline->deleteLine($user);
744
745 if ($object->fetch($objectline->fk_fichinter) <= 0) {
746 dol_print_error($db);
747 exit;
748 }
749
750 // Define output language
751 $outputlangs = $langs;
752 $newlang = '';
753 if (getDolGlobalInt('MAIN_MULTILANGS') /* && empty($newlang) */ && GETPOST('lang_id', 'aZ09')) {
754 $newlang = GETPOST('lang_id', 'aZ09');
755 }
756 if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) {
757 $newlang = $object->thirdparty->default_lang;
758 }
759 if (!empty($newlang)) {
760 $outputlangs = new Translate("", $conf);
761 $outputlangs->setDefaultLang($newlang);
762 }
763 if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) {
764 fichinter_create($db, $object, $object->model_pdf, $outputlangs);
765 }
766 } elseif ($action == 'up' && $permissiontoadd) {
767 // Set position of lines
768 $object->line_up($lineid);
769
770 // Define output language
771 $outputlangs = $langs;
772 $newlang = '';
773 if (getDolGlobalInt('MAIN_MULTILANGS') /* && empty($newlang) */ && GETPOST('lang_id', 'aZ09')) {
774 $newlang = GETPOST('lang_id', 'aZ09');
775 }
776 if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) {
777 $newlang = $object->thirdparty->default_lang;
778 }
779 if (!empty($newlang)) {
780 $outputlangs = new Translate("", $conf);
781 $outputlangs->setDefaultLang($newlang);
782 }
783 if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) {
784 fichinter_create($db, $object, $object->model_pdf, $outputlangs);
785 }
786
787 header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.$lineid);
788 exit;
789 } elseif ($action == 'down' && $permissiontoadd) {
790 $object->line_down($lineid);
791
792 // Define output language
793 $outputlangs = $langs;
794 $newlang = '';
795 if (getDolGlobalInt('MAIN_MULTILANGS') /* && empty($newlang) */ && GETPOST('lang_id', 'aZ09')) {
796 $newlang = GETPOST('lang_id', 'aZ09');
797 }
798 if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) {
799 $newlang = $object->thirdparty->default_lang;
800 }
801 if (!empty($newlang)) {
802 $outputlangs = new Translate("", $conf);
803 $outputlangs->setDefaultLang($newlang);
804 }
805 if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) {
806 fichinter_create($db, $object, $object->model_pdf, $outputlangs);
807 }
808
809 header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.$lineid);
810 exit;
811 }
812
813 // Actions when printing a doc from card
814 include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
815
816 // Actions to send emails
817 $triggersendname = 'FICHINTER_SENTBYMAIL';
818 $autocopy = 'MAIN_MAIL_AUTOCOPY_FICHINTER_TO';
819 $trackid = 'int'.$object->id;
820 include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
821
822 // Actions to build doc
823 $upload_dir = $conf->ficheinter->dir_output;
824 $permissiontoadd = $user->hasRight('ficheinter', 'creer');
825 include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
826
827 if ($action == 'update_extras' && $permissiontoeditextra) {
828 $object->oldcopy = dol_clone($object, 2); // @phan-suppress-current-line PhanTypeMismatchProperty
829
830 $attribute_name = GETPOST('attribute', 'aZ09');
831
832 // Fill array 'array_options' with data from update form
833 $ret = $extrafields->setOptionalsFromPost(null, $object, $attribute_name);
834 if ($ret < 0) {
835 $error++;
836 }
837
838 if (!$error) {
839 // Actions on extra fields
840 $result = $object->updateExtraField($attribute_name, 'INTERVENTION_MODIFY');
841 if ($result < 0) {
842 setEventMessages($object->error, $object->errors, 'errors');
843 $error++;
844 }
845 }
846
847 if ($error) {
848 $action = 'edit_extras';
849 }
850 }
851
852 if (getDolGlobalString('MAIN_DISABLE_CONTACTS_TAB')) {
853 if ($action == 'addcontact' && $permissiontoadd) {
854 if ($result > 0 && $id > 0) {
855 $contactid = (GETPOSTINT('userid') ? GETPOSTINT('userid') : GETPOSTINT('contactid'));
856 $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
857 $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
858 }
859
860 if ($result >= 0) {
861 header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
862 exit;
863 } else {
864 if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
865 $langs->load("errors");
866 $mesg = $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType");
867 } else {
868 $mesg = $object->error;
869 }
870 }
871 } elseif ($action == 'swapstatut' && $permissiontoadd) {
872 // bascule du statut d'un contact
873 $result = $object->swapContactStatus(GETPOSTINT('ligne'));
874 } elseif ($action == 'deletecontact' && $permissiontoadd) {
875 // Efface un contact
876 $result = $object->delete_contact(GETPOSTINT('lineid'));
877
878 if ($result >= 0) {
879 header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
880 exit;
881 } else {
882 dol_print_error($db);
883 }
884 }
885 }
886}
887
888
889/*
890 * View
891 */
892
893$form = new Form($db);
894$formfile = new FormFile($db);
895$formcontract = null;
896$formproject = null;
897if (isModEnabled('contract')) {
898 $formcontract = new FormContract($db);
899}
900if (isModEnabled('project')) {
901 $formproject = new FormProjets($db);
902}
903
904
905$help_url = 'EN:Module_Interventions';
906
907llxHeader('', $langs->trans("Intervention"), $help_url, '', 0, 0, '', '', '', 'mod-fichinter page-card');
908
909if ($action == 'create') {
910 // Create new intervention
911
912 $soc = new Societe($db);
913
914 print load_fiche_titre($langs->trans("AddIntervention"), '', 'intervention');
915
916 if ($error > 0) {
918 } else {
919 dol_htmloutput_mesg($mesg);
920 }
921
922 if ($socid) {
923 $res = $soc->fetch($socid);
924 }
925
926 if (GETPOST('origin', 'alphanohtml') && GETPOSTINT('originid')) {
927 // Parse element/subelement (ex: project_task)
928 $regs = array();
929 $element = $subelement = GETPOST('origin', 'alphanohtml');
930 if (preg_match('/^([^_]+)_([^_]+)/i', GETPOST('origin', 'alphanohtml'), $regs)) {
931 $element = $regs[1];
932 $subelement = $regs[2];
933 }
934
935 if ($element == 'project') {
936 $projectid = GETPOSTINT('originid');
937 } else {
938 // For compatibility
939 if ($element == 'order' || $element == 'commande') {
940 $element = $subelement = 'commande';
941 }
942 if ($element == 'propal') {
943 $element = 'comm/propal';
944 $subelement = 'propal';
945 }
946 if ($element == 'contract') {
947 $element = $subelement = 'contrat';
948 }
949
950 dol_include_once('/'.$element.'/class/'.$subelement.'.class.php');
951
952 $classname = ucfirst($subelement);
953 $objectsrc = new $classname($db);
954 '@phan-var-force Commande|Propal|Contrat $objectsrc';
955 $objectsrc->fetch(GETPOSTINT('originid'));
956 if (empty($objectsrc->lines) && method_exists($objectsrc, 'fetch_lines')) {
957 $objectsrc->fetch_lines();
958 $lines = $objectsrc->lines;
959 }
960 $objectsrc->fetch_thirdparty();
961
962 $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project : '');
963
964 $soc = $objectsrc->thirdparty;
965
966 $note_private = (!empty($objectsrc->note) ? $objectsrc->note : (!empty($objectsrc->note_private) ? $objectsrc->note_private : GETPOST('note_private', 'restricthtml')));
967 $note_public = (!empty($objectsrc->note_public) ? $objectsrc->note_public : GETPOST('note_public', 'restricthtml'));
968
969 // Replicate extrafields
970 $objectsrc->fetch_optionals();
971 $object->array_options = $objectsrc->array_options;
972
973 // Object source contacts list
974 $srccontactslist = $objectsrc->liste_contact(-1, 'external', 1);
975 }
976 } else {
977 $projectid = GETPOSTINT('projectid');
978 }
979
980 if (!$conf->global->FICHEINTER_ADDON) {
981 dol_print_error($db, $langs->trans("Error")." ".$langs->trans("Error_FICHEINTER_ADDON_NotDefined"));
982 exit;
983 }
984
985 $object->datec = dol_now();
986
987 $obj = getDolGlobalString('FICHEINTER_ADDON');
988 $obj = "mod_".$obj;
989
990 //$modFicheinter = new $obj;
991 //$numpr = $modFicheinter->getNextValue($soc, $object);
992
993 if ($socid > 0) {
994 $soc = new Societe($db);
995 $soc->fetch($socid);
996
997 print '<form name="fichinter" action="'.$_SERVER['PHP_SELF'].'" method="POST">';
998 print '<input type="hidden" name="token" value="'.newToken().'">';
999 print '<input type="hidden" name="socid" value='.$soc->id.'>';
1000 print '<input type="hidden" name="action" value="add">';
1001 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
1002
1003 print dol_get_fiche_head([]);
1004
1005 print '<table class="border centpercent">';
1006
1007 print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("ThirdParty").'</td><td>'.$soc->getNomUrl(1).'</td></tr>';
1008
1009 // Ref
1010 print '<tr><td class="fieldrequired">'.$langs->trans('Ref').'</td><td>'.$langs->trans("Draft").'</td></tr>';
1011
1012 // Ref customer
1013 print '<tr class="field_ref_client"><td class="titlefieldcreate">'.$langs->trans('RefCustomer').'</td><td class="valuefieldcreate">';
1014 print '<input type="text" name="ref_client" value="'.GETPOST('ref_client').'"></td>';
1015 print '</tr>';
1016
1017 // Description (must be a textarea and not html must be allowed (used in list view)
1018 print '<tr><td class="tdtop">'.$langs->trans("Description").'</td>';
1019 print '<td>';
1020 print '<textarea name="description" class="quatrevingtpercent" rows="'.ROWS_3.'">'.GETPOST('description').'</textarea>';
1021 print '</td></tr>';
1022
1023 // Project
1024 if (isModEnabled('project')) {
1025 $formproject = new FormProjets($db);
1026
1027 $langs->load("project");
1028
1029 print '<tr><td>'.$langs->trans("Project").'</td><td>';
1030 /* 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
1031 if ($societe->fournisseur==1)
1032 $numprojet=select_projects(-1, GETPOST("projectid", 'int'), 'projectid');
1033 else
1034 $numprojet=select_projects($societe->id, GETPOST("projectid", 'int'), 'projectid');
1035 */
1036 $numprojet = $formproject->select_projects($soc->id, $projectid, 'projectid');
1037 if ($numprojet == 0) {
1038 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>';
1039 }
1040 print '</td></tr>';
1041 }
1042
1043 // Contract
1044 if (isModEnabled('contract') && is_object($formcontract)) {
1045 $langs->load("contracts");
1046 print '<tr><td>'.$langs->trans("Contract").'</td><td>';
1047 $numcontrat = $formcontract->select_contract($soc->id, GETPOSTINT('contratid'), 'contratid', 0, 1, 1);
1048 if ($numcontrat == 0) {
1049 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>';
1050 }
1051 print '</td></tr>';
1052 }
1053
1054 // Model
1055 print '<tr>';
1056 print '<td>'.$langs->trans("DefaultModel").'</td>';
1057 print '<td>';
1059 print $form->selectarray('model', $liste, $conf->global->FICHEINTER_ADDON_PDF);
1060 print "</td></tr>";
1061
1062 // Public note
1063 print '<tr>';
1064 print '<td class="tdtop">'.$langs->trans('NotePublic').'</td>';
1065 print '<td>';
1066 $doleditor = new DolEditor('note_public', (string) $note_public, '', 80, 'dolibarr_notes', 'In', false, false, !getDolGlobalString('FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3, '90%');
1067 print $doleditor->Create(1);
1068 //print '<textarea name="note_public" cols="80" rows="'.ROWS_3.'">'.$note_public.'</textarea>';
1069 print '</td></tr>';
1070
1071 // Private note
1072 if (empty($user->socid)) {
1073 print '<tr>';
1074 print '<td class="tdtop">'.$langs->trans('NotePrivate').'</td>';
1075 print '<td>';
1076 $doleditor = new DolEditor('note_private', (string) $note_private, '', 80, 'dolibarr_notes', 'In', false, false, !getDolGlobalString('FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3, '90%');
1077 print $doleditor->Create(1);
1078 //print '<textarea name="note_private" cols="80" rows="'.ROWS_3.'">'.$note_private.'</textarea>';
1079 print '</td></tr>';
1080 }
1081
1082 // Other attributes
1083 $parameters = array();
1084 $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1085 print $hookmanager->resPrint;
1086 if (empty($reshook)) {
1087 print $object->showOptionals($extrafields, 'create');
1088 }
1089
1090 // Show link to origin object
1091 if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
1092 $newclassname = $classname;
1093 if ($newclassname == 'Propal') {
1094 $langs->load('propal');
1095 $newclassname = 'CommercialProposal';
1096 }
1097 print '<tr><td>'.$langs->trans($newclassname).'</td><td colspan="2">'.$objectsrc->getNomUrl(1).'</td></tr>';
1098
1099 // Amount
1100 /* Hide amount because we only copy services so amount may differ than source
1101 print '<tr><td>' . $langs->trans('AmountHT') . '</td><td>' . price($objectsrc->total_ht) . '</td></tr>';
1102 print '<tr><td>' . $langs->trans('AmountVAT') . '</td><td>' . price($objectsrc->total_tva) . "</td></tr>";
1103 if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) // Localtax1 RE
1104 {
1105 print '<tr><td>' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '</td><td>' . price($objectsrc->total_localtax1) . "</td></tr>";
1106 }
1107
1108 if ($mysoc->localtax2_assuj == "1" || $objectsrc->total_localtax2 != 0) // Localtax2 IRPF
1109 {
1110 print '<tr><td>' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '</td><td>' . price($objectsrc->total_localtax2) . "</td></tr>";
1111 }
1112
1113 print '<tr><td>' . $langs->trans('AmountTTC') . '</td><td>' . price($objectsrc->total_ttc) . "</td></tr>";
1114
1115 if (isModEnabled("multicurrency"))
1116 {
1117 print '<tr><td>' . $langs->trans('MulticurrencyAmountHT') . '</td><td>' . price($objectsrc->multicurrency_total_ht) . '</td></tr>';
1118 print '<tr><td>' . $langs->trans('MulticurrencyAmountVAT') . '</td><td>' . price($objectsrc->multicurrency_total_tva) . "</td></tr>";
1119 print '<tr><td>' . $langs->trans('MulticurrencyAmountTTC') . '</td><td>' . price($objectsrc->multicurrency_total_ttc) . "</td></tr>";
1120 }
1121 */
1122 }
1123
1124 print '</table>';
1125
1126 if (is_object($objectsrc)) {
1127 print '<input type="hidden" name="origin" value="'.$objectsrc->element.'">';
1128 print '<input type="hidden" name="originid" value="'.$objectsrc->id.'">';
1129 } elseif ($origin == 'project' && !empty($projectid)) {
1130 print '<input type="hidden" name="projectid" value="'.$projectid.'">';
1131 }
1132
1133 print dol_get_fiche_end();
1134
1135 print $form->buttonsSaveCancel("CreateDraftIntervention");
1136
1137 // Show origin lines
1138 if (!empty($origin) && !empty($originid) && is_object($objectsrc) && !getDolGlobalInt('FICHINTER_DISABLE_DETAILS')) {
1139 $title = $langs->trans('Services');
1140 print load_fiche_titre($title);
1141
1142 print '<div class="div-table-responsive-no-min">';
1143 print '<table class="noborder centpercent">';
1144
1145 $objectsrc->printOriginLinesList(!getDolGlobalString('FICHINTER_PRINT_PRODUCTS') ? 'services' : ''); // Show only service, except if option FICHINTER_PRINT_PRODUCTS is on
1146
1147 print '</table>';
1148 print '</div>';
1149 }
1150
1151 print '</form>';
1152 } else {
1153 print '<form name="fichinter" action="'.$_SERVER['PHP_SELF'].'" method="POST">';
1154 print '<input type="hidden" name="token" value="'.newToken().'">';
1155 print '<input type="hidden" name="action" value="create">'; // We go back to create action
1156 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
1157
1158 print dol_get_fiche_head([]);
1159
1160 if (is_object($objectsrc)) {
1161 print '<input type="hidden" name="origin" value="'.$objectsrc->element.'">';
1162 print '<input type="hidden" name="originid" value="'.$objectsrc->id.'">';
1163 } elseif ($origin == 'project' && !empty($projectid)) {
1164 print '<input type="hidden" name="projectid" value="'.$projectid.'">';
1165 }
1166 print '<table class="border centpercent">';
1167 print '<tr><td class="fieldrequired">'.$langs->trans("ThirdParty").'</td><td>';
1168 $filter = '(s.status:=:1)';
1169
1170 print $form->select_company('', 'socid', $filter, 'SelectThirdParty', 1, 0, array(), 0, 'minwidth300');
1171 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>';
1172 print '</td></tr>';
1173 print '</table>';
1174
1175 print dol_get_fiche_end();
1176
1177 print $form->buttonsSaveCancel("CreateDraftIntervention");
1178
1179 print '</form>';
1180 }
1181} elseif ($id > 0 || !empty($ref)) {
1182 // View mode
1183
1184 $object->fetch($id, $ref);
1185 $object->fetch_thirdparty();
1186
1187 $soc = new Societe($db);
1188 $soc->fetch($object->socid);
1189
1190 if ($error > 0) {
1191 dol_htmloutput_errors($mesg);
1192 } else {
1193 dol_htmloutput_mesg($mesg);
1194 }
1195
1197
1198 print dol_get_fiche_head($head, 'card', $langs->trans("InterventionCard"), -1, 'intervention');
1199
1200 $formconfirm = '';
1201
1202 // Confirm deletion of intervention
1203 if ($action == 'delete') {
1204 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteIntervention'), $langs->trans('ConfirmDeleteIntervention'), 'confirm_delete', '', 0, 1);
1205 }
1206
1207 // Confirm validation
1208 if ($action == 'validate') {
1209 // Verify if the object's number os temporary
1210 $ref = substr($object->ref, 1, 4);
1211 if ($ref == 'PROV') {
1212 $numref = $object->getNextNumRef($soc);
1213 if (empty($numref)) {
1214 $error++;
1215 setEventMessages($object->error, $object->errors, 'errors');
1216 }
1217 } else {
1218 $numref = $object->ref;
1219 }
1220 $text = $langs->trans('ConfirmValidateIntervention', $numref);
1221 if (isModEnabled('notification')) {
1222 require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php';
1223 $notify = new Notify($db);
1224 $text .= '<br>';
1225 $text .= $notify->confirmMessage('FICHINTER_VALIDATE', $object->socid, $object);
1226 }
1227
1228 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateIntervention'), $text, 'confirm_validate', '', 1, 1);
1229 }
1230
1231 // Confirm sign
1232 if ($action == 'sign') {
1233 $text = $langs->trans('ConfirmSignIntervention');
1234 if (isModEnabled('notification')) {
1235 require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php';
1236 $notify = new Notify($db);
1237 $text .= '<br>';
1238 $text .= $notify->confirmMessage('FICHINTER_MODIFY', $object->socid, $object);
1239 }
1240 $formquestion = [];
1241 $formquestion[] = [
1242 'type' => 'select',
1243 'name' => 'signed_status',
1244 'select_show_empty' => 0,
1245 'label' => '<span class="fieldrequired">'.$langs->trans('SignStatus').'</span>',
1246 'values' => $object->getSignedStatusLocalisedArray()
1247 ];
1248 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('SignIntervention'), $text, 'confirm_sign', $formquestion, 0, 1);
1249 }
1250
1251 // Confirm unsign
1252 if ($action == 'unsign') {
1253 $text = $langs->trans('ConfirmUnsignIntervention');
1254 if (isModEnabled('notification')) {
1255 require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php';
1256 $notify = new Notify($db);
1257 $text .= '<br>';
1258 $text .= $notify->confirmMessage('FICHINTER_MODIFY', $object->socid, $object);
1259 }
1260 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('UnsignIntervention'), $text, 'confirm_unsign', '', 0, 1);
1261 }
1262
1263 // Confirm done
1264 if ($action == 'classifydone') {
1265 $text = $langs->trans('ConfirmCloseIntervention');
1266 if (isModEnabled('notification')) {
1267 require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php';
1268 $notify = new Notify($db);
1269 $text .= '<br>';
1270 $text .= $notify->confirmMessage('FICHINTER_CLOSE', $object->socid, $object);
1271 }
1272 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('CloseIntervention'), $text, 'confirm_done', '', 0, 1);
1273 }
1274
1275 // Confirm back to draft
1276 if ($action == 'modify') {
1277 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ModifyIntervention'), $langs->trans('ConfirmModifyIntervention'), 'confirm_modify', '', 0, 1);
1278 }
1279
1280 // Confirm back to open
1281 if ($action == 'reopen') {
1282 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ReOpen'), $langs->trans('ConfirmReopenIntervention', $object->ref), 'confirm_reopen', '', 0, 1);
1283 }
1284
1285 // Confirm deletion of line
1286 if ($action == 'ask_deleteline') {
1287 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&line_id='.$lineid, $langs->trans('DeleteInterventionLine'), $langs->trans('ConfirmDeleteInterventionLine'), 'confirm_deleteline', '', 0, 1);
1288 }
1289
1290 // Clone confirmation
1291 if ($action == 'clone') {
1292 // Create an array for form
1293 $formquestion = array(
1294 // 'text' => $langs->trans("ConfirmClone"),
1295 // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
1296 array(
1297 'type' => 'other',
1298 'name' => 'socid',
1299 'label' => $langs->trans("SelectThirdParty"),
1300 'value' => $form->select_company(GETPOSTINT('socid'), 'socid', '', '', 0, 0, array(), 0, 'minwidth200')
1301 ),
1302 array(
1303 'type' => 'checkbox',
1304 'name' => 'clone_contacts',
1305 'label' => $langs->trans("CloneContacts"),
1306 'value' => 1
1307 ),
1308 array(
1309 'type' => 'checkbox',
1310 'name' => 'clone_notes',
1311 'label' => $langs->trans("CloneNotes"),
1312 'value' => 1
1313 )
1314 );
1315
1316 // Paiement incomplet. On demande si motif = escompte ou autre
1317 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneIntervention', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
1318 }
1319
1320 if (!$formconfirm) {
1321 $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
1322 $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1323 if (empty($reshook)) {
1324 $formconfirm .= $hookmanager->resPrint;
1325 } elseif ($reshook > 0) {
1326 $formconfirm = $hookmanager->resPrint;
1327 }
1328 }
1329
1330 // Print form confirm
1331 print $formconfirm;
1332
1333
1334 // Intervention card
1335 $linkback = '<a href="'.DOL_URL_ROOT.'/fichinter/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
1336
1337
1338 $morehtmlref = '<div class="refidno">';
1339 // Ref customer
1340 $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->hasRight('ficheinter', 'creer'), 'string', '', 0, 1);
1341 $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->hasRight('ficheinter', 'creer'), 'string', '', null, null, '', 1);
1342 // Thirdparty
1343 $morehtmlref .= '<br>'.$object->thirdparty->getNomUrl(1, 'customer');
1344 // Project
1345 if (isModEnabled('project')) {
1346 $langs->load("projects");
1347 $morehtmlref .= '<br>';
1348 if ($permissiontoadd) {
1349 $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
1350 if ($action != 'classify') {
1351 $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
1352 }
1353 $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');
1354 } else {
1355 if (!empty($object->fk_project)) {
1356 $proj = new Project($db);
1357 $proj->fetch($object->fk_project);
1358 $morehtmlref .= $proj->getNomUrl(1);
1359 if ($proj->title) {
1360 $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
1361 }
1362 }
1363 }
1364 }
1365 $morehtmlref .= '</div>';
1366
1367 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
1368
1369
1370 print '<div class="fichecenter">';
1371 print '<div class="fichehalfleft">';
1372 print '<div class="underbanner clearboth"></div>';
1373
1374 print '<table class="border tableforfield centpercent">';
1375
1376 if (getDolGlobalString('FICHINTER_USE_PLANNED_AND_DONE_DATES')) {
1377 // Date Start
1378 print '<tr><td class="titlefield">'.$langs->trans("Dateo").'</td>';
1379 print '<td>';
1380 print $object->dateo ? dol_print_date($object->dateo, 'daytext') : '&nbsp;';
1381 print '</td>';
1382 print '</tr>';
1383
1384 // Date End
1385 print '<tr><td>'.$langs->trans("Datee").'</td>';
1386 print '<td>';
1387 print $object->datee ? dol_print_date($object->datee, 'daytext') : '&nbsp;';
1388 print '</td>';
1389 print '</tr>';
1390
1391 // Date Terminate/close
1392 print '<tr><td>'.$langs->trans("Datet").'</td>';
1393 print '<td>';
1394 print $object->datet ? dol_print_date($object->datet, 'daytext') : '&nbsp;';
1395 print '</td>';
1396 print '</tr>';
1397 }
1398
1399 // Description (must be a textarea and not html must be allowed (used in list view)
1400 print '<tr><td class="titlefield">';
1401 print $form->editfieldkey("Description", 'description', $object->description, $object, $user->hasRight('ficheinter', 'creer'), 'textarea');
1402 print '</td><td>';
1403 print $form->editfieldval("Description", 'description', $object->description, $object, $user->hasRight('ficheinter', 'creer'), 'textarea:8');
1404 print '</td>';
1405 print '</tr>';
1406
1407 // Contract
1408 if (isModEnabled('contract')) {
1409 $langs->load('contracts');
1410 print '<tr>';
1411 print '<td>';
1412
1413 print '<table class="nobordernopadding centpercent"><tr><td>';
1414 print $langs->trans('Contract');
1415 print '</td>';
1416 if ($action != 'editcontract') {
1417 print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editcontract&id='.$object->id.'">';
1418 print img_edit($langs->trans('SetContract'), 1);
1419 print '</a></td>';
1420 }
1421 print '</tr></table>';
1422 print '</td><td>';
1423 if ($action == 'editcontract') {
1424 $formcontract = new FormContract($db);
1425 $formcontract->formSelectContract($_SERVER["PHP_SELF"].'?id='.$object->id, $object->socid, $object->fk_contrat, 'contratid', 0, 1, 1);
1426 } else {
1427 if ($object->fk_contrat) {
1428 $contratstatic = new Contrat($db);
1429 $contratstatic->fetch($object->fk_contrat);
1430 //print '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$selected.'">'.$projet->title.'</a>';
1431 print $contratstatic->getNomUrl(0, 0, 1);
1432 } else {
1433 print "&nbsp;";
1434 }
1435 }
1436 print '</td>';
1437 print '</tr>';
1438 }
1439
1440 // Other attributes
1441 $cols = 2;
1442 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
1443
1444 print '</table>';
1445
1446 print '</div>';
1447 print '<div class="fichehalfright">';
1448 print '<div class="underbanner clearboth"></div>';
1449
1450 print '<table class="border tableforfield centpercent">';
1451
1452 if (!getDolGlobalString('FICHINTER_DISABLE_DETAILS') || getDolGlobalString('FICHINTER_DISABLE_DETAILS') == '2') {
1453 // Duration in time
1454 print '<tr><td class="titlefield">'.$langs->trans("TotalDuration").'</td>';
1455 print '<td>'.convertSecondToTime($object->duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY).' ('.convertDurationtoHour($object->duration, "s").' '.$langs->trans("HourShort").')</td>';
1456 print '</tr>';
1457 }
1458
1459 print "</table>";
1460
1461 print '</div>';
1462 print '</div>';
1463
1464 print '<div class="clearboth"></div><br>';
1465
1466
1467 if (getDolGlobalString('MAIN_DISABLE_CONTACTS_TAB')) {
1468 $blocname = 'contacts';
1469 $title = $langs->trans('ContactsAddresses');
1470 include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php';
1471 }
1472
1473 if (getDolGlobalString('MAIN_DISABLE_NOTES_TAB')) {
1474 $blocname = 'notes';
1475 $title = $langs->trans('Notes');
1476 include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php';
1477 }
1478
1479 // Line of interventions
1480 if (!getDolGlobalString('FICHINTER_DISABLE_DETAILS') || getDolGlobalString('FICHINTER_DISABLE_DETAILS') == '2') {
1481 print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" name="addinter" method="post">';
1482 print '<input type="hidden" name="token" value="'.newToken().'">';
1483 print '<input type="hidden" name="id" value="'.$object->id.'">';
1484 if ($action == 'editline') {
1485 print '<input type="hidden" name="action" value="updateline">';
1486 print '<input type="hidden" name="line_id" value="'.GETPOSTINT('line_id').'">';
1487 } else {
1488 print '<input type="hidden" name="action" value="addline">';
1489 }
1490 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
1491
1492 // Intervention lines
1493 $sql = 'SELECT ft.rowid, ft.description, ft.fk_fichinter, ft.duree, ft.rang,';
1494 $sql .= ' ft.date as date_intervention';
1495 $sql .= ' FROM '.MAIN_DB_PREFIX.'fichinterdet as ft';
1496 $sql .= ' WHERE ft.fk_fichinter = '.((int) $object->id);
1497 if (getDolGlobalString('FICHINTER_HIDE_EMPTY_DURATION')) {
1498 $sql .= ' AND ft.duree <> 0';
1499 }
1500 $sql .= ' ORDER BY ft.rang ASC, ft.date ASC, ft.rowid';
1501
1502 $resql = $db->query($sql);
1503 if ($resql) {
1504 $num = $db->num_rows($resql);
1505 $i = 0;
1506
1507 if ($num) {
1508 print '<br>';
1509 print '<table class="noborder centpercent">';
1510 print '<tr class="liste_titre">';
1511
1512 // No.
1513 if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER')) {
1514 print '<td width="5" class="center linecolnum"></td>';
1515 }
1516
1517 print '<td class="liste_titre">'.$langs->trans('Description').'</td>';
1518 print '<td class="liste_titre center">'.$langs->trans('Date').'</td>';
1519 print '<td class="liste_titre right">'.(!getDolGlobalString('FICHINTER_WITHOUT_DURATION') ? $langs->trans('Duration') : '').'</td>';
1520 print '<td class="liste_titre">&nbsp;</td>';
1521 print '<td class="liste_titre">&nbsp;</td>';
1522 print "</tr>\n";
1523 }
1524 while ($i < $num) {
1525 $objp = $db->fetch_object($resql);
1526
1527 // Ligne en mode visu
1528 if ($action != 'editline' || GETPOSTINT('line_id') != $objp->rowid) {
1529 print '<tr class="oddeven">';
1530
1531 // No.
1532 if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER')) {
1533 print '<td class="center linecolnum">'.($i + 1).'</td>';
1534 }
1535
1536 print '<td>';
1537 print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne
1538 print dol_htmlentitiesbr($objp->description);
1539
1540 $objectline = new FichinterLigne($db);
1541 $objectline->fetch($objp->rowid);
1542 $objectline->fetch_optionals();
1543
1544 $extrafields->fetch_name_optionals_label($objectline->table_element);
1545
1546 $temps = $objectline->showOptionals($extrafields, 'view', array(), '', '', '1', 'line');
1547 if (!empty($temps)) {
1548 print '<div style="padding-top: 10px" id="extrafield_lines_area_'.$objp->rowid.'" name="extrafield_lines_area_'.$objp->rowid.'">';
1549 print $temps;
1550 print '</div>';
1551 }
1552
1553 print '</td>';
1554
1555 // Date
1556 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>';
1557
1558 // Duration
1559 print '<td class="right" width="150">'.(!getDolGlobalString('FICHINTER_WITHOUT_DURATION') ? convertSecondToTime($objp->duree) : '').'</td>';
1560
1561 print "</td>\n";
1562
1563 // Icon to edit and delete
1564 if ($object->status == 0 && $user->hasRight('ficheinter', 'creer')) {
1565 print '<td class="center">';
1566 print '<a class="editfielda marginrightonly" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=editline&token='.newToken().'&line_id='.$objp->rowid.'#'.$objp->rowid.'">';
1567 print img_edit();
1568 print '</a>';
1569 print '<a class="marginleftonly" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=ask_deleteline&token='.newToken().'&line_id='.$objp->rowid.'">';
1570 print img_delete();
1571 print '</a></td>';
1572 print '<td class="center">';
1573 if ($num > 1) {
1574 if ($i > 0) {
1575 print '<a class="marginleftonly" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=up&token='.newToken().'&line_id='.$objp->rowid.'">';
1576 print img_up();
1577 print '</a>';
1578 }
1579 if ($i < $num - 1) {
1580 print '<a class="marginleftonly" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=down&token='.newToken().'&line_id='.$objp->rowid.'">';
1581 print img_down();
1582 print '</a>';
1583 }
1584 }
1585 print '</td>';
1586 } else {
1587 print '<td colspan="2">&nbsp;</td>';
1588 }
1589
1590 print '</tr>';
1591 }
1592
1593 // Line in update mode
1594 if ($object->status == 0 && $action == 'editline' && $user->hasRight('ficheinter', 'creer') && GETPOSTINT('line_id') == $objp->rowid) {
1595 print '<tr class="oddeven nohover">';
1596
1597 // No.
1598 if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER')) {
1599 print '<td class="center linecolnum">'.($i + 1).'</td>';
1600 }
1601
1602 print '<td>';
1603 print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne
1604
1605 // Editeur wysiwyg
1606 require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
1607 $doleditor = new DolEditor('np_desc', $objp->description, '', 164, 'dolibarr_details', '', false, true, getDolGlobalInt('FCKEDITOR_ENABLE_DETAILS'), ROWS_2, '90%');
1608 $doleditor->Create();
1609
1610 $objectline = new FichinterLigne($db);
1611 $objectline->fetch($objp->rowid);
1612 $objectline->fetch_optionals();
1613
1614 $extrafields->fetch_name_optionals_label($objectline->table_element);
1615
1616 $temps = $objectline->showOptionals($extrafields, 'edit', array(), '', '', '1', 'line');
1617 if (!empty($temps)) {
1618 print '<div style="padding-top: 10px" id="extrafield_lines_area_'.$line->id.'" name="extrafield_lines_area_'.$line->id.'">';
1619 print $temps;
1620 print '</div>';
1621 }
1622
1623 print '</td>';
1624
1625 // Date d'intervention
1626 print '<td class="center nowrap">';
1627 if (getDolGlobalString('FICHINTER_DATE_WITHOUT_HOUR')) {
1628 print $form->selectDate($db->jdate($objp->date_intervention), 'di', 0, 0, 0, "date_intervention");
1629 } else {
1630 print $form->selectDate($db->jdate($objp->date_intervention), 'di', 1, 1, 0, "date_intervention");
1631 }
1632 print '</td>';
1633
1634 // Duration
1635 print '<td class="right">';
1636 if (!getDolGlobalString('FICHINTER_WITHOUT_DURATION')) {
1637 $selectmode = 'select';
1638 if (getDolGlobalString('INTERVENTION_ADDLINE_FREEDUREATION')) {
1639 $selectmode = 'text';
1640 }
1641 $form->select_duration('duration', $objp->duree, 0, $selectmode);
1642 }
1643 print '</td>';
1644
1645 print '<td class="center" colspan="5" valign="center">';
1646 print '<input type="submit" class="button buttongen marginbottomonly button-save" name="save" value="'.$langs->trans("Save").'">';
1647 print '<input type="submit" class="button buttongen marginbottomonly button-cancel" name="cancel" value="'.$langs->trans("Cancel").'"></td>';
1648 print '</tr>'."\n";
1649 }
1650
1651 $i++;
1652 }
1653
1654 $db->free($resql);
1655
1656 // Add new line
1657 if ($object->status == 0 && $user->hasRight('ficheinter', 'creer') && $action != 'editline' && (!getDolGlobalString('FICHINTER_DISABLE_DETAILS') || getDolGlobalString('FICHINTER_DISABLE_DETAILS') == '2')) {
1658 if (!$num) {
1659 print '<br>';
1660 print '<table class="noborder centpercent">';
1661 print '<tr class="liste_titre">';
1662
1663 // No.
1664 if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER')) {
1665 print '<td width="5" class="center linecolnum"></td>';
1666 }
1667
1668 print '<td>';
1669 print '<a name="add"></a>'; // ancre
1670 print $langs->trans('Description').'</td>';
1671 print '<td class="center">'.$langs->trans('Date').'</td>';
1672 print '<td class="right">'.(!getDolGlobalString('FICHINTER_WITHOUT_DURATION') ? $langs->trans('Duration') : '').'</td>';
1673 print '<td colspan="3">&nbsp;</td>';
1674 print "</tr>\n";
1675 }
1676
1677 print '<tr class="oddeven nohover">'."\n";
1678
1679 // No.
1680 if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER')) {
1681 print '<td class="center linecolnum">'.($i + 1).'</td>';
1682 }
1683
1684 print '<td>';
1685 // editeur wysiwyg
1686 if (!getDolGlobalString('FICHINTER_EMPTY_LINE_DESC')) {
1687 require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
1688 $doleditor = new DolEditor('np_desc', GETPOST('np_desc', 'restricthtml'), '', 100, 'dolibarr_details', '', false, true, getDolGlobalString('FCKEDITOR_ENABLE_DETAILS'), ROWS_2, '90%');
1689 $doleditor->Create();
1690 }
1691
1692 $objectline = new FichinterLigne($db);
1693 $extrafields->fetch_name_optionals_label($objectline->table_element);
1694
1695 if (is_object($objectline)) {
1696 $temps = $objectline->showOptionals($extrafields, 'create', array(), '', '', '1', 'line');
1697
1698 if (!empty($temps)) {
1699 print '<div style="padding-top: 10px" id="extrafield_lines_area_create" name="extrafield_lines_area_create">';
1700 print $temps;
1701 print '</div>';
1702 }
1703 }
1704
1705 print '</td>';
1706
1707 // Date intervention
1708 print '<td class="center nowrap">';
1709 $now = dol_now();
1710 $timearray = dol_getdate($now);
1711 if (!GETPOSTINT('diday')) {
1712 if (getDolGlobalInt('FICHINTER_DATE_WITHOUT_HOUR')) {
1713 $timewithnohour = dol_mktime(0, 0, 0, $timearray['mon'], $timearray['mday'], $timearray['year']);
1714 } else {
1715 $timewithnohour = dol_mktime($timearray['hours'], $timearray['minutes'], 0, $timearray['mon'], $timearray['mday'], $timearray['year']);
1716 }
1717 } else {
1718 $timewithnohour = dol_mktime(GETPOSTINT('dihour'), GETPOSTINT('dimin'), 0, GETPOSTINT('dimonth'), GETPOSTINT('diday'), GETPOSTINT('diyear'));
1719 }
1720 if (getDolGlobalInt('FICHINTER_DATE_WITHOUT_HOUR')) {
1721 print $form->selectDate($timewithnohour, 'di', 0, 0, 0, "addinter");
1722 } else {
1723 print $form->selectDate($timewithnohour, 'di', 1, 1, 0, "addinter");
1724 }
1725 print '</td>';
1726
1727 // Duration
1728 print '<td class="right">';
1729 if (!getDolGlobalString('FICHINTER_WITHOUT_DURATION')) {
1730 $selectmode = 'select';
1731 if (getDolGlobalString('INTERVENTION_ADDLINE_FREEDUREATION')) {
1732 $selectmode = 'text';
1733 }
1734 $form->select_duration('duration', (!GETPOSTINT('durationhour') && !GETPOSTINT('durationmin')) ? 3600 : (60 * 60 * GETPOSTINT('durationhour') + 60 * GETPOSTINT('durationmin')), 0, $selectmode);
1735 }
1736 print '</td>';
1737
1738 print '<td class="center" valign="middle" colspan="3"><input type="submit" class="button button-add" value="'.$langs->trans('Add').'" name="addline"></td>';
1739 print '</tr>';
1740
1741 if (!$num) {
1742 print '</table>';
1743 }
1744 }
1745
1746 if ($num) {
1747 print '</table>';
1748 }
1749 } else {
1750 dol_print_error($db);
1751 }
1752
1753 print '</form>'."\n";
1754 }
1755
1756 print dol_get_fiche_end();
1757
1758 print "\n";
1759
1760
1761 /*
1762 * Actions buttons
1763 */
1764
1765 print '<div class="tabsAction">';
1766
1767 $parameters = array();
1768 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
1769 // modified by hook
1770 if (empty($reshook)) {
1771 $params = array();
1772 if ($user->socid == 0) {
1773 if ($action != 'editdescription' && ($action != 'presend')) {
1774 // Validate
1775 if ($object->status == Fichinter::STATUS_DRAFT && (count($object->lines) > 0 || getDolGlobalString('FICHINTER_DISABLE_DETAILS') == '1')) {
1776 if ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('ficheinter', 'creer')) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('ficheinter', 'ficheinter_advance', 'validate'))) {
1777 print '<div class="inline-block divButAction"><a class="butAction" href="card.php?id='.$object->id.'&action=validate&token='.newToken().'">'.$langs->trans("Validate").'</a></div>';
1778 } else {
1779 print '<div class="inline-block divButActionRefused"><span class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("Validate").'</span></div>';
1780 }
1781 }
1782
1783 // Modify
1784 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')))) {
1785 print '<div class="inline-block divButAction"><a class="butAction" href="card.php?id='.$object->id.'&action=modify&token='.newToken().'">';
1786 if (!getDolGlobalString('FICHINTER_DISABLE_DETAILS') || getDolGlobalString('FICHINTER_DISABLE_DETAILS') == '2') {
1787 print $langs->trans("Modify");
1788 } else {
1789 print $langs->trans("SetToDraft");
1790 }
1791 print '</a></div>';
1792 }
1793
1794 // Reopen
1795 if ($object->status >= Fichinter::STATUS_CLOSED) {
1796 if ($user->hasRight('ficheinter', 'creer')) {
1797 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>';
1798 } else {
1799 print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans('ReOpen').'</a></div>';
1800 }
1801 }
1802
1803 // Send
1804 if (empty($user->socid)) {
1805 if ($object->status > Fichinter::STATUS_DRAFT) {
1806 if (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') || $user->hasRight('ficheinter', 'ficheinter_advance', 'send')) {
1807 print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&token='.newToken().'&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a></div>';
1808 } else {
1809 print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans('SendMail').'</a></div>';
1810 }
1811 }
1812 }
1813
1814 // Create intervention model
1815 if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 1 && $object->status == Fichinter::STATUS_DRAFT && $user->hasRight('ficheinter', 'creer') && (count($object->lines) > 0)) {
1816 print '<div class="inline-block divButAction">';
1817 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>';
1818 print '</div>';
1819 }
1820
1821 $arrayofcreatebutton = array();
1822 // Proposal
1823 if (isModEnabled("service") && isModEnabled("propal") && $object->status > Fichinter::STATUS_DRAFT) {
1824 $langs->load("propal");
1825 if ($object->status < Fichinter::STATUS_BILLED) {
1826 $arrayofcreatebutton[] = array(
1827 'url' => '/comm/propal/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid,
1828 'label' => $langs->trans('AddProp'),
1829 'lang' => 'propal',
1830 'perm' => $user->hasRight('propal', 'creer'),
1831 'enabled' => true,
1832 );
1833 }
1834 }
1835
1836 // Invoicing
1837 if (isModEnabled('invoice') && $object->status > Fichinter::STATUS_DRAFT) {
1838 $langs->load("bills");
1839 if ($object->status < Fichinter::STATUS_BILLED) {
1840 $arrayofcreatebutton[] = array(
1841 'url' => '/compta/facture/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid,
1842 'label' => $langs->trans('AddBill'),
1843 'lang' => 'bills',
1844 'perm' => $user->hasRight('facture', 'creer') ? true : false,
1845 'enabled' => true,
1846 );
1847 }
1848
1849 if (getDolGlobalString('FICHINTER_CLASSIFY_BILLED')) { // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1
1850 if ($object->status != Fichinter::STATUS_BILLED) {
1851 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>';
1852 } else {
1853 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>';
1854 }
1855 }
1856 }
1857
1858 if (count($arrayofcreatebutton)) {
1859 print dolGetButtonAction('', $langs->trans("Create"), 'default', $arrayofcreatebutton, '', true, $params);
1860 }
1861
1862 // Sign
1863 if ($object->status > Fichinter::STATUS_DRAFT) {
1864 if ($object->signed_status != Fichinter::$SIGNED_STATUSES['STATUS_SIGNED_ALL']) {
1865 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>';
1866 } else {
1867 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>';
1868 }
1869 }
1870
1871 // Done
1872 if (!getDolGlobalString('FICHINTER_CLASSIFY_BILLED') && $object->status > Fichinter::STATUS_DRAFT && $object->status < Fichinter::STATUS_CLOSED) {
1873 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>';
1874 }
1875
1876 // Clone
1877 if ($user->hasRight('ficheinter', 'creer')) {
1878 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>';
1879 }
1880
1881 // Delete
1882 print '<div class="inline-block divButAction">';
1883 print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $permissiontodelete);
1884 print '</div>';
1885 }
1886 }
1887 }
1888
1889 print '</div>';
1890
1891 if ($action != 'presend') {
1892 print '<div class="fichecenter"><div class="fichehalfleft">';
1893
1894 /*
1895 * Built documents
1896 */
1897 $filename = dol_sanitizeFileName($object->ref);
1898 $filedir = $conf->ficheinter->dir_output."/".$filename;
1899 $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
1900 $genallowed = $user->hasRight('ficheinter', 'lire');
1901 $delallowed = $user->hasRight('ficheinter', 'creer');
1902 print $formfile->showdocuments('ficheinter', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang);
1903
1904 // Show links to link elements
1905 $tmparray = $form->showLinkToObjectBlock($object, array(), array('fichinter'), 1);
1906 $linktoelem = $tmparray['linktoelem'];
1907 $htmltoenteralink = $tmparray['htmltoenteralink'];
1908 print $htmltoenteralink;
1909
1910 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
1911
1912 // Show direct download link
1913 if ($object->status != Fichinter::STATUS_DRAFT && getDolGlobalString('FICHINTER_ALLOW_EXTERNAL_DOWNLOAD')) {
1914 print '<br><!-- Link to download main doc -->'."\n";
1915 print showDirectDownloadLink($object).'<br>';
1916 }
1917
1918 // Show online signature link
1919 if ($object->status != Fichinter::STATUS_DRAFT && getDolGlobalString('FICHINTER_ALLOW_ONLINE_SIGN')) {
1920 print '<br><!-- Link to sign -->';
1921 require_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php';
1922
1923 print showOnlineSignatureUrl('fichinter', $object->ref, $object).'<br>';
1924 }
1925
1926 print '</div><div class="fichehalfright">';
1927
1928 $MAXEVENT = 10;
1929
1930 $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/fichinter/agenda.php?id='.$object->id);
1931
1932 // List of actions on element
1933 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
1934 $formactions = new FormActions($db);
1935 $somethingshown = $formactions->showactions($object, 'fichinter', $socid, 1, '', $MAXEVENT, '', $morehtmlcenter); // Show all action for thirdparty
1936
1937 print '</div></div>';
1938 }
1939
1940
1941 // Select mail models is same action as presend
1942 if (GETPOST('modelselected')) {
1943 $action = 'presend';
1944 }
1945
1946 // Presend form
1947 $modelmail = 'fichinter_send';
1948 $defaulttopic = 'SendInterventionRef';
1949 $diroutput = $conf->ficheinter->dir_output;
1950 $trackid = 'int'.$object->id;
1951
1952 include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
1953}
1954
1955
1956llxFooter();
1957
1958$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:67
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:338
convertTime2Seconds($iHours=0, $iMinutes=0, $iSeconds=0)
Convert hours and minutes into seconds.
Definition date.lib.php:215
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:244
fichinter_prepare_head($object)
Prepare array with list of tabs.
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...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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.
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.
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.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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.
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_clone($object, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
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.