diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index 616355eab28..cb31107c65c 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -295,22 +295,28 @@ class FormProjets /** * Output a combo list with projects qualified for a third party * - * @param int $socid Id third party (-1=all, 0=only projects not linked to a third party, id=projects not linked or linked to third party id) - * @param int $selected Id task preselected - * @param string $htmlname Name of HTML select - * @param int $maxlength Maximum length of label - * @param int $option_only Return only html options lines without the select tag - * @param string $show_empty Add an empty line ('1' or string to show for empty line) - * @param int $discard_closed Discard closed projects (0=Keep,1=hide completely,2=Disable) - * @param int $forcefocus Force focus on field (works with javascript only) - * @param int $disabled Disabled - * @param string $morecss More css added to the select component - * @return int Nbr of project if OK, <0 if KO + * @param int $socid Id third party (-1=all, 0=only projects not linked to a third party, id=projects not linked or linked to third party id) + * @param int $selected Id task preselected + * @param string $htmlname Name of HTML select + * @param int $maxlength Maximum length of label + * @param int $option_only Return only html options lines without the select tag + * @param string $show_empty Add an empty line ('1' or string to show for empty line) + * @param int $discard_closed Discard closed projects (0=Keep,1=hide completely,2=Disable) + * @param int $forcefocus Force focus on field (works with javascript only) + * @param int $disabled Disabled + * @param string $morecss More css added to the select component + * @param User $usertofilter User object to use for filtering + * @return int Nbr of project if OK, <0 if KO */ - function selectTasks($socid=-1, $selected='', $htmlname='taskid', $maxlength=24, $option_only=0, $show_empty='1', $discard_closed=0, $forcefocus=0, $disabled=0, $morecss='maxwidth500') + function selectTasks($socid=-1, $selected='', $htmlname='taskid', $maxlength=24, $option_only=0, $show_empty='1', $discard_closed=0, $forcefocus=0, $disabled=0, $morecss='maxwidth500', $usertofilter=null) { global $user,$conf,$langs; + if(is_null($usertofilter)) + { + $usertofilter = $user; + } + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; $out=''; @@ -319,10 +325,10 @@ class FormProjets if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true; $projectsListId = false; - if (empty($user->rights->projet->all->lire)) + if (empty($usertofilter->rights->projet->all->lire)) { $projectstatic=new Project($this->db); - $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1); + $projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertofilter,0,1); } // Search all projects @@ -367,7 +373,7 @@ class FormProjets { $obj = $this->db->fetch_object($resql); // If we ask to filter on a company and user has no permission to see all companies and project is linked to another company, we hide project. - if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && empty($user->rights->societe->lire)) + if ($socid > 0 && (empty($obj->fk_soc) || $obj->fk_soc == $socid) && empty($usertofilter->rights->societe->lire)) { // Do nothing } diff --git a/htdocs/fichinter/stats/index.php b/htdocs/fichinter/stats/index.php index 1c0ba5764ed..3551d8baab3 100644 --- a/htdocs/fichinter/stats/index.php +++ b/htdocs/fichinter/stats/index.php @@ -30,7 +30,7 @@ $WIDTH=DolGraph::getDefaultGraphSizeForStats('width'); $HEIGHT=DolGraph::getDefaultGraphSizeForStats('height'); $mode='customer'; -if ($mode == 'customer' && ! $user->rights->ficheinter->lire) accessforbidden(); +if (! $user->rights->ficheinter->lire) accessforbidden(); $userid=GETPOST('userid','int'); $socid=GETPOST('socid','int'); @@ -49,10 +49,7 @@ $endyear=$year; $object_status=GETPOST('object_status'); -$langs->load('interventions'); -$langs->load('companies'); -$langs->load('other'); -$langs->load('suppliers'); +$langs->loadLangs(array('interventions', 'companies', 'other', 'suppliers')); /* @@ -62,11 +59,8 @@ $langs->load('suppliers'); $form=new Form($db); $objectstatic=new FichInter($db); -if ($mode == 'customer') -{ - $title=$langs->trans("InterventionStatistics"); - $dir=$conf->ficheinter->dir_temp; -} +$title=$langs->trans("InterventionStatistics"); +$dir=$conf->ficheinter->dir_temp; llxHeader('', $title); @@ -79,19 +73,18 @@ if ($object_status != '' && $object_status > -1) $stats->where .= ' AND c.fk_sta // Build graphic number of object $data = $stats->getNbByMonthWithPrevYear($endyear,$startyear); -//var_dump($data); // $data = array(array('Lib',val1,val2,val3),...) if (!$user->rights->societe->client->voir || $user->societe_id) { $filenamenb = $dir.'/interventionsnbinyear-'.$user->id.'-'.$year.'.png'; - if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsnbinyear-'.$user->id.'-'.$year.'.png'; + $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsnbinyear-'.$user->id.'-'.$year.'.png'; } else { $filenamenb = $dir.'/interventionsnbinyear-'.$year.'.png'; - if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsnbinyear-'.$year.'.png'; + $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsnbinyear-'.$year.'.png'; } $px1 = new DolGraph(); @@ -123,20 +116,17 @@ if (! $mesg) // Build graphic amount of object $data = $stats->getAmountByMonthWithPrevYear($endyear,$startyear); -//var_dump($data); // $data = array(array('Lib',val1,val2,val3),...) if (!$user->rights->societe->client->voir || $user->societe_id) { $filenameamount = $dir.'/interventionsamountinyear-'.$user->id.'-'.$year.'.png'; - if ($mode == 'customer') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsamountinyear-'.$user->id.'-'.$year.'.png'; - if ($mode == 'supplier') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstatssupplier&file=interventionsamountinyear-'.$user->id.'-'.$year.'.png'; + $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsamountinyear-'.$user->id.'-'.$year.'.png'; } else { $filenameamount = $dir.'/interventionsamountinyear-'.$year.'.png'; - if ($mode == 'customer') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsamountinyear-'.$year.'.png'; - if ($mode == 'supplier') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstatssupplier&file=interventionsamountinyear-'.$year.'.png'; + $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsamountinyear-'.$year.'.png'; } $px2 = new DolGraph(); @@ -171,14 +161,12 @@ $data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear); if (!$user->rights->societe->client->voir || $user->societe_id) { $filename_avg = $dir.'/interventionsaverage-'.$user->id.'-'.$year.'.png'; - if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsaverage-'.$user->id.'-'.$year.'.png'; - if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstatssupplier&file=interventionsaverage-'.$user->id.'-'.$year.'.png'; + $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsaverage-'.$user->id.'-'.$year.'.png'; } else { $filename_avg = $dir.'/interventionsaverage-'.$year.'.png'; - if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsaverage-'.$year.'.png'; - if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstatssupplier&file=interventionsaverage-'.$year.'.png'; + $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=interventionstats&file=interventionsaverage-'.$year.'.png'; } $px3 = new DolGraph(); @@ -221,13 +209,12 @@ if (! count($arrayyears)) $arrayyears[$nowyear]=$nowyear; $h=0; $head = array(); -$head[$h][0] = DOL_URL_ROOT . '/commande/stats/index.php?mode='.$mode; +$head[$h][0] = DOL_URL_ROOT . '/fichinter/stats/index.php'; $head[$h][1] = $langs->trans("ByMonthYear"); $head[$h][2] = 'byyear'; $h++; -if ($mode == 'customer') $type='order_stats'; -if ($mode == 'supplier') $type='supplier_order_stats'; +$type = 'fichinter_stats'; complete_head_from_modules($conf,$langs,null,$head,$h,$type); @@ -246,9 +233,8 @@ print '