Merge github.com:Dolibarr/dolibarr into develop

This commit is contained in:
Florian HENRY 2020-10-12 09:43:01 +02:00
commit 371edd3052
18 changed files with 405 additions and 204 deletions

BIN
doc/images/invoice.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

View File

@ -65,6 +65,7 @@ if ($action == 'delete')
$action = ''; $action = '';
} }
/* /*
* View * View
*/ */
@ -119,7 +120,9 @@ if (in_array($type, array('pgsql'))) {
print "});\n"; print "});\n";
print "</script>\n"; print "</script>\n";
print load_fiche_titre($langs->trans("Backup"), '', 'title_setup'); $title = $langs->trans("Backup");
print load_fiche_titre($title, '', 'title_setup');
//print_barre_liste($langs->trans("Backup"), '', '', '', '', '', $langs->trans("BackupDesc",DOL_DATA_ROOT), 0, 0, 'title_setup'); //print_barre_liste($langs->trans("Backup"), '', '', '', '', '', $langs->trans("BackupDesc",DOL_DATA_ROOT), 0, 0, 'title_setup');
print '<div class="center opacitymedium">'; print '<div class="center opacitymedium">';
@ -139,7 +142,9 @@ print '<br>';
print '<div id="backupdatabaseleft" class="fichehalfleft" >'; print '<div id="backupdatabaseleft" class="fichehalfleft" >';
print load_fiche_titre($title ? $title : $langs->trans("BackupDumpWizard")); $title = $langs->trans("BackupDumpWizard");
print load_fiche_titre($title);
print '<table width="100%" class="'.($useinecm ? 'nobordernopadding' : 'liste').' nohover">'; print '<table width="100%" class="'.($useinecm ? 'nobordernopadding' : 'liste').' nohover">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';

View File

@ -122,7 +122,7 @@ $utils = new Utils($db);
// MYSQL // MYSQL
if ($what == 'mysql') if ($what == 'mysql')
{ {
$cmddump = GETPOST("mysqldump"); // Do not sanitize here with 'alpha', will be sanitize later by dol_sanitizePathName and escapeshellarg $cmddump = GETPOST("mysqldump", 'none'); // Do not sanitize here with 'alpha', will be sanitize later by dol_sanitizePathName and escapeshellarg
$cmddump = dol_sanitizePathName($cmddump); $cmddump = dol_sanitizePathName($cmddump);
if (!empty($dolibarr_main_restrict_os_commands)) if (!empty($dolibarr_main_restrict_os_commands))
@ -163,7 +163,7 @@ if ($what == 'mysqlnobin')
// POSTGRESQL // POSTGRESQL
if ($what == 'postgresql') if ($what == 'postgresql')
{ {
$cmddump = GETPOST("postgresqldump"); // Do not sanitize here with 'alpha', will be sanitize later by dol_sanitizePathName and escapeshellarg $cmddump = GETPOST("postgresqldump", 'none'); // Do not sanitize here with 'alpha', will be sanitize later by dol_sanitizePathName and escapeshellarg
$cmddump = dol_sanitizePathName($cmddump); $cmddump = dol_sanitizePathName($cmddump);
/* Not required, the command is output on screen but not ran for pgsql /* Not required, the command is output on screen but not ran for pgsql

View File

@ -113,7 +113,7 @@ $utils = new Utils($db);
if ($compression == 'zip') if ($compression == 'zip')
{ {
$file .= '.zip'; $file .= '.zip';
$ret = dol_compress_dir(DOL_DATA_ROOT, $outputdir."/".$file, $compression, '/(\.log|\/temp\/|documents\/admin\/documents\/)/'); $ret = dol_compress_dir(DOL_DATA_ROOT, $outputdir."/".$file, $compression, '/(\.back|\.old|\.log|[\\\/]temp[\\\/]|documents[\\\/]admin[\\\/]documents[\\\/])/i');
if ($ret < 0) if ($ret < 0)
{ {
if ($ret == -2) { if ($ret == -2) {

View File

@ -167,7 +167,7 @@ $usefilter = 0;
$sql = "SELECT e.rowid, e.type, e.ip, e.user_agent, e.dateevent,"; $sql = "SELECT e.rowid, e.type, e.ip, e.user_agent, e.dateevent,";
$sql .= " e.fk_user, e.description, e.prefix_session,"; $sql .= " e.fk_user, e.description, e.prefix_session,";
$sql .= " u.login"; $sql .= " u.login, u.admin, u.entity, u.firstname, u.lastname, u.statut as status";
$sql .= " FROM ".MAIN_DB_PREFIX."events as e"; $sql .= " FROM ".MAIN_DB_PREFIX."events as e";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = e.fk_user"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = e.fk_user";
$sql .= " WHERE e.entity IN (".getEntity('event').")"; $sql .= " WHERE e.entity IN (".getEntity('event').")";
@ -337,7 +337,18 @@ if ($result)
{ {
$userstatic->id = $obj->fk_user; $userstatic->id = $obj->fk_user;
$userstatic->login = $obj->login; $userstatic->login = $obj->login;
$userstatic->admin = $obj->admin;
$userstatic->entity = $obj->entity;
$userstatic->status = $obj->status;
print $userstatic->getLoginUrl(1); print $userstatic->getLoginUrl(1);
if (!empty($conf->multicompany->enabled) && $userstatic->admin && !$userstatic->entity)
{
print img_picto($langs->trans("SuperAdministrator"), 'redstar', 'class="valignmiddle paddingleft"');
} elseif ($userstatic->admin)
{
print img_picto($langs->trans("Administrator"), 'star', 'class="valignmiddle paddingleft"');
}
} else print '&nbsp;'; } else print '&nbsp;';
print '</td>'; print '</td>';

View File

@ -4118,17 +4118,13 @@ if ($action == 'create')
print '<table class="nobordernopadding" width="100%"><tr><td>'; print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('DateInvoice'); print $langs->trans('DateInvoice');
print '</td>'; print '</td>';
if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editinvoicedate' && !empty($object->brouillon) && $usercancreate && empty($conf->global->FAC_FORCE_DATE_VALIDATION)) if ($action != 'editinvoicedate' && !empty($object->brouillon) && $usercancreate && empty($conf->global->FAC_FORCE_DATE_VALIDATION))
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editinvoicedate&amp;facid='.$object->id.'">'.img_edit($langs->trans('SetDate'), 1).'</a></td>'; print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editinvoicedate&amp;facid='.$object->id.'">'.img_edit($langs->trans('SetDate'), 1).'</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td>'; print '</td><td>';
if ($object->type != Facture::TYPE_CREDIT_NOTE) { if ($action == 'editinvoicedate') {
if ($action == 'editinvoicedate') { $form->form_date($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->date, 'invoicedate');
$form->form_date($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->date, 'invoicedate');
} else {
print dol_print_date($object->date, 'day');
}
} else { } else {
print dol_print_date($object->date, 'day'); print dol_print_date($object->date, 'day');
} }

View File

@ -952,12 +952,21 @@ class FormOther
* @param int $invert Invert * @param int $invert Invert
* @param string $option Option * @param string $option Option
* @param string $morecss More css * @param string $morecss More css
* @param bool $addjscombo Add js combo
* @return string * @return string
*/ */
public function selectyear($selected = '', $htmlname = 'yearid', $useempty = 0, $min_year = 10, $max_year = 5, $offset = 0, $invert = 0, $option = '', $morecss = 'valignmiddle maxwidth75imp') public function selectyear($selected = '', $htmlname = 'yearid', $useempty = 0, $min_year = 10, $max_year = 5, $offset = 0, $invert = 0, $option = '', $morecss = 'valignmiddle maxwidth75imp', $addjscombo = false)
{ {
$out = ''; $out = '';
// Add code for jquery to use multiselect
if ($addjscombo)
{
// Enhance with select2
include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
$out .= ajax_combobox($htmlname);
}
$currentyear = date("Y") + $offset; $currentyear = date("Y") + $offset;
$max_year = $currentyear + $max_year; $max_year = $currentyear + $max_year;
$min_year = $currentyear - $min_year; $min_year = $currentyear - $min_year;

View File

@ -177,7 +177,7 @@ class modHoliday extends DolibarrModules
$this->rights[$r][0] = 20005; // Permission id (must not be already used) $this->rights[$r][0] = 20005; // Permission id (must not be already used)
$this->rights[$r][1] = 'Create/modify leave requests for everybody'; // Permission label $this->rights[$r][1] = 'Create/modify leave requests for everybody'; // Permission label
$this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][3] = 0; // Permission by default for new user (0/1)
$this->rights[$r][4] = 'write_all'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[$r][4] = 'writeall_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
$this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
$r++; $r++;

View File

@ -134,7 +134,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$this->name = "canelle"; $this->name = "canelle";
$this->description = $langs->trans('SuppliersInvoiceModel'); $this->description = $langs->trans('SuppliersInvoiceModel');
// Dimension page // Page dimensions
$this->type = 'pdf'; $this->type = 'pdf';
$formatarray = pdf_getFormat(); $formatarray = pdf_getFormat();
$this->page_largeur = $formatarray['width']; $this->page_largeur = $formatarray['width'];
@ -145,12 +145,12 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
$this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
$this->option_logo = 1; // Affiche logo $this->option_logo = 1; // Display logo
$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION
$this->option_modereg = 1; // Affiche mode reglement $this->option_modereg = 1; // Display payment mode
$this->option_condreg = 1; // Affiche conditions reglement $this->option_condreg = 1; // Display payment terms
$this->option_codeproduitservice = 1; // Affiche code produit-service $this->option_codeproduitservice = 1; // Display product-service code
$this->option_multilang = 1; // Dispo en plusieurs langues $this->option_multilang = 1; // Available in several languages
// Define column position // Define column position
$this->posxdesc = $this->marge_gauche + 1; $this->posxdesc = $this->marge_gauche + 1;
@ -489,7 +489,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$pdf->SetXY($this->postotalht, $curY); $pdf->SetXY($this->postotalht, $curY);
$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0, 'R', 0); $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva // Collection of totals by VAT value in $this->tva["taux"]=total_tva
if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva; if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva;
else $tvaligne = $object->lines[$i]->total_tva; else $tvaligne = $object->lines[$i]->total_tva;
@ -668,7 +668,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$this->atleastoneratenotnull = 0; $this->atleastoneratenotnull = 0;
foreach ($this->tva as $tvakey => $tvaval) foreach ($this->tva as $tvakey => $tvaval)
{ {
if ($tvakey > 0) // On affiche pas taux 0 if ($tvakey > 0) // We do not display rate 0
{ {
$this->atleastoneratenotnull++; $this->atleastoneratenotnull++;
@ -1209,7 +1209,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
} }
//Recipient name //Recipient name
// On peut utiliser le nom de la societe du contact // We can use the name of the contact's company
if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
$thirdparty = $object->contact; $thirdparty = $object->contact;
} else { } else {

View File

@ -142,13 +142,13 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
$this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
$this->option_logo = 1; // Affiche logo $this->option_logo = 1; // Display logo
$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION
$this->option_modereg = 1; // Affiche mode reglement $this->option_modereg = 1; // Display payment mode
$this->option_condreg = 1; // Affiche conditions reglement $this->option_condreg = 1; // Display payment terms
$this->option_codeproduitservice = 1; // Affiche code produit-service $this->option_codeproduitservice = 1; // Display product-service code
$this->option_multilang = 1; // Dispo en plusieurs langues $this->option_multilang = 1; // Available in several languages
$this->option_escompte = 0; // Affiche si il y a eu escompte $this->option_escompte = 0; // Displays if there has been a discount
$this->option_credit_note = 0; // Support credit notes $this->option_credit_note = 0; // Support credit notes
$this->option_freetext = 1; // Support add of a personalised text $this->option_freetext = 1; // Support add of a personalised text
$this->option_draft_watermark = 1; // Support add of a watermark on drafts $this->option_draft_watermark = 1; // Support add of a watermark on drafts

View File

@ -139,8 +139,8 @@ class pdf_standard extends ModelePDFSuppliersPayments
$this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
$this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
$this->option_logo = 1; // Affiche logo $this->option_logo = 1; // Display logo
$this->option_multilang = 1; // Dispo en plusieurs langues $this->option_multilang = 1; // Available in several languages
// Define column position // Define column position
$this->posxdate = $this->marge_gauche + 1; $this->posxdate = $this->marge_gauche + 1;
@ -168,7 +168,7 @@ class pdf_standard extends ModelePDFSuppliersPayments
$this->atleastoneratenotnull = 0; $this->atleastoneratenotnull = 0;
$this->atleastonediscount = 0; $this->atleastonediscount = 0;
// Recupere emetteur // Get source company
$this->emetteur = $mysoc; $this->emetteur = $mysoc;
if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
} }
@ -462,13 +462,13 @@ class pdf_standard extends ModelePDFSuppliersPayments
$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
} }
// Affiche zone cheèque // Display check zone
$posy = $this->_tableau_cheque($pdf, $object, $bottomlasttab, $outputlangs); $posy = $this->_tableau_cheque($pdf, $object, $bottomlasttab, $outputlangs);
// Affiche zone totaux // Affiche zone totaux
//$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); //$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
// Pied de page // Footer page
$this->_pagefoot($pdf, $object, $outputlangs); $this->_pagefoot($pdf, $object, $outputlangs);
if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();

View File

@ -214,6 +214,8 @@ if (empty($reshook))
if ($action == 'add' && $user->rights->expensereport->creer) if ($action == 'add' && $user->rights->expensereport->creer)
{ {
$error = 0;
$object = new ExpenseReport($db); $object = new ExpenseReport($db);
$object->date_debut = $date_start; $object->date_debut = $date_start;
@ -222,6 +224,19 @@ if (empty($reshook))
$object->fk_user_author = GETPOST('fk_user_author', 'int'); $object->fk_user_author = GETPOST('fk_user_author', 'int');
if (!($object->fk_user_author > 0)) $object->fk_user_author = $user->id; if (!($object->fk_user_author > 0)) $object->fk_user_author = $user->id;
// Check that expense report is for a user inside the hierarchy or advanced permission for all is set
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->expensereport->creer)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->expensereport->writeall_advance))) {
$error++;
setEventMessages($langs->trans("NotEnoughPermission"), null, 'errors');
} else {
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->expensereport->writeall_advance)) {
if (! in_array($object->fk_user_author, $childids)) {
$error++;
setEventMessages($langs->trans("UserNotInHierachy"), null, 'errors');
}
}
}
$fuser = new User($db); $fuser = new User($db);
$fuser->fetch($object->fk_user_author); $fuser->fetch($object->fk_user_author);
@ -1354,6 +1369,7 @@ if (empty($reshook))
$title = $langs->trans("ExpenseReport")." - ".$langs->trans("Card"); $title = $langs->trans("ExpenseReport")." - ".$langs->trans("Card");
$helpurl = "EN:Module_Expense_Reports"; $helpurl = "EN:Module_Expense_Reports";
llxHeader("", $title, $helpurl); llxHeader("", $title, $helpurl);
$form = new Form($db); $form = new Form($db);

View File

@ -82,7 +82,8 @@ if (($id > 0) || $ref)
} }
$cancreate = 0; $cancreate = 0;
if (!empty($user->rights->holiday->write_all)) $cancreate = 1;
if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->holiday->writeall_advance)) $cancreate = 1;
if (!empty($user->rights->holiday->write) && in_array($fuserid, $childids)) $cancreate = 1; if (!empty($user->rights->holiday->write) && in_array($fuserid, $childids)) $cancreate = 1;
$candelete = 0; $candelete = 0;
@ -146,12 +147,26 @@ if (empty($reshook))
$valideur = GETPOST('valideur', 'int'); $valideur = GETPOST('valideur', 'int');
$description = trim(GETPOST('description', 'restricthtml')); $description = trim(GETPOST('description', 'restricthtml'));
// Check that leave is for a user inside the hierarchy or advanced permission for all is set
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->expensereport->creer)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->expensereport->writeall_advance))) {
$error++;
setEventMessages($langs->trans("NotEnoughPermission"), null, 'errors');
} else {
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->expensereport->writeall_advance)) {
if (! in_array($fuserid, $childids)) {
$error++;
setEventMessages($langs->trans("UserNotInHierachy"), null, 'errors');
$action = 'create';
}
}
}
// If no type // If no type
if ($type <= 0) if ($type <= 0)
{ {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors');
$error++; $error++;
$action = 'add'; $action = 'create';
} }
// If no start date // If no start date
@ -159,21 +174,21 @@ if (empty($reshook))
{ {
setEventMessages($langs->trans("NoDateDebut"), null, 'errors'); setEventMessages($langs->trans("NoDateDebut"), null, 'errors');
$error++; $error++;
$action = 'add'; $action = 'create';
} }
// If no end date // If no end date
if (empty($date_fin)) if (empty($date_fin))
{ {
setEventMessages($langs->trans("NoDateFin"), null, 'errors'); setEventMessages($langs->trans("NoDateFin"), null, 'errors');
$error++; $error++;
$action = 'add'; $action = 'create';
} }
// If start date after end date // If start date after end date
if ($date_debut > $date_fin) if ($date_debut > $date_fin)
{ {
setEventMessages($langs->trans("ErrorEndDateCP"), null, 'errors'); setEventMessages($langs->trans("ErrorEndDateCP"), null, 'errors');
$error++; $error++;
$action = 'add'; $action = 'create';
} }
// Check if there is already holiday for this period // Check if there is already holiday for this period
@ -182,16 +197,16 @@ if (empty($reshook))
{ {
setEventMessages($langs->trans("alreadyCPexist"), null, 'errors'); setEventMessages($langs->trans("alreadyCPexist"), null, 'errors');
$error++; $error++;
$action = 'add'; $action = 'create';
} }
// If there is no Business Days within request // If there is no Business Days within request
$nbopenedday = num_open_day($date_debut_gmt, $date_fin_gmt, 0, 1, $halfday); $nbopenedday = num_open_day($date_debut_gmt, $date_fin_gmt, 0, 1, $halfday);
if ($nbopenedday < 0.5) if ($nbopenedday < 0.5)
{ {
setEventMessages($langs->trans("ErrorDureeCP"), null, 'errors'); setEventMessages($langs->trans("ErrorDureeCP"), null, 'errors'); // No working day
$error++; $error++;
$action = 'add'; $action = 'create';
} }
// If no validator designated // If no validator designated
@ -741,7 +756,8 @@ if (empty($reshook))
$object->fetch($id); $object->fetch($id);
// Si statut en attente de validation et valideur = valideur ou utilisateur, ou droits de faire pour les autres // Si statut en attente de validation et valideur = valideur ou utilisateur, ou droits de faire pour les autres
if (($object->statut == Holiday::STATUS_VALIDATED || $object->statut == Holiday::STATUS_APPROVED) && ($user->id == $object->fk_validator || in_array($object->fk_user, $childids) || !empty($user->rights->holiday->write_all))) if (($object->statut == Holiday::STATUS_VALIDATED || $object->statut == Holiday::STATUS_APPROVED) && ($user->id == $object->fk_validator || in_array($object->fk_user, $childids)
|| (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->holiday->writeall_advance))))
{ {
$db->begin(); $db->begin();
@ -866,15 +882,15 @@ llxHeader('', $langs->trans('CPTitreMenu'));
if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add')
{ {
// Si l'utilisateur n'a pas le droit de faire une demande // If user has no permission to create a leave
if (($fuserid == $user->id && empty($user->rights->holiday->write)) || ($fuserid != $user->id && empty($user->rights->holiday->write_all))) if ((in_array($fuserid, $childids) && empty($user->rights->holiday->write)) || (!in_array($fuserid, $childids) && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->holiday->writeall_advance))))
{ {
$errors[] = $langs->trans('CantCreateCP'); $errors[] = $langs->trans('CantCreateCP');
} else { } else {
// Formulaire de demande de congés payés // Form to add a leave request
print load_fiche_titre($langs->trans('MenuAddCP'), '', 'title_hrm.png'); print load_fiche_titre($langs->trans('MenuAddCP'), '', 'title_hrm.png');
// Si il y a une erreur // Error management
if (GETPOST('error')) { if (GETPOST('error')) {
switch (GETPOST('error')) { switch (GETPOST('error')) {
case 'datefin' : case 'datefin' :
@ -981,11 +997,13 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add')
print '<td class="titlefield fieldrequired">'.$langs->trans("User").'</td>'; print '<td class="titlefield fieldrequired">'.$langs->trans("User").'</td>';
print '<td>'; print '<td>';
if (empty($user->rights->holiday->write_all)) if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->holiday->writeall_advance))
{ {
print $form->select_dolusers(($fuserid ? $fuserid : $user->id), 'fuserid', 0, '', 0, 'hierarchyme', '', '0,'.$conf->entity, 0, 0, $morefilter, 0, '', 'maxwidth300'); print $form->select_dolusers(($fuserid ? $fuserid : $user->id), 'fuserid', 0, '', 0, 'hierarchyme', '', '0,'.$conf->entity, 0, 0, $morefilter, 0, '', 'maxwidth300');
//print '<input type="hidden" name="fuserid" value="'.($fuserid?$fuserid:$user->id).'">'; //print '<input type="hidden" name="fuserid" value="'.($fuserid?$fuserid:$user->id).'">';
} else print $form->select_dolusers(GETPOST('fuserid', 'int') ?GETPOST('fuserid', 'int') : $user->id, 'fuserid', 0, '', 0, '', '', '0,'.$conf->entity, 0, 0, $morefilter, 0, '', 'maxwidth300'); } else {
print $form->select_dolusers(GETPOST('fuserid', 'int') ? GETPOST('fuserid', 'int') : $user->id, 'fuserid', 0, '', 0, '', '', '0,'.$conf->entity, 0, 0, $morefilter, 0, '', 'maxwidth300');
}
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
@ -1459,7 +1477,7 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add')
print '<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans("NotTheAssignedApprover").'">'.$langs->trans("ActionRefuseCP").'</a>'; print '<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans("NotTheAssignedApprover").'">'.$langs->trans("ActionRefuseCP").'</a>';
} }
} }
if (($user->id == $object->fk_validator || in_array($object->fk_user, $childids) || !empty($user->rights->holiday->write_all)) && ($object->statut == 2 || $object->statut == 3)) // Status validated or approved if (($user->id == $object->fk_validator || in_array($object->fk_user, $childids) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->holiday->writeall_advance))) && ($object->statut == 2 || $object->statut == 3)) // Status validated or approved
{ {
if (($object->date_debut > dol_now()) || $user->admin) print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=cancel" class="butAction">'.$langs->trans("ActionCancelCP").'</a>'; if (($object->date_debut > dol_now()) || $user->admin) print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=cancel" class="butAction">'.$langs->trans("ActionCancelCP").'</a>';
else print '<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans("HolidayStarted").'">'.$langs->trans("ActionCancelCP").'</a>'; else print '<a href="#" class="butActionRefused classfortooltip" title="'.$langs->trans("HolidayStarted").'">'.$langs->trans("ActionCancelCP").'</a>';

View File

@ -421,7 +421,7 @@ if ($resql)
print '<div class="tabsAction">'; print '<div class="tabsAction">';
$canedit = (($user->id == $user_id && $user->rights->holiday->write) || ($user->id != $user_id && $user->rights->holiday->write_all)); $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)
{ {

View File

@ -25,9 +25,16 @@
*/ */
require '../main.inc.php'; require '../main.inc.php';
// Security check (access forbidden for external user too)
if (empty($user->rights->holiday->define_holiday) || $user->socid > 0) {
accessforbidden();
}
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php'; require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
@ -39,15 +46,15 @@ $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ')
$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
$search_id = GETPOST('search_id', 'alpha'); $search_id = GETPOST('search_id', 'alphanohtml');
$search_prev_solde = GETPOST('search_prev_solde', 'alpha'); $search_month = GETPOST('search_month', 'int');
$search_new_solde = GETPOST('search_new_solde', 'alpha'); $search_year = GETPOST('search_year', 'int');
$year = GETPOST('year'); $search_employee = GETPOST('search_employee', 'int');
if (empty($year)) $search_validator = GETPOST('search_validator', 'int');
{ $search_description = GETPOST('search_description', 'alphanohtml');
$tmpdate = dol_getdate(dol_now()); $search_type = GETPOST('search_type', 'int');
$year = $tmpdate['year']; $search_prev_solde = GETPOST('search_prev_solde', 'alphanohtml');
} $search_new_solde = GETPOST('search_new_solde', 'alphanohtml');
// Load variable for pagination // Load variable for pagination
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
@ -61,10 +68,6 @@ $pagenext = $page + 1;
if (! $sortfield) $sortfield="cpl.rowid"; if (! $sortfield) $sortfield="cpl.rowid";
if (! $sortorder) $sortorder="DESC"; if (! $sortorder) $sortorder="DESC";
// Protection if external user
if ($user->socid > 0) accessforbidden();
// Si l'utilisateur n'a pas le droit de lire cette page // Si l'utilisateur n'a pas le droit de lire cette page
if (!$user->rights->holiday->read_all) accessforbidden(); if (!$user->rights->holiday->read_all) accessforbidden();
@ -92,81 +95,126 @@ $parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $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
// Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria // 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_id = '';
$search_id = ''; $search_month = '';
$toselect = ''; $search_year = '';
$search_array_options = array(); $search_employee = '';
} $search_validator = '';
$search_description = '';
$search_type = '';
$search_prev_solde = '';
$search_new_solde = '';
$toselect = '';
$search_array_options = array();
}
if (GETPOST('button_removefilter_x', 'alpha') if (GETPOST('button_removefilter_x', 'alpha')
|| GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter.x', 'alpha')
|| GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter', 'alpha')
|| GETPOST('button_search_x', 'alpha') || GETPOST('button_search_x', '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 $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
} }
// Mass actions // Mass actions
/*$objectclass='MyObject'; /*$objectclass='MyObject';
$objectlabel='MyObject'; $objectlabel='MyObject';
$permissiontoread = $user->rights->mymodule->read; $permissiontoread = $user->rights->mymodule->read;
$permissiontodelete = $user->rights->mymodule->delete; $permissiontodelete = $user->rights->mymodule->delete;
$uploaddir = $conf->mymodule->dir_output; $uploaddir = $conf->mymodule->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
*/ */
} }
// Definition of fields for lists // Definition of fields for lists
$arrayfields = array( $arrayfields = array(
'cpl.rowid'=>array('label'=>$langs->trans("ID"), 'checked'=>1), 'cpl.rowid'=>array('label'=>$langs->trans("ID"), 'checked'=>1),
'cpl.date_action'=>array('label'=>$langs->trans("Date"), 'checked'=>1), 'cpl.date_action'=>array('label'=>$langs->trans("Date"), 'checked'=>1),
'cpl.fk_user_action'=>array('label'=>$langs->trans("ActionByCP"), 'checked'=>1), 'cpl.fk_user_action'=>array('label'=>$langs->trans("ActionByCP"), 'checked'=>1),
'cpl.fk_user_update'=>array('label'=>$langs->trans("UserUpdateCP"), 'checked'=>1), 'cpl.fk_user_update'=>array('label'=>$langs->trans("UserUpdateCP"), 'checked'=>1),
'cpl.type_action'=>array('label'=>$langs->trans("Description"), 'checked'=>1), 'cpl.type_action'=>array('label'=>$langs->trans("Description"), 'checked'=>1),
'cpl.fk_type'=>array('label'=>$langs->trans("Type"), 'checked'=>1), 'cpl.fk_type'=>array('label'=>$langs->trans("Type"), 'checked'=>1),
'cpl.prev_solde'=>array('label'=>$langs->trans("PrevSoldeCP"), 'checked'=>1), 'cpl.prev_solde'=>array('label'=>$langs->trans("PrevSoldeCP"), 'checked'=>1),
'variation'=>array('label'=>$langs->trans("Variation"), 'checked'=>1), 'variation'=>array('label'=>$langs->trans("Variation"), 'checked'=>1),
'cpl.new_solde'=>array('label'=>$langs->trans("NewSoldeCP"), 'checked'=>1), 'cpl.new_solde'=>array('label'=>$langs->trans("NewSoldeCP"), 'checked'=>1),
); );
/* /*
* View * View
*/ */
$form = new Form($db); $form = new Form($db);
$formother = new FormOther($db);
$holidaylogstatic = new stdClass();
$alltypeleaves = $object->getTypes(1, -1); // To have labels $alltypeleaves = $object->getTypes(1, -1); // To have labels
llxHeader('', $langs->trans('CPTitreMenu').' ('.$langs->trans("Year").' '.$year.')'); llxHeader('', $langs->trans('CPTitreMenu'));
$sqlwhere = " AND date_action BETWEEN ". $sqlwhere = '';
$sqlwhere.= "'".$db->idate(dol_get_first_day($year, 1, 1))."'";
$sqlwhere.= " AND ";
$sqlwhere.= "'".$db->idate(dol_get_last_day($year, 12, 1))."'";
if ($search_id != '') $sqlwhere.= natural_search('rowid', $search_id, 1); if (!empty($search_year) && $search_year > 0) {
if ($search_prev_solde != '') $sqlwhere.= natural_search('prev_solde', $search_prev_solde, 1); if (!empty($search_month) && $search_month > 0) {
if ($search_new_solde != '') $sqlwhere.= natural_search('new_solde', $search_new_solde, 1); $from_date = dol_get_first_day($search_year, $search_month, 1);
$to_date = dol_get_last_day($search_year, $search_month, 1);
} else {
$from_date = dol_get_first_day($search_year, 1, 1);
$to_date = dol_get_last_day($search_year, 12, 1);
}
$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);
$sqlorder = $db->order($sortfield, $sortorder); $sqlorder = $db->order($sortfield, $sortorder);
// Recent changes are more important than old changes // Recent changes are more important than old changes
$log_holiday = $object->fetchLog($sqlorder, $sqlwhere); // Load $object->logs $log_holiday = $object->fetchLog($sqlorder, $sqlwhere); // Load $object->logs
// Count total nb of records
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
//TODO: $result = $db->query($sql);
//TODO: $nbtotalofrecords = $db->num_rows($result);
$nbtotalofrecords = is_array($object->logs) ? count($object->logs) : 0;
if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
$page = 0;
$offset = 0;
}
}
// TODO: $num = $db->num_rows($resql);
$num = is_array($object->logs) ? count($object->logs) : 0;
$param = ''; $param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if ($search_id) $param = '&search_id='.urlencode($search_id); 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"].'">'; 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.'">';
@ -178,44 +226,23 @@ print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">'; print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
$pagination = '<div class="pagination">'; $newcardbutton = dolGetButtonTitle($langs->trans('MenuAddCP'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/holiday/card.php?action=request', '', $user->rights->holiday->write);
$pagination.= '<ul>'; print_barre_liste($langs->trans('LogCP'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_hrm', 0, $newcardbutton, '', $limit, 0, 0, 1);
$pagination.= '<li class="pagination">';
$pagination.= '<a href="'.$_SERVER["PHP_SELF"].'?year='.($year - 1).$param.'">'; print '<div class="info">'.$langs->trans('LastUpdateCP').': ';
$pagination.= '<i class="fa fa-chevron-left" title="Previous"></i>';
$pagination.= '</a>';
$pagination.= '<li class="pagination">';
$pagination.= '<span class="active">'.$langs->trans("Year").' '.$year.'</span>';
$pagination.= '</li>';
$pagination.= '<li class="pagination">';
$pagination.= '<a href="'.$_SERVER["PHP_SELF"].'?year='.($year + 1).$param.'">';
$pagination.= '<i class="fa fa-chevron-right" title="Next"></i>';
$pagination.= '</a>';
$pagination.= '</li>';
$pagination.= '</li>';
$pagination.= '</ul>';
$pagination.= '</div>';
print load_fiche_titre($langs->trans('LogCP'), $pagination, 'title_hrm.png');
print '<div class="info">'.$langs->trans('LastUpdateCP').': '."\n";
$lastUpdate = $object->getConfCP('lastUpdate'); $lastUpdate = $object->getConfCP('lastUpdate');
if ($lastUpdate) if ($lastUpdate) {
{ $monthLastUpdate = $lastUpdate[4].$lastUpdate[5];
$monthLastUpdate = $lastUpdate[4].$lastUpdate[5]; $yearLastUpdate = $lastUpdate[0].$lastUpdate[1].$lastUpdate[2].$lastUpdate[3];
$yearLastUpdate = $lastUpdate[0].$lastUpdate[1].$lastUpdate[2].$lastUpdate[3]; print '<strong>'.dol_print_date($db->jdate($object->getConfCP('lastUpdate')), 'dayhour', 'tzuser').'</strong>';
print '<strong>'.dol_print_date($db->jdate($object->getConfCP('lastUpdate')), 'dayhour', 'tzuser').'</strong>'; print '<br>';
print '<br>'.$langs->trans("MonthOfLastMonthlyUpdate").': <strong>'.$yearLastUpdate.'-'.$monthLastUpdate.'</strong>'."\n"; print $langs->trans("MonthOfLastMonthlyUpdate").': <strong>'.$yearLastUpdate.'-'.$monthLastUpdate.'</strong>';
} else {
print $langs->trans('None');
} }
else { print '</div>';
print $langs->trans('None'); print '<br>';
}
print "</div><br>\n";
$moreforfilter = ''; $moreforfilter = '';
@ -225,20 +252,84 @@ $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfiel
$selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); $selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
print '<div class="div-table-responsive">'; print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'" id="tablelines3">'."\n"; print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'" id="tablelines3">';
print '<tbody>'; print '<tr class="liste_titre_filter">';
// Filter Id
if (!empty($arrayfields['cpl.rowid']['checked'])) {
print '<td class="liste_titre"><input type="text" class="maxwidth50" name="search_id" value="'.$search_id.'"></td>';
}
// Filter: Date
if (!empty($arrayfields['cpl.date_action']['checked'])) {
print '<td class="liste_titre right">';
print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month" value="'.dol_escape_htmltag($search_month).'">';
print $formother->selectyear($search_year, 'search_year', 1, 10, 5, 0, 0, '', 'maxwidth200', true);
print '</td>';
}
// Filter: Validator
if (!empty($arrayfields['cpl.fk_user_action']['checked'])) {
$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;
}
print '<td class="liste_titre">';
print $form->select_dolusers($search_validator, "search_validator", 1, "", 0, $valideurarray, '', 0, 0, 0, $morefilter, 0, '', 'maxwidth200');
print '</td>';
}
// Filter: User
if (!empty($arrayfields['cpl.fk_user_update']['checked'])) {
print '<td class="liste_titre">';
print $form->select_dolusers($search_employee, "search_employee", 1, "", $disabled, $include, '', 0, 0, 0, $morefilter, 0, '', 'maxwidth200');
print '</td>';
}
// Filter: Description
if (!empty($arrayfields['cpl.type_action']['checked'])) {
print '<td class="liste_titre">';
print '<input type="text" class="maxwidth50" name="search_description" value="'.$search_description.'">';
print '</td>';
}
// Filter: Type
if (!empty($arrayfields['cpl.fk_type']['checked'])) {
foreach ($alltypeleaves as $key => $val) {
$labeltoshow = ($langs->trans($val['code']) != $val['code'] ? $langs->trans($val['code']) : $val['label']);
$arraytypeleaves[$val['rowid']] = $labeltoshow;
}
print '<td class="liste_titre">';
print $form->selectarray('search_type', $arraytypeleaves, $search_type, 1, 0, 0, '', 0, 0, 0, '', '', 1);
print '</td>';
}
// Filter: Previous balance
if (!empty($arrayfields['cpl.prev_solde']['checked'])) {
print '<td class="liste_titre">';
print '<input type="text" class="maxwidth50" name="search_prev_solde" value="'.$search_prev_solde.'">';
print '</td>';
}
// Filter: Variation (only placeholder)
if (!empty($arrayfields['variation']['checked'])) {
print '<td class="liste_titre"></td>';
}
// Filter: New Balance
if (!empty($arrayfields['cpl.new_solde']['checked'])) {
print '<td class="liste_titre">';
print '<input type="text" class="maxwidth50" name="search_new_solde" value="'.$search_new_solde.'">';
print '</td>';
}
print '<tr class="liste_titre">';
if (!empty($arrayfields['cpl.rowid']['checked'])) print '<td class="liste_titre"><input type="text" class="maxwidth50" name="search_id" value="'.$search_id.'"></td>';
if (!empty($arrayfields['cpl.date_action']['checked'])) print '<td class="liste_titre"></td>';
if (!empty($arrayfields['cpl.fk_user_action']['checked'])) print '<td class="liste_titre"></td>';
if (!empty($arrayfields['cpl.fk_user_update']['checked'])) print '<td class="liste_titre"></td>';
if (!empty($arrayfields['cpl.type_action']['checked'])) print '<td class="liste_titre"></td>';
if (!empty($arrayfields['cpl.fk_type']['checked'])) print '<td class="liste_titre"></td>';
if (!empty($arrayfields['cpl.prev_solde']['checked'])) print '<td class="liste_titre"><input type="text" class="maxwidth50" name="search_prev_solde" value="'.$search_prev_solde.'"></td>';
if (!empty($arrayfields['variation']['checked'])) print '<td class="liste_titre"></td>';
if (!empty($arrayfields['cpl.new_solde']['checked'])) print '<td class="liste_titre"><input type="text" class="maxwidth50" name="search_new_solde" value="'.$search_new_solde.'"></td>';
// Action column // Action column
print '<td class="liste_titre maxwidthsearch">'; print '<td class="liste_titre maxwidthsearch">';
$searchpicto = $form->showFilterButtons(); $searchpicto = $form->showFilterButtons();
@ -256,51 +347,102 @@ if (!empty($arrayfields['cpl.fk_type']['checked'])) print_liste_field_titre($arr
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['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['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.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 ')."\n"; print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
print '</tr>'; print '</tr>';
// TODO: $i = 0;
$i = 1;
foreach ($object->logs as $logs_CP) while ($i < min($num, $limit))
{ {
$user_action = new User($db); //TODO: $obj = $db->fetch_object($resql);
$user_action->fetch($logs_CP['fk_user_action']); $obj = next($object->logs);
$user_update = new User($db); $holidaylogstatic->id = $obj['rowid'];
$user_update->fetch($logs_CP['fk_user_update']); $holidaylogstatic->date = $obj['date_action'];
$holidaylogstatic->validator = $obj['fk_user_action'];
$holidaylogstatic->employee = $obj['fk_user_update'];
$holidaylogstatic->description = $obj['type_action'];
$holidaylogstatic->type = $obj['fk_type'];
$holidaylogstatic->balance_previous = $obj['prev_solde'];
$holidaylogstatic->balance_new = $obj['new_solde'];
$delta = price2num($logs_CP['new_solde'] - $logs_CP['prev_solde'], 5); print '<tr class="oddeven">';
$detasign = ($delta > 0 ? '+' : '');
print '<tr class="oddeven">'; // Id
if (!empty($arrayfields['cpl.rowid']['checked'])) print '<td>'.$logs_CP['rowid'].'</td>'; if (!empty($arrayfields['cpl.rowid']['checked'])) {
if (!empty($arrayfields['cpl.date_action']['checked'])) print '<td style="text-align: center;">'.$logs_CP['date_action'].'</td>'; print '<td>'.$holidaylogstatic->id.'</td>';
if (!empty($arrayfields['cpl.fk_user_action']['checked'])) print '<td>'.$user_action->getNomUrl(-1).'</td>'; }
if (!empty($arrayfields['cpl.fk_user_update']['checked'])) print '<td>'.$user_update->getNomUrl(-1).'</td>';
if (!empty($arrayfields['cpl.type_action']['checked'])) print '<td>'.$logs_CP['type_action'].'</td>';
if (!empty($arrayfields['cpl.fk_type']['checked']))
{
print '<td>';
$label = (($alltypeleaves[$logs_CP['fk_type']]['code'] && $langs->trans($alltypeleaves[$logs_CP['fk_type']]['code']) != $alltypeleaves[$logs_CP['fk_type']]['code']) ? $langs->trans($alltypeleaves[$logs_CP['fk_type']]['code']) : $alltypeleaves[$logs_CP['fk_type']]['label']);
print $label ? $label : $logs_CP['fk_type'];
print '</td>';
}
if (!empty($arrayfields['cpl.prev_solde']['checked'])) print '<td style="text-align: right;">'.price2num($logs_CP['prev_solde'], 5).' '.$langs->trans('days').'</td>'; // Date
if (!empty($arrayfields['variation']['checked'])) print '<td style="text-align: right;">'.$detasign.$delta.'</td>'; if (!empty($arrayfields['cpl.date_action']['checked'])) {
if (!empty($arrayfields['cpl.new_solde']['checked'])) print '<td style="text-align: right;">'.price2num($logs_CP['new_solde'], 5).' '.$langs->trans('days').'</td>'; print '<td style="text-align: center">'.$holidaylogstatic->date.'</td>';
print '<td></td>'; }
print '</tr>'."\n";
// Validator
if (!empty($arrayfields['cpl.fk_user_action']['checked'])) {
$user_action = new User($db);
$user_action->fetch($holidaylogstatic->validator);
print '<td>'.$user_action->getNomUrl(-1).'</td>';
}
// Emloyee
if (!empty($arrayfields['cpl.fk_user_update']['checked'])) {
$user_update = new User($db);
$user_update->fetch($holidaylogstatic->employee);
print '<td>'.$user_update->getNomUrl(-1).'</td>';
}
// Description
if (!empty($arrayfields['cpl.type_action']['checked'])) {
print '<td>'.$holidaylogstatic->description.'</td>';
}
// Type
if (!empty($arrayfields['cpl.fk_type']['checked'])) {
if ($alltypeleaves[$holidaylogstatic->type]['code'] && $langs->trans($alltypeleaves[$holidaylogstatic->type]['code']) != $alltypeleaves[$holidaylogstatic->type]['code']) {
$label = $langs->trans($alltypeleaves[$holidaylogstatic->type]['code']);
} else {
$label = $alltypeleaves[$holidaylogstatic->type]['label'];
}
print '<td>';
print $label ? $label : $holidaylogstatic->type;
print '</td>';
}
// Previous balance
if (!empty($arrayfields['cpl.prev_solde']['checked'])) {
print '<td style="text-align: right;">'.price2num($holidaylogstatic->balance_previous, 5).' '.$langs->trans('days').'</td>';
}
// Variation
if (!empty($arrayfields['variation']['checked'])) {
$delta = price2num($holidaylogstatic->balance_new - $holidaylogstatic->balance_previous, 5);
$detasign = ($delta > 0 ? '+' : '');
print '<td style="text-align: right;">'.$detasign.$delta.'</td>';
}
// New Balance
if (!empty($arrayfields['cpl.new_solde']['checked'])) {
print '<td style="text-align: right;">'.price2num($holidaylogstatic->balance_new, 5).' '.$langs->trans('days').'</td>';
}
// Buttons
print '<td></td>';
print '</tr>';
$i++;
} }
if ($log_holiday == '2') if ($log_holiday == '2') {
{ print '<tr class="opacitymedium">';
print '<tr class="opacitymedium">'; print '<td colspan="10" class="opacitymedium">'.$langs->trans('NoRecordFound').'</td>';
print '<td colspan="10" class="opacitymedium">'.$langs->trans('NoRecordFound').'</td>'; print '</tr>';
print '</tr>';
} }
print '</tbody>'."\n"; print '</table>';
print '</table>'."\n";
print '</div>'; print '</div>';
print '</form>'; print '</form>';

View File

@ -362,3 +362,7 @@ UPDATE llx_projet_task_time SET tms = null WHERE tms = 0;
ALTER TABLE llx_projet_task_time MODIFY COLUMN tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP; ALTER TABLE llx_projet_task_time MODIFY COLUMN tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;
ALTER TABLE llx_projet_task_time MODIFY COLUMN datec datetime; ALTER TABLE llx_projet_task_time MODIFY COLUMN datec datetime;
DELETE FROM llx_user_rights WHERE fk_id IN (SELECT id FROM llx_rights_def where module = 'holiday' and perms = 'lire_tous');
DELETE FROM llx_rights_def where module = 'holiday' and perms = 'lire_tous';

View File

@ -221,25 +221,25 @@ if (!empty($_POST["DOL_AUTOSET_COOKIE"]))
} }
// Init session. Name of session is specific to Dolibarr instance. // Init the 5 global objects, this include will make the 'new Xxx()' and set properties for: $conf, $db, $langs, $user, $mysoc
// Note: the function dol_getprefix may have been redefined to return a different key to manage another area to protect. require_once 'master.inc.php';
$prefix = dol_getprefix('');
// Init session. Name of session is specific to Dolibarr instance.
// Must be done after the include of master.inc.php so $conf file is loaded and vars like $dolibarr_main_force_https are set.
// Note: the function dol_getprefix may have been redefined to return a different key to manage another area to protect.
$prefix = dol_getprefix(''); // This uses the $conf file
$sessionname = 'DOLSESSID_'.$prefix; $sessionname = 'DOLSESSID_'.$prefix;
$sessiontimeout = 'DOLSESSTIMEOUT_'.$prefix; $sessiontimeout = 'DOLSESSTIMEOUT_'.$prefix;
if (!empty($_COOKIE[$sessiontimeout])) ini_set('session.gc_maxlifetime', $_COOKIE[$sessiontimeout]); if (!empty($_COOKIE[$sessiontimeout])) ini_set('session.gc_maxlifetime', $_COOKIE[$sessiontimeout]);
session_set_cookie_params(0, '/', null, (empty($dolibarr_main_force_https) ? false : true), true); // Add tag secure and httponly on session cookie (same as setting session.cookie_httponly into php.ini). Must be called before the session_start. session_set_cookie_params(0, '/', null, (empty($dolibarr_main_force_https) ? false : true), true); // Add tag secure and httponly on session cookie (same as setting session.cookie_httponly into php.ini). Must be called before the session_start.
session_name($sessionname); session_name($sessionname);
// This create lock, released when session_write_close() or end of page. // This create lock, released by session_write_close() or end of page.
// We need this lock as long as we read/write $_SESSION ['vars']. We can remove lock when finished. // We need this lock as long as we read/write $_SESSION ['vars']. We can remove lock when finished.
if (!defined('NOSESSION')) if (!defined('NOSESSION'))
{ {
session_start(); session_start();
} }
// Init the 5 global objects, this include will make the 'new Xxx()' and set properties for: $conf, $db, $langs, $user, $mysoc
require_once 'master.inc.php';
// Activate end of page function // Activate end of page function
register_shutdown_function('dol_shutdown'); register_shutdown_function('dol_shutdown');

View File

@ -73,7 +73,7 @@ CKEDITOR.editorConfig = function( config )
['Maximize'], ['Maximize'],
['SpellChecker', 'Scayt'], // 'Cut','Copy','Paste','-', are useless, can be done with right click, even on smarpthone ['SpellChecker', 'Scayt'], // 'Cut','Copy','Paste','-', are useless, can be done with right click, even on smarpthone
['Undo','Redo','-','Find','Replace'], ['Undo','Redo','-','Find','Replace'],
['Format','Font','FontSize'], ['Font','FontSize'],
['Bold','Italic','Underline','Strike','Superscript','-','TextColor','RemoveFormat'], ['Bold','Italic','Underline','Strike','Superscript','-','TextColor','RemoveFormat'],
['NumberedList','BulletedList','Outdent','Indent'], ['NumberedList','BulletedList','Outdent','Indent'],
['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'], ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],