Perf: Avoid duplicate load of project
This commit is contained in:
parent
736320ba47
commit
9379e28a94
@ -41,9 +41,10 @@ $mine = GETPOST('mode')=='mine' ? 1 : 0;
|
||||
//if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
|
||||
|
||||
$object = new Project($db);
|
||||
if ($ref)
|
||||
if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
$object->fetch(0,$ref);
|
||||
$object->fetch($id,$ref);
|
||||
$object->fetch_thirdparty();
|
||||
$id=$object->id;
|
||||
}
|
||||
|
||||
@ -140,82 +141,73 @@ $userstatic=new User($db);
|
||||
|
||||
if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
if ( $object->fetch($id,$ref) > 0)
|
||||
// To verify role of users
|
||||
//$userAccess = $object->restrictedProjectArea($user,'read');
|
||||
$userWrite = $object->restrictedProjectArea($user,'write');
|
||||
//$userDelete = $object->restrictedProjectArea($user,'delete');
|
||||
//print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete;
|
||||
|
||||
$head = project_prepare_head($object);
|
||||
dol_fiche_head($head, 'contact', $langs->trans("Project"), 0, ($object->public?'projectpub':'project'));
|
||||
|
||||
|
||||
/*
|
||||
* Projet synthese pour rappel
|
||||
*/
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/projet/liste.php">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
// Ref
|
||||
print '<tr><td width="30%">'.$langs->trans('Ref').'</td><td colspan="3">';
|
||||
// Define a complementary filter for search of next/prev ref.
|
||||
if (! $user->rights->projet->all->lire)
|
||||
{
|
||||
if ($object->societe->id > 0) $result=$object->societe->fetch($object->societe->id);
|
||||
|
||||
// To verify role of users
|
||||
//$userAccess = $object->restrictedProjectArea($user,'read');
|
||||
$userWrite = $object->restrictedProjectArea($user,'write');
|
||||
//$userDelete = $object->restrictedProjectArea($user,'delete');
|
||||
//print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete;
|
||||
|
||||
$head = project_prepare_head($object);
|
||||
dol_fiche_head($head, 'contact', $langs->trans("Project"), 0, ($object->public?'projectpub':'project'));
|
||||
|
||||
|
||||
/*
|
||||
* Projet synthese pour rappel
|
||||
*/
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/projet/liste.php">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
// Ref
|
||||
print '<tr><td width="30%">'.$langs->trans('Ref').'</td><td colspan="3">';
|
||||
// Define a complementary filter for search of next/prev ref.
|
||||
if (! $user->rights->projet->all->lire)
|
||||
{
|
||||
$objectsListId = $object->getProjectsAuthorizedForUser($user,$mine,0);
|
||||
$object->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")";
|
||||
}
|
||||
print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', '');
|
||||
print '</td></tr>';
|
||||
|
||||
// Label
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$object->title.'</td></tr>';
|
||||
|
||||
// Customer
|
||||
print "<tr><td>".$langs->trans("ThirdParty")."</td>";
|
||||
print '<td colspan="3">';
|
||||
if ($object->societe->id > 0) print $object->societe->getNomUrl(1);
|
||||
else print ' ';
|
||||
print '</td></tr>';
|
||||
|
||||
// Visibility
|
||||
print '<tr><td>'.$langs->trans("Visibility").'</td><td>';
|
||||
if ($object->public) print $langs->trans('SharedProject');
|
||||
else print $langs->trans('PrivateProject');
|
||||
print '</td></tr>';
|
||||
|
||||
// Statut
|
||||
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>';
|
||||
|
||||
// Date start
|
||||
print '<tr><td>'.$langs->trans("DateStart").'</td><td>';
|
||||
print dol_print_date($object->date_start,'day');
|
||||
print '</td></tr>';
|
||||
|
||||
// Date end
|
||||
print '<tr><td>'.$langs->trans("DateEnd").'</td><td>';
|
||||
print dol_print_date($object->date_end,'day');
|
||||
print '</td></tr>';
|
||||
|
||||
print "</table>";
|
||||
|
||||
print '</div>';
|
||||
|
||||
// Contacts lines (modules that overwrite templates must declare this into descriptor)
|
||||
$dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl'));
|
||||
foreach($dirtpls as $reldir)
|
||||
{
|
||||
$res=@include dol_buildpath($reldir.'/contacts.tpl.php');
|
||||
if ($res) break;
|
||||
}
|
||||
$objectsListId = $object->getProjectsAuthorizedForUser($user,$mine,0);
|
||||
$object->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")";
|
||||
}
|
||||
else
|
||||
print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', '');
|
||||
print '</td></tr>';
|
||||
|
||||
// Label
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$object->title.'</td></tr>';
|
||||
|
||||
// Customer
|
||||
print "<tr><td>".$langs->trans("ThirdParty")."</td>";
|
||||
print '<td colspan="3">';
|
||||
if ($object->thirdparty->id > 0) print $object->thirdparty->getNomUrl(1);
|
||||
else print ' ';
|
||||
print '</td></tr>';
|
||||
|
||||
// Visibility
|
||||
print '<tr><td>'.$langs->trans("Visibility").'</td><td>';
|
||||
if ($object->public) print $langs->trans('SharedProject');
|
||||
else print $langs->trans('PrivateProject');
|
||||
print '</td></tr>';
|
||||
|
||||
// Statut
|
||||
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>';
|
||||
|
||||
// Date start
|
||||
print '<tr><td>'.$langs->trans("DateStart").'</td><td>';
|
||||
print dol_print_date($object->date_start,'day');
|
||||
print '</td></tr>';
|
||||
|
||||
// Date end
|
||||
print '<tr><td>'.$langs->trans("DateEnd").'</td><td>';
|
||||
print dol_print_date($object->date_end,'day');
|
||||
print '</td></tr>';
|
||||
|
||||
print "</table>";
|
||||
|
||||
print '</div>';
|
||||
|
||||
// Contacts lines (modules that overwrite templates must declare this into descriptor)
|
||||
$dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl'));
|
||||
foreach($dirtpls as $reldir)
|
||||
{
|
||||
print "ErrorRecordNotFound";
|
||||
$res=@include dol_buildpath($reldir.'/contacts.tpl.php');
|
||||
if ($res) break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -46,9 +46,9 @@ if ($user->societe_id > 0) $socid=$user->societe_id;
|
||||
$result=restrictedArea($user,'projet',$id,'');
|
||||
|
||||
$object = new Project($db);
|
||||
$object->fetch($id,$ref);
|
||||
if ($object->id > 0)
|
||||
if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
$object->fetch($id,$ref);
|
||||
$object->fetch_thirdparty();
|
||||
$upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref);
|
||||
}
|
||||
@ -85,8 +85,6 @@ if ($object->id > 0)
|
||||
{
|
||||
$upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($object->ref);
|
||||
|
||||
if ($object->societe->id > 0) $result=$object->societe->fetch($object->societe->id);
|
||||
|
||||
// To verify role of users
|
||||
//$userAccess = $object->restrictedProjectArea($user,'read');
|
||||
$userWrite = $object->restrictedProjectArea($user,'write');
|
||||
@ -124,7 +122,7 @@ if ($object->id > 0)
|
||||
|
||||
// Company
|
||||
print '<tr><td>'.$langs->trans("ThirdParty").'</td><td>';
|
||||
if (! empty($object->societe->id)) print $object->societe->getNomUrl(1);
|
||||
if (! empty($object->thirdparty->id)) print $object->thirdparty->getNomUrl(1);
|
||||
else print ' ';
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
@ -61,12 +61,17 @@ $mine = $_REQUEST['mode']=='mine' ? 1 : 0;
|
||||
//if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
|
||||
|
||||
$project = new Project($db);
|
||||
if ($ref)
|
||||
if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
$project->fetch(0,$ref);
|
||||
$project->fetch($id,$ref);
|
||||
$project->fetch_thirdparty();
|
||||
$projectid=$project->id;
|
||||
}else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$project->fetch($projectid);
|
||||
$project->fetch_thirdparty();
|
||||
$projectid=$project->id;
|
||||
}
|
||||
|
||||
// Security check
|
||||
@ -87,10 +92,6 @@ $formproject=new FormProjets($db);
|
||||
|
||||
$userstatic=new User($db);
|
||||
|
||||
$project = new Project($db);
|
||||
$project->fetch($projectid,$ref);
|
||||
$project->fetch_thirdparty();
|
||||
|
||||
// To verify role of users
|
||||
$userAccess = $project->restrictedProjectArea($user);
|
||||
|
||||
|
||||
@ -49,10 +49,11 @@ $hookmanager->initHooks(array('projectcard'));
|
||||
|
||||
$object = new Project($db);
|
||||
$extrafields = new ExtraFields($db);
|
||||
$object->fetch($id,$ref);
|
||||
if ($object->id > 0)
|
||||
if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
$object->fetch($id,$ref);
|
||||
$object->fetch_thirdparty();
|
||||
$id=$object->id;
|
||||
}
|
||||
|
||||
// Security check
|
||||
|
||||
@ -38,9 +38,10 @@ $mine = ($mode == 'mine' ? 1 : 0);
|
||||
//if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
|
||||
|
||||
$object = new Project($db);
|
||||
if ($ref)
|
||||
if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
$object->fetch(0,$ref);
|
||||
$object->fetch($id,$ref);
|
||||
$object->fetch_thirdparty();
|
||||
$id=$object->id;
|
||||
}
|
||||
|
||||
@ -69,7 +70,6 @@ $formother=new FormOther($db);
|
||||
$userstatic=new User($db);
|
||||
$companystatic=new Societe($db);
|
||||
$task = new Task($db);
|
||||
$object = new Project($db);
|
||||
|
||||
$arrayofcss=array('/includes/jsgantt/jsgantt.css');
|
||||
|
||||
@ -86,9 +86,6 @@ llxHeader("",$langs->trans("Tasks"),$help_url,'',0,0,$arrayofjs,$arrayofcss);
|
||||
|
||||
if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
$object->fetch($id,$ref);
|
||||
if ($object->societe->id > 0) $result=$object->societe->fetch($object->societe->id);
|
||||
|
||||
// To verify role of users
|
||||
//$userAccess = $object->restrictedProjectArea($user,'read');
|
||||
$userWrite = $object->restrictedProjectArea($user,'write');
|
||||
@ -123,7 +120,7 @@ if ($id > 0 || ! empty($ref))
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$object->title.'</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("ThirdParty").'</td><td>';
|
||||
if (! empty($object->societe->id)) print $object->societe->getNomUrl(1);
|
||||
if (! empty($object->thirdparty->id)) print $object->thirdparty->getNomUrl(1);
|
||||
else print ' ';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
@ -36,9 +36,10 @@ $mine = $_REQUEST['mode']=='mine' ? 1 : 0;
|
||||
//if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
|
||||
|
||||
$object = new Project($db);
|
||||
if ($ref)
|
||||
if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
$object->fetch(0,$ref);
|
||||
$object->fetch($id,$ref);
|
||||
$object->fetch_thirdparty();
|
||||
$id=$object->id;
|
||||
}
|
||||
|
||||
@ -66,77 +67,71 @@ llxHeader("",$langs->trans("Project"),$help_url);
|
||||
|
||||
$form = new Form($db);
|
||||
$userstatic=new User($db);
|
||||
$object = new Project($db);
|
||||
|
||||
$now=dol_now();
|
||||
|
||||
if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
if ($object->fetch($id, $ref))
|
||||
// To verify role of users
|
||||
//$userAccess = $object->restrictedProjectArea($user,'read');
|
||||
$userWrite = $object->restrictedProjectArea($user,'write');
|
||||
//$userDelete = $object->restrictedProjectArea($user,'delete');
|
||||
//print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete;
|
||||
|
||||
$head = project_prepare_head($object);
|
||||
dol_fiche_head($head, 'notes', $langs->trans('Project'), 0, ($object->public?'projectpub':'project'));
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/projet/liste.php">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
// Ref
|
||||
print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td>';
|
||||
// Define a complementary filter for search of next/prev ref.
|
||||
if (! $user->rights->projet->all->lire)
|
||||
{
|
||||
if ($object->societe->id > 0) $result=$object->societe->fetch($object->societe->id);
|
||||
|
||||
// To verify role of users
|
||||
//$userAccess = $object->restrictedProjectArea($user,'read');
|
||||
$userWrite = $object->restrictedProjectArea($user,'write');
|
||||
//$userDelete = $object->restrictedProjectArea($user,'delete');
|
||||
//print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete;
|
||||
|
||||
$head = project_prepare_head($object);
|
||||
dol_fiche_head($head, 'notes', $langs->trans('Project'), 0, ($object->public?'projectpub':'project'));
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/projet/liste.php">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
// Ref
|
||||
print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td>';
|
||||
// Define a complementary filter for search of next/prev ref.
|
||||
if (! $user->rights->projet->all->lire)
|
||||
{
|
||||
$projectsListId = $object->getProjectsAuthorizedForUser($user,$mine,0);
|
||||
$object->next_prev_filter=" rowid in (".(count($projectsListId)?join(',',array_keys($projectsListId)):'0').")";
|
||||
}
|
||||
print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref');
|
||||
print '</td></tr>';
|
||||
|
||||
// Label
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$object->title.'</td></tr>';
|
||||
|
||||
// Third party
|
||||
print '<tr><td>'.$langs->trans("ThirdParty").'</td><td>';
|
||||
if ($object->societe->id > 0) print $object->societe->getNomUrl(1);
|
||||
else print' ';
|
||||
print '</td></tr>';
|
||||
|
||||
// Visibility
|
||||
print '<tr><td>'.$langs->trans("Visibility").'</td><td>';
|
||||
if ($object->public) print $langs->trans('SharedProject');
|
||||
else print $langs->trans('PrivateProject');
|
||||
print '</td></tr>';
|
||||
|
||||
// Statut
|
||||
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>';
|
||||
|
||||
// Date start
|
||||
print '<tr><td>'.$langs->trans("DateStart").'</td><td>';
|
||||
print dol_print_date($object->date_start,'day');
|
||||
print '</td></tr>';
|
||||
|
||||
// Date end
|
||||
print '<tr><td>'.$langs->trans("DateEnd").'</td><td>';
|
||||
print dol_print_date($object->date_end,'day');
|
||||
print '</td></tr>';
|
||||
|
||||
print "</table>";
|
||||
|
||||
print '<br>';
|
||||
|
||||
$colwidth=30;
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
|
||||
|
||||
dol_fiche_end();;
|
||||
$projectsListId = $object->getProjectsAuthorizedForUser($user,$mine,0);
|
||||
$object->next_prev_filter=" rowid in (".(count($projectsListId)?join(',',array_keys($projectsListId)):'0').")";
|
||||
}
|
||||
print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref');
|
||||
print '</td></tr>';
|
||||
|
||||
// Label
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$object->title.'</td></tr>';
|
||||
|
||||
// Third party
|
||||
print '<tr><td>'.$langs->trans("ThirdParty").'</td><td>';
|
||||
if ($object->thirdparty->id > 0) print $object->thirdparty->getNomUrl(1);
|
||||
else print' ';
|
||||
print '</td></tr>';
|
||||
|
||||
// Visibility
|
||||
print '<tr><td>'.$langs->trans("Visibility").'</td><td>';
|
||||
if ($object->public) print $langs->trans('SharedProject');
|
||||
else print $langs->trans('PrivateProject');
|
||||
print '</td></tr>';
|
||||
|
||||
// Statut
|
||||
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>';
|
||||
|
||||
// Date start
|
||||
print '<tr><td>'.$langs->trans("DateStart").'</td><td>';
|
||||
print dol_print_date($object->date_start,'day');
|
||||
print '</td></tr>';
|
||||
|
||||
// Date end
|
||||
print '<tr><td>'.$langs->trans("DateEnd").'</td><td>';
|
||||
print dol_print_date($object->date_end,'day');
|
||||
print '</td></tr>';
|
||||
|
||||
print "</table>";
|
||||
|
||||
print '<br>';
|
||||
|
||||
$colwidth=30;
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
|
||||
|
||||
dol_fiche_end();;
|
||||
}
|
||||
|
||||
llxFooter();
|
||||
|
||||
@ -47,7 +47,7 @@ $object = new Project($db);
|
||||
$taskstatic = new Task($db);
|
||||
$extrafields_project = new ExtraFields($db);
|
||||
$extrafields_task = new ExtraFields($db);
|
||||
if ($id > 0 || $ref)
|
||||
if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
$object->fetch($id,$ref);
|
||||
$id=$object->id;
|
||||
@ -130,8 +130,8 @@ if ($action == 'createtask' && $user->rights->projet->creer)
|
||||
if ($taskid > 0)
|
||||
{
|
||||
$result = $task->add_contact($_POST["userid"], 'TASKEXECUTIVE', 'internal');
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessage($task->error,'errors');
|
||||
setEventMessage($task->errors,'errors');
|
||||
@ -183,7 +183,7 @@ llxHeader("",$langs->trans("Tasks"),$help_url);
|
||||
if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
$object->fetch($id, $ref);
|
||||
if ($object->societe->id > 0) $result=$object->societe->fetch($object->societe->id);
|
||||
$object->fetch_thirdparty();
|
||||
$res=$object->fetch_optionals($object->id,$extralabels_projet);
|
||||
|
||||
|
||||
@ -198,7 +198,7 @@ if ($id > 0 || ! empty($ref))
|
||||
|
||||
$head=project_prepare_head($object);
|
||||
dol_fiche_head($head, $tab, $langs->trans("Project"),0,($object->public?'projectpub':'project'));
|
||||
|
||||
|
||||
$param=($mode=='mine'?'&mode=mine':'');
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
@ -221,7 +221,7 @@ if ($id > 0 || ! empty($ref))
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$object->title.'</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("ThirdParty").'</td><td>';
|
||||
if (! empty($object->societe->id)) print $object->societe->getNomUrl(1);
|
||||
if (! empty($object->thirdparty->id)) print $object->thirdparty->getNomUrl(1);
|
||||
else print ' ';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
@ -259,7 +259,7 @@ if ($id > 0 || ! empty($ref))
|
||||
}
|
||||
|
||||
|
||||
if ($action == 'create' && $user->rights->projet->creer && (empty($object->societe->id) || $userWrite > 0))
|
||||
if ($action == 'create' && $user->rights->projet->creer && (empty($object->thirdparty->id) || $userWrite > 0))
|
||||
{
|
||||
if ($id > 0 || ! empty($ref)) print '<br>';
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user