dolibarr/htdocs/webportal/controllers/propallist.controller.class.php

123 lines
3.4 KiB
PHP
Raw Permalink Normal View History

2023-09-12 13:12:30 +00:00
<?php
2024-01-08 10:40:03 +00:00
/* Copyright (C) 2023-2024 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2023-2024 Lionel Vessiller <lvessiller@easya.solutions>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
2023-09-12 13:12:30 +00:00
*
* 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 <https://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/webportal/controllers/propallist.controller.class.php
2023-09-12 13:12:30 +00:00
* \ingroup webportal
* \brief This file is a controller for propal list
*/
require_once DOL_DOCUMENT_ROOT . '/webportal/class/html.formlistwebportal.class.php';
2025-11-03 14:49:33 +00:00
require_once DOL_DOCUMENT_ROOT . '/webportal/controllers/abstractlist.controller.class.php';
2023-09-12 13:12:30 +00:00
/**
* Class for PropalListController
*/
2025-11-03 14:49:33 +00:00
class PropalListController extends AbstractListController
2023-09-12 13:12:30 +00:00
{
2023-09-12 13:26:12 +00:00
/**
2023-09-12 13:12:30 +00:00
* Check current access to controller
*
* @return bool
*/
public function checkAccess()
2023-09-12 13:26:12 +00:00
{
2023-09-12 13:12:30 +00:00
$this->accessRight = isModEnabled('propal') && getDolGlobalInt('WEBPORTAL_PROPAL_LIST_ACCESS');
return parent::checkAccess();
}
/**
* Action method is called before html output
* can be used to manage security and change context
*
2024-02-08 13:11:54 +00:00
* @return int Return integer < 0 on error, > 0 on success
2023-09-12 13:12:30 +00:00
*/
public function action()
2023-09-12 13:26:12 +00:00
{
2023-09-28 13:04:28 +00:00
global $langs;
2023-09-12 13:12:30 +00:00
$context = Context::getInstance();
if (!$context->controllerInstance->checkAccess()) {
2024-02-08 13:11:54 +00:00
return -1;
2023-09-12 13:26:12 +00:00
}
2023-09-12 13:12:30 +00:00
2023-09-12 13:26:12 +00:00
// Load translation files required by the page
$langs->loadLangs(array('companies', 'propal', 'compta', 'bills', 'orders', 'products', 'categories'));
if (isModEnabled('shipping')) {
2023-09-12 13:26:12 +00:00
$langs->loadLangs(array('sendings'));
}
2023-09-12 13:12:30 +00:00
$context->title = $langs->trans('WebPortalPropalListTitle');
$context->desc = $langs->trans('WebPortalPropalListDesc');
$context->menu_active[] = 'propal_list';
2023-09-12 13:26:12 +00:00
// set form list
$this->formList = new FormListWebPortal($this->db);
$this->formList->init($this, 'propal');
2023-09-12 13:12:30 +00:00
2023-09-12 13:26:12 +00:00
// hook for action
$hookRes = $this->hookDoAction();
if (empty($hookRes)) {
$this->formList->doActions();
2023-09-12 13:26:12 +00:00
}
2023-09-12 13:12:30 +00:00
// filter on logged third-party
$sqlBody = " AND t.fk_soc = ".((int) $context->logged_thirdparty->id);
// discard record with status draft
$sqlBody .= " AND t.fk_statut <> 0";
$this->formList->setSqlRequest('', $sqlBody);
$this->formList->loadRecords();
$this->formList->setParams();
$this->formList->setColumnsVisibility();
2024-02-08 13:11:54 +00:00
return 1;
2023-09-12 13:12:30 +00:00
}
/**
* Display
2023-09-12 13:26:12 +00:00
*
2023-09-12 13:12:30 +00:00
* @return void
*/
2023-09-12 13:26:12 +00:00
public function display()
{
$context = Context::getInstance();
if (!$context->controllerInstance->checkAccess()) {
$this->display404();
return;
}
$this->loadTemplate('header');
$this->loadTemplate('menu');
2023-09-28 08:44:22 +00:00
$this->loadTemplate('hero-header-banner');
2023-09-12 13:26:12 +00:00
$hookRes = $this->hookPrintPageView();
if (empty($hookRes)) {
print '<main class="container">';
//print '<figure>';
$this->loadTemplate('list');
2023-09-12 13:26:12 +00:00
//print '</figure>';
print '</main>';
}
$this->loadTemplate('footer');
}
2023-09-12 13:12:30 +00:00
}