Forum

[SOLVED] New report...
 
Notifications
Retirer tout

[SOLVED] New report "Work plan per week and per ressource" ?

3 Posts
2 Utilisateurs
0 Reactions
5,636 Vu
 Phil
(@phil-bzh)
Posts: 27
Active Member
Début du sujet
 
[#3502]

Hello,
In Follow-up / Reports / planning, it would be interesting to have a tabulated report "Work plan per week and per ressource" ?
Something like "work plan per week" but with a line per ressource.
Thank you.


 
Posté : 3 Juil PM 21:077
 Phil
(@phil-bzh)
Posts: 27
Active Member
Début du sujet
 

I've done it (finally per month and not per week) and sent it to the support for a future version if found useful.
In the meanwhile => file to put in the "report" directory and to name "reportPlanProjectPerRessourceAndMonth.php" :

<?php
/ COPYRIGHT NOTICE ******************************************************
*
* Copyright 2009-2015 ProjeQtOr - Pascal BERNARD - support@projeqtor.org
*
* This file is part of ProjeQtOr.
*
* ProjeQtOr is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option)
* any later version.
*
* ProjeQtOr is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* ProjeQtOr. If not, see .
*
* You can get complete code of ProjeQtOr, other resource, help and information
* about contributors at http://www.projeqtor.org
*
DO NOT REMOVE THIS NOTICE ******************************************/

/ In order to add the report :

INSERT INTO `report` (`id`, `name`, `idReportCategory`, `file`, `sortOrder`) VALUES (99, 'reportPlanProjectPerRessourceAndMonth', 2, 'reportPlanProjectPerRessourceAndMonth.php', 10)

INSERT INTO `habilitationreport` (`idProfile`,`idReport`,`allowAccess`) VALUES (1,99,1),(2,99,1),(3,99,1),(4,99,1)
(il est aussi possible de modifier les habilitations à la main dans Paramètres / Habilitation / Accès aux rapports)

INSERT INTO `reportparameter` (`idReport`, `name`, `paramType`, `sortOrder`, `defaultValue`) VALUES (99,'idProject','projectList',10,'currentProject'), (99,'idTeam','teamList',20,null), (99,'month','month',40,'currentMonth')

Pour les libellés internationaux : ajouter une ligne dans tooli18nnlsfrlang.js pour "reportPlanProjectPerRessourceAndMonth'

Forum : https://www.projeqtor.org/en/forum/3-propose-evolutions/7495-new-report-work-plan-per-week-and-per-ressource

***/

include_once '../tool/projeqtor.php';

$idProject="";
if (array_key_exists('idProject',$_REQUEST) and trim($_REQUEST['idProject'])!="") {
$idProject=trim($_REQUEST['idProject']);
$idProject = Security::checkValidId($idProject);
}
$paramYear='';
if (array_key_exists('yearSpinner',$_REQUEST)) {
$paramYear=$_REQUEST['yearSpinner'];
$paramYear=Security::checkValidYear($paramYear);
};
$paramMonth='';
if (array_key_exists('monthSpinner',$_REQUEST)) {
$paramMonth=$_REQUEST['monthSpinner'];
$paramMonth=Security::checkValidMonth($paramMonth);
};
$paramWeek='';
if (array_key_exists('weekSpinner',$_REQUEST)) {
$paramWeek=$_REQUEST['weekSpinner'];
$paramWeek=Security::checkValidWeek($paramWeek);
};
$paramTeam='';
if (array_key_exists('idTeam',$_REQUEST)) {
$paramTeam=trim($_REQUEST['idTeam']);
Security::checkValidId($paramTeam);
}
$scale='month';
if (array_key_exists('scale',$_REQUEST)) {
$scale=$_REQUEST['scale'];
$scale=Security::checkValidPeriodScale($scale);
}
$periodValue='';
if (array_key_exists('periodValue',$_REQUEST))
{
$periodValue=$_REQUEST['periodValue'];
$periodValue=Security::checkValidPeriod($periodValue);
}
$headerParameters="";
if ($idProject!="") {
$headerParameters.= i18n("colIdProject") . ' : ' . htmlEncode(SqlList::getNameFromId('Project',$idProject)) . '
';
}
if ( $paramTeam) {
$headerParameters.= i18n("team") . ' : ' . SqlList::getNameFromId('Team', $paramTeam) . '
';
}

include "header.php";

$accessRightRead=securityGetAccessRight('menuProject', 'read');

$user=getSessionUser();
$queryWhere=getAccesRestrictionClause('Activity','t1',false,true,true);

if ($idProject!='') {
$queryWhere.= " and t1.idProject in " . getVisibleProjectsList(true, $idProject) ;
} else {
//
}
// Remove Admin Projects : should not appear in Work Plan
$queryWhere.= " and t1.idProject not in " . Project::getAdminitrativeProjectList() ;

if ($periodValue) {
$queryWhere.= " and month>=".Sql::str($periodValue);
}

if ($paramTeam) {
$res=new Resource();
$lstRes=$res->getSqlElementsFromCriteria(array('idTeam'=>$paramTeam));
$inClause='(0';
foreach ($lstRes as $res) {
$inClause.=','.$res->id;
}
$inClause.=')';
$queryWhere.= " and t1.idResource in ".$inClause;
}

$querySelect= 'select t1.idResource, month, sum(work) as sumWork, ' . $scale . ' as scale , t2.id as idproject ';

$queryGroupBy = 't1.idresource,' .$scale . ', t1.idProject';
// constitute query and execute

$tab=array();
$start="";
$end="";
$prj=new Project();
$prjTable=$prj->getDatabaseTableName();
for ($i=1;$igetDatabaseTableName().' t1, '.$prjTable.' t2 '
. ' where ' . $queryWhere." and t1.idProject=t2.id "
. ' group by ' . $queryGroupBy
. ' order by t2.sortOrder asc, t1.idresource asc ';
$result=Sql::query($query);
//echo $query."

";

while ($line = Sql::fetchLine($result)) {
$line=array_change_key_case($line,CASE_LOWER);
$date=$line['scale'];
$proj=$line['idproject'];
$work=$line['sumwork']; //$work=round($line['sumwork'],2);
$ress=$line['idresource'];

$val = 0;
if (array_key_exists ($proj, $tab)) {
if (array_key_exists ($ress, $tab[$proj])) {
if (array_key_exists ($date, $tab[$proj][$ress]) ){
$val = $tab[$proj][$ress][$date];
}
}
}
$tab[$proj][$ress][$date]= $work+$val;
//echo "on écrit $work dans tab [$proj][$ress][$date] qui prend pour valeur".$tab[$proj][$ress][$date]."
";

if ($start=="" or $start>$date) {
$start=$date;
}
if ($end=="" or $end<$date) {
$end=$date;
}
}
}
if (checkNoData($tab)) exit;

$arrDates=array();
$arrYear=array();
$date=$start;
while ($date<=$end) {
$arrDates[]=$date;
$year=substr($date,0,4);
if (! array_key_exists($year,$arrYear)) {
$arrYear[$year]=0;
}
$arrYear[$year]+=1;

$day=substr($date,0,4) . '-' . substr($date,4,2) . '-01';
$next=addMonthsToDate($day,1);
$date=substr($next,0,4) . substr($next,5,2);

}

// Header

echo "

";
echo '

';

echo '

';
echo "

";
echo "

";
echo "

";
echo "

  " . Work::displayWorkUnit() . "  

";

echo "
";
echo '

';

// Affichage ligne des années
echo '

';
echo '

';
echo '

';
foreach ($arrYear as $year=>$nb) {
echo '

';
}
echo '

';
echo '

';

// Affichage ligne des mois
echo '

';
$arrSum=array();
foreach ($arrDates as $date) {
echo '

';
$arrSum[$date]=0;
}
echo '

';

$sumProj=array();
$sumProjUnit=array();

// parcours des projets

foreach($tab as $proj=>$projet) {
$sumProj[$proj]=array();
$sumProjUnit[$proj]=array();

echo '

';

foreach($tab[$proj] as $resource=>$ressource) {

echo '

';

$sum=0;
foreach($arrDates as $date) {
$val="";
if (array_key_exists ($date, $tab[$proj][$resource]) ) {
$val=$tab[$proj][$resource][$date];
}
echo '

';
} // fin du parcours des mois
echo '

';

echo '

';

} // fin des ressources

} // fin des projets

echo "

";
echo '

';

$sum=0;
$cumul=array();
$cumulUnit=array();
foreach ($arrSum as $date=>$val) {
echo '

';
$sum+=$val;
$cumul[$date]=$sum;
$cumulUnit[$date]=Work::displayWork($sum);
}

echo '

';
echo '

';

echo '

' . i18n('Project') . ' ' . i18n('Resource') . ' ' . $year . ' ' . i18n('sum') . '
';
echo substr($date,4,2);
echo '
' . htmlEncode(SqlList::getNameFromId('Project',$proj)) . ' ' . htmlEncode(SqlList::getNameFromId('Resource',$resource)) . ' ';
echo Work::displayWork($val);
$sum+=$val;
$arrSum[$date]+=$val;
echo '
';
echo Work::displayWork($sum);
echo '
 
' . i18n('sum') . ' ' . Work::displayWork($val) . ' ' . Work::displayWork($sum) . '

';

echo '

';

?>


 
Posté : 1 Nov PM 23:1111
(@babynus)
Posts: 14952
Membre Admin
 

It is included in next version.
Thanks.


 
Posté : 6 Nov PM 16:1111
Share:
Retour en haut