From a7d472bf7bc2f6d96b5954d39ac2c6e8aee69362 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 29 Mar 2018 12:31:17 +0200 Subject: [PATCH] Dolibarize module ticket --- htdocs/ticketsup/list.php | 119 ++++++++++++++++++++------------------ 1 file changed, 62 insertions(+), 57 deletions(-) diff --git a/htdocs/ticketsup/list.php b/htdocs/ticketsup/list.php index d4b5733ef55..7715803f4de 100644 --- a/htdocs/ticketsup/list.php +++ b/htdocs/ticketsup/list.php @@ -34,7 +34,7 @@ if (!empty($conf->projet->enabled)) { } // Load traductions files requiredby by page -$langs->loadLangs(array("ticketsup","companies","other")); +$langs->loadLangs(array("ticketsup","companies","other","projects")); // Get parameters @@ -53,6 +53,7 @@ $id = GETPOST('id','int'); $msg_id = GETPOST('msg_id', 'int'); $socid = GETPOST('socid', 'int'); $projectid = GETPOST('projectid', 'int'); +$search_fk_project=GETPOST('search_fk_project','int')?GETPOST('search_fk_project','int'):GETPOST('projectid','int'); $search_fk_status = GETPOST('search_fk_status', 'alpha'); $mode = GETPOST('mode', 'alpha'); @@ -112,6 +113,10 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab } $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); +if ($projectid > 0) +{ + unset($arrayfields['t.fk_project']); +} // Filters @@ -121,7 +126,7 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); // $search_type = GETPOST("search_type", 'alpha'); // $search_category = GETPOST("search_category", 'alpha'); // $search_severity = GETPOST("search_severity", 'alpha'); -// $search_project = GETPOST("search_project", 'int'); +// $search_fk_project = GETPOST("search_fk_project", 'int'); // $search_fk_user_create = GETPOST("search_fk_user_create", 'int'); // $search_fk_user_assign = GETPOST("search_fk_user_assign", 'int'); @@ -218,7 +223,7 @@ foreach($search as $key => $val) if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'fk_statut')?2:$mode_search)); } if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); - +if ($search_fk_project) $sql.= natural_search('fk_project', $search_fk_project); if (!$user->societe_id && ($mode == "my_assign" || (!$user->admin && $conf->global->TICKETS_LIMIT_VIEW_ASSIGNED_ONLY))) { $sql.= " AND t.fk_user_assign=".$user->id; } @@ -336,11 +341,14 @@ if ($socid && !$projectid && $user->rights->societe->lire) { } } -if ($projectid) { +if ($projectid > 0) { $projectstat = new Project($db); if ($projectstat->fetch($projectid) > 0) { $projectstat->fetch_thirdparty(); + $savobject = $object; + $object = $projectstat; + // To verify role of users //$userAccess = $object->restrictedProjectArea($user,'read'); $userWrite = $projectstat->restrictedProjectArea($user, 'write'); @@ -348,55 +356,52 @@ if ($projectid) { //print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete; $head = project_prepare_head($projectstat); - dol_fiche_head($head, 'ticketsup', $langs->trans("Project"), 0, ($projectstat->public ? 'projectpub' : 'project')); + dol_fiche_head($head, 'ticketsup', $langs->trans("Project"), -1, ($projectstat->public ? 'projectpub' : 'project')); + + // Project card + + $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref='
'; + // Title + $morehtmlref.=$object->title; + // Thirdparty + if ($object->thirdparty->id > 0) + { + $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1, 'project'); + } + $morehtmlref.='
'; + + // Define a complementary filter for search of next/prev ref. + if (! $user->rights->projet->all->lire) + { + $objectsListId = $object->getProjectsAuthorizedForUser($user,0,0); + $object->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")"; + } + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + print '
'; + print '
'; - /* - * Projet synthese pour rappel - */ print ''; - $linkback = '' . $langs->trans("BackToList") . ''; - - // Ref - print ''; - - // Label - print ''; - - // Customer - print ""; - print ''; - // Visibility - print ''; - // Statut - print ''; - print "
' . $langs->trans('Ref') . ''; - // Define a complementary filter for search of next/prev ref. - if (!$user->rights->projet->all->lire) { - $objectsListId = $projectstat->getProjectsAuthorizedForUser($user, $mine, 0); - $projectstat->next_prev_filter = " rowid in (" . (count($objectsListId) ? join(',', array_keys($objectsListId)) : '0') . ")"; - } - print $form->showrefnav($projectstat, 'ref', $linkback, 1, 'ref', 'ref', ''); - print '
' . $langs->trans("Label") . '' . $projectstat->title . '
" . $langs->trans("ThirdParty") . "'; - if ($projectstat->thirdparty->id > 0) { - print $projectstat->thirdparty->getNomUrl(1); - } else { - print ' '; - } - - print '
' . $langs->trans("Visibility") . ''; + print '
' . $langs->trans("Visibility") . ''; if ($projectstat->public) { print $langs->trans('SharedProject'); } else { print $langs->trans('PrivateProject'); } - print '
' . $langs->trans("Status") . '' . $projectstat->getLibStatut(4) . '
"; print '
'; + dol_fiche_end(); + + $object = $savobject; + } else { print "ErrorRecordNotFound"; } @@ -591,24 +596,24 @@ while ($i < min($num, $limit)) print ''; foreach($object->fields as $key => $val) { - $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; - if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; - if ($key == 'status') $align.=($align?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) - { - print ''; - print $object->showOutputField($val, $key, $obj->$key, ''); - print ''; - if (! $i) $totalarray['nbfield']++; - if (! empty($val['isameasure'])) - { - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; - $totalarray['val']['t.'.$key] += $obj->$key; - } - } + $align=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; + if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; + if ($key == 'status') $align.=($align?' ':'').'center'; + if (! empty($arrayfields['t.'.$key]['checked'])) + { + print ''; + print $object->showOutputField($val, $key, $obj->$key, ''); + print ''; + if (! $i) $totalarray['nbfield']++; + if (! empty($val['isameasure'])) + { + if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; + $totalarray['val']['t.'.$key] += $obj->$key; + } + } } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';