PERF Use cache for loaded users/contact on project list
This commit is contained in:
parent
8b84be2d6c
commit
47511a6903
2 changed files with 59 additions and 45 deletions
|
|
@ -204,8 +204,8 @@ InputPerWeek=Input per week
|
|||
InputPerMonth=Input per month
|
||||
InputDetail=Input detail
|
||||
TimeAlreadyRecorded=This is time spent already recorded for this task/day and user %s
|
||||
ProjectsWithThisUserAsContact=Projects with this user as contact
|
||||
ProjectsWithThisContact=Projects with this third-party contact
|
||||
ProjectsWithThisUserAsContact=Projects assigned to this user
|
||||
ProjectsWithThisContact=Projects assigned to this third-party contact
|
||||
TasksWithThisUserAsContact=Tasks assigned to this user
|
||||
ResourceNotAssignedToProject=Not assigned to project
|
||||
ResourceNotAssignedToTheTask=Not assigned to the task
|
||||
|
|
|
|||
|
|
@ -1135,16 +1135,6 @@ if (isModEnabled('category') && $user->hasRight('categorie', 'lire')) {
|
|||
if (getDolGlobalString('MAIN_SEARCH_CATEGORY_CUSTOMER_ON_PROJECT_LIST') && isModEnabled("category") && $user->hasRight('categorie', 'lire')) {
|
||||
$formcategory = new FormCategory($db);
|
||||
$moreforfilter .= $formcategory->getFilterBox(Categorie::TYPE_CUSTOMER, $searchCategoryCustomerList, 'minwidth300', $searchCategoryCustomerList ? $searchCategoryCustomerList : 0);
|
||||
/*$moreforfilter .= '<div class="divsearchfield">';
|
||||
$tmptitle = $langs->transnoentities('CustomersProspectsCategoriesShort');
|
||||
$moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"');
|
||||
$categoriesArr = $form->select_all_categories(Categorie::TYPE_CUSTOMER, '', '', 64, 0, 3);
|
||||
$categoriesArr[-2] = '- '.$langs->trans('NotCategorized').' -';
|
||||
$moreforfilter .= Form::multiselectarray('search_category_customer_list', $categoriesArr, $searchCategoryCustomerList, 0, 0, 'minwidth300im minwidth300 widthcentpercentminusx', 0, 0, '', 'category', $tmptitle);
|
||||
$moreforfilter .= ' <input type="checkbox" class="valignmiddle" id="search_category_customer_operator" name="search_category_customer_operator" value="1"'.($searchCategoryCustomerOperator == 1 ? ' checked="checked"' : '').'/>';
|
||||
$moreforfilter .= $form->textwithpicto('', $langs->trans('UseOrOperatorForCategories') . ' : ' . $tmptitle, 1, 'help', '', 0, 2, 'tooltip_cat_cus'); // Tooltip on click
|
||||
$moreforfilter .= '</div>';
|
||||
*/
|
||||
}
|
||||
|
||||
if (getDolGlobalInt('PROJECT_ENABLE_SUB_PROJECT')) {
|
||||
|
|
@ -1537,6 +1527,20 @@ while ($i < $imaxinloop) {
|
|||
break; // Should not happen
|
||||
}
|
||||
|
||||
// Thirdparty
|
||||
$companystatic->id = $obj->socid;
|
||||
$companystatic->name = $obj->name;
|
||||
$companystatic->name_alias = $obj->alias;
|
||||
$companystatic->client = $obj->client;
|
||||
$companystatic->code_client = $obj->code_client;
|
||||
$companystatic->email = $obj->email;
|
||||
$companystatic->phone = $obj->phone;
|
||||
$companystatic->address = $obj->address;
|
||||
$companystatic->zip = $obj->zip;
|
||||
$companystatic->town = $obj->town;
|
||||
$companystatic->country_code = $obj->country_code;
|
||||
|
||||
// Project
|
||||
$object->id = $obj->id;
|
||||
$object->ref = $obj->ref;
|
||||
$object->title = $obj->title;
|
||||
|
|
@ -1560,25 +1564,10 @@ while ($i < $imaxinloop) {
|
|||
$object->usage_organize_event = $obj->usage_organize_event;
|
||||
$object->email_msgid = $obj->email_msgid;
|
||||
$object->import_key = $obj->import_key;
|
||||
|
||||
$object->thirdparty = $companystatic;
|
||||
|
||||
//$userAccess = $object->restrictedProjectArea($user); // disabled, permission on project must be done by the select
|
||||
|
||||
// Thirdparty
|
||||
$companystatic->id = $obj->socid;
|
||||
$companystatic->name = $obj->name;
|
||||
$companystatic->name_alias = $obj->alias;
|
||||
$companystatic->client = $obj->client;
|
||||
$companystatic->code_client = $obj->code_client;
|
||||
$companystatic->email = $obj->email;
|
||||
$companystatic->phone = $obj->phone;
|
||||
$companystatic->address = $obj->address;
|
||||
$companystatic->zip = $obj->zip;
|
||||
$companystatic->town = $obj->town;
|
||||
$companystatic->country_code = $obj->country_code;
|
||||
|
||||
$object->thirdparty = $companystatic;
|
||||
|
||||
$stringassignedusers = '';
|
||||
|
||||
if (!empty($arrayfields['c.assigned']['checked'])) {
|
||||
|
|
@ -1590,25 +1579,27 @@ while ($i < $imaxinloop) {
|
|||
foreach ($tab as $contactproject) {
|
||||
//var_dump($contacttask);
|
||||
if ($source == 'internal') {
|
||||
$c = new User($db);
|
||||
if (!empty($conf->cache['user'][$contactproject['id']])) {
|
||||
$c = $conf->cache['user'][$contactproject['id']];
|
||||
} else {
|
||||
$c = new User($db);
|
||||
$c->fetch($contactproject['id']);
|
||||
$conf->cache['user'][$contactproject['id']] = $c;
|
||||
}
|
||||
} else {
|
||||
$c = new Contact($db);
|
||||
if (!empty($conf->cache['contact'][$contactproject['id']])) {
|
||||
$c = $conf->cache['contact'][$contactproject['id']];
|
||||
} else {
|
||||
$c = new Contact($db);
|
||||
$c->fetch($contactproject['id']);
|
||||
$conf->cache['contact'][$contactproject['id']] = $c;
|
||||
}
|
||||
}
|
||||
$c->fetch($contactproject['id']);
|
||||
//var_dump($c->photo);
|
||||
//if (!empty($c->photo)) {
|
||||
if (get_class($c) == 'User') {
|
||||
$stringassignedusers .= $c->getNomUrl(-2, '', 0, 0, 24, 1, '', 'valignmiddle'.($ifisrt ? '' : ' notfirst'));
|
||||
} else {
|
||||
$stringassignedusers .= $c->getNomUrl(-2, '', 0, '', -1, 0, 'valignmiddle'.($ifisrt ? '' : ' notfirst'));
|
||||
}
|
||||
/*} else {
|
||||
if (get_class($c) == 'User') {
|
||||
$stringassignedusers .= $c->getNomUrl(2, '', 0, 0, 24, 1, '', 'valignmiddle'.($ifisrt ? '' : ' notfirst'));
|
||||
} else {
|
||||
$stringassignedusers .= $c->getNomUrl(2, '', 0, '', -1, 0, 'valignmiddle'.($ifisrt ? '' : ' notfirst'));
|
||||
}
|
||||
}*/
|
||||
$ifisrt = 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -1620,12 +1611,17 @@ while ($i < $imaxinloop) {
|
|||
print '<tr class="trkanban"><td colspan="'.$savnbfield.'">';
|
||||
print '<div class="box-flex-container kanban">';
|
||||
}
|
||||
|
||||
$selected = in_array($object->id, $arrayofselected);
|
||||
// Output Kanban
|
||||
$selected = -1;
|
||||
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
|
||||
$selected = 0;
|
||||
if (in_array($object->id, $arrayofselected)) {
|
||||
$selected = 1;
|
||||
}
|
||||
}
|
||||
$arrayofdata = array('assignedusers' => $stringassignedusers, 'thirdparty' => $companystatic, 'selected' => $selected);
|
||||
|
||||
print $object->getKanbanView('', $arrayofdata);
|
||||
|
||||
if ($i == ($imaxinloop - 1)) {
|
||||
print '</div>';
|
||||
print '</td></tr>';
|
||||
|
|
@ -1979,8 +1975,6 @@ while ($i < $imaxinloop) {
|
|||
print '<td class="center tdoverflowmax150">';
|
||||
if ($userstatic->id) {
|
||||
print $userstatic->getNomUrl(-1);
|
||||
} else {
|
||||
print ' ';
|
||||
}
|
||||
print "</td>\n";
|
||||
if (!$i) {
|
||||
|
|
@ -2081,6 +2075,26 @@ print '</div>'."\n";
|
|||
|
||||
print '</form>'."\n";
|
||||
|
||||
if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
|
||||
$hidegeneratedfilelistifempty = 1;
|
||||
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
|
||||
$hidegeneratedfilelistifempty = 0;
|
||||
}
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||
$formfile = new FormFile($db);
|
||||
|
||||
// Show list of available documents
|
||||
$urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
|
||||
$urlsource .= str_replace('&', '&', $param);
|
||||
|
||||
$filedir = $diroutputmassaction;
|
||||
$genallowed = $permissiontoread;
|
||||
$delallowed = $permissiontoadd;
|
||||
|
||||
print $formfile->showdocuments('massfilesarea_'.$object->module, '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
|
||||
}
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
$db->close();
|
||||
|
|
|
|||
Loading…
Reference in a new issue