* Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2005-2018 Regis Houssin * Copyright (C) 2011-2020 Juanjo Menent * Copyright (C) 2013 Florian Henry * Copyright (C) 2014-2018 Ferran Marcet * Copyright (C) 2014-2022 Charlene Benke * Copyright (C) 2015-2016 Abbes Bahfir * Copyright (C) 2018-2022 Philippe Grand * Copyright (C) 2020-2024 Frédéric France * Copyright (C) 2023 Benjamin Grembi * Copyright (C) 2023-2024 William Mead * Copyright (C) 2024 MDW * Copyright (C) 2024 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file htdocs/fichinter/card.php * \brief Page of intervention * \ingroup ficheinter */ // Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/fichinter/modules_fichinter.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/fichinter.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; if (isModEnabled('project')) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } if (isModEnabled('contract')) { require_once DOL_DOCUMENT_ROOT."/core/class/html.formcontract.class.php"; require_once DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php"; } if (getDolGlobalString('FICHEINTER_ADDON') && is_readable(DOL_DOCUMENT_ROOT."/core/modules/fichinter/mod_" . getDolGlobalString('FICHEINTER_ADDON').".php")) { require_once DOL_DOCUMENT_ROOT."/core/modules/fichinter/mod_" . getDolGlobalString('FICHEINTER_ADDON').'.php'; } require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; // Load translation files required by the page $langs->loadLangs(array('bills', 'companies', 'interventions', 'stocks')); $id = GETPOSTINT('id'); $ref = GETPOST('ref', 'alpha'); $ref_client = GETPOST('ref_client', 'alpha'); $socid = GETPOSTINT('socid'); $contratid = GETPOSTINT('contratid'); $action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); $mesg = GETPOST('msg', 'alpha'); $origin = GETPOST('origin', 'alpha'); $originid = (GETPOSTINT('originid') ? GETPOSTINT('originid') : GETPOSTINT('origin_id')); // For backward compatibility $note_public = GETPOST('note_public', 'restricthtml'); $note_private = GETPOST('note_private', 'restricthtml'); $lineid = GETPOSTINT('line_id'); $error = 0; //PDF $hidedetails = (GETPOSTINT('hidedetails') ? GETPOSTINT('hidedetails') : (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS') ? 1 : 0)); $hidedesc = (GETPOSTINT('hidedesc') ? GETPOSTINT('hidedesc') : (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_DESC') ? 1 : 0)); $hideref = (GETPOSTINT('hideref') ? GETPOSTINT('hideref') : (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_REF') ? 1 : 0)); // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context $hookmanager->initHooks(array('interventioncard', 'globalcard')); $object = new Fichinter($db); $extrafields = new ExtraFields($db); $objectsrc = null; $extrafields->fetch_name_optionals_label($object->table_element); // Load object if ($id > 0 || !empty($ref)) { $ret = $object->fetch($id, $ref); if ($ret > 0) { $ret = $object->fetch_thirdparty(); } if ($ret < 0) { dol_print_error(null, $object->error); } } // Security check if ($user->socid) { $socid = $user->socid; } $result = restrictedArea($user, 'ficheinter', $id, 'fichinter'); $permissionnote = $user->hasRight('ficheinter', 'creer'); // Used by the include of actions_setnotes.inc.php $permissiondellink = $user->hasRight('ficheinter', 'creer'); // Used by the include of actions_dellink.inc.php $permissiontodelete = (($object->statut == Fichinter::STATUS_DRAFT && $user->hasRight('ficheinter', 'creer')) || $user->hasRight('ficheinter', 'supprimer')); $permissiontoadd = $user->hasRight('ficheinter', 'creer'); $usercancreate = $user->hasRight('ficheinter', 'creer'); /* * Actions */ $parameters = array('socid' => $socid); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } if (empty($reshook)) { $backurlforlist = DOL_URL_ROOT.'/fichinter/list.php'; if (empty($backtopage) || ($cancel && empty($id))) { if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) { $backtopage = $backurlforlist; } else { $backtopage = DOL_URL_ROOT.'/fichinter/card.php?id='.((!empty($id) && $id > 0) ? $id : '__ID__'); } } } if ($cancel) { if (!empty($backtopageforcancel)) { header("Location: ".$backtopageforcancel); exit; } elseif (!empty($backtopage)) { header("Location: ".$backtopage); exit; } $action = ''; } include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be 'include', not 'include_once' include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be 'include', not 'include_once' // Action clone object if ($action == 'confirm_clone' && $confirm == 'yes' && $permissiontoadd) { if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers')) { setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); } else { if ($object->id > 0) { // Because createFromClone modifies the object, we must clone it so that we can restore it later $orig = clone $object; $result = $object->createFromClone($user, $socid); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); exit; } else { setEventMessages($object->error, $object->errors, 'errors'); $object = $orig; $action = ''; } } } } if ($action == 'confirm_validate' && $confirm == 'yes' && $permissiontoadd) { $result = $object->setValid($user); if ($result >= 0) { if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) { // Define output language $outputlangs = $langs; $newlang = ''; if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } $result = fichinter_create($db, $object, (!GETPOST('model', 'alpha')) ? $object->model_pdf : GETPOST('model', 'alpha'), $outputlangs); } header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; } else { $mesg = $object->error; } } elseif ($action == 'confirm_sign' && $confirm == 'yes' && $permissiontoadd) { $result = $object->setSignedStatus($user, GETPOSTINT('signed_status'), 0, 'FICHINTER_MODIFY'); if ($result >= 0) { if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) { // Define output language $outputlangs = $langs; $newlang = ''; if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } $result = fichinter_create($db, $object, (!GETPOST('model', 'alpha')) ? $object->model_pdf : GETPOST('model', 'alpha'), $outputlangs); } header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id); exit; } else { $mesg = $object->error; } } elseif ($action == 'confirm_unsign' && $confirm == 'yes' && $permissiontoadd) { $result = $object->setSignedStatus($user, $object::SIGNED_STATUSES['STATUS_NO_SIGNATURE'], 0, 'FICHINTER_MODIFY'); if ($result >= 0) { if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) { // Define output language $outputlangs = $langs; $newlang = ''; if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } $result = fichinter_create($db, $object, (!GETPOST('model', 'alpha')) ? $object->model_pdf : GETPOST('model', 'alpha'), $outputlangs); } header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id); exit; } else { $mesg = $object->error; } } elseif ($action == 'confirm_modify' && $confirm == 'yes' && $permissiontoadd) { $result = $object->setDraft($user); if ($result >= 0) { if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) { // Define output language $outputlangs = $langs; $newlang = ''; if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } $result = fichinter_create($db, $object, (!GETPOST('model', 'alpha')) ? $object->model_pdf : GETPOST('model', 'alpha'), $outputlangs); } header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id); exit; } else { $mesg = $object->error; } } elseif ($action == 'confirm_done' && $confirm == 'yes' && $permissiontoadd) { $result = $object->setClose($user); if ($result >= 0) { if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) { // Define output language $outputlangs = $langs; $newlang = ''; if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } $result = fichinter_create($db, $object, (!GETPOST('model', 'alpha')) ? $object->model_pdf : GETPOST('model', 'alpha'), $outputlangs); } header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; } else { $mesg = $object->error; } } elseif ($action == 'add' && $permissiontoadd) { $selectedLines = GETPOST('toselect', 'array'); $object->socid = $socid; $object->duration = GETPOSTINT('duration'); $object->fk_project = GETPOSTINT('projectid'); $object->fk_contrat = GETPOSTINT('contratid'); $object->user_author_id = $user->id; $object->description = GETPOST('description', 'restricthtml'); $object->ref = $ref; $object->ref_client = $ref_client; $object->model_pdf = GETPOST('model', 'alpha'); $object->note_private = GETPOST('note_private', 'restricthtml'); $object->note_public = GETPOST('note_public', 'restricthtml'); if ($object->socid > 0) { // If creation from another object of another module (Example: origin=propal, originid=1) if (!empty($origin) && !empty($originid)) { // Parse element/subelement (ex: project_task) $regs = array(); $element = $subelement = GETPOST('origin', 'alphanohtml'); if (preg_match('/^([^_]+)_([^_]+)/i', GETPOST('origin', 'alphanohtml'), $regs)) { $element = $regs[1]; $subelement = $regs[2]; } // For compatibility if ($element == 'order') { $element = $subelement = 'commande'; } if ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; } if ($element == 'contract') { $element = $subelement = 'contrat'; } $object->origin = $origin; $object->origin_id = $originid; // Possibility to add external linked objects with hooks $object->linked_objects[$object->origin] = $object->origin_id; if (GETPOSTISARRAY('other_linked_objects')) { $object->linked_objects = array_merge($object->linked_objects, GETPOST('other_linked_objects', 'array:int')); } // Extrafields // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) { $error++; $action = 'create'; } //$array_options = $extrafields->getOptionalsFromPost($object->table_element); //$object->array_options = $array_options; $id = $object->create($user); if ($id > 0) { dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); $classname = ucfirst($subelement); $srcobject = new $classname($db); dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines"); $result = $srcobject->fetch($object->origin_id); if ($result > 0) { $srcobject->fetch_thirdparty(); $lines = $srcobject->lines; if (empty($lines) && method_exists($srcobject, 'fetch_lines')) { $srcobject->fetch_lines(); $lines = $srcobject->lines; } if (is_array($lines)) { $num = count($lines); for ($i = 0; $i < $num; $i++) { if (!in_array($lines[$i]->id, $selectedLines)) { continue; // Skip unselected lines } $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : Product::TYPE_PRODUCT); if ($product_type == Product::TYPE_SERVICE || getDolGlobalString('FICHINTER_PRINT_PRODUCTS')) { //only services except if config includes products $duration = 3600; // Default to one hour $desc = ''; // Predefined products & services if ($lines[$i]->fk_product > 0) { $prod = new Product($db); $prod->id = $lines[$i]->fk_product; // Define output language if (getDolGlobalInt('MAIN_MULTILANGS') && getDolGlobalString('PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE')) { $prod->getMultiLangs(); // We show if duration is present on service (so we get it) $prod->fetch($lines[$i]->fk_product); $outputlangs = $langs; $newlang = ''; if (empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } if (empty($newlang)) { $newlang = $srcobject->thirdparty->default_lang; } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } $label = (!empty($prod->multilangs[$outputlangs->defaultlang]["libelle"])) ? $prod->multilangs[$outputlangs->defaultlang]["libelle"] : $lines[$i]->product_label; } else { $prod->fetch($lines[$i]->fk_product); $label = $lines[$i]->product_label; } if ($prod->duration_value && $conf->global->FICHINTER_USE_SERVICE_DURATION) { switch ($prod->duration_unit) { default: case 'h': $mult = 3600; break; case 'd': $mult = 3600 * 24; break; case 'w': $mult = 3600 * 24 * 7; break; case 'm': $mult = (int) (3600 * 24 * (365 / 12)); // Average month duration break; case 'y': $mult = 3600 * 24 * 365; break; } $duration = (int) $prod->duration_value * $mult * $lines[$i]->qty; } $desc = $lines[$i]->product_ref; $desc .= ' - '; $desc .= $label; $desc .= '
'; } // Common part (predefined or free line) $desc .= dol_htmlentitiesbr($lines[$i]->desc); $desc .= '
'; $desc .= ' ('.$langs->trans('Quantity').': '.$lines[$i]->qty.')'; $timearray = dol_getdate(dol_now()); $date_intervention = dol_mktime(0, 0, 0, $timearray['mon'], $timearray['mday'], $timearray['year']); if ($product_type == Product::TYPE_PRODUCT) { $duration = 0; } $predef = ''; // Extrafields $extrafields->fetch_name_optionals_label($object->table_element_line); $array_options = $extrafields->getOptionalsFromPost($object->table_element_line, $predef); $result = $object->addline( $user, $id, $desc, $date_intervention, $duration, $array_options ); if ($result < 0) { $error++; break; } } } } } else { $langs->load("errors"); setEventMessages($srcobject->error, $srcobject->errors, 'errors'); $action = 'create'; $error++; } } else { $langs->load("errors"); setEventMessages($object->error, $object->errors, 'errors'); $action = 'create'; $error++; } } else { // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) { $error++; $action = 'create'; } if (!$error) { // Extrafields $array_options = $extrafields->getOptionalsFromPost($object->table_element); $object->array_options = $array_options; $result = $object->create($user); if ($result > 0) { $id = $result; // Force raffraichissement sur fiche venant d'etre cree } else { $langs->load("errors"); setEventMessages($object->error, $object->errors, 'errors'); $action = 'create'; $error++; } } } } else { $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ThirdParty")); $action = 'create'; $error++; } } elseif ($action == 'update' && $permissiontoadd) { $object->socid = $socid; $object->fk_project = GETPOSTINT('projectid'); $object->fk_contrat = GETPOSTINT('contratid'); $object->user_author_id = $user->id; $object->description = GETPOST('description', 'restricthtml'); $object->ref = $ref; $object->ref_client = $ref_client; $result = $object->update($user); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } } elseif ($action == 'classin' && $permissiontoadd) { // Set into a project $result = $object->setProject(GETPOSTINT('projectid')); if ($result < 0) { dol_print_error($db, $object->error); } } elseif ($action == 'setcontract' && $permissiontoadd) { // Set into a contract $result = $object->set_contrat($user, GETPOSTINT('contratid')); if ($result < 0) { dol_print_error($db, $object->error); } } elseif ($action == 'setref_client' && $permissiontoadd) { // Positionne ref client $result = $object->setRefClient($user, GETPOST('ref_client', 'alpha')); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } } elseif ($action == 'confirm_delete' && $confirm == 'yes' && $user->hasRight('ficheinter', 'supprimer')) { $result = $object->delete($user); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } header('Location: '.DOL_URL_ROOT.'/fichinter/list.php?leftmenu=ficheinter&restore_lastsearch_values=1'); exit; } elseif ($action == 'setdescription' && $permissiontoadd) { $result = $object->set_description($user, GETPOST('description')); if ($result < 0) { dol_print_error($db, $object->error); } } elseif ($action == "addline" && $permissiontoadd) { // Add line if (!GETPOST('np_desc', 'restricthtml') && !getDolGlobalString('FICHINTER_EMPTY_LINE_DESC')) { $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description")); $error++; } if (!getDolGlobalString('FICHINTER_WITHOUT_DURATION') && !GETPOSTINT('durationhour') && !GETPOSTINT('durationmin')) { $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Duration")); $error++; } if (!getDolGlobalString('FICHINTER_WITHOUT_DURATION') && GETPOSTINT('durationhour') >= 24 && GETPOSTINT('durationmin') > 0) { $mesg = $langs->trans("ErrorValueTooHigh"); $error++; } if (!$error) { $db->begin(); $desc = GETPOST('np_desc', 'restricthtml'); $date_intervention = dol_mktime(GETPOSTINT('dihour'), GETPOSTINT('dimin'), 0, GETPOSTINT('dimonth'), GETPOSTINT('diday'), GETPOSTINT('diyear')); $duration = !getDolGlobalString('FICHINTER_WITHOUT_DURATION') ? convertTime2Seconds(GETPOSTINT('durationhour'), GETPOSTINT('durationmin')) : 0; // Extrafields $extrafields->fetch_name_optionals_label($object->table_element_line); $array_options = $extrafields->getOptionalsFromPost($object->table_element_line); $result = $object->addline( $user, $id, $desc, $date_intervention, $duration, $array_options ); // Define output language $outputlangs = $langs; $newlang = ''; if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } if ($result >= 0) { $db->commit(); if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) { fichinter_create($db, $object, $object->model_pdf, $outputlangs); } header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; } else { $mesg = $object->error; $db->rollback(); } } } elseif ($action == 'classifybilled' && $permissiontoadd) { // Classify Billed $result = $object->setStatut(Fichinter::STATUS_BILLED); if ($result > 0) { header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; } else { setEventMessages($object->error, $object->errors, 'errors'); } } elseif ($action == 'classifyunbilled' && $permissiontoadd) { // Classify unbilled $result = $object->setStatut(Fichinter::STATUS_VALIDATED); if ($result > 0) { header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; } else { $mesg = $object->error; } } elseif ($action == 'confirm_reopen' && $permissiontoadd) { // Reopen $result = $object->setStatut(Fichinter::STATUS_VALIDATED); if ($result > 0) { header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; } else { $mesg = $object->error; } } elseif ($action == 'updateline' && $permissiontoadd && GETPOST('save', 'alpha')) { // Mise a jour d'une ligne d'intervention $objectline = new FichinterLigne($db); if ($objectline->fetch($lineid) <= 0) { dol_print_error($db); exit; } if ($object->fetch($objectline->fk_fichinter) <= 0) { dol_print_error($db); exit; } $object->fetch_thirdparty(); $desc = GETPOST('np_desc', 'restricthtml'); $date_inter = dol_mktime(GETPOSTINT('dihour'), GETPOSTINT('dimin'), 0, GETPOSTINT('dimonth'), GETPOSTINT('diday'), GETPOSTINT('diyear')); $duration = convertTime2Seconds(GETPOSTINT('durationhour'), GETPOSTINT('durationmin')); $objectline->date = $date_inter; $objectline->desc = $desc; $objectline->duration = $duration; // Extrafields $extrafields->fetch_name_optionals_label($object->table_element_line); $array_options = $extrafields->getOptionalsFromPost($object->table_element_line); if (is_array($array_options)) { $objectline->array_options = array_merge($objectline->array_options, $array_options); } $result = $objectline->update($user); if ($result < 0) { dol_print_error($db); exit; } // Define output language $outputlangs = $langs; $newlang = ''; if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) { fichinter_create($db, $object, $object->model_pdf, $outputlangs); } header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit; } elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $permissiontoadd) { // Supprime une ligne d'intervention AVEC confirmation $objectline = new FichinterLigne($db); if ($objectline->fetch($lineid) <= 0) { dol_print_error($db); exit; } $result = $objectline->deleteLine($user); if ($object->fetch($objectline->fk_fichinter) <= 0) { dol_print_error($db); exit; } // Define output language $outputlangs = $langs; $newlang = ''; if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) { fichinter_create($db, $object, $object->model_pdf, $outputlangs); } } elseif ($action == 'up' && $permissiontoadd) { // Set position of lines $object->line_up($lineid); // Define output language $outputlangs = $langs; $newlang = ''; if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) { fichinter_create($db, $object, $object->model_pdf, $outputlangs); } header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.$lineid); exit; } elseif ($action == 'down' && $permissiontoadd) { $object->line_down($lineid); // Define output language $outputlangs = $langs; $newlang = ''; if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); } if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) { $newlang = $object->thirdparty->default_lang; } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) { fichinter_create($db, $object, $object->model_pdf, $outputlangs); } header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.$lineid); exit; } // Actions when printing a doc from card include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to send emails $triggersendname = 'FICHINTER_SENTBYMAIL'; $autocopy = 'MAIN_MAIL_AUTOCOPY_FICHINTER_TO'; $trackid = 'int'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; // Actions to build doc $upload_dir = $conf->ficheinter->dir_output; $permissiontoadd = $user->hasRight('ficheinter', 'creer'); include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; if ($action == 'update_extras' && $permissiontoadd) { $object->oldcopy = dol_clone($object, 2); $attribute_name = GETPOST('attribute', 'restricthtml'); // Fill array 'array_options' with data from update form $ret = $extrafields->setOptionalsFromPost(null, $object, $attribute_name); if ($ret < 0) { $error++; } if (!$error) { // Actions on extra fields $result = $object->updateExtraField($attribute_name, 'INTERVENTION_MODIFY'); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $error++; } } if ($error) { $action = 'edit_extras'; } } if (getDolGlobalString('MAIN_DISABLE_CONTACTS_TAB')) { if ($action == 'addcontact' && $permissiontoadd) { if ($result > 0 && $id > 0) { $contactid = (GETPOSTINT('userid') ? GETPOSTINT('userid') : GETPOSTINT('contactid')); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); } if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } else { if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); $mesg = $langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"); } else { $mesg = $object->error; } } } elseif ($action == 'swapstatut' && $permissiontoadd) { // bascule du statut d'un contact $result = $object->swapContactStatus(GETPOSTINT('ligne')); } elseif ($action == 'deletecontact' && $permissiontoadd) { // Efface un contact $result = $object->delete_contact(GETPOSTINT('lineid')); if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } else { dol_print_error($db); } } } } /* * View */ $form = new Form($db); $formfile = new FormFile($db); if (isModEnabled('contract')) { $formcontract = new FormContract($db); } if (isModEnabled('project')) { $formproject = new FormProjets($db); } $help_url = 'EN:Module_Interventions'; llxHeader('', $langs->trans("Intervention"), $help_url, '', 0, 0, '', '', '', 'mod-fichinter page-card'); if ($action == 'create') { // Create new intervention $soc = new Societe($db); print load_fiche_titre($langs->trans("AddIntervention"), '', 'intervention'); if ($error > 0) { dol_htmloutput_errors($mesg); } else { dol_htmloutput_mesg($mesg); } if ($socid) { $res = $soc->fetch($socid); } if (GETPOSTINT('origin') && GETPOSTINT('originid')) { // Parse element/subelement (ex: project_task) $regs = array(); $element = $subelement = GETPOST('origin', 'alphanohtml'); if (preg_match('/^([^_]+)_([^_]+)/i', GETPOST('origin', 'alphanohtml'), $regs)) { $element = $regs[1]; $subelement = $regs[2]; } if ($element == 'project') { $projectid = GETPOSTINT('originid'); } else { // For compatibility if ($element == 'order' || $element == 'commande') { $element = $subelement = 'commande'; } if ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; } if ($element == 'contract') { $element = $subelement = 'contrat'; } dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); $classname = ucfirst($subelement); $objectsrc = new $classname($db); $objectsrc->fetch(GETPOST('originid')); if (empty($objectsrc->lines) && method_exists($objectsrc, 'fetch_lines')) { $objectsrc->fetch_lines(); $lines = $objectsrc->lines; } $objectsrc->fetch_thirdparty(); $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project : ''); $soc = $objectsrc->thirdparty; $note_private = (!empty($objectsrc->note) ? $objectsrc->note : (!empty($objectsrc->note_private) ? $objectsrc->note_private : GETPOST('note_private', 'restricthtml'))); $note_public = (!empty($objectsrc->note_public) ? $objectsrc->note_public : GETPOST('note_public', 'restricthtml')); // Replicate extrafields $objectsrc->fetch_optionals(); $object->array_options = $objectsrc->array_options; // Object source contacts list $srccontactslist = $objectsrc->liste_contact(-1, 'external', 1); } } else { $projectid = GETPOSTINT('projectid'); } if (!$conf->global->FICHEINTER_ADDON) { dol_print_error($db, $langs->trans("Error")." ".$langs->trans("Error_FICHEINTER_ADDON_NotDefined")); exit; } $object->date = dol_now(); $obj = getDolGlobalString('FICHEINTER_ADDON'); $obj = "mod_".$obj; //$modFicheinter = new $obj; //$numpr = $modFicheinter->getNextValue($soc, $object); if ($socid > 0) { $soc = new Societe($db); $soc->fetch($socid); print '
'; print ''; print ''; print ''; print ''; print dol_get_fiche_head(''); print ''; print ''; // Ref print ''; // Ref customer print ''; print ''; // Description (must be a textarea and not html must be allowed (used in list view) print ''; print ''; // Project if (isModEnabled('project')) { $formproject = new FormProjets($db); $langs->load("project"); print ''; } // Contract if (isModEnabled('contract')) { $langs->load("contracts"); print ''; } // Model print ''; print ''; print '"; // Public note print ''; print ''; print ''; // Private note if (empty($user->socid)) { print ''; print ''; print ''; } // Other attributes $parameters = array(); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { print $object->showOptionals($extrafields, 'create'); } // Show link to origin object if (!empty($origin) && !empty($originid) && is_object($objectsrc)) { $newclassname = $classname; if ($newclassname == 'Propal') { $newclassname = 'CommercialProposal'; } print ''; // Amount /* Hide amount because we only copy services so amount may differ than source print ''; print '"; if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) // Localtax1 RE { print '"; } if ($mysoc->localtax2_assuj == "1" || $objectsrc->total_localtax2 != 0) // Localtax2 IRPF { print '"; } print '"; if (isModEnabled("multicurrency")) { print ''; print '"; print '"; } */ } print '
'.$langs->trans("ThirdParty").''.$soc->getNomUrl(1).'
'.$langs->trans('Ref').''.$langs->trans("Draft").'
'.$langs->trans('RefCustomer').''; print '
'.$langs->trans("Description").''; print ''; print '
'.$langs->trans("Project").''; /* 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 if ($societe->fournisseur==1) $numprojet=select_projects(-1, GETPOST("projectid", 'int'), 'projectid'); else $numprojet=select_projects($societe->id, GETPOST("projectid", 'int'), 'projectid'); */ $numprojet = $formproject->select_projects($soc->id, $projectid, 'projectid'); if ($numprojet == 0) { print '   '; } print '
'.$langs->trans("Contract").''; $numcontrat = $formcontract->select_contract($soc->id, GETPOSTINT('contratid'), 'contratid', 0, 1, 1); if ($numcontrat == 0) { print '   '; } print '
'.$langs->trans("DefaultModel").''; $liste = ModelePDFFicheinter::liste_modeles($db); print $form->selectarray('model', $liste, $conf->global->FICHEINTER_ADDON_PDF); print "
'.$langs->trans('NotePublic').''; $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, !getDolGlobalString('FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3, '90%'); print $doleditor->Create(1); //print ''; print '
'.$langs->trans('NotePrivate').''; $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, !getDolGlobalString('FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3, '90%'); print $doleditor->Create(1); //print ''; print '
'.$langs->trans($newclassname).''.$objectsrc->getNomUrl(1).'
' . $langs->trans('AmountHT') . '' . price($objectsrc->total_ht) . '
' . $langs->trans('AmountVAT') . '' . price($objectsrc->total_tva) . "
' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '' . price($objectsrc->total_localtax1) . "
' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '' . price($objectsrc->total_localtax2) . "
' . $langs->trans('AmountTTC') . '' . price($objectsrc->total_ttc) . "
' . $langs->trans('MulticurrencyAmountHT') . '' . price($objectsrc->multicurrency_total_ht) . '
' . $langs->trans('MulticurrencyAmountVAT') . '' . price($objectsrc->multicurrency_total_tva) . "
' . $langs->trans('MulticurrencyAmountTTC') . '' . price($objectsrc->multicurrency_total_ttc) . "
'; if (is_object($objectsrc)) { print ''; print ''; } elseif ($origin == 'project' && !empty($projectid)) { print ''; } print dol_get_fiche_end(); print $form->buttonsSaveCancel("CreateDraftIntervention"); // Show origin lines if (!empty($origin) && !empty($originid) && is_object($objectsrc)) { $title = $langs->trans('Services'); print load_fiche_titre($title); print '
'; print ''; $objectsrc->printOriginLinesList(!getDolGlobalString('FICHINTER_PRINT_PRODUCTS') ? 'services' : ''); // Show only service, except if option FICHINTER_PRINT_PRODUCTS is on print '
'; print '
'; } print '
'; } else { print '
'; print ''; print ''; // We go back to create action print ''; print dol_get_fiche_head(''); if (is_object($objectsrc)) { print ''; print ''; } elseif ($origin == 'project' && !empty($projectid)) { print ''; } print ''; print ''; print '
'.$langs->trans("ThirdParty").''; print $form->select_company('', 'socid', '', 'SelectThirdParty', 1, 0, null, 0, 'minwidth300'); print ' '; print '
'; print dol_get_fiche_end(); print $form->buttonsSaveCancel("CreateDraftIntervention"); print '
'; } } elseif ($id > 0 || !empty($ref)) { // View mode $object->fetch($id, $ref); $object->fetch_thirdparty(); $soc = new Societe($db); $soc->fetch($object->socid); if ($error > 0) { dol_htmloutput_errors($mesg); } else { dol_htmloutput_mesg($mesg); } $head = fichinter_prepare_head($object); print dol_get_fiche_head($head, 'card', $langs->trans("InterventionCard"), -1, 'intervention'); $formconfirm = ''; // Confirm deletion of intervention if ($action == 'delete') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteIntervention'), $langs->trans('ConfirmDeleteIntervention'), 'confirm_delete', '', 0, 1); } // Confirm validation if ($action == 'validate') { // Verify if the object's number os temporary $ref = substr($object->ref, 1, 4); if ($ref == 'PROV') { $numref = $object->getNextNumRef($soc); if (empty($numref)) { $error++; setEventMessages($object->error, $object->errors, 'errors'); } } else { $numref = $object->ref; } $text = $langs->trans('ConfirmValidateIntervention', $numref); if (isModEnabled('notification')) { require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; $notify = new Notify($db); $text .= '
'; $text .= $notify->confirmMessage('FICHINTER_VALIDATE', $object->socid, $object); } $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateIntervention'), $text, 'confirm_validate', '', 1, 1); } // Confirm sign if ($action == 'sign') { $text = $langs->trans('ConfirmSignIntervention'); if (isModEnabled('notification')) { require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; $notify = new Notify($db); $text .= '
'; $text .= $notify->confirmMessage('FICHINTER_MODIFY', $object->socid, $object); } $formquestion = []; $formquestion[] = [ 'type' => 'select', 'name' => 'signed_status', 'label' => ''.$langs->trans('SignStatus').'', 'values' => $object->getSignedStatusLocalisedArray() ]; $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('SignIntervention'), $text, 'confirm_sign', $formquestion, 0, 1); } // Confirm unsign if ($action == 'unsign') { $text = $langs->trans('ConfirmUnsignIntervention'); if (isModEnabled('notification')) { require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; $notify = new Notify($db); $text .= '
'; $text .= $notify->confirmMessage('FICHINTER_MODIFY', $object->socid, $object); } $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('UnsignIntervention'), $text, 'confirm_unsign', '', 0, 1); } // Confirm done if ($action == 'classifydone') { $text = $langs->trans('ConfirmCloseIntervention'); if (isModEnabled('notification')) { require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; $notify = new Notify($db); $text .= '
'; $text .= $notify->confirmMessage('FICHINTER_CLOSE', $object->socid, $object); } $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('CloseIntervention'), $text, 'confirm_done', '', 0, 1); } // Confirm back to draft if ($action == 'modify') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ModifyIntervention'), $langs->trans('ConfirmModifyIntervention'), 'confirm_modify', '', 0, 1); } // Confirm back to open if ($action == 'reopen') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ReOpen'), $langs->trans('ConfirmReopenIntervention', $object->ref), 'confirm_reopen', '', 0, 1); } // Confirm deletion of line if ($action == 'ask_deleteline') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&line_id='.$lineid, $langs->trans('DeleteInterventionLine'), $langs->trans('ConfirmDeleteInterventionLine'), 'confirm_deleteline', '', 0, 1); } // Clone confirmation if ($action == 'clone') { // Create an array for form $formquestion = array( // 'text' => $langs->trans("ConfirmClone"), // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => // 1), // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' // => 1), array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOSTINT('socid'), 'socid', '', '', 0, 0, null, 0, 'minwidth200'))); // Paiement incomplet. On demande si motif = escompte ou autre $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneIntervention', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } if (!$formconfirm) { $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { $formconfirm .= $hookmanager->resPrint; } elseif ($reshook > 0) { $formconfirm = $hookmanager->resPrint; } } // Print form confirm print $formconfirm; // Intervention card $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
'; // Ref customer $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->hasRight('ficheinter', 'creer'), 'string', '', 0, 1); $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->hasRight('ficheinter', 'creer'), 'string', '', null, null, '', 1); // Thirdparty $morehtmlref .= '
'.$object->thirdparty->getNomUrl(1, 'customer'); // Project if (isModEnabled('project')) { $langs->load("projects"); $morehtmlref .= '
'; if ($usercancreate) { $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); $morehtmlref .= $proj->getNomUrl(1); if ($proj->title) { $morehtmlref .= ' - '.dol_escape_htmltag($proj->title).''; } } } } $morehtmlref .= '
'; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); print '
'; print '
'; print '
'; print ''; if (getDolGlobalString('FICHINTER_USE_PLANNED_AND_DONE_DATES')) { // Date Start print ''; print ''; print ''; // Date End print ''; print ''; print ''; // Date Terminate/close print ''; print ''; print ''; } // Description (must be a textarea and not html must be allowed (used in list view) print ''; print ''; // Contract if (isModEnabled('contract')) { $langs->load('contracts'); print ''; print ''; print ''; } // Other attributes $cols = 2; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '
'.$langs->trans("Dateo").''; print $object->dateo ? dol_print_date($object->dateo, 'daytext') : ' '; print '
'.$langs->trans("Datee").''; print $object->datee ? dol_print_date($object->datee, 'daytext') : ' '; print '
'.$langs->trans("Datet").''; print $object->datet ? dol_print_date($object->datet, 'daytext') : ' '; print '
'; print $form->editfieldkey("Description", 'description', $object->description, $object, $user->hasRight('ficheinter', 'creer'), 'textarea'); print ''; print $form->editfieldval("Description", 'description', $object->description, $object, $user->hasRight('ficheinter', 'creer'), 'textarea:8'); print '
'; print ''; if ($action != 'contrat') { print ''; } print '
'; print $langs->trans('Contract'); print 'id.'">'; print img_edit($langs->trans('SetContract'), 1); print '
'; print '
'; if ($action == 'contrat') { $formcontract = new FormContract($db); $formcontract->formSelectContract($_SERVER["PHP_SELF"].'?id='.$object->id, $object->socid, $object->fk_contrat, 'contratid', 0, 1, 1); } else { if ($object->fk_contrat) { $contratstatic = new Contrat($db); $contratstatic->fetch($object->fk_contrat); //print ''.$projet->title.''; print $contratstatic->getNomUrl(0, '', 1); } else { print " "; } } print '
'; print '
'; print '
'; print '
'; print ''; if (!getDolGlobalString('FICHINTER_DISABLE_DETAILS')) { // Duration in time print ''; print ''; print ''; } print "
'.$langs->trans("TotalDuration").''.convertSecondToTime($object->duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY).' ('.convertDurationtoHour($object->duration, "s").' '.$langs->trans("h").')
"; print '
'; print '
'; print '

'; if (getDolGlobalString('MAIN_DISABLE_CONTACTS_TAB')) { $blocname = 'contacts'; $title = $langs->trans('ContactsAddresses'); include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; } if (getDolGlobalString('MAIN_DISABLE_NOTES_TAB')) { $blocname = 'notes'; $title = $langs->trans('Notes'); include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; } // Line of interventions if (!getDolGlobalString('FICHINTER_DISABLE_DETAILS')) { print '
'; print ''; print ''; if ($action == 'editline') { print ''; print ''; } else { print ''; } print ''; // Intervention lines $sql = 'SELECT ft.rowid, ft.description, ft.fk_fichinter, ft.duree, ft.rang,'; $sql .= ' ft.date as date_intervention'; $sql .= ' FROM '.MAIN_DB_PREFIX.'fichinterdet as ft'; $sql .= ' WHERE ft.fk_fichinter = '.((int) $object->id); if (getDolGlobalString('FICHINTER_HIDE_EMPTY_DURATION')) { $sql .= ' AND ft.duree <> 0'; } $sql .= ' ORDER BY ft.rang ASC, ft.date ASC, ft.rowid'; $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; if ($num) { print '
'; print ''; print ''; // No. if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER')) { print ''; } print ''; print ''; print ''; print ''; print ''; print "\n"; } while ($i < $num) { $objp = $db->fetch_object($resql); // Ligne en mode visu if ($action != 'editline' || GETPOSTINT('line_id') != $objp->rowid) { print ''; // No. if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER')) { print ''; } print ''; // Date print ''; // Duration print ''; print "\n"; // Icon to edit and delete if ($object->statut == 0 && $user->hasRight('ficheinter', 'creer')) { print ''; print ''; } else { print ''; } print ''; } // Line in update mode if ($object->statut == 0 && $action == 'editline' && $user->hasRight('ficheinter', 'creer') && GETPOSTINT('line_id') == $objp->rowid) { print ''; // No. if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER')) { print ''; } print ''; // Date d'intervention print ''; // Duration print ''; print ''; print ''."\n"; } $i++; } $db->free($resql); // Add new line if ($object->statut == 0 && $user->hasRight('ficheinter', 'creer') && $action != 'editline' && !getDolGlobalString('FICHINTER_DISABLE_DETAILS')) { if (!$num) { print '
'; print '
'.$langs->trans('Description').''.$langs->trans('Date').''.(!getDolGlobalString('FICHINTER_WITHOUT_DURATION') ? $langs->trans('Duration') : '').'  
'.($i + 1).''; print ''; // ancre pour retourner sur la ligne print dol_htmlentitiesbr($objp->description); $objectline = new FichinterLigne($db); $objectline->fetch($objp->rowid); $objectline->fetch_optionals(); $extrafields->fetch_name_optionals_label($objectline->table_element); if (!empty($extrafields)) { $temps = $objectline->showOptionals($extrafields, 'view', array(), '', '', 1, 'line'); if (!empty($temps)) { print '
'; print $temps; print '
'; } } print '
'.(!getDolGlobalString('FICHINTER_DATE_WITHOUT_HOUR') ? dol_print_date($db->jdate($objp->date_intervention), 'dayhour') : dol_print_date($db->jdate($objp->date_intervention), 'day')).''.(!getDolGlobalString('FICHINTER_WITHOUT_DURATION') ? convertSecondToTime($objp->duree) : '').''; print 'rowid.'#'.$objp->rowid.'">'; print img_edit(); print ''; print 'rowid.'">'; print img_delete(); print ''; if ($num > 1) { if ($i > 0) { print 'rowid.'">'; print img_up(); print ''; } if ($i < $num - 1) { print 'rowid.'">'; print img_down(); print ''; } } print ' 
'.($i + 1).''; print ''; // ancre pour retourner sur la ligne // Editeur wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor('np_desc', $objp->description, '', 164, 'dolibarr_details', '', false, true, getDolGlobalInt('FCKEDITOR_ENABLE_DETAILS'), ROWS_2, '90%'); $doleditor->Create(); $objectline = new FichinterLigne($db); $objectline->fetch($objp->rowid); $objectline->fetch_optionals(); $extrafields->fetch_name_optionals_label($objectline->table_element); if (!empty($extrafields)) { $temps = $objectline->showOptionals($extrafields, 'edit', array(), '', '', 1, 'line'); if (!empty($temps)) { print '
'; print $temps; print '
'; } } print '
'; if (getDolGlobalString('FICHINTER_DATE_WITHOUT_HOUR')) { print $form->selectDate($db->jdate($objp->date_intervention), 'di', 0, 0, 0, "date_intervention"); } else { print $form->selectDate($db->jdate($objp->date_intervention), 'di', 1, 1, 0, "date_intervention"); } print ''; if (!getDolGlobalString('FICHINTER_WITHOUT_DURATION')) { $selectmode = 'select'; if (getDolGlobalString('INTERVENTION_ADDLINE_FREEDUREATION')) { $selectmode = 'text'; } $form->select_duration('duration', $objp->duree, 0, $selectmode); } print ''; print ''; print '
'; print ''; // No. if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER')) { print ''; } print ''; print ''; print ''; print ''; print "\n"; } print ''."\n"; // No. if (getDolGlobalString('MAIN_VIEW_LINE_NUMBER')) { print ''; } print ''; // Date intervention print ''; // Duration print ''; print ''; print ''; if (!$num) { print '
'; print ''; // ancre print $langs->trans('Description').''.$langs->trans('Date').''.(!getDolGlobalString('FICHINTER_WITHOUT_DURATION') ? $langs->trans('Duration') : '').' 
'.($i + 1).''; // editeur wysiwyg if (!getDolGlobalString('FICHINTER_EMPTY_LINE_DESC')) { require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor('np_desc', GETPOST('np_desc', 'restricthtml'), '', 100, 'dolibarr_details', '', false, true, getDolGlobalString('FCKEDITOR_ENABLE_DETAILS'), ROWS_2, '90%'); $doleditor->Create(); } $objectline = new FichinterLigne($db); $extrafields->fetch_name_optionals_label($objectline->table_element); if (is_object($objectline)) { $temps = $objectline->showOptionals($extrafields, 'create', array(), '', '', 1, 'line'); if (!empty($temps)) { print '
'; print $temps; print '
'; } } print '
'; $now = dol_now(); $timearray = dol_getdate($now); if (!GETPOSTINT('diday')) { if (getDolGlobalInt('FICHINTER_DATE_WITHOUT_HOUR')) { $timewithnohour = dol_mktime(0, 0, 0, $timearray['mon'], $timearray['mday'], $timearray['year']); } else { $timewithnohour = dol_mktime($timearray['hours'], $timearray['minutes'], 0, $timearray['mon'], $timearray['mday'], $timearray['year']); } } else { $timewithnohour = dol_mktime(GETPOSTINT('dihour'), GETPOSTINT('dimin'), 0, GETPOSTINT('dimonth'), GETPOSTINT('diday'), GETPOSTINT('diyear')); } if (getDolGlobalInt('FICHINTER_DATE_WITHOUT_HOUR')) { print $form->selectDate($timewithnohour, 'di', 0, 0, 0, "addinter"); } else { print $form->selectDate($timewithnohour, 'di', 1, 1, 0, "addinter"); } print ''; if (!getDolGlobalString('FICHINTER_WITHOUT_DURATION')) { $selectmode = 'select'; if (getDolGlobalString('INTERVENTION_ADDLINE_FREEDUREATION')) { $selectmode = 'text'; } $form->select_duration('duration', (!GETPOSTINT('durationhour') && !GETPOSTINT('durationmin')) ? 3600 : (60 * 60 * GETPOSTINT('durationhour') + 60 * GETPOSTINT('durationmin')), 0, $selectmode); } print '
'; } } if ($num) { print ''; } } else { dol_print_error($db); } print '
'."\n"; } print dol_get_fiche_end(); print "\n"; /* * Actions buttons */ print '
'; $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook if (empty($reshook)) { if ($user->socid == 0) { if ($action != 'editdescription' && ($action != 'presend')) { // Validate if ($object->statut == Fichinter::STATUS_DRAFT && (count($object->lines) > 0 || getDolGlobalString('FICHINTER_DISABLE_DETAILS'))) { if ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('ficheinter', 'creer')) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('ficheinter', 'ficheinter_advance', 'validate'))) { print ''; } else { print '
'.$langs->trans("Validate").'
'; } } // Modify if ($object->statut == Fichinter::STATUS_VALIDATED && ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('ficheinter', 'creer')) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('ficheinter', 'ficheinter_advance', 'unvalidate')))) { print ''; } // Reopen if ($object->statut >= Fichinter::STATUS_CLOSED) { if ($user->hasRight('ficheinter', 'creer')) { print ''; } else { print ''; } } // Send if (empty($user->socid)) { if ($object->statut > Fichinter::STATUS_DRAFT) { if (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') || $user->hasRight('ficheinter', 'ficheinter_advance', 'send')) { print ''; } else { print ''; } } } // Create intervention model if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 1 && $object->statut == Fichinter::STATUS_DRAFT && $user->hasRight('ficheinter', 'creer') && (count($object->lines) > 0)) { print ''; } // Proposal if (isModEnabled("service") && isModEnabled("propal") && $object->statut > Fichinter::STATUS_DRAFT) { $langs->load("propal"); if ($object->statut < Fichinter::STATUS_BILLED) { if ($user->hasRight('propal', 'creer')) { print ''; } else { print ''; } } } // Invoicing if (isModEnabled('invoice') && $object->statut > Fichinter::STATUS_DRAFT) { $langs->load("bills"); if ($object->statut < Fichinter::STATUS_BILLED) { if ($user->hasRight('facture', 'creer')) { print ''; } else { print ''; } } if (getDolGlobalString('FICHINTER_CLASSIFY_BILLED')) { // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1 if ($object->statut != Fichinter::STATUS_BILLED) { print ''; } else { print ''; } } } // Sign if ($object->statut > Fichinter::STATUS_DRAFT) { if ($object->signed_status != Fichinter::SIGNED_STATUSES['STATUS_SIGNED_ALL']) { print ''; } else { print ''; } } // Done if (!getDolGlobalString('FICHINTER_CLASSIFY_BILLED') && $object->statut > Fichinter::STATUS_DRAFT && $object->statut < Fichinter::STATUS_CLOSED) { print ''; } // Clone if ($user->hasRight('ficheinter', 'creer')) { print ''; } // Delete print '
'; print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $permissiontodelete); print '
'; } } } print '
'; if ($action != 'presend') { print '
'; /* * Built documents */ $filename = dol_sanitizeFileName($object->ref); $filedir = $conf->ficheinter->dir_output."/".$filename; $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; $genallowed = $user->hasRight('ficheinter', 'lire'); $delallowed = $user->hasRight('ficheinter', 'creer'); print $formfile->showdocuments('ficheinter', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); // Show links to link elements $linktoelem = $form->showLinkToObjectBlock($object, null, array('fichinter')); $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); // Show direct download link if ($object->statut != Fichinter::STATUS_DRAFT && getDolGlobalString('FICHINTER_ALLOW_EXTERNAL_DOWNLOAD')) { print '
'."\n"; print showDirectDownloadLink($object).'
'; } // Show online signature link if ($object->statut != Fichinter::STATUS_DRAFT && getDolGlobalString('FICHINTER_ALLOW_ONLINE_SIGN')) { print '
'; require_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php'; print showOnlineSignatureUrl('fichinter', $object->ref, $object).'
'; } print '
'; $MAXEVENT = 10; $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/fichinter/agenda.php?id='.$object->id); // List of actions on element include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; $formactions = new FormActions($db); $somethingshown = $formactions->showactions($object, 'fichinter', $socid, 1, '', $MAXEVENT, '', $morehtmlcenter); // Show all action for thirdparty print '
'; } // Select mail models is same action as presend if (GETPOST('modelselected')) { $action = 'presend'; } // Presend form $modelmail = 'fichinter_send'; $defaulttopic = 'SendInterventionRef'; $diroutput = $conf->ficheinter->dir_output; $trackid = 'int'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; } llxFooter(); $db->close();