Skip to content
Snippets Groups Projects
Commit f25bb79d authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Merge pull request #1672 from defrance69/patch-19

Add project and task boxes
parents 534e5743 b34947b3
No related branches found
No related tags found
No related merge requests found
......@@ -24,7 +24,6 @@
*/
include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php';
/**
* Class to manage the box to show last invoices
*/
......@@ -159,4 +158,4 @@ class box_factures extends ModeleBoxes
}
}
?>
\ No newline at end of file
<?php
/* Copyright (C) 2012-2014 Charles-François BENKE <charles.fr@benke.fr>
* This program 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/core/boxes/box_activite.php
* \ingroup projet
* \brief Module to show Projet activity of the current Year
*/
include_once(DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php");
/**
* Class to manage the box to show last projet
*/
class box_project extends ModeleBoxes
{
var $boxcode="project";
var $boximg="object_projectpub";
var $boxlabel;
//var $depends = array("projet");
var $db;
var $param;
var $info_box_head = array();
var $info_box_contents = array();
/**
* \brief Constructeur de la classe
*/
function box_project()
{
global $langs;
$langs->load("boxes");
$langs->load("projects");
$this->boxlabel="Projet";
}
/**
* Load data for box to show them later
*
* @param int $max Maximum number of records to load
* @return void
*/
function loadBox($max=5)
{
global $conf, $user, $langs, $db;
$this->max=$max;
$totalMnt = 0;
$totalnb = 0;
$totalnbTask=0;
include_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/project.lib.php");
$projectstatic=new Project($db);
$textHead = $langs->trans("Projet");
$this->info_box_head = array('text' => $textHead, 'limit'=> dol_strlen($textHead));
// list the summary of the orders
if ($user->rights->projet->lire)
{
$sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut ";
$sql.= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."projet as p";
$sql.= ")";
$sql.= " WHERE p.fk_soc = s.rowid";
$sql.= " AND s.entity = ".$conf->entity;
$sql.= " AND p.fk_statut = 1"; // Seulement les projets ouverts
$sql.= " ORDER BY p.datec DESC";
$sql.= $db->plimit($max, 0);
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
$i = 0;
while ($i < $num)
{
$this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"','logo' => 'object_projectpub');
$objp = $db->fetch_object($result);
$projectstatic->fetch($objp->rowid);
$this->info_box_contents[$i][1] = array('td' => 'align="left"',
'text' =>$projectstatic->getNomUrl(1)
);
$this->info_box_contents[$i][2] = array('td' => 'align="left"',
'text' => $objp->title
);
$sql ="SELECT count(*) as nb, sum(progress) as totprogress";
$sql.=" FROM ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."projet as p";
$sql.=" WHERE pt.fk_projet = p.rowid";
$sql.=" AND p.entity = ".$conf->entity;
$resultTask = $db->query($sql);
if ($resultTask)
{
$objTask = $db->fetch_object($resultTask);
$this->info_box_contents[$i][3] = array('td' => 'align="right"', 'text' => number_format($objTask->nb, 0, ',', ' ')."&nbsp;".$langs->trans("Tasks"));
if ($objTask->nb > 0 )
$this->info_box_contents[$i][4] = array('td' => 'align="right"', 'text' => number_format(($objTask->totprogress/$objTask->nb), 0, ',', ' ')." %&nbsp;".$langs->trans("Progress"));
else
$this->info_box_contents[$i][4] = array('td' => 'align="right"', 'text' => "N/A&nbsp;");
$totalnbTask += $objTask->nb;
}
else
{
$this->info_box_contents[$i][3] = array('td' => 'align="right"', 'text' => number_format(0, 0, ',', ' '));
$this->info_box_contents[$i][4] = array('td' => 'align="right"', 'text' => "N/A&nbsp;");
}
$i++;
}
}
}
// Add the sum à the bottom of the boxes
$this->info_box_contents[$i][0] = array('tr' => 'class="liste_total"', 'td' => 'colspan=2 align="left" ', 'text' => $langs->trans("Total")."&nbsp;".$textHead);
$this->info_box_contents[$i][1] = array('td' => 'align="right" ', 'text' => number_format($num, 0, ',', ' ')."&nbsp;".$langs->trans("Projects"));
$this->info_box_contents[$i][2] = array('td' => 'align="right" ', 'text' => number_format($totalnbTask, 0, ',', ' ')."&nbsp;".$langs->trans("Tasks"));
$this->info_box_contents[$i][4] = array('td' => 'colspan=2', 'text' => "");
}
/**
* Method to show box
*
* @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines
* @return void
*/
function showBox($head = null, $contents = null)
{
parent::showBox($this->info_box_head, $this->info_box_contents);
}
}
?>
<?php
/* Copyright (C) 2012-2014 Charles-François BENKE <charles.fr@benke.fr>
* This program 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/core/boxes/box_task.php
* \ingroup Projet
* \brief Module to Task activity of the current year
* \version $Id: box_task.php,v 1.1 2012/09/11 Charles-François BENKE
*/
include_once(DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php");
/**
* Class to manage the box to show last task
*/
class box_task extends ModeleBoxes
{
var $boxcode="projet";
var $boximg="object_projecttask";
var $boxlabel;
//var $depends = array("projet");
var $db;
var $param;
var $info_box_head = array();
var $info_box_contents = array();
/**
* \brief Constructeur de la classe
*
* @return void
*/
function box_task()
{
global $langs;
$langs->load("boxes");
$langs->load("projects");
$this->boxlabel="Tasks";
}
/**
* Load data for box to show them later
*
* @param int $max Maximum number of records to load
* @return void
*/
function loadBox($max=5)
{
global $conf, $user, $langs, $db;
$this->max=$max;
$totalMnt = 0;
$totalnb = 0;
$totalDuree=0;
include_once(DOL_DOCUMENT_ROOT."/projet/class/task.class.php");
$taskstatic=new Task($db);
$textHead = $langs->trans("Tasks")."&nbsp;".date("Y");
$this->info_box_head = array('text' => $textHead, 'limit'=> dol_strlen($textHead));
// list the summary of the orders
if ($user->rights->projet->lire)
{
$sql = "SELECT pt.fk_statut, count(pt.rowid) as nb, sum(ptt.task_duration) as durationtot, sum(pt.planned_workload) as plannedtot";
$sql.= " FROM ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."projet_task_time as ptt";
$sql.= " WHERE DATE_FORMAT(pt.datec,'%Y') = ".date("Y")." ";
$sql.= " AND pt.rowid = ptt.fk_task";
$sql.= " GROUP BY pt.fk_statut ";
$sql.= " ORDER BY pt.fk_statut DESC";
$sql.= $db->plimit($max, 0);
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
$i = 0;
while ($i < $num)
{
$this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"','logo' => 'object_projecttask');
$objp = $db->fetch_object($result);
$this->info_box_contents[$i][1] = array('td' => 'align="left"',
'text' =>$langs->trans("Task")."&nbsp;".$taskstatic->LibStatut($objp->fk_statut,0)
);
$this->info_box_contents[$i][2] = array('td' => 'align="right"',
'text' => $objp->nb."&nbsp;".$langs->trans("Tasks"),
'url' => DOL_URL_ROOT."/projet/tasks/index.php?leftmenu=projects&viewstatut=".$objp->fk_statut
);
$totalnb += $objp->nb;
$this->info_box_contents[$i][3] = array('td' => 'align="right"', 'text' => ConvertSecondToTime($objp->plannedtot,'all',25200,5));
$totalplannedtot += $objp->plannedtot;
$this->info_box_contents[$i][4] = array('td' => 'align="right"', 'text' => ConvertSecondToTime($objp->durationtot,'all',25200,5));
$totaldurationtot += $objp->durationtot;
$this->info_box_contents[$i][5] = array('td' => 'align="right" width="18"', 'text' => $taskstatic->LibStatut($objp->fk_statut,3));
$i++;
}
}
}
// Add the sum à the bottom of the boxes
$this->info_box_contents[$i][0] = array('tr' => 'class="liste_total"', 'td' => 'colspan=2 align="left" ', 'text' => $langs->trans("Total")."&nbsp;".$textHead);
$this->info_box_contents[$i][1] = array('td' => 'align="right" ', 'text' => number_format($totalnb, 0, ',', ' ')."&nbsp;".$langs->trans("Tasks"));
$this->info_box_contents[$i][2] = array('td' => 'align="right" ', 'text' => ConvertSecondToTime($totalplannedtot,'all',25200,5));
$this->info_box_contents[$i][3] = array('td' => 'align="right" ', 'text' => ConvertSecondToTime($totaldurationtot,'all',25200,5));
$this->info_box_contents[$i][4] = array('td' => 'colspan=2', 'text' => "");
}
/**
* Method to show box
*
* @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines
* @return void
*/
function showBox($head = null, $contents = null)
{
parent::showBox($this->info_box_head, $this->info_box_contents);
}
}
?>
......@@ -5,6 +5,7 @@
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Charles-Fr BENKE <charles.fr@benke.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -116,6 +117,11 @@ class modProjet extends DolibarrModules
// Boxes
$this->boxes = array();
$r=0;
$this->boxes[$r][1] = "box_project.php";
$r++;
$this->boxes[$r][1] = "box_task.php";
$r++;
// Permissions
$this->rights = array();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment