Laurent Destailleur 3 anos atrás
pai
commit
7b4dae8773

+ 49 - 14
htdocs/comm/action/list.php

@@ -183,7 +183,8 @@ if ($user->socid && $socid) {
  */
 
 if (GETPOST('cancel', 'alpha')) {
-	$mode = 'list'; $massaction = '';
+	$mode = 'list';
+	$massaction = '';
 }
 
 if (GETPOST("viewcal") || GETPOST("viewweek") || GETPOST("viewday")) {
@@ -268,7 +269,7 @@ if (empty($reshook)) {
 }
 
 /*
- *  View
+ * View
  */
 
 $form = new Form($db);
@@ -282,7 +283,8 @@ $nav .= ' <input type="submit" name="submitdateselect" class="button" value="'.$
 $now = dol_now();
 
 $help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda';
-llxHeader('', $langs->trans("Agenda"), $help_url);
+$title = $langs->trans("Agenda");
+llxHeader('', $title, $help_url);
 
 // Define list of all external calendars
 $listofextcals = array();
@@ -570,11 +572,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
 		$nbtotalofrecords++;
 	}*/
 	/* The fast and low memory method to get and count full list converts the sql into a sql count */
-	$sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),]+FROM/i', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql);
+	$sqlforcount = preg_replace('/^SELECT[a-zA-Z0-9\._\s\(\),]+FROM/i', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql);
 	$resql = $db->query($sqlforcount);
 	$objforcount = $db->fetch_object($resql);
 	$nbtotalofrecords = $objforcount->nbtotalofrecords;
-	if (($page * $limit) > $nbtotalofrecords) {	// if total resultset is smaller then paging size (filtering), goto and load page 0
+	if (($page * $limit) > $nbtotalofrecords) {	// if total of record found is smaller than page * limit, goto and load page 0
 		$page = 0;
 		$offset = 0;
 	}
@@ -804,44 +806,57 @@ print '<td class="liste_titre" align="middle">';
 $searchpicto = $form->showFilterButtons();
 print $searchpicto;
 print '</td>';
-print "</tr>\n";
+print '</tr>'."\n";
+
+$totalarray = array();
+$totalarray['nbfield'] = 0;
 
+// Fields title label
+// --------------------------------------------------------------------
 print '<tr class="liste_titre">';
 if (!empty($arrayfields['a.id']['checked'])) {
 	print_liste_field_titre($arrayfields['a.id']['label'], $_SERVER["PHP_SELF"], "a.id", $param, "", "", $sortfield, $sortorder);
+	$totalarray['nbfield']++;
 }
 if (!empty($arrayfields['owner']['checked'])) {
 	print_liste_field_titre($arrayfields['owner']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder);
+	$totalarray['nbfield']++;
 }
 if (!empty($arrayfields['c.libelle']['checked'])) {
 	print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], "c.libelle", $param, "", "", $sortfield, $sortorder);
+	$totalarray['nbfield']++;
 }
 if (!empty($arrayfields['a.label']['checked'])) {
 	print_liste_field_titre($arrayfields['a.label']['label'], $_SERVER["PHP_SELF"], "a.label", $param, "", "", $sortfield, $sortorder);
+	$totalarray['nbfield']++;
 }
 if (!empty($arrayfields['a.note']['checked'])) {
 	print_liste_field_titre($arrayfields['a.note']['label'], $_SERVER["PHP_SELF"], "a.note", $param, "", "", $sortfield, $sortorder);
+	$totalarray['nbfield']++;
 }
 //if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
 if (!empty($arrayfields['a.datep']['checked'])) {
 	print_liste_field_titre($arrayfields['a.datep']['label'], $_SERVER["PHP_SELF"], "a.datep,a.id", $param, '', 'align="center"', $sortfield, $sortorder);
+	$totalarray['nbfield']++;
 }
 if (!empty($arrayfields['a.datep2']['checked'])) {
 	print_liste_field_titre($arrayfields['a.datep2']['label'], $_SERVER["PHP_SELF"], "a.datep2", $param, '', 'align="center"', $sortfield, $sortorder);
+	$totalarray['nbfield']++;
 }
 if (!empty($arrayfields['s.nom']['checked'])) {
 	print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", $param, "", "", $sortfield, $sortorder);
+	$totalarray['nbfield']++;
 }
 if (!empty($arrayfields['a.fk_contact']['checked'])) {
 	print_liste_field_titre($arrayfields['a.fk_contact']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder);
+	$totalarray['nbfield']++;
 }
 if (!empty($arrayfields['a.fk_element']['checked'])) {
 	print_liste_field_titre($arrayfields['a.fk_element']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder);
+	$totalarray['nbfield']++;
 }
-
 // Extra fields
 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
-
 // Hook fields
 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
@@ -869,9 +884,21 @@ $caction = new CActionComm($db);
 $arraylist = $caction->liste_array(1, 'code', '', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : 0), '', 1);
 $contactListCache = array();
 
-while ($i < min($num, $limit)) {
+// Loop on record
+// --------------------------------------------------------------------
+$i = 0;
+//$savnbfield = $totalarray['nbfield'];
+//$totalarray['nbfield'] = 0;
+$imaxinloop = ($limit ? min($num, $limit) : $num);
+while ($i < $imaxinloop) {
 	$obj = $db->fetch_object($resql);
-
+	if (empty($obj)) {
+		break; // Should not happen
+	}
+	
+	// Store properties in $object
+	$object->setVarsFromFetchObj($obj);
+	
 	// Discard auto action if option is on
 	if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->type_code == 'AC_OTH_AUTO') {
 		$i++;
@@ -1087,12 +1114,20 @@ while ($i < min($num, $limit)) {
 	}
 	print '</td>';
 
-	print "</tr>\n";
+	print '</tr>'."\n";
+
 	$i++;
 }
-print "</table>";
-print '</div>';
-print '</form>';
+// If no record found
+if ($num == 0) {
+	print '<tr><td colspan="'.$totalarray['nbfield'].'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
+}
+
+
+print '</table>'."\n";
+print '</div>'."\n";
+
+print '</form>'."\n";
 
 $db->free($resql);
 

+ 4 - 2
htdocs/core/class/html.form.class.php

@@ -1279,7 +1279,6 @@ class Form
 
 			// mode 1
 			$urloption = 'htmlname='.urlencode(str_replace('.', '_', $htmlname)).'&outjson=1&filter='.urlencode($filter).(empty($excludeids) ? '' : '&excludeids='.join(',', $excludeids)).($showtype ? '&showtype='.urlencode($showtype) : '');
-			$out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/societe/ajax/company.php', $urloption, $conf->global->COMPANY_USE_SEARCH_TO_SELECT, 0, $ajaxoptions);
 
 			$out .= '<style type="text/css">.ui-autocomplete { z-index: 1003; }</style>';
 			if (empty($hidelabel)) {
@@ -1294,6 +1293,8 @@ class Form
 			if ($hidelabel == 3) {
 				$out .= img_picto($langs->trans("Search"), 'search');
 			}
+
+			$out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/societe/ajax/company.php', $urloption, $conf->global->COMPANY_USE_SEARCH_TO_SELECT, 0, $ajaxoptions);
 		} else {
 			// Immediate load of all database
 			$out .= $this->select_thirdparty_list($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events, '', 0, $limit, $morecss, $moreparam, $multiple, $excludeids);
@@ -9435,7 +9436,6 @@ class Form
 		if ($resql) {
 			// Enhance with select2
 			include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
-			$out .= ajax_combobox($htmlname);
 
 			$out .= '<select class="flat minwidth200'.($morecss ? ' '.$morecss : '').'" id="'.$htmlname.'" name="'.$htmlname.($multiple ? '[]' : '').'" '.($multiple ? 'multiple' : '').' '.($disabled ? ' disabled' : '').'>';
 
@@ -9477,6 +9477,8 @@ class Form
 				$out .= '<option value="" disabled>'.$langs->trans("NoUserGroupDefined").'</option>';
 			}
 			$out .= '</select>';
+
+			$out .= ajax_combobox($htmlname);
 		} else {
 			dol_print_error($this->db);
 		}

+ 9 - 5
htdocs/core/class/html.formprojet.class.php

@@ -191,14 +191,9 @@ class FormProjets
 
 		$resql = $this->db->query($sql);
 		if ($resql) {
-			// Use select2 selector
 			if (!empty($conf->use_javascript_ajax)) {
-				include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
-				$comboenhancement = ajax_combobox($htmlid, array(), 0, $forcefocus);
-				$out .= $comboenhancement;
 				$morecss .= ' minwidth100';
 			}
-
 			if (empty($option_only)) {
 				$out .= '<select class="flat'.($morecss ? ' '.$morecss : '').'"'.($disabled ? ' disabled="disabled"' : '').' id="'.$htmlid.'" name="'.$htmlname.'">';
 			}
@@ -284,6 +279,15 @@ class FormProjets
 				if (empty($option_only)) {
 					$out .= '</select>';
 				}
+
+				// Use select2 selector
+				if (!empty($conf->use_javascript_ajax)) {
+					include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
+					$comboenhancement = ajax_combobox($htmlid, array(), 0, $forcefocus);
+					$out .= $comboenhancement;
+					$morecss .= ' minwidth100';
+				}
+
 				if (empty($nooutput)) {
 					print $out;
 					return '';

+ 8 - 9
htdocs/core/lib/agenda.lib.php

@@ -71,25 +71,24 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh
 
 	if ($canedit) {
 		print '<div class="divsearchfield">';
-
 		// Type
 		$multiselect = 0;
 		if (!empty($conf->global->MAIN_ENABLE_MULTISELECT_TYPE)) {     // We use an option here because it adds bugs when used on agenda page "peruser" and "list"
 			$multiselect = (!empty($conf->global->AGENDA_USE_EVENT_TYPE));
 		}
-		print img_picto($langs->trans("ActionType"), 'square', 'class="fawidth30 inline-block" style="color: #ddd;"');
-		print $formactions->select_type_actions($actioncode, "search_actioncode", $excludetype, (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : -1), 0, $multiselect, 0, 'maxwidth500');
+		print img_picto($langs->trans("ActionType"), 'square', 'class="pictofixedwidth inline-block" style="color: #ddd;"');
+		print $formactions->select_type_actions($actioncode, "search_actioncode", $excludetype, (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : -1), 0, $multiselect, 0, 'maxwidth500 widthcentpercentminusx');
 		print '</div>';
 
 		// Assigned to user
 		print '<div class="divsearchfield">';
-		print img_picto($langs->trans("ActionsToDoBy"), 'user', 'class="fawidth30 inline-block"');
+		print img_picto($langs->trans("ActionsToDoBy"), 'user', 'class="pictofixedwidth inline-block"');
 		print $form->select_dolusers($filtert, 'search_filtert', 1, '', !$canedit, '', '', 0, 0, 0, '', 0, '', 'minwidth150 maxwidth500 widthcentpercentminusxx');
 		print '</div>';
 
 		// Assigned to user group
 		print '<div class="divsearchfield">';
-		print img_picto($langs->trans("ToUserOfGroup"), 'object_group', 'class="fawidth30 inline-block"');
+		print img_picto($langs->trans("ToUserOfGroup"), 'object_group', 'class="pictofixedwidth inline-block"');
 		print $form->select_dolgroups($usergroupid, 'usergroup', 1, '', !$canedit, '', '', '0', false, 'minwidth100 maxwidth500 widthcentpercentminusxx');
 		print '</div>';
 
@@ -99,7 +98,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh
 
 			// Resource
 			print '<div class="divsearchfield">';
-			print img_picto($langs->trans("Resource"), 'object_resource', 'class="fawidth30 inline-block"');
+			print img_picto($langs->trans("Resource"), 'object_resource', 'class="pictofixedwidth inline-block"');
 			print $formresource->select_resource_list($resourceid, "search_resourceid", '', 1, 0, 0, null, '', 2, 0, 'maxwidth500');
 			print '</div>';
 		}
@@ -107,7 +106,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh
 
 	if (!empty($conf->societe->enabled) && !empty($user->rights->societe->lire)) {
 		print '<div class="divsearchfield">';
-		print img_picto($langs->trans("ThirdParty"), 'company', 'class="fawidth30 inline-block"');
+		print img_picto($langs->trans("ThirdParty"), 'company', 'class="pictofixedwidth inline-block"');
 		print $form->select_company($socid, 'search_socid', '', '&nbsp;', 0, 0, null, 0, 'minwidth100 maxwidth500');
 		print '</div>';
 	}
@@ -117,7 +116,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh
 		$formproject = new FormProjets($db);
 
 		print '<div class="divsearchfield">';
-		print img_picto($langs->trans("Project"), 'project', 'class="fawidth30 inline-block"');
+		print img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth inline-block"');
 		print $formproject->select_projects($socid ? $socid : -1, $pid, 'search_projectid', 0, 0, 1, 0, 0, 0, 0, '', 1, 0, 'maxwidth500');
 		print '</div>';
 	}
@@ -125,7 +124,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh
 	if ($canedit && !preg_match('/list/', $_SERVER["PHP_SELF"])) {
 		// Status
 		print '<div class="divsearchfield">';
-		print img_picto($langs->trans("Status"), 'setup', 'class="fawidth30 inline-block"');
+		print img_picto($langs->trans("Status"), 'setup', 'class="pictofixedwidth inline-block"');
 		$formactions->form_select_status_action('formaction', $status, 1, 'search_status', 1, 2, 'minwidth100');
 		print '</div>';
 	}

+ 7 - 7
htdocs/resource/class/html.formresource.class.php

@@ -101,13 +101,6 @@ class FormResource
 		}
 
 		if ($resourcestat) {
-			if (!empty($conf->use_javascript_ajax) && !empty($conf->global->RESOURCE_USE_SEARCH_TO_SELECT) && !$forcecombo) {
-				//$minLength = (is_numeric($conf->global->RESOURCE_USE_SEARCH_TO_SELECT)?$conf->global->RESOURCE_USE_SEARCH_TO_SELECT:2);
-				$out .= ajax_combobox($htmlname, $event, $conf->global->RESOURCE_USE_SEARCH_TO_SELECT);
-			} else {
-				$out .= ajax_combobox($htmlname);
-			}
-
 			// Construct $out and $outarray
 			$out .= '<select id="'.$htmlname.'" class="flat minwidth100'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.($multiple ? '[]' : '').'" '.($multiple ? 'multiple' : '').'>'."\n";
 			if ($showempty) {
@@ -147,6 +140,13 @@ class FormResource
 			}
 			$out .= '</select>'."\n";
 
+			if (!empty($conf->use_javascript_ajax) && !empty($conf->global->RESOURCE_USE_SEARCH_TO_SELECT) && !$forcecombo) {
+				//$minLength = (is_numeric($conf->global->RESOURCE_USE_SEARCH_TO_SELECT)?$conf->global->RESOURCE_USE_SEARCH_TO_SELECT:2);
+				$out .= ajax_combobox($htmlname, $event, $conf->global->RESOURCE_USE_SEARCH_TO_SELECT);
+			} else {
+				$out .= ajax_combobox($htmlname);
+			}
+
 			if ($outputmode != 2) {
 				$out .= '<input type="submit" class="button" value="'.$langs->trans("Search").'"> &nbsp; &nbsp; ';