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 ($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 '';
- print ' ';
- print ' ';
- }
- if (! empty($arrayfields['p.title']['checked']))
- {
- print '';
- print ' ';
- print ' ';
- }
- if (! empty($arrayfields['s.nom']['checked']))
- {
- print '';
- print ' ';
- print ' ';
- }
- // Sale representative
- if (! empty($arrayfields['commercial']['checked']))
- {
- print ' ';
- }
- // Start date
- if (! empty($arrayfields['p.dateo']['checked']))
- {
- print '';
- if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ' ';
- print ' ';
- $formother->select_year($syear?$syear:-1,'syear',1, 20, 5);
- print ' ';
- }
- // End date
- if (! empty($arrayfields['p.datee']['checked']))
- {
- print '';
- if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ' ';
- print ' ';
- $formother->select_year($year?$year:-1,'year',1, 20, 5);
- print ' ';
- }
- if (! empty($arrayfields['p.public']['checked']))
- {
- print '';
- $array=array(''=>'',0 => $langs->trans("PrivateProject"),1 => $langs->trans("SharedProject"));
- print $form->selectarray('search_public',$array,$search_public);
- print ' ';
- }
- if (! empty($arrayfields['p.opp_amount']['checked']))
- {
- print '';
- print ' ';
- print ' ';
- }
- if (! empty($arrayfields['p.fk_opp_status']['checked']))
- {
- print '';
- print $formproject->selectOpportunityStatus('search_opp_status',$search_opp_status,1,1,1);
- print ' ';
- }
- if (! empty($arrayfields['p.opp_percent']['checked']))
- {
- print '';
- print ' ';
- print ' ';
- }
- if (! empty($arrayfields['p.budget_amount']['checked']))
- {
- print '';
- print ' ';
- 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 '';
- 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 ' ';
- }
- }
- }
- // 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 '';
- print ' ';
- }
- if (! empty($arrayfields['p.tms']['checked']))
- {
- // Date modification
- print '';
- print ' ';
- }
- if (! empty($arrayfields['p.fk_statut']['checked']))
- {
- 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 ' ';
- }
- // Action column
- print '';
- $searchpitco=$form->showFilterAndCheckAddButtons(0);
- print $searchpitco;
- 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 '';
- print $projectstatic->getNomUrl(1);
- if ($projectstatic->hasDelay()) print img_warning($langs->trans('Late'));
- print ' ';
- if (! $i) $totalarray['nbfield']++;
- }
- // Title
- if (! empty($arrayfields['p.title']['checked']))
- {
- print '';
- print dol_trunc($obj->title,80);
- print ' ';
- if (! $i) $totalarray['nbfield']++;
- }
- // Company
- if (! empty($arrayfields['s.nom']['checked']))
- {
- print '';
- if ($obj->socid)
- {
- $socstatic->id=$obj->socid;
- $socstatic->name=$obj->name;
- print $socstatic->getNomUrl(1);
- }
- else
- {
- print ' ';
- }
- print ' ';
- if (! $i) $totalarray['nbfield']++;
- }
- // Sales Representatives
- if (! empty($arrayfields['commercial']['checked']))
- {
- 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 ' ';
- if (! $i) $totalarray['nbfield']++;
- }
- // Date start
- if (! empty($arrayfields['p.dateo']['checked']))
- {
- print '';
- print dol_print_date($db->jdate($obj->date_start),'day');
- print ' ';
- if (! $i) $totalarray['nbfield']++;
- }
- // Date end
- if (! empty($arrayfields['p.datee']['checked']))
- {
- print '';
- print dol_print_date($db->jdate($obj->date_end),'day');
- print ' ';
- if (! $i) $totalarray['nbfield']++;
- }
- // Visibility
- if (! empty($arrayfields['p.public']['checked']))
- {
- print '';
- if ($obj->public) print $langs->trans('SharedProject');
- else print $langs->trans('PrivateProject');
- print ' ';
- if (! $i) $totalarray['nbfield']++;
- }
- // Amount
- if (! empty($arrayfields['p.opp_amount']['checked']))
- {
- print '';
- if ($obj->opp_status_code)
- {
- print price($obj->opp_amount, 1, '', 1, -1, -1, '');
- $totalarray['totalopp'] += $obj->opp_amount;
- }
- print ' ';
- if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totaloppfield']=$totalarray['nbfield'];
- }
- if (! empty($arrayfields['p.fk_opp_status']['checked']))
- {
- print '';
- if ($obj->opp_status_code) print $langs->trans("OppStatusShort".$obj->opp_status_code);
- print ' ';
- if (! $i) $totalarray['nbfield']++;
- }
- if (! empty($arrayfields['p.opp_percent']['checked']))
- {
- print '';
- if ($obj->opp_percent) print price($obj->opp_percent, 1, '', 1, 0).'%';
- print ' ';
- if (! $i) $totalarray['nbfield']++;
- }
- if (! empty($arrayfields['p.budget_amount']['checked']))
- {
- print '';
- if ($obj->budget_amount != '')
- {
- print price($obj->budget_amount, 1, '', 1, -1, -1);
- $totalarray['totalbudget'] += $obj->budget_amount;
- }
- 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 '';
- print dol_print_date($db->jdate($obj->date_creation), 'dayhour');
- print ' ';
- if (! $i) $totalarray['nbfield']++;
- }
- // Date modification
- if (! empty($arrayfields['p.tms']['checked']))
- {
- print '';
- print dol_print_date($db->jdate($obj->date_update), 'dayhour');
- print ' ';
- if (! $i) $totalarray['nbfield']++;
- }
- // Status
- if (! empty($arrayfields['p.fk_statut']['checked']))
- {
- $projectstatic->statut = $obj->fk_statut;
- print ''.$projectstatic->getLibStatut(5).' ';
- if (! $i) $totalarray['nbfield']++;
- }
- // Action column
- print '';
- 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 ' ';
- 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 ''.$langs->trans("Total").' ';
- else print ''.$langs->trans("Totalforthispage").' ';
- }
- elseif ($totalarray['totaloppfield'] == $i) print ''.price($totalarray['totalopp']).' ';
- elseif ($totalarray['totalbudgetfield'] == $i) print ''.price($totalarray['totalbudget']).' ';
- 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 "
\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 '';
+ print ' ';
+ print ' ';
+}
+if (! empty($arrayfields['p.title']['checked']))
+{
+ print '';
+ print ' ';
+ print ' ';
+}
+if (! empty($arrayfields['s.nom']['checked']))
+{
+ print '';
+ print ' ';
+ print ' ';
+}
+// Sale representative
+if (! empty($arrayfields['commercial']['checked']))
+{
+ print ' ';
+}
+// Start date
+if (! empty($arrayfields['p.dateo']['checked']))
+{
+ print '';
+ if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ' ';
+ print ' ';
+ $formother->select_year($syear?$syear:-1,'syear',1, 20, 5);
+ print ' ';
+}
+// End date
+if (! empty($arrayfields['p.datee']['checked']))
+{
+ print '';
+ if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ' ';
+ print ' ';
+ $formother->select_year($year?$year:-1,'year',1, 20, 5);
+ print ' ';
+}
+if (! empty($arrayfields['p.public']['checked']))
+{
+ print '';
+ $array=array(''=>'',0 => $langs->trans("PrivateProject"),1 => $langs->trans("SharedProject"));
+ print $form->selectarray('search_public',$array,$search_public);
+ print ' ';
+}
+if (! empty($arrayfields['p.opp_amount']['checked']))
+{
+ print '';
+ print ' ';
+ print ' ';
+}
+if (! empty($arrayfields['p.fk_opp_status']['checked']))
+{
+ print '';
+ print $formproject->selectOpportunityStatus('search_opp_status',$search_opp_status,1,1,1);
+ print ' ';
+}
+if (! empty($arrayfields['p.opp_percent']['checked']))
+{
+ print '';
+ print ' ';
+ print ' ';
+}
+if (! empty($arrayfields['p.budget_amount']['checked']))
+{
+ print '';
+ print ' ';
+ 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 '';
+ 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 ' ';
+ }
+ }
+}
+// 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 '';
+ print ' ';
+}
+if (! empty($arrayfields['p.tms']['checked']))
+{
+ // Date modification
+ print '';
+ print ' ';
+}
+if (! empty($arrayfields['p.fk_statut']['checked']))
+{
+ 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 ' ';
+}
+// Action column
+print '';
+$searchpitco=$form->showFilterAndCheckAddButtons(0);
+print $searchpitco;
+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 '';
+ print $projectstatic->getNomUrl(1);
+ if ($projectstatic->hasDelay()) print img_warning($langs->trans('Late'));
+ print ' ';
+ if (! $i) $totalarray['nbfield']++;
+ }
+ // Title
+ if (! empty($arrayfields['p.title']['checked']))
+ {
+ print '';
+ print dol_trunc($obj->title,80);
+ print ' ';
+ if (! $i) $totalarray['nbfield']++;
+ }
+ // Company
+ if (! empty($arrayfields['s.nom']['checked']))
+ {
+ print '';
+ if ($obj->socid)
+ {
+ $socstatic->id=$obj->socid;
+ $socstatic->name=$obj->name;
+ print $socstatic->getNomUrl(1);
+ }
+ else
+ {
+ print ' ';
+ }
+ print ' ';
+ if (! $i) $totalarray['nbfield']++;
+ }
+ // Sales Representatives
+ if (! empty($arrayfields['commercial']['checked']))
+ {
+ 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 ' ';
+ if (! $i) $totalarray['nbfield']++;
+ }
+ // Date start
+ if (! empty($arrayfields['p.dateo']['checked']))
+ {
+ print '';
+ print dol_print_date($db->jdate($obj->date_start),'day');
+ print ' ';
+ if (! $i) $totalarray['nbfield']++;
+ }
+ // Date end
+ if (! empty($arrayfields['p.datee']['checked']))
+ {
+ print '';
+ print dol_print_date($db->jdate($obj->date_end),'day');
+ print ' ';
+ if (! $i) $totalarray['nbfield']++;
+ }
+ // Visibility
+ if (! empty($arrayfields['p.public']['checked']))
+ {
+ print '';
+ if ($obj->public) print $langs->trans('SharedProject');
+ else print $langs->trans('PrivateProject');
+ print ' ';
+ if (! $i) $totalarray['nbfield']++;
+ }
+ // Amount
+ if (! empty($arrayfields['p.opp_amount']['checked']))
+ {
+ print '';
+ if ($obj->opp_status_code)
+ {
+ print price($obj->opp_amount, 1, '', 1, -1, -1, '');
+ $totalarray['totalopp'] += $obj->opp_amount;
+ }
+ print ' ';
+ if (! $i) $totalarray['nbfield']++;
+ if (! $i) $totalarray['totaloppfield']=$totalarray['nbfield'];
+ }
+ if (! empty($arrayfields['p.fk_opp_status']['checked']))
+ {
+ print '';
+ if ($obj->opp_status_code) print $langs->trans("OppStatusShort".$obj->opp_status_code);
+ print ' ';
+ if (! $i) $totalarray['nbfield']++;
+ }
+ if (! empty($arrayfields['p.opp_percent']['checked']))
+ {
+ print '';
+ if ($obj->opp_percent) print price($obj->opp_percent, 1, '', 1, 0).'%';
+ print ' ';
+ if (! $i) $totalarray['nbfield']++;
+ }
+ if (! empty($arrayfields['p.budget_amount']['checked']))
+ {
+ print '';
+ if ($obj->budget_amount != '')
+ {
+ print price($obj->budget_amount, 1, '', 1, -1, -1);
+ $totalarray['totalbudget'] += $obj->budget_amount;
+ }
+ 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 '';
+ print dol_print_date($db->jdate($obj->date_creation), 'dayhour');
+ print ' ';
+ if (! $i) $totalarray['nbfield']++;
+ }
+ // Date modification
+ if (! empty($arrayfields['p.tms']['checked']))
+ {
+ print '';
+ print dol_print_date($db->jdate($obj->date_update), 'dayhour');
+ print ' ';
+ if (! $i) $totalarray['nbfield']++;
+ }
+ // Status
+ if (! empty($arrayfields['p.fk_statut']['checked']))
+ {
+ $projectstatic->statut = $obj->fk_statut;
+ print ''.$projectstatic->getLibStatut(5).' ';
+ if (! $i) $totalarray['nbfield']++;
+ }
+ // Action column
+ print '';
+ 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 ' ';
+ 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 ''.$langs->trans("Total").' ';
+ else print ''.$langs->trans("Totalforthispage").' ';
+ }
+ elseif ($totalarray['totaloppfield'] == $i) print ''.price($totalarray['totalopp']).' ';
+ elseif ($totalarray['totalbudgetfield'] == $i) print ''.price($totalarray['totalbudget']).' ';
+ 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 "
\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 '';
- print ' ';
- print ' ';
- }
- if (! empty($arrayfields['t.label']['checked']))
- {
- print '';
- print ' ';
- print ' ';
- }
- // Start date
- if (! empty($arrayfields['t.dateo']['checked']))
- {
- print '';
- if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ' ';
- print ' ';
- $formother->select_year($syear?$syear:-1,'syear',1, 20, 5);
- print ' ';
- }
- // End date
- if (! empty($arrayfields['t.datee']['checked']))
- {
- print '';
- if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ' ';
- print ' ';
- $formother->select_year($year?$year:-1,'year',1, 20, 5);
- print ' ';
- }
- if (! empty($arrayfields['p.ref']['checked']))
- {
- print '';
- print ' ';
- print ' ';
- }
- if (! empty($arrayfields['p.title']['checked']))
- {
- print '';
- print ' ';
- print ' ';
- }
- if (! empty($arrayfields['s.nom']['checked']))
- {
- print '';
- print ' ';
- print ' ';
- }
- if (! empty($arrayfields['p.fk_statut']['checked']))
- {
- 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 (! 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 '';
- 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 ' ';
- }
- }
- }
- // 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 '';
- print ' ';
- }
- if (! empty($arrayfields['t.tms']['checked']))
- {
- // Date modification
- print '';
- print ' ';
- }
- // Action column
- print '';
- $searchpitco=$form->showFilterAndCheckAddButtons(0);
- print $searchpitco;
- 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 '';
- print $taskstatic->getNomUrl(1,'withproject');
- if ($taskstatic->hasDelay()) print img_warning("Late");
- print ' ';
- if (! $i) $totalarray['nbfield']++;
- }
- // Label
- if (! empty($arrayfields['t.label']['checked']))
- {
- print '';
- print $taskstatic->label;
- print ' ';
- if (! $i) $totalarray['nbfield']++;
- }
- // Date start
- if (! empty($arrayfields['t.dateo']['checked']))
- {
- print '';
- print dol_print_date($db->jdate($obj->date_start),'day');
- print ' ';
- if (! $i) $totalarray['nbfield']++;
- }
- // Date end
- if (! empty($arrayfields['t.datee']['checked']))
- {
- print '';
- print dol_print_date($db->jdate($obj->date_end),'day');
- print ' ';
- if (! $i) $totalarray['nbfield']++;
- }
- // Project ref
- if (! empty($arrayfields['p.ref']['checked']))
- {
- print '';
- print $projectstatic->getNomUrl(1, 'task');
- if ($projectstatic->hasDelay()) print img_warning("Late");
- print ' ';
- if (! $i) $totalarray['nbfield']++;
- }
- // Project title
- if (! empty($arrayfields['p.title']['checked']))
- {
- print '';
- print dol_trunc($obj->projecttitle,80);
- print ' ';
- if (! $i) $totalarray['nbfield']++;
- }
- // Third party
- if (! empty($arrayfields['s.nom']['checked']))
- {
- print '';
- if ($obj->socid)
- {
- $socstatic->id=$obj->socid;
- $socstatic->name=$obj->name;
- print $socstatic->getNomUrl(1);
- }
- else
- {
- print ' ';
- }
- print ' ';
- if (! $i) $totalarray['nbfield']++;
- }
- // Project status
- if (! empty($arrayfields['p.fk_statut']['checked']))
- {
- print '';
- print $projectstatic->getLibStatut(1);
- print ' ';
- if (! $i) $totalarray['nbfield']++;
- }
-
- // Planned workload
- if (! empty($arrayfields['t.planned_workload']['checked']))
- {
- 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 (! $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 ($showlineingray) print '';
- else print '';
- if ($obj->duration_effective) print convertSecondToTime($obj->duration_effective,$timespentoutputformat);
- else print '--:--';
- if ($showlineingray) print ' ';
- else print '';
- 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 ($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 (! $i) $totalarray['nbfield']++;
- }
- // Declared progress
- if (! empty($arrayfields['t.progress']['checked']))
- {
- print '';
- if ($obj->progress != '')
- {
- print $obj->progress.' %';
- }
- 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 '';
- print dol_print_date($db->jdate($obj->date_creation), 'dayhour');
- print ' ';
- if (! $i) $totalarray['nbfield']++;
- }
- // Date modification
- if (! empty($arrayfields['t.tms']['checked']))
- {
- print '';
- print dol_print_date($db->jdate($obj->date_update), 'dayhour');
- print ' ';
- if (! $i) $totalarray['nbfield']++;
- }
- // Status
- /*if (! empty($arrayfields['p.fk_statut']['checked']))
- {
- $projectstatic->statut = $obj->fk_statut;
- print ''.$projectstatic->getLibStatut(5).' ';
- }*/
- // Action column
- print '';
- 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 ' ';
- 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 ''.$langs->trans("Total").' ';
- else print ''.$langs->trans("Totalforthispage").' ';
- }
- elseif ($totalarray['totalplannedworkloadfield'] == $i) print ''.convertSecondToTime($totalarray['totalplannedworkload'],$plannedworkloadoutputformat).' ';
- elseif ($totalarray['totaldurationeffectivefield'] == $i) print ''.convertSecondToTime($totalarray['totaldurationeffective'],$timespentoutputformat).' ';
- 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 ' ';
-}
-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 '';
+ print ' ';
+ print ' ';
+}
+if (! empty($arrayfields['t.label']['checked']))
+{
+ print '';
+ print ' ';
+ print ' ';
+}
+// Start date
+if (! empty($arrayfields['t.dateo']['checked']))
+{
+ print '';
+ if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ' ';
+ print ' ';
+ $formother->select_year($syear?$syear:-1,'syear',1, 20, 5);
+ print ' ';
+}
+// End date
+if (! empty($arrayfields['t.datee']['checked']))
+{
+ print '';
+ if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ' ';
+ print ' ';
+ $formother->select_year($year?$year:-1,'year',1, 20, 5);
+ print ' ';
+}
+if (! empty($arrayfields['p.ref']['checked']))
+{
+ print '';
+ print ' ';
+ print ' ';
+}
+if (! empty($arrayfields['p.title']['checked']))
+{
+ print '';
+ print ' ';
+ print ' ';
+}
+if (! empty($arrayfields['s.nom']['checked']))
+{
+ print '';
+ print ' ';
+ print ' ';
+}
+if (! empty($arrayfields['p.fk_statut']['checked']))
+{
+ 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 (! 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 '';
+ 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 ' ';
+ }
+ }
+}
+// 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 '';
+ print ' ';
+}
+if (! empty($arrayfields['t.tms']['checked']))
+{
+ // Date modification
+ print '';
+ print ' ';
+}
+// Action column
+print '';
+$searchpitco=$form->showFilterAndCheckAddButtons(0);
+print $searchpitco;
+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 '';
+ print $taskstatic->getNomUrl(1,'withproject');
+ if ($taskstatic->hasDelay()) print img_warning("Late");
+ print ' ';
+ if (! $i) $totalarray['nbfield']++;
+ }
+ // Label
+ if (! empty($arrayfields['t.label']['checked']))
+ {
+ print '';
+ print $taskstatic->label;
+ print ' ';
+ if (! $i) $totalarray['nbfield']++;
+ }
+ // Date start
+ if (! empty($arrayfields['t.dateo']['checked']))
+ {
+ print '';
+ print dol_print_date($db->jdate($obj->date_start),'day');
+ print ' ';
+ if (! $i) $totalarray['nbfield']++;
+ }
+ // Date end
+ if (! empty($arrayfields['t.datee']['checked']))
+ {
+ print '';
+ print dol_print_date($db->jdate($obj->date_end),'day');
+ print ' ';
+ if (! $i) $totalarray['nbfield']++;
+ }
+ // Project ref
+ if (! empty($arrayfields['p.ref']['checked']))
+ {
+ print '';
+ print $projectstatic->getNomUrl(1, 'task');
+ if ($projectstatic->hasDelay()) print img_warning("Late");
+ print ' ';
+ if (! $i) $totalarray['nbfield']++;
+ }
+ // Project title
+ if (! empty($arrayfields['p.title']['checked']))
+ {
+ print '';
+ print dol_trunc($obj->projecttitle,80);
+ print ' ';
+ if (! $i) $totalarray['nbfield']++;
+ }
+ // Third party
+ if (! empty($arrayfields['s.nom']['checked']))
+ {
+ print '';
+ if ($obj->socid)
+ {
+ $socstatic->id=$obj->socid;
+ $socstatic->name=$obj->name;
+ print $socstatic->getNomUrl(1);
+ }
+ else
+ {
+ print ' ';
+ }
+ print ' ';
+ if (! $i) $totalarray['nbfield']++;
+ }
+ // Project status
+ if (! empty($arrayfields['p.fk_statut']['checked']))
+ {
+ print '';
+ print $projectstatic->getLibStatut(1);
+ print ' ';
+ if (! $i) $totalarray['nbfield']++;
+ }
+
+ // Planned workload
+ if (! empty($arrayfields['t.planned_workload']['checked']))
+ {
+ 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 (! $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 ($showlineingray) print '';
+ else print '';
+ if ($obj->duration_effective) print convertSecondToTime($obj->duration_effective,$timespentoutputformat);
+ else print '--:--';
+ if ($showlineingray) print ' ';
+ else print '';
+ 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 ($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 (! $i) $totalarray['nbfield']++;
+ }
+ // Declared progress
+ if (! empty($arrayfields['t.progress']['checked']))
+ {
+ print '';
+ if ($obj->progress != '')
+ {
+ print $obj->progress.' %';
+ }
+ 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 '';
+ print dol_print_date($db->jdate($obj->date_creation), 'dayhour');
+ print ' ';
+ if (! $i) $totalarray['nbfield']++;
+ }
+ // Date modification
+ if (! empty($arrayfields['t.tms']['checked']))
+ {
+ print '';
+ print dol_print_date($db->jdate($obj->date_update), 'dayhour');
+ print ' ';
+ if (! $i) $totalarray['nbfield']++;
+ }
+ // Status
+ /*if (! empty($arrayfields['p.fk_statut']['checked']))
+ {
+ $projectstatic->statut = $obj->fk_statut;
+ print ''.$projectstatic->getLibStatut(5).' ';
+ }*/
+ // Action column
+ print '';
+ 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 ' ';
+ 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 ''.$langs->trans("Total").' ';
+ else print ''.$langs->trans("Totalforthispage").' ';
+ }
+ elseif ($totalarray['totalplannedworkloadfield'] == $i) print ''.convertSecondToTime($totalarray['totalplannedworkload'],$plannedworkloadoutputformat).' ';
+ elseif ($totalarray['totaldurationeffectivefield'] == $i) print ''.convertSecondToTime($totalarray['totaldurationeffective'],$timespentoutputformat).' ';
+ 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 ' ';
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 '';
+ $arraygender=array('man'=>$langs->trans("Genderman"),'woman'=>$langs->trans("Genderwoman"));
+ print $form->selectarray('search_gender', $arraygender, $search_gender, 1);
+ print ' ';
+}
+if (! empty($arrayfields['u.employee']['checked']))
+{
+ print '';
+ print $form->selectyesno('search_employee', $search_employee, 1, false, 1);
+ 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 '';
+ 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 ' ';
+ }
+ }
+}
+// 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 '';
+ print ' ';
+}
+if (! empty($arrayfields['u.tms']['checked']))
+{
+ // Date modification
+ print '';
+ print ' ';
+}
+if (! empty($arrayfields['u.statut']['checked']))
+{
+ // Status
+ print '';
+ print $form->selectarray('search_statut', array('-1'=>'','0'=>$langs->trans('Disabled'),'1'=>$langs->trans('Enabled')),$search_statut);
+ print ' ';
+}
+// Action column
+print '';
+$searchpitco=$form->showFilterAndCheckAddButtons(0);
+print $searchpitco;
+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 '';
+ 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 ' ';
+ }
if (! empty($arrayfields['u.lastname']['checked']))
- {
- print ' ';
- }
+ {
+ print ''.$obj->lastname.' ';
+ }
if (! empty($arrayfields['u.firstname']['checked']))
- {
- print ' ';
- }
+ {
+ print ''.$obj->firstname.' ';
+ }
if (! empty($arrayfields['u.gender']['checked']))
- {
- print '';
- $arraygender=array('man'=>$langs->trans("Genderman"),'woman'=>$langs->trans("Genderwoman"));
- print $form->selectarray('search_gender', $arraygender, $search_gender, 1);
- print ' ';
- }
+ {
+ print '';
+ if ($obj->gender) print $langs->trans("Gender".$obj->gender);
+ print ' ';
+ }
if (! empty($arrayfields['u.employee']['checked']))
- {
- print '';
- print $form->selectyesno('search_employee', $search_employee, 1, false, 1);
- print ' ';
- }
- if (! empty($arrayfields['u.accountancy_code']['checked']))
- {
- print ' ';
- }
+ {
+ print ''.yn($obj->employee).' ';
+ }
+ if (! empty($arrayfields['u.accountancy_code']['checked']))
+ {
+ print ''.$obj->accountancy_code.' ';
+ }
if (! empty($arrayfields['u.email']['checked']))
+ {
+ print ''.$obj->email.' ';
+ }
+ if (! empty($arrayfields['u.fk_soc']['checked']))
+ {
+ print "";
+ 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 ' ';
+ }
+ // 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 '';
+ 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 ' ';
+ }
}
+ // Supervisor
if (! empty($arrayfields['u.fk_user']['checked']))
- {
- print ' ';
- }
+ {
+ // Resp
+ 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 ' ';
+ }
+
+ // Date last login
if (! empty($arrayfields['u.datelastlogin']['checked']))
- {
- print ' ';
- }
+ {
+ print ''.dol_print_date($db->jdate($obj->datelastlogin),"dayhour").' ';
+ }
+ // Date previous login
if (! empty($arrayfields['u.datepreviouslogin']['checked']))
- {
- print ' ';
- }
+ {
+ print ''.dol_print_date($db->jdate($obj->datepreviouslogin),"dayhour").' ';
+ }
+
// 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 '';
- 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 ' ';
}
}
}
// 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 '';
+ print ' ';
+ print dol_print_date($db->jdate($obj->date_creation), 'dayhour');
print ' ';
}
+ // Date modification
if (! empty($arrayfields['u.tms']['checked']))
{
- // Date modification
- print '';
+ print ' ';
+ print dol_print_date($db->jdate($obj->date_update), 'dayhour');
print ' ';
}
+ // Status
if (! empty($arrayfields['u.statut']['checked']))
{
- // Status
- print '';
- print $form->selectarray('search_statut', array('-1'=>'','0'=>$langs->trans('Disabled'),'1'=>$langs->trans('Enabled')),$search_statut);
- print ' ';
+ $userstatic->statut=$obj->statut;
+ print ''.$userstatic->getLibStatut(3).' ';
}
// Action column
- print '';
- $searchpitco=$form->showFilterAndCheckAddButtons(0);
- print $searchpitco;
- 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 '';
- 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 ' ';
- }
- if (! empty($arrayfields['u.lastname']['checked']))
- {
- print ''.$obj->lastname.' ';
- }
- if (! empty($arrayfields['u.firstname']['checked']))
- {
- print ''.$obj->firstname.' ';
- }
- if (! empty($arrayfields['u.gender']['checked']))
- {
- print '';
- if ($obj->gender) print $langs->trans("Gender".$obj->gender);
- print ' ';
- }
- if (! empty($arrayfields['u.employee']['checked']))
- {
- print ''.yn($obj->employee).' ';
- }
- if (! empty($arrayfields['u.accountancy_code']['checked']))
- {
- print ''.$obj->accountancy_code.' ';
- }
- if (! empty($arrayfields['u.email']['checked']))
- {
- print ''.$obj->email.' ';
- }
- if (! empty($arrayfields['u.fk_soc']['checked']))
- {
- print "";
- 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 ' ';
- }
- // Multicompany enabled
- if (! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode))
- {
- if (! empty($arrayfields['u.entity']['checked']))
- {
- 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 ' ';
- }
- }
- // Supervisor
- if (! empty($arrayfields['u.fk_user']['checked']))
- {
- // Resp
- 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 ' ';
- }
-
- // Date last login
- if (! empty($arrayfields['u.datelastlogin']['checked']))
- {
- print ''.dol_print_date($db->jdate($obj->datelastlogin),"dayhour").' ';
- }
- // Date previous login
- if (! empty($arrayfields['u.datepreviouslogin']['checked']))
- {
- print ''.dol_print_date($db->jdate($obj->datepreviouslogin),"dayhour").' ';
- }
-
- // 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 '';
- print dol_print_date($db->jdate($obj->date_creation), 'dayhour');
- print ' ';
- }
- // Date modification
- if (! empty($arrayfields['u.tms']['checked']))
- {
- print '';
- print dol_print_date($db->jdate($obj->date_update), 'dayhour');
- print ' ';
- }
- // Status
- if (! empty($arrayfields['u.statut']['checked']))
- {
- $userstatic->statut=$obj->statut;
- print ''.$userstatic->getLibStatut(3).' ';
- }
- // 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 "
";
- 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();