alxarafe /
alixar
| 1 | <?php |
||
| 2 | |||
| 3 | /* Copyright (C) 2001-2007 Rodolphe Quiedeville <[email protected]> |
||
| 4 | * Copyright (C) 2005 Brice Davoleau <[email protected]> |
||
| 5 | * Copyright (C) 2005-2012 Regis Houssin <[email protected]> |
||
| 6 | * Copyright (C) 2006-2019 Laurent Destailleur <[email protected]> |
||
| 7 | * Copyright (C) 2007 Patrick Raguin <[email protected]> |
||
| 8 | * Copyright (C) 2010 Juanjo Menent <[email protected]> |
||
| 9 | * Copyright (C) 2015 Marcos García <[email protected]> |
||
| 10 | * Copyright (C) 2024 Rafael San José <[email protected]> |
||
| 11 | * |
||
| 12 | * This program is free software; you can redistribute it and/or modify |
||
| 13 | * it under the terms of the GNU General Public License as published by |
||
| 14 | * the Free Software Foundation; either version 3 of the License, or |
||
| 15 | * (at your option) any later version. |
||
| 16 | * |
||
| 17 | * This program is distributed in the hope that it will be useful, |
||
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 20 | * GNU General Public License for more details. |
||
| 21 | * |
||
| 22 | * You should have received a copy of the GNU General Public License |
||
| 23 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
||
| 24 | */ |
||
| 25 | |||
| 26 | use Dolibarr\Code\Contrat\Classes\Contrat; |
||
| 27 | use Dolibarr\Code\Core\Classes\Form; |
||
| 28 | use Dolibarr\Code\Projet\Classes\Project; |
||
| 29 | use Dolibarr\Lib\ViewMain; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * \file htdocs/contrat/messaging.php |
||
| 33 | * \ingroup contrat |
||
| 34 | * \brief Page of contrat events |
||
| 35 | */ |
||
| 36 | |||
| 37 | // Load Dolibarr environment |
||
| 38 | require constant('DOL_DOCUMENT_ROOT') . '/main.inc.php'; |
||
| 39 | require_once constant('DOL_DOCUMENT_ROOT') . '/core/lib/functions2.lib.php'; |
||
| 40 | require_once constant('DOL_DOCUMENT_ROOT') . '/core/lib/company.lib.php'; |
||
| 41 | require_once constant('DOL_DOCUMENT_ROOT') . '/core/lib/contract.lib.php'; |
||
| 42 | |||
| 43 | // Load translation files required by the page |
||
| 44 | $langs->loadLangs(array('agenda', 'contracts', 'companies')); |
||
| 45 | |||
| 46 | $action = GETPOST('action', 'alpha'); |
||
| 47 | $confirm = GETPOST('confirm', 'alpha'); |
||
| 48 | $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'contratagenda'; |
||
| 49 | |||
| 50 | if (GETPOST('actioncode', 'array')) { |
||
| 51 | $actioncode = GETPOST('actioncode', 'array', 3); |
||
| 52 | if (!count($actioncode)) { |
||
| 53 | $actioncode = '0'; |
||
| 54 | } |
||
| 55 | } else { |
||
| 56 | $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); |
||
| 57 | } |
||
| 58 | |||
| 59 | $search_rowid = GETPOST('search_rowid'); |
||
| 60 | $search_agenda_label = GETPOST('search_agenda_label'); |
||
| 61 | |||
| 62 | $id = GETPOSTINT('id'); |
||
| 63 | $ref = GETPOST('ref', 'alpha'); |
||
| 64 | |||
| 65 | $limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; |
||
| 66 | $sortfield = GETPOST('sortfield', 'aZ09comma'); |
||
| 67 | $sortorder = GETPOST('sortorder', 'aZ09comma'); |
||
| 68 | $page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page"); |
||
| 69 | if (empty($page) || $page == -1) { |
||
| 70 | $page = 0; |
||
| 71 | } // If $page is not defined, or '' or -1 |
||
| 72 | $offset = $limit * $page; |
||
| 73 | $pageprev = $page - 1; |
||
| 74 | $pagenext = $page + 1; |
||
| 75 | if (!$sortfield) { |
||
| 76 | $sortfield = 'a.datep,a.id'; |
||
| 77 | } |
||
| 78 | if (!$sortorder) { |
||
| 79 | $sortorder = 'DESC,DESC'; |
||
| 80 | } |
||
| 81 | |||
| 82 | // Initialize technical objects |
||
| 83 | $object = new Contrat($db); |
||
| 84 | |||
| 85 | // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context |
||
| 86 | $hookmanager->initHooks(array('agendacontract', 'globalcard')); |
||
| 87 | |||
| 88 | // Security check |
||
| 89 | $id = GETPOSTINT("id"); |
||
| 90 | $socid = 0; |
||
| 91 | if ($user->socid) { |
||
| 92 | $socid = $user->socid; |
||
| 93 | } |
||
| 94 | |||
| 95 | $result = $object->fetch($id); |
||
| 96 | if ($result <= 0) { |
||
| 97 | accessforbidden('Contrat not found'); |
||
| 98 | } |
||
| 99 | |||
| 100 | $result = restrictedArea($user, 'contrat', $id, '&contrat'); |
||
| 101 | |||
| 102 | if (!$user->hasRight('contrat', 'lire')) { |
||
| 103 | accessforbidden(); |
||
| 104 | } |
||
| 105 | |||
| 106 | |||
| 107 | /* |
||
| 108 | * Actions |
||
| 109 | */ |
||
| 110 | $parameters = array('id' => $id); |
||
| 111 | $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
||
| 112 | if ($reshook < 0) { |
||
| 113 | setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
||
| 114 | } |
||
| 115 | |||
| 116 | if (empty($reshook)) { |
||
| 117 | // Cancel |
||
| 118 | if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { |
||
| 119 | header("Location: " . $backtopage); |
||
| 120 | exit; |
||
| 121 | } |
||
| 122 | |||
| 123 | // Purge search criteria |
||
| 124 | if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers |
||
| 125 | $actioncode = ''; |
||
| 126 | $search_agenda_label = ''; |
||
| 127 | } |
||
| 128 | } |
||
| 129 | |||
| 130 | |||
| 131 | /* |
||
| 132 | * View |
||
| 133 | */ |
||
| 134 | |||
| 135 | $form = new Form($db); |
||
| 136 | |||
| 137 | // Load object modContract |
||
| 138 | $module = (getDolGlobalString('CONTRACT_ADDON') ? $conf->global->CONTRACT_ADDON : 'mod_contract_serpis'); |
||
| 139 | if (substr($module, 0, 13) == 'mod_contract_' && substr($module, -3) == 'php') { |
||
| 140 | $module = substr($module, 0, dol_strlen($module) - 4); |
||
| 141 | } |
||
| 142 | $result = dol_include_once('/core/modules/contract/' . $module . '.php'); |
||
| 143 | if ($result > 0) { |
||
| 144 | $modCodeContract = new $module(); |
||
| 145 | } |
||
| 146 | |||
| 147 | require_once constant('DOL_DOCUMENT_ROOT') . '/core/lib/company.lib.php'; |
||
| 148 | |||
| 149 | $object->fetch_thirdparty(); |
||
| 150 | |||
| 151 | $title = $langs->trans("Agenda"); |
||
| 152 | if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/contractrefonly/', getDolGlobalString('MAIN_HTML_TITLE')) && $object->ref) { |
||
| 153 | $title = $object->ref . " - " . $title; |
||
| 154 | } |
||
| 155 | $help_url = 'EN:Module_Contracts|FR:Module_Contrat'; |
||
| 156 | |||
| 157 | ViewMain::llxHeader('', $title, $help_url); |
||
| 158 | |||
| 159 | if (isModEnabled('notification')) { |
||
| 160 | $langs->load("mails"); |
||
| 161 | } |
||
| 162 | $head = contract_prepare_head($object); |
||
| 163 | |||
| 164 | print dol_get_fiche_head($head, 'agenda', $langs->trans("Contract"), -1, 'contract'); |
||
| 165 | |||
| 166 | $linkback = '<a href="' . constant('BASE_URL') . '/contrat/list.php?restore_lastsearch_values=1">' . $langs->trans("BackToList") . '</a>'; |
||
| 167 | |||
| 168 | $morehtmlref = ''; |
||
| 169 | if (!empty($modCodeContract->code_auto)) { |
||
| 170 | $morehtmlref .= $object->ref; |
||
| 171 | } else { |
||
| 172 | $morehtmlref .= $form->editfieldkey("", 'ref', $object->ref, $object, $user->hasRight('contrat', 'creer'), 'string', '', 0, 3); |
||
| 173 | $morehtmlref .= $form->editfieldval("", 'ref', $object->ref, $object, $user->hasRight('contrat', 'creer'), 'string', '', 0, 2); |
||
| 174 | } |
||
| 175 | |||
| 176 | $permtoedit = 0; |
||
| 177 | |||
| 178 | $morehtmlref .= '<div class="refidno">'; |
||
| 179 | // Ref customer |
||
| 180 | $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_customer', $object->ref_customer, $object, $permtoedit, 'string', '', 0, 1); |
||
| 181 | $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_customer', $object->ref_customer, $object, $permtoedit, 'string', '', null, null, '', 1, 'getFormatedCustomerRef'); |
||
| 182 | // Ref supplier |
||
| 183 | $morehtmlref .= '<br>'; |
||
| 184 | $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $permtoedit, 'string', '', 0, 1); |
||
| 185 | $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $permtoedit, 'string', '', null, null, '', 1, 'getFormatedSupplierRef'); |
||
| 186 | // Thirdparty |
||
| 187 | $morehtmlref .= '<br>' . $object->thirdparty->getNomUrl(1); |
||
|
0 ignored issues
–
show
|
|||
| 188 | if (!getDolGlobalString('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) { |
||
| 189 | $morehtmlref .= ' (<a href="' . constant('BASE_URL') . '/contrat/list.php?socid=' . $object->thirdparty->id . '&search_name=' . urlencode($object->thirdparty->name) . '">' . $langs->trans("OtherContracts") . '</a>)'; |
||
| 190 | } |
||
| 191 | // Project |
||
| 192 | if (isModEnabled('project')) { |
||
| 193 | $langs->load("projects"); |
||
| 194 | $morehtmlref .= '<br>'; |
||
| 195 | if (0) { |
||
| 196 | $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); |
||
| 197 | if ($action != 'classify') { |
||
| 198 | $morehtmlref .= '<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&token=' . newToken() . '&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> '; |
||
| 199 | } |
||
| 200 | $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); |
||
| 201 | } else { |
||
| 202 | if (!empty($object->fk_project)) { |
||
| 203 | $proj = new Project($db); |
||
| 204 | $proj->fetch($object->fk_project); |
||
| 205 | $morehtmlref .= $proj->getNomUrl(1); |
||
| 206 | if ($proj->title) { |
||
| 207 | $morehtmlref .= '<span class="opacitymedium"> - ' . dol_escape_htmltag($proj->title) . '</span>'; |
||
| 208 | } |
||
| 209 | } |
||
| 210 | } |
||
| 211 | } |
||
| 212 | $morehtmlref .= '</div>'; |
||
| 213 | |||
| 214 | dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'none', $morehtmlref); |
||
| 215 | |||
| 216 | print '<div class="fichecenter">'; |
||
| 217 | |||
| 218 | print '<div class="underbanner clearboth"></div>'; |
||
| 219 | |||
| 220 | $object->info($object->id); |
||
| 221 | dol_print_object_info($object, 1); |
||
| 222 | |||
| 223 | print '</div>'; |
||
| 224 | |||
| 225 | print dol_get_fiche_end(); |
||
| 226 | |||
| 227 | |||
| 228 | // Actions buttons |
||
| 229 | |||
| 230 | $morehtmlright = ''; |
||
| 231 | |||
| 232 | $morehtmlright .= dolGetButtonTitle($langs->trans('FullConversation'), '', 'fa fa-comments imgforviewmode', constant('BASE_URL') . '/contrat/messaging.php?id=' . $object->id, '', 2); |
||
| 233 | $morehtmlright .= dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-bars imgforviewmode', constant('BASE_URL') . '/contrat/agenda.php?id=' . $object->id, '', 1); |
||
| 234 | |||
| 235 | if (isModEnabled('agenda')) { |
||
| 236 | if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) { |
||
| 237 | $backtopage = $_SERVER['PHP_SELF'] . '?id=' . $object->id; |
||
| 238 | $out = '&origin=' . $object->element . '&originid=' . $object->id . '&backtopage=' . urlencode($backtopage); |
||
| 239 | $morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', constant('BASE_URL') . '/comm/action/card.php?action=create' . $out); |
||
| 240 | } |
||
| 241 | } |
||
| 242 | |||
| 243 | if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) { |
||
| 244 | print '<br>'; |
||
| 245 | |||
| 246 | $param = '&id=' . urlencode((string)($id)); |
||
| 247 | if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { |
||
| 248 | $param .= '&contextpage=' . urlencode($contextpage); |
||
| 249 | } |
||
| 250 | if ($limit > 0 && $limit != $conf->liste_limit) { |
||
| 251 | $param .= '&limit=' . ((int)$limit); |
||
| 252 | } |
||
| 253 | |||
| 254 | // Try to know count of actioncomm from cache |
||
| 255 | require_once constant('DOL_DOCUMENT_ROOT') . '/core/lib/memory.lib.php'; |
||
| 256 | $cachekey = 'count_events_thirdparty_' . $object->id; |
||
| 257 | $nbEvent = dol_getcache($cachekey); |
||
| 258 | |||
| 259 | $titlelist = $langs->trans("ActionsOnCompany") . (is_numeric($nbEvent) ? '<span class="opacitymedium colorblack paddingleft">(' . $nbEvent . ')</span>' : ''); |
||
| 260 | if (!empty($conf->dol_optimize_smallscreen)) { |
||
| 261 | $titlelist = $langs->trans("Actions") . (is_numeric($nbEvent) ? '<span class="opacitymedium colorblack paddingleft">(' . $nbEvent . ')</span>' : ''); |
||
| 262 | } |
||
| 263 | |||
| 264 | print_barre_liste($titlelist, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 0); |
||
| 265 | |||
| 266 | // List of all actions |
||
| 267 | $filters = array(); |
||
| 268 | $filters['search_agenda_label'] = $search_agenda_label; |
||
| 269 | $filters['search_rowid'] = $search_rowid; |
||
| 270 | |||
| 271 | // TODO Replace this with same code than into list.php |
||
| 272 | show_actions_messaging($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder); |
||
| 273 | } |
||
| 274 | |||
| 275 | // End of page |
||
| 276 | ViewMain::llxFooter(); |
||
| 277 | $db->close(); |
||
| 278 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.