Merge pull request #11209 from atm-maxime/fix_holiday_missing_stats

Fix holiday missing stats
This commit is contained in:
Laurent Destailleur 2019-05-18 19:33:36 +02:00 committed by GitHub
commit 34b5399329
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 131 additions and 16 deletions

View File

@ -120,6 +120,12 @@ $modules=array(
'img' => 'trip' 'img' => 'trip'
)*/ )*/
), ),
'holiday' => array(
array(
'code' => 'MAIN_DELAY_HOLIDAYS',
'img' => 'holiday'
),
),
); );
$labelmeteo = array(0=>$langs->trans("No"), 1=>$langs->trans("Yes"), 2=>$langs->trans("OnMobileOnly")); $labelmeteo = array(0=>$langs->trans("No"), 1=>$langs->trans("Yes"), 2=>$langs->trans("OnMobileOnly"));

View File

@ -615,6 +615,10 @@ class Conf
$this->expensereport->payment = new stdClass(); $this->expensereport->payment = new stdClass();
$this->expensereport->payment->warning_delay=(isset($this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY)?$this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY:0)*24*60*60; $this->expensereport->payment->warning_delay=(isset($this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY)?$this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY:0)*24*60*60;
} }
if (isset($this->holiday)) {
$this->holiday->approve = new stdClass();
$this->holiday->approve->warning_delay=(isset($this->global->MAIN_DELAY_HOLIDAYS)?$this->global->MAIN_DELAY_HOLIDAYS:0)*24*60*60;
}
if (! empty($this->global->PRODUIT_MULTIPRICES) && empty($this->global->PRODUIT_MULTIPRICES_LIMIT)) if (! empty($this->global->PRODUIT_MULTIPRICES) && empty($this->global->PRODUIT_MULTIPRICES_LIMIT))
{ {

View File

@ -1439,9 +1439,9 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
{ {
$langs->load("hrm"); $langs->load("hrm");
$newmenu->add("/user/list.php?leftmenu=hrm&mode=employee", $langs->trans("Employees"), 0, $user->rights->hrm->employee->read, '', $mainmenu, 'hrm'); $newmenu->add("/user/list.php?mainmenu=hrm&mode=employee", $langs->trans("Employees"), 0, $user->rights->hrm->employee->read, '', $mainmenu, 'hrm');
$newmenu->add("/user/card.php?action=create&employee=1", $langs->trans("NewEmployee"), 1,$user->rights->hrm->employee->write); $newmenu->add("/user/card.php?mainmenu=hrm&action=create&employee=1", $langs->trans("NewEmployee"), 1,$user->rights->hrm->employee->write);
$newmenu->add("/user/list.php?leftmenu=hrm&mode=employee&contextpage=employeelist", $langs->trans("List"), 1,$user->rights->hrm->employee->read); $newmenu->add("/user/list.php?mainmenu=hrm&mode=employee&contextpage=employeelist", $langs->trans("List"), 1,$user->rights->hrm->employee->read);
} }
// Leave/Holiday/Vacation module // Leave/Holiday/Vacation module
@ -1450,17 +1450,17 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("holiday","trips")); $langs->loadLangs(array("holiday","trips"));
$newmenu->add("/holiday/list.php?leftmenu=hrm", $langs->trans("CPTitreMenu"), 0, $user->rights->holiday->read, '', $mainmenu, 'hrm'); $newmenu->add("/holiday/list.php?mainmenu=hrm&leftmenu=holiday", $langs->trans("CPTitreMenu"), 0, $user->rights->holiday->read, '', $mainmenu, 'hrm');
$newmenu->add("/holiday/card.php?action=request", $langs->trans("New"), 1,$user->rights->holiday->write); $newmenu->add("/holiday/card.php?mainmenu=hrm&leftmenu=holiday&action=request", $langs->trans("New"), 1,$user->rights->holiday->write);
$newmenu->add("/holiday/list.php?leftmenu=hrm", $langs->trans("List"), 1,$user->rights->holiday->read); $newmenu->add("/holiday/list.php?mainmenu=hrm&leftmenu=holiday", $langs->trans("List"), 1,$user->rights->holiday->read);
if ($usemenuhider || empty($leftmenu) || $leftmenu=="hrm") $newmenu->add("/holiday/list.php?search_statut=1&leftmenu=hrm", $langs->trans("DraftCP"), 2, $user->rights->holiday->read); if ($usemenuhider || empty($leftmenu) || $leftmenu=="holiday") $newmenu->add("/holiday/list.php?search_statut=1&mainmenu=hrm&leftmenu=holiday", $langs->trans("DraftCP"), 2, $user->rights->holiday->read);
if ($usemenuhider || empty($leftmenu) || $leftmenu=="hrm") $newmenu->add("/holiday/list.php?search_statut=2&leftmenu=hrm", $langs->trans("ToReviewCP"), 2, $user->rights->holiday->read); if ($usemenuhider || empty($leftmenu) || $leftmenu=="holiday") $newmenu->add("/holiday/list.php?search_statut=2&mainmenu=hrm&leftmenu=holiday", $langs->trans("ToReviewCP"), 2, $user->rights->holiday->read);
if ($usemenuhider || empty($leftmenu) || $leftmenu=="hrm") $newmenu->add("/holiday/list.php?search_statut=3&leftmenu=hrm", $langs->trans("ApprovedCP"), 2, $user->rights->holiday->read); if ($usemenuhider || empty($leftmenu) || $leftmenu=="holiday") $newmenu->add("/holiday/list.php?search_statut=3&mainmenu=hrm&leftmenu=holiday", $langs->trans("ApprovedCP"), 2, $user->rights->holiday->read);
if ($usemenuhider || empty($leftmenu) || $leftmenu=="hrm") $newmenu->add("/holiday/list.php?search_statut=4&leftmenu=hrm", $langs->trans("CancelCP"), 2, $user->rights->holiday->read); if ($usemenuhider || empty($leftmenu) || $leftmenu=="holiday") $newmenu->add("/holiday/list.php?search_statut=4&mainmenu=hrm&leftmenu=holiday", $langs->trans("CancelCP"), 2, $user->rights->holiday->read);
if ($usemenuhider || empty($leftmenu) || $leftmenu=="hrm") $newmenu->add("/holiday/list.php?search_statut=5&leftmenu=hrm", $langs->trans("RefuseCP"), 2, $user->rights->holiday->read); if ($usemenuhider || empty($leftmenu) || $leftmenu=="holiday") $newmenu->add("/holiday/list.php?search_statut=5&mainmenu=hrm&leftmenu=holiday", $langs->trans("RefuseCP"), 2, $user->rights->holiday->read);
$newmenu->add("/holiday/define_holiday.php?action=request", $langs->trans("MenuConfCP"), 1, $user->rights->holiday->read); $newmenu->add("/holiday/define_holiday.php?mainmenu=hrm&leftmenu=holiday&action=request", $langs->trans("MenuConfCP"), 1, $user->rights->holiday->read);
$newmenu->add("/holiday/month_report.php", $langs->trans("MenuReportMonth"), 1, $user->rights->holiday->read_all); $newmenu->add("/holiday/month_report.php?mainmenu=hrm&leftmenu=holiday", $langs->trans("MenuReportMonth"), 1, $user->rights->holiday->read_all);
$newmenu->add("/holiday/view_log.php?action=request", $langs->trans("MenuLogCP"), 1, $user->rights->holiday->define_holiday); $newmenu->add("/holiday/view_log.php?mainmenu=hrm&leftmenu=holiday&action=request", $langs->trans("MenuLogCP"), 1, $user->rights->holiday->define_holiday);
} }
// Trips and expenses (old module) // Trips and expenses (old module)

View File

@ -876,6 +876,7 @@ if ((empty($id) && empty($ref)) || $action == 'add' || $action == 'request' || $
// Formulaire de demande // Formulaire de demande
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'" onsubmit="return valider()" name="demandeCP">'."\n"; print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'" onsubmit="return valider()" name="demandeCP">'."\n";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />'."\n";
print '<input type="hidden" name="action" value="create" />'."\n"; print '<input type="hidden" name="action" value="create" />'."\n";
if (empty($conf->global->HOLIDAY_HIDE_BALANCE)) if (empty($conf->global->HOLIDAY_HIDE_BALANCE))

View File

@ -2177,4 +2177,91 @@ class Holiday extends CommonObject
$this->fk_type=1; $this->fk_type=1;
$this->statut=Holiday::STATUS_VALIDATED; $this->statut=Holiday::STATUS_VALIDATED;
} }
/**
* Load this->nb for dashboard
*
* @return int <0 if KO, >0 if OK
*/
public function load_state_board()
{
global $conf;
$this->nb=array();
$sql = "SELECT count(h.rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."holiday as h";
$sql.= " WHERE h.statut > 1";
$sql.= " AND h.entity IN (".getEntity('holiday').")";
$resql=$this->db->query($sql);
if ($resql) {
while ($obj=$this->db->fetch_object($resql)) {
$this->nb["holidays"]=$obj->nb;
}
$this->db->free($resql);
return 1;
}
else
{
dol_print_error($this->db);
$this->error=$this->db->error();
return -1;
}
}
/**
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
*
* @param User $user Objet user
* @param string $option 'toapprove'
* @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK
*/
public function load_board($user)
{
// phpcs:enable
global $conf, $langs;
if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe
$now=dol_now();
$userchildids = $user->getAllChildIds(1);
$sql = "SELECT h.rowid, h.date_debut";
$sql.= " FROM ".MAIN_DB_PREFIX."holiday as h";
$sql.= " WHERE h.statut = 2";
$sql.= " AND h.entity IN (".getEntity('holiday').")";
$sql.= " AND (h.fk_user IN (".join(',', $userchildids).")";
$sql.= " OR h.fk_validator IN (".join(',', $userchildids)."))";
$resql=$this->db->query($sql);
if ($resql)
{
$langs->load("members");
$response = new WorkboardResponse();
$response->warning_delay=$conf->holiday->approve->warning_delay/60/60/24;
$response->label=$langs->trans("HolidaysToApprove");
$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))
{
$response->nbtodo++;
if ($this->db->jdate($obj->date_debut) < ($now - $conf->holiday->approve->warning_delay)) {
$response->nbtodolate++;
}
}
return $response;
}
else
{
dol_print_error($this->db);
$this->error=$this->db->error();
return -1;
}
}
} }

View File

@ -150,6 +150,7 @@ if (empty($user->societe_id))
! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_PROPOSAL_STATS), ! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_PROPOSAL_STATS),
! empty($conf->projet->enabled) && $user->rights->projet->lire, ! empty($conf->projet->enabled) && $user->rights->projet->lire,
! empty($conf->expensereport->enabled) && $user->rights->expensereport->lire, ! empty($conf->expensereport->enabled) && $user->rights->expensereport->lire,
! empty($conf->holiday->enabled) && $user->rights->holiday->read,
! empty($conf->don->enabled) && $user->rights->don->lire ! empty($conf->don->enabled) && $user->rights->don->lire
); );
// Class file containing the method load_state_board for each line // Class file containing the method load_state_board for each line
@ -172,6 +173,7 @@ if (empty($user->societe_id))
DOL_DOCUMENT_ROOT."/supplier_proposal/class/supplier_proposal.class.php", DOL_DOCUMENT_ROOT."/supplier_proposal/class/supplier_proposal.class.php",
DOL_DOCUMENT_ROOT."/projet/class/project.class.php", DOL_DOCUMENT_ROOT."/projet/class/project.class.php",
DOL_DOCUMENT_ROOT."/expensereport/class/expensereport.class.php", DOL_DOCUMENT_ROOT."/expensereport/class/expensereport.class.php",
DOL_DOCUMENT_ROOT."/holiday/class/holiday.class.php",
DOL_DOCUMENT_ROOT."/don/class/don.class.php" DOL_DOCUMENT_ROOT."/don/class/don.class.php"
); );
// Name class containing the method load_state_board for each line // Name class containing the method load_state_board for each line
@ -193,6 +195,7 @@ if (empty($user->societe_id))
'SupplierProposal', 'SupplierProposal',
'Project', 'Project',
'ExpenseReport', 'ExpenseReport',
'Holiday',
'Don' 'Don'
); );
// Cle array returned by the method load_state_board for each line // Cle array returned by the method load_state_board for each line
@ -203,7 +206,7 @@ if (empty($user->societe_id))
'contacts', 'contacts',
'members', 'members',
'products', 'products',
'services', 'services',
'proposals', 'proposals',
'orders', 'orders',
'invoices', 'invoices',
@ -214,6 +217,7 @@ if (empty($user->societe_id))
'askprice', 'askprice',
'projects', 'projects',
'expensereports', 'expensereports',
'holidays',
'donations' 'donations'
); );
// Dashboard Icon lines // Dashboard Icon lines
@ -235,6 +239,7 @@ if (empty($user->societe_id))
'propal', 'propal',
'projectpub', 'projectpub',
'trip', 'trip',
'holiday',
'generic' 'generic'
); );
// Translation keyword // Translation keyword
@ -256,6 +261,7 @@ if (empty($user->societe_id))
"SupplierProposalShort", "SupplierProposalShort",
"Projects", "Projects",
"ExpenseReports", "ExpenseReports",
"Holidays",
"Donations" "Donations"
); );
// Dashboard Link lines // Dashboard Link lines
@ -278,6 +284,7 @@ if (empty($user->societe_id))
DOL_URL_ROOT.'/supplier_proposal/list.php?mainmenu=commercial&leftmenu=', DOL_URL_ROOT.'/supplier_proposal/list.php?mainmenu=commercial&leftmenu=',
DOL_URL_ROOT.'/projet/list.php?mainmenu=project', DOL_URL_ROOT.'/projet/list.php?mainmenu=project',
DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm&leftmenu=expensereport', DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm&leftmenu=expensereport',
DOL_URL_ROOT.'/holiday/list.php?mainmenu=hrm&leftmenu=holiday',
DOL_URL_ROOT.'/don/list.php?leftmenu=donations' DOL_URL_ROOT.'/don/list.php?leftmenu=donations'
); );
// Translation lang files // Translation lang files
@ -299,6 +306,7 @@ if (empty($user->societe_id))
"supplier_proposal", "supplier_proposal",
"projects", "projects",
"trips", "trips",
"holidays",
"donations" "donations"
); );
@ -496,6 +504,14 @@ if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->to_p
$dashboardlines[] = $board->load_board($user,'topay'); $dashboardlines[] = $board->load_board($user,'topay');
} }
// Number of holidays to approve
if (! empty($conf->holiday->enabled) && $user->rights->holiday->approve)
{
include_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
$board=new Holiday($db);
$dashboardlines[] = $board->load_board($user);
}
$object=new stdClass(); $object=new stdClass();
$parameters=array(); $parameters=array();
$action=''; $action='';

View File

@ -126,4 +126,5 @@ HolidaySetup=Setup of module Holiday
HolidaysNumberingModules=Leave requests numbering models HolidaysNumberingModules=Leave requests numbering models
TemplatePDFHolidays=Template for leave requests PDF TemplatePDFHolidays=Template for leave requests PDF
FreeLegalTextOnHolidays=Free text on PDF FreeLegalTextOnHolidays=Free text on PDF
WatermarkOnDraftHolidayCards=Watermarks on draft leave requests WatermarkOnDraftHolidayCards=Watermarks on draft leave requests
HolidaysToApprove=Holidays to approve