Works on enhancement of project tasks

This commit is contained in:
Regis Houssin 2010-01-28 08:52:41 +00:00
parent a15415e772
commit 354fa8a605
6 changed files with 66 additions and 21 deletions

View File

@ -4,7 +4,7 @@
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2006 Marc Barilley/Ocebo <marc@ocebo.com>
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerker@telenet.be>

View File

@ -4,7 +4,7 @@
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2006 Marc Barilley/Ocebo <marc@ocebo.com>
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerker@telenet.be>
@ -200,6 +200,37 @@ class FormOther
}
}
/**
* \brief Retourne une liste de pourcentage
* \param selected pourcentage pre-selectionne
* \param htmlname nom de la liste deroulante
* \param increment increment value
* \param start start value
* \param end end value
* \return return combo
*/
function select_percent($selected=0,$htmlname='percent',$increment=5,$start=0,$end=100)
{
$return = '<select class="flat" name="'.$htmlname.'">';
for ($i = $start ; $i <= $end ; $i += $increment)
{
if ($selected == $i)
{
$return.= '<option value="'.$i.'" selected="true">';
}
else
{
$return.= '<option value="'.$i.'">';
}
$return.= $i.' % ';
$return.= '</option>';
}
$return.= '</select>';
return $return;
}
/**
* \brief Retourn list of project and tasks
@ -217,7 +248,7 @@ class FormOther
//print $modeproject.'-'.$modetask;
$task=new Task($this->db);
$tasksarray=$task->getTasksArray($modetask?$user:0, $modeproject?$user:0, $mode);
$tasksarray=$task->getTasksArray($modetask?$user:0, $modeproject?$user:0, $selected);
if ($tasksarray)
{
print '<select class="flat" name="'.$htmlname.'">';
@ -296,7 +327,7 @@ class FormOther
$couleur = imagecolorallocate($image,$rouge,$vert,$bleu);
//print $rouge.$vert.$bleu;
imagefill($image,0,0,$couleur); //on remplit l'image
// On cree la couleur et on l'attribue <EFBFBD> une variable pour ne pas la perdre
// On cree la couleur et on l'attribue a une variable pour ne pas la perdre
ImagePng($image,$file); //renvoie une image sous format png
ImageDestroy($image);
}
@ -366,7 +397,7 @@ function PLineSelect(&$inc, $parent, $lines, $level=0)
{
print "&nbsp;&nbsp;&nbsp;";
}
print $lines[$i]->title."</option>\n";
print $lines[$i]->label."</option>\n";
$inc++;
}

View File

@ -5,7 +5,7 @@
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
*
* This program is free software; you can redistribute it and/or modify

View File

@ -137,12 +137,13 @@ function task_prepare_head($object)
*/
function select_projects($socid, $selected='', $htmlname='projectid')
{
global $db,$langs;
global $db,$conf,$langs;
// On recherche les projets
$sql = 'SELECT p.rowid, p.ref, p.title, p.fk_soc';
$sql.= ' FROM '.MAIN_DB_PREFIX .'projet as p';
$sql.= " WHERE (fk_soc='".$socid."' or fk_soc IS NULL)";
$sql.= " WHERE (p.fk_soc='".$socid."' OR p.fk_soc IS NULL)";
$sql.= " AND p.entity = ".$conf->entity;
$sql.= " ORDER BY p.title ASC";
dol_syslog("project.lib::select_projects sql=".$sql);
@ -447,7 +448,9 @@ function clean_orphelins($db)
// There is orphelins. We clean that
$listofid=array();
$sql='SELECT rowid from '.MAIN_DB_PREFIX.'projet_task';
$sql='SELECT rowid FROM '.MAIN_DB_PREFIX.'projet_task';
$resql = $db->query($sql);
if ($resql)
{
@ -469,13 +472,24 @@ function clean_orphelins($db)
{
// Removed orphelins records
print 'Some orphelins were found and restored to be parents so records are visible again.';
$sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task set fk_task_parent = 0 where fk_task_parent';
$sql.= ' NOT IN ('.join(',',$listofid).')';
$resql = $db->query($sql);
$nb=$db->affected_rows($sql);
$sql = "UPDATE ".MAIN_DB_PREFIX."projet_task";
$sql.= " SET fk_task_parent = 0";
$sql.= " WHERE fk_task_parent NOT IN (".join(',',$listofid).")";
$resql = $db->query($sql);
if ($resql)
{
$nb=$db->affected_rows($sql);
return $nb;
}
else
{
return -1;
}
}
return $nb;
}
?>

View File

@ -300,9 +300,9 @@ else
// Get list of tasks in tasksarray and taskarrayfiltered
// We need all tasks (even not limited to a user because a task to user
// can have a parent that is not affected to him).
$tasksarray=$task->getTasksArray(0, 0, 0);
$tasksarray=$task->getTasksArray(0, 0, $project->id);
// We load also tasks limited to a particular user
$tasksrole=($_REQUEST["mode"]=='mine' ? $task->getTasksRoleForUser($user) : '');
$tasksrole=($_REQUEST["mode"]=='mine' ? $task->getTasksRoleForUser($user,$project->id) : '');
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';

View File

@ -417,7 +417,7 @@ class Task extends CommonObject
* @param mode 0=Return list of tasks and their projects, 1=Return projects and tasks if exists
* @return array Array of tasks
*/
function getTasksArray($usert=0, $userp=0, $mode=0, $socid=0)
function getTasksArray($usert=0, $userp=0, $projectid=0, $socid=0)
{
global $conf;
@ -434,7 +434,7 @@ class Task extends CommonObject
$sql.= " WHERE t.fk_projet = p.rowid";
$sql.= " AND p.entity = ".$conf->entity;
if ($socid) $sql.= " AND p.fk_soc = ".$socid;
if ($this->id) $sql.= " AND t.fk_projet =".$this->id;
if ($projectid) $sql.= " AND t.fk_projet =".$projectid;
$sql.= " ORDER BY p.ref, t.label";
dol_syslog("Project::getTasksArray sql=".$sql, LOG_DEBUG);
@ -474,7 +474,7 @@ class Task extends CommonObject
* @param unknown_type $user
* @return unknown
*/
function getTasksRoleForUser($user)
function getTasksRoleForUser($user,$projectid=0)
{
$tasksrole = array();
@ -487,7 +487,7 @@ class Task extends CommonObject
$sql.= " AND ctc.element = '".$this->element."'";
$sql.= " AND ctc.rowid = ec.fk_c_type_contact";
$sql.= " AND ec.fk_socpeople = ".$user->id;
if ($this->id) $sql.= " AND pt.fk_projet =".$this->id;
if ($projectid) $sql.= " AND pt.fk_projet =".$projectid;
$resql = $this->db->query($sql);
if ($resql)