dolibarr 23.0.3
propallist.controller.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2023-2024 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2023-2024 Lionel Vessiller <lvessiller@easya.solutions>
4 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
26require_once DOL_DOCUMENT_ROOT . '/webportal/class/html.formlistwebportal.class.php';
27require_once DOL_DOCUMENT_ROOT . '/webportal/controllers/abstractlist.controller.class.php';
28
33{
39 public function checkAccess()
40 {
41 $this->accessRight = isModEnabled('propal') && getDolGlobalInt('WEBPORTAL_PROPAL_LIST_ACCESS');
42
43 return parent::checkAccess();
44 }
45
52 public function action()
53 {
54 global $langs;
55
57 if (!$context->controllerInstance->checkAccess()) {
58 return -1;
59 }
60
61 // Load translation files required by the page
62 $langs->loadLangs(array('companies', 'propal', 'compta', 'bills', 'orders', 'products', 'categories'));
63 if (isModEnabled('shipping')) {
64 $langs->loadLangs(array('sendings'));
65 }
66
67 $context->title = $langs->trans('WebPortalPropalListTitle');
68 $context->desc = $langs->trans('WebPortalPropalListDesc');
69 $context->menu_active[] = 'propal_list';
70
71 // set form list
72 $this->formList = new FormListWebPortal($this->db);
73 $this->formList->init($this, 'propal');
74
75 // hook for action
76 $hookRes = $this->hookDoAction();
77 if (empty($hookRes)) {
78 $this->formList->doActions();
79 }
80
81 $this->formList->setSqlRequest();
82
83 // filter on logged third-party
84 $this->formList->sql_body .= " AND t.fk_soc = " . ((int) $context->logged_thirdparty->id);
85 // discard record with status draft
86 $this->formList->sql_body .= " AND t.fk_statut <> 0";
87
88 $this->formList->loadRecords();
89 $this->formList->setParams();
90 $this->formList->setColumnsVisibility();
91
92 return 1;
93 }
94
100 public function display()
101 {
103 if (!$context->controllerInstance->checkAccess()) {
104 $this->display404();
105 return;
106 }
107
108 $this->loadTemplate('header');
109 $this->loadTemplate('menu');
110 $this->loadTemplate('hero-header-banner');
111
112 $hookRes = $this->hookPrintPageView();
113 if (empty($hookRes)) {
114 print '<main class="container">';
115 //print '<figure>';
116 $this->loadTemplate('list');
117 //print '</figure>';
118 print '</main>';
119 }
120
121 $this->loadTemplate('footer');
122 }
123}
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 to manage generation of HTML components Only common components for WebPortal must be here.
Class for PropalListController.
checkAccess()
Check current access to controller.
action()
Action method is called before html output can be used to manage security and change context.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
isModEnabled($module)
Is Dolibarr module enabled.
$context
@method int call_trigger(string $triggerName, ?User $user)
Definition logout.php:42