Clean code
This commit is contained in:
parent
c8f918265a
commit
6d4a90b543
@ -103,6 +103,7 @@ class Adherent extends CommonObject
|
||||
* @var int Thirdparty ID
|
||||
*/
|
||||
public $fk_soc;
|
||||
public $socid;
|
||||
|
||||
/**
|
||||
* @var string Address
|
||||
@ -1262,14 +1263,15 @@ class Adherent extends CommonObject
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as dep ON d.state_id = dep.rowid";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON d.rowid = u.fk_member";
|
||||
$sql .= " WHERE d.fk_adherent_type = t.rowid";
|
||||
if ($rowid)
|
||||
$sql .= " AND d.rowid=".$rowid;
|
||||
elseif ($ref || $fk_soc) {
|
||||
if ($rowid) {
|
||||
$sql .= " AND d.rowid=".((int) $rowid);
|
||||
} elseif ($ref || $fk_soc) {
|
||||
$sql .= " AND d.entity IN (".getEntity('adherent').")";
|
||||
if ($ref)
|
||||
if ($ref) {
|
||||
$sql .= " AND d.rowid='".$this->db->escape($ref)."'";
|
||||
elseif ($fk_soc > 0)
|
||||
$sql .= " AND d.fk_soc=".$fk_soc;
|
||||
} elseif ($fk_soc > 0) {
|
||||
$sql .= " AND d.fk_soc=".((int) $fk_soc);
|
||||
}
|
||||
} elseif ($ref_ext) {
|
||||
$sql .= " AND d.ref_ext='".$this->db->escape($ref_ext)."'";
|
||||
}
|
||||
|
||||
@ -918,9 +918,10 @@ class FormOther
|
||||
* @param int $useempty Show empty in list
|
||||
* @param int $longlabel Show long label
|
||||
* @param string $morecss More Css
|
||||
* @param bool $addjscombo Add js combo
|
||||
* @return string
|
||||
*/
|
||||
public function select_month($selected = '', $htmlname = 'monthid', $useempty = 0, $longlabel = 0, $morecss = 'maxwidth50imp valignmiddle')
|
||||
public function select_month($selected = '', $htmlname = 'monthid', $useempty = 0, $longlabel = 0, $morecss = 'minwidth50 maxwidth75imp valignmiddle', $addjscombo = false)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $langs;
|
||||
@ -947,6 +948,15 @@ class FormOther
|
||||
$select_month .= '</option>';
|
||||
}
|
||||
$select_month .= '</select>';
|
||||
|
||||
// Add code for jquery to use multiselect
|
||||
if ($addjscombo)
|
||||
{
|
||||
// Enhance with select2
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
|
||||
$select_month .= ajax_combobox($htmlname);
|
||||
}
|
||||
|
||||
return $select_month;
|
||||
}
|
||||
|
||||
@ -986,18 +996,10 @@ class FormOther
|
||||
* @param bool $addjscombo Add js combo
|
||||
* @return string
|
||||
*/
|
||||
public function selectyear($selected = '', $htmlname = 'yearid', $useempty = 0, $min_year = 10, $max_year = 5, $offset = 0, $invert = 0, $option = '', $morecss = 'valignmiddle maxwidth75imp', $addjscombo = false)
|
||||
public function selectyear($selected = '', $htmlname = 'yearid', $useempty = 0, $min_year = 10, $max_year = 5, $offset = 0, $invert = 0, $option = '', $morecss = 'valignmiddle width75', $addjscombo = false)
|
||||
{
|
||||
$out = '';
|
||||
|
||||
// Add code for jquery to use multiselect
|
||||
if ($addjscombo)
|
||||
{
|
||||
// Enhance with select2
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
|
||||
$out .= ajax_combobox($htmlname);
|
||||
}
|
||||
|
||||
$currentyear = date("Y") + $offset;
|
||||
$max_year = $currentyear + $max_year;
|
||||
$min_year = $currentyear - $min_year;
|
||||
@ -1028,6 +1030,14 @@ class FormOther
|
||||
}
|
||||
$out .= "</select>\n";
|
||||
|
||||
// Add code for jquery to use multiselect
|
||||
if ($addjscombo)
|
||||
{
|
||||
// Enhance with select2
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
|
||||
$out .= ajax_combobox($htmlname);
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/holiday.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||
|
||||
// Get parameters
|
||||
@ -49,7 +49,7 @@ $ref = GETPOST('ref', 'alpha');
|
||||
$fuserid = (GETPOST('fuserid', 'int') ?GETPOST('fuserid', 'int') : $user->id);
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("holiday", "mails"));
|
||||
$langs->loadLangs(array("other", "holiday", "mails"));
|
||||
|
||||
$now = dol_now();
|
||||
|
||||
|
||||
@ -1,42 +0,0 @@
|
||||
<?php
|
||||
/* Copyright (C) 2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2011 Dimitri Mouillard <dmouillard@teclib.com>
|
||||
* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
*
|
||||
* 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/holiday/common.inc.php
|
||||
* \ingroup holiday
|
||||
* \brief Common load of data
|
||||
*/
|
||||
|
||||
require_once realpath(__DIR__).'/../main.inc.php';
|
||||
if (!class_exists('Holiday')) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
|
||||
}
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('user', 'other', 'holiday'));
|
||||
|
||||
if (empty($conf->holiday->enabled))
|
||||
{
|
||||
llxHeader('', $langs->trans('CPTitreMenu'));
|
||||
print '<div class="tabBar">';
|
||||
print '<span style="color: #FF0000;">'.$langs->trans('NotActiveModCP').'</span>';
|
||||
print '</div>';
|
||||
llxFooter();
|
||||
exit();
|
||||
}
|
||||
@ -28,10 +28,10 @@
|
||||
|
||||
require '../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadlangs(array('users', 'hrm'));
|
||||
$langs->loadlangs(array('users', 'other', 'holiday', 'hrm'));
|
||||
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'defineholidaylist';
|
||||
@ -56,7 +56,7 @@ if (!$sortorder) $sortorder = "ASC";
|
||||
if ($user->socid > 0) accessforbidden();
|
||||
|
||||
// If the user does not have perm to read the page
|
||||
if (!$user->rights->holiday->read) accessforbidden();
|
||||
if (empty($user->rights->holiday->read)) accessforbidden();
|
||||
|
||||
|
||||
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
|
||||
@ -65,6 +65,17 @@ $extrafields = new ExtraFields($db);
|
||||
|
||||
$holiday = new Holiday($db);
|
||||
|
||||
if (empty($conf->holiday->enabled))
|
||||
{
|
||||
llxHeader('', $langs->trans('CPTitreMenu'));
|
||||
print '<div class="tabBar">';
|
||||
print '<span style="color: #FF0000;">'.$langs->trans('NotActiveModCP').'</span>';
|
||||
print '</div>';
|
||||
llxFooter();
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
|
||||
@ -32,12 +32,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('users', 'holiday', 'hrm'));
|
||||
$langs->loadLangs(array('users', 'other', 'holiday', 'hrm'));
|
||||
|
||||
// Protection if external user
|
||||
if ($user->socid > 0) accessforbidden();
|
||||
@ -152,6 +152,15 @@ if (is_array($extrafields->attributes[$object->table_element]['label']) && count
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($conf->holiday->enabled))
|
||||
{
|
||||
llxHeader('', $langs->trans('CPTitreMenu'));
|
||||
print '<div class="tabBar">';
|
||||
print '<span style="color: #FF0000;">'.$langs->trans('NotActiveModCP').'</span>';
|
||||
print '</div>';
|
||||
llxFooter();
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
@ -179,8 +179,8 @@ print load_fiche_titre($langs->trans('MenuReportMonth'), '', 'title_hrm');
|
||||
|
||||
// Selection filter
|
||||
print '<div class="tabBar">';
|
||||
print $formother->select_month($search_month, 'remonth');
|
||||
print $formother->select_year($search_year, 'reyear');
|
||||
print $formother->select_month($search_month, 'remonth', 0, 0, 'minwidth50 maxwidth75imp valignmiddle', true);
|
||||
print $formother->selectyear($search_year, 'reyear', 0, 10, 5, 0, 0, '', 'valignmiddle width75', true);
|
||||
print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Search")).'" />';
|
||||
print '</div>';
|
||||
print '<br>';
|
||||
|
||||
@ -34,7 +34,7 @@ if (empty($user->rights->holiday->define_holiday) || $user->socid > 0) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
|
||||
|
||||
$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
|
||||
$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
|
||||
@ -72,7 +72,7 @@ if (!$sortorder) $sortorder = "DESC";
|
||||
if (!$user->rights->holiday->readall) accessforbidden();
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->load('users');
|
||||
$langs->loadLangs(array('users', 'other', 'holiday'));
|
||||
|
||||
// Initialize technical objects
|
||||
$object = new Holiday($db);
|
||||
@ -83,6 +83,16 @@ $hookmanager->initHooks(array('leavemovementlist')); // Note that conf->hooks_mo
|
||||
$arrayfields = array();
|
||||
$arrayofmassactions = array();
|
||||
|
||||
if (empty($conf->holiday->enabled))
|
||||
{
|
||||
llxHeader('', $langs->trans('CPTitreMenu'));
|
||||
print '<div class="tabBar">';
|
||||
print '<span style="color: #FF0000;">'.$langs->trans('NotActiveModCP').'</span>';
|
||||
print '</div>';
|
||||
llxFooter();
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
@ -263,9 +273,9 @@ if (!empty($arrayfields['cpl.rowid']['checked'])) {
|
||||
|
||||
// Filter: Date
|
||||
if (!empty($arrayfields['cpl.date_action']['checked'])) {
|
||||
print '<td class="liste_titre right">';
|
||||
print '<td class="liste_titre center">';
|
||||
print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month" value="'.dol_escape_htmltag($search_month).'">';
|
||||
print $formother->selectyear($search_year, 'search_year', 1, 10, 5, 0, 0, '', 'maxwidth200', true);
|
||||
print $formother->selectyear($search_year, 'search_year', 1, 10, 5, 0, 0, '', 'valignmiddle width75', true);
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
|
||||
@ -17,20 +17,6 @@
|
||||
<!-- Also don't forget to change suhosin.memory_limit=4G -->
|
||||
</php>
|
||||
<filter>
|
||||
<blacklist>
|
||||
<directory suffix=".php">../../build/</directory>
|
||||
<directory suffix=".php">../../dev/</directory>
|
||||
<directory suffix=".php">../../doc/</directory>
|
||||
<directory suffix=".php">../../test/</directory>
|
||||
<directory suffix=".php">../../documents/</directory>
|
||||
<directory suffix=".php">../../htdocs/custom/</directory>
|
||||
<directory suffix=".php">../../htdocs/documents/custom/</directory>
|
||||
<directory suffix=".php">../../htdocs/nltechno/</directory>
|
||||
<directory suffix=".php">../../htdocs/products/canvas/</directory>
|
||||
<directory suffix=".php">../../htdocs/contact/canvas/</directory>
|
||||
<directory suffix=".php">../../htdocs/societe/canvas/</directory>
|
||||
<directory suffix=".php">../../htdocs/includes/</directory>
|
||||
</blacklist>
|
||||
<whitelist addUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".class.php">../../htdocs/</directory>
|
||||
<directory suffix=".lib.php">../../htdocs/</directory>
|
||||
@ -54,8 +40,21 @@
|
||||
<directory suffix=".php">../../htdocs/contact/canvas/</directory>
|
||||
<directory suffix=".php">../../htdocs/societe/canvas/</directory>
|
||||
<directory suffix=".php">../../htdocs/includes/</directory>
|
||||
<file>../../htdocs/holiday/common.inc.php</file>
|
||||
</exclude>
|
||||
</whitelist>
|
||||
<blacklist>
|
||||
<directory suffix=".php">../../build/</directory>
|
||||
<directory suffix=".php">../../dev/</directory>
|
||||
<directory suffix=".php">../../doc/</directory>
|
||||
<directory suffix=".php">../../test/</directory>
|
||||
<directory suffix=".php">../../documents/</directory>
|
||||
<directory suffix=".php">../../htdocs/custom/</directory>
|
||||
<directory suffix=".php">../../htdocs/documents/custom/</directory>
|
||||
<directory suffix=".php">../../htdocs/nltechno/</directory>
|
||||
<directory suffix=".php">../../htdocs/products/canvas/</directory>
|
||||
<directory suffix=".php">../../htdocs/contact/canvas/</directory>
|
||||
<directory suffix=".php">../../htdocs/societe/canvas/</directory>
|
||||
<directory suffix=".php">../../htdocs/includes/</directory>
|
||||
</blacklist>
|
||||
</filter>
|
||||
</phpunit>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user