Works on enhancement of project tasks
Fix: use task.class.php
This commit is contained in:
parent
b8954be4e5
commit
4223eacb7a
@ -157,8 +157,8 @@ class pdf_baleine extends ModelePDFProjects
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Complete object by loading several other informations
|
// Complete object by loading several other informations
|
||||||
$tasks = $object->getTasksArray(0,0,1);
|
|
||||||
$task = new Task($this->db);
|
$task = new Task($this->db);
|
||||||
|
$tasksarray = $task->getTasksArray(0,0,1);
|
||||||
|
|
||||||
$pdf->Open();
|
$pdf->Open();
|
||||||
$pagenb=0;
|
$pagenb=0;
|
||||||
|
|||||||
@ -35,7 +35,7 @@ $langs->load("projects");
|
|||||||
$langs->load('companies');
|
$langs->load('companies');
|
||||||
|
|
||||||
$projectid = (isset($_GET["id"])?$_GET["id"]:(isset($_POST["id"])?$_POST["id"]:''));
|
$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 socid provided by ajax company selector
|
||||||
if (! empty($_REQUEST['socid_id']))
|
if (! empty($_REQUEST['socid_id']))
|
||||||
@ -45,7 +45,7 @@ if (! empty($_REQUEST['socid_id']))
|
|||||||
$_REQUEST['socid'] = $_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
|
// Security check
|
||||||
if ($user->societe_id) $socid=$user->societe_id;
|
if ($user->societe_id) $socid=$user->societe_id;
|
||||||
@ -306,7 +306,7 @@ else
|
|||||||
if ($mesg) print $mesg;
|
if ($mesg) print $mesg;
|
||||||
|
|
||||||
$project = new Project($db);
|
$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->societe->id > 0) $result=$project->societe->fetch($project->societe->id);
|
||||||
if ($project->user_resp_id > 0) $result=$project->fetch_user($project->user_resp_id);
|
if ($project->user_resp_id > 0) $result=$project->fetch_user($project->user_resp_id);
|
||||||
@ -323,19 +323,19 @@ else
|
|||||||
// Confirmation close
|
// Confirmation close
|
||||||
if ($_GET["action"] == '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 '<br>';
|
if ($ret == 'html') print '<br>';
|
||||||
}
|
}
|
||||||
// Confirmation reopen
|
// Confirmation reopen
|
||||||
if ($_GET["action"] == '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 '<br>';
|
if ($ret == 'html') print '<br>';
|
||||||
}
|
}
|
||||||
// Confirmation delete
|
// Confirmation delete
|
||||||
if ($_GET["action"] == '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 '<br>';
|
if ($ret == 'html') print '<br>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -345,7 +345,7 @@ else
|
|||||||
print '<form method="post" action="fiche.php">';
|
print '<form method="post" action="fiche.php">';
|
||||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
print '<input type="hidden" name="action" value="update">';
|
print '<input type="hidden" name="action" value="update">';
|
||||||
print '<input type="hidden" name="id" value="'.$_GET["id"].'">';
|
print '<input type="hidden" name="id" value="'.$project->id.'">';
|
||||||
|
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
@ -378,7 +378,9 @@ else
|
|||||||
print $html->select_date($project->date_end?$project->date_end:-1,'projectend');
|
print $html->select_date($project->date_end?$project->date_end:-1,'projectend');
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
print '<tr><td align="center" colspan="2"><input name="update" class="button" type="submit" value="'.$langs->trans("Modify").'"> <input type="submit" class="button" name="cancel" Value="'.$langs->trans("Cancel").'"></td></tr>';
|
print '<tr><td align="center" colspan="2">';
|
||||||
|
print '<input name="update" class="button" type="submit" value="'.$langs->trans("Modify").'"> ';
|
||||||
|
print '<input type="submit" class="button" name="cancel" Value="'.$langs->trans("Cancel").'"></td></tr>';
|
||||||
print '</table>';
|
print '</table>';
|
||||||
print '</form>';
|
print '</form>';
|
||||||
}
|
}
|
||||||
@ -434,7 +436,7 @@ else
|
|||||||
// Validate
|
// Validate
|
||||||
if ($project->statut == 0 && $user->rights->projet->creer)
|
if ($project->statut == 0 && $user->rights->projet->creer)
|
||||||
{
|
{
|
||||||
print '<a class="butAction" href="fiche.php?id='.$_GET["id"].'&action=validate"';
|
print '<a class="butAction" href="fiche.php?id='.$project->id.'&action=validate"';
|
||||||
print '>'.$langs->trans("Valid").'</a>';
|
print '>'.$langs->trans("Valid").'</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -485,40 +487,6 @@ else
|
|||||||
|
|
||||||
$somethingshown=$formfile->show_documents('project',$filename,$filedir,$urlsource,$genallowed,$delallowed,$project->modelpdf);
|
$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 '<br>'; $somethingshown=1; }
|
|
||||||
print_titre($langs->trans('RelatedOrders'));
|
|
||||||
print '<table class="noborder" width="100%">';
|
|
||||||
print '<tr class="liste_titre">';
|
|
||||||
print '<td>'.$langs->trans("Ref").'</td>';
|
|
||||||
print '<td align="center">'.$langs->trans("Date").'</td>';
|
|
||||||
print '<td align="right">'.$langs->trans("Price").'</td>';
|
|
||||||
print '<td align="right">'.$langs->trans("Status").'</td>';
|
|
||||||
print '</tr>';
|
|
||||||
$var=true;
|
|
||||||
for ($i = 0 ; $i < sizeof($coms) ; $i++)
|
|
||||||
{
|
|
||||||
$var=!$var;
|
|
||||||
print '<tr '.$bc[$var].'><td>';
|
|
||||||
print '<a href="'.DOL_URL_ROOT.'/commande/fiche.php?id='.$coms[$i]->id.'">'.img_object($langs->trans("ShowOrder"),"order").' '.$coms[$i]->ref."</a></td>\n";
|
|
||||||
print '<td align="center">'.dol_print_date($coms[$i]->date,'day').'</td>';
|
|
||||||
print '<td align="right">'.price($coms[$i]->total_ttc).'</td>';
|
|
||||||
print '<td align="right">'.$coms[$i]->getLibStatut(3).'</td>';
|
|
||||||
print "</tr>\n";
|
|
||||||
}
|
|
||||||
print '</table>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
print '</td><td valign="top" width="50%">';
|
print '</td><td valign="top" width="50%">';
|
||||||
|
|
||||||
// List of actions on element
|
// List of actions on element
|
||||||
@ -529,7 +497,6 @@ else
|
|||||||
print '</td></tr></table>';
|
print '</td></tr></table>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|||||||
@ -550,46 +550,6 @@ class Project extends CommonObject
|
|||||||
return $result;
|
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
|
* \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
|
* \param mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
|
||||||
|
|||||||
@ -276,7 +276,7 @@ else
|
|||||||
// can have a parent that is not affected to him).
|
// can have a parent that is not affected to him).
|
||||||
$tasksarray=$task->getTasksArray(0, 0, 0);
|
$tasksarray=$task->getTasksArray(0, 0, 0);
|
||||||
// We load also tasks limited to a particular user
|
// We load also tasks limited to a particular user
|
||||||
$tasksrole=($_REQUEST["mode"]=='mine' ? $project->getTasksRoleForUser($user) : '');
|
$tasksrole=($_REQUEST["mode"]=='mine' ? $task->getTasksRoleForUser($user) : '');
|
||||||
|
|
||||||
print '<table class="noborder" width="100%">';
|
print '<table class="noborder" width="100%">';
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2006-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2006-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2006-2009 Regis Houssin <regis@dolibarr.fr>
|
* Copyright (C) 2006-2010 Regis Houssin <regis@dolibarr.fr>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* 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;
|
$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
|
* View
|
||||||
*/
|
*/
|
||||||
@ -79,15 +59,15 @@ llxHeader("",$title,"Projet");
|
|||||||
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num);
|
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
|
// Get list of tasks in tasksarray and taskarrayfiltered
|
||||||
// We need all tasks (even not limited to a user because a task to user
|
// 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).
|
// 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
|
// We load also tasks limited to a particular user
|
||||||
$tasksrole=($_REQUEST["mode"]=='mine' ? $project->getTasksRoleForUser($user) : '');
|
$tasksrole=($_REQUEST["mode"]=='mine' ? $task->getTasksRoleForUser($user) : '');
|
||||||
|
|
||||||
print '<table class="noborder" width="100%">';
|
print '<table class="noborder" width="100%">';
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
|
|||||||
@ -497,6 +497,45 @@ class Task extends CommonObject
|
|||||||
|
|
||||||
return $tasks;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
Loading…
Reference in New Issue
Block a user