Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEW multiselect search_sale in list societe #29110

Merged
merged 16 commits into from
Nov 13, 2024

Conversation

atm-jonathan
Copy link
Contributor

Instructions

In htdocs/societe/list.php :
Replace button search simple Select commercial by Multiselect in list societe
Now we can search for multiple companies belonging to several sales representatives.
But also third parties without sales representatives.

NEW|New [New multiselect list societe]

Replace méthode select_salesrepresentatives() by multiselectarray()

@atm-jonathan atm-jonathan changed the title New multiselect list societe NEW multiselect search_sale in list societe Mar 28, 2024
@@ -97,7 +97,7 @@
$search_idprof5 = trim(GETPOST('search_idprof5', 'alpha'));
$search_idprof6 = trim(GETPOST('search_idprof6', 'alpha'));
$search_vat = trim(GETPOST('search_vat', 'alpha'));
$search_sale = GETPOSTINT("search_sale");
$search_sale = GETPOST("search_sale", 'alphanohtml');
Copy link
Member

@eldy eldy Mar 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to new code search_sale is an array of int. So you should use
$search_sale = GETPOST('search_sale', 'array:int');
And to be compatible with old url (bookmarked for exemple), you can do

if (GETPOSTISARRAY('search_sale')) {
  $search_sale = GETPOST('search_sale', 'array:int');
} else {
  $search_sale = array(GETPOSTINT($search_sale));
}

Later
$search_sale_req = implode(',', $search_sale_req); can become
$search_sale_req = implode(',', $search_sale);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK for the first suggestion
if (GETPOSTISARRAY('search_sale')) {
$search_sale = GETPOST('search_sale', 'array:int');
} else if (GETPOSTISSET('search_sale')) {
$search_sale = array(GETPOSTINT('search_sale'));
}
for the second
$search_sale_req must be different de $search_sale
because it must not contain "-2" = (no sales staff)

the case of -2

elseif (count($search_sale) > 0 && in_array('-2', $search_sale)) {
		$sql .= " AND (EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = s.rowid AND sc.fk_user IN (".$db->sanitize($search_sale_req)."))";
		$sql .= " OR NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = s.rowid))";
	}

in my block following
$search_sale_req = implode(',', $search_sale_req);
I need both variables

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eldy eldy added Discussion Some questions or discussions are opened and wait answers of author or other people to be processed PR to fix - See feedback in comments PR needs to be fixed to be integrated (some comments should describes the fix to do) and removed Discussion Some questions or discussions are opened and wait answers of author or other people to be processed labels Mar 29, 2024
@atm-quentin atm-quentin requested a review from eldy April 5, 2024 12:28
@eldy eldy added the PR to fix - Conflict or CI error to solve The PHP unit tests return something wrong. Check details to know what to fix or solve the conflicts. label Apr 5, 2024
@eldy eldy merged commit e20d1f0 into Dolibarr:develop Nov 13, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR to fix - Conflict or CI error to solve The PHP unit tests return something wrong. Check details to know what to fix or solve the conflicts. PR to fix - See feedback in comments PR needs to be fixed to be integrated (some comments should describes the fix to do)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants