diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 5d449de78eb..2792d60f7d3 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -12899,7 +12899,7 @@ function getElementProperties($elementType) $classfile = 'mailing'; $classname = 'Mailing'; $subelement = ''; - } elseif ($elementType == 'member') { + } elseif ($elementType == 'member' || $elementType == 'adherent') { $classpath = 'adherents/class'; $module = 'adherent'; $subelement = 'adherent'; diff --git a/htdocs/partnership/partnership_list.php b/htdocs/partnership/partnership_list.php index 372b8cf3b4a..47347792176 100644 --- a/htdocs/partnership/partnership_list.php +++ b/htdocs/partnership/partnership_list.php @@ -95,10 +95,19 @@ if ($managedfor != 'member' && $sortfield == 'd.datefin') { $sortfield = ''; } +// Add non object fields to fields for list +$non_object_fields = array( + 'town' => array('type' => 'varchar(128)', 'label' => 'Town', 'enabled' => 1, 'position' => 51, 'notnull' => 0, 'visible' => 1, 'alwayseditable' => 1, 'searchall' => 1,), + 'country' => array('type' => 'integer', 'label' => 'Country', 'enabled' => 1, 'position' => 51, 'notnull' => 0, 'visible' => 1, 'alwayseditable' => 1, 'css' => 'maxwidth500 widthcentpercentminusxx', 'searchall' => 1,) +); + +// All fields in list +$all_fields_list = array_merge($object->fields, $non_object_fields); + // Default sort order (if not yet defined by previous GETPOST) if (!$sortfield) { - reset($object->fields); // Reset is required to avoid key() to return null. - $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. + reset($all_fields_list); // Reset is required to avoid key() to return null. + $sortfield = "t.".key($all_fields_list); // Set here default search field. By default 1st field in definition. } if (!$sortorder) { $sortorder = "ASC"; @@ -107,7 +116,7 @@ if (!$sortorder) { // Initialize array of search criteria $search_all = GETPOST('search_all', 'alphanohtml'); $search = array(); -foreach ($object->fields as $key => $val) { +foreach ($all_fields_list as $key => $val) { if (GETPOST('search_'.$key, 'alpha') !== '') { $search[$key] = GETPOST('search_'.$key, 'alpha'); } @@ -124,7 +133,7 @@ if ($filter) { // List of fields to search into when doing a "search in all" $fieldstosearchall = array(); -foreach ($object->fields as $key => $val) { +foreach ($non_object_fields as $key => $val) { if (!empty($val['searchall'])) { $fieldstosearchall['t.'.$key] = $val['label']; } @@ -132,7 +141,7 @@ foreach ($object->fields as $key => $val) { // Definition of array of fields for columns $arrayfields = array(); -foreach ($object->fields as $key => $val) { +foreach ($all_fields_list as $key => $val) { // If $val['visible']==0, then we never show the field if (!empty($val['visible'])) { $visible = (int) dol_eval((string) $val['visible'], 1); @@ -150,6 +159,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); +$all_fields_list = dol_sort_array($all_fields_list, 'position'); $permissiontoread = $user->hasRight('partnership', 'read'); $permissiontoadd = $user->hasRight('partnership', 'write'); @@ -197,7 +207,7 @@ if (empty($reshook)) { // Purge search criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers - foreach ($object->fields as $key => $val) { + foreach ($all_fields_list as $key => $val) { $search[$key] = ''; if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { $search[$key.'_dtstart'] = ''; @@ -337,6 +347,8 @@ if (isset($extrafields->attributes[$object->table_element]['label']) && is_array if ($managedfor == 'member') { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d on (d.rowid = t.fk_member)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_type as dty on (dty.rowid = d.fk_adherent_type)"; +} else { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as d on (d.rowid = t.fk_soc)"; } // Add table from hooks $parameters = array(); @@ -387,6 +399,17 @@ foreach ($search as $key => $val) { } } } + if ($key == 'country' && $search[$key] != '') { + if ($managedfor == 'member') { + $sql .= " AND d.country = '".$db->escape($val)."'"; + } else { + $sql .= " AND d.fk_pays = '".$db->escape($val)."'"; + } + //$sql .= natural_search("d.fk_pays", $val); + } + if ($key == 'town' && $search[$key] != '') { + $sql .= natural_search("d.town", $val); + } } } if ($managedfor == 'member') { @@ -742,7 +765,7 @@ if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print $searchpicto; print ''; } -foreach ($object->fields as $key => $val) { +foreach ($all_fields_list as $key => $val) { $searchkey = empty($search[$key]) ? '' : $search[$key]; $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); if ($key == 'status') { @@ -771,6 +794,8 @@ foreach ($object->fields as $key => $val) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; $formadmin = new FormAdmin($db); print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth100imp maxwidth125', 2); + } elseif ($key == 'country') { + print $form->select_country($search[$key], 'search_country', '', 0, 'minwidth100imp maxwidth100'); } else { print ''; } @@ -810,7 +835,7 @@ if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; $totalarray['nbfield']++; // For the column action } -foreach ($object->fields as $key => $val) { +foreach ($all_fields_list as $key => $val) { $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); if ($key == 'status') { $cssforfield .= ($cssforfield ? ' ' : '').'center'; @@ -888,6 +913,12 @@ while ($i < $imaxinloop) { $object->thirdparty = $companyobj; } + if ($managedfor == 'member') { + if ($obj->fk_member > 0) { + $result = $adherent->fetch($obj->fk_member); + } + } + if ($mode == 'kanban') { if ($i == 0) { print '