FIX assign member cateogry to a member

This commit is contained in:
Laurent Destailleur 2022-05-03 21:54:34 +02:00
parent c55da219d9
commit ae282245fe
3 changed files with 30 additions and 25 deletions

View File

@ -734,9 +734,9 @@ if ($type == Categorie::TYPE_MEMBER) {
print '<input type="hidden" name="action" value="addintocategory">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td>';
print $langs->trans("AddMemberIntoCategory").' &nbsp;';
print $langs->trans("AssignCategoryTo").' &nbsp;';
print $form->selectMembers('', 'elemid');
print '<input type="submit" class="button buttongen" value="'.$langs->trans("ClassifyInCategory").'"></td>';
print '<input type="submit" class="button buttongen" value="'.$langs->trans("Save").'"></td>';
print '</tr>';
print '</table>';
print '</form>';

View File

@ -7101,12 +7101,14 @@ class Form
if ($selected && empty($selected_input_value)) {
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
$adherenttmpselect = new Member($this->db);
$adherenttmpselect = new Adherent($this->db);
$adherenttmpselect->fetch($selected);
$selected_input_value = $adherenttmpselect->ref;
unset($adherenttmpselect);
}
$urloption = '';
$out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/adherents/ajax/adherents.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 1, $ajaxoptions);
if (empty($hidelabel)) $out .= $langs->trans("RefOrLabel").' : ';
@ -7121,7 +7123,9 @@ class Form
$out .= img_picto($langs->trans("Search"), 'search');
}
} else {
$out .= $this->selectMembersList($selected, $htmlname, $filtertype, $limit, $status, 0, $socid, $showempty, $forcecombo, $morecss);
$filterkey = '';
$out .= $this->selectMembersList($selected, $htmlname, $filtertype, $limit, $filterkey, $status, 0, $showempty, $forcecombo, $morecss);
}
if (empty($nooutput)) print $out;
@ -7136,8 +7140,8 @@ class Form
* @param string $htmlname Name of select html
* @param string $filtertype Filter on adherent type
* @param int $limit Limit on number of returned lines
* @param string $filterkey Filter on adherent ref or subject
* @param int $status Ticket status
* @param string $filterkey Filter on member status
* @param int $status Member status
* @param int $outputmode 0=HTML select string, 1=Array
* @param string $showempty '' to not show empty line. Translation key to show an empty line. '1' show empty line with no text.
* @param int $forcecombo Force to use combo box
@ -7151,7 +7155,7 @@ class Form
$out = '';
$outarray = array();
$selectFields = " p.rowid, p.ref";
$selectFields = " p.rowid, p.ref, p.firstname, p.lastname";
$sql = "SELECT ";
$sql .= $selectFields;
@ -7161,21 +7165,23 @@ class Form
// Add criteria on ref/label
if ($filterkey != '') {
$sql .= ' AND (';
$prefix = empty($conf->global->TICKET_DONOTSEARCH_ANYWHERE) ? '%' : ''; // Can use index if PRODUCT_DONOTSEARCH_ANYWHERE is on
$prefix = empty($conf->global->MEMBER_DONOTSEARCH_ANYWHERE) ? '%' : ''; // Can use index if PRODUCT_DONOTSEARCH_ANYWHERE is on
// For natural search
$scrit = explode(' ', $filterkey);
$i = 0;
if (count($scrit) > 1) $sql .= "(";
foreach ($scrit as $crit) {
if ($i > 0) $sql .= " AND ";
$sql .= "p.ref LIKE '".$this->db->escape($prefix.$crit)."%'";
$sql .= "";
$sql .= "(p.firstname LIKE '".$this->db->escape($prefix.$crit)."%'";
$sql .= " OR p.lastname LIKE '".$this->db->escape($prefix.$crit)."%')";
$i++;
}
if (count($scrit) > 1) $sql .= ")";
$sql .= ')';
}
if ($status != -1) {
$sql .= ' AND statut = '.((int) $status);
}
$sql .= $this->db->plimit($limit, 0);
// Build output string
@ -7205,7 +7211,9 @@ class Form
} else {
if ($showempty && !is_numeric($showempty)) $textifempty = $langs->trans($showempty);
}
if ($showempty) $out .= '<option value="0" selected>'.$textifempty.'</option>';
if ($showempty) {
$out .= '<option value="-1" selected>'.$textifempty.'</option>';
}
$i = 0;
while ($num && $i < $num) {
@ -7214,6 +7222,7 @@ class Form
$objp = $this->db->fetch_object($result);
$this->constructMemberListOption($objp, $opt, $optJson, $selected, $filterkey);
// Add new entry
// "key" value of json key array is used by jQuery automatically as selected value
// "label" value of json key array is used by jQuery automatically as text for combo box
@ -7250,28 +7259,23 @@ class Form
global $langs, $conf, $user, $db;
$outkey = '';
$outval = '';
$outref = '';
$outlabel = '';
$outtype = '';
$label = $objp->label;
$outkey = $objp->rowid;
$outref = $objp->ref;
$outlabel = $objp->label;
$outtype = $objp->fk_product_type;
$outlabel = dolGetFirstLastname($objp->firstname, $objp->lastname);
$outtype = $objp->fk_adherent_type;
$opt = '<option value="'.$objp->rowid.'"';
$opt .= ($objp->rowid == $selected) ? ' selected' : '';
$opt .= '>';
$opt .= $objp->ref;
$objRef = $objp->ref;
if (!empty($filterkey) && $filterkey != '') $objRef = preg_replace('/('.preg_quote($filterkey, '/').')/i', '<strong>$1</strong>', $objRef, 1);
$outval .= $objRef;
if (!empty($filterkey) && $filterkey != '') {
$outlabel = preg_replace('/('.preg_quote($filterkey, '/').')/i', '<strong>$1</strong>', $outlabel, 1);
}
$opt .= $outlabel;
$opt .= "</option>\n";
$optJson = array('key'=>$outkey, 'value'=>$outref, 'type'=>$outtypem);
$optJson = array('key'=>$outkey, 'value'=>$outlabel, 'type'=>$outtype);
}
/**

View File

@ -90,6 +90,7 @@ CategorieRecursivHelp=If option is on, when you add a product into a subcategory
AddProductServiceIntoCategory=Add the following product/service
AddCustomerIntoCategory=Assign category to customer
AddSupplierIntoCategory=Assign category to supplier
AssignCategoryTo=Assign category to
ShowCategory=Show tag/category
ByDefaultInList=By default in list
ChooseCategory=Choose category