dolibarr 24.0.0-beta
invoicelist.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 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
25require_once DOL_DOCUMENT_ROOT . '/webportal/class/html.formlistwebportal.class.php';
26require_once DOL_DOCUMENT_ROOT . '/webportal/controllers/abstractlist.controller.class.php';
27
32{
38 public function checkAccess()
39 {
40 $this->accessRight = isModEnabled('invoice') && getDolGlobalInt('WEBPORTAL_INVOICE_LIST_ACCESS');
41
42 return parent::checkAccess();
43 }
44
51 public function action()
52 {
53 global $langs;
54
56 if (!$context->controllerInstance->checkAccess()) {
57 return -1;
58 }
59
60 // Load translation files required by the page
61 $langs->loadLangs(array('bills', 'companies', 'products', 'categories'));
62
63 $context->title = $langs->trans('WebPortalInvoiceListTitle');
64 $context->desc = $langs->trans('WebPortalInvoiceListDesc');
65 $context->menu_active[] = 'invoice_list';
66
67 // set form list
68 $this->formList = new FormListWebPortal($this->db);
69 $this->formList->init($this, 'invoice');
70
71 // hook for action
72 $hookRes = $this->hookDoAction();
73 if (empty($hookRes)) {
74 $this->formList->doActions();
75 }
76
77 // filter on logged third-party
78 $sqlBody = " AND t.fk_soc = ".((int) $context->logged_thirdparty->id);
79 // discard record with status draft
80 $sqlBody .= " AND t.fk_statut <> 0";
81 $this->formList->setSqlRequest('', $sqlBody);
82
83 $this->formList->loadRecords();
84 $this->formList->setParams();
85 $this->formList->setColumnsVisibility();
86
87 return 1;
88 }
89
95 public function display()
96 {
98 if (!$context->controllerInstance->checkAccess()) {
99 $this->display404();
100 return;
101 }
102
103 $this->loadTemplate('header');
104 $this->loadTemplate('menu');
105 $this->loadTemplate('hero-header-banner');
106
107 $hookRes = $this->hookPrintPageView();
108 if (empty($hookRes)) {
109 print '<main class="container">';
110 //print '<figure>';
111 $this->loadTemplate('list');
112 //print '</figure>';
113 print '</main>';
114 }
115
116 $this->loadTemplate('footer');
117 }
118}
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 InvoiceListController.
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