Works on enhancement of project tasks

This commit is contained in:
Regis Houssin 2010-01-28 14:52:45 +00:00
parent 5c0d4b896b
commit cf13e466c5
3 changed files with 11 additions and 39 deletions

View File

@ -86,6 +86,8 @@ if ($_POST["action"] == 'add' && $user->rights->projet->creer)
$result = $project->create($user); $result = $project->create($user);
if ($result > 0) if ($result > 0)
{ {
$result = $project->add_contact($_POST["officer_project"], 'PROJECTLEADER', 'internal');
Header("Location:fiche.php?id=".$project->id); Header("Location:fiche.php?id=".$project->id);
exit; exit;
} }

View File

@ -48,9 +48,9 @@ if ($_POST["action"] == 'createtask' && $user->rights->projet->creer)
if (empty($_POST["cancel"])) if (empty($_POST["cancel"]))
{ {
if (empty($_POST['task_parent'])) if (empty($_POST['label']))
{ {
$mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("ChildOfTask")); $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Label"));
$_GET["action"]='create'; $_GET["action"]='create';
$error++; $error++;
} }
@ -59,11 +59,12 @@ if ($_POST["action"] == 'createtask' && $user->rights->projet->creer)
{ {
$tmparray=explode('_',$_POST['task_parent']); $tmparray=explode('_',$_POST['task_parent']);
$projectid=$tmparray[0]; $projectid=$tmparray[0];
if (empty($projectid)) $projectid = $_POST["projectid"]; // If projectid is ''
$task_parent=$tmparray[1]; $task_parent=$tmparray[1];
if (empty($task_parent)) $task_parent=0; // If task_parent is '' if (empty($task_parent)) $task_parent = 0; // If task_parent is ''
$task = new Task($db); $task = new Task($db);
$task->fk_project = $projectid; $task->fk_project = $projectid;
$task->label = $_POST["label"]; $task->label = $_POST["label"];
$task->description = $_POST['description']; $task->description = $_POST['description'];
@ -90,43 +91,12 @@ if ($_POST["action"] == 'createtask' && $user->rights->projet->creer)
} }
else else
{ {
Header("Location: ".DOL_URL_ROOT.'/projet/tasks/fiche.php?id='.$projectid); Header("Location: ".DOL_URL_ROOT.'/projet/tasks/task.php?id='.$taskid);
exit; exit;
} }
} }
} }
if ($_POST["action"] == 'addtime' && $user->rights->projet->creer)
{
$task = new Task($db);
$result = $task->fetch($_GET["id"]);
if ($result == 0)
{
foreach ($_POST as $key => $post)
{
//$pro->CreateTask($user, $_POST["task_name"]);
if (substr($key,0,4) == 'task')
{
if ($post > 0)
{
$post=intval($post)+(($post-intval($post))*(1+2/3));
$post=price2num($post);
$id = str_replace("task","",$key);
$date = dol_mktime(12,0,0,$_POST["$id"."month"],$_POST["$id"."day"],$_POST["$id"."year"]);
$task->addTimeSpent($user, $post, $date);
}
}
}
Header("Location:fiche.php?id=".$task->id);
exit;
}
}
/* /*
* View * View
*/ */
@ -157,13 +127,13 @@ if ($_GET["action"] == 'create' && $user->rights->projet->creer)
print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">'; print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">';
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="createtask">'; print '<input type="hidden" name="action" value="createtask">';
if ($_GET['id']) print '<input type="hidden" name="id" value="'.$_GET['id'].'">'; if ($_GET['id']) print '<input type="hidden" name="projectid" value="'.$_GET['id'].'">';
if ($_GET['mode']) print '<input type="hidden" name="mode" value="'.$_GET['mode'].'">'; if ($_GET['mode']) print '<input type="hidden" name="mode" value="'.$_GET['mode'].'">';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td>'.$langs->trans("Label").'</td><td>'; print '<tr><td>'.$langs->trans("Label").'</td><td>';
print '<input type="text" size="25" name="label" class="flat">'; print '<input type="text" size="25" name="label" class="flat" value="'.$_POST["label"].'">';
print '</td></tr>'; print '</td></tr>';
print '<tr><td>'.$langs->trans("ChildOfTask").'</td><td>'; print '<tr><td>'.$langs->trans("ChildOfTask").'</td><td>';

View File

@ -67,7 +67,7 @@ $task = new Task($db);
// 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, $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 = $task->getTasksRoleForUser($user); var_dump($tasksrole); $tasksrole = $task->getTasksRoleForUser($user);
$tasksrole=($_REQUEST["mode"]=='mine' ? $task->getTasksRoleForUser($user) : ''); $tasksrole=($_REQUEST["mode"]=='mine' ? $task->getTasksRoleForUser($user) : '');
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';