From 7fa96924588c7dde4280141e6f49f847cd9473a1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 2 Nov 2016 12:48:50 +0100 Subject: [PATCH] Uniformize code. Generalize option MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE. --- dev/skeletons/skeleton_list.php | 4 +- htdocs/adherents/list.php | 1023 ++++++++++++++-------------- htdocs/contact/list.php | 2 +- htdocs/product/list.php | 52 +- htdocs/projet/list.php | 1122 ++++++++++++++++--------------- htdocs/projet/tasks/list.php | 1053 +++++++++++++++-------------- htdocs/societe/list.php | 2 +- htdocs/user/index.php | 784 ++++++++++----------- 8 files changed, 2057 insertions(+), 1985 deletions(-) diff --git a/dev/skeletons/skeleton_list.php b/dev/skeletons/skeleton_list.php index da8a9995538..c47a87a8033 100644 --- a/dev/skeletons/skeleton_list.php +++ b/dev/skeletons/skeleton_list.php @@ -58,6 +58,7 @@ $action = GETPOST('action','alpha'); $backtopage = GETPOST('backtopage'); $myparam = GETPOST('myparam','alpha'); +$search_all=trim(GETPOST("sall")); $search_field1=GETPOST("search_field1"); $search_field2=GETPOST("search_field2"); $search_myfield=GETPOST('search_myfield'); @@ -247,7 +248,6 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $sql.= $db->plimit($limit+1, $offset); - dol_syslog($script_file, LOG_DEBUG); $resql=$db->query($sql); if (! $resql) @@ -259,7 +259,7 @@ if (! $resql) $num = $db->num_rows($resql); // Direct jump if only one record found -if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE)) +if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { $obj = $db->fetch_object($resql); $id = $obj->rowid; diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index d3e7e96a793..c98ad4abf31 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -129,44 +129,49 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab } } + /* * Actions */ if (GETPOST('cancel')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction')) { $massaction=''; } +if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction=''; } $parameters=array('socid'=>$socid); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - -// Purge search criteria -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +if (empty($reshook)) { - $search=""; - $search_ref=""; - $search_lastname=""; - $search_firstname=""; - $search_login=""; - $search_company=""; - $type=""; - $search_email=""; - $search_address=""; - $search_zip=""; - $search_town=""; - $search_state=""; - $search_country=''; - $search_phone=''; - $search_phone_perso=''; - $search_phone_mobile=''; - $search_morphy=""; - $search_categ=""; - $catid=""; - $sall=""; - $statut=''; - $search_array_options=array(); + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + + // Purge search criteria + if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers + { + $search=""; + $search_ref=""; + $search_lastname=""; + $search_firstname=""; + $search_login=""; + $search_company=""; + $type=""; + $search_email=""; + $search_address=""; + $search_zip=""; + $search_town=""; + $search_state=""; + $search_country=''; + $search_phone=''; + $search_phone_perso=''; + $search_phone_mobile=''; + $search_morphy=""; + $search_categ=""; + $catid=""; + $sall=""; + $statut=''; + $search_array_options=array(); + } } @@ -179,8 +184,6 @@ $formother=new FormOther($db); $membertypestatic=new AdherentType($db); $memberstatic=new Adherent($db); -llxHeader('',$langs->trans("Member"),'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'); - $now=dol_now(); $sql = "SELECT d.rowid, d.login, d.lastname, d.firstname, d.societe as company, d.fk_soc,"; @@ -259,263 +262,510 @@ $sql.= $db->plimit($limit+1, $offset); dol_syslog("get list", LOG_DEBUG); $resql = $db->query($sql); -if ($resql) +if (! $resql) { - $num = $db->num_rows($resql); - $i = 0; + dol_print_error($db); + exit; +} - $titre=$langs->trans("MembersList"); - if (isset($_GET["statut"])) - { - if ($statut == '-1,1') { $titre=$langs->trans("MembersListQualified"); } - if ($statut == '-1') { $titre=$langs->trans("MembersListToValid"); } - if ($statut == '1' && ! $filter) { $titre=$langs->trans("MembersListValid"); } - if ($statut == '1' && $filter=='uptodate') { $titre=$langs->trans("MembersListUpToDate"); } - if ($statut == '1' && $filter=='outofdate') { $titre=$langs->trans("MembersListNotUpToDate"); } - if ($statut == '0') { $titre=$langs->trans("MembersListResiliated"); } - } - elseif ($action == 'search') - { - $titre=$langs->trans("MembersListQualified"); - } +$num = $db->num_rows($resql); - if ($type > 0) - { - $membertype=new AdherentType($db); - $result=$membertype->fetch(GETPOST("type")); - $titre.=" (".$membertype->libelle.")"; - } +if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) +{ + $obj = $db->fetch_object($resql); + $id = $obj->rowid; + header("Location: ".DOL_URL_ROOT.'/adherents/card.php?id='.$id); + exit; +} - $param=''; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); - if ($statut != "") $param.="&statut=".urlencode($statut); - if ($search_ref) $param.="&search_ref=".urlencode($search_ref); - if ($search_nom) $param.="&search_nom=".urlencode($search_nom); - if ($search_firstname) $param.="&search_firstname=".urlencode($search_firstname); - if ($search_lastname) $param.="&search_lastname=".urlencode($search_lastname); - if ($search_login) $param.="&search_login=".urlencode($search_login); - if ($search_email) $param.="&search_email=".urlencode($search_email); - if ($search_company) $param.="&search_company=".urlencode($search_company); - if ($search_address != '') $param.= "&search_address=".urlencode($search_address); - if ($search_town != '') $param.= "&search_town=".urlencode($search_town); - if ($search_zip != '') $param.= "&search_zip=".urlencode($search_zip); - if ($search_state != '') $param.= "&search_state=".urlencode($search_state); - if ($search_country != '') $param.= "&search_country=".urlencode($search_country); - if ($search_phone != '') $param.= "&search_phone=".urlencode($search_phone); - if ($search_phone_perso != '') $param.= "&search_phone_perso=".urlencode($search_phone_perso); - if ($search_phone_mobile != '') $param.= "&search_phone_mobile=".urlencode($search_phone_mobile); - if ($filter) $param.="&filter=".urlencode($filter); - if ($type > 0) $param.="&type=".urlencode($type); - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); - // Add $param from extra fields - foreach ($search_array_options as $key => $val) - { - $crit=$val; - $tmpkey=preg_replace('/search_options_/','',$key); - if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); - } +llxHeader('',$langs->trans("Member"),'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'); + +$titre=$langs->trans("MembersList"); +if (isset($_GET["statut"])) +{ + if ($statut == '-1,1') { $titre=$langs->trans("MembersListQualified"); } + if ($statut == '-1') { $titre=$langs->trans("MembersListToValid"); } + if ($statut == '1' && ! $filter) { $titre=$langs->trans("MembersListValid"); } + if ($statut == '1' && $filter=='uptodate') { $titre=$langs->trans("MembersListUpToDate"); } + if ($statut == '1' && $filter=='outofdate') { $titre=$langs->trans("MembersListNotUpToDate"); } + if ($statut == '0') { $titre=$langs->trans("MembersListResiliated"); } +} +elseif ($action == 'search') +{ + $titre=$langs->trans("MembersListQualified"); +} + +if ($type > 0) +{ + $membertype=new AdherentType($db); + $result=$membertype->fetch(GETPOST("type")); + $titre.=" (".$membertype->libelle.")"; +} + +$param=''; +if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; +if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; +if ($sall != "") $param.="&sall=".urlencode($sall); +if ($statut != "") $param.="&statut=".urlencode($statut); +if ($search_ref) $param.="&search_ref=".urlencode($search_ref); +if ($search_nom) $param.="&search_nom=".urlencode($search_nom); +if ($search_firstname) $param.="&search_firstname=".urlencode($search_firstname); +if ($search_lastname) $param.="&search_lastname=".urlencode($search_lastname); +if ($search_login) $param.="&search_login=".urlencode($search_login); +if ($search_email) $param.="&search_email=".urlencode($search_email); +if ($search_company) $param.="&search_company=".urlencode($search_company); +if ($search_address != '') $param.= "&search_address=".urlencode($search_address); +if ($search_town != '') $param.= "&search_town=".urlencode($search_town); +if ($search_zip != '') $param.= "&search_zip=".urlencode($search_zip); +if ($search_state != '') $param.= "&search_state=".urlencode($search_state); +if ($search_country != '') $param.= "&search_country=".urlencode($search_country); +if ($search_phone != '') $param.= "&search_phone=".urlencode($search_phone); +if ($search_phone_perso != '') $param.= "&search_phone_perso=".urlencode($search_phone_perso); +if ($search_phone_mobile != '') $param.= "&search_phone_mobile=".urlencode($search_phone_mobile); +if ($filter) $param.="&filter=".urlencode($filter); +if ($type > 0) $param.="&type=".urlencode($type); +if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +// Add $param from extra fields +foreach ($search_array_options as $key => $val) +{ + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); +} + +//$massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"))); + +print '
'; +if ($optioncss != '') print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +print_barre_liste($titre, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic.png', 0, '', '', $limit); + +if ($sall) +{ + foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); + print $langs->trans("FilterOnInto", $sall) . implode(', ',$fieldstosearchall); +} + +// Filter on categories +$moreforfilter=''; +if (! empty($conf->categorie->enabled)) +{ + require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + $moreforfilter.='
'; + $moreforfilter.=$langs->trans('Categories'). ': '; + $moreforfilter.=$formother->select_categories(Categorie::TYPE_MEMBER,$search_categ,'search_categ',1); + $moreforfilter.='
'; +} +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook +if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; +else $moreforfilter = $hookmanager->resPrint; +if (! empty($moreforfilter)) +{ + print '
'; + print $moreforfilter; + print '
'; +} + +$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; +$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + +print ''."\n"; +print ''; +if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) +{ + print ''; +} +if (! empty($arrayfields['d.ref']['checked'])) print_liste_field_titre($arrayfields['d.ref']['label'],$_SERVER["PHP_SELF"],'d.rowid','',$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['d.firstname']['checked'])) print_liste_field_titre($arrayfields['d.firstname']['label'],$_SERVER["PHP_SELF"],'d.firstname','',$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['d.lastname']['checked'])) print_liste_field_titre($arrayfields['d.lastname']['label'],$_SERVER["PHP_SELF"],'d.lastname','',$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['d.company']['checked'])) print_liste_field_titre($arrayfields['d.company']['label'],$_SERVER["PHP_SELF"],'d.societe','',$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['d.login']['checked'])) print_liste_field_titre($arrayfields['d.login']['label'],$_SERVER["PHP_SELF"],'d.login','',$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['d.morphy']['checked'])) print_liste_field_titre($arrayfields['d.morphy']['label'],$_SERVER["PHP_SELF"],'d.morphy','',$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['t.libelle']['checked'])) print_liste_field_titre($arrayfields['t.libelle']['label'],$_SERVER["PHP_SELF"],'t.libelle','',$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['d.address']['checked'])) print_liste_field_titre($arrayfields['d.address']['label'],$_SERVER["PHP_SELF"],'d.address','',$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['d.zip']['checked'])) print_liste_field_titre($arrayfields['d.zip']['label'],$_SERVER["PHP_SELF"],'d.zip','',$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['d.town']['checked'])) print_liste_field_titre($arrayfields['d.town']['label'],$_SERVER["PHP_SELF"],'d.town','',$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($langs->trans("StateShort"),$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($langs->trans("Country"),$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder); +if (! empty($arrayfields['d.phone']['checked'])) print_liste_field_titre($arrayfields['d.phone']['label'],$_SERVER["PHP_SELF"],'d.phone','',$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['d.phone_perso']['checked'])) print_liste_field_titre($arrayfields['d.phone_perso']['label'],$_SERVER["PHP_SELF"],'d.phone_perso','',$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['d.phone_mobile']['checked'])) print_liste_field_titre($arrayfields['d.phone_mobile']['label'],$_SERVER["PHP_SELF"],'d.phone_mobile','',$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['d.email']['checked'])) print_liste_field_titre($arrayfields['d.email']['label'],$_SERVER["PHP_SELF"],'d.email','',$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['d.datefin']['checked'])) print_liste_field_titre($arrayfields['d.datefin']['label'],$_SERVER["PHP_SELF"],'d.datefin','',$param,'align="center"',$sortfield,$sortorder); +// Extra fields +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +{ + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + $align=$extrafields->getAlignFlag($key); + print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); + } + } +} +// Hook fields +$parameters=array('arrayfields'=>$arrayfields); +$reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +if (! empty($arrayfields['d.datec']['checked'])) print_liste_field_titre($arrayfields['d.datec']['label'],$_SERVER["PHP_SELF"],"d.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['d.tms']['checked'])) print_liste_field_titre($arrayfields['d.tms']['label'],$_SERVER["PHP_SELF"],"d.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['d.statut']['checked'])) print_liste_field_titre($arrayfields['d.statut']['label'],$_SERVER["PHP_SELF"],"d.statut","",$param,'align="right"',$sortfield,$sortorder); +print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch '); +print "\n"; + +// Line for filters fields +print ''; + +// Line numbering +if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) +{ + print ''; +} + +// Ref +if (! empty($arrayfields['d.ref']['checked'])) +{ + print ''; +} + +if (! empty($arrayfields['d.firstname']['checked'])) +{ + print ''; +} + +if (! empty($arrayfields['d.lastname']['checked'])) +{ + print ''; +} + +if (! empty($arrayfields['d.company']['checked'])) +{ + print ''; +} + +if (! empty($arrayfields['d.login']['checked'])) +{ + print ''; +} + +if (! empty($arrayfields['d.morphy']['checked'])) +{ + print ''; +} + +if (! empty($arrayfields['t.libelle']['checked'])) +{ + print ''; +} + +if (! empty($arrayfields['d.address']['checked'])) +{ + print ''; +} + +if (! empty($arrayfields['d.zip']['checked'])) +{ + print ''; +} +if (! empty($arrayfields['d.town']['checked'])) +{ + print ''; +} +// State +if (! empty($arrayfields['state.nom']['checked'])) +{ + print ''; +} +// Country +if (! empty($arrayfields['country.code_iso']['checked'])) +{ + print ''; +} +// Phone pro +if (! empty($arrayfields['d.phone']['checked'])) +{ + print ''; +} +// Phone perso +if (! empty($arrayfields['d.phone_perso']['checked'])) +{ + print ''; +} +// Phone mobile +if (! empty($arrayfields['d.phone_mobile']['checked'])) +{ + print ''; +} +// Email +if (! empty($arrayfields['d.email']['checked'])) +{ + print ''; +} + +if (! empty($arrayfields['d.datefin']['checked'])) +{ + print ''; +} +// Extra fields +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +{ + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + $align=$extrafields->getAlignFlag($key); + $typeofextrafield=$extrafields->attribute_type[$key]; + print ''; + } + } +} +// Fields from hook +$parameters=array('arrayfields'=>$arrayfields); +$reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +// Date creation +if (! empty($arrayfields['d.datec']['checked'])) +{ + print ''; +} +// Date modification +if (! empty($arrayfields['d.tms']['checked'])) +{ + print ''; +} +// Status +if (! empty($arrayfields['d.statut']['checked'])) +{ + print ''; +} +// Action column +print ''; + +print "\n"; + +$var=True; +$i = 0; +while ($i < $num && $i < $conf->liste_limit) +{ + $obj = $db->fetch_object($resql); + + $datefin=$db->jdate($obj->datefin); + $memberstatic->id=$obj->rowid; + $memberstatic->ref=$obj->rowid; + $memberstatic->lastname=$obj->lastname; + $memberstatic->firstname=$obj->firstname; + $memberstatic->societe=$obj->company; + $memberstatic->statut=$obj->statut; + $memberstatic->datefin= $datefin; + $memberstatic->socid = $obj->fk_soc; - //$massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"))); - - print ''; - if ($optioncss != '') print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - print_barre_liste($titre, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic.png', 0, '', '', $limit); - - if ($sall) - { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print $langs->trans("FilterOnInto", $sall) . implode(', ',$fieldstosearchall); + if (! empty($obj->fk_soc)) { + $memberstatic->fetch_thirdparty(); + $companyname=$memberstatic->thirdparty->name; + } else { + $companyname=$obj->company; } - // Filter on categories - $moreforfilter=''; - if (! empty($conf->categorie->enabled)) - { - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('Categories'). ': '; - $moreforfilter.=$formother->select_categories(Categorie::TYPE_MEMBER,$search_categ,'search_categ',1); - $moreforfilter.='
'; - } - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook - if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; - else $moreforfilter = $hookmanager->resPrint; - if (! empty($moreforfilter)) - { - print '
'; - print $moreforfilter; - print '
'; - } - - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + $var=!$var; + print ""; - print '
'.$langs->trans("NumberingShort").'
 '; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $listetype=$membertypestatic->liste_array(); + print $form->selectarray("type", $listetype, $type, 1, 0, 0, '', 0, 32); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print $form->select_country($search_country,'search_country','',0,'maxwidth100'); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + { + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $searchclass=''; + if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; + if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + print ''; + } + print ''; + print ''; + print ''; + $liststatus=array( + '-1'=>$langs->trans("Draft"), + '1'=>$langs->trans("Validated"), + '0'=>$langs->trans("Resiliated") + ); + print $form->selectarray('statut', $liststatus, $statut, -2); + print ''; +$searchpitco=$form->showFilterAndCheckAddButtons(0); +print $searchpitco; +print '
'."\n"; - print ''; if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { - print ''; + print ''; } - if (! empty($arrayfields['d.ref']['checked'])) print_liste_field_titre($arrayfields['d.ref']['label'],$_SERVER["PHP_SELF"],'d.rowid','',$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['d.firstname']['checked'])) print_liste_field_titre($arrayfields['d.firstname']['label'],$_SERVER["PHP_SELF"],'d.firstname','',$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['d.lastname']['checked'])) print_liste_field_titre($arrayfields['d.lastname']['label'],$_SERVER["PHP_SELF"],'d.lastname','',$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['d.company']['checked'])) print_liste_field_titre($arrayfields['d.company']['label'],$_SERVER["PHP_SELF"],'d.societe','',$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['d.login']['checked'])) print_liste_field_titre($arrayfields['d.login']['label'],$_SERVER["PHP_SELF"],'d.login','',$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['d.morphy']['checked'])) print_liste_field_titre($arrayfields['d.morphy']['label'],$_SERVER["PHP_SELF"],'d.morphy','',$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['t.libelle']['checked'])) print_liste_field_titre($arrayfields['t.libelle']['label'],$_SERVER["PHP_SELF"],'t.libelle','',$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['d.address']['checked'])) print_liste_field_titre($arrayfields['d.address']['label'],$_SERVER["PHP_SELF"],'d.address','',$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['d.zip']['checked'])) print_liste_field_titre($arrayfields['d.zip']['label'],$_SERVER["PHP_SELF"],'d.zip','',$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['d.town']['checked'])) print_liste_field_titre($arrayfields['d.town']['label'],$_SERVER["PHP_SELF"],'d.town','',$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($langs->trans("StateShort"),$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($langs->trans("Country"),$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['d.phone']['checked'])) print_liste_field_titre($arrayfields['d.phone']['label'],$_SERVER["PHP_SELF"],'d.phone','',$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['d.phone_perso']['checked'])) print_liste_field_titre($arrayfields['d.phone_perso']['label'],$_SERVER["PHP_SELF"],'d.phone_perso','',$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['d.phone_mobile']['checked'])) print_liste_field_titre($arrayfields['d.phone_mobile']['label'],$_SERVER["PHP_SELF"],'d.phone_mobile','',$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['d.email']['checked'])) print_liste_field_titre($arrayfields['d.email']['label'],$_SERVER["PHP_SELF"],'d.email','',$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['d.datefin']['checked'])) print_liste_field_titre($arrayfields['d.datefin']['label'],$_SERVER["PHP_SELF"],'d.datefin','',$param,'align="center"',$sortfield,$sortorder); - // Extra fields - if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) - { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) - { - $align=$extrafields->getAlignFlag($key); - print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); - } - } - } - // Hook fields - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (! empty($arrayfields['d.datec']['checked'])) print_liste_field_titre($arrayfields['d.datec']['label'],$_SERVER["PHP_SELF"],"d.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); - if (! empty($arrayfields['d.tms']['checked'])) print_liste_field_titre($arrayfields['d.tms']['label'],$_SERVER["PHP_SELF"],"d.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); - if (! empty($arrayfields['d.statut']['checked'])) print_liste_field_titre($arrayfields['d.statut']['label'],$_SERVER["PHP_SELF"],"d.statut","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch '); - print "\n"; - // Line for filters fields - print ''; - - // Line numbering - if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) - { - print ''; - } - // Ref if (! empty($arrayfields['d.ref']['checked'])) { - print ''; - } - + print "\n"; + } + // Firstname if (! empty($arrayfields['d.firstname']['checked'])) { - print ''; + print "\n"; } - + // Lastname if (! empty($arrayfields['d.lastname']['checked'])) { - print ''; + print "\n"; } - + // Company if (! empty($arrayfields['d.company']['checked'])) { - print ''; + print "\n"; } - + // Login if (! empty($arrayfields['d.login']['checked'])) { - print ''; + print "\n"; } - - if (! empty($arrayfields['d.morphy']['checked'])) + // Moral/Physique + if (! empty($arrayfields['d.morphy']['checked'])) { - print ''; + print "\n"; } - + // Type label if (! empty($arrayfields['t.libelle']['checked'])) { - print ''; } - - if (! empty($arrayfields['d.address']['checked'])) + // Address + if (! empty($arrayfields['d.address']['checked'])) { - print ''; + print ''; } - - if (! empty($arrayfields['d.zip']['checked'])) + // Zip + if (! empty($arrayfields['d.zip']['checked'])) { - print ''; + print ''; + if (! $i) $totalarray['nbfield']++; } - if (! empty($arrayfields['d.town']['checked'])) + // Town + if (! empty($arrayfields['d.town']['checked'])) { - print ''; + print ''; + if (! $i) $totalarray['nbfield']++; } // State if (! empty($arrayfields['state.nom']['checked'])) { - print ''; + print "\n"; + if (! $i) $totalarray['nbfield']++; } // Country if (! empty($arrayfields['country.code_iso']['checked'])) { - print ''; + if (! $i) $totalarray['nbfield']++; } // Phone pro if (! empty($arrayfields['d.phone']['checked'])) { - print ''; + print ''; + if (! $i) $totalarray['nbfield']++; } // Phone perso if (! empty($arrayfields['d.phone_perso']['checked'])) { - print ''; + print ''; + if (! $i) $totalarray['nbfield']++; } // Phone mobile if (! empty($arrayfields['d.phone_mobile']['checked'])) { - print ''; + print ''; + if (! $i) $totalarray['nbfield']++; } - // Email - if (! empty($arrayfields['d.email']['checked'])) + // EMail + if (! empty($arrayfields['d.email']['checked'])) { - print ''; + print "\n"; } - - if (! empty($arrayfields['d.datefin']['checked'])) + // End of subscription date + $datefin=$db->jdate($obj->datefin); + if (! empty($arrayfields['d.datefin']['checked'])) { - print ''; + if ($datefin) + { + print ''; + } + else + { + print ''; + } } // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) @@ -524,315 +774,78 @@ if ($resql) { if (! empty($arrayfields["ef.".$key]['checked'])) { + print 'getAlignFlag($key); - $typeofextrafield=$extrafields->attribute_type[$key]; - print ''; + if (! $i) $totalarray['nbfield']++; } } } // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation if (! empty($arrayfields['d.datec']['checked'])) { - print ''; + if (! $i) $totalarray['nbfield']++; } // Date modification if (! empty($arrayfields['d.tms']['checked'])) { - print ''; + if (! $i) $totalarray['nbfield']++; } // Status if (! empty($arrayfields['d.statut']['checked'])) { - print ''; + if (! $i) $totalarray['nbfield']++; } // Action column - print ''; - - print "\n"; - - $var=True; - while ($i < $num && $i < $conf->liste_limit) + print '"; - - if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) - { - print ''; - } - - // Ref - if (! empty($arrayfields['d.ref']['checked'])) - { - print "\n"; - } - // Firstname - if (! empty($arrayfields['d.firstname']['checked'])) - { - print "\n"; - } - // Lastname - if (! empty($arrayfields['d.lastname']['checked'])) - { - print "\n"; - } - // Company - if (! empty($arrayfields['d.company']['checked'])) - { - print "\n"; - } - // Login - if (! empty($arrayfields['d.login']['checked'])) - { - print "\n"; - } - // Moral/Physique - if (! empty($arrayfields['d.morphy']['checked'])) - { - print "\n"; - } - // Type label - if (! empty($arrayfields['t.libelle']['checked'])) - { - $membertypestatic->id=$obj->type_id; - $membertypestatic->libelle=$obj->type; - print ''; - } - // Address - if (! empty($arrayfields['d.address']['checked'])) - { - print ''; - } - // Zip - if (! empty($arrayfields['d.zip']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Town - if (! empty($arrayfields['d.town']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // State - if (! empty($arrayfields['state.nom']['checked'])) - { - print "\n"; - if (! $i) $totalarray['nbfield']++; - } - // Country - if (! empty($arrayfields['country.code_iso']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Phone pro - if (! empty($arrayfields['d.phone']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Phone perso - if (! empty($arrayfields['d.phone_perso']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Phone mobile - if (! empty($arrayfields['d.phone_mobile']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // EMail - if (! empty($arrayfields['d.email']['checked'])) - { - print "\n"; - } - // End of subscription date - $datefin=$db->jdate($obj->datefin); - if (! empty($arrayfields['d.datefin']['checked'])) - { - if ($datefin) - { - print ''; - } - else - { - print ''; - } - } - // Extra fields - if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) - { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) - { - print 'getAlignFlag($key); - if ($align) print ' align="'.$align.'"'; - print '>'; - $tmpkey='options_'.$key; - print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); - print ''; - if (! $i) $totalarray['nbfield']++; - } - } - } - // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (! empty($arrayfields['d.datec']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Date modification - if (! empty($arrayfields['d.tms']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Status - if (! empty($arrayfields['d.statut']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Action column - print '"; - if (! $i) $totalarray['nbfield']++; - - print "\n"; - $i++; + print "rowid."&action=edit&backtopage=1\">".img_edit().""; } - - $db->free($resql); - - $parameters=array('sql' => $sql); - $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - print "
'.$langs->trans("NumberingShort").''.($i+1).'
 '; - print ''; - print '"; + print $memberstatic->getNomUrl(1); + print "'; - print '"; + print $obj->firstname; + print "'; - print '"; + print $obj->lastname; + print "'; - print '"; + print $companyname; + print "'; - print '".$obj->login."'; - print '".$memberstatic->getmorphylib($obj->morphy)."'; - $listetype=$membertypestatic->liste_array(); - print $form->selectarray("type", $listetype, $type, 1, 0, 0, '', 0, 32); + $membertypestatic->id=$obj->type_id; + $membertypestatic->libelle=$obj->type; + print ''; + print $membertypestatic->getNomUrl(1,32); print ''; - print ''; + print $obj->address; + print ''; - print ''; + print $obj->zip; + print ''; - print ''; + print $obj->town; + print ''; - print ''; - print '".$obj->state_name."'; - print $form->select_country($search_country,'search_country','',0,'maxwidth100'); + print ''; + $tmparray=getCountry($obj->country,'all'); + print $tmparray['label']; print ''; - print ''; + print $obj->phone; + print ''; - print ''; + print $obj->phone_perso; + print ''; - print ''; + print $obj->phone_mobile; + print ''; - print '".dol_print_email($obj->email,0,0,1)."'; - print ''; + print dol_print_date($datefin,'day'); + if ($memberstatic->hasDelay()) { + print " ".img_warning($langs->trans("SubscriptionLate")); + } + print ''; + if ($obj->subscription == 'yes') + { + print $langs->trans("SubscriptionNotReceived"); + if ($obj->statut > 0) print " ".img_warning(); + } + else + { + print ' '; + } + print ''; - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) - { - $crit=$val; - $tmpkey=preg_replace('/search_options_/','',$key); - $searchclass=''; - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; - print ''; - } + if ($align) print ' align="'.$align.'"'; + print '>'; + $tmpkey='options_'.$key; + print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); print ''; + print ''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); print ''; + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour'); print ''; - $liststatus=array( - '-1'=>$langs->trans("Draft"), - '1'=>$langs->trans("Validated"), - '0'=>$langs->trans("Resiliated") - ); - print $form->selectarray('statut', $liststatus, $statut, -2); + print ''; + print $memberstatic->LibStatut($obj->statut,$obj->subscription,$datefin,2); print ''; - $searchpitco=$form->showFilterAndCheckAddButtons(0); - print $searchpitco; - print '
'; + if ($user->rights->adherent->creer) { - $obj = $db->fetch_object($resql); - - $datefin=$db->jdate($obj->datefin); - $memberstatic->id=$obj->rowid; - $memberstatic->ref=$obj->rowid; - $memberstatic->lastname=$obj->lastname; - $memberstatic->firstname=$obj->firstname; - $memberstatic->societe=$obj->company; - $memberstatic->statut=$obj->statut; - $memberstatic->datefin= $datefin; - $memberstatic->socid = $obj->fk_soc; - - if (! empty($obj->fk_soc)) { - $memberstatic->fetch_thirdparty(); - $companyname=$memberstatic->thirdparty->name; - } else { - $companyname=$obj->company; - } - - $var=!$var; - print "
'.($i+1).'"; - print $memberstatic->getNomUrl(1); - print ""; - print $obj->firstname; - print ""; - print $obj->lastname; - print ""; - print $companyname; - print "".$obj->login."".$memberstatic->getmorphylib($obj->morphy)."'; - print $membertypestatic->getNomUrl(1,32); - print ''; - print $obj->address; - print ''; - print $obj->zip; - print ''; - print $obj->town; - print '".$obj->state_name."'; - $tmparray=getCountry($obj->country,'all'); - print $tmparray['label']; - print ''; - print $obj->phone; - print ''; - print $obj->phone_perso; - print ''; - print $obj->phone_mobile; - print '".dol_print_email($obj->email,0,0,1)."'; - print dol_print_date($datefin,'day'); - if ($memberstatic->hasDelay()) { - print " ".img_warning($langs->trans("SubscriptionLate")); - } - print ''; - if ($obj->subscription == 'yes') - { - print $langs->trans("SubscriptionNotReceived"); - if ($obj->statut > 0) print " ".img_warning(); - } - else - { - print ' '; - } - print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour'); - print ''; - print $memberstatic->LibStatut($obj->statut,$obj->subscription,$datefin,2); - print ''; - if ($user->rights->adherent->creer) - { - print "rowid."&action=edit&backtopage=1\">".img_edit().""; - } - print ' '; - if ($user->rights->adherent->supprimer && $obj->statut == -1) - { - print "rowid."&action=delete&backtopage=1\">".img_picto($langs->trans("Delete"),'disable.png').""; - } - if ($user->rights->adherent->supprimer && $obj->statut == 1) - { - print "rowid."&action=resign&backtopage=1\">".img_picto($langs->trans("Resiliate"),'disable.png').""; - } - print "
\n"; - print '
'; - - if ($num > $limit || $page) print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic.png', 0, '', '', $limit, 1); -} -else -{ - dol_print_error($db); + print ' '; + if ($user->rights->adherent->supprimer && $obj->statut == -1) + { + print "rowid."&action=delete&backtopage=1\">".img_picto($langs->trans("Delete"),'disable.png').""; + } + if ($user->rights->adherent->supprimer && $obj->statut == 1) + { + print "rowid."&action=resign&backtopage=1\">".img_picto($langs->trans("Resiliate"),'disable.png').""; + } + print ""; + if (! $i) $totalarray['nbfield']++; + + print "\n"; + $i++; } +$db->free($resql); + +$parameters=array('sql' => $sql); +$reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + +print "\n"; +print ''; + +if ($num > $limit || $page) print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic.png', 0, '', '', $limit, 1); + llxFooter(); - $db->close(); diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index bc8c3235242..7b2e5528eb6 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -385,7 +385,7 @@ if (! $result) $num = $db->num_rows($result); -if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE)) +if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) { $obj = $db->fetch_object($resql); $id = $obj->cidp; diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 671e6db3af3..3e2f21e4ecd 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -170,26 +170,38 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab } - + /* * Actions */ -include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; +if (GETPOST('cancel')) { $action='list'; $massaction=''; } +if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions',$parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) { - $sall=""; - $sref=""; - $snom=""; - $sbarcode=""; - $search_categ=0; - $tosell=""; - $tobuy=""; - $search_tobatch=''; - $search_accountancy_code_sell=''; - $search_accountancy_code_buy=''; - $search_array_options=array(); + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + + // Purge search criteria + if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers + { + $sall=""; + $sref=""; + $snom=""; + $sbarcode=""; + $search_categ=0; + $tosell=""; + $tobuy=""; + $search_tobatch=''; + $search_accountancy_code_sell=''; + $search_accountancy_code_buy=''; + $search_array_options=array(); + } } @@ -305,13 +317,12 @@ else { $num = $db->num_rows($resql); - $i = 0; - - if ($num == 1 && ($sall || $snom || $sref || $sbarcode) && $action != 'list') + if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) { - $objp = $db->fetch_object($resql); - header("Location: card.php?id=".$objp->rowid); - exit; + $obj = $db->fetch_object($resql); + $id = $obj->rowid; + header("Location: ".DOL_URL_ROOT.'/product/card.php?id='.$id); + exit; } $helpurl=''; @@ -585,6 +596,7 @@ else $product_fourn =new ProductFournisseur($db); $var=true; + $i = 0; while ($i < min($num,$limit)) { $objp = $db->fetch_object($resql); diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 56da78cdbcf..787d902768d 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -142,34 +142,44 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab * Actions */ -include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; +if (GETPOST('cancel')) { $action='list'; $massaction=''; } +if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction=''; } -// Do we click on purge search criteria ? -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +$parameters=array('socid'=>$socid); +$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) { - $search_all=''; - $search_categ=''; - $search_ref=""; - $search_label=""; - $search_societe=""; - $search_year=""; - $search_status=-1; - $search_opp_status=-1; - $search_opp_amount=''; - $search_opp_percent=''; - $search_budget_amount=''; - $search_public=""; - $search_sale=""; - $search_user=''; - $sday=""; - $smonth=""; - $syear=""; - $day=""; - $month=""; - $year=""; - $search_array_options=array(); -} + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + // Purge search criteria + if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers + { + $search_all=''; + $search_categ=''; + $search_ref=""; + $search_label=""; + $search_societe=""; + $search_year=""; + $search_status=-1; + $search_opp_status=-1; + $search_opp_amount=''; + $search_opp_percent=''; + $search_budget_amount=''; + $search_public=""; + $search_sale=""; + $search_user=''; + $sday=""; + $smonth=""; + $syear=""; + $day=""; + $month=""; + $year=""; + $search_array_options=array(); + } +} /* @@ -185,8 +195,6 @@ $formproject = new FormProjets($db); $title=$langs->trans("Projects"); if ($search_user == $user->id) $title=$langs->trans("MyProjects"); -llxHeader("",$title,"EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"); - // Get list of project id allowed to user (in a string list separated by coma) if (! $user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1,$socid); @@ -320,538 +328,546 @@ $sql.= $db->plimit($limit + 1,$offset); dol_syslog("list allowed project", LOG_DEBUG); //print $sql; $resql = $db->query($sql); -if ($resql) +if (! $resql) { - $var=true; - $num = $db->num_rows($resql); - - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($sday) $param.='&sday='.$day; - if ($smonth) $param.='&smonth='.$smonth; - if ($syear) $param.='&syear=' .$syear; - if ($day) $param.='&day='.$day; - if ($month) $param.='&month='.$month; - if ($year) $param.='&year=' .$year; - if ($socid) $param.='&socid='.$socid; - if ($search_all != '') $param.='&search_all='.$search_all; - if ($search_ref != '') $param.='&search_ref='.$search_ref; - if ($search_label != '') $param.='&search_label='.$search_label; - if ($search_societe != '') $param.='&search_societe='.$search_societe; - if ($search_status >= 0) $param.='&search_status='.$search_status; - if ((is_numeric($search_opp_status) && $search_opp_status >= 0) || in_array($search_opp_status, array('all','openedopp','none'))) $param.='&search_opp_status='.urlencode($search_opp_status); - if ((is_numeric($search_opp_percent) && $search_opp_percent >= 0) || in_array($search_opp_percent, array('all','openedopp','none'))) $param.='&search_opp_percent='.urlencode($search_opp_percent); - if ($search_public != '') $param.='&search_public='.$search_public; - if ($search_user > 0) $param.='&search_user='.$search_user; - if ($search_sale > 0) $param.='&search_sale='.$search_sale; - if ($search_opp_amount != '') $param.='&search_opp_amount='.$search_opp_amount; - if ($search_budget_amount != '') $param.='&search_budget_amount='.$search_budget_amount; - if ($optioncss != '') $param.='&optioncss='.$optioncss; - // Add $param from extra fields - foreach ($search_array_options as $key => $val) - { - $crit=$val; - $tmpkey=preg_replace('/search_options_/','',$key); - if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); - } - - $text=$langs->trans("Projects"); - if ($search_user == $user->id) $text=$langs->trans('MyProjects'); - - print '
'; - if ($optioncss != '') print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - print_barre_liste($text, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, "", $num, $nbtotalofrecords, 'title_project', 0, '', '', $limit); - - // Show description of content - if ($search_user == $user->id) print $langs->trans("MyProjectsDesc").'

'; - else - { - if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").'

'; - else print $langs->trans("ProjectsPublicDesc").'

'; - } - - if ($search_all) - { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print $langs->trans("FilterOnInto", $search_all) . join(', ',$fieldstosearchall); - } - - $moreforfilter=''; - - // Filter on categories - if (! empty($conf->categorie->enabled)) - { - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('Categories'). ': '; - $moreforfilter.=$formother->select_categories('project',$search_categ,'search_categ',1); - $moreforfilter.='
'; - } - - // If the user can view user other than himself - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('ProjectsWithThisUserAsContact'). ': '; - $includeonly=''; - if (empty($user->rights->user->user->lire)) $includeonly=array($user->id); - $moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth300'); - $moreforfilter.='
'; - - // If the user can view thirdparties other than his' - if ($user->rights->societe->client->voir || $socid) - { - $langs->load("commercial"); - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': '; - $moreforfilter.=$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth300'); - $moreforfilter.='
'; - } - - if (! empty($moreforfilter)) - { - print '
'; - print $moreforfilter; - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - print '
'; - } - - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - - print ''; - - print ''; - if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'],$_SERVER["PHP_SELF"],"p.ref","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['p.title']['checked'])) print_liste_field_titre($arrayfields['p.title']['label'],$_SERVER["PHP_SELF"],"p.title","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'],$_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['commercial']['checked'])) print_liste_field_titre($arrayfields['commercial']['label'],$_SERVER["PHP_SELF"],"","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['p.dateo']['checked'])) print_liste_field_titre($arrayfields['p.dateo']['label'],$_SERVER["PHP_SELF"],"p.dateo","",$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['p.datee']['checked'])) print_liste_field_titre($arrayfields['p.datee']['label'],$_SERVER["PHP_SELF"],"p.datee","",$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['p.public']['checked'])) print_liste_field_titre($arrayfields['p.public']['label'],$_SERVER["PHP_SELF"],"p.public","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['p.opp_amount']['checked'])) print_liste_field_titre($arrayfields['p.opp_amount']['label'],$_SERVER["PHP_SELF"],'p.opp_amount',"",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.fk_opp_status']['checked'])) print_liste_field_titre($arrayfields['p.fk_opp_status']['label'],$_SERVER["PHP_SELF"],'p.fk_opp_status',"",$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['p.opp_percent']['checked'])) print_liste_field_titre($arrayfields['p.opp_percent']['label'],$_SERVER["PHP_SELF"],'p.opp_percent',"",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.budget_amount']['checked'])) print_liste_field_titre($arrayfields['p.budget_amount']['label'],$_SERVER["PHP_SELF"],'p.budget_amount',"",$param,'align="right"',$sortfield,$sortorder); - // Extra fields - if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) - { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) - { - $align=$extrafields->getAlignFlag($key); - print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); - } - } - } - // Hook fields - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (! empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'],$_SERVER["PHP_SELF"],"p.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); - if (! empty($arrayfields['p.tms']['checked'])) print_liste_field_titre($arrayfields['p.tms']['label'],$_SERVER["PHP_SELF"],"p.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); - if (! empty($arrayfields['p.fk_statut']['checked'])) print_liste_field_titre($arrayfields['p.fk_statut']['label'],$_SERVER["PHP_SELF"],"p.fk_statut","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch '); - print "\n"; - - print ''; - if (! empty($arrayfields['p.ref']['checked'])) - { - print ''; - } - if (! empty($arrayfields['p.title']['checked'])) - { - print ''; - } - if (! empty($arrayfields['s.nom']['checked'])) - { - print ''; - } - // Sale representative - if (! empty($arrayfields['commercial']['checked'])) - { - print ''; - } - // Start date - if (! empty($arrayfields['p.dateo']['checked'])) - { - print ''; - } - // End date - if (! empty($arrayfields['p.datee']['checked'])) - { - print ''; - } - if (! empty($arrayfields['p.public']['checked'])) - { - print ''; - } - if (! empty($arrayfields['p.opp_amount']['checked'])) - { - print ''; - } - if (! empty($arrayfields['p.fk_opp_status']['checked'])) - { - print ''; - } - if (! empty($arrayfields['p.opp_percent']['checked'])) - { - print ''; - } - if (! empty($arrayfields['p.budget_amount']['checked'])) - { - print ''; - } - // Extra fields - if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) - { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) - { - $align=$extrafields->getAlignFlag($key); - $typeofextrafield=$extrafields->attribute_type[$key]; - print ''; - } - } - } - // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (! empty($arrayfields['p.datec']['checked'])) - { - // Date creation - print ''; - } - if (! empty($arrayfields['p.tms']['checked'])) - { - // Date modification - print ''; - } - if (! empty($arrayfields['p.fk_statut']['checked'])) - { - print ''; - } - // Action column - print ''; - - print ''."\n"; - - $i=0; - $var=true; - $totalarray=array(); - while ($i < min($num,$limit)) - { - $obj = $db->fetch_object($resql); - - $projectstatic->id = $obj->projectid; - $projectstatic->user_author_id = $obj->fk_user_creat; - $projectstatic->public = $obj->public; - $projectstatic->ref = $obj->ref; - $projectstatic->datee = $obj->date_end; - $projectstatic->statut = $obj->fk_statut; - $projectstatic->opp_status = $obj->fk_opp_status; - - $userAccess = $projectstatic->restrictedProjectArea($user); // why this ? - if ($userAccess >= 0) - { - $var=!$var; - print ""; - - // Project url - if (! empty($arrayfields['p.ref']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Title - if (! empty($arrayfields['p.title']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Company - if (! empty($arrayfields['s.nom']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Sales Representatives - if (! empty($arrayfields['commercial']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Date start - if (! empty($arrayfields['p.dateo']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Date end - if (! empty($arrayfields['p.datee']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Visibility - if (! empty($arrayfields['p.public']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Amount - if (! empty($arrayfields['p.opp_amount']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['totaloppfield']=$totalarray['nbfield']; - } - if (! empty($arrayfields['p.fk_opp_status']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - if (! empty($arrayfields['p.opp_percent']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - if (! empty($arrayfields['p.budget_amount']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['totalbudgetfield']=$totalarray['nbfield']; - } - // Extra fields - if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) - { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) - { - print 'getAlignFlag($key); - if ($align) print ' align="'.$align.'"'; - print '>'; - $tmpkey='options_'.$key; - print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); - print ''; - } - } - if (! $i) $totalarray['nbfield']++; - } - // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (! empty($arrayfields['p.datec']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Date modification - if (! empty($arrayfields['p.tms']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Status - if (! empty($arrayfields['p.fk_statut']['checked'])) - { - $projectstatic->statut = $obj->fk_statut; - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Action column - print ''; - if (! $i) $totalarray['nbfield']++; - - print "\n"; - - } - - $i++; - - } - - // Show total line - if (isset($totalarray['totaloppfield']) || isset($totalarray['totalbudgetfield'])) - { - print ''; - $i=0; - while ($i < $totalarray['nbfield']) - { - $i++; - if ($i == 1) - { - if ($num < $limit) print ''; - else print ''; - } - elseif ($totalarray['totaloppfield'] == $i) print ''; - elseif ($totalarray['totalbudgetfield'] == $i) print ''; - else print ''; - } - print ''; - } - - $db->free($resql); - - $parameters=array('sql' => $sql); - $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - print "
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ' '; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; - print ''; - $formother->select_year($syear?$syear:-1,'syear',1, 20, 5); - print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; - print ''; - $formother->select_year($year?$year:-1,'year',1, 20, 5); - print ''; - $array=array(''=>'',0 => $langs->trans("PrivateProject"),1 => $langs->trans("SharedProject")); - print $form->selectarray('search_public',$array,$search_public); - print ''; - print ''; - print ''; - print $formproject->selectOpportunityStatus('search_opp_status',$search_opp_status,1,1,1); - print ''; - print ''; - print ''; - print ''; - print ''; - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) - { - $crit=$val; - $tmpkey=preg_replace('/search_options_/','',$key); - $searchclass=''; - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; - print ''; - } - print ''; - print ''; - print ''; - $arrayofstatus = array(); - foreach($projectstatic->statuts_short as $key => $val) $arrayofstatus[$key]=$langs->trans($val); - $arrayofstatus['99']=$langs->trans("NotClosed").' ('.$langs->trans('Draft').'+'.$langs->trans('Opened').')'; - print $form->selectarray('search_status', $arrayofstatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100'); - print ''; - $searchpitco=$form->showFilterAndCheckAddButtons(0); - print $searchpitco; - print '
'; - print $projectstatic->getNomUrl(1); - if ($projectstatic->hasDelay()) print img_warning($langs->trans('Late')); - print ''; - print dol_trunc($obj->title,80); - print ''; - if ($obj->socid) - { - $socstatic->id=$obj->socid; - $socstatic->name=$obj->name; - print $socstatic->getNomUrl(1); - } - else - { - print ' '; - } - print ''; - if ($obj->socid) - { - $socstatic->id=$obj->socid; - $socstatic->name=$obj->name; - $listsalesrepresentatives=$socstatic->getSalesRepresentatives($user); - $nbofsalesrepresentative=count($listsalesrepresentatives); - if ($nbofsalesrepresentative > 3) // We print only number - { - print ''; - print $nbofsalesrepresentative; - print ''; - } - else if ($nbofsalesrepresentative > 0) - { - $userstatic=new User($db); - $j=0; - foreach($listsalesrepresentatives as $val) - { - $userstatic->id=$val['id']; - $userstatic->lastname=$val['lastname']; - $userstatic->firstname=$val['firstname']; - $userstatic->email=$val['email']; - $userstatic->statut=$val['statut']; - $userstatic->entity=$val['entity']; - print $userstatic->getNomUrl(1); - $j++; - if ($j < $nbofsalesrepresentative) print ', '; - } - } - //else print $langs->trans("NoSalesRepresentativeAffected"); - } - else - { - print ' '; - } - print ''; - print dol_print_date($db->jdate($obj->date_start),'day'); - print ''; - print dol_print_date($db->jdate($obj->date_end),'day'); - print ''; - if ($obj->public) print $langs->trans('SharedProject'); - else print $langs->trans('PrivateProject'); - print ''; - if ($obj->opp_status_code) - { - print price($obj->opp_amount, 1, '', 1, -1, -1, ''); - $totalarray['totalopp'] += $obj->opp_amount; - } - print ''; - if ($obj->opp_status_code) print $langs->trans("OppStatusShort".$obj->opp_status_code); - print ''; - if ($obj->opp_percent) print price($obj->opp_percent, 1, '', 1, 0).'%'; - print ''; - if ($obj->budget_amount != '') - { - print price($obj->budget_amount, 1, '', 1, -1, -1); - $totalarray['totalbudget'] += $obj->budget_amount; - } - print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour'); - print ''.$projectstatic->getLibStatut(5).''; - 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($obj->rowid, $arrayofselected)) $selected=1; - print ''; - } - print '
'.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.price($totalarray['totalopp']).''.price($totalarray['totalbudget']).'
\n"; - print "
\n"; + dol_print_error($db); + exit; } + +$var=true; +$num = $db->num_rows($resql); + +if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) +{ + $obj = $db->fetch_object($resql); + $id = $obj->projectid; + header("Location: ".DOL_URL_ROOT.'/projet/card.php?id='.$id); + exit; +} + +llxHeader("",$title,"EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"); + +$param=''; +if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; +if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; +if ($sday) $param.='&sday='.$day; +if ($smonth) $param.='&smonth='.$smonth; +if ($syear) $param.='&syear=' .$syear; +if ($day) $param.='&day='.$day; +if ($month) $param.='&month='.$month; +if ($year) $param.='&year=' .$year; +if ($socid) $param.='&socid='.$socid; +if ($search_all != '') $param.='&search_all='.$search_all; +if ($search_ref != '') $param.='&search_ref='.$search_ref; +if ($search_label != '') $param.='&search_label='.$search_label; +if ($search_societe != '') $param.='&search_societe='.$search_societe; +if ($search_status >= 0) $param.='&search_status='.$search_status; +if ((is_numeric($search_opp_status) && $search_opp_status >= 0) || in_array($search_opp_status, array('all','openedopp','none'))) $param.='&search_opp_status='.urlencode($search_opp_status); +if ((is_numeric($search_opp_percent) && $search_opp_percent >= 0) || in_array($search_opp_percent, array('all','openedopp','none'))) $param.='&search_opp_percent='.urlencode($search_opp_percent); +if ($search_public != '') $param.='&search_public='.$search_public; +if ($search_user > 0) $param.='&search_user='.$search_user; +if ($search_sale > 0) $param.='&search_sale='.$search_sale; +if ($search_opp_amount != '') $param.='&search_opp_amount='.$search_opp_amount; +if ($search_budget_amount != '') $param.='&search_budget_amount='.$search_budget_amount; +if ($optioncss != '') $param.='&optioncss='.$optioncss; +// Add $param from extra fields +foreach ($search_array_options as $key => $val) +{ + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); +} + +$text=$langs->trans("Projects"); +if ($search_user == $user->id) $text=$langs->trans('MyProjects'); + +print '
'; +if ($optioncss != '') print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +print_barre_liste($text, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, "", $num, $nbtotalofrecords, 'title_project', 0, '', '', $limit); + +// Show description of content +if ($search_user == $user->id) print $langs->trans("MyProjectsDesc").'

'; else { - dol_print_error($db); + if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").'

'; + else print $langs->trans("ProjectsPublicDesc").'

'; } +if ($search_all) +{ + foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); + print $langs->trans("FilterOnInto", $search_all) . join(', ',$fieldstosearchall); +} + +$moreforfilter=''; + +// Filter on categories +if (! empty($conf->categorie->enabled)) +{ + require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + $moreforfilter.='
'; + $moreforfilter.=$langs->trans('Categories'). ': '; + $moreforfilter.=$formother->select_categories('project',$search_categ,'search_categ',1); + $moreforfilter.='
'; +} + +// If the user can view user other than himself +$moreforfilter.='
'; +$moreforfilter.=$langs->trans('ProjectsWithThisUserAsContact'). ': '; +$includeonly=''; +if (empty($user->rights->user->user->lire)) $includeonly=array($user->id); +$moreforfilter.=$form->select_dolusers($search_user, 'search_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth300'); +$moreforfilter.='
'; + +// If the user can view thirdparties other than his' +if ($user->rights->societe->client->voir || $socid) +{ + $langs->load("commercial"); + $moreforfilter.='
'; + $moreforfilter.=$langs->trans('ThirdPartiesOfSaleRepresentative'). ': '; + $moreforfilter.=$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, 1, 'maxwidth300'); + $moreforfilter.='
'; +} + +if (! empty($moreforfilter)) +{ + print '
'; + print $moreforfilter; + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + print '
'; +} + +$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; +$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + +print ''; + +print ''; +if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'],$_SERVER["PHP_SELF"],"p.ref","",$param,"",$sortfield,$sortorder); +if (! empty($arrayfields['p.title']['checked'])) print_liste_field_titre($arrayfields['p.title']['label'],$_SERVER["PHP_SELF"],"p.title","",$param,"",$sortfield,$sortorder); +if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'],$_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder); +if (! empty($arrayfields['commercial']['checked'])) print_liste_field_titre($arrayfields['commercial']['label'],$_SERVER["PHP_SELF"],"","",$param,"",$sortfield,$sortorder); +if (! empty($arrayfields['p.dateo']['checked'])) print_liste_field_titre($arrayfields['p.dateo']['label'],$_SERVER["PHP_SELF"],"p.dateo","",$param,'align="center"',$sortfield,$sortorder); +if (! empty($arrayfields['p.datee']['checked'])) print_liste_field_titre($arrayfields['p.datee']['label'],$_SERVER["PHP_SELF"],"p.datee","",$param,'align="center"',$sortfield,$sortorder); +if (! empty($arrayfields['p.public']['checked'])) print_liste_field_titre($arrayfields['p.public']['label'],$_SERVER["PHP_SELF"],"p.public","",$param,"",$sortfield,$sortorder); +if (! empty($arrayfields['p.opp_amount']['checked'])) print_liste_field_titre($arrayfields['p.opp_amount']['label'],$_SERVER["PHP_SELF"],'p.opp_amount',"",$param,'align="right"',$sortfield,$sortorder); +if (! empty($arrayfields['p.fk_opp_status']['checked'])) print_liste_field_titre($arrayfields['p.fk_opp_status']['label'],$_SERVER["PHP_SELF"],'p.fk_opp_status',"",$param,'align="center"',$sortfield,$sortorder); +if (! empty($arrayfields['p.opp_percent']['checked'])) print_liste_field_titre($arrayfields['p.opp_percent']['label'],$_SERVER["PHP_SELF"],'p.opp_percent',"",$param,'align="right"',$sortfield,$sortorder); +if (! empty($arrayfields['p.budget_amount']['checked'])) print_liste_field_titre($arrayfields['p.budget_amount']['label'],$_SERVER["PHP_SELF"],'p.budget_amount',"",$param,'align="right"',$sortfield,$sortorder); +// Extra fields +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +{ + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + $align=$extrafields->getAlignFlag($key); + print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); + } + } +} +// Hook fields +$parameters=array('arrayfields'=>$arrayfields); +$reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +if (! empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'],$_SERVER["PHP_SELF"],"p.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['p.tms']['checked'])) print_liste_field_titre($arrayfields['p.tms']['label'],$_SERVER["PHP_SELF"],"p.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['p.fk_statut']['checked'])) print_liste_field_titre($arrayfields['p.fk_statut']['label'],$_SERVER["PHP_SELF"],"p.fk_statut","",$param,'align="right"',$sortfield,$sortorder); +print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch '); +print "\n"; + +print ''; +if (! empty($arrayfields['p.ref']['checked'])) +{ + print ''; +} +if (! empty($arrayfields['p.title']['checked'])) +{ + print ''; +} +if (! empty($arrayfields['s.nom']['checked'])) +{ + print ''; +} +// Sale representative +if (! empty($arrayfields['commercial']['checked'])) +{ + print ''; +} +// Start date +if (! empty($arrayfields['p.dateo']['checked'])) +{ + print ''; +} +// End date +if (! empty($arrayfields['p.datee']['checked'])) +{ + print ''; +} +if (! empty($arrayfields['p.public']['checked'])) +{ + print ''; +} +if (! empty($arrayfields['p.opp_amount']['checked'])) +{ + print ''; +} +if (! empty($arrayfields['p.fk_opp_status']['checked'])) +{ + print ''; +} +if (! empty($arrayfields['p.opp_percent']['checked'])) +{ + print ''; +} +if (! empty($arrayfields['p.budget_amount']['checked'])) +{ + print ''; +} +// Extra fields +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +{ + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + $align=$extrafields->getAlignFlag($key); + $typeofextrafield=$extrafields->attribute_type[$key]; + print ''; + } + } +} +// Fields from hook +$parameters=array('arrayfields'=>$arrayfields); +$reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +if (! empty($arrayfields['p.datec']['checked'])) +{ + // Date creation + print ''; +} +if (! empty($arrayfields['p.tms']['checked'])) +{ + // Date modification + print ''; +} +if (! empty($arrayfields['p.fk_statut']['checked'])) +{ + print ''; +} +// Action column +print ''; + +print ''."\n"; + +$i=0; +$var=true; +$totalarray=array(); +while ($i < min($num,$limit)) +{ + $obj = $db->fetch_object($resql); + + $projectstatic->id = $obj->projectid; + $projectstatic->user_author_id = $obj->fk_user_creat; + $projectstatic->public = $obj->public; + $projectstatic->ref = $obj->ref; + $projectstatic->datee = $obj->date_end; + $projectstatic->statut = $obj->fk_statut; + $projectstatic->opp_status = $obj->fk_opp_status; + + $userAccess = $projectstatic->restrictedProjectArea($user); // why this ? + if ($userAccess >= 0) + { + $var=!$var; + print ""; + + // Project url + if (! empty($arrayfields['p.ref']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Title + if (! empty($arrayfields['p.title']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Company + if (! empty($arrayfields['s.nom']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Sales Representatives + if (! empty($arrayfields['commercial']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Date start + if (! empty($arrayfields['p.dateo']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Date end + if (! empty($arrayfields['p.datee']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Visibility + if (! empty($arrayfields['p.public']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Amount + if (! empty($arrayfields['p.opp_amount']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totaloppfield']=$totalarray['nbfield']; + } + if (! empty($arrayfields['p.fk_opp_status']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['p.opp_percent']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + if (! empty($arrayfields['p.budget_amount']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totalbudgetfield']=$totalarray['nbfield']; + } + // Extra fields + if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) + { + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + print 'getAlignFlag($key); + if ($align) print ' align="'.$align.'"'; + print '>'; + $tmpkey='options_'.$key; + print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); + print ''; + } + } + if (! $i) $totalarray['nbfield']++; + } + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (! empty($arrayfields['p.datec']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Date modification + if (! empty($arrayfields['p.tms']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Status + if (! empty($arrayfields['p.fk_statut']['checked'])) + { + $projectstatic->statut = $obj->fk_statut; + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Action column + print ''; + if (! $i) $totalarray['nbfield']++; + + print "\n"; + + } + + $i++; + +} + +// Show total line +if (isset($totalarray['totaloppfield']) || isset($totalarray['totalbudgetfield'])) +{ + print ''; + $i=0; + while ($i < $totalarray['nbfield']) + { + $i++; + if ($i == 1) + { + if ($num < $limit) print ''; + else print ''; + } + elseif ($totalarray['totaloppfield'] == $i) print ''; + elseif ($totalarray['totalbudgetfield'] == $i) print ''; + else print ''; + } + print ''; +} + +$db->free($resql); + +$parameters=array('sql' => $sql); +$reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + +print "
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ' '; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($syear?$syear:-1,'syear',1, 20, 5); + print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($year?$year:-1,'year',1, 20, 5); + print ''; + $array=array(''=>'',0 => $langs->trans("PrivateProject"),1 => $langs->trans("SharedProject")); + print $form->selectarray('search_public',$array,$search_public); + print ''; + print ''; + print ''; + print $formproject->selectOpportunityStatus('search_opp_status',$search_opp_status,1,1,1); + print ''; + print ''; + print ''; + print ''; + print ''; + if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + { + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $searchclass=''; + if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; + if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + print ''; + } + print ''; + print ''; + print ''; + $arrayofstatus = array(); + foreach($projectstatic->statuts_short as $key => $val) $arrayofstatus[$key]=$langs->trans($val); + $arrayofstatus['99']=$langs->trans("NotClosed").' ('.$langs->trans('Draft').'+'.$langs->trans('Opened').')'; + print $form->selectarray('search_status', $arrayofstatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100'); + print ''; +$searchpitco=$form->showFilterAndCheckAddButtons(0); +print $searchpitco; +print '
'; + print $projectstatic->getNomUrl(1); + if ($projectstatic->hasDelay()) print img_warning($langs->trans('Late')); + print ''; + print dol_trunc($obj->title,80); + print ''; + if ($obj->socid) + { + $socstatic->id=$obj->socid; + $socstatic->name=$obj->name; + print $socstatic->getNomUrl(1); + } + else + { + print ' '; + } + print ''; + if ($obj->socid) + { + $socstatic->id=$obj->socid; + $socstatic->name=$obj->name; + $listsalesrepresentatives=$socstatic->getSalesRepresentatives($user); + $nbofsalesrepresentative=count($listsalesrepresentatives); + if ($nbofsalesrepresentative > 3) // We print only number + { + print ''; + print $nbofsalesrepresentative; + print ''; + } + else if ($nbofsalesrepresentative > 0) + { + $userstatic=new User($db); + $j=0; + foreach($listsalesrepresentatives as $val) + { + $userstatic->id=$val['id']; + $userstatic->lastname=$val['lastname']; + $userstatic->firstname=$val['firstname']; + $userstatic->email=$val['email']; + $userstatic->statut=$val['statut']; + $userstatic->entity=$val['entity']; + print $userstatic->getNomUrl(1); + $j++; + if ($j < $nbofsalesrepresentative) print ', '; + } + } + //else print $langs->trans("NoSalesRepresentativeAffected"); + } + else + { + print ' '; + } + print ''; + print dol_print_date($db->jdate($obj->date_start),'day'); + print ''; + print dol_print_date($db->jdate($obj->date_end),'day'); + print ''; + if ($obj->public) print $langs->trans('SharedProject'); + else print $langs->trans('PrivateProject'); + print ''; + if ($obj->opp_status_code) + { + print price($obj->opp_amount, 1, '', 1, -1, -1, ''); + $totalarray['totalopp'] += $obj->opp_amount; + } + print ''; + if ($obj->opp_status_code) print $langs->trans("OppStatusShort".$obj->opp_status_code); + print ''; + if ($obj->opp_percent) print price($obj->opp_percent, 1, '', 1, 0).'%'; + print ''; + if ($obj->budget_amount != '') + { + print price($obj->budget_amount, 1, '', 1, -1, -1); + $totalarray['totalbudget'] += $obj->budget_amount; + } + print ''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour'); + print ''.$projectstatic->getLibStatut(5).''; + 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($obj->rowid, $arrayofselected)) $selected=1; + print ''; + } + print '
'.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.price($totalarray['totalopp']).''.price($totalarray['totalbudget']).'
\n"; +print "
\n"; llxFooter(); diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index f5b422a7ce2..1179ca7546e 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -129,29 +129,41 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab * Actions */ -include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; +if (GETPOST('cancel')) { $action='list'; $massaction=''; } +if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction=''; } -// Purge criteria -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +$parameters=array('socid'=>$socid); +$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) { - $search_all=""; - $search_project=""; - $search_projectstatus=-1; - $search_project_ref=""; - $search_project_title=""; - $search_task_ref=""; - $search_task_label=""; - $search_task_description=""; - $search_task_user=-1; - $search_project_user=-1; - $sday=''; - $smonth=''; - $syear=''; - $day=''; - $month=''; - $year=''; - $search_array_options=array(); + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + + // Purge search criteria + if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers + { + $search_all=""; + $search_project=""; + $search_projectstatus=-1; + $search_project_ref=""; + $search_project_title=""; + $search_task_ref=""; + $search_task_label=""; + $search_task_description=""; + $search_task_user=-1; + $search_project_user=-1; + $sday=''; + $smonth=''; + $syear=''; + $day=''; + $month=''; + $year=''; + $search_array_options=array(); + } } + if (empty($search_projectstatus) && $search_projectstatus == '') $search_projectstatus=1; @@ -174,8 +186,6 @@ if ($search_task_user > 0) $tuser->fetch($search_task_user); $title=$langs->trans("Activities"); if ($search_task_user == $user->id) $title=$langs->trans("MyActivities"); -llxHeader("",$title,"Projet"); - if ($id) { $projectstatic->fetch($id); @@ -311,506 +321,513 @@ $sql.= $db->plimit($limit + 1,$offset); dol_syslog("list allowed project", LOG_DEBUG); //print $sql; $resql = $db->query($sql); -if ($resql) -{ - $var=true; - $num = $db->num_rows($resql); - - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($sday) $param.='&sday='.$day; - if ($smonth) $param.='&smonth='.$smonth; - if ($syear) $param.='&syear=' .$syear; - if ($day) $param.='&day='.$day; - if ($month) $param.='&month='.$month; - if ($year) $param.='&year=' .$year; - if ($socid) $param.='&socid='.$socid; - if ($search_all != '') $param.='&search_all='.$search_all; - if ($search_project_ref != '') $param.='&search_project_ref='.$search_project_ref; - if ($search_project_title != '') $param.='&search_project_title='.$search_project_title; - if ($search_ref != '') $param.='&search_ref='.$search_ref; - if ($search_label != '') $param.='&search_label='.$search_label; - if ($search_societe != '') $param.='&search_societe='.$search_societe; - if ($search_projectstatus != '') $param.='&search_projectstatus='.$search_projectstatus; - if ((is_numeric($search_opp_status) && $search_opp_status >= 0) || in_array($search_opp_status, array('all','none'))) $param.='&search_opp_status='.urlencode($search_opp_status); - if ($search_public != '') $param.='&search_public='.$search_public; - if ($search_project_user > 0) $param.='&search_project_user='.$search_project_user; - if ($search_task_user > 0) $param.='&search_task_user='.$search_task_user; - if ($optioncss != '') $param.='&optioncss='.$optioncss; - // Add $param from extra fields - foreach ($search_array_options as $key => $val) - { - $crit=$val; - $tmpkey=preg_replace('/search_options_/','',$key); - if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); - } - - print '
'; - if ($optioncss != '') print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num, $nbtotalofrecords, 'title_project', 0, '', '', $limit); - - // Show description of content - if ($search_task_user == $user->id) print $langs->trans("MyTasksDesc").'

'; - else - { - if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("TasksOnProjectsDesc").'

'; - else print $langs->trans("TasksOnProjectsPublicDesc").'

'; - } - - if ($search_all) - { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print $langs->trans("FilterOnInto", $search_all) . join(', ',$fieldstosearchall); - } - - // If the user can view users - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('ProjectsWithThisUserAsContact'). ' '; - $includeonly=''; - if (empty($user->rights->user->user->lire)) $includeonly=array($user->id); - $moreforfilter.=$form->select_dolusers($search_project_user, 'search_project_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth300'); - $moreforfilter.='
'; - - // If the user can view users - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('TasksWithThisUserAsContact'). ': '; - $includeonly=''; - if (empty($user->rights->user->user->lire)) $includeonly=array($user->id); - $moreforfilter.=$form->select_dolusers($search_task_user, 'search_task_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth300'); - $moreforfilter.='
'; - - if (! empty($moreforfilter)) - { - print '
'; - print $moreforfilter; - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - print '
'; - } - - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - - print ''; - - print ''; - if (! empty($arrayfields['t.ref']['checked'])) print_liste_field_titre($arrayfields['t.ref']['label'],$_SERVER["PHP_SELF"],"t.ref","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['t.label']['checked'])) print_liste_field_titre($arrayfields['t.label']['label'],$_SERVER["PHP_SELF"],"t.label","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['t.dateo']['checked'])) print_liste_field_titre($arrayfields['t.dateo']['label'],$_SERVER["PHP_SELF"],"t.dateo","",$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['t.datee']['checked'])) print_liste_field_titre($arrayfields['t.datee']['label'],$_SERVER["PHP_SELF"],"t.datee","",$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'],$_SERVER["PHP_SELF"],"p.ref","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['p.title']['checked'])) print_liste_field_titre($arrayfields['p.title']['label'],$_SERVER["PHP_SELF"],"p.title","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'],$_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['p.fk_statut']['checked'])) print_liste_field_titre($arrayfields['p.fk_statut']['label'],$_SERVER["PHP_SELF"],"p.fk_statut","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['t.planned_workload']['checked'])) print_liste_field_titre($arrayfields['t.planned_workload']['label'],$_SERVER["PHP_SELF"],"t.planned_workload","",$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['t.duration_effective']['checked'])) print_liste_field_titre($arrayfields['t.duration_effective']['label'],$_SERVER["PHP_SELF"],"t.duration_effective","",$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['t.progress_calculated']['checked'])) print_liste_field_titre($arrayfields['t.progress_calculated']['label'],$_SERVER["PHP_SELF"],"","",$param,'align="center"'); - if (! empty($arrayfields['t.progress']['checked'])) print_liste_field_titre($arrayfields['t.progress']['label'],$_SERVER["PHP_SELF"],"t.progress","",$param,'align="center"',$sortfield,$sortorder); - // Extra fields - if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) - { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) - { - $align=$extrafields->getAlignFlag($key); - print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); - } - } - } - // Hook fields - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (! empty($arrayfields['t.datec']['checked'])) print_liste_field_titre($arrayfields['t.datec']['label'],$_SERVER["PHP_SELF"],"t.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); - if (! empty($arrayfields['t.tms']['checked'])) print_liste_field_titre($arrayfields['t.tms']['label'],$_SERVER["PHP_SELF"],"t.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch '); - print "\n"; - - print ''; - if (! empty($arrayfields['t.ref']['checked'])) - { - print ''; - } - if (! empty($arrayfields['t.label']['checked'])) - { - print ''; - } - // Start date - if (! empty($arrayfields['t.dateo']['checked'])) - { - print ''; - } - // End date - if (! empty($arrayfields['t.datee']['checked'])) - { - print ''; - } - if (! empty($arrayfields['p.ref']['checked'])) - { - print ''; - } - if (! empty($arrayfields['p.title']['checked'])) - { - print ''; - } - if (! empty($arrayfields['s.nom']['checked'])) - { - print ''; - } - if (! empty($arrayfields['p.fk_statut']['checked'])) - { - print ''; - } - if (! empty($arrayfields['t.planned_workload']['checked'])) print ''; - if (! empty($arrayfields['t.duration_effective']['checked'])) print ''; - if (! empty($arrayfields['t.progress_calculated']['checked'])) print ''; - if (! empty($arrayfields['t.progress']['checked'])) print ''; - // Extra fields - if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) - { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) - { - $align=$extrafields->getAlignFlag($key); - $typeofextrafield=$extrafields->attribute_type[$key]; - print ''; - } - } - } - // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (! empty($arrayfields['t.datec']['checked'])) - { - // Date creation - print ''; - } - if (! empty($arrayfields['t.tms']['checked'])) - { - // Date modification - print ''; - } - // Action column - print ''; - print ''; - - - $plannedworkloadoutputformat='allhourmin'; - $timespentoutputformat='allhourmin'; - if (! empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) $plannedworkloadoutputformat=$conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT; - if (! empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat=$conf->global->PROJECT_TIME_SPENT_FORMAT; - - $now = dol_now(); - $i=0; - $var=true; - $totalarray=array(); - while ($i < min($num,$limit)) - { - $obj = $db->fetch_object($resql); - - $projectstatic->id = $obj->projectid; - $projectstatic->ref = $obj->projectref; - $projectstatic->title = $obj->projecttitle; - $projectstatic->public = $obj->public; - $projectstatic->statut = $obj->projectstatus; - $projectstatic->datee = $db->jdate($obj->projectdatee); - - $taskstatic->id = $obj->id; - $taskstatic->ref = $obj->ref; - $taskstatic->label = $obj->label; - $taskstatic->fk_statut = $obj->fk_statut; - $taskstatic->progress = $obj->progress; - $taskstatic->datee = $db->jdate($obj->date_end); // deprecated - $taskstatic->date_end = $db->jdate($obj->date_end); - - $userAccess = $projectstatic->restrictedProjectArea($user); // why this ? - if ($userAccess >= 0) - { - $var=!$var; - print ""; - - // Ref - if (! empty($arrayfields['t.ref']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Label - if (! empty($arrayfields['t.label']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Date start - if (! empty($arrayfields['t.dateo']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Date end - if (! empty($arrayfields['t.datee']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Project ref - if (! empty($arrayfields['p.ref']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Project title - if (! empty($arrayfields['p.title']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Third party - if (! empty($arrayfields['s.nom']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Project status - if (! empty($arrayfields['p.fk_statut']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - - // Planned workload - if (! empty($arrayfields['t.planned_workload']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['totalplannedworkloadfield']=$totalarray['nbfield']; - $totalarray['totalplannedworkload'] += $obj->planned_workload; - } - // Time spent - if (! empty($arrayfields['t.duration_effective']['checked'])) - { - $showlineingray=0;$showproject=1; - print ''; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['totaldurationeffectivefield']=$totalarray['nbfield']; - $totalarray['totaldurationeffective'] += $obj->duration_effective; - } - // Calculated progress - if (! empty($arrayfields['t.progress_calculated']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Declared progress - if (! empty($arrayfields['t.progress']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Extra fields - if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) - { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) - { - print 'getAlignFlag($key); - if ($align) print ' align="'.$align.'"'; - print '>'; - $tmpkey='options_'.$key; - print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); - print ''; - if (! $i) $totalarray['nbfield']++; - } - } - } - // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (! empty($arrayfields['t.datec']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Date modification - if (! empty($arrayfields['t.tms']['checked'])) - { - print ''; - if (! $i) $totalarray['nbfield']++; - } - // Status - /*if (! empty($arrayfields['p.fk_statut']['checked'])) - { - $projectstatic->statut = $obj->fk_statut; - print ''; - }*/ - // Action column - print ''; - if (! $i) $totalarray['nbfield']++; - - print "\n"; - - //print projectLinesa(); - } - - $i++; - } - - // Show total line - if (isset($totalarray['totaldurationeffectivefield']) || isset($totalarray['totalplannedworkloadfield'])) - { - print ''; - $i=0; - while ($i < $totalarray['nbfield']) - { - $i++; - if ($i == 1) - { - if ($num < $limit) print ''; - else print ''; - } - elseif ($totalarray['totalplannedworkloadfield'] == $i) print ''; - elseif ($totalarray['totaldurationeffectivefield'] == $i) print ''; - else print ''; - } - print ''; - } - - $db->free($resql); - - $parameters=array('sql' => $sql); - $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - print "
'; - print ''; - print ''; - print ''; - print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; - print ''; - $formother->select_year($syear?$syear:-1,'syear',1, 20, 5); - print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; - print ''; - $formother->select_year($year?$year:-1,'year',1, 20, 5); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - $arrayofstatus = array(); - foreach($projectstatic->statuts_short as $key => $val) $arrayofstatus[$key]=$langs->trans($val); - $arrayofstatus['99']=$langs->trans("NotClosed").' ('.$langs->trans('Draft').'+'.$langs->trans('Opened').')'; - print $form->selectarray('search_projectstatus', $arrayofstatus, $search_projectstatus, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100'); - print ''; - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) - { - $crit=$val; - $tmpkey=preg_replace('/search_options_/','',$key); - $searchclass=''; - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; - print ''; - } - print ''; - print ''; - print ''; - $searchpitco=$form->showFilterAndCheckAddButtons(0); - print $searchpitco; - print '
'; - print $taskstatic->getNomUrl(1,'withproject'); - if ($taskstatic->hasDelay()) print img_warning("Late"); - print ''; - print $taskstatic->label; - print ''; - print dol_print_date($db->jdate($obj->date_start),'day'); - print ''; - print dol_print_date($db->jdate($obj->date_end),'day'); - print ''; - print $projectstatic->getNomUrl(1, 'task'); - if ($projectstatic->hasDelay()) print img_warning("Late"); - print ''; - print dol_trunc($obj->projecttitle,80); - print ''; - if ($obj->socid) - { - $socstatic->id=$obj->socid; - $socstatic->name=$obj->name; - print $socstatic->getNomUrl(1); - } - else - { - print ' '; - } - print ''; - print $projectstatic->getLibStatut(1); - print ''; - $fullhour=convertSecondToTime($obj->planned_workload,$plannedworkloadoutputformat); - $workingdelay=convertSecondToTime($obj->planned_workload,'all',86400,7); // TODO Replace 86400 and 7 to take account working hours per day and working day per weeks - if ($obj->planned_workload != '') - { - print $fullhour; - // TODO Add delay taking account of working hours per day and working day per week - //if ($workingdelay != $fullhour) print '
('.$workingdelay.')'; - } - //else print '--:--'; - print '
'; - if ($showlineingray) print ''; - else print ''; - if ($obj->duration_effective) print convertSecondToTime($obj->duration_effective,$timespentoutputformat); - else print '--:--'; - if ($showlineingray) print ''; - else print ''; - print ''; - if ($obj->planned_workload || $obj->duration_effective) - { - if ($obj->planned_workload) print round(100 * $obj->duration_effective / $obj->planned_workload,2).' %'; - else print $langs->trans('WorkloadNotDefined'); - } - print ''; - if ($obj->progress != '') - { - print $obj->progress.' %'; - } - print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour'); - print ''.$projectstatic->getLibStatut(5).''; - 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($obj->rowid, $arrayofselected)) $selected=1; - print ''; - } - print '
'.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.convertSecondToTime($totalarray['totalplannedworkload'],$plannedworkloadoutputformat).''.convertSecondToTime($totalarray['totaldurationeffective'],$timespentoutputformat).'
"; - - print '
'; -} -else +if (! $resql) { dol_print_error($db); + exit; } +$var=true; +$num = $db->num_rows($resql); + +if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) +{ + $obj = $db->fetch_object($resql); + $id = $obj->id; + header("Location: ".DOL_URL_ROOT.'/projet/tasks/task.php?id='.$id.'&withprojet=1'); + exit; +} + +llxHeader("",$title,"Projet"); + +$param=''; +if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; +if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; +if ($sday) $param.='&sday='.$day; +if ($smonth) $param.='&smonth='.$smonth; +if ($syear) $param.='&syear=' .$syear; +if ($day) $param.='&day='.$day; +if ($month) $param.='&month='.$month; +if ($year) $param.='&year=' .$year; +if ($socid) $param.='&socid='.$socid; +if ($search_all != '') $param.='&search_all='.$search_all; +if ($search_project_ref != '') $param.='&search_project_ref='.$search_project_ref; +if ($search_project_title != '') $param.='&search_project_title='.$search_project_title; +if ($search_ref != '') $param.='&search_ref='.$search_ref; +if ($search_label != '') $param.='&search_label='.$search_label; +if ($search_societe != '') $param.='&search_societe='.$search_societe; +if ($search_projectstatus != '') $param.='&search_projectstatus='.$search_projectstatus; +if ((is_numeric($search_opp_status) && $search_opp_status >= 0) || in_array($search_opp_status, array('all','none'))) $param.='&search_opp_status='.urlencode($search_opp_status); +if ($search_public != '') $param.='&search_public='.$search_public; +if ($search_project_user > 0) $param.='&search_project_user='.$search_project_user; +if ($search_task_user > 0) $param.='&search_task_user='.$search_task_user; +if ($optioncss != '') $param.='&optioncss='.$optioncss; +// Add $param from extra fields +foreach ($search_array_options as $key => $val) +{ + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); +} + +print '
'; +if ($optioncss != '') print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num, $nbtotalofrecords, 'title_project', 0, '', '', $limit); + +// Show description of content +if ($search_task_user == $user->id) print $langs->trans("MyTasksDesc").'

'; +else +{ + if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("TasksOnProjectsDesc").'

'; + else print $langs->trans("TasksOnProjectsPublicDesc").'

'; +} + +if ($search_all) +{ + foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); + print $langs->trans("FilterOnInto", $search_all) . join(', ',$fieldstosearchall); +} + +// If the user can view users +$moreforfilter.='
'; +$moreforfilter.=$langs->trans('ProjectsWithThisUserAsContact'). ' '; +$includeonly=''; +if (empty($user->rights->user->user->lire)) $includeonly=array($user->id); +$moreforfilter.=$form->select_dolusers($search_project_user, 'search_project_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth300'); +$moreforfilter.='
'; + +// If the user can view users +$moreforfilter.='
'; +$moreforfilter.=$langs->trans('TasksWithThisUserAsContact'). ': '; +$includeonly=''; +if (empty($user->rights->user->user->lire)) $includeonly=array($user->id); +$moreforfilter.=$form->select_dolusers($search_task_user, 'search_task_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth300'); +$moreforfilter.='
'; + +if (! empty($moreforfilter)) +{ + print '
'; + print $moreforfilter; + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + print '
'; +} + +$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; +$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + +print ''; + +print ''; +if (! empty($arrayfields['t.ref']['checked'])) print_liste_field_titre($arrayfields['t.ref']['label'],$_SERVER["PHP_SELF"],"t.ref","",$param,"",$sortfield,$sortorder); +if (! empty($arrayfields['t.label']['checked'])) print_liste_field_titre($arrayfields['t.label']['label'],$_SERVER["PHP_SELF"],"t.label","",$param,"",$sortfield,$sortorder); +if (! empty($arrayfields['t.dateo']['checked'])) print_liste_field_titre($arrayfields['t.dateo']['label'],$_SERVER["PHP_SELF"],"t.dateo","",$param,'align="center"',$sortfield,$sortorder); +if (! empty($arrayfields['t.datee']['checked'])) print_liste_field_titre($arrayfields['t.datee']['label'],$_SERVER["PHP_SELF"],"t.datee","",$param,'align="center"',$sortfield,$sortorder); +if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'],$_SERVER["PHP_SELF"],"p.ref","",$param,"",$sortfield,$sortorder); +if (! empty($arrayfields['p.title']['checked'])) print_liste_field_titre($arrayfields['p.title']['label'],$_SERVER["PHP_SELF"],"p.title","",$param,"",$sortfield,$sortorder); +if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'],$_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder); +if (! empty($arrayfields['p.fk_statut']['checked'])) print_liste_field_titre($arrayfields['p.fk_statut']['label'],$_SERVER["PHP_SELF"],"p.fk_statut","",$param,"",$sortfield,$sortorder); +if (! empty($arrayfields['t.planned_workload']['checked'])) print_liste_field_titre($arrayfields['t.planned_workload']['label'],$_SERVER["PHP_SELF"],"t.planned_workload","",$param,'align="center"',$sortfield,$sortorder); +if (! empty($arrayfields['t.duration_effective']['checked'])) print_liste_field_titre($arrayfields['t.duration_effective']['label'],$_SERVER["PHP_SELF"],"t.duration_effective","",$param,'align="center"',$sortfield,$sortorder); +if (! empty($arrayfields['t.progress_calculated']['checked'])) print_liste_field_titre($arrayfields['t.progress_calculated']['label'],$_SERVER["PHP_SELF"],"","",$param,'align="center"'); +if (! empty($arrayfields['t.progress']['checked'])) print_liste_field_titre($arrayfields['t.progress']['label'],$_SERVER["PHP_SELF"],"t.progress","",$param,'align="center"',$sortfield,$sortorder); +// Extra fields +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +{ + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + $align=$extrafields->getAlignFlag($key); + print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); + } + } +} +// Hook fields +$parameters=array('arrayfields'=>$arrayfields); +$reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +if (! empty($arrayfields['t.datec']['checked'])) print_liste_field_titre($arrayfields['t.datec']['label'],$_SERVER["PHP_SELF"],"t.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['t.tms']['checked'])) print_liste_field_titre($arrayfields['t.tms']['label'],$_SERVER["PHP_SELF"],"t.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); +print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch '); +print "\n"; + +print ''; +if (! empty($arrayfields['t.ref']['checked'])) +{ + print ''; +} +if (! empty($arrayfields['t.label']['checked'])) +{ + print ''; +} +// Start date +if (! empty($arrayfields['t.dateo']['checked'])) +{ + print ''; +} +// End date +if (! empty($arrayfields['t.datee']['checked'])) +{ + print ''; +} +if (! empty($arrayfields['p.ref']['checked'])) +{ + print ''; +} +if (! empty($arrayfields['p.title']['checked'])) +{ + print ''; +} +if (! empty($arrayfields['s.nom']['checked'])) +{ + print ''; +} +if (! empty($arrayfields['p.fk_statut']['checked'])) +{ + print ''; +} +if (! empty($arrayfields['t.planned_workload']['checked'])) print ''; +if (! empty($arrayfields['t.duration_effective']['checked'])) print ''; +if (! empty($arrayfields['t.progress_calculated']['checked'])) print ''; +if (! empty($arrayfields['t.progress']['checked'])) print ''; +// Extra fields +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +{ + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + $align=$extrafields->getAlignFlag($key); + $typeofextrafield=$extrafields->attribute_type[$key]; + print ''; + } + } +} +// Fields from hook +$parameters=array('arrayfields'=>$arrayfields); +$reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +if (! empty($arrayfields['t.datec']['checked'])) +{ + // Date creation + print ''; +} +if (! empty($arrayfields['t.tms']['checked'])) +{ + // Date modification + print ''; +} +// Action column +print ''; +print ''; + + +$plannedworkloadoutputformat='allhourmin'; +$timespentoutputformat='allhourmin'; +if (! empty($conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT)) $plannedworkloadoutputformat=$conf->global->PROJECT_PLANNED_WORKLOAD_FORMAT; +if (! empty($conf->global->PROJECT_TIMES_SPENT_FORMAT)) $timespentoutputformat=$conf->global->PROJECT_TIME_SPENT_FORMAT; + +$now = dol_now(); +$i=0; +$var=true; +$totalarray=array(); +while ($i < min($num,$limit)) +{ + $obj = $db->fetch_object($resql); + + $projectstatic->id = $obj->projectid; + $projectstatic->ref = $obj->projectref; + $projectstatic->title = $obj->projecttitle; + $projectstatic->public = $obj->public; + $projectstatic->statut = $obj->projectstatus; + $projectstatic->datee = $db->jdate($obj->projectdatee); + + $taskstatic->id = $obj->id; + $taskstatic->ref = $obj->ref; + $taskstatic->label = $obj->label; + $taskstatic->fk_statut = $obj->fk_statut; + $taskstatic->progress = $obj->progress; + $taskstatic->datee = $db->jdate($obj->date_end); // deprecated + $taskstatic->date_end = $db->jdate($obj->date_end); + + $userAccess = $projectstatic->restrictedProjectArea($user); // why this ? + if ($userAccess >= 0) + { + $var=!$var; + print ""; + + // Ref + if (! empty($arrayfields['t.ref']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Label + if (! empty($arrayfields['t.label']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Date start + if (! empty($arrayfields['t.dateo']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Date end + if (! empty($arrayfields['t.datee']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Project ref + if (! empty($arrayfields['p.ref']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Project title + if (! empty($arrayfields['p.title']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Third party + if (! empty($arrayfields['s.nom']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Project status + if (! empty($arrayfields['p.fk_statut']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + + // Planned workload + if (! empty($arrayfields['t.planned_workload']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totalplannedworkloadfield']=$totalarray['nbfield']; + $totalarray['totalplannedworkload'] += $obj->planned_workload; + } + // Time spent + if (! empty($arrayfields['t.duration_effective']['checked'])) + { + $showlineingray=0;$showproject=1; + print ''; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totaldurationeffectivefield']=$totalarray['nbfield']; + $totalarray['totaldurationeffective'] += $obj->duration_effective; + } + // Calculated progress + if (! empty($arrayfields['t.progress_calculated']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Declared progress + if (! empty($arrayfields['t.progress']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Extra fields + if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) + { + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + print 'getAlignFlag($key); + if ($align) print ' align="'.$align.'"'; + print '>'; + $tmpkey='options_'.$key; + print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); + print ''; + if (! $i) $totalarray['nbfield']++; + } + } + } + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (! empty($arrayfields['t.datec']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Date modification + if (! empty($arrayfields['t.tms']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Status + /*if (! empty($arrayfields['p.fk_statut']['checked'])) + { + $projectstatic->statut = $obj->fk_statut; + print ''; + }*/ + // Action column + print ''; + if (! $i) $totalarray['nbfield']++; + + print "\n"; + + //print projectLinesa(); + } + + $i++; +} + +// Show total line +if (isset($totalarray['totaldurationeffectivefield']) || isset($totalarray['totalplannedworkloadfield'])) +{ + print ''; + $i=0; + while ($i < $totalarray['nbfield']) + { + $i++; + if ($i == 1) + { + if ($num < $limit) print ''; + else print ''; + } + elseif ($totalarray['totalplannedworkloadfield'] == $i) print ''; + elseif ($totalarray['totaldurationeffectivefield'] == $i) print ''; + else print ''; + } + print ''; +} + +$db->free($resql); + +$parameters=array('sql' => $sql); +$reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + +print "
'; + print ''; + print ''; + print ''; + print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($syear?$syear:-1,'syear',1, 20, 5); + print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($year?$year:-1,'year',1, 20, 5); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $arrayofstatus = array(); + foreach($projectstatic->statuts_short as $key => $val) $arrayofstatus[$key]=$langs->trans($val); + $arrayofstatus['99']=$langs->trans("NotClosed").' ('.$langs->trans('Draft').'+'.$langs->trans('Opened').')'; + print $form->selectarray('search_projectstatus', $arrayofstatus, $search_projectstatus, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100'); + print ''; + if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + { + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $searchclass=''; + if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; + if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + print ''; + } + print ''; + print ''; + print ''; +$searchpitco=$form->showFilterAndCheckAddButtons(0); +print $searchpitco; +print '
'; + print $taskstatic->getNomUrl(1,'withproject'); + if ($taskstatic->hasDelay()) print img_warning("Late"); + print ''; + print $taskstatic->label; + print ''; + print dol_print_date($db->jdate($obj->date_start),'day'); + print ''; + print dol_print_date($db->jdate($obj->date_end),'day'); + print ''; + print $projectstatic->getNomUrl(1, 'task'); + if ($projectstatic->hasDelay()) print img_warning("Late"); + print ''; + print dol_trunc($obj->projecttitle,80); + print ''; + if ($obj->socid) + { + $socstatic->id=$obj->socid; + $socstatic->name=$obj->name; + print $socstatic->getNomUrl(1); + } + else + { + print ' '; + } + print ''; + print $projectstatic->getLibStatut(1); + print ''; + $fullhour=convertSecondToTime($obj->planned_workload,$plannedworkloadoutputformat); + $workingdelay=convertSecondToTime($obj->planned_workload,'all',86400,7); // TODO Replace 86400 and 7 to take account working hours per day and working day per weeks + if ($obj->planned_workload != '') + { + print $fullhour; + // TODO Add delay taking account of working hours per day and working day per week + //if ($workingdelay != $fullhour) print '
('.$workingdelay.')'; + } + //else print '--:--'; + print '
'; + if ($showlineingray) print ''; + else print ''; + if ($obj->duration_effective) print convertSecondToTime($obj->duration_effective,$timespentoutputformat); + else print '--:--'; + if ($showlineingray) print ''; + else print ''; + print ''; + if ($obj->planned_workload || $obj->duration_effective) + { + if ($obj->planned_workload) print round(100 * $obj->duration_effective / $obj->planned_workload,2).' %'; + else print $langs->trans('WorkloadNotDefined'); + } + print ''; + if ($obj->progress != '') + { + print $obj->progress.' %'; + } + print ''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour'); + print ''.$projectstatic->getLibStatut(5).''; + 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($obj->rowid, $arrayofselected)) $selected=1; + print ''; + } + print '
'.$langs->trans("Total").''.$langs->trans("Totalforthispage").''.convertSecondToTime($totalarray['totalplannedworkload'],$plannedworkloadoutputformat).''.convertSecondToTime($totalarray['totaldurationeffective'],$timespentoutputformat).'
"; + +print '
'; llxFooter(); - $db->close(); diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 96c527f3976..6acae492c33 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -444,7 +444,7 @@ if (! $resql) $num = $db->num_rows($resql); -if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE)) +if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && $action != 'list') { $obj = $db->fetch_object($resql); $id = $obj->rowid; diff --git a/htdocs/user/index.php b/htdocs/user/index.php index 459a89e573b..f5d9407d2e3 100644 --- a/htdocs/user/index.php +++ b/htdocs/user/index.php @@ -134,40 +134,46 @@ if ($mode == 'employee') $search_employee=1; /* * Actions */ - + +if (GETPOST('cancel')) { $action='list'; $massaction=''; } +if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction=''; } + $parameters=array(); $reshook=$hookmanager->executeHooks('doActions',$parameters); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") ||GETPOST("button_removefilter")) // All test are required to be compatible with all browsers +if (empty($reshook)) { - $search_user=""; - $search_login=""; - $search_lastname=""; - $search_firstname=""; - $search_gender=""; - $search_employee=""; - $search_accountancy_code=""; - $search_email=""; - $search_statut=""; - $search_thirdparty=""; - $search_supervisor=""; - $search_datelastlogin=""; - $search_datepreviouslogin=""; - $search_date_creation=""; - $search_date_update=""; - $search_array_options=array(); + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + + // Purge search criteria + if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") ||GETPOST("button_removefilter")) // All test are required to be compatible with all browsers + { + $search_user=""; + $search_login=""; + $search_lastname=""; + $search_firstname=""; + $search_gender=""; + $search_employee=""; + $search_accountancy_code=""; + $search_email=""; + $search_statut=""; + $search_thirdparty=""; + $search_supervisor=""; + $search_datelastlogin=""; + $search_datepreviouslogin=""; + $search_date_creation=""; + $search_date_update=""; + $search_array_options=array(); + } } - /* * View */ -llxHeader('',$langs->trans("ListOfUsers")); $buttonviewhierarchy='
'; @@ -239,150 +245,363 @@ if ($result) $sql.= $db->plimit($limit+1, $offset); $result = $db->query($sql); -if ($result) +if (! $result) { - $num = $db->num_rows($result); - $i = 0; + dol_print_error($db); + exit; +} - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($sall != '') $param.='&sall='.urlencode($sall); - if ($search_user != '') $param.="&search_user=".$search_user; - if ($search_login != '') $param.="&search_login=".$search_login; - if ($search_lastname != '') $param.="&search_lastname=".$search_lastname; - if ($search_firstname != '') $param.="&search_firstname=".$search_firstname; - if ($search_gender != '') $param.="&search_gender=".$search_gender; - if ($search_employee != '') $param.="&search_employee=".$search_employee; - if ($search_accountancy_code != '') $param.="&search_accountancy_code=".$search_accountancy_code; - if ($search_email != '') $param.="&search_email=".$search_email; - if ($search_supervisor > 0) $param.="&search_supervisor=".$search_supervisor; - if ($search_statut != '') $param.="&search_statut=".$search_statut; - if ($optioncss != '') $param.='&optioncss='.$optioncss; - if ($mode != '') $param.='&mode='.$mode; - // Add $param from extra fields - foreach ($search_array_options as $key => $val) - { - $crit=$val; - $tmpkey=preg_replace('/search_options_/','',$key); - if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); - } - - $text = $langs->trans("ListOfUsers"); - - print '
'."\n"; - if ($optioncss != '') print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - print_barre_liste($text, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, "", $num, $nbtotalofrecords, 'title_generic', 0, '', '', $limit); +$num = $db->num_rows($result); - if ($sall) - { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); - } - - $moreforfilter=''; - - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - - print ''; - print ''; - if (! empty($arrayfields['u.login']['checked'])) print_liste_field_titre($langs->trans("Login"),$_SERVER['PHP_SELF'],"u.login",$param,"","",$sortfield,$sortorder); - if (! empty($arrayfields['u.lastname']['checked'])) print_liste_field_titre($langs->trans("Lastname"),$_SERVER['PHP_SELF'],"u.lastname",$param,"","",$sortfield,$sortorder); - if (! empty($arrayfields['u.firstname']['checked'])) print_liste_field_titre($langs->trans("FirstName"),$_SERVER['PHP_SELF'],"u.firstname",$param,"","",$sortfield,$sortorder); - if (! empty($arrayfields['u.gender']['checked'])) print_liste_field_titre($langs->trans("Gender"),$_SERVER['PHP_SELF'],"u.gender",$param,"","",$sortfield,$sortorder); - if (! empty($arrayfields['u.employee']['checked'])) print_liste_field_titre($langs->trans("Employee"),$_SERVER['PHP_SELF'],"u.employee",$param,"","",$sortfield,$sortorder); - if (! empty($arrayfields['u.accountancy_code']['checked'])) print_liste_field_titre($langs->trans("AccountancyCode"),$_SERVER['PHP_SELF'],"u.accountancy_code",$param,"","",$sortfield,$sortorder); - if (! empty($arrayfields['u.email']['checked'])) print_liste_field_titre($langs->trans("EMail"),$_SERVER['PHP_SELF'],"u.email",$param,"","",$sortfield,$sortorder); - if (! empty($arrayfields['u.fk_soc']['checked'])) print_liste_field_titre($langs->trans("Company"),$_SERVER['PHP_SELF'],"u.fk_soc",$param,"","",$sortfield,$sortorder); - if (! empty($arrayfields['u.entity']['checked'])) print_liste_field_titre($langs->trans("Entity"),$_SERVER['PHP_SELF'],"u.entity",$param,"","",$sortfield,$sortorder); - if (! empty($arrayfields['u.fk_user']['checked'])) print_liste_field_titre($langs->trans("HierarchicalResponsible"),$_SERVER['PHP_SELF'],"u.fk_user",$param,"","",$sortfield,$sortorder); - if (! empty($arrayfields['u.datelastlogin']['checked'])) print_liste_field_titre($langs->trans("LastConnexion"),$_SERVER['PHP_SELF'],"u.datelastlogin",$param,"",'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['u.datepreviouslogin']['checked'])) print_liste_field_titre($langs->trans("PreviousConnexion"),$_SERVER['PHP_SELF'],"u.datepreviouslogin",$param,"",'align="center"',$sortfield,$sortorder); - // Extra fields - if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) - { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) - { - $align=$extrafields->getAlignFlag($key); - print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); - } - } - } - // Hook fields - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (! empty($arrayfields['u.datec']['checked'])) print_liste_field_titre($langs->trans("DateCreationShort"),$_SERVER["PHP_SELF"],"u.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); - if (! empty($arrayfields['u.tms']['checked'])) print_liste_field_titre($langs->trans("DateModificationShort"),$_SERVER["PHP_SELF"],"u.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); - if (! empty($arrayfields['u.statut']['checked'])) print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"u.statut","",$param,'align="center"',$sortfield,$sortorder); - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch '); - print "\n"; +if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) +{ + $obj = $db->fetch_object($resql); + $id = $obj->rowid; + header("Location: ".DOL_URL_ROOT.'/user/card.php?id='.$id); + exit; +} - // Search bar - print ''; +llxHeader('',$langs->trans("ListOfUsers")); + +$param=''; +if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; +if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; +if ($sall != '') $param.='&sall='.urlencode($sall); +if ($search_user != '') $param.="&search_user=".$search_user; +if ($search_login != '') $param.="&search_login=".$search_login; +if ($search_lastname != '') $param.="&search_lastname=".$search_lastname; +if ($search_firstname != '') $param.="&search_firstname=".$search_firstname; +if ($search_gender != '') $param.="&search_gender=".$search_gender; +if ($search_employee != '') $param.="&search_employee=".$search_employee; +if ($search_accountancy_code != '') $param.="&search_accountancy_code=".$search_accountancy_code; +if ($search_email != '') $param.="&search_email=".$search_email; +if ($search_supervisor > 0) $param.="&search_supervisor=".$search_supervisor; +if ($search_statut != '') $param.="&search_statut=".$search_statut; +if ($optioncss != '') $param.='&optioncss='.$optioncss; +if ($mode != '') $param.='&mode='.$mode; +// Add $param from extra fields +foreach ($search_array_options as $key => $val) +{ + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); +} + +$text = $langs->trans("ListOfUsers"); + +print ''."\n"; +if ($optioncss != '') print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +print_barre_liste($text, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, "", $num, $nbtotalofrecords, 'title_generic', 0, '', '', $limit); + +if ($sall) +{ + foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); + print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); +} + +$moreforfilter=''; + +$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; +$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + +print '
'; +print ''; +if (! empty($arrayfields['u.login']['checked'])) print_liste_field_titre($langs->trans("Login"),$_SERVER['PHP_SELF'],"u.login",$param,"","",$sortfield,$sortorder); +if (! empty($arrayfields['u.lastname']['checked'])) print_liste_field_titre($langs->trans("Lastname"),$_SERVER['PHP_SELF'],"u.lastname",$param,"","",$sortfield,$sortorder); +if (! empty($arrayfields['u.firstname']['checked'])) print_liste_field_titre($langs->trans("FirstName"),$_SERVER['PHP_SELF'],"u.firstname",$param,"","",$sortfield,$sortorder); +if (! empty($arrayfields['u.gender']['checked'])) print_liste_field_titre($langs->trans("Gender"),$_SERVER['PHP_SELF'],"u.gender",$param,"","",$sortfield,$sortorder); +if (! empty($arrayfields['u.employee']['checked'])) print_liste_field_titre($langs->trans("Employee"),$_SERVER['PHP_SELF'],"u.employee",$param,"","",$sortfield,$sortorder); +if (! empty($arrayfields['u.accountancy_code']['checked'])) print_liste_field_titre($langs->trans("AccountancyCode"),$_SERVER['PHP_SELF'],"u.accountancy_code",$param,"","",$sortfield,$sortorder); +if (! empty($arrayfields['u.email']['checked'])) print_liste_field_titre($langs->trans("EMail"),$_SERVER['PHP_SELF'],"u.email",$param,"","",$sortfield,$sortorder); +if (! empty($arrayfields['u.fk_soc']['checked'])) print_liste_field_titre($langs->trans("Company"),$_SERVER['PHP_SELF'],"u.fk_soc",$param,"","",$sortfield,$sortorder); +if (! empty($arrayfields['u.entity']['checked'])) print_liste_field_titre($langs->trans("Entity"),$_SERVER['PHP_SELF'],"u.entity",$param,"","",$sortfield,$sortorder); +if (! empty($arrayfields['u.fk_user']['checked'])) print_liste_field_titre($langs->trans("HierarchicalResponsible"),$_SERVER['PHP_SELF'],"u.fk_user",$param,"","",$sortfield,$sortorder); +if (! empty($arrayfields['u.datelastlogin']['checked'])) print_liste_field_titre($langs->trans("LastConnexion"),$_SERVER['PHP_SELF'],"u.datelastlogin",$param,"",'align="center"',$sortfield,$sortorder); +if (! empty($arrayfields['u.datepreviouslogin']['checked'])) print_liste_field_titre($langs->trans("PreviousConnexion"),$_SERVER['PHP_SELF'],"u.datepreviouslogin",$param,"",'align="center"',$sortfield,$sortorder); +// Extra fields +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +{ + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + $align=$extrafields->getAlignFlag($key); + print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); + } + } +} +// Hook fields +$parameters=array('arrayfields'=>$arrayfields); +$reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +if (! empty($arrayfields['u.datec']['checked'])) print_liste_field_titre($langs->trans("DateCreationShort"),$_SERVER["PHP_SELF"],"u.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['u.tms']['checked'])) print_liste_field_titre($langs->trans("DateModificationShort"),$_SERVER["PHP_SELF"],"u.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['u.statut']['checked'])) print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"u.statut","",$param,'align="center"',$sortfield,$sortorder); +print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch '); +print "\n"; + +// Search bar +print ''; +if (! empty($arrayfields['u.login']['checked'])) +{ + print ''; +} +if (! empty($arrayfields['u.lastname']['checked'])) +{ + print ''; +} +if (! empty($arrayfields['u.firstname']['checked'])) +{ + print ''; +} +if (! empty($arrayfields['u.gender']['checked'])) +{ + print ''; +} +if (! empty($arrayfields['u.employee']['checked'])) +{ + print ''; +} +if (! empty($arrayfields['u.accountancy_code']['checked'])) +{ + print ''; +} +if (! empty($arrayfields['u.email']['checked'])) +{ + print ''; +} +if (! empty($arrayfields['u.fk_soc']['checked'])) +{ + print ''; +} +if (! empty($arrayfields['u.entity']['checked'])) +{ + print ''; +} +if (! empty($arrayfields['u.fk_user']['checked'])) +{ + print ''; +} +if (! empty($arrayfields['u.datelastlogin']['checked'])) +{ + print ''; +} +if (! empty($arrayfields['u.datepreviouslogin']['checked'])) +{ + print ''; +} +// Extra fields +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +{ + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + $align=$extrafields->getAlignFlag($key); + $typeofextrafield=$extrafields->attribute_type[$key]; + print ''; + } + } +} +// Fields from hook +$parameters=array('arrayfields'=>$arrayfields); +$reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +if (! empty($arrayfields['u.datec']['checked'])) +{ + // Date creation + print ''; +} +if (! empty($arrayfields['u.tms']['checked'])) +{ + // Date modification + print ''; +} +if (! empty($arrayfields['u.statut']['checked'])) +{ + // Status + print ''; +} +// Action column +print ''; + +print "\n"; + +$user2=new User($db); + +$var=True; +$i = 0; +while ($i < min($num,$limit)) +{ + $obj = $db->fetch_object($result); + $var=!$var; + + $userstatic->id=$obj->rowid; + $userstatic->ref=$obj->label; + $userstatic->login=$obj->login; + $userstatic->statut=$obj->statut; + $userstatic->email=$obj->email; + $userstatic->gender=$obj->gender; + $userstatic->societe_id=$obj->fk_soc; + $userstatic->firstname=$obj->firstname; + $userstatic->lastname=$obj->lastname; + $userstatic->employee=$obj->employee; + $userstatic->photo=$obj->photo; + + $li=$userstatic->getNomUrl(-1,'',0,0,24,1,'login'); + + print ""; if (! empty($arrayfields['u.login']['checked'])) - { - print ''; - } + { + print ''; + } if (! empty($arrayfields['u.lastname']['checked'])) - { - print ''; - } + { + print ''; + } if (! empty($arrayfields['u.firstname']['checked'])) - { - print ''; - } + { + print ''; + } if (! empty($arrayfields['u.gender']['checked'])) - { - print ''; - } + { + print ''; + } if (! empty($arrayfields['u.employee']['checked'])) - { - print ''; - } - if (! empty($arrayfields['u.accountancy_code']['checked'])) - { - print ''; - } + { + print ''; + } + if (! empty($arrayfields['u.accountancy_code']['checked'])) + { + print ''; + } if (! empty($arrayfields['u.email']['checked'])) + { + print ''; + } + if (! empty($arrayfields['u.fk_soc']['checked'])) + { + print "'; + } + // Multicompany enabled + if (! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode)) { - print ''; - } - if (! empty($arrayfields['u.fk_soc']['checked'])) - { - print ''; - } - if (! empty($arrayfields['u.entity']['checked'])) - { - print ''; + if (! empty($arrayfields['u.entity']['checked'])) + { + print ''; + } } + // Supervisor if (! empty($arrayfields['u.fk_user']['checked'])) - { - print ''; - } + { + // Resp + print ''; + } + + // Date last login if (! empty($arrayfields['u.datelastlogin']['checked'])) - { - print ''; - } + { + print ''; + } + // Date previous login if (! empty($arrayfields['u.datepreviouslogin']['checked'])) - { - print ''; - } + { + print ''; + } + // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { @@ -390,260 +609,55 @@ if ($result) { if (! empty($arrayfields["ef.".$key]['checked'])) { - $align=$extrafields->getAlignFlag($key); - $typeofextrafield=$extrafields->attribute_type[$key]; - print ''; } } } // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; + // Date creation if (! empty($arrayfields['u.datec']['checked'])) { - // Date creation - print ''; } + // Date modification if (! empty($arrayfields['u.tms']['checked'])) { - // Date modification - print ''; } + // Status if (! empty($arrayfields['u.statut']['checked'])) { - // Status - print ''; + $userstatic->statut=$obj->statut; + print ''; } // Action column - print ''; - + print ''; + print "\n"; - - $user2=new User($db); - - $var=True; - $i = 0; - while ($i < min($num,$limit)) - { - $obj = $db->fetch_object($result); - $var=!$var; - - $userstatic->id=$obj->rowid; - $userstatic->ref=$obj->label; - $userstatic->login=$obj->login; - $userstatic->statut=$obj->statut; - $userstatic->email=$obj->email; - $userstatic->gender=$obj->gender; - $userstatic->societe_id=$obj->fk_soc; - $userstatic->firstname=$obj->firstname; - $userstatic->lastname=$obj->lastname; - $userstatic->employee=$obj->employee; - $userstatic->photo=$obj->photo; - - $li=$userstatic->getNomUrl(-1,'',0,0,24,1,'login'); - - print ""; - if (! empty($arrayfields['u.login']['checked'])) - { - print ''; - } - if (! empty($arrayfields['u.lastname']['checked'])) - { - print ''; - } - if (! empty($arrayfields['u.firstname']['checked'])) - { - print ''; - } - if (! empty($arrayfields['u.gender']['checked'])) - { - print ''; - } - if (! empty($arrayfields['u.employee']['checked'])) - { - print ''; - } - if (! empty($arrayfields['u.accountancy_code']['checked'])) - { - print ''; - } - if (! empty($arrayfields['u.email']['checked'])) - { - print ''; - } - if (! empty($arrayfields['u.fk_soc']['checked'])) - { - print "'; - } - // Multicompany enabled - if (! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode)) - { - if (! empty($arrayfields['u.entity']['checked'])) - { - print ''; - } - } - // Supervisor - if (! empty($arrayfields['u.fk_user']['checked'])) - { - // Resp - print ''; - } - - // Date last login - if (! empty($arrayfields['u.datelastlogin']['checked'])) - { - print ''; - } - // Date previous login - if (! empty($arrayfields['u.datepreviouslogin']['checked'])) - { - print ''; - } - - // Extra fields - if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) - { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) - { - print 'getAlignFlag($key); - if ($align) print ' align="'.$align.'"'; - print '>'; - $tmpkey='options_'.$key; - print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); - print ''; - } - } - } - // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (! empty($arrayfields['u.datec']['checked'])) - { - print ''; - } - // Date modification - if (! empty($arrayfields['u.tms']['checked'])) - { - print ''; - } - // Status - if (! empty($arrayfields['u.statut']['checked'])) - { - $userstatic->statut=$obj->statut; - print ''; - } - // Action column - print ''; - - print "\n"; - $i++; - } - - $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); - $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - print "
'; + $arraygender=array('man'=>$langs->trans("Genderman"),'woman'=>$langs->trans("Genderwoman")); + print $form->selectarray('search_gender', $arraygender, $search_gender, 1); + print ''; + print $form->selectyesno('search_employee', $search_employee, 1, false, 1); + print ''; + if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + { + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $searchclass=''; + if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; + if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + print ''; + } + print ''; + print ''; + print ''; + print $form->selectarray('search_statut', array('-1'=>'','0'=>$langs->trans('Disabled'),'1'=>$langs->trans('Enabled')),$search_statut); + print ''; +$searchpitco=$form->showFilterAndCheckAddButtons(0); +print $searchpitco; +print '
'; + print $li; + if (! empty($conf->multicompany->enabled) && $obj->admin && ! $obj->entity) + { + print img_picto($langs->trans("SuperAdministrator"),'redstar'); + } + else if ($obj->admin) + { + print img_picto($langs->trans("Administrator"),'star'); + } + print ''.$obj->lastname.''.$obj->firstname.''; - $arraygender=array('man'=>$langs->trans("Genderman"),'woman'=>$langs->trans("Genderwoman")); - print $form->selectarray('search_gender', $arraygender, $search_gender, 1); - print ''; + if ($obj->gender) print $langs->trans("Gender".$obj->gender); + print ''; - print $form->selectyesno('search_employee', $search_employee, 1, false, 1); - print ''.yn($obj->employee).''.$obj->accountancy_code.''.$obj->email.'"; + if ($obj->fk_soc) + { + $companystatic->id=$obj->fk_soc; + $companystatic->name=$obj->name; + $companystatic->canvas=$obj->canvas; + print $companystatic->getNomUrl(1); + } + else if ($obj->ldap_sid) + { + print $langs->trans("DomainUser"); + } + else + { + print $langs->trans("InternalUser"); + } + print ''; + if (! $obj->entity) + { + print $langs->trans("AllEntities"); + } + else + { + // $mc is defined in conf.class.php if multicompany enabled. + if (is_object($mc)) + { + $mc->getInfo($obj->entity); + print $mc->label; + } + } + print ''; + if ($obj->login2) + { + $user2->id=$obj->id2; + $user2->login=$obj->login2; + $user2->lastname=$obj->lastname2; + $user2->firstname=$obj->firstname2; + $user2->gender=$obj->gender2; + $user2->photo=$obj->photo2; + $user2->admin=$obj->admin2; + $user2->email=$obj->email2; + $user2->societe_id=$obj->fk_soc2; + print $user2->getNomUrl(-1,'',0,0,24,0,''); + if (! empty($conf->multicompany->enabled) && $obj->admin2 && ! $obj->entity2) + { + print img_picto($langs->trans("SuperAdministrator"),'redstar'); + } + else if ($obj->admin2) + { + print img_picto($langs->trans("Administrator"),'star'); + } + } + print ''.dol_print_date($db->jdate($obj->datelastlogin),"dayhour").''.dol_print_date($db->jdate($obj->datepreviouslogin),"dayhour").''; - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) - { - $crit=$val; - $tmpkey=preg_replace('/search_options_/','',$key); - $searchclass=''; - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; - print ''; - } + print 'getAlignFlag($key); + if ($align) print ' align="'.$align.'"'; + print '>'; + $tmpkey='options_'.$key; + print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); print ''; + print ''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); print ''; + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour'); print ''; - print $form->selectarray('search_statut', array('-1'=>'','0'=>$langs->trans('Disabled'),'1'=>$langs->trans('Enabled')),$search_statut); - print ''.$userstatic->getLibStatut(3).''; - $searchpitco=$form->showFilterAndCheckAddButtons(0); - print $searchpitco; - print '
'; - print $li; - if (! empty($conf->multicompany->enabled) && $obj->admin && ! $obj->entity) - { - print img_picto($langs->trans("SuperAdministrator"),'redstar'); - } - else if ($obj->admin) - { - print img_picto($langs->trans("Administrator"),'star'); - } - print ''.$obj->lastname.''.$obj->firstname.''; - if ($obj->gender) print $langs->trans("Gender".$obj->gender); - print ''.yn($obj->employee).''.$obj->accountancy_code.''.$obj->email.'"; - if ($obj->fk_soc) - { - $companystatic->id=$obj->fk_soc; - $companystatic->name=$obj->name; - $companystatic->canvas=$obj->canvas; - print $companystatic->getNomUrl(1); - } - else if ($obj->ldap_sid) - { - print $langs->trans("DomainUser"); - } - else - { - print $langs->trans("InternalUser"); - } - print ''; - if (! $obj->entity) - { - print $langs->trans("AllEntities"); - } - else - { - // $mc is defined in conf.class.php if multicompany enabled. - if (is_object($mc)) - { - $mc->getInfo($obj->entity); - print $mc->label; - } - } - print ''; - if ($obj->login2) - { - $user2->id=$obj->id2; - $user2->login=$obj->login2; - $user2->lastname=$obj->lastname2; - $user2->firstname=$obj->firstname2; - $user2->gender=$obj->gender2; - $user2->photo=$obj->photo2; - $user2->admin=$obj->admin2; - $user2->email=$obj->email2; - $user2->societe_id=$obj->fk_soc2; - print $user2->getNomUrl(-1,'',0,0,24,0,''); - if (! empty($conf->multicompany->enabled) && $obj->admin2 && ! $obj->entity2) - { - print img_picto($langs->trans("SuperAdministrator"),'redstar'); - } - else if ($obj->admin2) - { - print img_picto($langs->trans("Administrator"),'star'); - } - } - print ''.dol_print_date($db->jdate($obj->datelastlogin),"dayhour").''.dol_print_date($db->jdate($obj->datepreviouslogin),"dayhour").''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour'); - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour'); - print ''.$userstatic->getLibStatut(3).'
"; - print "
\n"; - $db->free($result); -} -else -{ - dol_print_error($db); + $i++; } +$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + +print ""; +print "\n"; +$db->free($result); + + llxFooter(); - $db->close();