Merge pull request #35552 from Easya-Solutions/develop_new_rework_webportal_lists
NEW : Rework of the webportal list for more flexibility and more templating
This commit is contained in:
commit
adae01854f
13 changed files with 1140 additions and 710 deletions
40
htdocs/public/webportal/tpl/list-additional-filters.tpl.php
Normal file
40
htdocs/public/webportal/tpl/list-additional-filters.tpl.php
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<!-- file list-additional-filters.tpl.php -->
|
||||
<?php
|
||||
/* Copyright (C) 2025 Open-Dsi <support@open-dsi.fr>
|
||||
*/
|
||||
// Protection to avoid direct call of template
|
||||
if (empty($context) || !is_object($context)) {
|
||||
print "Error, template page can't be called as URL";
|
||||
exit(1);
|
||||
}
|
||||
'@phan-var-force Context $context';
|
||||
'@phan-var-force AbstractListController $this';
|
||||
|
||||
/**
|
||||
* @var Conf $conf
|
||||
* @var HookManager $hookmanager
|
||||
* @var Translate $langs
|
||||
* @var Context $context
|
||||
* @var AbstractListController $this
|
||||
* @var FormListWebPortal $formList
|
||||
*/
|
||||
$formList = &$this->formList;
|
||||
|
||||
// Filters
|
||||
$moreforfilter = '';
|
||||
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $context);
|
||||
if (empty($reshook)) {
|
||||
$moreforfilter .= $hookmanager->resPrint;
|
||||
} else {
|
||||
$moreforfilter = $hookmanager->resPrint;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php if (!empty($moreforfilter)) { ?>
|
||||
<div id="webportal-<?php print dolPrintHTMLForAttribute($formList->object->element) ?>-additional-filters" class="centpercent">
|
||||
<?php print $moreforfilter ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
65
htdocs/public/webportal/tpl/list-filters.tpl.php
Normal file
65
htdocs/public/webportal/tpl/list-filters.tpl.php
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
<!-- file list-filters.tpl.php -->
|
||||
<?php
|
||||
/* Copyright (C) 2025 Open-Dsi <support@open-dsi.fr>
|
||||
*/
|
||||
// Protection to avoid direct call of template
|
||||
if (empty($context) || !is_object($context)) {
|
||||
print "Error, template page can't be called as URL";
|
||||
exit(1);
|
||||
}
|
||||
'@phan-var-force Context $context';
|
||||
'@phan-var-force AbstractListController $this';
|
||||
|
||||
/**
|
||||
* @var Conf $conf
|
||||
* @var HookManager $hookmanager
|
||||
* @var Translate $langs
|
||||
* @var Context $context
|
||||
* @var AbstractListController $this
|
||||
* @var FormListWebPortal $formList
|
||||
*/
|
||||
$formList = &$this->formList;
|
||||
|
||||
?>
|
||||
|
||||
<tr role="search-row">
|
||||
<td data-col="row-checkbox">
|
||||
<button class="btn-filter-icon btn-search-filters-icon" type="submit" name="button_search_x" value="x" aria-label="<?php print dolPrintHTMLForAttribute((string) $langs->trans('Search')) ?>"></button>
|
||||
<button class="btn-filter-icon btn-remove-search-filters-icon" type="submit" name="button_removefilter_x" value="x" aria-label="<?php print dolPrintHTMLForAttribute((string) $langs->trans('RemoveSearchFilters')) ?>"></button>
|
||||
</td>
|
||||
|
||||
<?php foreach ($formList->object->fields as $key => $val) {
|
||||
$alias = $val['alias'] ?? 't.';
|
||||
if (array_key_exists($alias . $key, $formList->arrayfields) && !empty($formList->arrayfields[$alias . $key]['checked'])) {
|
||||
$cssforfield = $formList->getClasseCssList($key, $val);
|
||||
if ($key == 'status') $cssforfield .= ' parentonrightofpage';
|
||||
?>
|
||||
<td <?php print empty($cssforfield) ? '' : 'class="' . dolPrintHTMLForAttribute($cssforfield) . '" ' ?>data-label="<?php print dolPrintHTMLForAttribute((string) $formList->arrayfields[$alias . $key]['label']) ?>" data-col="<?php print dolPrintHTMLForAttribute((string) $key) ?>">
|
||||
<?php print $formList->printSearchInput($key, $val) ?>
|
||||
</td>
|
||||
<?php }
|
||||
}
|
||||
|
||||
// Fields from hook
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $context);
|
||||
print $hookmanager->resPrint;
|
||||
|
||||
// Remain to pay
|
||||
if (array_key_exists('remain_to_pay', $formList->arrayfields) && !empty($formList->arrayfields['remain_to_pay']['checked'])) { ?>
|
||||
<td data-label="<?php print dolPrintHTMLForAttribute((string) $formList->arrayfields['remain_to_pay']['label']) ?>">
|
||||
</td>
|
||||
<?php }
|
||||
|
||||
// Download link
|
||||
if (array_key_exists('download_link', $formList->arrayfields) && !empty($formList->arrayfields['download_link']['checked'])) { ?>
|
||||
<td data-label="<?php print dolPrintHTMLForAttribute((string) $formList->arrayfields['download_link']['label']) ?>">
|
||||
</td>
|
||||
<?php }
|
||||
|
||||
// Signature link
|
||||
if (array_key_exists('signature_link', $formList->arrayfields) && !empty($formList->arrayfields['signature_link']['checked'])) { ?>
|
||||
<td data-label="<?php print dolPrintHTMLForAttribute((string) $formList->arrayfields['signature_link']['label']) ?>">
|
||||
</td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
25
htdocs/public/webportal/tpl/list-footer.tpl.php
Normal file
25
htdocs/public/webportal/tpl/list-footer.tpl.php
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<!-- file list-footer.tpl.php -->
|
||||
<?php
|
||||
/* Copyright (C) 2025 Open-Dsi <support@open-dsi.fr>
|
||||
*/
|
||||
// Protection to avoid direct call of template
|
||||
if (empty($context) || !is_object($context)) {
|
||||
print "Error, template page can't be called as URL";
|
||||
exit(1);
|
||||
}
|
||||
'@phan-var-force Context $context';
|
||||
'@phan-var-force AbstractListController $this';
|
||||
|
||||
/**
|
||||
* @var Conf $conf
|
||||
* @var HookManager $hookmanager
|
||||
* @var Translate $langs
|
||||
* @var Context $context
|
||||
* @var AbstractListController $this
|
||||
* @var FormListWebPortal $formList
|
||||
*/
|
||||
$formList = &$this->formList;
|
||||
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $context); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
113
htdocs/public/webportal/tpl/list-lines.tpl.php
Normal file
113
htdocs/public/webportal/tpl/list-lines.tpl.php
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
<!-- file list-lines.tpl.php -->
|
||||
<?php
|
||||
/* Copyright (C) 2025 Open-Dsi <support@open-dsi.fr>
|
||||
*/
|
||||
// Protection to avoid direct call of template
|
||||
if (empty($context) || !is_object($context)) {
|
||||
print "Error, template page can't be called as URL";
|
||||
exit(1);
|
||||
}
|
||||
'@phan-var-force Context $context';
|
||||
'@phan-var-force AbstractListController $this';
|
||||
|
||||
/**
|
||||
* @var Conf $conf
|
||||
* @var HookManager $hookmanager
|
||||
* @var Translate $langs
|
||||
* @var Context $context
|
||||
* @var AbstractListController $this
|
||||
* @var FormListWebPortal $formList
|
||||
*/
|
||||
$formList = &$this->formList;
|
||||
|
||||
if (!empty($formList->records)) {
|
||||
$totalarray = [
|
||||
'nbfield' => 0,
|
||||
'totalizable' => [],
|
||||
];
|
||||
|
||||
foreach ($formList->records as $i => $record) {
|
||||
// Store properties in $object
|
||||
$formList->setVarsFromFetchObj($record); ?>
|
||||
<tr data-rowid="<?php print dolPrintHTMLForAttribute((string) $formList->object->id) ?>">
|
||||
<td></td>
|
||||
<?php $formList->setTotalValue('', [], $record, $i, $totalarray) ?>
|
||||
|
||||
<?php foreach ($formList->object->fields as $key => $val) {
|
||||
$alias = $val['alias'] ?? 't.';
|
||||
if (array_key_exists($alias . $key, $formList->arrayfields) && !empty($formList->arrayfields[$alias . $key]['checked'])) {
|
||||
$cssforfield = $formList->getClasseCssList($key, $val, true);
|
||||
if (preg_match('/tdoverflow/', $cssforfield)) $cssforfield .= ' classfortooltip';
|
||||
$title = '';
|
||||
if (preg_match('/tdoverflow/', $cssforfield) && !is_numeric($formList->object->$key)) {
|
||||
$title = ' title="' . dolPrintHTMLForAttribute((string) $formList->object->$key) . '"';
|
||||
}
|
||||
?>
|
||||
<td <?php print (empty($cssforfield) ? '' : 'class="' . dolPrintHTMLForAttribute($cssforfield) . '" '); print $title ?>data-label="<?php print dolPrintHTMLForAttribute((string) $formList->arrayfields[$alias . $key]['label']) ?>" data-col="<?php print dolPrintHTMLForAttribute((string) $key) ?>">
|
||||
<?php print $formList->printValue($key, $val, $record, $i, $totalarray);
|
||||
$formList->setTotalValue($key, $val, $record, $i, $totalarray) ?>
|
||||
</td>
|
||||
<?php }
|
||||
}
|
||||
|
||||
// Fields from hook
|
||||
$parameters = array('record' => $record, 'i' => $i, 'totalarray' => &$totalarray);
|
||||
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $context);
|
||||
print $hookmanager->resPrint;
|
||||
|
||||
// Remain to pay
|
||||
if (array_key_exists('remain_to_pay', $formList->arrayfields) && !empty($formList->arrayfields['remain_to_pay']['checked'])) { ?>
|
||||
<td class="nowraponall" data-label="<?php print dolPrintHTMLForAttribute((string) $formList->arrayfields['remain_to_pay']['label']) ?>" data-col="remain_to_pay">
|
||||
<?php print $formList->printValue('remain_to_pay', [], $record, $i, $totalarray);
|
||||
$formList->setTotalValue('remain_to_pay', [], $record, $i, $totalarray) ?>
|
||||
</td>
|
||||
<?php }
|
||||
|
||||
// Download link
|
||||
if (array_key_exists('download_link', $formList->arrayfields) && !empty($formList->arrayfields['download_link']['checked'])) { ?>
|
||||
<td data-label="<?php print dolPrintHTMLForAttribute((string) $formList->arrayfields['download_link']['label']) ?>" data-col="download_link">
|
||||
<?php print $formList->printValue('download_link', [], $record, $i, $totalarray);
|
||||
$formList->setTotalValue('download_link', [], $record, $i, $totalarray) ?>
|
||||
</td>
|
||||
<?php }
|
||||
|
||||
// Signature link
|
||||
if (array_key_exists('signature_link', $formList->arrayfields) && !empty($formList->arrayfields['signature_link']['checked'])) { ?>
|
||||
<td data-label="<?php print dolPrintHTMLForAttribute((string) $formList->arrayfields['signature_link']['label']) ?>" data-col="signature_link">
|
||||
<?php print $formList->printValue('signature_link', [], $record, $i, $totalarray);
|
||||
$formList->setTotalValue('signature_link', [], $record, $i, $totalarray) ?>
|
||||
</td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
<?php }
|
||||
|
||||
// Move fields of totalizable into the common array pos and val
|
||||
if (!empty($totalarray['totalizable']) && is_array($totalarray['totalizable'])) {
|
||||
foreach ($totalarray['totalizable'] as $keytotalizable => $valtotalizable) {
|
||||
$totalarray['pos'][$valtotalizable['pos']] = $keytotalizable;
|
||||
$totalarray['val'][$keytotalizable] = isset($valtotalizable['total']) ? $valtotalizable['total'] : 0;
|
||||
}
|
||||
}
|
||||
// Show total line
|
||||
if (isset($totalarray['pos'])) { ?>
|
||||
<tr>
|
||||
<?php $i = 0;
|
||||
while ($i < $totalarray['nbfield']) {
|
||||
$i++;
|
||||
if (!empty($totalarray['pos'][$i])) { ?>
|
||||
<td class="nowraponall essai">
|
||||
<?php print price(!empty($totalarray['val'][$totalarray['pos'][$i]]) ? $totalarray['val'][$totalarray['pos'][$i]] : 0) ?>
|
||||
</td>
|
||||
<?php } else {
|
||||
if ($i == 1) { ?>
|
||||
<td><?php print $langs->trans("Total") ?></td>
|
||||
<?php } else { ?>
|
||||
<td></td>
|
||||
<?php }
|
||||
}
|
||||
} ?>
|
||||
</tr>
|
||||
<?php }
|
||||
} else { // If no record found ?>
|
||||
<tr><td colspan="<?php print $formList->nbColumn ?>"><span class="opacitymedium"><?php print $langs->trans("NoRecordFound") ?></span></td></tr>
|
||||
<?php } ?>
|
||||
74
htdocs/public/webportal/tpl/list-nav.tpl.php
Normal file
74
htdocs/public/webportal/tpl/list-nav.tpl.php
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
<!-- file list-nav.tpl.php -->
|
||||
<?php
|
||||
/* Copyright (C) 2025 Open-Dsi <support@open-dsi.fr>
|
||||
*/
|
||||
// Protection to avoid direct call of template
|
||||
if (empty($context) || !is_object($context)) {
|
||||
print "Error, template page can't be called as URL";
|
||||
exit(1);
|
||||
}
|
||||
'@phan-var-force Context $context';
|
||||
'@phan-var-force AbstractListController $this';
|
||||
|
||||
/**
|
||||
* @var Conf $conf
|
||||
* @var HookManager $hookmanager
|
||||
* @var Translate $langs
|
||||
* @var Context $context
|
||||
* @var AbstractListController $this
|
||||
* @var FormListWebPortal $formList
|
||||
*/
|
||||
$formList = &$this->formList;
|
||||
|
||||
// Get nb pages
|
||||
$nbPages = 0;
|
||||
if ($formList->limit > 0) {
|
||||
$nbPages = ceil($formList->nbtotalofrecords / $formList->limit);
|
||||
}
|
||||
if ($nbPages <= 0) {
|
||||
$nbPages = 1;
|
||||
}
|
||||
|
||||
$maxPaginationItem = min($nbPages, 5);
|
||||
$minPageNum = max(1, $formList->page - 3);
|
||||
$maxPageNum = min($nbPages, $formList->page + 3);
|
||||
|
||||
$params = $formList->params . '&sortfield=' . $formList->sortfield . '&sortorder=' . $formList->sortorder;
|
||||
$params = preg_replace('/^(&|&)/i', '', $params); // remove first & or &
|
||||
$url = $context->getControllerUrl($context->controller);
|
||||
$url .= (preg_match('/\?/', $url) ? '&' : '?') . $params;
|
||||
|
||||
?>
|
||||
|
||||
<input type="hidden" name="page" value="<?php print dolPrintHTMLForAttribute((string) $formList->page) ?>">
|
||||
<nav id="webportal-<?php print dolPrintHTMLForAttribute($formList->object->element) ?>-pagination">
|
||||
<ul>
|
||||
<li><strong><?php print $langs->trans($formList->titleKey) ?></strong> (<?php print $formList->nbtotalofrecords ?>)</li>
|
||||
</ul>
|
||||
|
||||
<?php if ($nbPages > 1) { ?>
|
||||
<ul class="pages-nav-list">
|
||||
<?php if ($formList->page > 1) { ?>
|
||||
<li><a class="pages-nav-list__icon --prev" aria-label="<?php print dolPrintHTMLForAttribute((string) $langs->trans('AriaPrevPage')) ?>" href="<?php print $url . '&page=' . ($formList->page - 1) ?>"<?php // print ($formList->page <= 1 ? ' disabled' : '') ?>></a></li>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($minPageNum > 1) { ?>
|
||||
<li><a class="pages-nav-list__link <?php print ($formList->page == 1 ? '--active' : '') ?>" aria-label="<?php print dolPrintHTMLForAttribute((string) $langs->trans('AriaPageX', 1)) ?>" href="<?php print $url . '&page=1' ?>">1</a></li>
|
||||
<li>…</li>
|
||||
<?php } ?>
|
||||
|
||||
<?php for ($p = $minPageNum; $p <= $maxPageNum; $p++) { ?>
|
||||
<li><a class="pages-nav-list__link <?php print ($formList->page === $p ? '--active' : '') ?>" aria-label="<?php print dolPrintHTMLForAttribute((string) $langs->trans('AriaPageX', $p)) ?>" href="<?php print $url . '&page=' . $p ?>"><?php print $p ?></a></li>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($maxPaginationItem < $nbPages) { ?>
|
||||
<li>…</li>
|
||||
<li><a class="pages-nav-list__link <?php print ($formList->page == $nbPages ? '--active' : '') ?>" aria-label="<?php print dolPrintHTMLForAttribute((string) $langs->trans('AriaPageX', $nbPages)) ?>" href="<?php print $url . '&page=' . $nbPages ?>"><?php print $nbPages ?></a></li>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($formList->page < $nbPages) { ?>
|
||||
<li><a class="pages-nav-list__icon --next" aria-label="<?php print dolPrintHTMLForAttribute((string) $langs->trans('AriaNextPage')) ?>" href="<?php print $url . '&page=' . ($formList->page + 1) ?>"<?php // print ($formList->page >= $nbPages ? ' disabled' : '') ?>></a></li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
<?php } ?>
|
||||
</nav>
|
||||
75
htdocs/public/webportal/tpl/list-titles.tpl.php
Normal file
75
htdocs/public/webportal/tpl/list-titles.tpl.php
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
<!-- file list-titles.tpl.php -->
|
||||
<?php
|
||||
/* Copyright (C) 2025 Open-Dsi <support@open-dsi.fr>
|
||||
*/
|
||||
// Protection to avoid direct call of template
|
||||
if (empty($context) || !is_object($context)) {
|
||||
print "Error, template page can't be called as URL";
|
||||
exit(1);
|
||||
}
|
||||
'@phan-var-force Context $context';
|
||||
'@phan-var-force AbstractListController $this';
|
||||
|
||||
/**
|
||||
* @var Conf $conf
|
||||
* @var HookManager $hookmanager
|
||||
* @var Translate $langs
|
||||
* @var Context $context
|
||||
* @var AbstractListController $this
|
||||
* @var FormListWebPortal $formList
|
||||
*/
|
||||
$formList = &$this->formList;
|
||||
|
||||
$url = $context->getControllerUrl($context->controller);
|
||||
$url .= (preg_match('/\?/', $url) ? '&' : '?') . preg_replace('/^(&|&)/i', '', $formList->params/* . "&page=" . urlencode($formList->page)*/);
|
||||
|
||||
// Make array[sort field => sort order] for this list
|
||||
$sortList = array_combine(explode(",", $formList->sortfield), explode(",", $formList->sortorder));
|
||||
|
||||
$formList->nbColumn = 0;
|
||||
|
||||
?>
|
||||
|
||||
<!-- Fields title label -->
|
||||
<tr>
|
||||
<th data-col="row-checkbox"></th>
|
||||
<?php $formList->nbColumn++ ?>
|
||||
|
||||
<?php foreach ($formList->object->fields as $key => $val) {
|
||||
$alias = $val['alias'] ?? 't.';
|
||||
if (array_key_exists($alias . $key, $formList->arrayfields) && !empty($formList->arrayfields[$alias . $key]['checked'])) {
|
||||
$order = array_key_exists($alias . $key, $sortList) ? strtolower(trim($sortList[$alias . $key])) : '';
|
||||
$link_url = $url . '&sortfield=' . urlencode($alias . $key) . '&sortorder=' . ($order == 'desc' ? 'asc' : 'desc');
|
||||
$cssforfield = $formList->getClasseCssList($key, $val);
|
||||
$cssforfield = preg_replace('/small\s*/', '', $cssforfield);
|
||||
?>
|
||||
<th <?php print empty($cssforfield) ? '' : 'class="' . dolPrintHTMLForAttribute($cssforfield) . '" ' ?>data-col="<?php print dolPrintHTMLForAttribute((string) $key) ?>" scope="col"<?php print (!empty($order) ? ' table-order="' . dolPrintHTMLForAttribute($order) . '"' : '') ?>>
|
||||
<a href="<?php print dolPrintHTMLForAttribute($link_url) ?>"><?php print $langs->trans((string) $formList->arrayfields[$alias . $key]['label']) ?></a>
|
||||
</th>
|
||||
<?php $formList->nbColumn++;
|
||||
}
|
||||
}
|
||||
|
||||
// Hook fields
|
||||
$parameters = array('sortList' => $sortList);
|
||||
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $context);
|
||||
print $hookmanager->resPrint;
|
||||
|
||||
// Remain to pay
|
||||
if (array_key_exists('remain_to_pay', $formList->arrayfields) && !empty($formList->arrayfields['remain_to_pay']['checked'])) { ?>
|
||||
<th scope="col"><?php print $langs->trans((string) $formList->arrayfields['remain_to_pay']['label']) ?></th>
|
||||
<?php $formList->nbColumn++;
|
||||
}
|
||||
|
||||
// Download link
|
||||
if (array_key_exists('download_link', $formList->arrayfields) && !empty($formList->arrayfields['download_link']['checked'])) { ?>
|
||||
<th scope="col"><?php print $langs->trans((string) $formList->arrayfields['download_link']['label']) ?></th>
|
||||
<?php $formList->nbColumn++;
|
||||
}
|
||||
|
||||
// Signature link
|
||||
if (array_key_exists('signature_link', $formList->arrayfields) && !empty($formList->arrayfields['signature_link']['checked'])) { ?>
|
||||
<th scope="col"><?php print $langs->trans((string) $formList->arrayfields['signature_link']['label']) ?></th>
|
||||
<?php $formList->nbColumn++;
|
||||
} ?>
|
||||
</tr>
|
||||
52
htdocs/public/webportal/tpl/list.tpl.php
Normal file
52
htdocs/public/webportal/tpl/list.tpl.php
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
<!-- file list.tpl.php -->
|
||||
<?php
|
||||
/* Copyright (C) 2025 Open-Dsi <support@open-dsi.fr>
|
||||
*/
|
||||
// Protection to avoid direct call of template
|
||||
if (empty($context) || !is_object($context)) {
|
||||
print "Error, template page can't be called as URL";
|
||||
exit(1);
|
||||
}
|
||||
'@phan-var-force Context $context';
|
||||
'@phan-var-force AbstractListController $this';
|
||||
|
||||
/**
|
||||
* @var Conf $conf
|
||||
* @var HookManager $hookmanager
|
||||
* @var Translate $langs
|
||||
* @var Context $context
|
||||
* @var AbstractListController $this
|
||||
* @var FormListWebPortal $formList
|
||||
*/
|
||||
$formList = &$this->formList;
|
||||
|
||||
?>
|
||||
|
||||
<form method="POST" id="searchFormList" action="<?php print $context->getControllerUrl($context->controller, '', false) ?>">
|
||||
<?php print $context->getFormToken() ?>
|
||||
<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">
|
||||
<input type="hidden" name="action" value="list">
|
||||
<input type="hidden" name="sortfield" value="<?php print dolPrintHTMLForAttribute($formList->sortfield) ?>">
|
||||
<input type="hidden" name="sortorder" value="<?php print dolPrintHTMLForAttribute($formList->sortorder) ?>">
|
||||
<input type="hidden" name="contextpage" value="<?php print dolPrintHTMLForAttribute($formList->contextpage) ?>">
|
||||
|
||||
<?php $this->loadTemplate('list-nav') ?>
|
||||
|
||||
<?php $this->loadTemplate('list-additional-filters') ?>
|
||||
|
||||
<table id="webportal-<?php print dolPrintHTMLForAttribute($formList->object->element) ?>-list" responsive="scroll" role="grid">
|
||||
<thead>
|
||||
<?php $this->loadTemplate('list-filters') ?>
|
||||
|
||||
<?php $this->loadTemplate('list-titles') ?>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<?php $this->loadTemplate('list-lines') ?>
|
||||
</tbody>
|
||||
|
||||
<tfoot>
|
||||
<?php $this->loadTemplate('list-footer') ?>
|
||||
</tfoot>
|
||||
</table>
|
||||
</form>
|
||||
|
|
@ -56,6 +56,11 @@ class Controller
|
|||
*/
|
||||
public $tplPath;
|
||||
|
||||
/**
|
||||
* @var FormListWebPortal Form for list
|
||||
*/
|
||||
public $formList;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,82 @@
|
|||
<?php
|
||||
/* Copyright (C) 2023-2024 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2023-2024 Lionel Vessiller <lvessiller@easya.solutions>
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/../class/controller.class.php';
|
||||
|
||||
/**
|
||||
* \file htdocs/webportal/controllers/abstractlist.controller.class.php
|
||||
* \ingroup webportal
|
||||
* \brief This file is an abstract controller with shared logic to display a list
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class for AbstractListController
|
||||
*/
|
||||
abstract class AbstractListController extends Controller
|
||||
{
|
||||
/**
|
||||
* @var FormListWebPortal Form for list
|
||||
*/
|
||||
public $formList;
|
||||
|
||||
/**
|
||||
* Set array fields
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function listSetArrayFields()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Set search values
|
||||
*
|
||||
* @param bool $clear Clear search values
|
||||
* @return void
|
||||
*/
|
||||
public function listSetSearchValues($clear = false)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Called before print value for list
|
||||
*
|
||||
* @param string $field_key Field key
|
||||
* @param array<string,mixed> $field_spec Field specification
|
||||
* @param stdClass $record Contain data of object from database
|
||||
* @return string HTML input
|
||||
*/
|
||||
public function listPrintValueBefore($field_key, $field_spec, &$record)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after print value for list
|
||||
*
|
||||
* @param string $field_key Field key
|
||||
* @param array<string,mixed> $field_spec Field specification
|
||||
* @param stdClass $record Contain data of object from database
|
||||
* @param string $out Current HTML input
|
||||
* @return string HTML input
|
||||
*/
|
||||
public function listPrintValueAfter($field_key, $field_spec, &$record, $out)
|
||||
{
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
|
|
@ -22,17 +22,14 @@
|
|||
* \brief This file is a controller for invoice list
|
||||
*/
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT . '/webportal/class/html.formlistwebportal.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/webportal/controllers/abstractlist.controller.class.php';
|
||||
|
||||
/**
|
||||
* Class for InvoiceListController
|
||||
*/
|
||||
class InvoiceListController extends Controller
|
||||
class InvoiceListController extends AbstractListController
|
||||
{
|
||||
/**
|
||||
* @var FormListWebPortal Form for list
|
||||
*/
|
||||
public $formList;
|
||||
|
||||
|
||||
/**
|
||||
* Check current access to controller
|
||||
*
|
||||
|
|
@ -60,8 +57,6 @@ class InvoiceListController extends Controller
|
|||
return -1;
|
||||
}
|
||||
|
||||
dol_include_once('/webportal/class/html.formlistwebportal.class.php');
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('bills', 'companies', 'products', 'categories'));
|
||||
|
||||
|
|
@ -70,16 +65,25 @@ class InvoiceListController extends Controller
|
|||
$context->menu_active[] = 'invoice_list';
|
||||
|
||||
// set form list
|
||||
$formListWebPortal = new FormListWebPortal($this->db);
|
||||
$formListWebPortal->init('invoice');
|
||||
$this->formList = new FormListWebPortal($this->db);
|
||||
$this->formList->init($this, 'invoice');
|
||||
|
||||
// hook for action
|
||||
$hookRes = $this->hookDoAction();
|
||||
if (empty($hookRes)) {
|
||||
$formListWebPortal->doActions();
|
||||
$this->formList->doActions();
|
||||
}
|
||||
|
||||
$this->formList = $formListWebPortal;
|
||||
$this->formList->setSqlRequest();
|
||||
|
||||
// filter on logged third-party
|
||||
$this->formList->sql_body .= " AND t.fk_soc = " . ((int) $context->logged_thirdparty->id);
|
||||
// discard record with status draft
|
||||
$this->formList->sql_body .= " AND t.fk_statut <> 0";
|
||||
|
||||
$this->formList->loadRecords();
|
||||
$this->formList->setParams();
|
||||
$this->formList->setColumnsVisibility();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -105,7 +109,7 @@ class InvoiceListController extends Controller
|
|||
if (empty($hookRes)) {
|
||||
print '<main class="container">';
|
||||
//print '<figure>';
|
||||
print $this->formList->elementList($context);
|
||||
$this->loadTemplate('list');
|
||||
//print '</figure>';
|
||||
print '</main>';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,18 +24,13 @@
|
|||
*/
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT . '/webportal/class/html.formlistwebportal.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/webportal/controllers/abstractlist.controller.class.php';
|
||||
|
||||
/**
|
||||
* Class for OrderListController
|
||||
*/
|
||||
class OrderListController extends Controller
|
||||
class OrderListController extends AbstractListController
|
||||
{
|
||||
/**
|
||||
* @var FormListWebPortal Form for list
|
||||
*/
|
||||
public $formList;
|
||||
|
||||
|
||||
/**
|
||||
* Check current access to controller
|
||||
*
|
||||
|
|
@ -71,16 +66,25 @@ class OrderListController extends Controller
|
|||
$context->menu_active[] = 'order_list';
|
||||
|
||||
// set form list
|
||||
$formListWebPortal = new FormListWebPortal($this->db);
|
||||
$formListWebPortal->init('order');
|
||||
$this->formList = new FormListWebPortal($this->db);
|
||||
$this->formList->init($this, 'order');
|
||||
|
||||
// hook for action
|
||||
$hookRes = $this->hookDoAction();
|
||||
if (empty($hookRes)) {
|
||||
$formListWebPortal->doActions();
|
||||
$this->formList->doActions();
|
||||
}
|
||||
|
||||
$this->formList = $formListWebPortal;
|
||||
$this->formList->setSqlRequest();
|
||||
|
||||
// filter on logged third-party
|
||||
$this->formList->sql_body .= " AND t.fk_soc = " . ((int) $context->logged_thirdparty->id);
|
||||
// discard record with status draft
|
||||
$this->formList->sql_body .= " AND t.fk_statut <> 0";
|
||||
|
||||
$this->formList->loadRecords();
|
||||
$this->formList->setParams();
|
||||
$this->formList->setColumnsVisibility();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -106,7 +110,7 @@ class OrderListController extends Controller
|
|||
if (empty($hookRes)) {
|
||||
print '<main class="container">';
|
||||
//print '<figure>';
|
||||
print $this->formList->elementList($context);
|
||||
$this->loadTemplate('list');
|
||||
//print '</figure>';
|
||||
print '</main>';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,18 +24,13 @@
|
|||
*/
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT . '/webportal/class/html.formlistwebportal.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/webportal/controllers/abstractlist.controller.class.php';
|
||||
|
||||
/**
|
||||
* Class for PropalListController
|
||||
*/
|
||||
class PropalListController extends Controller
|
||||
class PropalListController extends AbstractListController
|
||||
{
|
||||
/**
|
||||
* @var FormListWebPortal Form for list
|
||||
*/
|
||||
public $formList;
|
||||
|
||||
|
||||
/**
|
||||
* Check current access to controller
|
||||
*
|
||||
|
|
@ -74,16 +69,25 @@ class PropalListController extends Controller
|
|||
$context->menu_active[] = 'propal_list';
|
||||
|
||||
// set form list
|
||||
$formListWebPortal = new FormListWebPortal($this->db);
|
||||
$formListWebPortal->init('propal');
|
||||
$this->formList = new FormListWebPortal($this->db);
|
||||
$this->formList->init($this, 'propal');
|
||||
|
||||
// hook for action
|
||||
$hookRes = $this->hookDoAction();
|
||||
if (empty($hookRes)) {
|
||||
$formListWebPortal->doActions();
|
||||
$this->formList->doActions();
|
||||
}
|
||||
|
||||
$this->formList = $formListWebPortal;
|
||||
$this->formList->setSqlRequest();
|
||||
|
||||
// filter on logged third-party
|
||||
$this->formList->sql_body .= " AND t.fk_soc = " . ((int) $context->logged_thirdparty->id);
|
||||
// discard record with status draft
|
||||
$this->formList->sql_body .= " AND t.fk_statut <> 0";
|
||||
|
||||
$this->formList->loadRecords();
|
||||
$this->formList->setParams();
|
||||
$this->formList->setColumnsVisibility();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -109,7 +113,7 @@ class PropalListController extends Controller
|
|||
if (empty($hookRes)) {
|
||||
print '<main class="container">';
|
||||
//print '<figure>';
|
||||
print $this->formList->elementList($context);
|
||||
$this->loadTemplate('list');
|
||||
//print '</figure>';
|
||||
print '</main>';
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue