dolibarr 24.0.0-beta
ficheinterlist.controller.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2026 Pierre Ardoin <developpeur@lesmetiersdubatiment.fr>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
24require_once DOL_DOCUMENT_ROOT . '/webportal/class/html.formlistwebportal.class.php';
25require_once DOL_DOCUMENT_ROOT . '/webportal/controllers/abstractlist.controller.class.php';
26
31{
37 public function checkAccess()
38 {
39 $this->accessRight = isModEnabled('intervention') && getDolGlobalInt('WEBPORTAL_FICHEINTER_LIST_ACCESS');
40
41 return parent::checkAccess();
42 }
43
50 public function action()
51 {
52 global $langs;
53
55 if (!$context->controllerInstance->checkAccess()) {
56 return -1;
57 }
58
59 $langs->loadLangs(array('fichinter', 'companies', 'products'));
60
61 $context->title = $langs->trans('WebPortalFicheinterListTitle');
62 $context->desc = $langs->trans('WebPortalFicheinterListDesc');
63 $context->menu_active[] = 'ficheinter_list';
64
65 $this->formList = new FormListWebPortal($this->db);
66 $this->formList->init($this, 'ficheinter');
67
68 $hookRes = $this->hookDoAction();
69 if (empty($hookRes)) {
70 $this->formList->doActions();
71 }
72
73 $sqlBody = " AND t.fk_soc = ".((int) $context->logged_thirdparty->id);
74 $sqlBody .= " AND t.fk_statut <> 0";
75
76 $searchStatus = (string) ($this->formList->search['fk_statut'] ?? '');
77 if ($searchStatus !== '') {
78 $searchSignedStatus = 0;
79 if ((int) $searchStatus === WebPortalFicheinter::STATUS_SIGN_NOT_SIGNED) {
80 $searchSignedStatus = 0;
81 }
82 if ((int) $searchStatus === WebPortalFicheinter::STATUS_SIGN_SIGNED_INTERNAL) {
83 $searchSignedStatus = 1;
84 }
85 if ((int) $searchStatus === WebPortalFicheinter::STATUS_SIGN_SIGNED_THIRDPARTY) {
86 $searchSignedStatus = 2;
87 }
88 if ((int) $searchStatus === WebPortalFicheinter::STATUS_SIGN_SIGNED_THIRDPARTY_ONLINE) {
89 $searchSignedStatus = 3;
90 }
91 if ((int) $searchStatus === WebPortalFicheinter::STATUS_SIGN_SIGNED_ALL_PARTIES) {
92 $searchSignedStatus = 9;
93 }
94
95 if ((int) $searchStatus >= WebPortalFicheinter::STATUS_SIGN_NOT_SIGNED && (int) $searchStatus <= WebPortalFicheinter::STATUS_SIGN_SIGNED_ALL_PARTIES) {
96 $this->formList->search['fk_statut'] = '';
97 $sqlBody .= " AND t.fk_statut = ".((int) WebPortalFicheinter::STATUS_VALIDATED);
98 if ($searchSignedStatus === 0) {
99 $sqlBody .= " AND (t.signed_status IS NULL OR t.signed_status = 0)";
100 } else {
101 $sqlBody .= " AND t.signed_status = ".((int) $searchSignedStatus);
102 }
103 }
104 }
105
106 $this->formList->setSqlRequest('', $sqlBody);
107
108 $this->formList->loadRecords();
109 $this->formList->setParams();
110 $this->formList->setColumnsVisibility();
111
112 return 1;
113 }
114
115
121 public function listSetArrayFields()
122 {
123 $this->formList->arrayfields['download_link']['label'] = 'PDF';
124 $this->formList->arrayfields['download_link']['enabled'] = isModEnabled('intervention');
125 $this->formList->arrayfields['download_link']['checked'] = 1;
126 $this->formList->arrayfields['signature_link']['enabled'] = isModEnabled('intervention');
127 $this->formList->arrayfields['signature_link']['checked'] = 1;
128 }
129
138 public function listPrintValueBefore($field_key, $field_spec, &$record)
139 {
140 global $conf, $langs;
141
142 if ($field_key === 'fk_statut') {
143 $this->formList->object->status = (int) ($record->fk_statut ?? 0);
144 $this->formList->object->statut = (int) ($record->fk_statut ?? 0);
145 $this->formList->object->signed_status = (int) ($record->signed_status ?? 0);
146 return $this->formList->object->getLibStatut(5);
147 }
148
149 if ($field_key === 'download_link') {
150 $filename = dol_sanitizeFileName($this->formList->object->ref);
151 $entity = (int) ($this->formList->object->entity ?? 1);
152 $filedir = $conf->ficheinter->multidir_output[$entity] . '/' . dol_sanitizeFileName($this->formList->object->ref);
153 return $this->formList->form->getDocumentsLink('ficheinter', $filename, $filedir);
154 }
155
156 if ($field_key === 'signature_link') {
157 $status = (int) ($record->fk_statut ?? 0);
158 $signedStatus = (int) ($record->signed_status ?? 0);
159 if ($status === WebPortalFicheinter::STATUS_CLOSED || in_array($signedStatus, array(2, 3, 9), true)) {
160 return $langs->trans('WebPortalInterSignedDone');
161 }
162 return $this->formList->form->getSignatureLink('fichinter', $this->formList->object);
163 }
164
165 return '';
166 }
167
173 public function display()
174 {
176 if (!$context->controllerInstance->checkAccess()) {
177 $this->display404();
178 return;
179 }
180
181 $this->loadTemplate('header');
182 $this->loadTemplate('menu');
183 $this->loadTemplate('hero-header-banner');
184
185 $hookRes = $this->hookPrintPageView();
186 if (empty($hookRes)) {
187 print '<main class="container">';
188 $this->loadTemplate('list');
189 print '</main>';
190 }
191
192 $this->loadTemplate('footer');
193 }
194}
Class for AbstractListController.
static getInstance()
Singleton method to create one instance of this object.
hookPrintPageView($parameters=array())
Execute hook PrintPageView.
display404()
Display error template.
hookDoAction($parameters=array())
Execute hook doActions.
loadTemplate($templateName, $vars=false)
Load a template .tpl file.
Class for FicheinterListController.
checkAccess()
Check current access to controller.
action()
Action method is called before html output can be used to manage security and change context.
listSetArrayFields()
Set array fields for intervention list.
listPrintValueBefore($field_key, $field_spec, &$record)
Called before print value for list.
const STATUS_VALIDATED
Validated status.
const STATUS_CLOSED
Closed.
Class to manage generation of HTML components Only common components for WebPortal must be here.
const STATUS_SIGN_NOT_SIGNED
Status list (short label)
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
isModEnabled($module)
Is Dolibarr module enabled.
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
$context
@method int call_trigger(string $triggerName, ?User $user)
Definition logout.php:42