Fix and restore a lot of broken features in the project module. Must try to restore a stable module to start a release.

This commit is contained in:
Laurent Destailleur 2010-02-07 02:39:01 +00:00
parent ad308ad087
commit 382f11a514
16 changed files with 137 additions and 206 deletions

View File

@ -2587,6 +2587,7 @@ class Form
* \param option Valeur de l'option en fonction du type choisi * \param option Valeur de l'option en fonction du type choisi
* \param translate Traduire la valeur * \param translate Traduire la valeur
* \param maxlen Length maximum for labels * \param maxlen Length maximum for labels
* \return string HTML select string
*/ */
function selectarray($htmlname, $array, $id='', $show_empty=0, $key_in_label=0, $value_as_key=0, $optionType=0, $option='', $translate=0, $maxlen=0) function selectarray($htmlname, $array, $id='', $show_empty=0, $key_in_label=0, $value_as_key=0, $optionType=0, $option='', $translate=0, $maxlen=0)
{ {

View File

@ -313,14 +313,15 @@ class FormFile
{ {
print '<td align="center">'; print '<td align="center">';
print $langs->trans('Model').' '; print $langs->trans('Model').' ';
$html->select_array('model',$modellist,$modelselected,0,0,1); print $html->selectarray('model',$modellist,$modelselected,0,0,1);
print '</td>';
} }
else else
{ {
print '<td align="left">'; print '<td align="left">';
print $langs->trans("Files"); print $langs->trans("Files");
print '</td>';
} }
print '</td>';
print '<td align="center">'; print '<td align="center">';
if($conf->global->MAIN_MULTILANGS && ! $forcenomultilang) if($conf->global->MAIN_MULTILANGS && ! $forcenomultilang)
{ {
@ -334,7 +335,7 @@ class FormFile
} }
print '</td>'; print '</td>';
print '<td align="center" colspan="'.($delallowed?'2':'1').'">'; print '<td align="center" colspan="'.($delallowed?'2':'1').'">';
print '<input class="button" type="submit" value="'.$buttonlabel.'">'; print '<input class="button" '.((is_array($modellist) && sizeof($modellist))?'':' disabled="true"').' type="submit" value="'.$buttonlabel.'">';
print '</td></tr>'; print '</td></tr>';
} }

View File

@ -241,7 +241,7 @@ class FormOther
* \param modetask 1 to restrict on tasks associated to user * \param modetask 1 to restrict on tasks associated to user
* \param mode 0=Return list of tasks and their projects, 1=Return projects and tasks if exists * \param mode 0=Return list of tasks and their projects, 1=Return projects and tasks if exists
*/ */
function selectProjectTasks($selected='', $projectid=0, $htmlname='task_parent', $modeproject=0, $modetask=0) function selectProjectTasks($selected='', $projectid=0, $htmlname='task_parent', $modeproject=0, $modetask=0, $mode=0)
{ {
global $user, $langs; global $user, $langs;
@ -249,7 +249,7 @@ class FormOther
//print $modeproject.'-'.$modetask; //print $modeproject.'-'.$modetask;
$task=new Task($this->db); $task=new Task($this->db);
$tasksarray=$task->getTasksArray($modetask?$user:0, $modeproject?$user:0, $projectid); $tasksarray=$task->getTasksArray($modetask?$user:0, $modeproject?$user:0, $projectid, 0, $mode);
if ($tasksarray) if ($tasksarray)
{ {
print '<select class="flat" name="'.$htmlname.'">'; print '<select class="flat" name="'.$htmlname.'">';

View File

@ -189,6 +189,7 @@ function project_pdf_create($db, $comid, $modele,$outputlangs)
return 0; return 0;
} }
} }
// Charge le modele // Charge le modele
$file = "pdf_".$modele.".modules.php"; $file = "pdf_".$modele.".modules.php";
if (file_exists($dir.$file)) if (file_exists($dir.$file))

View File

@ -158,7 +158,7 @@ class pdf_baleine extends ModelePDFProjects
// Complete object by loading several other informations // Complete object by loading several other informations
$task = new Task($this->db); $task = new Task($this->db);
$tasksarray = $task->getTasksArray(0,0,1); $tasksarray = $task->getTasksArray(0,0,$object->id);
$pdf->Open(); $pdf->Open();
$pagenb=0; $pagenb=0;

View File

@ -287,7 +287,7 @@ function PLinesb(&$inc, $parent, $lines, &$level, &$tasksrole)
* @param $level Level of task * @param $level Level of task
* @param $var Color * @param $var Color
* @param $showproject Show project columns * @param $showproject Show project columns
* @param $taskrole Array of task filtered on a particular user * @param $taskrole Array of tasks filtered on a particular user
*/ */
function PLines(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole) function PLines(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole)
{ {

View File

@ -111,7 +111,7 @@ print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorde
if ($mesg) print $mesg; if ($mesg) print $mesg;
$tasksarray=$task->getTasksArray(0,0,$project->id,0); $tasksarray=$task->getTasksArray(0,0,$project->id,0);
$tasksrole=$task->getTasksForProjectOwnedByAUser($user,0,$project->id,0); $tasksrole=$task->getUserRolesForProjetsOrTasks($user,0,$project->id,0);
//var_dump($tasksarray); //var_dump($tasksarray);
print '<form name="addtime" method="POST" action="'.$_SERVER["PHP_SELF"].'?id='.$project->id.'">'; print '<form name="addtime" method="POST" action="'.$_SERVER["PHP_SELF"].'?id='.$project->id.'">';

View File

@ -273,30 +273,33 @@ if ($id > 0 || ! empty($ref))
print '<input type="hidden" name="source" value="external">'; print '<input type="hidden" name="source" value="external">';
print '<input type="hidden" name="id" value="'.$id.'">'; print '<input type="hidden" name="id" value="'.$id.'">';
// Ligne ajout pour contact externe // Line to add external contact. Only if project is linked to a third party.
$var=!$var; if ($project->societe->id)
print "<tr $bc[$var]>"; {
$var=!$var;
print "<tr $bc[$var]>";
print '<td nowrap="nowrap">'; print '<td nowrap="nowrap">';
print img_object('','contact').' '.$langs->trans("ThirdPartyContacts"); print img_object('','contact').' '.$langs->trans("ThirdPartyContacts");
print '</td>'; print '</td>';
print '<td colspan="1">'; print '<td colspan="1">';
$selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$project->societe->id; $selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$project->societe->id;
$selectedCompany = $formcompany->selectCompaniesForNewContact($project, 'id', $selectedCompany, 'newcompany'); $selectedCompany = $formcompany->selectCompaniesForNewContact($project, 'id', $selectedCompany, 'newcompany');
print '</td>'; print '</td>';
print '<td colspan="1">'; print '<td colspan="1">';
$nbofcontacts=$html->select_contacts($selectedCompany,'','contactid',0); $nbofcontacts=$html->select_contacts($selectedCompany,'','contactid',0);
if ($nbofcontacts == 0) print $langs->trans("NoContactDefined"); if ($nbofcontacts == 0) print $langs->trans("NoContactDefined");
print '</td>'; print '</td>';
print '<td>'; print '<td>';
$formcompany->selectTypeContact($project, '', 'type','external','rowid'); $formcompany->selectTypeContact($project, '', 'type','external','rowid');
print '</td>'; print '</td>';
print '<td align="right" colspan="3" ><input type="submit" class="button" value="'.$langs->trans("Add").'"'; print '<td align="right" colspan="3" ><input type="submit" class="button" value="'.$langs->trans("Add").'"';
if (! $nbofcontacts) print ' disabled="true"'; if (! $nbofcontacts) print ' disabled="true"';
print '></td>'; print '></td>';
print '</tr>'; print '</tr>';
}
print "</form>"; print "</form>";

View File

@ -253,16 +253,14 @@ if ($_GET["action"] == 'create' && $user->rights->projet->creer)
$project = new Project($db); $project = new Project($db);
$defaultref=''; $defaultref='';
$obj = $conf->global->PROJECT_ADDON; $obj = empty($conf->global->PROJECT_ADDON)?'mod_project_simple':$conf->global->PROJECT_ADDON;
if ($obj) if (! empty($conf->global->PROJECT_ADDON) && is_readable(DOL_DOCUMENT_ROOT ."/includes/modules/project/".$conf->global->PROJECT_ADDON.".php"))
{ {
if (! empty($conf->global->PROJECT_ADDON) && is_readable(DOL_DOCUMENT_ROOT ."/includes/modules/project/".$conf->global->PROJECT_ADDON.".php")) require_once(DOL_DOCUMENT_ROOT ."/includes/modules/project/".$conf->global->PROJECT_ADDON.".php");
{ $modProject = new $obj;
require_once(DOL_DOCUMENT_ROOT ."/includes/modules/project/".$conf->global->PROJECT_ADDON.".php"); $defaultref = $modProject->getNextValue($soc,$project);
$modProject = new $obj;
$defaultref = $modProject->getNextValue($soc,$project);
}
} }
if (empty($defaultref)) $defaultref='';
// Ref // Ref
print '<tr><td><span class="fieldrequired">'.$langs->trans("Ref").'</span></td><td><input size="12" type="text" name="ref" value="'.($_POST["ref"]?$_POST["ref"]:$defaultref).'"></td></tr>'; print '<tr><td><span class="fieldrequired">'.$langs->trans("Ref").'</span></td><td><input size="12" type="text" name="ref" value="'.($_POST["ref"]?$_POST["ref"]:$defaultref).'"></td></tr>';

View File

@ -1,6 +1,6 @@
<?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-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 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
@ -19,9 +19,9 @@
*/ */
/** /**
* \file htdocs/projet/tasks/who.php * \file htdocs/projet/tasks/contact.php
* \ingroup project * \ingroup project
* \brief Fiche taches d'un projet * \brief Actors of a task
* \version $Id$ * \version $Id$
*/ */
@ -156,7 +156,7 @@ llxHeader('', $langs->trans("Task"));
$html = new Form($db); $html = new Form($db);
$formcompany = new FormCompany($db); $formcompany = new FormCompany($db);
$contactstatic = new Contact($db); $contactstatic = new Contact($db);
$projectstatic = new Project($db); $project = new Project($db);
/* *************************************************************************** */ /* *************************************************************************** */
@ -174,8 +174,8 @@ if ($id > 0 || ! empty($ref))
if ( $task->fetch($id,$ref) > 0) if ( $task->fetch($id,$ref) > 0)
{ {
$result=$projectstatic->fetch($task->fk_project); $result=$project->fetch($task->fk_project);
if (! empty($projectstatic->socid)) $projectstatic->societe->fetch($projectstatic->socid); if (! empty($project->socid)) $project->societe->fetch($project->socid);
$head = task_prepare_head($task); $head = task_prepare_head($task);
dol_fiche_head($head, 'contact', $langs->trans("Task"), 0, 'projecttask'); dol_fiche_head($head, 'contact', $langs->trans("Task"), 0, 'projecttask');
@ -190,7 +190,7 @@ if ($id > 0 || ! empty($ref))
// Ref // Ref
print '<tr><td width="30%">'.$langs->trans('Ref').'</td><td colspan="3">'; print '<tr><td width="30%">'.$langs->trans('Ref').'</td><td colspan="3">';
print $html->showrefnav($task,'ref',$linkback,1,'ref','ref',''); print $html->showrefnav($task,'id','',1,'rowid','ref','','');
print '</td></tr>'; print '</td></tr>';
// Label // Label
@ -198,13 +198,13 @@ if ($id > 0 || ! empty($ref))
// Project // Project
print '<tr><td>'.$langs->trans("Project").'</td><td>'; print '<tr><td>'.$langs->trans("Project").'</td><td>';
print $projectstatic->getNomUrl(1); print $project->getNomUrl(1);
print '</td></tr>'; print '</td></tr>';
// Customer // Customer
print "<tr><td>".$langs->trans("Company")."</td>"; print "<tr><td>".$langs->trans("Company")."</td>";
print '<td colspan="3">'; print '<td colspan="3">';
if ($projectstatic->societe->id > 0) print $projectstatic->societe->getNomUrl(1); if ($project->societe->id > 0) print $project->societe->getNomUrl(1);
else print '&nbsp;'; else print '&nbsp;';
print '</td></tr>'; print '</td></tr>';
@ -268,30 +268,33 @@ if ($id > 0 || ! empty($ref))
print '<input type="hidden" name="source" value="external">'; print '<input type="hidden" name="source" value="external">';
print '<input type="hidden" name="id" value="'.$id.'">'; print '<input type="hidden" name="id" value="'.$id.'">';
// Ligne ajout pour contact externe // Line to add an external contact. Only if project linked to a third party.
$var=!$var; if ($project->socid)
print "<tr $bc[$var]>"; {
$var=!$var;
print "<tr $bc[$var]>";
print '<td nowrap="nowrap">'; print '<td nowrap="nowrap">';
print img_object('','contact').' '.$langs->trans("ThirdPartyContacts"); print img_object('','contact').' '.$langs->trans("ThirdPartyContacts");
print '</td>'; print '</td>';
print '<td colspan="1">'; print '<td colspan="1">';
$selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$projectstatic->societe->id; $selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$project->societe->id;
$selectedCompany = $formcompany->selectCompaniesForNewContact($task, 'id', $selectedCompany, 'newcompany'); $selectedCompany = $formcompany->selectCompaniesForNewContact($task, 'id', $selectedCompany, 'newcompany');
print '</td>'; print '</td>';
print '<td colspan="1">'; print '<td colspan="1">';
$nbofcontacts=$html->select_contacts($selectedCompany,'','contactid',0); $nbofcontacts=$html->select_contacts($selectedCompany,'','contactid',0);
if ($nbofcontacts == 0) print $langs->trans("NoContactDefined"); if ($nbofcontacts == 0) print $langs->trans("NoContactDefined");
print '</td>'; print '</td>';
print '<td>'; print '<td>';
$formcompany->selectTypeContact($task, '', 'type','external','rowid'); $formcompany->selectTypeContact($task, '', 'type','external','rowid');
print '</td>'; print '</td>';
print '<td align="right" colspan="3" ><input type="submit" class="button" value="'.$langs->trans("Add").'"'; print '<td align="right" colspan="3" ><input type="submit" class="button" value="'.$langs->trans("Add").'"';
if (! $nbofcontacts) print ' disabled="true"'; if (! $nbofcontacts) print ' disabled="true"';
print '></td>'; print '></td>';
print '</tr>'; print '</tr>';
}
print "</form>"; print "</form>";

View File

@ -263,7 +263,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, $project->id, $socid, 0); $tasksarray=$task->getTasksArray(0, 0, $project->id, $socid, 0);
// We load also tasks limited to a particular user // We load also tasks limited to a particular user
$tasksrole=($_REQUEST["mode"]=='mine' ? $task->getTasksForProjectOwnedByAUser(0,$user,$project->id,0) : ''); $tasksrole=($_REQUEST["mode"]=='mine' ? $task->getUserRolesForProjetsOrTasks(0,$user,$project->id,0) : '');
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';

View File

@ -77,7 +77,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, $project->id, $socid); $tasksarray=$task->getTasksArray(0, 0, $project->id, $socid);
// We load also tasks limited to a particular user // We load also tasks limited to a particular user
$tasksrole=($_REQUEST["mode"]=='mine' ? $task->getTasksForProjectOwnedByAUser(0,$user,$project->id,0) : ''); $tasksrole=($_REQUEST["mode"]=='mine' ? $task->getUserRolesForProjetsOrTasks(0,$user,$project->id,0) : '');
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';

View File

@ -81,10 +81,9 @@ if ($_POST['action'] == 'update_private' && $user->rights->projet->task->creer)
} }
/*
/******************************************************************************/ * View
/* Affichage fiche */ */
/******************************************************************************/
llxHeader(); llxHeader();
@ -134,7 +133,7 @@ if ($id > 0 || ! empty($ref))
// Ref // Ref
print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td>'; print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td>';
print $html->showrefnav($task,'ref','',1,'ref','ref'); print $html->showrefnav($task,'id','',1,'rowid','ref','','');
print '</td></tr>'; print '</td></tr>';
// Label // Label
@ -151,31 +150,6 @@ if ($id > 0 || ! empty($ref))
else print'&nbsp;'; else print'&nbsp;';
print '</td></tr>'; print '</td></tr>';
// Task executive
print '<tr><td>'.$langs->trans("TaskExecutive").'</td><td>';
$contact = $task->liste_contact(4,'internal');
$num=sizeof($contact);
if ($num)
{
$i = 0;
while ($i < $num)
{
if ($contact[$i]['code'] == 'TASKEXECUTIVE')
{
$userstatic->id = $contact[$i]['id'];
$userstatic->fetch();
print $userstatic->getNomUrl(1);
print '<br>';
}
$i++;
}
}
else
{
print $langs->trans('SharedTask');
}
print '</td></tr>';
// Note publique // Note publique
print '<tr><td valign="top">'.$langs->trans("NotePublic").' :</td>'; print '<tr><td valign="top">'.$langs->trans("NotePublic").' :</td>';
print '<td valign="top" colspan="3">'; print '<td valign="top" colspan="3">';

View File

@ -503,7 +503,7 @@ class Task extends CommonObject
if ((! $obj->public) && ($userp || $usert)) // If not public and we ask a filter on user if ((! $obj->public) && ($userp || $usert)) // If not public and we ask a filter on user
{ {
if (! $this->getTasksForProjectOwnedByAUser($userp, $usert, $obj->projectid, $obj->rowid)) if (! $this->getUserRolesForProjetsOrTasks($userp, $usert, $obj->projectid, $obj->rowid))
{ {
$error++; $error++;
} }
@ -541,7 +541,7 @@ class Task extends CommonObject
* @param taskid * @param taskid
* @return array Array of role of user for each projects or each tasks * @return array Array of role of user for each projects or each tasks
*/ */
function getTasksForProjectOwnedByAUser($userp,$usert,$projectid=0,$taskid=0) function getUserRolesForProjetsOrTasks($userp,$usert,$projectid=0,$taskid=0)
{ {
$tasksrole = array(); $tasksrole = array();

View File

@ -1,6 +1,6 @@
<?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-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 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
@ -223,31 +223,6 @@ if ($taskid)
else print '&nbsp;'; else print '&nbsp;';
print '</td></tr>'; print '</td></tr>';
// Task executive
print '<tr><td>'.$langs->trans("TaskExecutive").'</td><td>';
$contact = $task->liste_contact(4,'internal');
$num=sizeof($contact);
if ($num)
{
$i = 0;
while ($i < $num)
{
if ($contact[$i]['code'] == 'TASKEXECUTIVE')
{
$userstatic->id = $contact[$i]['id'];
$userstatic->fetch();
print $userstatic->getNomUrl(1);
print '<br>';
}
$i++;
}
}
else
{
print $langs->trans('SharedTask');
}
print '</td></tr>';
// Date start // Date start
print '<tr><td>'.$langs->trans("DateStart").'</td><td colspan="3">'; print '<tr><td>'.$langs->trans("DateStart").'</td><td colspan="3">';
print dol_print_date($task->date_start,'day'); print dol_print_date($task->date_start,'day');

View File

@ -93,31 +93,6 @@ if ($_GET["id"] > 0)
else print '&nbsp;'; else print '&nbsp;';
print '</td></tr>'; print '</td></tr>';
// Task executive
print '<tr><td>'.$langs->trans("TaskExecutive").'</td><td>';
$contact = $task->liste_contact(4,'internal');
$num=sizeof($contact);
if ($num)
{
$i = 0;
while ($i < $num)
{
if ($contact[$i]['code'] == 'TASKEXECUTIVE')
{
$userstatic->id = $contact[$i]['id'];
$userstatic->fetch();
print $userstatic->getNomUrl(1);
print '<br>';
}
$i++;
}
}
else
{
print $langs->trans('SharedTask');
}
print '</td></tr>';
/* /*
* List of time spent * List of time spent
*/ */