Merge pull request #16462 from frederic34/ftpholiday_code_syntax
code syntax ftp holiday directory
This commit is contained in:
commit
7498721629
@ -28,7 +28,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||
$langs->loadLangs(array("admin", "ftp"));
|
||||
|
||||
// Security check
|
||||
if (!$user->admin) accessforbidden();
|
||||
if (!$user->admin) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
$def = array();
|
||||
$lastftpentry = 0;
|
||||
@ -45,36 +47,33 @@ $entry = GETPOST('numero_entry', 'alpha');
|
||||
$sql = "select MAX(name) as name from ".MAIN_DB_PREFIX."const";
|
||||
$sql .= " WHERE name like 'FTP_SERVER_%'";
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
if ($result) {
|
||||
$obj = $db->fetch_object($result);
|
||||
preg_match('/([0-9]+)$/i', $obj->name, $reg);
|
||||
if ($reg[1]) $lastftpentry = $reg[1];
|
||||
if ($reg[1]) {
|
||||
$lastftpentry = $reg[1];
|
||||
}
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
if ($action == 'add' || GETPOST('modify', 'alpha'))
|
||||
{
|
||||
if ($action == 'add' || GETPOST('modify', 'alpha')) {
|
||||
$ftp_name = "FTP_NAME_".$entry; // $_POST["numero_entry"];
|
||||
$ftp_server = "FTP_SERVER_".$entry; //$_POST["numero_entry"];
|
||||
|
||||
$error = 0;
|
||||
|
||||
if (!GETPOST("$ftp_name", 'alpha'))
|
||||
{
|
||||
if (!GETPOST("$ftp_name", 'alpha')) {
|
||||
$error = 1;
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
|
||||
}
|
||||
|
||||
if (!GETPOST("$ftp_server", 'alpha'))
|
||||
{
|
||||
if (!GETPOST("$ftp_server", 'alpha')) {
|
||||
$error = 1;
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Server")), null, 'errors');
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$ftp_port = "FTP_PORT_".$entry;
|
||||
$ftp_user = "FTP_USER_".$entry;
|
||||
$ftp_password = "FTP_PASSWORD_".$entry;
|
||||
@ -83,14 +82,23 @@ if ($action == 'add' || GETPOST('modify', 'alpha'))
|
||||
$db->begin();
|
||||
|
||||
$result1 = dolibarr_set_const($db, "FTP_PORT_".$entry, GETPOST($ftp_port, 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
if ($result1) $result2 = dolibarr_set_const($db, "FTP_SERVER_".$entry, GETPOST($ftp_server, 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
if ($result2) $result3 = dolibarr_set_const($db, "FTP_USER_".$entry, GETPOST($ftp_user, 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
if ($result3) $result4 = dolibarr_set_const($db, "FTP_PASSWORD_".$entry, GETPOST($ftp_password, 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
if ($result4) $result5 = dolibarr_set_const($db, "FTP_NAME_".$entry, GETPOST($ftp_name, 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
if ($result5) $result6 = dolibarr_set_const($db, "FTP_PASSIVE_".$entry, GETPOST($ftp_passive, 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
if ($result1) {
|
||||
$result2 = dolibarr_set_const($db, "FTP_SERVER_".$entry, GETPOST($ftp_server, 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
}
|
||||
if ($result2) {
|
||||
$result3 = dolibarr_set_const($db, "FTP_USER_".$entry, GETPOST($ftp_user, 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
}
|
||||
if ($result3) {
|
||||
$result4 = dolibarr_set_const($db, "FTP_PASSWORD_".$entry, GETPOST($ftp_password, 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
}
|
||||
if ($result4) {
|
||||
$result5 = dolibarr_set_const($db, "FTP_NAME_".$entry, GETPOST($ftp_name, 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
}
|
||||
if ($result5) {
|
||||
$result6 = dolibarr_set_const($db, "FTP_PASSIVE_".$entry, GETPOST($ftp_passive, 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
}
|
||||
|
||||
if ($result1 && $result2 && $result3 && $result4 && $result5 && $result6)
|
||||
{
|
||||
if ($result1 && $result2 && $result3 && $result4 && $result5 && $result6) {
|
||||
$db->commit();
|
||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||
exit;
|
||||
@ -101,21 +109,28 @@ if ($action == 'add' || GETPOST('modify', 'alpha'))
|
||||
}
|
||||
}
|
||||
|
||||
if (GETPOST('delete', 'alpha'))
|
||||
{
|
||||
if ($entry)
|
||||
{
|
||||
if (GETPOST('delete', 'alpha')) {
|
||||
if ($entry) {
|
||||
$db->begin();
|
||||
|
||||
$result1 = dolibarr_del_const($db, "FTP_PORT_".$entry, $conf->entity);
|
||||
if ($result1) $result2 = dolibarr_del_const($db, "FTP_SERVER_".$entry, $conf->entity);
|
||||
if ($result2) $result3 = dolibarr_del_const($db, "FTP_USER_".$entry, $conf->entity);
|
||||
if ($result3) $result4 = dolibarr_del_const($db, "FTP_PASSWORD_".$entry, $conf->entity);
|
||||
if ($result4) $result5 = dolibarr_del_const($db, "FTP_NAME_".$entry, $conf->entity);
|
||||
if ($result4) $result6 = dolibarr_del_const($db, "FTP_PASSIVE_".$entry, $conf->entity);
|
||||
if ($result1) {
|
||||
$result2 = dolibarr_del_const($db, "FTP_SERVER_".$entry, $conf->entity);
|
||||
}
|
||||
if ($result2) {
|
||||
$result3 = dolibarr_del_const($db, "FTP_USER_".$entry, $conf->entity);
|
||||
}
|
||||
if ($result3) {
|
||||
$result4 = dolibarr_del_const($db, "FTP_PASSWORD_".$entry, $conf->entity);
|
||||
}
|
||||
if ($result4) {
|
||||
$result5 = dolibarr_del_const($db, "FTP_NAME_".$entry, $conf->entity);
|
||||
}
|
||||
if ($result4) {
|
||||
$result6 = dolibarr_del_const($db, "FTP_PASSIVE_".$entry, $conf->entity);
|
||||
}
|
||||
|
||||
if ($result1 && $result2 && $result3 && $result4 && $result5 && $result6)
|
||||
{
|
||||
if ($result1 && $result2 && $result3 && $result4 && $result5 && $result6) {
|
||||
$db->commit();
|
||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||
exit;
|
||||
@ -139,8 +154,7 @@ $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_valu
|
||||
print load_fiche_titre($langs->trans("FTPClientSetup"), $linkback, 'title_setup');
|
||||
print '<br>';
|
||||
|
||||
if (!function_exists('ftp_connect'))
|
||||
{
|
||||
if (!function_exists('ftp_connect')) {
|
||||
print $langs->trans("FTPFeatureNotSupportedByYourPHP");
|
||||
} else {
|
||||
// Formulaire ajout
|
||||
@ -186,7 +200,9 @@ if (!function_exists('ftp_connect'))
|
||||
print '<tr class="impair">';
|
||||
print '<td>'.$langs->trans("FTPPassiveMode").'</td>';
|
||||
$defaultpassive = GETPOST("FTP_PASSIVE_".($lastftpentry + 1));
|
||||
if (!isset($_POST["FTP_PASSIVE_".($lastftpentry + 1)])) $defaultpassive = empty($conf->global->FTP_SUGGEST_PASSIVE_BYDEFAULT) ? 0 : 1;
|
||||
if (!isset($_POST["FTP_PASSIVE_".($lastftpentry + 1)])) {
|
||||
$defaultpassive = empty($conf->global->FTP_SUGGEST_PASSIVE_BYDEFAULT) ? 0 : 1;
|
||||
}
|
||||
print '<td>'.$form->selectyesno('FTP_PASSIVE_'.($lastftpentry + 1), $defaultpassive, 2).'</td>';
|
||||
print '<td>'.$langs->trans("No").'</td>';
|
||||
print '</tr>';
|
||||
@ -211,13 +227,11 @@ if (!function_exists('ftp_connect'))
|
||||
|
||||
dol_syslog("ftpclient select ftp setup", LOG_DEBUG);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
while ($i < $num) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
preg_match('/([0-9]+)$/i', $obj->name, $reg);
|
||||
|
||||
@ -32,13 +32,17 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
|
||||
$langs->loadLangs(array('ftp', 'companies', 'other'));
|
||||
|
||||
// Security check
|
||||
if ($user->socid) $socid = $user->socid;
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'ftp', '');
|
||||
|
||||
// Get parameters
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
$section = GETPOST('section');
|
||||
if (!$section) $section = '/';
|
||||
if (!$section) {
|
||||
$section = '/';
|
||||
}
|
||||
$numero_ftp = GETPOST("numero_ftp");
|
||||
/* if (! $numero_ftp) $numero_ftp=1; */
|
||||
$file = GETPOST("file");
|
||||
@ -51,12 +55,18 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
|
||||
$sortfield = GETPOST("sortfield", 'alpha');
|
||||
$sortorder = GETPOST("sortorder", 'alpha');
|
||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
||||
if (empty($page) || $page == -1) {
|
||||
$page = 0;
|
||||
} // If $page is not defined, or '' or -1
|
||||
$offset = $limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if (!$sortorder) $sortorder = "ASC";
|
||||
if (!$sortfield) $sortfield = "label";
|
||||
if (!$sortorder) {
|
||||
$sortorder = "ASC";
|
||||
}
|
||||
if (!$sortfield) {
|
||||
$sortfield = "label";
|
||||
}
|
||||
|
||||
$s_ftp_name = 'FTP_NAME_'.$numero_ftp;
|
||||
$s_ftp_server = 'FTP_SERVER_'.$numero_ftp;
|
||||
@ -66,7 +76,9 @@ $s_ftp_password = 'FTP_PASSWORD_'.$numero_ftp;
|
||||
$s_ftp_passive = 'FTP_PASSIVE_'.$numero_ftp;
|
||||
$ftp_name = $conf->global->$s_ftp_name;
|
||||
$ftp_server = $conf->global->$s_ftp_server;
|
||||
$ftp_port = $conf->global->$s_ftp_port; if (empty($ftp_port)) $ftp_port = 21;
|
||||
$ftp_port = $conf->global->$s_ftp_port; if (empty($ftp_port)) {
|
||||
$ftp_port = 21;
|
||||
}
|
||||
$ftp_user = $conf->global->$s_ftp_user;
|
||||
$ftp_password = $conf->global->$s_ftp_password;
|
||||
$ftp_passive = $conf->global->$s_ftp_passive;
|
||||
@ -83,29 +95,24 @@ $mesg = '';
|
||||
*/
|
||||
|
||||
// Submit file
|
||||
if (GETPOST("sendit") && !empty($conf->global->MAIN_UPLOAD_DOC))
|
||||
{
|
||||
if (GETPOST("sendit") && !empty($conf->global->MAIN_UPLOAD_DOC)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
|
||||
$result = $ecmdir->fetch(GETPOST("section", 'int'));
|
||||
if (!$result > 0)
|
||||
{
|
||||
if (!$result > 0) {
|
||||
dol_print_error($db, $ecmdir->error);
|
||||
exit;
|
||||
}
|
||||
$relativepath = $ecmdir->getRelativePath();
|
||||
$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
|
||||
|
||||
if (dol_mkdir($upload_dir) >= 0)
|
||||
{
|
||||
if (dol_mkdir($upload_dir) >= 0) {
|
||||
$resupload = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir."/".dol_unescapefile($_FILES['userfile']['name']), 0);
|
||||
if (is_numeric($resupload) && $resupload > 0)
|
||||
{
|
||||
if (is_numeric($resupload) && $resupload > 0) {
|
||||
$result = $ecmdir->changeNbOfFiles('+');
|
||||
} else {
|
||||
$langs->load("errors");
|
||||
if ($resupload < 0) // Unknown error
|
||||
{
|
||||
if ($resupload < 0) { // Unknown error
|
||||
setEventMessages($langs->trans("ErrorFileNotUploaded"), null, 'errors');
|
||||
} elseif (preg_match('/ErrorFileIsInfectedWithAVirus/', $resupload)) {
|
||||
// Files infected by a virus
|
||||
@ -123,15 +130,13 @@ if (GETPOST("sendit") && !empty($conf->global->MAIN_UPLOAD_DOC))
|
||||
}
|
||||
|
||||
// Action ajout d'un rep
|
||||
if ($action == 'add' && $user->rights->ftp->setup)
|
||||
{
|
||||
if ($action == 'add' && $user->rights->ftp->setup) {
|
||||
$ecmdir->ref = GETPOST("ref");
|
||||
$ecmdir->label = GETPOST("label");
|
||||
$ecmdir->description = GETPOST("desc");
|
||||
|
||||
$id = $ecmdir->create($user);
|
||||
if ($id > 0)
|
||||
{
|
||||
if ($id > 0) {
|
||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||
exit;
|
||||
} else {
|
||||
@ -141,11 +146,9 @@ if ($action == 'add' && $user->rights->ftp->setup)
|
||||
}
|
||||
|
||||
// Remove 1 file
|
||||
if ($action == 'confirm_deletefile' && GETPOST('confirm') == 'yes')
|
||||
{
|
||||
if ($action == 'confirm_deletefile' && GETPOST('confirm') == 'yes') {
|
||||
// set up a connection or die
|
||||
if (!$conn_id)
|
||||
{
|
||||
if (!$conn_id) {
|
||||
$newsectioniso = utf8_decode($section);
|
||||
$resultarray = dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $newsectioniso, $ftp_passive);
|
||||
$conn_id = $resultarray['conn_id'];
|
||||
@ -153,11 +156,9 @@ if ($action == 'confirm_deletefile' && GETPOST('confirm') == 'yes')
|
||||
$mesg = $resultarray['mesg'];
|
||||
}
|
||||
|
||||
if ($conn_id && $ok && !$mesg)
|
||||
{
|
||||
if ($conn_id && $ok && !$mesg) {
|
||||
$newsection = $section;
|
||||
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP))
|
||||
{
|
||||
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) {
|
||||
$newsection = ssh2_sftp_realpath($conn_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169
|
||||
}
|
||||
|
||||
@ -175,8 +176,7 @@ if ($action == 'confirm_deletefile' && GETPOST('confirm') == 'yes')
|
||||
} else {
|
||||
$result = @ftp_delete($conn_id, $newremotefileiso);
|
||||
}
|
||||
if ($result)
|
||||
{
|
||||
if ($result) {
|
||||
setEventMessages($langs->trans("FileWasRemoved", $file), null, 'mesgs');
|
||||
} else {
|
||||
dol_syslog("ftp/index.php ftp_delete", LOG_ERR);
|
||||
@ -192,11 +192,9 @@ if ($action == 'confirm_deletefile' && GETPOST('confirm') == 'yes')
|
||||
}
|
||||
|
||||
// Delete several lines at once
|
||||
if (GETPOST("const", 'array') && GETPOST("delete") && GETPOST("delete") == $langs->trans("Delete"))
|
||||
{
|
||||
if (GETPOST("const", 'array') && GETPOST("delete") && GETPOST("delete") == $langs->trans("Delete")) {
|
||||
// set up a connection or die
|
||||
if (!$conn_id)
|
||||
{
|
||||
if (!$conn_id) {
|
||||
$newsectioniso = utf8_decode($section);
|
||||
$resultarray = dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $newsectioniso, $ftp_passive);
|
||||
$conn_id = $resultarray['conn_id'];
|
||||
@ -204,19 +202,15 @@ if (GETPOST("const", 'array') && GETPOST("delete") && GETPOST("delete") == $lang
|
||||
$mesg = $resultarray['mesg'];
|
||||
}
|
||||
|
||||
if ($conn_id && $ok && !$mesg)
|
||||
{
|
||||
foreach (GETPOST('const', 'array') as $const)
|
||||
{
|
||||
if ($const["check"]) // Is checkbox checked
|
||||
{
|
||||
if ($conn_id && $ok && !$mesg) {
|
||||
foreach (GETPOST('const', 'array') as $const) {
|
||||
if ($const["check"]) { // Is checkbox checked
|
||||
$langs->load("other");
|
||||
|
||||
// Remote file
|
||||
$file = $const["file"];
|
||||
$newsection = $const["section"];
|
||||
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP))
|
||||
{
|
||||
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) {
|
||||
$newsection = ssh2_sftp_realpath($conn_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169
|
||||
}
|
||||
$remotefile = $newsection.(preg_match('@[\\\/]$@', $newsection) ? '' : '/').$file;
|
||||
@ -229,8 +223,7 @@ if (GETPOST("const", 'array') && GETPOST("delete") && GETPOST("delete") == $lang
|
||||
} else {
|
||||
$result = @ftp_delete($conn_id, $newremotefileiso);
|
||||
}
|
||||
if ($result)
|
||||
{
|
||||
if ($result) {
|
||||
setEventMessages($langs->trans("FileWasRemoved", $file), null, 'mesgs');
|
||||
} else {
|
||||
dol_syslog("ftp/index.php ftp_delete n files", LOG_ERR);
|
||||
@ -248,11 +241,9 @@ if (GETPOST("const", 'array') && GETPOST("delete") && GETPOST("delete") == $lang
|
||||
}
|
||||
|
||||
// Remove directory
|
||||
if ($action == 'confirm_deletesection' && $confirm == 'yes')
|
||||
{
|
||||
if ($action == 'confirm_deletesection' && $confirm == 'yes') {
|
||||
// set up a connection or die
|
||||
if (!$conn_id)
|
||||
{
|
||||
if (!$conn_id) {
|
||||
$newsectioniso = utf8_decode($section);
|
||||
$resultarray = dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $newsectioniso, $ftp_passive);
|
||||
$conn_id = $resultarray['conn_id'];
|
||||
@ -260,11 +251,9 @@ if ($action == 'confirm_deletesection' && $confirm == 'yes')
|
||||
$mesg = $resultarray['mesg'];
|
||||
}
|
||||
|
||||
if ($conn_id && $ok && !$mesg)
|
||||
{
|
||||
if ($conn_id && $ok && !$mesg) {
|
||||
$newsection = $section;
|
||||
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP))
|
||||
{
|
||||
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) {
|
||||
$newsection = ssh2_sftp_realpath($conn_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169
|
||||
}
|
||||
|
||||
@ -278,8 +267,7 @@ if ($action == 'confirm_deletesection' && $confirm == 'yes')
|
||||
} else {
|
||||
$result = @ftp_rmdir($conn_id, $newremotefileiso);
|
||||
}
|
||||
if ($result)
|
||||
{
|
||||
if ($result) {
|
||||
setEventMessages($langs->trans("DirWasRemoved", $file), null, 'mesgs');
|
||||
} else {
|
||||
setEventMessages($langs->trans("FTPFailedToRemoveDir", $file), null, 'errors');
|
||||
@ -294,11 +282,9 @@ if ($action == 'confirm_deletesection' && $confirm == 'yes')
|
||||
}
|
||||
|
||||
// Download directory
|
||||
if ($action == 'download')
|
||||
{
|
||||
if ($action == 'download') {
|
||||
// set up a connection or die
|
||||
if (!$conn_id)
|
||||
{
|
||||
if (!$conn_id) {
|
||||
$newsectioniso = utf8_decode($section);
|
||||
$resultarray = dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $newsectioniso, $ftp_passive);
|
||||
$conn_id = $resultarray['conn_id'];
|
||||
@ -306,14 +292,12 @@ if ($action == 'download')
|
||||
$mesg = $resultarray['mesg'];
|
||||
}
|
||||
|
||||
if ($conn_id && $ok && !$mesg)
|
||||
{
|
||||
if ($conn_id && $ok && !$mesg) {
|
||||
// Local file
|
||||
$localfile = tempnam($download_dir, 'dol_');
|
||||
|
||||
$newsection = $section;
|
||||
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP))
|
||||
{
|
||||
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) {
|
||||
$newsection = ssh2_sftp_realpath($conn_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169
|
||||
}
|
||||
|
||||
@ -327,23 +311,31 @@ if ($action == 'download')
|
||||
} else {
|
||||
$result = ftp_get($conn_id, $localfile, $newremotefileiso, FTP_BINARY);
|
||||
}
|
||||
if ($result)
|
||||
{
|
||||
if (!empty($conf->global->MAIN_UMASK))
|
||||
@chmod($localfile, octdec($conf->global->MAIN_UMASK));
|
||||
if ($result) {
|
||||
if (!empty($conf->global->MAIN_UMASK)) {
|
||||
@chmod($localfile, octdec($conf->global->MAIN_UMASK));
|
||||
}
|
||||
|
||||
// Define mime type
|
||||
$type = 'application/octet-stream';
|
||||
if (GETPOSTISSET("type")) $type = GETPOST("type");
|
||||
else $type = dol_mimetype($file);
|
||||
if (GETPOSTISSET("type")) {
|
||||
$type = GETPOST("type");
|
||||
} else {
|
||||
$type = dol_mimetype($file);
|
||||
}
|
||||
|
||||
// Define attachment (attachment=true to force choice popup 'open'/'save as')
|
||||
$attachment = true;
|
||||
|
||||
//if ($encoding) header('Content-Encoding: '.$encoding);
|
||||
if ($type) header('Content-Type: '.$type);
|
||||
if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"');
|
||||
else header('Content-Disposition: inline; filename="'.$filename.'"');
|
||||
if ($type) {
|
||||
header('Content-Type: '.$type);
|
||||
}
|
||||
if ($attachment) {
|
||||
header('Content-Disposition: attachment; filename="'.$filename.'"');
|
||||
} else {
|
||||
header('Content-Disposition: inline; filename="'.$filename.'"');
|
||||
}
|
||||
|
||||
// Ajout directives pour resoudre bug IE
|
||||
header('Cache-Control: Public, must-revalidate');
|
||||
@ -374,8 +366,7 @@ if ($action == 'download')
|
||||
llxHeader();
|
||||
|
||||
// Add logic to shoow/hide buttons
|
||||
if ($conf->use_javascript_ajax)
|
||||
{
|
||||
if ($conf->use_javascript_ajax) {
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function() {
|
||||
@ -411,21 +402,17 @@ print load_fiche_titre($langs->trans("FTPArea"));
|
||||
|
||||
print $langs->trans("FTPAreaDesc")."<br>";
|
||||
|
||||
if (!function_exists('ftp_connect'))
|
||||
{
|
||||
if (!function_exists('ftp_connect')) {
|
||||
print $langs->trans("FTPFeatureNotSupportedByYourPHP");
|
||||
} else {
|
||||
if (!empty($ftp_server))
|
||||
{
|
||||
if (!empty($ftp_server)) {
|
||||
// Confirm remove file
|
||||
if ($action == 'delete')
|
||||
{
|
||||
if ($action == 'delete') {
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"].'?numero_ftp='.$numero_ftp.'§ion='.urlencode(GETPOST('section')).'&file='.urlencode(GETPOST('file')), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', '', 1);
|
||||
}
|
||||
|
||||
// Confirmation de la suppression d'une ligne categorie
|
||||
if ($action == 'delete_section')
|
||||
{
|
||||
if ($action == 'delete_section') {
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"].'?numero_ftp='.$numero_ftp.'§ion='.urlencode(GETPOST('section')).'&file='.urlencode(GETPOST('file')), $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection', $ecmdir->label), 'confirm_deletesection', '', '', 1);
|
||||
}
|
||||
|
||||
@ -443,11 +430,11 @@ if (!function_exists('ftp_connect'))
|
||||
print '</a> ';
|
||||
// For other directories
|
||||
$i = 0;
|
||||
foreach ($sectionarray as $val)
|
||||
{
|
||||
if (empty($val)) continue; // Discard first and last entry that should be empty as section start/end with /
|
||||
if ($i > 0)
|
||||
{
|
||||
foreach ($sectionarray as $val) {
|
||||
if (empty($val)) {
|
||||
continue; // Discard first and last entry that should be empty as section start/end with /
|
||||
}
|
||||
if ($i > 0) {
|
||||
print ' / ';
|
||||
$newsection .= '/';
|
||||
}
|
||||
@ -476,14 +463,15 @@ if (!function_exists('ftp_connect'))
|
||||
print '<td class="liste_titre center">'.$langs->trans("Group").'</td>'."\n";
|
||||
print '<td class="liste_titre center">'.$langs->trans("Permissions").'</td>'."\n";
|
||||
print '<td class="liste_titre nowrap right">';
|
||||
if ($conf->use_javascript_ajax) print '<a href="#" id="checkall">'.$langs->trans("All").'</a> / <a href="#" id="checknone">'.$langs->trans("None").'</a> ';
|
||||
if ($conf->use_javascript_ajax) {
|
||||
print '<a href="#" id="checkall">'.$langs->trans("All").'</a> / <a href="#" id="checknone">'.$langs->trans("None").'</a> ';
|
||||
}
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=refreshmanual&numero_ftp='.$numero_ftp.($section ? '§ion='.urlencode($section) : '').'">'.img_picto($langs->trans("Refresh"), 'refresh').'</a> ';
|
||||
print '</td>'."\n";
|
||||
print '</tr>'."\n";
|
||||
|
||||
// set up a connection or die
|
||||
if (empty($conn_id))
|
||||
{
|
||||
if (empty($conn_id)) {
|
||||
$resultarray = dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $section, $ftp_passive);
|
||||
|
||||
$conn_id = $resultarray['conn_id'];
|
||||
@ -491,8 +479,7 @@ if (!function_exists('ftp_connect'))
|
||||
$mesg = $resultarray['mesg'];
|
||||
}
|
||||
|
||||
if ($ok)
|
||||
{
|
||||
if ($ok) {
|
||||
//$type = ftp_systype($conn_id);
|
||||
|
||||
$newsection = $section;
|
||||
@ -500,8 +487,7 @@ if (!function_exists('ftp_connect'))
|
||||
//$newsection='/home';
|
||||
|
||||
// List content of directory ($newsection = '/', '/home', ...)
|
||||
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP))
|
||||
{
|
||||
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) {
|
||||
if ($newsection == '/') {
|
||||
//$newsection = '/./';
|
||||
$newsection = ssh2_sftp_realpath($conn_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169
|
||||
@ -511,8 +497,7 @@ if (!function_exists('ftp_connect'))
|
||||
//$dirHandle = opendir("ssh2.sftp://".intval($conn_id).ssh2_sftp_realpath($conn_id, ".").'/./');
|
||||
$contents = scandir('ssh2.sftp://'.intval($conn_id).$newsection);
|
||||
$buff = array();
|
||||
foreach ($contents as $i => $key)
|
||||
{
|
||||
foreach ($contents as $i => $key) {
|
||||
$buff[$i] = "---------- - root root 1234 Aug 01 2000 ".$key;
|
||||
}
|
||||
} else {
|
||||
@ -525,31 +510,32 @@ if (!function_exists('ftp_connect'))
|
||||
$nboflines = count($contents);
|
||||
$rawlisthasfailed = false;
|
||||
$i = 0;
|
||||
while ($i < $nboflines && $i < 1000)
|
||||
{
|
||||
while ($i < $nboflines && $i < 1000) {
|
||||
$vals = preg_split('@ +@', utf8_encode($buff[$i]), 9);
|
||||
//$vals=preg_split('@ +@','drwxr-xr-x 2 root root 4096 Aug 30 2008 backup_apollon1',9);
|
||||
//var_dump($vals);
|
||||
$file = $vals[8];
|
||||
if (empty($file))
|
||||
{
|
||||
if (empty($file)) {
|
||||
$rawlisthasfailed = true;
|
||||
$file = utf8_encode($contents[$i]);
|
||||
}
|
||||
|
||||
if ($file == '.' || ($file == '..' && $section == '/'))
|
||||
{
|
||||
if ($file == '.' || ($file == '..' && $section == '/')) {
|
||||
$i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Is it a directory ?
|
||||
$is_directory = 0;
|
||||
if ($file == '..') $is_directory = 1;
|
||||
elseif (!$rawlisthasfailed)
|
||||
{
|
||||
if (preg_match('/^d/', $vals[0])) $is_directory = 1;
|
||||
if (preg_match('/^l/', $vals[0])) $is_link = 1;
|
||||
if ($file == '..') {
|
||||
$is_directory = 1;
|
||||
} elseif (!$rawlisthasfailed) {
|
||||
if (preg_match('/^d/', $vals[0])) {
|
||||
$is_directory = 1;
|
||||
}
|
||||
if (preg_match('/^l/', $vals[0])) {
|
||||
$is_link = 1;
|
||||
}
|
||||
} else {
|
||||
// Remote file
|
||||
$filename = $file;
|
||||
@ -569,14 +555,21 @@ if (!function_exists('ftp_connect'))
|
||||
print '<td>';
|
||||
$newsection = $section.(preg_match('@[\\\/]$@', $section) ? '' : '/').$file;
|
||||
$newsection = preg_replace('@[\\\/][^\\\/]+[\\\/]\.\.$@', '/', $newsection); // Change aaa/xxx/.. to new aaa
|
||||
if ($is_directory) print '<a href="'.$_SERVER["PHP_SELF"].'?section='.urlencode($newsection).'&numero_ftp='.$numero_ftp.'">';
|
||||
if ($is_directory) {
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?section='.urlencode($newsection).'&numero_ftp='.$numero_ftp.'">';
|
||||
}
|
||||
print dol_escape_htmltag($file);
|
||||
if ($is_directory) print '</a>';
|
||||
if ($is_directory) {
|
||||
print '</a>';
|
||||
}
|
||||
print '</td>';
|
||||
// Size
|
||||
print '<td class="center nowrap">';
|
||||
if (!$is_directory && !$is_link) print $vals[4];
|
||||
else print ' ';
|
||||
if (!$is_directory && !$is_link) {
|
||||
print $vals[4];
|
||||
} else {
|
||||
print ' ';
|
||||
}
|
||||
print '</td>';
|
||||
// Date
|
||||
print '<td class="center nowrap">';
|
||||
@ -596,12 +589,13 @@ if (!function_exists('ftp_connect'))
|
||||
print '</td>';
|
||||
// Action
|
||||
print '<td class="right nowrap" width="64">';
|
||||
if ($is_directory)
|
||||
{
|
||||
if ($file != '..') print '<a href="'.$_SERVER["PHP_SELF"].'?action=delete_section&token='.newToken().'&numero_ftp='.$numero_ftp.'§ion='.urlencode($section).'&file='.urlencode($file).'">'.img_delete().'</a>';
|
||||
else print ' ';
|
||||
} elseif ($is_link)
|
||||
{
|
||||
if ($is_directory) {
|
||||
if ($file != '..') {
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=delete_section&token='.newToken().'&numero_ftp='.$numero_ftp.'§ion='.urlencode($section).'&file='.urlencode($file).'">'.img_delete().'</a>';
|
||||
} else {
|
||||
print ' ';
|
||||
}
|
||||
} elseif ($is_link) {
|
||||
$newfile = $file;
|
||||
$newfile = preg_replace('/ ->.*/', '', $newfile);
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&numero_ftp='.$numero_ftp.'§ion='.urlencode($section).'&file='.urlencode($newfile).'">'.img_delete().'</a>';
|
||||
@ -624,8 +618,7 @@ if (!function_exists('ftp_connect'))
|
||||
print "</table>";
|
||||
|
||||
|
||||
if (!$ok)
|
||||
{
|
||||
if (!$ok) {
|
||||
print $mesg.'<br>'."\n";
|
||||
setEventMessages($mesg, null, 'errors');
|
||||
}
|
||||
@ -650,19 +643,16 @@ if (!function_exists('ftp_connect'))
|
||||
$foundsetup = false;
|
||||
$MAXFTP = 20;
|
||||
$i = 1;
|
||||
while ($i <= $MAXFTP)
|
||||
{
|
||||
while ($i <= $MAXFTP) {
|
||||
$paramkey = 'FTP_NAME_'.$i;
|
||||
//print $paramkey;
|
||||
if (!empty($conf->global->$paramkey))
|
||||
{
|
||||
if (!empty($conf->global->$paramkey)) {
|
||||
$foundsetup = true;
|
||||
break;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
if (!$foundsetup)
|
||||
{
|
||||
if (!$foundsetup) {
|
||||
print $langs->trans("SetupOfFTPClientModuleNotComplete");
|
||||
} else {
|
||||
print $langs->trans("ChooseAFTPEntryIntoMenu");
|
||||
@ -673,12 +663,9 @@ if (!function_exists('ftp_connect'))
|
||||
print '<br>';
|
||||
|
||||
// Close FTP connection
|
||||
if ($conn_id)
|
||||
{
|
||||
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP))
|
||||
{
|
||||
} elseif (!empty($conf->global->FTP_CONNECT_WITH_SSL))
|
||||
{
|
||||
if ($conn_id) {
|
||||
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) {
|
||||
} elseif (!empty($conf->global->FTP_CONNECT_WITH_SSL)) {
|
||||
ftp_close($conn_id);
|
||||
} else {
|
||||
ftp_close($conn_id);
|
||||
@ -709,14 +696,12 @@ function dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $sect
|
||||
$ok = 1;
|
||||
$conn_id = null;
|
||||
|
||||
if (!is_numeric($ftp_port))
|
||||
{
|
||||
if (!is_numeric($ftp_port)) {
|
||||
$mesg = $langs->transnoentitiesnoconv("FailedToConnectToFTPServer", $ftp_server, $ftp_port);
|
||||
$ok = 0;
|
||||
}
|
||||
|
||||
if ($ok)
|
||||
{
|
||||
if ($ok) {
|
||||
$connecttimeout = (empty($conf->global->FTP_CONNECT_TIMEOUT) ? 40 : $conf->global->FTP_CONNECT_TIMEOUT);
|
||||
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) {
|
||||
dol_syslog('Try to connect with ssh2_ftp');
|
||||
@ -728,15 +713,11 @@ function dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $sect
|
||||
dol_syslog('Try to connect with ftp_connect');
|
||||
$conn_id = ftp_connect($ftp_server, $ftp_port, $connecttimeout);
|
||||
}
|
||||
if ($conn_id || $tmp_conn_id)
|
||||
{
|
||||
if ($ftp_user)
|
||||
{
|
||||
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP))
|
||||
{
|
||||
if ($conn_id || $tmp_conn_id) {
|
||||
if ($ftp_user) {
|
||||
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) {
|
||||
dol_syslog('Try to authenticate with ssh2_auth_password');
|
||||
if (ssh2_auth_password($tmp_conn_id, $ftp_user, $ftp_password))
|
||||
{
|
||||
if (ssh2_auth_password($tmp_conn_id, $ftp_user, $ftp_password)) {
|
||||
// Turn on passive mode transfers (must be after a successful login
|
||||
//if ($ftp_passive) ftp_pasv($conn_id, true);
|
||||
|
||||
@ -744,31 +725,31 @@ function dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $sect
|
||||
$newsectioniso = utf8_decode($section);
|
||||
//ftp_chdir($conn_id, $newsectioniso);
|
||||
$conn_id = ssh2_sftp($tmp_conn_id);
|
||||
if (!$conn_id)
|
||||
{
|
||||
if (!$conn_id) {
|
||||
dol_syslog('Failed to connect to SFTP after sssh authentication', LOG_DEBUG);
|
||||
$mesg = $langs->transnoentitiesnoconv("FailedToConnectToSFTPAfterSSHAuthentication");
|
||||
$ok = 0;
|
||||
$ok = 0;
|
||||
$error++;
|
||||
}
|
||||
} else {
|
||||
dol_syslog('Failed to connect to FTP with login '.$ftp_user, LOG_DEBUG);
|
||||
$mesg = $langs->transnoentitiesnoconv("FailedToConnectToFTPServerWithCredentials");
|
||||
$ok = 0;
|
||||
$ok = 0;
|
||||
$error++;
|
||||
}
|
||||
} else {
|
||||
if (ftp_login($conn_id, $ftp_user, $ftp_password))
|
||||
{
|
||||
if (ftp_login($conn_id, $ftp_user, $ftp_password)) {
|
||||
// Turn on passive mode transfers (must be after a successful login
|
||||
if ($ftp_passive) ftp_pasv($conn_id, true);
|
||||
if ($ftp_passive) {
|
||||
ftp_pasv($conn_id, true);
|
||||
}
|
||||
|
||||
// Change the dir
|
||||
$newsectioniso = utf8_decode($section);
|
||||
ftp_chdir($conn_id, $newsectioniso);
|
||||
} else {
|
||||
$mesg = $langs->transnoentitiesnoconv("FailedToConnectToFTPServerWithCredentials");
|
||||
$ok = 0;
|
||||
$ok = 0;
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
@ -794,8 +775,7 @@ function dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $sect
|
||||
*/
|
||||
function ftp_isdir($connect_id, $dir)
|
||||
{
|
||||
if (@ftp_chdir($connect_id, $dir))
|
||||
{
|
||||
if (@ftp_chdir($connect_id, $dir)) {
|
||||
ftp_cdup($connect_id);
|
||||
return 1;
|
||||
} else {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -170,13 +170,11 @@ class Holiday extends CommonObject
|
||||
global $langs, $conf;
|
||||
$langs->load("order");
|
||||
|
||||
if (empty($conf->global->HOLIDAY_ADDON))
|
||||
{
|
||||
if (empty($conf->global->HOLIDAY_ADDON)) {
|
||||
$conf->global->HOLIDAY_ADDON = 'mod_holiday_madonna';
|
||||
}
|
||||
|
||||
if (!empty($conf->global->HOLIDAY_ADDON))
|
||||
{
|
||||
if (!empty($conf->global->HOLIDAY_ADDON)) {
|
||||
$mybool = false;
|
||||
|
||||
$file = $conf->global->HOLIDAY_ADDON.".php";
|
||||
@ -184,16 +182,14 @@ class Holiday extends CommonObject
|
||||
|
||||
// Include file with class
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
foreach ($dirmodels as $reldir)
|
||||
{
|
||||
foreach ($dirmodels as $reldir) {
|
||||
$dir = dol_buildpath($reldir."core/modules/holiday/");
|
||||
|
||||
// Load file with numbering class (if found)
|
||||
$mybool |= @include_once $dir.$file;
|
||||
}
|
||||
|
||||
if ($mybool === false)
|
||||
{
|
||||
if ($mybool === false) {
|
||||
dol_print_error('', "Failed to include file ".$file);
|
||||
return '';
|
||||
}
|
||||
@ -201,8 +197,7 @@ class Holiday extends CommonObject
|
||||
$obj = new $classname();
|
||||
$numref = $obj->getNextValue($objsoc, $this);
|
||||
|
||||
if ($numref != "")
|
||||
{
|
||||
if ($numref != "") {
|
||||
return $numref;
|
||||
} else {
|
||||
$this->error = $obj->error;
|
||||
@ -230,8 +225,7 @@ class Holiday extends CommonObject
|
||||
// Check nb of users into table llx_holiday_users and update with empty lines
|
||||
//if ($result > 0) $result = $this->verifNbUsers($this->countActiveUsersWithoutCP(), $this->getConfCP('nbUser'));
|
||||
|
||||
if ($result >= 0)
|
||||
{
|
||||
if ($result >= 0) {
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
} else {
|
||||
@ -255,9 +249,15 @@ class Holiday extends CommonObject
|
||||
$now = dol_now();
|
||||
|
||||
// Check parameters
|
||||
if (empty($this->fk_user) || !is_numeric($this->fk_user) || $this->fk_user < 0) { $this->error = "ErrorBadParameterFkUser"; return -1; }
|
||||
if (empty($this->fk_validator) || !is_numeric($this->fk_validator) || $this->fk_validator < 0) { $this->error = "ErrorBadParameterFkValidator"; return -1; }
|
||||
if (empty($this->fk_type) || !is_numeric($this->fk_type) || $this->fk_type < 0) { $this->error = "ErrorBadParameterFkType"; return -1; }
|
||||
if (empty($this->fk_user) || !is_numeric($this->fk_user) || $this->fk_user < 0) {
|
||||
$this->error = "ErrorBadParameterFkUser"; return -1;
|
||||
}
|
||||
if (empty($this->fk_validator) || !is_numeric($this->fk_validator) || $this->fk_validator < 0) {
|
||||
$this->error = "ErrorBadParameterFkValidator"; return -1;
|
||||
}
|
||||
if (empty($this->fk_type) || !is_numeric($this->fk_type) || $this->fk_type < 0) {
|
||||
$this->error = "ErrorBadParameterFkType"; return -1;
|
||||
}
|
||||
|
||||
// Insert request
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday(";
|
||||
@ -296,32 +296,33 @@ class Holiday extends CommonObject
|
||||
$error++; $this->errors[] = "Error ".$this->db->lasterror();
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."holiday");
|
||||
|
||||
if ($this->id)
|
||||
{
|
||||
if ($this->id) {
|
||||
// update ref
|
||||
$initialref = '(PROV'.$this->id.')';
|
||||
if (!empty($this->ref)) $initialref = $this->ref;
|
||||
if (!empty($this->ref)) {
|
||||
$initialref = $this->ref;
|
||||
}
|
||||
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX."holiday SET ref='".$this->db->escape($initialref)."' WHERE rowid=".$this->id;
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
if ($this->db->query($sql)) {
|
||||
$this->ref = $initialref;
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$result = $this->insertExtraFields();
|
||||
if ($result < 0) $error++;
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error && !$notrigger)
|
||||
{
|
||||
if (!$error && !$notrigger) {
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('HOLIDAY_CREATE', $user);
|
||||
if ($result < 0) { $error++; }
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
// End call triggers
|
||||
}
|
||||
}
|
||||
@ -329,10 +330,8 @@ class Holiday extends CommonObject
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error)
|
||||
{
|
||||
foreach ($this->errors as $errmsg)
|
||||
{
|
||||
if ($error) {
|
||||
foreach ($this->errors as $errmsg) {
|
||||
dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
|
||||
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
|
||||
}
|
||||
@ -380,15 +379,16 @@ class Holiday extends CommonObject
|
||||
$sql .= " cp.fk_type,";
|
||||
$sql .= " cp.entity";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."holiday as cp";
|
||||
if ($id > 0) $sql .= " WHERE cp.rowid = ".$id;
|
||||
else $sql .= " WHERE cp.ref = '".$this->db->escape($ref)."'";
|
||||
if ($id > 0) {
|
||||
$sql .= " WHERE cp.rowid = ".$id;
|
||||
} else {
|
||||
$sql .= " WHERE cp.ref = '".$this->db->escape($ref)."'";
|
||||
}
|
||||
|
||||
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($this->db->num_rows($resql))
|
||||
{
|
||||
if ($resql) {
|
||||
if ($this->db->num_rows($resql)) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
@ -693,8 +693,7 @@ class Holiday extends CommonObject
|
||||
$error = 0;
|
||||
|
||||
// Define new ref
|
||||
if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref) || $this->ref == $this->id))
|
||||
{
|
||||
if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref) || $this->ref == $this->id)) {
|
||||
$num = $this->getNextNumRef(null);
|
||||
} else {
|
||||
$num = $this->ref;
|
||||
@ -719,22 +718,20 @@ class Holiday extends CommonObject
|
||||
$error++; $this->errors[] = "Error ".$this->db->lasterror();
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$notrigger)
|
||||
{
|
||||
if (!$error) {
|
||||
if (!$notrigger) {
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('HOLIDAY_VALIDATE', $user);
|
||||
if ($result < 0) { $error++; }
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
// End call triggers
|
||||
}
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error)
|
||||
{
|
||||
foreach ($this->errors as $errmsg)
|
||||
{
|
||||
if ($error) {
|
||||
foreach ($this->errors as $errmsg) {
|
||||
dol_syslog(get_class($this)."::validate ".$errmsg, LOG_ERR);
|
||||
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
|
||||
}
|
||||
@ -831,22 +828,20 @@ class Holiday extends CommonObject
|
||||
$error++; $this->errors[] = "Error ".$this->db->lasterror();
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$notrigger)
|
||||
{
|
||||
if (!$error) {
|
||||
if (!$notrigger) {
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('HOLIDAY_APPROVE', $user);
|
||||
if ($result < 0) { $error++; }
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
// End call triggers
|
||||
}
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error)
|
||||
{
|
||||
foreach ($this->errors as $errmsg)
|
||||
{
|
||||
if ($error) {
|
||||
foreach ($this->errors as $errmsg) {
|
||||
dol_syslog(get_class($this)."::approve ".$errmsg, LOG_ERR);
|
||||
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
|
||||
}
|
||||
@ -942,22 +937,20 @@ class Holiday extends CommonObject
|
||||
$error++; $this->errors[] = "Error ".$this->db->lasterror();
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$notrigger)
|
||||
{
|
||||
if (!$error) {
|
||||
if (!$notrigger) {
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('HOLIDAY_MODIFY', $user);
|
||||
if ($result < 0) { $error++; }
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
// End call triggers
|
||||
}
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error)
|
||||
{
|
||||
foreach ($this->errors as $errmsg)
|
||||
{
|
||||
if ($error) {
|
||||
foreach ($this->errors as $errmsg) {
|
||||
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
|
||||
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
|
||||
}
|
||||
@ -993,22 +986,20 @@ class Holiday extends CommonObject
|
||||
$error++; $this->errors[] = "Error ".$this->db->lasterror();
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$notrigger)
|
||||
{
|
||||
if (!$error) {
|
||||
if (!$notrigger) {
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('HOLIDAY_DELETE', $user);
|
||||
if ($result < 0) { $error++; }
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
// End call triggers
|
||||
}
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error)
|
||||
{
|
||||
foreach ($this->errors as $errmsg)
|
||||
{
|
||||
if ($error) {
|
||||
foreach ($this->errors as $errmsg) {
|
||||
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
|
||||
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
|
||||
}
|
||||
@ -1037,60 +1028,67 @@ class Holiday extends CommonObject
|
||||
{
|
||||
$this->fetchByUser($fk_user, '', '');
|
||||
|
||||
foreach ($this->holiday as $infos_CP)
|
||||
{
|
||||
if ($infos_CP['statut'] == 4) continue; // ignore not validated holidays
|
||||
if ($infos_CP['statut'] == 5) continue; // ignore not validated holidays
|
||||
foreach ($this->holiday as $infos_CP) {
|
||||
if ($infos_CP['statut'] == 4) {
|
||||
continue; // ignore not validated holidays
|
||||
}
|
||||
if ($infos_CP['statut'] == 5) {
|
||||
continue; // ignore not validated holidays
|
||||
}
|
||||
/*
|
||||
var_dump("--");
|
||||
var_dump("old: ".dol_print_date($infos_CP['date_debut'],'dayhour').' '.dol_print_date($infos_CP['date_fin'],'dayhour').' '.$infos_CP['halfday']);
|
||||
var_dump("new: ".dol_print_date($dateStart,'dayhour').' '.dol_print_date($dateEnd,'dayhour').' '.$halfday);
|
||||
*/
|
||||
|
||||
if ($halfday == 0)
|
||||
{
|
||||
if ($dateStart >= $infos_CP['date_debut'] && $dateStart <= $infos_CP['date_fin'])
|
||||
{
|
||||
if ($halfday == 0) {
|
||||
if ($dateStart >= $infos_CP['date_debut'] && $dateStart <= $infos_CP['date_fin']) {
|
||||
return false;
|
||||
}
|
||||
if ($dateEnd <= $infos_CP['date_fin'] && $dateEnd >= $infos_CP['date_debut'])
|
||||
{
|
||||
if ($dateEnd <= $infos_CP['date_fin'] && $dateEnd >= $infos_CP['date_debut']) {
|
||||
return false;
|
||||
}
|
||||
} elseif ($halfday == -1)
|
||||
{
|
||||
} elseif ($halfday == -1) {
|
||||
// new start afternoon, new end afternoon
|
||||
if ($dateStart >= $infos_CP['date_debut'] && $dateStart <= $infos_CP['date_fin'])
|
||||
{
|
||||
if ($dateStart < $infos_CP['date_fin'] || in_array($infos_CP['halfday'], array(0, -1))) return false;
|
||||
if ($dateStart >= $infos_CP['date_debut'] && $dateStart <= $infos_CP['date_fin']) {
|
||||
if ($dateStart < $infos_CP['date_fin'] || in_array($infos_CP['halfday'], array(0, -1))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if ($dateEnd <= $infos_CP['date_fin'] && $dateEnd >= $infos_CP['date_debut'])
|
||||
{
|
||||
if ($dateStart < $dateEnd) return false;
|
||||
if ($dateEnd < $infos_CP['date_fin'] || in_array($infos_CP['halfday'], array(0, -1))) return false;
|
||||
if ($dateEnd <= $infos_CP['date_fin'] && $dateEnd >= $infos_CP['date_debut']) {
|
||||
if ($dateStart < $dateEnd) {
|
||||
return false;
|
||||
}
|
||||
if ($dateEnd < $infos_CP['date_fin'] || in_array($infos_CP['halfday'], array(0, -1))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} elseif ($halfday == 1)
|
||||
{
|
||||
} elseif ($halfday == 1) {
|
||||
// new start morning, new end morning
|
||||
if ($dateStart >= $infos_CP['date_debut'] && $dateStart <= $infos_CP['date_fin'])
|
||||
{
|
||||
if ($dateStart < $dateEnd) return false;
|
||||
if ($dateStart > $infos_CP['date_debut'] || in_array($infos_CP['halfday'], array(0, 1))) return false;
|
||||
if ($dateStart >= $infos_CP['date_debut'] && $dateStart <= $infos_CP['date_fin']) {
|
||||
if ($dateStart < $dateEnd) {
|
||||
return false;
|
||||
}
|
||||
if ($dateStart > $infos_CP['date_debut'] || in_array($infos_CP['halfday'], array(0, 1))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if ($dateEnd <= $infos_CP['date_fin'] && $dateEnd >= $infos_CP['date_debut'])
|
||||
{
|
||||
if ($dateEnd > $infos_CP['date_debut'] || in_array($infos_CP['halfday'], array(0, 1))) return false;
|
||||
if ($dateEnd <= $infos_CP['date_fin'] && $dateEnd >= $infos_CP['date_debut']) {
|
||||
if ($dateEnd > $infos_CP['date_debut'] || in_array($infos_CP['halfday'], array(0, 1))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} elseif ($halfday == 2)
|
||||
{
|
||||
} elseif ($halfday == 2) {
|
||||
// new start afternoon, new end morning
|
||||
if ($dateStart >= $infos_CP['date_debut'] && $dateStart <= $infos_CP['date_fin'])
|
||||
{
|
||||
if ($dateStart < $infos_CP['date_fin'] || in_array($infos_CP['halfday'], array(0, -1))) return false;
|
||||
if ($dateStart >= $infos_CP['date_debut'] && $dateStart <= $infos_CP['date_fin']) {
|
||||
if ($dateStart < $infos_CP['date_fin'] || in_array($infos_CP['halfday'], array(0, -1))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if ($dateEnd <= $infos_CP['date_fin'] && $dateEnd >= $infos_CP['date_debut'])
|
||||
{
|
||||
if ($dateEnd > $infos_CP['date_debut'] || in_array($infos_CP['halfday'], array(0, 1))) return false;
|
||||
if ($dateEnd <= $infos_CP['date_fin'] && $dateEnd >= $infos_CP['date_debut']) {
|
||||
if ($dateEnd > $infos_CP['date_debut'] || in_array($infos_CP['halfday'], array(0, 1))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
dol_print_error('', 'Bad value of parameter halfday when calling function verifDateHolidayCP');
|
||||
@ -1123,18 +1121,17 @@ class Holiday extends CommonObject
|
||||
$sql .= " WHERE cp.entity IN (".getEntity('holiday').")";
|
||||
$sql .= " AND cp.fk_user = ".(int) $fk_user;
|
||||
$sql .= " AND cp.date_debut <= '".$this->db->idate($timestamp)."' AND cp.date_fin >= '".$this->db->idate($timestamp)."'";
|
||||
if ($status != '-1') $sql .= " AND cp.statut IN (".$this->db->sanitize($this->db->escape($status)).")";
|
||||
if ($status != '-1') {
|
||||
$sql .= " AND cp.statut IN (".$this->db->sanitize($this->db->escape($status)).")";
|
||||
}
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$num_rows = $this->db->num_rows($resql); // Note, we can have 2 records if on is morning and the other one is afternoon
|
||||
if ($num_rows > 0)
|
||||
{
|
||||
if ($num_rows > 0) {
|
||||
$arrayofrecord = array();
|
||||
$i = 0;
|
||||
while ($i < $num_rows)
|
||||
{
|
||||
while ($i < $num_rows) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
// Note: $obj->halfday is 0:Full days, 2:Sart afternoon end morning, -1:Start afternoon, 1:End morning
|
||||
@ -1144,27 +1141,39 @@ class Holiday extends CommonObject
|
||||
|
||||
// We found a record, user is on holiday by default, so is not available is true.
|
||||
$isavailablemorning = true;
|
||||
foreach ($arrayofrecord as $record)
|
||||
{
|
||||
if ($timestamp == $record['date_start'] && $record['halfday'] == 2) continue;
|
||||
if ($timestamp == $record['date_start'] && $record['halfday'] == -1) continue;
|
||||
foreach ($arrayofrecord as $record) {
|
||||
if ($timestamp == $record['date_start'] && $record['halfday'] == 2) {
|
||||
continue;
|
||||
}
|
||||
if ($timestamp == $record['date_start'] && $record['halfday'] == -1) {
|
||||
continue;
|
||||
}
|
||||
$isavailablemorning = false;
|
||||
break;
|
||||
}
|
||||
$isavailableafternoon = true;
|
||||
foreach ($arrayofrecord as $record)
|
||||
{
|
||||
if ($timestamp == $record['date_end'] && $record['halfday'] == 2) continue;
|
||||
if ($timestamp == $record['date_end'] && $record['halfday'] == 1) continue;
|
||||
foreach ($arrayofrecord as $record) {
|
||||
if ($timestamp == $record['date_end'] && $record['halfday'] == 2) {
|
||||
continue;
|
||||
}
|
||||
if ($timestamp == $record['date_end'] && $record['halfday'] == 1) {
|
||||
continue;
|
||||
}
|
||||
$isavailableafternoon = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else dol_print_error($this->db);
|
||||
} else {
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
|
||||
$result = array('morning'=>$isavailablemorning, 'afternoon'=>$isavailableafternoon);
|
||||
if (!$isavailablemorning) $result['morning_reason'] = 'leave_request';
|
||||
if (!$isavailableafternoon) $result['afternoon_reason'] = 'leave_request';
|
||||
if (!$isavailablemorning) {
|
||||
$result['morning_reason'] = 'leave_request';
|
||||
}
|
||||
if (!$isavailableafternoon) {
|
||||
$result['afternoon_reason'] = 'leave_request';
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -1194,16 +1203,24 @@ class Holiday extends CommonObject
|
||||
//{
|
||||
// Add param to save lastsearch_values or not
|
||||
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
|
||||
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
|
||||
if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
|
||||
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
|
||||
$add_save_lastsearch_values = 1;
|
||||
}
|
||||
if ($add_save_lastsearch_values) {
|
||||
$url .= '&save_lastsearch_values=1';
|
||||
}
|
||||
//}
|
||||
|
||||
$linkstart = '<a href="'.$url.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
|
||||
$linkend = '</a>';
|
||||
|
||||
$result .= $linkstart;
|
||||
if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
|
||||
if ($withpicto != 2) $result .= $this->ref;
|
||||
if ($withpicto) {
|
||||
$result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
|
||||
}
|
||||
if ($withpicto != 2) {
|
||||
$result .= $this->ref;
|
||||
}
|
||||
$result .= $linkend;
|
||||
|
||||
return $result;
|
||||
@ -1233,8 +1250,7 @@ class Holiday extends CommonObject
|
||||
public function LibStatut($status, $mode = 0, $startdate = '')
|
||||
{
|
||||
// phpcs:enable
|
||||
if (empty($this->labelStatus) || empty($this->labelStatusShort))
|
||||
{
|
||||
if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
|
||||
global $langs;
|
||||
//$langs->load("mymodule");
|
||||
$this->labelStatus[self::STATUS_DRAFT] = $langs->trans('DraftCP');
|
||||
@ -1250,11 +1266,21 @@ class Holiday extends CommonObject
|
||||
}
|
||||
|
||||
$statusType = 'status6';
|
||||
if (!empty($startdate) && $startdate > dol_now()) $statusType = 'status4';
|
||||
if ($status == self::STATUS_DRAFT) $statusType = 'status0';
|
||||
if ($status == self::STATUS_VALIDATED) $statusType = 'status1';
|
||||
if ($status == self::STATUS_CANCELED) $statusType = 'status5';
|
||||
if ($status == self::STATUS_REFUSED) $statusType = 'status5';
|
||||
if (!empty($startdate) && $startdate > dol_now()) {
|
||||
$statusType = 'status4';
|
||||
}
|
||||
if ($status == self::STATUS_DRAFT) {
|
||||
$statusType = 'status0';
|
||||
}
|
||||
if ($status == self::STATUS_VALIDATED) {
|
||||
$statusType = 'status1';
|
||||
}
|
||||
if ($status == self::STATUS_CANCELED) {
|
||||
$statusType = 'status5';
|
||||
}
|
||||
if ($status == self::STATUS_REFUSED) {
|
||||
$statusType = 'status5';
|
||||
}
|
||||
|
||||
return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
|
||||
}
|
||||
@ -1338,15 +1364,12 @@ class Holiday extends CommonObject
|
||||
if ($result) {
|
||||
$obj = $this->db->fetch_object($result);
|
||||
// Return value
|
||||
if (empty($obj))
|
||||
{
|
||||
if ($createifnotfound)
|
||||
{
|
||||
if (empty($obj)) {
|
||||
if ($createifnotfound) {
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday_config(name, value)";
|
||||
$sql .= " VALUES('".$this->db->escape($name)."', '".$this->db->escape($createifnotfound)."')";
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
if ($result) {
|
||||
return $createifnotfound;
|
||||
} else {
|
||||
$this->error = $this->db->lasterror();
|
||||
@ -1379,8 +1402,7 @@ class Holiday extends CommonObject
|
||||
|
||||
$error = 0;
|
||||
|
||||
if (empty($userID) && empty($nbHoliday) && empty($fk_type))
|
||||
{
|
||||
if (empty($userID) && empty($nbHoliday) && empty($fk_type)) {
|
||||
$langs->load("holiday");
|
||||
|
||||
// Si mise à jour pour tout le monde en début de mois
|
||||
@ -1395,8 +1417,7 @@ class Holiday extends CommonObject
|
||||
//print 'month: '.$month.' lastUpdate:'.$lastUpdate.' monthLastUpdate:'.$monthLastUpdate;exit;
|
||||
|
||||
// Si la date du mois n'est pas la même que celle sauvegardée, on met à jour le timestamp
|
||||
if ($month != $monthLastUpdate)
|
||||
{
|
||||
if ($month != $monthLastUpdate) {
|
||||
$this->db->begin();
|
||||
|
||||
$users = $this->fetchUsers(false, false);
|
||||
@ -1412,7 +1433,9 @@ class Holiday extends CommonObject
|
||||
// Update each user counter
|
||||
foreach ($users as $userCounter) {
|
||||
$nbDaysToAdd = (isset($typeleaves[$userCounter['type']]['newByMonth']) ? $typeleaves[$userCounter['type']]['newByMonth'] : 0);
|
||||
if (empty($nbDaysToAdd)) continue;
|
||||
if (empty($nbDaysToAdd)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
dol_syslog("We update leave type id ".$userCounter['type']." for user id ".$userCounter['rowid'], LOG_DEBUG);
|
||||
|
||||
@ -1424,15 +1447,13 @@ class Holiday extends CommonObject
|
||||
|
||||
$result = $this->updateSoldeCP($userCounter['rowid'], $newSolde, $userCounter['type'], $langs->trans('HolidaysMonthlyUpdate'));
|
||||
|
||||
if ($result < 0)
|
||||
{
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
} else {
|
||||
@ -1449,19 +1470,16 @@ class Holiday extends CommonObject
|
||||
$sql = "SELECT nb_holiday FROM ".MAIN_DB_PREFIX."holiday_users";
|
||||
$sql .= " WHERE fk_user = ".(int) $userID." AND fk_type = ".(int) $fk_type;
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$num = $this->db->num_rows($resql);
|
||||
|
||||
if ($num > 0)
|
||||
{
|
||||
if ($num > 0) {
|
||||
// Update for user
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."holiday_users SET";
|
||||
$sql .= " nb_holiday = ".$nbHoliday;
|
||||
$sql .= " WHERE fk_user = ".(int) $userID." AND fk_type = ".(int) $fk_type;
|
||||
$result = $this->db->query($sql);
|
||||
if (!$result)
|
||||
{
|
||||
if (!$result) {
|
||||
$error++;
|
||||
$this->errors[] = $this->db->lasterror();
|
||||
}
|
||||
@ -1471,8 +1489,7 @@ class Holiday extends CommonObject
|
||||
$sql .= $nbHoliday;
|
||||
$sql .= ", ".(int) $userID.", ".(int) $fk_type.")";
|
||||
$result = $this->db->query($sql);
|
||||
if (!$result)
|
||||
{
|
||||
if (!$result) {
|
||||
$error++;
|
||||
$this->errors[] = $this->db->lasterror();
|
||||
}
|
||||
@ -1482,8 +1499,7 @@ class Holiday extends CommonObject
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
return 1;
|
||||
} else {
|
||||
return -1;
|
||||
@ -1527,19 +1543,19 @@ class Holiday extends CommonObject
|
||||
public function createCPusers($single = false, $userid = '')
|
||||
{
|
||||
// do we have to add balance for all users ?
|
||||
if (!$single)
|
||||
{
|
||||
if (!$single) {
|
||||
dol_syslog(get_class($this).'::createCPusers');
|
||||
$arrayofusers = $this->fetchUsers(false, true);
|
||||
|
||||
foreach ($arrayofusers as $users)
|
||||
{
|
||||
foreach ($arrayofusers as $users) {
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday_users";
|
||||
$sql .= " (fk_user, nb_holiday)";
|
||||
$sql .= " VALUES (".((int) $users['rowid'])."', '0')";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql) dol_print_error($this->db);
|
||||
if (!$resql) {
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday_users";
|
||||
@ -1547,7 +1563,9 @@ class Holiday extends CommonObject
|
||||
$sql .= " VALUES (".((int) $userid)."', '0')";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql) dol_print_error($this->db);
|
||||
if (!$resql) {
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1579,16 +1597,20 @@ class Holiday extends CommonObject
|
||||
$sql = "SELECT nb_holiday";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."holiday_users";
|
||||
$sql .= " WHERE fk_user = ".(int) $user_id;
|
||||
if ($fk_type > 0) $sql .= " AND fk_type = ".(int) $fk_type;
|
||||
if ($fk_type > 0) {
|
||||
$sql .= " AND fk_type = ".(int) $fk_type;
|
||||
}
|
||||
|
||||
dol_syslog(get_class($this).'::getCPforUser user_id='.$user_id.' type_id='.$fk_type, LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
if ($result) {
|
||||
$obj = $this->db->fetch_object($result);
|
||||
//return number_format($obj->nb_holiday,2);
|
||||
if ($obj) return $obj->nb_holiday;
|
||||
else return null;
|
||||
if ($obj) {
|
||||
return $obj->nb_holiday;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@ -1608,10 +1630,8 @@ class Holiday extends CommonObject
|
||||
|
||||
dol_syslog(get_class($this)."::fetchUsers", LOG_DEBUG);
|
||||
|
||||
if ($stringlist)
|
||||
{
|
||||
if ($type)
|
||||
{
|
||||
if ($stringlist) {
|
||||
if ($type) {
|
||||
// If user of Dolibarr
|
||||
$sql = "SELECT";
|
||||
if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
|
||||
@ -1620,8 +1640,7 @@ class Holiday extends CommonObject
|
||||
$sql .= " u.rowid";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."user as u";
|
||||
|
||||
if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
|
||||
{
|
||||
if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
|
||||
$sql .= ", ".MAIN_DB_PREFIX."usergroup_user as ug";
|
||||
$sql .= " WHERE ((ug.fk_user = u.rowid";
|
||||
$sql .= " AND ug.entity IN (".getEntity('usergroup')."))";
|
||||
@ -1630,7 +1649,9 @@ class Holiday extends CommonObject
|
||||
$sql .= " WHERE u.entity IN (".getEntity('user').")";
|
||||
}
|
||||
$sql .= " AND u.statut > 0";
|
||||
if ($filters) $sql .= $filters;
|
||||
if ($filters) {
|
||||
$sql .= $filters;
|
||||
}
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
@ -1641,8 +1662,7 @@ class Holiday extends CommonObject
|
||||
$stringlist = '';
|
||||
|
||||
// Boucles du listage des utilisateurs
|
||||
while ($i < $num)
|
||||
{
|
||||
while ($i < $num) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
if ($i == 0) {
|
||||
@ -1665,7 +1685,9 @@ class Holiday extends CommonObject
|
||||
$sql = "SELECT DISTINCT cpu.fk_user";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu, ".MAIN_DB_PREFIX."user as u";
|
||||
$sql .= " WHERE cpu.fk_user = u.rowid";
|
||||
if ($filters) $sql .= $filters;
|
||||
if ($filters) {
|
||||
$sql .= $filters;
|
||||
}
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
@ -1676,8 +1698,7 @@ class Holiday extends CommonObject
|
||||
$stringlist = '';
|
||||
|
||||
// Boucles du listage des utilisateurs
|
||||
while ($i < $num)
|
||||
{
|
||||
while ($i < $num) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
if ($i == 0) {
|
||||
@ -1699,8 +1720,7 @@ class Holiday extends CommonObject
|
||||
} else {
|
||||
// Si faux donc return array
|
||||
// List for Dolibarr users
|
||||
if ($type)
|
||||
{
|
||||
if ($type) {
|
||||
// If user of Dolibarr
|
||||
$sql = "SELECT";
|
||||
if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
|
||||
@ -1709,8 +1729,7 @@ class Holiday extends CommonObject
|
||||
$sql .= " u.rowid, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut, u.fk_user";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."user as u";
|
||||
|
||||
if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
|
||||
{
|
||||
if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
|
||||
$sql .= ", ".MAIN_DB_PREFIX."usergroup_user as ug";
|
||||
$sql .= " WHERE ((ug.fk_user = u.rowid";
|
||||
$sql .= " AND ug.entity IN (".getEntity('usergroup')."))";
|
||||
@ -1720,13 +1739,14 @@ class Holiday extends CommonObject
|
||||
}
|
||||
|
||||
$sql .= " AND u.statut > 0";
|
||||
if ($filters) $sql .= $filters;
|
||||
if ($filters) {
|
||||
$sql .= $filters;
|
||||
}
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
// Si pas d'erreur SQL
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$i = 0;
|
||||
$tab_result = $this->holiday;
|
||||
$num = $this->db->num_rows($resql);
|
||||
@ -1761,20 +1781,20 @@ class Holiday extends CommonObject
|
||||
$sql = "SELECT cpu.fk_type, cpu.nb_holiday, u.rowid, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut, u.fk_user";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu, ".MAIN_DB_PREFIX."user as u";
|
||||
$sql .= " WHERE cpu.fk_user = u.rowid";
|
||||
if ($filters) $sql .= $filters;
|
||||
if ($filters) {
|
||||
$sql .= $filters;
|
||||
}
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
// Si pas d'erreur SQL
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$i = 0;
|
||||
$tab_result = $this->holiday;
|
||||
$num = $this->db->num_rows($resql);
|
||||
|
||||
// Boucles du listage des utilisateurs
|
||||
while ($i < $num)
|
||||
{
|
||||
while ($i < $num) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$tab_result[$i]['rowid'] = $obj->rowid; // rowid of user
|
||||
@ -1827,11 +1847,9 @@ class Holiday extends CommonObject
|
||||
|
||||
dol_syslog(get_class($this)."::fetch_users_approver_holiday sql=".$sql);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
if ($result) {
|
||||
$num_rows = $this->db->num_rows($result); $i = 0;
|
||||
while ($i < $num_rows)
|
||||
{
|
||||
while ($i < $num_rows) {
|
||||
$objp = $this->db->fetch_object($result);
|
||||
array_push($users_validator, $objp->fk_user);
|
||||
$i++;
|
||||
@ -1888,7 +1906,9 @@ class Holiday extends CommonObject
|
||||
*/
|
||||
public function verifNbUsers($userDolibarrWithoutCP, $userCP)
|
||||
{
|
||||
if (empty($userCP)) $userCP = 0;
|
||||
if (empty($userCP)) {
|
||||
$userCP = 0;
|
||||
}
|
||||
dol_syslog(get_class($this).'::verifNbUsers userDolibarr='.$userDolibarrWithoutCP.' userCP='.$userCP);
|
||||
return 1;
|
||||
}
|
||||
@ -1914,7 +1934,9 @@ class Holiday extends CommonObject
|
||||
$new_solde = price2num($new_solde, 5);
|
||||
//print "$prev_solde == $new_solde";
|
||||
|
||||
if ($prev_solde == $new_solde) return 0;
|
||||
if ($prev_solde == $new_solde) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
@ -1938,21 +1960,17 @@ class Holiday extends CommonObject
|
||||
$sql .= ")";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql)
|
||||
{
|
||||
if (!$resql) {
|
||||
$error++; $this->errors[] = "Error ".$this->db->lasterror();
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$this->optRowid = $this->db->last_insert_id(MAIN_DB_PREFIX."holiday_logs");
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error)
|
||||
{
|
||||
foreach ($this->errors as $errmsg)
|
||||
{
|
||||
if ($error) {
|
||||
foreach ($this->errors as $errmsg) {
|
||||
dol_syslog(get_class($this)."::addLogCP ".$errmsg, LOG_ERR);
|
||||
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
|
||||
}
|
||||
@ -2051,23 +2069,26 @@ class Holiday extends CommonObject
|
||||
$sql = "SELECT rowid, code, label, affect, delay, newByMonth";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_holiday_types";
|
||||
$sql .= " WHERE (fk_country IS NULL OR fk_country = ".$mysoc->country_id.')';
|
||||
if ($active >= 0) $sql .= " AND active = ".((int) $active);
|
||||
if ($affect >= 0) $sql .= " AND affect = ".((int) $affect);
|
||||
if ($active >= 0) {
|
||||
$sql .= " AND active = ".((int) $active);
|
||||
}
|
||||
if ($affect >= 0) {
|
||||
$sql .= " AND affect = ".((int) $affect);
|
||||
}
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
if ($result) {
|
||||
$num = $this->db->num_rows($result);
|
||||
if ($num)
|
||||
{
|
||||
while ($obj = $this->db->fetch_object($result))
|
||||
{
|
||||
if ($num) {
|
||||
while ($obj = $this->db->fetch_object($result)) {
|
||||
$types[$obj->rowid] = array('rowid'=> $obj->rowid, 'code'=> $obj->code, 'label'=>$obj->label, 'affect'=>$obj->affect, 'delay'=>$obj->delay, 'newByMonth'=>$obj->newByMonth);
|
||||
}
|
||||
|
||||
return $types;
|
||||
}
|
||||
} else dol_print_error($this->db);
|
||||
} else {
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
@ -2099,10 +2120,8 @@ class Holiday extends CommonObject
|
||||
$sql .= " AND f.entity = ".$conf->entity;
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($this->db->num_rows($resql))
|
||||
{
|
||||
if ($resql) {
|
||||
if ($this->db->num_rows($resql)) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
@ -2116,26 +2135,22 @@ class Holiday extends CommonObject
|
||||
$cuser->fetch($obj->fk_user_author);
|
||||
$this->user_creation = $cuser;
|
||||
|
||||
if ($obj->fk_user_creation)
|
||||
{
|
||||
if ($obj->fk_user_creation) {
|
||||
$cuser = new User($this->db);
|
||||
$cuser->fetch($obj->fk_user_creation);
|
||||
$this->user_creation = $cuser;
|
||||
}
|
||||
if ($obj->fk_user_valid)
|
||||
{
|
||||
if ($obj->fk_user_valid) {
|
||||
$vuser = new User($this->db);
|
||||
$vuser->fetch($obj->fk_user_valid);
|
||||
$this->user_validation = $vuser;
|
||||
}
|
||||
if ($obj->fk_user_modification)
|
||||
{
|
||||
if ($obj->fk_user_modification) {
|
||||
$muser = new User($this->db);
|
||||
$muser->fetch($obj->fk_user_modification);
|
||||
$this->user_modification = $muser;
|
||||
}
|
||||
if ($obj->fk_user_approve)
|
||||
{
|
||||
if ($obj->fk_user_approve) {
|
||||
$auser = new User($this->db);
|
||||
$auser->fetch($obj->fk_user_approve);
|
||||
$this->user_approve = $auser;
|
||||
@ -2191,8 +2206,7 @@ class Holiday extends CommonObject
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."holiday as h";
|
||||
$sql .= " WHERE h.statut > 1";
|
||||
$sql .= " AND h.entity IN (".getEntity('holiday').")";
|
||||
if (empty($user->rights->expensereport->readall))
|
||||
{
|
||||
if (empty($user->rights->expensereport->readall)) {
|
||||
$userchildids = $user->getAllChildIds(1);
|
||||
$sql .= " AND (h.fk_user IN (".join(',', $userchildids).")";
|
||||
$sql .= " OR h.fk_validator IN (".join(',', $userchildids)."))";
|
||||
@ -2224,7 +2238,9 @@ class Holiday extends CommonObject
|
||||
// phpcs:enable
|
||||
global $conf, $langs;
|
||||
|
||||
if ($user->socid) return -1; // protection pour eviter appel par utilisateur externe
|
||||
if ($user->socid) {
|
||||
return -1; // protection pour eviter appel par utilisateur externe
|
||||
}
|
||||
|
||||
$now = dol_now();
|
||||
|
||||
@ -2232,16 +2248,14 @@ class Holiday extends CommonObject
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."holiday as h";
|
||||
$sql .= " WHERE h.statut = 2";
|
||||
$sql .= " AND h.entity IN (".getEntity('holiday').")";
|
||||
if (empty($user->rights->expensereport->read_all))
|
||||
{
|
||||
if (empty($user->rights->expensereport->read_all)) {
|
||||
$userchildids = $user->getAllChildIds(1);
|
||||
$sql .= " AND (h.fk_user IN (".join(',', $userchildids).")";
|
||||
$sql .= " OR h.fk_validator IN (".join(',', $userchildids)."))";
|
||||
}
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$langs->load("members");
|
||||
|
||||
$response = new WorkboardResponse();
|
||||
@ -2251,8 +2265,7 @@ class Holiday extends CommonObject
|
||||
$response->url = DOL_URL_ROOT.'/holiday/list.php?search_statut=2&mainmenu=hrm&leftmenu=holiday';
|
||||
$response->img = img_object('', "holiday");
|
||||
|
||||
while ($obj = $this->db->fetch_object($resql))
|
||||
{
|
||||
while ($obj = $this->db->fetch_object($resql)) {
|
||||
$response->nbtodo++;
|
||||
|
||||
if ($this->db->jdate($obj->date_debut) < ($now - $conf->holiday->approve->warning_delay)) {
|
||||
|
||||
@ -44,19 +44,29 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
|
||||
$sortfield = GETPOST('sortfield', 'aZ09comma');
|
||||
$sortorder = GETPOST('sortorder', 'aZ09comma');
|
||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
||||
if (empty($page) || $page == -1) {
|
||||
$page = 0;
|
||||
} // If $page is not defined, or '' or -1
|
||||
$offset = $limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if (!$sortfield) $sortfield = "t.rowid"; // Set here default search field
|
||||
if (!$sortorder) $sortorder = "ASC";
|
||||
if (!$sortfield) {
|
||||
$sortfield = "t.rowid"; // Set here default search field
|
||||
}
|
||||
if (!$sortorder) {
|
||||
$sortorder = "ASC";
|
||||
}
|
||||
|
||||
|
||||
// Protection if external user
|
||||
if ($user->socid > 0) accessforbidden();
|
||||
if ($user->socid > 0) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
// If the user does not have perm to read the page
|
||||
if (empty($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,8 +75,7 @@ $extrafields = new ExtraFields($db);
|
||||
|
||||
$holiday = new Holiday($db);
|
||||
|
||||
if (empty($conf->holiday->enabled))
|
||||
{
|
||||
if (empty($conf->holiday->enabled)) {
|
||||
llxHeader('', $langs->trans('CPTitreMenu'));
|
||||
print '<div class="tabBar">';
|
||||
print '<span style="color: #FF0000;">'.$langs->trans('NotActiveModCP').'</span>';
|
||||
@ -81,21 +90,25 @@ if (empty($conf->holiday->enabled))
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
|
||||
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
|
||||
if (GETPOST('cancel', 'alpha')) {
|
||||
$action = 'list'; $massaction = '';
|
||||
}
|
||||
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
|
||||
$massaction = '';
|
||||
}
|
||||
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
if (empty($reshook)) {
|
||||
// Selection of new fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
|
||||
|
||||
// Purge search criteria
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
|
||||
{
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
|
||||
$search_name = '';
|
||||
$search_supervisor = '';
|
||||
$toselect = '';
|
||||
@ -104,17 +117,16 @@ if (empty($reshook))
|
||||
|
||||
// Mass actions
|
||||
/*
|
||||
$objectclass='Skeleton';
|
||||
$objectlabel='Skeleton';
|
||||
$permissiontoread = $user->rights->skeleton->read;
|
||||
$permissiontodelete = $user->rights->skeleton->delete;
|
||||
$uploaddir = $conf->skeleton->dir_output;
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
|
||||
*/
|
||||
$objectclass='Skeleton';
|
||||
$objectlabel='Skeleton';
|
||||
$permissiontoread = $user->rights->skeleton->read;
|
||||
$permissiontodelete = $user->rights->skeleton->delete;
|
||||
$uploaddir = $conf->skeleton->dir_output;
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
|
||||
*/
|
||||
|
||||
// Si il y a une action de mise à jour
|
||||
if ($action == 'update' && isset($_POST['update_cp']))
|
||||
{
|
||||
if ($action == 'update' && isset($_POST['update_cp'])) {
|
||||
$error = 0;
|
||||
|
||||
$typeleaves = $holiday->getTypes(1, 1);
|
||||
@ -122,13 +134,11 @@ if (empty($reshook))
|
||||
$userID = array_keys($_POST['update_cp']);
|
||||
$userID = $userID[0];
|
||||
|
||||
foreach ($typeleaves as $key => $val)
|
||||
{
|
||||
foreach ($typeleaves as $key => $val) {
|
||||
$userValue = $_POST['nb_holiday_'.$val['rowid']];
|
||||
$userValue = $userValue[$userID];
|
||||
|
||||
if (!empty($userValue) || (string) $userValue == '0')
|
||||
{
|
||||
if (!empty($userValue) || (string) $userValue == '0') {
|
||||
$userValue = price2num($userValue, 5);
|
||||
} else {
|
||||
$userValue = '';
|
||||
@ -138,37 +148,36 @@ if (empty($reshook))
|
||||
$comment = ((isset($_POST['note_holiday'][$userID]) && !empty($_POST['note_holiday'][$userID])) ? ' ('.$_POST['note_holiday'][$userID].')' : '');
|
||||
|
||||
//print 'holiday: '.$val['rowid'].'-'.$userValue;
|
||||
if ($userValue != '')
|
||||
{
|
||||
if ($userValue != '') {
|
||||
// We add the modification to the log (must be before update of sold because we read current value of sold)
|
||||
$result = $holiday->addLogCP($user->id, $userID, $langs->transnoentitiesnoconv('ManualUpdate').$comment, $userValue, $val['rowid']);
|
||||
if ($result < 0)
|
||||
{
|
||||
if ($result < 0) {
|
||||
setEventMessages($holiday->error, $holiday->errors, 'errors');
|
||||
$error++;
|
||||
}
|
||||
|
||||
// Update of the days of the employee
|
||||
$result = $holiday->updateSoldeCP($userID, $userValue, $val['rowid']);
|
||||
if ($result < 0)
|
||||
{
|
||||
if ($result < 0) {
|
||||
setEventMessages($holiday->error, $holiday->errors, 'errors');
|
||||
$error++;
|
||||
}
|
||||
|
||||
// If it first update of balance, we set date to avoid to have sold incremented by new month
|
||||
/*
|
||||
$now=dol_now();
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."holiday_config SET";
|
||||
$sql.= " value = '".dol_print_date($now,'%Y%m%d%H%M%S')."'";
|
||||
$sql.= " WHERE name = 'lastUpdate' and value IS NULL"; // Add value IS NULL to be sure to update only at init.
|
||||
dol_syslog('define_holiday update lastUpdate entry', LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
*/
|
||||
$now=dol_now();
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."holiday_config SET";
|
||||
$sql.= " value = '".dol_print_date($now,'%Y%m%d%H%M%S')."'";
|
||||
$sql.= " WHERE name = 'lastUpdate' and value IS NULL"; // Add value IS NULL to be sure to update only at init.
|
||||
dol_syslog('define_holiday update lastUpdate entry', LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error) setEventMessages('UpdateConfCPOK', '', 'mesgs');
|
||||
if (!$error) {
|
||||
setEventMessages('UpdateConfCPOK', '', 'mesgs');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -191,7 +200,9 @@ if ($result < 0) {
|
||||
|
||||
|
||||
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
if ($optioncss != '') {
|
||||
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
}
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
@ -217,35 +228,36 @@ $filters = '';
|
||||
|
||||
// Filter on array of ids of all childs
|
||||
$userchilds = array();
|
||||
if (empty($user->rights->holiday->readall))
|
||||
{
|
||||
if (empty($user->rights->holiday->readall)) {
|
||||
$userchilds = $user->getAllChildIds(1);
|
||||
$filters .= ' AND u.rowid IN ('.join(', ', $userchilds).')';
|
||||
}
|
||||
if (!empty($search_name)) {
|
||||
$filters .= natural_search(array('u.firstname', 'u.lastname'), $search_name);
|
||||
}
|
||||
if ($search_supervisor > 0) $filters .= natural_search(array('u.fk_user'), $search_supervisor, 2);
|
||||
if ($search_supervisor > 0) {
|
||||
$filters .= natural_search(array('u.fk_user'), $search_supervisor, 2);
|
||||
}
|
||||
$filters .= ' AND employee = 1'; // Only employee users are visible
|
||||
|
||||
$listUsers = $holiday->fetchUsers(false, true, $filters);
|
||||
if (is_numeric($listUsers) && $listUsers < 0)
|
||||
{
|
||||
if (is_numeric($listUsers) && $listUsers < 0) {
|
||||
setEventMessages($holiday->error, $holiday->errors, 'errors');
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
|
||||
|
||||
if (count($typeleaves) == 0)
|
||||
{
|
||||
if (count($typeleaves) == 0) {
|
||||
//print '<div class="info">';
|
||||
print $langs->trans("NoLeaveWithCounterDefined")."<br>\n";
|
||||
print $langs->trans("GoIntoDictionaryHolidayTypes");
|
||||
//print '</div>';
|
||||
} else {
|
||||
$canedit = 0;
|
||||
if (!empty($user->rights->holiday->define_holiday)) $canedit = 1;
|
||||
if (!empty($user->rights->holiday->define_holiday)) {
|
||||
$canedit = 1;
|
||||
}
|
||||
|
||||
$moreforfilter = '';
|
||||
|
||||
@ -263,10 +275,8 @@ if (count($typeleaves) == 0)
|
||||
print '</td>';
|
||||
|
||||
// Type of leave request
|
||||
if (count($typeleaves))
|
||||
{
|
||||
foreach ($typeleaves as $key => $val)
|
||||
{
|
||||
if (count($typeleaves)) {
|
||||
foreach ($typeleaves as $key => $val) {
|
||||
print '<td class="liste_titre" style="text-align:center"></td>';
|
||||
}
|
||||
} else {
|
||||
@ -285,10 +295,8 @@ if (count($typeleaves) == 0)
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre('Employee', $_SERVER["PHP_SELF"]);
|
||||
print_liste_field_titre('Supervisor', $_SERVER["PHP_SELF"]);
|
||||
if (count($typeleaves))
|
||||
{
|
||||
foreach ($typeleaves as $key => $val)
|
||||
{
|
||||
if (count($typeleaves)) {
|
||||
foreach ($typeleaves as $key => $val) {
|
||||
$labeltype = ($langs->trans($val['code']) != $val['code']) ? $langs->trans($val['code']) : $langs->trans($val['label']);
|
||||
print_liste_field_titre($labeltype, $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'center ');
|
||||
}
|
||||
@ -301,12 +309,12 @@ if (count($typeleaves) == 0)
|
||||
|
||||
$usersupervisor = new User($db);
|
||||
|
||||
foreach ($listUsers as $users)
|
||||
{
|
||||
foreach ($listUsers as $users) {
|
||||
// If user has not permission to edit/read all, we must see only subordinates
|
||||
if (empty($user->rights->holiday->readall))
|
||||
{
|
||||
if (($users['rowid'] != $user->id) && (!in_array($users['rowid'], $userchilds))) continue; // This user is not into hierarchy of current user, we hide it.
|
||||
if (empty($user->rights->holiday->readall)) {
|
||||
if (($users['rowid'] != $user->id) && (!in_array($users['rowid'], $userchilds))) {
|
||||
continue; // This user is not into hierarchy of current user, we hide it.
|
||||
}
|
||||
}
|
||||
|
||||
$userstatic->id = $users['rowid'];
|
||||
@ -318,7 +326,9 @@ if (count($typeleaves) == 0)
|
||||
$userstatic->employee = $users['employee'];
|
||||
$userstatic->fk_user = $users['fk_user'];
|
||||
|
||||
if ($userstatic->fk_user > 0) $usersupervisor->fetch($userstatic->fk_user);
|
||||
if ($userstatic->fk_user > 0) {
|
||||
$usersupervisor->fetch($userstatic->fk_user);
|
||||
}
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
@ -329,21 +339,26 @@ if (count($typeleaves) == 0)
|
||||
|
||||
// Supervisor
|
||||
print '<td>';
|
||||
if ($userstatic->fk_user > 0) print $usersupervisor->getNomUrl(-1);
|
||||
if ($userstatic->fk_user > 0) {
|
||||
print $usersupervisor->getNomUrl(-1);
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
// Amount for each type
|
||||
if (count($typeleaves))
|
||||
{
|
||||
foreach ($typeleaves as $key => $val)
|
||||
{
|
||||
if (count($typeleaves)) {
|
||||
foreach ($typeleaves as $key => $val) {
|
||||
$nbtoshow = '';
|
||||
if ($holiday->getCPforUser($users['rowid'], $val['rowid']) != '') $nbtoshow = price2num($holiday->getCPforUser($users['rowid'], $val['rowid']), 5);
|
||||
if ($holiday->getCPforUser($users['rowid'], $val['rowid']) != '') {
|
||||
$nbtoshow = price2num($holiday->getCPforUser($users['rowid'], $val['rowid']), 5);
|
||||
}
|
||||
|
||||
//var_dump($users['rowid'].' - '.$val['rowid']);
|
||||
print '<td style="text-align:center">';
|
||||
if ($canedit) print '<input type="text"'.($canedit ? '' : ' disabled="disabled"').' value="'.$nbtoshow.'" name="nb_holiday_'.$val['rowid'].'['.$users['rowid'].']" size="5" style="text-align: center;"/>';
|
||||
else print $nbtoshow;
|
||||
if ($canedit) {
|
||||
print '<input type="text"'.($canedit ? '' : ' disabled="disabled"').' value="'.$nbtoshow.'" name="nb_holiday_'.$val['rowid'].'['.$users['rowid'].']" size="5" style="text-align: center;"/>';
|
||||
} else {
|
||||
print $nbtoshow;
|
||||
}
|
||||
//print ' '.$langs->trans('days');
|
||||
print '</td>'."\n";
|
||||
}
|
||||
@ -353,13 +368,14 @@ if (count($typeleaves) == 0)
|
||||
|
||||
// Note
|
||||
print '<td>';
|
||||
if ($canedit) print '<input type="text"'.($canedit ? '' : ' disabled="disabled"').' class="maxwidthonsmartphone" value="" name="note_holiday['.$users['rowid'].']" size="30"/>';
|
||||
if ($canedit) {
|
||||
print '<input type="text"'.($canedit ? '' : ' disabled="disabled"').' class="maxwidthonsmartphone" value="" name="note_holiday['.$users['rowid'].']" size="30"/>';
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
// Button modify
|
||||
print '<td>';
|
||||
if (!empty($user->rights->holiday->define_holiday)) // Allowed to set the balance of any user
|
||||
{
|
||||
if (!empty($user->rights->holiday->define_holiday)) { // Allowed to set the balance of any user
|
||||
print '<input type="submit" name="update_cp['.$users['rowid'].']" value="'.dol_escape_htmltag($langs->trans("Save")).'" class="button smallpaddingimp"/>';
|
||||
}
|
||||
print '</td>'."\n";
|
||||
|
||||
@ -45,7 +45,9 @@ $action = GETPOST('action', 'aZ09');
|
||||
$confirm = GETPOST('confirm', 'alpha');
|
||||
|
||||
// Security check
|
||||
if ($user->socid) $socid = $user->socid;
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'holiday', $id, 'holiday');
|
||||
|
||||
// Get parameters
|
||||
@ -53,12 +55,18 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
|
||||
$sortfield = GETPOST('sortfield', 'aZ09comma');
|
||||
$sortorder = GETPOST('sortorder', 'aZ09comma');
|
||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
||||
if (empty($page) || $page == -1) {
|
||||
$page = 0;
|
||||
} // If $page is not defined, or '' or -1
|
||||
$offset = $limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if (!$sortorder) $sortorder = "ASC";
|
||||
if (!$sortfield) $sortfield = "position_name";
|
||||
if (!$sortorder) {
|
||||
$sortorder = "ASC";
|
||||
}
|
||||
if (!$sortfield) {
|
||||
$sortfield = "position_name";
|
||||
}
|
||||
|
||||
|
||||
$object = new Holiday($db);
|
||||
@ -86,8 +94,7 @@ $listhalfday = array('morning'=>$langs->trans("Morning"), "afternoon"=>$langs->t
|
||||
llxHeader("", "", $langs->trans("InterventionCard"));
|
||||
|
||||
|
||||
if ($object->id)
|
||||
{
|
||||
if ($object->id) {
|
||||
$valideur = new User($db);
|
||||
$valideur->fetch($object->fk_validator);
|
||||
|
||||
@ -102,8 +109,7 @@ if ($object->id)
|
||||
// Build file list
|
||||
$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
|
||||
$totalsize = 0;
|
||||
foreach ($filearray as $key => $file)
|
||||
{
|
||||
foreach ($filearray as $key => $file) {
|
||||
$totalsize += $file['size'];
|
||||
}
|
||||
|
||||
@ -138,8 +144,7 @@ if ($object->id)
|
||||
$starthalfday = ($object->halfday == -1 || $object->halfday == 2) ? 'afternoon' : 'morning';
|
||||
$endhalfday = ($object->halfday == 1 || $object->halfday == 2) ? 'morning' : 'afternoon';
|
||||
|
||||
if (!$edit)
|
||||
{
|
||||
if (!$edit) {
|
||||
print '<tr>';
|
||||
print '<td>';
|
||||
print $form->textwithpicto($langs->trans('DateDebCP'), $langs->trans("FirstDayOfHoliday"));
|
||||
@ -162,8 +167,7 @@ if ($object->id)
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
if (!$edit)
|
||||
{
|
||||
if (!$edit) {
|
||||
print '<tr>';
|
||||
print '<td>';
|
||||
print $form->textwithpicto($langs->trans('DateFinCP'), $langs->trans("LastDayOfHoliday"));
|
||||
@ -192,15 +196,18 @@ if ($object->id)
|
||||
$htmlhelp = $langs->trans('NbUseDaysCPHelp');
|
||||
$includesaturday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY : 1);
|
||||
$includesunday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY : 1);
|
||||
if ($includesaturday) $htmlhelp .= '<br>'.$langs->trans("DayIsANonWorkingDay", $langs->trans("Saturday"));
|
||||
if ($includesunday) $htmlhelp .= '<br>'.$langs->trans("DayIsANonWorkingDay", $langs->trans("Sunday"));
|
||||
if ($includesaturday) {
|
||||
$htmlhelp .= '<br>'.$langs->trans("DayIsANonWorkingDay", $langs->trans("Saturday"));
|
||||
}
|
||||
if ($includesunday) {
|
||||
$htmlhelp .= '<br>'.$langs->trans("DayIsANonWorkingDay", $langs->trans("Sunday"));
|
||||
}
|
||||
print $form->textwithpicto($langs->trans('NbUseDaysCP'), $htmlhelp);
|
||||
print '</td>';
|
||||
print '<td>'.num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
if ($object->statut == 5)
|
||||
{
|
||||
if ($object->statut == 5) {
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans('DetailRefusCP').'</td>';
|
||||
print '<td>'.$object->detail_refuse.'</td>';
|
||||
@ -208,8 +215,7 @@ if ($object->id)
|
||||
}
|
||||
|
||||
// Description
|
||||
if (!$edit)
|
||||
{
|
||||
if (!$edit) {
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans('DescCP').'</td>';
|
||||
print '<td>'.nl2br($object->description).'</td>';
|
||||
@ -227,67 +233,67 @@ if ($object->id)
|
||||
print '</tbody>';
|
||||
print '</table>'."\n";
|
||||
/*
|
||||
print '</div>';
|
||||
print '<div class="fichehalfright">';
|
||||
print '<div class="ficheaddleft">';
|
||||
print '</div>';
|
||||
print '<div class="fichehalfright">';
|
||||
print '<div class="ficheaddleft">';
|
||||
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
// Info workflow
|
||||
print '<table class="border tableforfield centpercent">'."\n";
|
||||
print '<tbody>';
|
||||
print '<table class="border tableforfield centpercent">'."\n";
|
||||
print '<tbody>';
|
||||
|
||||
if (! empty($object->fk_user_create))
|
||||
{
|
||||
$userCreate=new User($db);
|
||||
$userCreate->fetch($object->fk_user_create);
|
||||
print '<tr>';
|
||||
print '<td class="titlefield">'.$langs->trans('RequestByCP').'</td>';
|
||||
print '<td>'.$userCreate->getNomUrl(-1).'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
if (! empty($object->fk_user_create))
|
||||
{
|
||||
$userCreate=new User($db);
|
||||
$userCreate->fetch($object->fk_user_create);
|
||||
print '<tr>';
|
||||
print '<td class="titlefield">'.$langs->trans('RequestByCP').'</td>';
|
||||
print '<td>'.$userCreate->getNomUrl(-1).'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
if (!$edit) {
|
||||
print '<tr>';
|
||||
print '<td class="titlefield">'.$langs->trans('ReviewedByCP').'</td>';
|
||||
print '<td>'.$valideur->getNomUrl(-1).'</td>';
|
||||
print '</tr>';
|
||||
} else {
|
||||
print '<tr>';
|
||||
print '<td class="titlefield">'.$langs->trans('ReviewedByCP').'</td>';
|
||||
print '<td>';
|
||||
if (!$edit) {
|
||||
print '<tr>';
|
||||
print '<td class="titlefield">'.$langs->trans('ReviewedByCP').'</td>';
|
||||
print '<td>'.$valideur->getNomUrl(-1).'</td>';
|
||||
print '</tr>';
|
||||
} else {
|
||||
print '<tr>';
|
||||
print '<td class="titlefield">'.$langs->trans('ReviewedByCP').'</td>';
|
||||
print '<td>';
|
||||
print $form->select_dolusers($object->fk_user, "valideur", 1, ($user->admin ? '' : array($user->id))); // By default, hierarchical parent
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans('DateCreation').'</td>';
|
||||
print '<td>'.dol_print_date($object->date_create,'dayhour').'</td>';
|
||||
print '</tr>';
|
||||
if ($object->statut == 3) {
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans('DateValidCP').'</td>';
|
||||
print '<td>'.dol_print_date($object->date_valid,'dayhour').'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
if ($object->statut == 4) {
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans('DateCancelCP').'</td>';
|
||||
print '<td>'.dol_print_date($object->date_cancel,'dayhour').'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
if ($object->statut == 5) {
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans('DateRefusCP').'</td>';
|
||||
print '<td>'.dol_print_date($object->date_refuse,'dayhour').'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
print '</tbody>';
|
||||
print '</table>';
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans('DateCreation').'</td>';
|
||||
print '<td>'.dol_print_date($object->date_create,'dayhour').'</td>';
|
||||
print '</tr>';
|
||||
if ($object->statut == 3) {
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans('DateValidCP').'</td>';
|
||||
print '<td>'.dol_print_date($object->date_valid,'dayhour').'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
if ($object->statut == 4) {
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans('DateCancelCP').'</td>';
|
||||
print '<td>'.dol_print_date($object->date_cancel,'dayhour').'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
if ($object->statut == 5) {
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans('DateRefusCP').'</td>';
|
||||
print '<td>'.dol_print_date($object->date_refuse,'dayhour').'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
print '</tbody>';
|
||||
print '</table>';
|
||||
|
||||
print '</div>';
|
||||
print '</div>'; */
|
||||
print '</div>';
|
||||
print '</div>'; */
|
||||
print '</div>';
|
||||
|
||||
print '<div class="clearboth"></div>';
|
||||
|
||||
@ -37,23 +37,26 @@ $ref = GETPOST('ref', 'alpha');
|
||||
$childids = $user->getAllChildIds(1);
|
||||
|
||||
// Security check
|
||||
if ($user->socid) $socid = $user->socid;
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'holiday', $id, 'holiday');
|
||||
|
||||
$object = new Holiday($db);
|
||||
if (!$object->fetch($id, $ref) > 0)
|
||||
{
|
||||
if (!$object->fetch($id, $ref) > 0) {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
if ($object->id > 0)
|
||||
{
|
||||
if ($object->id > 0) {
|
||||
// Check current user can read this expense report
|
||||
$canread = 0;
|
||||
if (!empty($user->rights->holiday->readall)) $canread = 1;
|
||||
if (!empty($user->rights->holiday->lire) && in_array($object->fk_user_author, $childids)) $canread = 1;
|
||||
if (!$canread)
|
||||
{
|
||||
if (!empty($user->rights->holiday->readall)) {
|
||||
$canread = 1;
|
||||
}
|
||||
if (!empty($user->rights->holiday->lire) && in_array($object->fk_user_author, $childids)) {
|
||||
$canread = 1;
|
||||
}
|
||||
if (!$canread) {
|
||||
accessforbidden();
|
||||
}
|
||||
}
|
||||
@ -69,8 +72,7 @@ $title = $langs->trans("Holiday")." - ".$langs->trans("Info");
|
||||
$helpurl = "";
|
||||
llxHeader("", $title, $helpurl);
|
||||
|
||||
if ($id > 0 || !empty($ref))
|
||||
{
|
||||
if ($id > 0 || !empty($ref)) {
|
||||
$object = new Holiday($db);
|
||||
$object->fetch($id, $ref);
|
||||
$object->info($object->id);
|
||||
|
||||
@ -40,7 +40,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
|
||||
$langs->loadLangs(array('users', 'other', 'holiday', 'hrm'));
|
||||
|
||||
// Protection if external user
|
||||
if ($user->socid > 0) accessforbidden();
|
||||
if ($user->socid > 0) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
$action = GETPOST('action', 'aZ09'); // The action 'add', 'create', 'edit', 'update', 'view', ...
|
||||
$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
|
||||
@ -59,21 +61,24 @@ $childids = $user->getAllChildIds(1);
|
||||
|
||||
// Security check
|
||||
$socid = 0;
|
||||
if ($user->socid > 0) // Protection if external user
|
||||
{
|
||||
if ($user->socid > 0) { // Protection if external user
|
||||
//$socid = $user->socid;
|
||||
accessforbidden();
|
||||
}
|
||||
$result = restrictedArea($user, 'holiday', '', '');
|
||||
// If we are on the view of a specific user
|
||||
if ($id > 0)
|
||||
{
|
||||
if ($id > 0) {
|
||||
$canread = 0;
|
||||
if ($id == $user->id) $canread = 1;
|
||||
if (!empty($user->rights->holiday->readall)) $canread = 1;
|
||||
if (!empty($user->rights->holiday->read) && in_array($id, $childids)) $canread = 1;
|
||||
if (!$canread)
|
||||
{
|
||||
if ($id == $user->id) {
|
||||
$canread = 1;
|
||||
}
|
||||
if (!empty($user->rights->holiday->readall)) {
|
||||
$canread = 1;
|
||||
}
|
||||
if (!empty($user->rights->holiday->read) && in_array($id, $childids)) {
|
||||
$canread = 1;
|
||||
}
|
||||
if (!$canread) {
|
||||
accessforbidden();
|
||||
}
|
||||
}
|
||||
@ -86,12 +91,18 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
|
||||
$sortfield = GETPOST('sortfield', 'aZ09comma');
|
||||
$sortorder = GETPOST('sortorder', 'aZ09comma');
|
||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
||||
if (empty($page) || $page == -1) {
|
||||
$page = 0;
|
||||
} // If $page is not defined, or '' or -1
|
||||
$offset = $limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if (!$sortorder) $sortorder = "DESC";
|
||||
if (!$sortfield) $sortfield = "cp.rowid";
|
||||
if (!$sortorder) {
|
||||
$sortorder = "DESC";
|
||||
}
|
||||
if (!$sortfield) {
|
||||
$sortfield = "cp.rowid";
|
||||
}
|
||||
|
||||
$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
|
||||
$search_ref = GETPOST('search_ref', 'alphanohtml');
|
||||
@ -145,8 +156,7 @@ $arrayfields = array(
|
||||
// Extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
|
||||
|
||||
if (empty($conf->holiday->enabled))
|
||||
{
|
||||
if (empty($conf->holiday->enabled)) {
|
||||
llxHeader('', $langs->trans('CPTitreMenu'));
|
||||
print '<div class="tabBar">';
|
||||
print '<span style="color: #FF0000;">'.$langs->trans('NotActiveModCP').'</span>';
|
||||
@ -160,21 +170,25 @@ if (empty($conf->holiday->enabled))
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
|
||||
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
|
||||
if (GETPOST('cancel', 'alpha')) {
|
||||
$action = 'list'; $massaction = '';
|
||||
}
|
||||
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
|
||||
$massaction = '';
|
||||
}
|
||||
|
||||
$parameters = array('socid'=>$socid);
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
if (empty($reshook)) {
|
||||
// Selection of new fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
|
||||
|
||||
// Purge search criteria
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
|
||||
{
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
|
||||
$search_ref = "";
|
||||
$search_month_create = "";
|
||||
$search_year_create = "";
|
||||
@ -190,8 +204,7 @@ if (empty($reshook))
|
||||
$search_array_options = array();
|
||||
}
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
|
||||
|| GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha'))
|
||||
{
|
||||
|| GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
|
||||
$massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
|
||||
}
|
||||
|
||||
@ -230,8 +243,7 @@ $min_year = 10;
|
||||
// Get current user id
|
||||
$user_id = $user->id;
|
||||
|
||||
if ($id > 0)
|
||||
{
|
||||
if ($id > 0) {
|
||||
// Charge utilisateur edite
|
||||
$fuser->fetch($id, '', '', 1);
|
||||
$fuser->getrights();
|
||||
@ -282,21 +294,29 @@ $sql .= " ua.statut as validator_status,";
|
||||
$sql .= " ua.photo as validator_photo";
|
||||
// Add fields from extrafields
|
||||
if (!empty($extrafields->attributes[$object->table_element]['label'])) {
|
||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
|
||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
|
||||
$sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
|
||||
}
|
||||
}
|
||||
// Add fields from hooks
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
|
||||
$sql .= $hookmanager->resPrint;
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."holiday as cp";
|
||||
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (cp.rowid = ef.fk_object)";
|
||||
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (cp.rowid = ef.fk_object)";
|
||||
}
|
||||
$sql .= ", ".MAIN_DB_PREFIX."user as uu, ".MAIN_DB_PREFIX."user as ua";
|
||||
$sql .= " WHERE cp.entity IN (".getEntity('holiday').")";
|
||||
$sql .= " AND cp.fk_user = uu.rowid AND cp.fk_validator = ua.rowid "; // Hack pour la recherche sur le tableau
|
||||
// Search all
|
||||
if (!empty($sall)) $sql .= natural_search(array_keys($fieldstosearchall), $sall);
|
||||
if (!empty($sall)) {
|
||||
$sql .= natural_search(array_keys($fieldstosearchall), $sall);
|
||||
}
|
||||
// Ref
|
||||
if (!empty($search_ref)) $sql .= natural_search("cp.ref", $search_ref);
|
||||
if (!empty($search_ref)) {
|
||||
$sql .= natural_search("cp.ref", $search_ref);
|
||||
}
|
||||
// Start date
|
||||
$sql .= dolSqlDateFilter("cp.date_debut", $search_day_start, $search_month_start, $search_year_start);
|
||||
// End date
|
||||
@ -320,8 +340,12 @@ if (!empty($search_status) && $search_status != -1) {
|
||||
$sql .= " AND cp.statut = '".$db->escape($search_status)."'\n";
|
||||
}
|
||||
|
||||
if (empty($user->rights->holiday->readall)) $sql .= ' AND cp.fk_user IN ('.join(',', $childids).')';
|
||||
if ($id > 0) $sql .= " AND cp.fk_user IN (".$id.")";
|
||||
if (empty($user->rights->holiday->readall)) {
|
||||
$sql .= ' AND cp.fk_user IN ('.join(',', $childids).')';
|
||||
}
|
||||
if ($id > 0) {
|
||||
$sql .= " AND cp.fk_user IN (".$id.")";
|
||||
}
|
||||
|
||||
// Add where from extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
|
||||
@ -334,12 +358,10 @@ $sql .= $db->order($sortfield, $sortorder);
|
||||
|
||||
// Count total nb of records
|
||||
$nbtotalofrecords = '';
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||
{
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
||||
$result = $db->query($sql);
|
||||
$nbtotalofrecords = $db->num_rows($result);
|
||||
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
|
||||
{
|
||||
if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
|
||||
$page = 0;
|
||||
$offset = 0;
|
||||
}
|
||||
@ -350,30 +372,63 @@ $sql .= $db->plimit($limit + 1, $offset);
|
||||
|
||||
//print $sql;
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
$arrayofselected = is_array($toselect) ? $toselect : array();
|
||||
|
||||
$param = '';
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
|
||||
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
|
||||
if ($search_ref) $param .= '&search_ref='.urlencode($search_ref);
|
||||
if ($search_day_create) $param .= '&search_day_create='.urlencode($search_day_create);
|
||||
if ($search_month_create) $param .= '&search_month_create='.urlencode($search_month_create);
|
||||
if ($search_year_create) $param .= '&search_year_create='.urlencode($search_year_create);
|
||||
if ($search_day_start) $param .= '&search_day_start='.urlencode($search_day_start);
|
||||
if ($search_month_start) $param .= '&search_month_start='.urlencode($search_month_start);
|
||||
if ($search_year_start) $param .= '&search_year_start='.urlencode($search_year_start);
|
||||
if ($search_day_end) $param .= '&search_day_end='.urlencode($search_day_end);
|
||||
if ($search_month_end) $param .= '&search_month_end='.urlencode($search_month_end);
|
||||
if ($search_year_end) $param .= '&search_year_end='.urlencode($search_year_end);
|
||||
if ($search_employee > 0) $param .= '&search_employee='.urlencode($search_employee);
|
||||
if ($search_valideur > 0) $param .= '&search_valideur='.urlencode($search_valideur);
|
||||
if ($search_type > 0) $param .= '&search_type='.urlencode($search_type);
|
||||
if ($search_status > 0) $param .= '&search_status='.urlencode($search_status);
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
|
||||
$param .= '&contextpage='.urlencode($contextpage);
|
||||
}
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) {
|
||||
$param .= '&limit='.urlencode($limit);
|
||||
}
|
||||
if ($optioncss != '') {
|
||||
$param .= '&optioncss='.urlencode($optioncss);
|
||||
}
|
||||
if ($search_ref) {
|
||||
$param .= '&search_ref='.urlencode($search_ref);
|
||||
}
|
||||
if ($search_day_create) {
|
||||
$param .= '&search_day_create='.urlencode($search_day_create);
|
||||
}
|
||||
if ($search_month_create) {
|
||||
$param .= '&search_month_create='.urlencode($search_month_create);
|
||||
}
|
||||
if ($search_year_create) {
|
||||
$param .= '&search_year_create='.urlencode($search_year_create);
|
||||
}
|
||||
if ($search_day_start) {
|
||||
$param .= '&search_day_start='.urlencode($search_day_start);
|
||||
}
|
||||
if ($search_month_start) {
|
||||
$param .= '&search_month_start='.urlencode($search_month_start);
|
||||
}
|
||||
if ($search_year_start) {
|
||||
$param .= '&search_year_start='.urlencode($search_year_start);
|
||||
}
|
||||
if ($search_day_end) {
|
||||
$param .= '&search_day_end='.urlencode($search_day_end);
|
||||
}
|
||||
if ($search_month_end) {
|
||||
$param .= '&search_month_end='.urlencode($search_month_end);
|
||||
}
|
||||
if ($search_year_end) {
|
||||
$param .= '&search_year_end='.urlencode($search_year_end);
|
||||
}
|
||||
if ($search_employee > 0) {
|
||||
$param .= '&search_employee='.urlencode($search_employee);
|
||||
}
|
||||
if ($search_valideur > 0) {
|
||||
$param .= '&search_valideur='.urlencode($search_valideur);
|
||||
}
|
||||
if ($search_type > 0) {
|
||||
$param .= '&search_type='.urlencode($search_type);
|
||||
}
|
||||
if ($search_status > 0) {
|
||||
$param .= '&search_status='.urlencode($search_status);
|
||||
}
|
||||
// Add $param from extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
|
||||
|
||||
@ -383,23 +438,30 @@ if ($resql)
|
||||
//'builddoc'=>$langs->trans("PDFMerge"),
|
||||
//'presend'=>$langs->trans("SendByMail"),
|
||||
);
|
||||
if ($user->rights->holiday->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
|
||||
if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
|
||||
if ($user->rights->holiday->supprimer) {
|
||||
$arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
|
||||
}
|
||||
if (in_array($massaction, array('presend', 'predelete'))) {
|
||||
$arrayofmassactions = array();
|
||||
}
|
||||
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
|
||||
|
||||
// Lines of title fields
|
||||
print '<form id="searchFormList" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
|
||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
if ($optioncss != '') {
|
||||
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
}
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
||||
print '<input type="hidden" name="action" value="'.($action == 'edit' ? 'update' : 'list').'">';
|
||||
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
|
||||
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
||||
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||
if ($id > 0) print '<input type="hidden" name="id" value="'.$id.'">';
|
||||
if ($id > 0) {
|
||||
print '<input type="hidden" name="id" value="'.$id.'">';
|
||||
}
|
||||
|
||||
if ($id > 0) // For user tab
|
||||
{
|
||||
if ($id > 0) { // For user tab
|
||||
$title = $langs->trans("User");
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/user/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
||||
$head = user_prepare_head($fuser);
|
||||
@ -408,8 +470,7 @@ if ($resql)
|
||||
|
||||
dol_banner_tab($fuser, 'id', $linkback, $user->rights->user->user->lire || $user->admin);
|
||||
|
||||
if (empty($conf->global->HOLIDAY_HIDE_BALANCE))
|
||||
{
|
||||
if (empty($conf->global->HOLIDAY_HIDE_BALANCE)) {
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
print '<br>';
|
||||
@ -425,8 +486,7 @@ if ($resql)
|
||||
|
||||
$canedit = (($user->id == $user_id && $user->rights->holiday->write) || ($user->id != $user_id && (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->holiday->writeall_advance))));
|
||||
|
||||
if ($canedit)
|
||||
{
|
||||
if ($canedit) {
|
||||
print '<a href="'.DOL_URL_ROOT.'/holiday/card.php?action=create&fuserid='.$user_id.'" class="butAction">'.$langs->trans("AddCP").'</a>';
|
||||
}
|
||||
|
||||
@ -445,9 +505,10 @@ if ($resql)
|
||||
$trackid = 'leav'.$object->id;
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
|
||||
|
||||
if ($sall)
|
||||
{
|
||||
foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
|
||||
if ($sall) {
|
||||
foreach ($fieldstosearchall as $key => $val) {
|
||||
$fieldstosearchall[$key] = $langs->trans($val);
|
||||
}
|
||||
print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
|
||||
}
|
||||
|
||||
@ -455,11 +516,13 @@ if ($resql)
|
||||
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
|
||||
else $moreforfilter = $hookmanager->resPrint;
|
||||
if (empty($reshook)) {
|
||||
$moreforfilter .= $hookmanager->resPrint;
|
||||
} else {
|
||||
$moreforfilter = $hookmanager->resPrint;
|
||||
}
|
||||
|
||||
if (!empty($moreforfilter))
|
||||
{
|
||||
if (!empty($moreforfilter)) {
|
||||
print '<div class="liste_titre liste_titre_bydiv centpercent">';
|
||||
print $moreforfilter;
|
||||
print '</div>';
|
||||
@ -471,7 +534,9 @@ if ($resql)
|
||||
|
||||
|
||||
$include = '';
|
||||
if (empty($user->rights->holiday->readall)) $include = 'hierarchyme'; // Can see only its hierarchyl
|
||||
if (empty($user->rights->holiday->readall)) {
|
||||
$include = 'hierarchyme'; // Can see only its hierarchyl
|
||||
}
|
||||
|
||||
print '<div class="div-table-responsive">';
|
||||
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
|
||||
@ -480,23 +545,22 @@ if ($resql)
|
||||
// Filters
|
||||
print '<tr class="liste_titre_filter">';
|
||||
|
||||
if (!empty($arrayfields['cp.ref']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['cp.ref']['checked'])) {
|
||||
print '<td class="liste_titre">';
|
||||
print '<input class="flat maxwidth50" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
if (!empty($arrayfields['cp.fk_user']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['cp.fk_user']['checked'])) {
|
||||
$morefilter = '';
|
||||
if (!empty($conf->global->HOLIDAY_HIDE_FOR_NON_SALARIES)) $morefilter = 'AND employee = 1';
|
||||
if (!empty($conf->global->HOLIDAY_HIDE_FOR_NON_SALARIES)) {
|
||||
$morefilter = 'AND employee = 1';
|
||||
}
|
||||
|
||||
// User
|
||||
$disabled = 0;
|
||||
// If into the tab holiday of a user ($id is set in such a case)
|
||||
if ($id && !GETPOSTISSET('search_employee'))
|
||||
{
|
||||
if ($id && !GETPOSTISSET('search_employee')) {
|
||||
$search_employee = $id;
|
||||
$disabled = 1;
|
||||
}
|
||||
@ -507,16 +571,16 @@ if ($resql)
|
||||
}
|
||||
|
||||
// Approver
|
||||
if (!empty($arrayfields['cp.fk_validator']['checked']))
|
||||
{
|
||||
if ($user->rights->holiday->readall)
|
||||
{
|
||||
if (!empty($arrayfields['cp.fk_validator']['checked'])) {
|
||||
if ($user->rights->holiday->readall) {
|
||||
print '<td class="liste_titre maxwidthonsmartphone left">';
|
||||
$validator = new UserGroup($db);
|
||||
$excludefilter = $user->admin ? '' : 'u.rowid <> '.$user->id;
|
||||
$valideurobjects = $validator->listUsersForGroup($excludefilter);
|
||||
$valideurarray = array();
|
||||
foreach ($valideurobjects as $val) $valideurarray[$val->id] = $val->id;
|
||||
foreach ($valideurobjects as $val) {
|
||||
$valideurarray[$val->id] = $val->id;
|
||||
}
|
||||
print $form->select_dolusers($search_valideur, "search_valideur", 1, "", 0, $valideurarray, '', 0, 0, 0, $morefilter, 0, '', 'maxwidth150');
|
||||
print '</td>';
|
||||
} else {
|
||||
@ -525,16 +589,14 @@ if ($resql)
|
||||
}
|
||||
|
||||
// Type
|
||||
if (!empty($arrayfields['cp.fk_type']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['cp.fk_type']['checked'])) {
|
||||
print '<td class="liste_titre">';
|
||||
if (empty($mysoc->country_id)) {
|
||||
setEventMessages(null, array($langs->trans("ErrorSetACountryFirst"), $langs->trans("CompanyFoundation")), 'errors');
|
||||
} else {
|
||||
$typeleaves = $holidaystatic->getTypes(1, -1);
|
||||
$arraytypeleaves = array();
|
||||
foreach ($typeleaves as $key => $val)
|
||||
{
|
||||
foreach ($typeleaves as $key => $val) {
|
||||
$labeltoshow = ($langs->trans($val['code']) != $val['code'] ? $langs->trans($val['code']) : $val['label']);
|
||||
//$labeltoshow .= ($val['delay'] > 0 ? ' ('.$langs->trans("NoticePeriod").': '.$val['delay'].' '.$langs->trans("days").')':'');
|
||||
$arraytypeleaves[$val['rowid']] = $labeltoshow;
|
||||
@ -545,14 +607,12 @@ if ($resql)
|
||||
}
|
||||
|
||||
// Duration
|
||||
if (!empty($arrayfields['duration']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['duration']['checked'])) {
|
||||
print '<td class="liste_titre"> </td>';
|
||||
}
|
||||
|
||||
// Start date
|
||||
if (!empty($arrayfields['cp.date_debut']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['cp.date_debut']['checked'])) {
|
||||
print '<td class="liste_titre center nowraponall">';
|
||||
print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month_start" value="'.dol_escape_htmltag($search_month_start).'">';
|
||||
$formother->select_year($search_year_start, 'search_year_start', 1, $min_year, $max_year);
|
||||
@ -560,8 +620,7 @@ if ($resql)
|
||||
}
|
||||
|
||||
// End date
|
||||
if (!empty($arrayfields['cp.date_fin']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['cp.date_fin']['checked'])) {
|
||||
print '<td class="liste_titre center nowraponall">';
|
||||
print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month_end" value="'.dol_escape_htmltag($search_month_end).'">';
|
||||
$formother->select_year($search_year_end, 'search_year_end', 1, $min_year, $max_year);
|
||||
@ -576,8 +635,7 @@ if ($resql)
|
||||
print $hookmanager->resPrint;
|
||||
|
||||
// Create date
|
||||
if (!empty($arrayfields['cp.date_create']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['cp.date_create']['checked'])) {
|
||||
print '<td class="liste_titre center nowraponall">';
|
||||
print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month_create" value="'.dol_escape_htmltag($search_month_create).'">';
|
||||
$formother->select_year($search_year_create, 'search_year_create', 1, $min_year, 0);
|
||||
@ -585,8 +643,7 @@ if ($resql)
|
||||
}
|
||||
|
||||
// Create date
|
||||
if (!empty($arrayfields['cp.tms']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['cp.tms']['checked'])) {
|
||||
print '<td class="liste_titre center nowraponall">';
|
||||
print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month_update" value="'.dol_escape_htmltag($search_month_update).'">';
|
||||
$formother->select_year($search_year_update, 'search_year_update', 1, $min_year, 0);
|
||||
@ -594,8 +651,7 @@ if ($resql)
|
||||
}
|
||||
|
||||
// Status
|
||||
if (!empty($arrayfields['cp.statut']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['cp.statut']['checked'])) {
|
||||
print '<td class="liste_titre maxwidthonsmartphone maxwidth200 right">';
|
||||
$object->selectStatutCP($search_status, 'search_status');
|
||||
print '</td>';
|
||||
@ -610,22 +666,42 @@ if ($resql)
|
||||
print "</tr>\n";
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
if (!empty($arrayfields['cp.ref']['checked'])) print_liste_field_titre($arrayfields['cp.ref']['label'], $_SERVER["PHP_SELF"], "cp.ref", "", $param, '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['cp.fk_user']['checked'])) print_liste_field_titre($arrayfields['cp.fk_user']['label'], $_SERVER["PHP_SELF"], "cp.fk_user", "", $param, '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['cp.fk_validator']['checked'])) print_liste_field_titre($arrayfields['cp.fk_validator']['label'], $_SERVER["PHP_SELF"], "cp.fk_validator", "", $param, '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['cp.fk_type']['checked'])) print_liste_field_titre($arrayfields['cp.fk_type']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['duration']['checked'])) print_liste_field_titre($arrayfields['duration']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right maxwidth100');
|
||||
if (!empty($arrayfields['cp.date_debut']['checked'])) print_liste_field_titre($arrayfields['cp.date_debut']['label'], $_SERVER["PHP_SELF"], "cp.date_debut", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
if (!empty($arrayfields['cp.date_fin']['checked'])) print_liste_field_titre($arrayfields['cp.date_fin']['label'], $_SERVER["PHP_SELF"], "cp.date_fin", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
if (!empty($arrayfields['cp.ref']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['cp.ref']['label'], $_SERVER["PHP_SELF"], "cp.ref", "", $param, '', $sortfield, $sortorder);
|
||||
}
|
||||
if (!empty($arrayfields['cp.fk_user']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['cp.fk_user']['label'], $_SERVER["PHP_SELF"], "cp.fk_user", "", $param, '', $sortfield, $sortorder);
|
||||
}
|
||||
if (!empty($arrayfields['cp.fk_validator']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['cp.fk_validator']['label'], $_SERVER["PHP_SELF"], "cp.fk_validator", "", $param, '', $sortfield, $sortorder);
|
||||
}
|
||||
if (!empty($arrayfields['cp.fk_type']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['cp.fk_type']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
|
||||
}
|
||||
if (!empty($arrayfields['duration']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['duration']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right maxwidth100');
|
||||
}
|
||||
if (!empty($arrayfields['cp.date_debut']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['cp.date_debut']['label'], $_SERVER["PHP_SELF"], "cp.date_debut", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
}
|
||||
if (!empty($arrayfields['cp.date_fin']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['cp.date_fin']['label'], $_SERVER["PHP_SELF"], "cp.date_fin", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
}
|
||||
// Extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
|
||||
// Hook fields
|
||||
$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
|
||||
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
if (!empty($arrayfields['cp.date_create']['checked'])) print_liste_field_titre($arrayfields['cp.date_create']['label'], $_SERVER["PHP_SELF"], "cp.date_create", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
if (!empty($arrayfields['cp.tms']['checked'])) print_liste_field_titre($arrayfields['cp.tms']['label'], $_SERVER["PHP_SELF"], "cp.tms", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
if (!empty($arrayfields['cp.statut']['checked'])) print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "cp.statut", "", $param, '', $sortfield, $sortorder, 'right ');
|
||||
if (!empty($arrayfields['cp.date_create']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['cp.date_create']['label'], $_SERVER["PHP_SELF"], "cp.date_create", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
}
|
||||
if (!empty($arrayfields['cp.tms']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['cp.tms']['label'], $_SERVER["PHP_SELF"], "cp.tms", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
}
|
||||
if (!empty($arrayfields['cp.statut']['checked'])) {
|
||||
print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "cp.statut", "", $param, '', $sortfield, $sortorder, 'right ');
|
||||
}
|
||||
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
|
||||
print "</tr>\n";
|
||||
|
||||
@ -637,8 +713,7 @@ if ($resql)
|
||||
$langs->load("errors");
|
||||
print '<tr class="oddeven opacitymediuem"><td colspan="10">'.$langs->trans("NotEnoughPermissions").'</td></tr>';
|
||||
$result = 0;
|
||||
} elseif ($num > 0 && !empty($mysoc->country_id))
|
||||
{
|
||||
} elseif ($num > 0 && !empty($mysoc->country_id)) {
|
||||
// Lines
|
||||
$userstatic = new User($db);
|
||||
$approbatorstatic = new User($db);
|
||||
@ -647,8 +722,7 @@ if ($resql)
|
||||
|
||||
$i = 0;
|
||||
$totalarray = array();
|
||||
while ($i < min($num, $limit))
|
||||
{
|
||||
while ($i < min($num, $limit)) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
// Leave request
|
||||
@ -684,54 +758,61 @@ if ($resql)
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
if (!empty($arrayfields['cp.ref']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['cp.ref']['checked'])) {
|
||||
print '<td class="nowraponall">';
|
||||
print $holidaystatic->getNomUrl(1, 1);
|
||||
print '</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
if (!empty($arrayfields['cp.fk_user']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['cp.fk_user']['checked'])) {
|
||||
print '<td class="tdoverflowmax150">'.$userstatic->getNomUrl(-1, 'leave').'</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
if (!empty($arrayfields['cp.fk_validator']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['cp.fk_validator']['checked'])) {
|
||||
print '<td class="tdoverflowmax150">'.$approbatorstatic->getNomUrl(-1).'</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
if (!empty($arrayfields['cp.fk_type']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['cp.fk_type']['checked'])) {
|
||||
print '<td>';
|
||||
$labeltypeleavetoshow = ($langs->trans($typeleaves[$obj->fk_type]['code']) != $typeleaves[$obj->fk_type]['code'] ? $langs->trans($typeleaves[$obj->fk_type]['code']) : $typeleaves[$obj->fk_type]['label']);
|
||||
print empty($typeleaves[$obj->fk_type]['label']) ? $langs->trans("TypeWasDisabledOrRemoved", $obj->fk_type) : $labeltypeleavetoshow;
|
||||
print '</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
if (!empty($arrayfields['duration']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['duration']['checked'])) {
|
||||
print '<td class="right">';
|
||||
$nbopenedday = num_open_day($db->jdate($obj->date_debut, 1), $db->jdate($obj->date_fin, 1), 0, 1, $obj->halfday);
|
||||
print $nbopenedday.' '.$langs->trans('DurationDays');
|
||||
print '</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
if (!empty($arrayfields['cp.date_debut']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['cp.date_debut']['checked'])) {
|
||||
print '<td class="center">';
|
||||
print dol_print_date($db->jdate($obj->date_debut), 'day');
|
||||
print ' <span class="opacitymedium nowraponall">('.$langs->trans($listhalfday[$starthalfday]).')</span>';
|
||||
print '</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
if (!empty($arrayfields['cp.date_fin']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['cp.date_fin']['checked'])) {
|
||||
print '<td class="center">';
|
||||
print dol_print_date($db->jdate($obj->date_fin), 'day');
|
||||
print ' <span class="opacitymedium nowraponall">('.$langs->trans($listhalfday[$endhalfday]).')</span>';
|
||||
print '</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
|
||||
// Extra fields
|
||||
@ -742,32 +823,38 @@ if ($resql)
|
||||
print $hookmanager->resPrint;
|
||||
|
||||
// Date creation
|
||||
if (!empty($arrayfields['cp.date_create']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['cp.date_create']['checked'])) {
|
||||
print '<td style="text-align: center;">'.dol_print_date($date, 'dayhour').'</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
if (!empty($arrayfields['cp.tms']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['cp.tms']['checked'])) {
|
||||
print '<td style="text-align: center;">'.dol_print_date($date_modif, 'dayhour').'</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
if (!empty($arrayfields['cp.statut']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['cp.statut']['checked'])) {
|
||||
print '<td class="right nowrap">'.$holidaystatic->getLibStatut(5).'</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
|
||||
// Action column
|
||||
print '<td class="nowrap center">';
|
||||
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
|
||||
{
|
||||
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
|
||||
$selected = 0;
|
||||
if (in_array($obj->rowid, $arrayofselected)) $selected = 1;
|
||||
if (in_array($obj->rowid, $arrayofselected)) {
|
||||
$selected = 1;
|
||||
}
|
||||
print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
|
||||
}
|
||||
print '</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
print '</tr>'."\n";
|
||||
|
||||
@ -776,10 +863,13 @@ if ($resql)
|
||||
}
|
||||
|
||||
// Si il n'y a pas d'enregistrement suite à une recherche
|
||||
if ($num == 0)
|
||||
{
|
||||
if ($num == 0) {
|
||||
$colspan = 1;
|
||||
foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; }
|
||||
foreach ($arrayfields as $key => $val) {
|
||||
if (!empty($val['checked'])) {
|
||||
$colspan++;
|
||||
}
|
||||
}
|
||||
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
|
||||
}
|
||||
|
||||
@ -815,8 +905,7 @@ function showMyBalance($holiday, $user_id)
|
||||
$out = '';
|
||||
$nb_holiday = 0;
|
||||
$typeleaves = $holiday->getTypes(1, 1);
|
||||
foreach ($typeleaves as $key => $val)
|
||||
{
|
||||
foreach ($typeleaves as $key => $val) {
|
||||
$nb_type = $holiday->getCPforUser($user_id, $val['rowid']);
|
||||
$nb_holiday += $nb_type;
|
||||
$out .= ' - '.$val['label'].': <strong>'.($nb_type ?price2num($nb_type) : 0).'</strong><br>';
|
||||
|
||||
@ -36,8 +36,7 @@ $langs->loadLangs(array("holiday"));
|
||||
|
||||
// Security check
|
||||
$socid = 0;
|
||||
if ($user->socid > 0) // Protection if external user
|
||||
{
|
||||
if ($user->socid > 0) { // Protection if external user
|
||||
//$socid = $user->socid;
|
||||
accessforbidden();
|
||||
}
|
||||
@ -57,8 +56,12 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_
|
||||
$sortfield = GETPOST('sortfield', 'aZ09comma');
|
||||
$sortorder = GETPOST('sortorder', 'alpha');
|
||||
|
||||
if (!$sortfield) $sortfield = "cp.rowid";
|
||||
if (!$sortorder) $sortorder = "ASC";
|
||||
if (!$sortfield) {
|
||||
$sortfield = "cp.rowid";
|
||||
}
|
||||
if (!$sortorder) {
|
||||
$sortorder = "ASC";
|
||||
}
|
||||
|
||||
$hookmanager->initHooks(array('leavemovementlist'));
|
||||
|
||||
@ -69,21 +72,25 @@ $arrayofmassactions = array();
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
|
||||
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
|
||||
if (GETPOST('cancel', 'alpha')) {
|
||||
$action = 'list'; $massaction = '';
|
||||
}
|
||||
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
|
||||
$massaction = '';
|
||||
}
|
||||
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
if (empty($reshook)) {
|
||||
// Selection of new fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
|
||||
|
||||
// Purge search criteria
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
|
||||
{
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
|
||||
$search_ref = '';
|
||||
$search_employee = '';
|
||||
$search_type = '';
|
||||
@ -97,8 +104,7 @@ if (empty($reshook))
|
||||
|| GETPOST('button_removefilter', 'alpha')
|
||||
|| GETPOST('button_search_x', 'alpha')
|
||||
|| GETPOST('button_search.x', 'alpha')
|
||||
|| GETPOST('button_search', 'alpha'))
|
||||
{
|
||||
|| GETPOST('button_search', 'alpha')) {
|
||||
$massaction = '';
|
||||
}
|
||||
}
|
||||
@ -141,16 +147,23 @@ $sql .= " WHERE cp.rowid > 0";
|
||||
$sql .= " AND cp.statut = 3"; // 3 = Approved
|
||||
$sql .= " AND (date_format(cp.date_debut, '%Y-%m') = '".$db->escape($year_month)."' OR date_format(cp.date_fin, '%Y-%m') = '".$db->escape($year_month)."')";
|
||||
|
||||
if (!empty($search_ref)) $sql .= natural_search('cp.ref', $search_ref);
|
||||
if (!empty($search_employee)) $sql .= " AND cp.fk_user = '".$db->escape($search_employee)."'";
|
||||
if (!empty($search_type)) $sql .= ' AND cp.fk_type IN ('.$db->escape($search_type).')';
|
||||
if (!empty($search_description)) $sql .= natural_search('cp.description', $search_description);
|
||||
if (!empty($search_ref)) {
|
||||
$sql .= natural_search('cp.ref', $search_ref);
|
||||
}
|
||||
if (!empty($search_employee)) {
|
||||
$sql .= " AND cp.fk_user = '".$db->escape($search_employee)."'";
|
||||
}
|
||||
if (!empty($search_type)) {
|
||||
$sql .= ' AND cp.fk_type IN ('.$db->escape($search_type).')';
|
||||
}
|
||||
if (!empty($search_description)) {
|
||||
$sql .= natural_search('cp.description', $search_description);
|
||||
}
|
||||
|
||||
$sql .= $db->order($sortfield, $sortorder);
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if (empty($resql))
|
||||
{
|
||||
if (empty($resql)) {
|
||||
dol_print_error($db);
|
||||
exit;
|
||||
}
|
||||
@ -158,15 +171,29 @@ if (empty($resql))
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
$param = '';
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
|
||||
if (!empty($search_ref)) $param .= '&search_ref='.urlencode($search_ref);
|
||||
if (!empty($search_employee)) $param .= '&search_employee='.urlencode($search_employee);
|
||||
if (!empty($search_type)) $param .= '&search_type='.urlencode($search_type);
|
||||
if (!empty($search_description)) $param .= '&search_description='.urlencode($search_description);
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
|
||||
$param .= '&contextpage='.urlencode($contextpage);
|
||||
}
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) {
|
||||
$param .= '&limit='.urlencode($limit);
|
||||
}
|
||||
if (!empty($search_ref)) {
|
||||
$param .= '&search_ref='.urlencode($search_ref);
|
||||
}
|
||||
if (!empty($search_employee)) {
|
||||
$param .= '&search_employee='.urlencode($search_employee);
|
||||
}
|
||||
if (!empty($search_type)) {
|
||||
$param .= '&search_type='.urlencode($search_type);
|
||||
}
|
||||
if (!empty($search_description)) {
|
||||
$param .= '&search_description='.urlencode($search_description);
|
||||
}
|
||||
|
||||
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
if ($optioncss != '') {
|
||||
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
}
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
||||
print '<input type="hidden" name="action" value="list">';
|
||||
@ -215,8 +242,7 @@ if (!empty($arrayfields['cp.fk_user']['checked'])) {
|
||||
if (!empty($arrayfields['ct.label']['checked'])) {
|
||||
$typeleaves = $holidaystatic->getTypes(1, -1);
|
||||
$arraytypeleaves = array();
|
||||
foreach ($typeleaves as $key => $val)
|
||||
{
|
||||
foreach ($typeleaves as $key => $val) {
|
||||
$labeltoshow = ($langs->trans($val['code']) != $val['code'] ? $langs->trans($val['code']) : $val['label']);
|
||||
$arraytypeleaves[$val['rowid']] = $labeltoshow;
|
||||
}
|
||||
@ -226,12 +252,24 @@ if (!empty($arrayfields['ct.label']['checked'])) {
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
if (!empty($arrayfields['cp.date_debut']['checked'])) print '<td class="liste_titre"></td>';
|
||||
if (!empty($arrayfields['cp.date_fin']['checked'])) print '<td class="liste_titre"></td>';
|
||||
if (!empty($arrayfields['used_days']['checked'])) print '<td class="liste_titre"></td>';
|
||||
if (!empty($arrayfields['date_start_month']['checked'])) print '<td class="liste_titre"></td>';
|
||||
if (!empty($arrayfields['date_end_month']['checked'])) print '<td class="liste_titre"></td>';
|
||||
if (!empty($arrayfields['used_days_month']['checked'])) print '<td class="liste_titre"></td>';
|
||||
if (!empty($arrayfields['cp.date_debut']['checked'])) {
|
||||
print '<td class="liste_titre"></td>';
|
||||
}
|
||||
if (!empty($arrayfields['cp.date_fin']['checked'])) {
|
||||
print '<td class="liste_titre"></td>';
|
||||
}
|
||||
if (!empty($arrayfields['used_days']['checked'])) {
|
||||
print '<td class="liste_titre"></td>';
|
||||
}
|
||||
if (!empty($arrayfields['date_start_month']['checked'])) {
|
||||
print '<td class="liste_titre"></td>';
|
||||
}
|
||||
if (!empty($arrayfields['date_end_month']['checked'])) {
|
||||
print '<td class="liste_titre"></td>';
|
||||
}
|
||||
if (!empty($arrayfields['used_days_month']['checked'])) {
|
||||
print '<td class="liste_titre"></td>';
|
||||
}
|
||||
|
||||
// Filter: Description
|
||||
if (!empty($arrayfields['cp.description']['checked'])) {
|
||||
@ -248,26 +286,43 @@ print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
if (!empty($arrayfields['cp.ref']['checked'])) print_liste_field_titre($arrayfields['cp.ref']['label'], $_SERVER["PHP_SELF"], 'cp.ref', '', '', '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['cp.fk_user']['checked'])) print_liste_field_titre($arrayfields['cp.fk_user']['label'], $_SERVER["PHP_SELF"], 'cp.fk_user', '', '', '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['ct.label']['checked'])) print_liste_field_titre($arrayfields['ct.label']['label'], $_SERVER["PHP_SELF"], 'ct.label', '', '', '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['cp.date_debut']['checked'])) print_liste_field_titre($arrayfields['cp.date_debut']['label'], $_SERVER["PHP_SELF"], 'cp.date_debut', '', '', '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['cp.date_fin']['checked'])) print_liste_field_titre($arrayfields['cp.date_fin']['label'], $_SERVER["PHP_SELF"], 'cp.date_fin', '', '', '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['used_days']['checked'])) print_liste_field_titre($arrayfields['used_days']['label'], $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['date_start_month']['checked'])) print_liste_field_titre($arrayfields['date_start_month']['label'], $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['date_end_month']['checked'])) print_liste_field_titre($arrayfields['date_end_month']['label'], $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['used_days_month']['checked'])) print_liste_field_titre($arrayfields['used_days_month']['label'], $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['cp.description']['checked'])) print_liste_field_titre($arrayfields['cp.description']['label'], $_SERVER["PHP_SELF"], 'cp.description', '', '', '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['cp.ref']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['cp.ref']['label'], $_SERVER["PHP_SELF"], 'cp.ref', '', '', '', $sortfield, $sortorder);
|
||||
}
|
||||
if (!empty($arrayfields['cp.fk_user']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['cp.fk_user']['label'], $_SERVER["PHP_SELF"], 'cp.fk_user', '', '', '', $sortfield, $sortorder);
|
||||
}
|
||||
if (!empty($arrayfields['ct.label']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['ct.label']['label'], $_SERVER["PHP_SELF"], 'ct.label', '', '', '', $sortfield, $sortorder);
|
||||
}
|
||||
if (!empty($arrayfields['cp.date_debut']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['cp.date_debut']['label'], $_SERVER["PHP_SELF"], 'cp.date_debut', '', '', '', $sortfield, $sortorder);
|
||||
}
|
||||
if (!empty($arrayfields['cp.date_fin']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['cp.date_fin']['label'], $_SERVER["PHP_SELF"], 'cp.date_fin', '', '', '', $sortfield, $sortorder);
|
||||
}
|
||||
if (!empty($arrayfields['used_days']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['used_days']['label'], $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder);
|
||||
}
|
||||
if (!empty($arrayfields['date_start_month']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['date_start_month']['label'], $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder);
|
||||
}
|
||||
if (!empty($arrayfields['date_end_month']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['date_end_month']['label'], $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder);
|
||||
}
|
||||
if (!empty($arrayfields['used_days_month']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['used_days_month']['label'], $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder);
|
||||
}
|
||||
if (!empty($arrayfields['cp.description']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['cp.description']['label'], $_SERVER["PHP_SELF"], 'cp.description', '', '', '', $sortfield, $sortorder);
|
||||
}
|
||||
print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
|
||||
print '</tr>';
|
||||
|
||||
if ($num == 0)
|
||||
{
|
||||
if ($num == 0) {
|
||||
print '<tr><td colspan="10" class="opacitymedium">'.$langs->trans('None').'</td></tr>';
|
||||
}
|
||||
else {
|
||||
while ($obj = $db->fetch_object($resql))
|
||||
{
|
||||
} else {
|
||||
while ($obj = $db->fetch_object($resql)) {
|
||||
$user = new User($db);
|
||||
$user->fetch($obj->fk_user);
|
||||
|
||||
@ -289,19 +344,25 @@ else {
|
||||
// Set date_start_gmt and date_end_gmt that are date to show for the selected month
|
||||
$date_start_inmonth = $db->jdate($obj->date_debut, true);
|
||||
$date_end_inmonth = $db->jdate($obj->date_fin, true);
|
||||
if ($tmpstart['year'] < $search_year || $tmpstart['mon'] < $search_month)
|
||||
{
|
||||
if ($tmpstart['year'] < $search_year || $tmpstart['mon'] < $search_month) {
|
||||
$date_start_inmonth = dol_get_first_day($search_year, $search_month, true);
|
||||
$starthalfdayinmonth = 'morning';
|
||||
if ($halfdayinmonth == 2) $halfdayinmonth = 1;
|
||||
if ($halfdayinmonth == -1) $halfdayinmonth = 0;
|
||||
if ($halfdayinmonth == 2) {
|
||||
$halfdayinmonth = 1;
|
||||
}
|
||||
if ($halfdayinmonth == -1) {
|
||||
$halfdayinmonth = 0;
|
||||
}
|
||||
}
|
||||
if ($tmpend['year'] > $search_year || $tmpend['mon'] > $search_month)
|
||||
{
|
||||
if ($tmpend['year'] > $search_year || $tmpend['mon'] > $search_month) {
|
||||
$date_end_inmonth = dol_get_last_day($search_year, $search_month, true) - ((24 * 3600) - 1);
|
||||
$endhalfdayinmonth = 'afternoon';
|
||||
if ($halfdayinmonth == 2) $halfdayinmonth = -1;
|
||||
if ($halfdayinmonth == 1) $halfdayinmonth = 0;
|
||||
if ($halfdayinmonth == 2) {
|
||||
$halfdayinmonth = -1;
|
||||
}
|
||||
if ($halfdayinmonth == 1) {
|
||||
$halfdayinmonth = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Leave request
|
||||
@ -310,42 +371,50 @@ else {
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
if (!empty($arrayfields['cp.ref']['checked'])) print '<td>'.$holidaystatic->getNomUrl(1, 1).'</td>';
|
||||
if (!empty($arrayfields['cp.fk_user']['checked'])) print '<td>'.$user->getFullName($langs).'</td>';
|
||||
if (!empty($arrayfields['ct.label']['checked'])) print '<td>'.$obj->label.'</td>';
|
||||
if (!empty($arrayfields['cp.ref']['checked'])) {
|
||||
print '<td>'.$holidaystatic->getNomUrl(1, 1).'</td>';
|
||||
}
|
||||
if (!empty($arrayfields['cp.fk_user']['checked'])) {
|
||||
print '<td>'.$user->getFullName($langs).'</td>';
|
||||
}
|
||||
if (!empty($arrayfields['ct.label']['checked'])) {
|
||||
print '<td>'.$obj->label.'</td>';
|
||||
}
|
||||
|
||||
if (!empty($arrayfields['cp.date_debut']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['cp.date_debut']['checked'])) {
|
||||
print '<td class="center">'.dol_print_date($db->jdate($obj->date_debut), 'day');
|
||||
print ' <span class="opacitymedium">('.$langs->trans($listhalfday[$starthalfday]).')</span>';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
if (!empty($arrayfields['cp.date_fin']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['cp.date_fin']['checked'])) {
|
||||
print '<td class="center">'.dol_print_date($db->jdate($obj->date_fin), 'day');
|
||||
print ' <span class="opacitymedium">('.$langs->trans($listhalfday[$endhalfday]).')</span>';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
if (!empty($arrayfields['used_days']['checked'])) print '<td class="right">'.num_open_day($date_start, $date_end, 0, 1, $obj->halfday).'</td>';
|
||||
if (!empty($arrayfields['used_days']['checked'])) {
|
||||
print '<td class="right">'.num_open_day($date_start, $date_end, 0, 1, $obj->halfday).'</td>';
|
||||
}
|
||||
|
||||
if (!empty($arrayfields['date_start_month']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['date_start_month']['checked'])) {
|
||||
print '<td class="center">'.dol_print_date($date_start_inmonth, 'day');
|
||||
print ' <span class="opacitymedium">('.$langs->trans($listhalfday[$starthalfdayinmonth]).')</span>';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
if (!empty($arrayfields['date_end_month']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['date_end_month']['checked'])) {
|
||||
print '<td class="center">'.dol_print_date($date_end_inmonth, 'day');
|
||||
print ' <span class="opacitymedium">('.$langs->trans($listhalfday[$endhalfdayinmonth]).')</span>';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
if (!empty($arrayfields['used_days_month']['checked'])) print '<td class="right">'.num_open_day($date_start_inmonth, $date_end_inmonth, 0, 1, $halfdayinmonth).'</td>';
|
||||
if (!empty($arrayfields['cp.description']['checked'])) print '<td class="maxwidth300">'.dol_escape_htmltag(dolGetFirstLineOfText($obj->description)).'</td>';
|
||||
if (!empty($arrayfields['used_days_month']['checked'])) {
|
||||
print '<td class="right">'.num_open_day($date_start_inmonth, $date_end_inmonth, 0, 1, $halfdayinmonth).'</td>';
|
||||
}
|
||||
if (!empty($arrayfields['cp.description']['checked'])) {
|
||||
print '<td class="maxwidth300">'.dol_escape_htmltag(dolGetFirstLineOfText($obj->description)).'</td>';
|
||||
}
|
||||
|
||||
print '<td></td>';
|
||||
print '</tr>';
|
||||
|
||||
@ -61,15 +61,23 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
|
||||
$sortfield = GETPOST('sortfield', 'aZ09comma');
|
||||
$sortorder = GETPOST('sortorder', 'aZ09comma');
|
||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
|
||||
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
|
||||
$page = 0;
|
||||
} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
|
||||
$offset = $limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if (!$sortfield) $sortfield = "cpl.rowid";
|
||||
if (!$sortorder) $sortorder = "DESC";
|
||||
if (!$sortfield) {
|
||||
$sortfield = "cpl.rowid";
|
||||
}
|
||||
if (!$sortorder) {
|
||||
$sortorder = "DESC";
|
||||
}
|
||||
|
||||
// Si l'utilisateur n'a pas le droit de lire cette page
|
||||
if (!$user->rights->holiday->readall) accessforbidden();
|
||||
if (!$user->rights->holiday->readall) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('users', 'other', 'holiday'));
|
||||
@ -83,8 +91,7 @@ $hookmanager->initHooks(array('leavemovementlist')); // Note that conf->hooks_mo
|
||||
$arrayfields = array();
|
||||
$arrayofmassactions = array();
|
||||
|
||||
if (empty($conf->holiday->enabled))
|
||||
{
|
||||
if (empty($conf->holiday->enabled)) {
|
||||
llxHeader('', $langs->trans('CPTitreMenu'));
|
||||
print '<div class="tabBar">';
|
||||
print '<span style="color: #FF0000;">'.$langs->trans('NotActiveModCP').'</span>';
|
||||
@ -98,12 +105,18 @@ if (empty($conf->holiday->enabled))
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
|
||||
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
|
||||
if (GETPOST('cancel', 'alpha')) {
|
||||
$action = 'list'; $massaction = '';
|
||||
}
|
||||
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
|
||||
$massaction = '';
|
||||
}
|
||||
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
if (empty($reshook)) {
|
||||
// Selection of new fields
|
||||
@ -129,8 +142,7 @@ if (empty($reshook)) {
|
||||
|| GETPOST('button_removefilter', 'alpha')
|
||||
|| GETPOST('button_search_x', 'alpha')
|
||||
|| GETPOST('button_search.x', 'alpha')
|
||||
|| GETPOST('button_search', 'alpha'))
|
||||
{
|
||||
|| GETPOST('button_search', 'alpha')) {
|
||||
$massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
|
||||
}
|
||||
|
||||
@ -184,13 +196,27 @@ if (!empty($search_year) && $search_year > 0) {
|
||||
$sqlwhere .= "AND date_action BETWEEN '".$db->idate($from_date)."' AND '".$db->idate($to_date)."'";
|
||||
}
|
||||
|
||||
if (!empty($search_id) && $search_id > 0) $sqlwhere .= natural_search('rowid', $search_id, 1);
|
||||
if (!empty($search_validator) && $search_validator > 0) $sqlwhere .= natural_search('fk_user_action', $search_validator, 1);
|
||||
if (!empty($search_employee) && $search_employee > 0) $sqlwhere .= natural_search('fk_user_update', $search_employee, 1);
|
||||
if (!empty($search_description)) $sqlwhere .= natural_search('type_action', $search_description);
|
||||
if (!empty($search_type) && $search_type > 0) $sqlwhere .= natural_search('fk_type', $search_type, 1);
|
||||
if (!empty($search_prev_solde)) $sqlwhere .= natural_search('prev_solde', $search_prev_solde, 1);
|
||||
if (!empty($search_new_solde)) $sqlwhere .= natural_search('new_solde', $search_new_solde, 1);
|
||||
if (!empty($search_id) && $search_id > 0) {
|
||||
$sqlwhere .= natural_search('rowid', $search_id, 1);
|
||||
}
|
||||
if (!empty($search_validator) && $search_validator > 0) {
|
||||
$sqlwhere .= natural_search('fk_user_action', $search_validator, 1);
|
||||
}
|
||||
if (!empty($search_employee) && $search_employee > 0) {
|
||||
$sqlwhere .= natural_search('fk_user_update', $search_employee, 1);
|
||||
}
|
||||
if (!empty($search_description)) {
|
||||
$sqlwhere .= natural_search('type_action', $search_description);
|
||||
}
|
||||
if (!empty($search_type) && $search_type > 0) {
|
||||
$sqlwhere .= natural_search('fk_type', $search_type, 1);
|
||||
}
|
||||
if (!empty($search_prev_solde)) {
|
||||
$sqlwhere .= natural_search('prev_solde', $search_prev_solde, 1);
|
||||
}
|
||||
if (!empty($search_new_solde)) {
|
||||
$sqlwhere .= natural_search('new_solde', $search_new_solde, 1);
|
||||
}
|
||||
|
||||
$sqlorder = $db->order($sortfield, $sortorder);
|
||||
|
||||
@ -214,20 +240,44 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
||||
$num = is_array($object->logs) ? count($object->logs) : 0;
|
||||
|
||||
$param = '';
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
|
||||
if (!empty($search_id)) $param .= '&search_statut='.urlencode($search_statut);
|
||||
if (!empty($search_month) && $search_month > 0) $param .= '&search_month='.urlencode($search_month);
|
||||
if (!empty($search_year) && $search_year > 0) $param .= '&search_year='.urlencode($search_year);
|
||||
if (!empty($search_validator) && $search_validator > 0) $param .= '&search_validator='.urlencode($search_validator);
|
||||
if (!empty($search_employee) && $search_employee > 0) $param .= '&search_employee='.urlencode($search_employee);
|
||||
if (!empty($search_description)) $param .= '&search_description='.urlencode($search_description);
|
||||
if (!empty($search_type) && $search_type > 0) $param .= '&search_type='.urlencode($search_type);
|
||||
if (!empty($search_prev_solde)) $param .= '&search_prev_solde='.urlencode($search_prev_solde);
|
||||
if (!empty($search_new_solde)) $param .= '&search_new_solde='.urlencode($search_new_solde);
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
|
||||
$param .= '&contextpage='.urlencode($contextpage);
|
||||
}
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) {
|
||||
$param .= '&limit='.urlencode($limit);
|
||||
}
|
||||
if (!empty($search_id)) {
|
||||
$param .= '&search_statut='.urlencode($search_statut);
|
||||
}
|
||||
if (!empty($search_month) && $search_month > 0) {
|
||||
$param .= '&search_month='.urlencode($search_month);
|
||||
}
|
||||
if (!empty($search_year) && $search_year > 0) {
|
||||
$param .= '&search_year='.urlencode($search_year);
|
||||
}
|
||||
if (!empty($search_validator) && $search_validator > 0) {
|
||||
$param .= '&search_validator='.urlencode($search_validator);
|
||||
}
|
||||
if (!empty($search_employee) && $search_employee > 0) {
|
||||
$param .= '&search_employee='.urlencode($search_employee);
|
||||
}
|
||||
if (!empty($search_description)) {
|
||||
$param .= '&search_description='.urlencode($search_description);
|
||||
}
|
||||
if (!empty($search_type) && $search_type > 0) {
|
||||
$param .= '&search_type='.urlencode($search_type);
|
||||
}
|
||||
if (!empty($search_prev_solde)) {
|
||||
$param .= '&search_prev_solde='.urlencode($search_prev_solde);
|
||||
}
|
||||
if (!empty($search_new_solde)) {
|
||||
$param .= '&search_new_solde='.urlencode($search_new_solde);
|
||||
}
|
||||
|
||||
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
if ($optioncss != '') {
|
||||
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
}
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
||||
print '<input type="hidden" name="action" value="list">';
|
||||
@ -348,23 +398,40 @@ print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
if (!empty($arrayfields['cpl.rowid']['checked'])) print_liste_field_titre($arrayfields['cpl.rowid']['label'], $_SERVER["PHP_SELF"], 'rowid', '', '', '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['cpl.date_action']['checked'])) print_liste_field_titre($arrayfields['cpl.date_action']['label'], $_SERVER["PHP_SELF"], 'date_action', '', '', '', $sortfield, $sortorder, 'center ');
|
||||
if (!empty($arrayfields['cpl.fk_user_action']['checked'])) print_liste_field_titre($arrayfields['cpl.fk_user_action']['label'], $_SERVER["PHP_SELF"], 'fk_user_action', '', '', '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['cpl.fk_user_update']['checked'])) print_liste_field_titre($arrayfields['cpl.fk_user_update']['label'], $_SERVER["PHP_SELF"], 'fk_user_update', '', '', '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['cpl.type_action']['checked'])) print_liste_field_titre($arrayfields['cpl.type_action']['label'], $_SERVER["PHP_SELF"], 'type_action', '', '', '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['cpl.fk_type']['checked'])) print_liste_field_titre($arrayfields['cpl.fk_type']['label'], $_SERVER["PHP_SELF"], 'fk_type', '', '', '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['cpl.prev_solde']['checked'])) print_liste_field_titre($arrayfields['cpl.prev_solde']['label'], $_SERVER["PHP_SELF"], 'prev_solde', '', '', '', $sortfield, $sortorder, 'right ');
|
||||
if (!empty($arrayfields['variation']['checked'])) print_liste_field_titre($arrayfields['variation']['label'], $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'right ');
|
||||
if (!empty($arrayfields['cpl.new_solde']['checked'])) print_liste_field_titre($arrayfields['cpl.new_solde']['label'], $_SERVER["PHP_SELF"], 'new_solde', '', '', '', $sortfield, $sortorder, 'right ');
|
||||
if (!empty($arrayfields['cpl.rowid']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['cpl.rowid']['label'], $_SERVER["PHP_SELF"], 'rowid', '', '', '', $sortfield, $sortorder);
|
||||
}
|
||||
if (!empty($arrayfields['cpl.date_action']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['cpl.date_action']['label'], $_SERVER["PHP_SELF"], 'date_action', '', '', '', $sortfield, $sortorder, 'center ');
|
||||
}
|
||||
if (!empty($arrayfields['cpl.fk_user_action']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['cpl.fk_user_action']['label'], $_SERVER["PHP_SELF"], 'fk_user_action', '', '', '', $sortfield, $sortorder);
|
||||
}
|
||||
if (!empty($arrayfields['cpl.fk_user_update']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['cpl.fk_user_update']['label'], $_SERVER["PHP_SELF"], 'fk_user_update', '', '', '', $sortfield, $sortorder);
|
||||
}
|
||||
if (!empty($arrayfields['cpl.type_action']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['cpl.type_action']['label'], $_SERVER["PHP_SELF"], 'type_action', '', '', '', $sortfield, $sortorder);
|
||||
}
|
||||
if (!empty($arrayfields['cpl.fk_type']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['cpl.fk_type']['label'], $_SERVER["PHP_SELF"], 'fk_type', '', '', '', $sortfield, $sortorder);
|
||||
}
|
||||
if (!empty($arrayfields['cpl.prev_solde']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['cpl.prev_solde']['label'], $_SERVER["PHP_SELF"], 'prev_solde', '', '', '', $sortfield, $sortorder, 'right ');
|
||||
}
|
||||
if (!empty($arrayfields['variation']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['variation']['label'], $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'right ');
|
||||
}
|
||||
if (!empty($arrayfields['cpl.new_solde']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['cpl.new_solde']['label'], $_SERVER["PHP_SELF"], 'new_solde', '', '', '', $sortfield, $sortorder, 'right ');
|
||||
}
|
||||
print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
|
||||
print '</tr>';
|
||||
|
||||
// TODO: $i = 0;
|
||||
$i = 1;
|
||||
|
||||
while ($i < min($num, $limit))
|
||||
{
|
||||
while ($i < min($num, $limit)) {
|
||||
//TODO: $obj = $db->fetch_object($resql);
|
||||
$obj = next($object->logs);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user