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
|
//if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
|
||||||
|
|
||||||
$object = new Project($db);
|
$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;
|
$id=$object->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,10 +141,6 @@ $userstatic=new User($db);
|
|||||||
|
|
||||||
if ($id > 0 || ! empty($ref))
|
if ($id > 0 || ! empty($ref))
|
||||||
{
|
{
|
||||||
if ( $object->fetch($id,$ref) > 0)
|
|
||||||
{
|
|
||||||
if ($object->societe->id > 0) $result=$object->societe->fetch($object->societe->id);
|
|
||||||
|
|
||||||
// To verify role of users
|
// To verify role of users
|
||||||
//$userAccess = $object->restrictedProjectArea($user,'read');
|
//$userAccess = $object->restrictedProjectArea($user,'read');
|
||||||
$userWrite = $object->restrictedProjectArea($user,'write');
|
$userWrite = $object->restrictedProjectArea($user,'write');
|
||||||
@ -178,7 +175,7 @@ if ($id > 0 || ! empty($ref))
|
|||||||
// Customer
|
// Customer
|
||||||
print "<tr><td>".$langs->trans("ThirdParty")."</td>";
|
print "<tr><td>".$langs->trans("ThirdParty")."</td>";
|
||||||
print '<td colspan="3">';
|
print '<td colspan="3">';
|
||||||
if ($object->societe->id > 0) print $object->societe->getNomUrl(1);
|
if ($object->thirdparty->id > 0) print $object->thirdparty->getNomUrl(1);
|
||||||
else print ' ';
|
else print ' ';
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
@ -212,11 +209,6 @@ if ($id > 0 || ! empty($ref))
|
|||||||
$res=@include dol_buildpath($reldir.'/contacts.tpl.php');
|
$res=@include dol_buildpath($reldir.'/contacts.tpl.php');
|
||||||
if ($res) break;
|
if ($res) break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print "ErrorRecordNotFound";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
llxFooter();
|
llxFooter();
|
||||||
|
|||||||
@ -46,9 +46,9 @@ if ($user->societe_id > 0) $socid=$user->societe_id;
|
|||||||
$result=restrictedArea($user,'projet',$id,'');
|
$result=restrictedArea($user,'projet',$id,'');
|
||||||
|
|
||||||
$object = new Project($db);
|
$object = new Project($db);
|
||||||
$object->fetch($id,$ref);
|
if ($id > 0 || ! empty($ref))
|
||||||
if ($object->id > 0)
|
|
||||||
{
|
{
|
||||||
|
$object->fetch($id,$ref);
|
||||||
$object->fetch_thirdparty();
|
$object->fetch_thirdparty();
|
||||||
$upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref);
|
$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);
|
$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
|
// To verify role of users
|
||||||
//$userAccess = $object->restrictedProjectArea($user,'read');
|
//$userAccess = $object->restrictedProjectArea($user,'read');
|
||||||
$userWrite = $object->restrictedProjectArea($user,'write');
|
$userWrite = $object->restrictedProjectArea($user,'write');
|
||||||
@ -124,7 +122,7 @@ if ($object->id > 0)
|
|||||||
|
|
||||||
// Company
|
// Company
|
||||||
print '<tr><td>'.$langs->trans("ThirdParty").'</td><td>';
|
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 ' ';
|
else print ' ';
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
|
|||||||
@ -61,12 +61,17 @@ $mine = $_REQUEST['mode']=='mine' ? 1 : 0;
|
|||||||
//if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
|
//if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
|
||||||
|
|
||||||
$project = new Project($db);
|
$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;
|
$projectid=$project->id;
|
||||||
}else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
$project->fetch($projectid);
|
$project->fetch($projectid);
|
||||||
|
$project->fetch_thirdparty();
|
||||||
|
$projectid=$project->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
@ -87,10 +92,6 @@ $formproject=new FormProjets($db);
|
|||||||
|
|
||||||
$userstatic=new User($db);
|
$userstatic=new User($db);
|
||||||
|
|
||||||
$project = new Project($db);
|
|
||||||
$project->fetch($projectid,$ref);
|
|
||||||
$project->fetch_thirdparty();
|
|
||||||
|
|
||||||
// To verify role of users
|
// To verify role of users
|
||||||
$userAccess = $project->restrictedProjectArea($user);
|
$userAccess = $project->restrictedProjectArea($user);
|
||||||
|
|
||||||
|
|||||||
@ -49,10 +49,11 @@ $hookmanager->initHooks(array('projectcard'));
|
|||||||
|
|
||||||
$object = new Project($db);
|
$object = new Project($db);
|
||||||
$extrafields = new ExtraFields($db);
|
$extrafields = new ExtraFields($db);
|
||||||
$object->fetch($id,$ref);
|
if ($id > 0 || ! empty($ref))
|
||||||
if ($object->id > 0)
|
|
||||||
{
|
{
|
||||||
|
$object->fetch($id,$ref);
|
||||||
$object->fetch_thirdparty();
|
$object->fetch_thirdparty();
|
||||||
|
$id=$object->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
|
|||||||
@ -38,9 +38,10 @@ $mine = ($mode == 'mine' ? 1 : 0);
|
|||||||
//if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
|
//if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
|
||||||
|
|
||||||
$object = new Project($db);
|
$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;
|
$id=$object->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +70,6 @@ $formother=new FormOther($db);
|
|||||||
$userstatic=new User($db);
|
$userstatic=new User($db);
|
||||||
$companystatic=new Societe($db);
|
$companystatic=new Societe($db);
|
||||||
$task = new Task($db);
|
$task = new Task($db);
|
||||||
$object = new Project($db);
|
|
||||||
|
|
||||||
$arrayofcss=array('/includes/jsgantt/jsgantt.css');
|
$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))
|
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
|
// To verify role of users
|
||||||
//$userAccess = $object->restrictedProjectArea($user,'read');
|
//$userAccess = $object->restrictedProjectArea($user,'read');
|
||||||
$userWrite = $object->restrictedProjectArea($user,'write');
|
$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("Label").'</td><td>'.$object->title.'</td></tr>';
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans("ThirdParty").'</td><td>';
|
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 ' ';
|
else print ' ';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|||||||
@ -36,9 +36,10 @@ $mine = $_REQUEST['mode']=='mine' ? 1 : 0;
|
|||||||
//if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
|
//if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
|
||||||
|
|
||||||
$object = new Project($db);
|
$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;
|
$id=$object->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,16 +67,11 @@ llxHeader("",$langs->trans("Project"),$help_url);
|
|||||||
|
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
$userstatic=new User($db);
|
$userstatic=new User($db);
|
||||||
$object = new Project($db);
|
|
||||||
|
|
||||||
$now=dol_now();
|
$now=dol_now();
|
||||||
|
|
||||||
if ($id > 0 || ! empty($ref))
|
if ($id > 0 || ! empty($ref))
|
||||||
{
|
{
|
||||||
if ($object->fetch($id, $ref))
|
|
||||||
{
|
|
||||||
if ($object->societe->id > 0) $result=$object->societe->fetch($object->societe->id);
|
|
||||||
|
|
||||||
// To verify role of users
|
// To verify role of users
|
||||||
//$userAccess = $object->restrictedProjectArea($user,'read');
|
//$userAccess = $object->restrictedProjectArea($user,'read');
|
||||||
$userWrite = $object->restrictedProjectArea($user,'write');
|
$userWrite = $object->restrictedProjectArea($user,'write');
|
||||||
@ -105,7 +101,7 @@ if ($id > 0 || ! empty($ref))
|
|||||||
|
|
||||||
// Third party
|
// Third party
|
||||||
print '<tr><td>'.$langs->trans("ThirdParty").'</td><td>';
|
print '<tr><td>'.$langs->trans("ThirdParty").'</td><td>';
|
||||||
if ($object->societe->id > 0) print $object->societe->getNomUrl(1);
|
if ($object->thirdparty->id > 0) print $object->thirdparty->getNomUrl(1);
|
||||||
else print' ';
|
else print' ';
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
@ -136,7 +132,6 @@ if ($id > 0 || ! empty($ref))
|
|||||||
include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
|
include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
|
||||||
|
|
||||||
dol_fiche_end();;
|
dol_fiche_end();;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
llxFooter();
|
llxFooter();
|
||||||
|
|||||||
@ -47,7 +47,7 @@ $object = new Project($db);
|
|||||||
$taskstatic = new Task($db);
|
$taskstatic = new Task($db);
|
||||||
$extrafields_project = new ExtraFields($db);
|
$extrafields_project = new ExtraFields($db);
|
||||||
$extrafields_task = new ExtraFields($db);
|
$extrafields_task = new ExtraFields($db);
|
||||||
if ($id > 0 || $ref)
|
if ($id > 0 || ! empty($ref))
|
||||||
{
|
{
|
||||||
$object->fetch($id,$ref);
|
$object->fetch($id,$ref);
|
||||||
$id=$object->id;
|
$id=$object->id;
|
||||||
@ -183,7 +183,7 @@ llxHeader("",$langs->trans("Tasks"),$help_url);
|
|||||||
if ($id > 0 || ! empty($ref))
|
if ($id > 0 || ! empty($ref))
|
||||||
{
|
{
|
||||||
$object->fetch($id, $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);
|
$res=$object->fetch_optionals($object->id,$extralabels_projet);
|
||||||
|
|
||||||
|
|
||||||
@ -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("Label").'</td><td>'.$object->title.'</td></tr>';
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans("ThirdParty").'</td><td>';
|
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 ' ';
|
else print ' ';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '</tr>';
|
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>';
|
if ($id > 0 || ! empty($ref)) print '<br>';
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user