Better ressource management on project and task
This commit is contained in:
parent
565de5258f
commit
119be5da42
@ -120,6 +120,7 @@ TypeContact_project_task_internal_TASKCONTRIBUTOR=Contributor
|
||||
TypeContact_project_task_external_TASKCONTRIBUTOR=Contributor
|
||||
SelectElement=Select element
|
||||
AddElement=Link to element
|
||||
UnlinkElement=Unlink element
|
||||
# Documents models
|
||||
DocumentModelBaleine=A complete project's report model (logo...)
|
||||
PlannedWorkload = Planned workload
|
||||
@ -128,3 +129,4 @@ ProjectReferers=Refering objects
|
||||
SearchAProject=Search a project
|
||||
ProjectMustBeValidatedFirst=Project must be validated first
|
||||
ProjectDraft=Draft projects
|
||||
FirstAddRessourceToAllocateTime=Associate a ressource to allocate time
|
||||
@ -119,7 +119,8 @@ TypeContact_project_task_external_TASKEXECUTIVE=Responsable
|
||||
TypeContact_project_task_internal_TASKCONTRIBUTOR=Contributeur
|
||||
TypeContact_project_task_external_TASKCONTRIBUTOR=Contributeur
|
||||
SelectElement=Séléctionnez l'élément
|
||||
AddElement=Link to element
|
||||
AddElement=Associer l'élément
|
||||
UnlinkElement=Délier l'element
|
||||
# Documents models
|
||||
DocumentModelBaleine=Modèle de rapport de projet complet (logo...)
|
||||
PlannedWorkload = Charge de travail prévue
|
||||
@ -128,3 +129,4 @@ ProjectReferers=Objets associés
|
||||
SearchAProject=Rechercher un projet
|
||||
ProjectMustBeValidatedFirst=Le projet doit être validé d'abord
|
||||
ProjectDraft=Projets brouillons
|
||||
FirstAddRessourceToAllocateTime=Associer une ressource pour allouer du temps consomée
|
||||
@ -322,6 +322,7 @@ class Project extends CommonObject
|
||||
$this->note_private = $obj->note_private;
|
||||
$this->note_public = $obj->note_public;
|
||||
$this->socid = $obj->fk_soc;
|
||||
$this->societe=(object)array();// To avoid warning on next line
|
||||
$this->societe->id = $obj->fk_soc; // TODO For backward compatibility
|
||||
$this->user_author_id = $obj->fk_user_creat;
|
||||
$this->public = $obj->public;
|
||||
@ -1276,23 +1277,23 @@ class Project extends CommonObject
|
||||
/**
|
||||
* Associate element to a project
|
||||
*
|
||||
* @param string $TableName Table of the element to update
|
||||
* @param int $ElementSelectId Key-rowid of the line of the element to update
|
||||
* @param string $tableName Table of the element to update
|
||||
* @param int $elementSelectId Key-rowid of the line of the element to update
|
||||
* @return int 1 if OK or < 0 if KO
|
||||
*/
|
||||
function update_element($TableName, $ElementSelectId)
|
||||
function update_element($tableName, $elementSelectId)
|
||||
{
|
||||
$sql="UPDATE ".MAIN_DB_PREFIX.$TableName;
|
||||
$sql="UPDATE ".MAIN_DB_PREFIX.$tableName;
|
||||
|
||||
if ($TableName=="actioncomm")
|
||||
{
|
||||
$sql.= " SET fk_project=".$this->id;
|
||||
$sql.= " WHERE id=".$ElementSelectId;
|
||||
$sql.= " WHERE id=".$elementSelectId;
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql.= " SET fk_projet=".$this->id;
|
||||
$sql.= " WHERE rowid=".$ElementSelectId;
|
||||
$sql.= " WHERE rowid=".$elementSelectId;
|
||||
}
|
||||
|
||||
dol_syslog(get_class($this)."::update_element", LOG_DEBUG);
|
||||
@ -1305,5 +1306,38 @@ class Project extends CommonObject
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Associate element to a project
|
||||
*
|
||||
* @param string $tableName Table of the element to update
|
||||
* @param int $elementSelectId Key-rowid of the line of the element to update
|
||||
* @return int 1 if OK or < 0 if KO
|
||||
*/
|
||||
function remove_element($tableName, $elementSelectId)
|
||||
{
|
||||
$sql="UPDATE ".MAIN_DB_PREFIX.$tableName;
|
||||
|
||||
if ($TableName=="actioncomm")
|
||||
{
|
||||
$sql.= " SET fk_project=NULL";
|
||||
$sql.= " WHERE id=".$elementSelectId;
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql.= " SET fk_projet=NULL";
|
||||
$sql.= " WHERE rowid=".$elementSelectId;
|
||||
}
|
||||
|
||||
dol_syslog(get_class($this)."::remove_element", LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
if (!$resql) {
|
||||
$this->error=$this->db->lasterror();
|
||||
return -1;
|
||||
}else {
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -215,6 +215,15 @@ if ($action=="addelement")
|
||||
if ($result<0) {
|
||||
setEventMessage($mailchimp->error,'errors');
|
||||
}
|
||||
}elseif ($action == "unlink") {
|
||||
|
||||
$tablename = GETPOST("tablename");
|
||||
$elementselectid = GETPOST("elementselect");
|
||||
|
||||
$result = $project->remove_element($tablename, $elementselectid);
|
||||
if ($result < 0) {
|
||||
setEventMessage($project->error, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($listofreferent as $key => $value)
|
||||
@ -247,7 +256,7 @@ foreach ($listofreferent as $key => $value)
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td width="100">'.$langs->trans("Ref").'</td>';
|
||||
print '<td width="100" colspan="2">'.$langs->trans("Ref").'</td>';
|
||||
print '<td width="100" align="center">'.$langs->trans("Date").'</td>';
|
||||
print '<td>'.$langs->trans("ThirdParty").'</td>';
|
||||
if (empty($value['disableamount'])) print '<td align="right" width="120">'.$langs->trans("AmountHT").'</td>';
|
||||
@ -276,7 +285,9 @@ foreach ($listofreferent as $key => $value)
|
||||
|
||||
$var=!$var;
|
||||
print "<tr ".$bc[$var].">";
|
||||
|
||||
print '<td width="1%">';
|
||||
print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $projectid . '&action=unlink&tablename=' . $tablename . '&elementselect=' . $element->id . '">' . img_picto($langs->trans('Unlink'), 'editdelete') . '</a>';
|
||||
print "</td>\n";
|
||||
// Ref
|
||||
print '<td align="left">';
|
||||
print $element->getNomUrl(1);
|
||||
@ -326,7 +337,7 @@ foreach ($listofreferent as $key => $value)
|
||||
}
|
||||
}
|
||||
|
||||
print '<tr class="liste_total"><td colspan="3">'.$langs->trans("Number").': '.$i.'</td>';
|
||||
print '<tr class="liste_total"><td colspan="4">'.$langs->trans("Number").': '.$i.'</td>';
|
||||
if (empty($value['disableamount'])) print '<td align="right" width="100">'.$langs->trans("TotalHT").' : '.price($total_ht).'</td>';
|
||||
if (empty($value['disableamount'])) print '<td align="right" width="100">'.$langs->trans("TotalTTC").' : '.price($total_ttc).'</td>';
|
||||
print '<td> </td>';
|
||||
|
||||
@ -300,7 +300,8 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("AffectedTo").'</td><td>';
|
||||
print $form->select_dolusers($user->id,'userid',1);
|
||||
$contactsofproject=$object->getListContactId('internal');
|
||||
$form->select_users($user->id,'userid',0,'',0,'',$contactsofproject);
|
||||
print '</td></tr>';
|
||||
|
||||
// Date start
|
||||
|
||||
@ -155,7 +155,7 @@ if ($id > 0 || ! empty($ref))
|
||||
if ($object->fetch($id) > 0)
|
||||
{
|
||||
$result=$projectstatic->fetch($object->fk_project);
|
||||
if (! empty($projectstatic->socid)) $projectstatic->societe->fetch($projectstatic->socid);
|
||||
if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty();
|
||||
|
||||
$object->project = dol_clone($projectstatic);
|
||||
|
||||
@ -179,7 +179,7 @@ if ($id > 0 || ! empty($ref))
|
||||
// Define a complementary filter for search of next/prev ref.
|
||||
if (! $user->rights->projet->all->lire)
|
||||
{
|
||||
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,0);
|
||||
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,0);
|
||||
$projectstatic->next_prev_filter=" rowid in (".(count($projectsListId)?join(',',array_keys($projectsListId)):'0').")";
|
||||
}
|
||||
print $form->showrefnav($projectstatic,'project_ref','',1,'ref','ref','',$param.'&withproject=1');
|
||||
@ -188,7 +188,7 @@ if ($id > 0 || ! empty($ref))
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$projectstatic->title.'</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("ThirdParty").'</td><td>';
|
||||
if (! empty($projectstatic->societe->id)) print $projectstatic->societe->getNomUrl(1);
|
||||
if (! empty($projectstatic->thridparty->id)) print $projectstatic->thridparty->getNomUrl(1);
|
||||
else print ' ';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
@ -239,7 +239,7 @@ if ($id > 0 || ! empty($ref))
|
||||
print '<tr><td width="30%">'.$langs->trans('Ref').'</td><td colspan="3">';
|
||||
if (! GETPOST('withproject') || empty($projectstatic->id))
|
||||
{
|
||||
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1);
|
||||
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1);
|
||||
$object->next_prev_filter=" fk_projet in (".$projectsListId.")";
|
||||
}
|
||||
else $object->next_prev_filter=" fk_projet = ".$projectstatic->id;
|
||||
@ -259,7 +259,7 @@ if ($id > 0 || ! empty($ref))
|
||||
// Customer
|
||||
print "<tr><td>".$langs->trans("ThirdParty")."</td>";
|
||||
print '<td colspan="3">';
|
||||
if ($projectstatic->societe->id > 0) print $projectstatic->societe->getNomUrl(1);
|
||||
if ($projectstatic->thridparty->id > 0) print $projectstatic->thridparty->getNomUrl(1);
|
||||
else print ' ';
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
@ -202,7 +202,7 @@ if ($id > 0 || ! empty($ref))
|
||||
$res=$object->fetch_optionals($object->id,$extralabels);
|
||||
|
||||
$result=$projectstatic->fetch($object->fk_project);
|
||||
if (! empty($projectstatic->socid)) $projectstatic->societe->fetch($projectstatic->socid);
|
||||
if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty();
|
||||
|
||||
$object->project = dol_clone($projectstatic);
|
||||
|
||||
@ -235,7 +235,7 @@ if ($id > 0 || ! empty($ref))
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$projectstatic->title.'</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("ThirdParty").'</td><td>';
|
||||
if (! empty($projectstatic->societe->id)) print $projectstatic->societe->getNomUrl(1);
|
||||
if (! empty($projectstatic->thirdparty->id)) print $projectstatic->thirdparty->getNomUrl(1);
|
||||
else print ' ';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
@ -195,7 +195,7 @@ if ($id > 0 || ! empty($ref))
|
||||
if ($object->fetch($id) >= 0)
|
||||
{
|
||||
$result=$projectstatic->fetch($object->fk_project);
|
||||
if (! empty($projectstatic->socid)) $projectstatic->societe->fetch($projectstatic->socid);
|
||||
if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty();
|
||||
|
||||
$object->project = dol_clone($projectstatic);
|
||||
|
||||
@ -230,7 +230,7 @@ if ($id > 0 || ! empty($ref))
|
||||
|
||||
// Thirdparty
|
||||
print '<tr><td>'.$langs->trans("ThirdParty").'</td><td>';
|
||||
if (! empty($projectstatic->societe->id)) print $projectstatic->societe->getNomUrl(1);
|
||||
if (! empty($projectstatic->thirdparty->id)) print $projectstatic->thirdparty->getNomUrl(1);
|
||||
else print ' ';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
@ -302,7 +302,7 @@ if ($id > 0 || ! empty($ref))
|
||||
|
||||
// Third party
|
||||
print '<td>'.$langs->trans("ThirdParty").'</td><td>';
|
||||
if ($projectstatic->societe->id) print $projectstatic->societe->getNomUrl(1);
|
||||
if ($projectstatic->thirdparty->id) print $projectstatic->thirdparty->getNomUrl(1);
|
||||
else print ' ';
|
||||
print '</td></tr>';
|
||||
}
|
||||
@ -345,13 +345,14 @@ if ($id > 0 || ! empty($ref))
|
||||
|
||||
// Contributor
|
||||
print '<td class="nowrap">';
|
||||
$restrictaddtimetocontactoftask=0;
|
||||
if (empty($conf->global->PROJECT_TIME_ON_ALL_TASKS_MY_PROJECTS))
|
||||
{
|
||||
$restrictaddtimetocontactoftask=$object->getListContactId('internal');
|
||||
}
|
||||
print img_object('','user');
|
||||
print $form->select_dolusers($_POST["userid"]?$_POST["userid"]:$user->id,'userid',0,'',0,'',$restrictaddtimetocontactoftask); // Note: If user is not allowed it will be disabled into combo list and userid not posted
|
||||
$contactsoftask=$object->getListContactId('internal');
|
||||
if (count($contactsoftask)>0) {
|
||||
$userid=$contactsoftask[0];
|
||||
$form->select_users($userid,'userid',0,'',0,'',$contactsoftask);
|
||||
}else {
|
||||
print img_error($langs->trans('FirstAddRessourceToAllocateTime')).$langs->trans('FirstAddRessourceToAllocateTime');
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
// Note
|
||||
@ -440,7 +441,15 @@ if ($id > 0 || ! empty($ref))
|
||||
print '<td>';
|
||||
if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid)
|
||||
{
|
||||
print $form->select_dolusers($task_time->fk_user,'userid_line');
|
||||
$contactsoftask=$object->getListContactId('internal');
|
||||
if (!in_array($task_time->fk_user,$contactsoftask)) {
|
||||
$contactsoftask[]=$task_time->fk_user;
|
||||
}
|
||||
if (count($contactsoftask)>0) {
|
||||
$form->select_users($task_time->fk_user,'userid_line',0,'',0,'',$contactsoftask);
|
||||
}else {
|
||||
print img_error($langs->trans('FirstAddRessourceToAllocateTime')).$langs->trans('FirstAddRessourceToAllocateTime');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user