diff --git a/htdocs/includes/modules/project/pdf/pdf_baleine.modules.php b/htdocs/includes/modules/project/pdf/pdf_baleine.modules.php
index 6daf800068b..8681fcfde15 100644
--- a/htdocs/includes/modules/project/pdf/pdf_baleine.modules.php
+++ b/htdocs/includes/modules/project/pdf/pdf_baleine.modules.php
@@ -157,8 +157,8 @@ class pdf_baleine extends ModelePDFProjects
}
// Complete object by loading several other informations
- $tasks = $object->getTasksArray(0,0,1);
$task = new Task($this->db);
+ $tasksarray = $task->getTasksArray(0,0,1);
$pdf->Open();
$pagenb=0;
diff --git a/htdocs/projet/fiche.php b/htdocs/projet/fiche.php
index f2c9361745a..c7d7ac361e3 100644
--- a/htdocs/projet/fiche.php
+++ b/htdocs/projet/fiche.php
@@ -35,7 +35,7 @@ $langs->load("projects");
$langs->load('companies');
$projectid = (isset($_GET["id"])?$_GET["id"]:(isset($_POST["id"])?$_POST["id"]:''));
-$ref = (isset($_GET["ref"])?$_GET["ref"]:'');
+$projectref = (isset($_GET["ref"])?$_GET["ref"]:'');
// If socid provided by ajax company selector
if (! empty($_REQUEST['socid_id']))
@@ -45,7 +45,7 @@ if (! empty($_REQUEST['socid_id']))
$_REQUEST['socid'] = $_REQUEST['socid_id'];
}
-if ($projectid == '' && $ref == '' && ($_GET['action'] != "create" && $_POST['action'] != "add" && $_POST["action"] != "update" && !$_POST["cancel"])) accessforbidden();
+if ($projectid == '' && $projectref == '' && ($_GET['action'] != "create" && $_POST['action'] != "add" && $_POST["action"] != "update" && !$_POST["cancel"])) accessforbidden();
// Security check
if ($user->societe_id) $socid=$user->societe_id;
@@ -306,7 +306,7 @@ else
if ($mesg) print $mesg;
$project = new Project($db);
- $project->fetch($_GET["id"],$_GET["ref"]);
+ $project->fetch($projectid,$projectref);
if ($project->societe->id > 0) $result=$project->societe->fetch($project->societe->id);
if ($project->user_resp_id > 0) $result=$project->fetch_user($project->user_resp_id);
@@ -323,19 +323,19 @@ else
// Confirmation close
if ($_GET["action"] == 'close')
{
- $ret=$html->form_confirm($_SERVER["PHP_SELF"]."?id=".$_GET["id"],$langs->trans("CloseAProject"),$langs->trans("ConfirmCloseAProject"),"confirm_close",'','',1);
+ $ret=$html->form_confirm($_SERVER["PHP_SELF"]."?id=".$project->id,$langs->trans("CloseAProject"),$langs->trans("ConfirmCloseAProject"),"confirm_close",'','',1);
if ($ret == 'html') print '
';
}
// Confirmation reopen
if ($_GET["action"] == 'reopen')
{
- $ret=$html->form_confirm($_SERVER["PHP_SELF"]."?id=".$_GET["id"],$langs->trans("ReOpenAProject"),$langs->trans("ConfirmReOpenAProject"),"confirm_reopen",'','',1);
+ $ret=$html->form_confirm($_SERVER["PHP_SELF"]."?id=".$project->id,$langs->trans("ReOpenAProject"),$langs->trans("ConfirmReOpenAProject"),"confirm_reopen",'','',1);
if ($ret == 'html') print '
';
}
// Confirmation delete
if ($_GET["action"] == 'delete')
{
- $ret=$html->form_confirm($_SERVER["PHP_SELF"]."?id=".$_GET["id"],$langs->trans("DeleteAProject"),$langs->trans("ConfirmDeleteAProject"),"confirm_delete",'','',1);
+ $ret=$html->form_confirm($_SERVER["PHP_SELF"]."?id=".$project->id,$langs->trans("DeleteAProject"),$langs->trans("ConfirmDeleteAProject"),"confirm_delete",'','',1);
if ($ret == 'html') print '
';
}
@@ -345,7 +345,7 @@ else
print '
';
}
@@ -434,7 +436,7 @@ else
// Validate
if ($project->statut == 0 && $user->rights->projet->creer)
{
- print ''.$langs->trans("Valid").'';
}
@@ -485,40 +487,6 @@ else
$somethingshown=$formfile->show_documents('project',$filename,$filedir,$urlsource,$genallowed,$delallowed,$project->modelpdf);
-
- /*
- * Commandes rattachees
- */
-/* if($conf->commande->enabled)
- {
- $propal->loadOrders();
- $coms = $propal->commandes;
- if (sizeof($coms) > 0)
- {
- if ($somethingshown) { print '
'; $somethingshown=1; }
- print_titre($langs->trans('RelatedOrders'));
- print '';
- print '';
- print '| '.$langs->trans("Ref").' | ';
- print ''.$langs->trans("Date").' | ';
- print ''.$langs->trans("Price").' | ';
- print ''.$langs->trans("Status").' | ';
- print '
';
- $var=true;
- for ($i = 0 ; $i < sizeof($coms) ; $i++)
- {
- $var=!$var;
- print '| ';
- print ''.img_object($langs->trans("ShowOrder"),"order").' '.$coms[$i]->ref." | \n";
- print ''.dol_print_date($coms[$i]->date,'day').' | ';
- print ''.price($coms[$i]->total_ttc).' | ';
- print ''.$coms[$i]->getLibStatut(3).' | ';
- print "
\n";
- }
- print '
';
- }
- }
-*/
print '';
// List of actions on element
@@ -529,7 +497,6 @@ else
print ' | ';
}
-
}
$db->close();
diff --git a/htdocs/projet/project.class.php b/htdocs/projet/project.class.php
index 3b265c7f07b..053e2256c25 100644
--- a/htdocs/projet/project.class.php
+++ b/htdocs/projet/project.class.php
@@ -550,46 +550,6 @@ class Project extends CommonObject
return $result;
}
- /**
- * Return array of role of user for each projects
- *
- * @param unknown_type $user
- * @return unknown
- */
- function getTasksRoleForUser($user)
- {
- $tasksrole = array();
-
- /* Liste des taches et role sur la tache du user courant dans $tasksrole */
- $sql = "SELECT a.fk_projet_task, a.role";
- $sql.= " FROM ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."projet_task_actors as a";
- $sql.= " WHERE pt.rowid = a.fk_projet_task";
- $sql.= " AND a.fk_user = ".$user->id;
- if ($this->id) $sql.= " AND pt.fk_projet =".$this->id;
-
- $resql = $this->db->query($sql);
- if ($resql)
- {
- $num = $this->db->num_rows($resql);
- $i = 0;
- while ($i < $num)
- {
- $row = $this->db->fetch_row($resql);
- $tasksrole[$row[0]] = $row[1];
- $i++;
- }
- $this->db->free();
- }
- else
- {
- dol_print_error($this->db);
- }
-
- return $tasksrole;
- }
-
-
-
/**
* \brief Return status label of object
* \param mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
diff --git a/htdocs/projet/tasks/fiche.php b/htdocs/projet/tasks/fiche.php
index 9f30e43a900..90a523b2524 100644
--- a/htdocs/projet/tasks/fiche.php
+++ b/htdocs/projet/tasks/fiche.php
@@ -276,7 +276,7 @@ else
// can have a parent that is not affected to him).
$tasksarray=$task->getTasksArray(0, 0, 0);
// We load also tasks limited to a particular user
- $tasksrole=($_REQUEST["mode"]=='mine' ? $project->getTasksRoleForUser($user) : '');
+ $tasksrole=($_REQUEST["mode"]=='mine' ? $task->getTasksRoleForUser($user) : '');
print '';
print '';
diff --git a/htdocs/projet/tasks/index.php b/htdocs/projet/tasks/index.php
index b3dee5d4b7b..6cc6302e6a3 100644
--- a/htdocs/projet/tasks/index.php
+++ b/htdocs/projet/tasks/index.php
@@ -1,7 +1,7 @@
* Copyright (C) 2006-2009 Laurent Destailleur
- * Copyright (C) 2006-2009 Regis Houssin
+ * Copyright (C) 2006-2010 Regis Houssin
*
* 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
@@ -44,26 +44,6 @@ $page = is_numeric($page) ? $page : 0;
$page = $page == -1 ? 0 : $page;
-
-/*
- * Actions
- */
-
-if ($_POST["action"] == 'createtask' && $user->rights->projet->creer)
-{
- $project = new Project($db);
-
- $result = $project->fetch($_GET["id"]);
-
- if ($result == 0)
- {
- $task_parent = $_POST["task_parent"]?$_POST["task_parent"]:0;
- $project->CreateTask($user, $_POST["task_name"], $task_parent);
-
- Header("Location:fiche.php?id=".$project->id);
- }
-}
-
/*
* View
*/
@@ -79,15 +59,15 @@ llxHeader("",$title,"Projet");
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num);
-$project = new Project($db);
+$task = new Task($db);
// 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=$project->getTasksArray(0, 0, 0, $socid);
+$tasksarray=$task->getTasksArray(0, 0, 0, $socid);
// We load also tasks limited to a particular user
-$tasksrole=($_REQUEST["mode"]=='mine' ? $project->getTasksRoleForUser($user) : '');
+$tasksrole=($_REQUEST["mode"]=='mine' ? $task->getTasksRoleForUser($user) : '');
print '';
print '';
diff --git a/htdocs/projet/tasks/task.class.php b/htdocs/projet/tasks/task.class.php
index 9587fa2cf16..baf0a870a48 100644
--- a/htdocs/projet/tasks/task.class.php
+++ b/htdocs/projet/tasks/task.class.php
@@ -497,6 +497,45 @@ class Task extends CommonObject
return $tasks;
}
+
+ /**
+ * Return array of role of user for each projects
+ *
+ * @param unknown_type $user
+ * @return unknown
+ */
+ function getTasksRoleForUser($user)
+ {
+ $tasksrole = array();
+
+ /* Liste des taches et role sur la tache du user courant dans $tasksrole */
+ $sql = "SELECT a.fk_projet_task, a.role";
+ $sql.= " FROM ".MAIN_DB_PREFIX."projet_task as pt";
+ $sql.= ", ".MAIN_DB_PREFIX."projet_task_actors as a";
+ $sql.= " WHERE pt.rowid = a.fk_projet_task";
+ $sql.= " AND a.fk_user = ".$user->id;
+ if ($this->id) $sql.= " AND pt.fk_projet =".$this->id;
+
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ $num = $this->db->num_rows($resql);
+ $i = 0;
+ while ($i < $num)
+ {
+ $row = $this->db->fetch_row($resql);
+ $tasksrole[$row[0]] = $row[1];
+ $i++;
+ }
+ $this->db->free();
+ }
+ else
+ {
+ dol_print_error($this->db);
+ }
+
+ return $tasksrole;
+ }
}
?>
\ No newline at end of file