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

FIX #32186 #32198

Open
wants to merge 8 commits into
base: 20.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion htdocs/comm/propal/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,8 @@
}
}*/

if (!$user->hasRight('societe', 'client', 'voir')) {
// Check only if it's an internal user
if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) {
Copy link
Member

Choose a reason for hiding this comment

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

Do you mean
If (!empty(...
?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we first have to check that $user is internal, so the fix proposed by @hregis is ok

$search_sale = $user->id;
}

Expand Down
3 changes: 2 additions & 1 deletion htdocs/compta/facture/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,8 @@
$arrayfields = dol_sort_array($arrayfields, 'position');
'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan

if (!$user->hasRight('societe', 'client', 'voir')) {
// Check only if it's an internal user
if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) {
$search_sale = $user->id;
}

Expand Down
4 changes: 3 additions & 1 deletion htdocs/fourn/commande/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@

$error = 0;

if (!$user->hasRight('societe', 'client', 'voir')) {
// Check only if it's an internal user
if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) {
$search_sale = $user->id;
}

Expand Down Expand Up @@ -511,6 +512,7 @@
}

$tva_tx = $lines[$i]->tva_tx;
// @phan-suppress-next-line PhanTypeMismatchArgumentInternal
if (!empty($lines[$i]->vat_src_code) && !preg_match('/\(/', (string) $tva_tx)) {
$tva_tx .= ' ('.$lines[$i]->vat_src_code.')';
}
Expand Down
1 change: 1 addition & 0 deletions htdocs/fourn/facture/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -1339,6 +1339,7 @@
}

$tva_tx = $lines[$i]->tva_tx;
// @phan-suppress-next-line PhanTypeMismatchArgumentInternal
if (!empty($lines[$i]->vat_src_code) && !preg_match('/\(/', (string) $tva_tx)) {
$tva_tx .= ' ('.$lines[$i]->vat_src_code.')';
}
Expand Down
4 changes: 2 additions & 2 deletions htdocs/fourn/facture/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@
accessforbidden();
}

if (!$user->hasRight('societe', 'client', 'voir')) {
// Check only if it' an internal user
if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) {
$search_sale = $user->id;
}

Expand Down Expand Up @@ -307,7 +308,6 @@
$search_categ_sup = 0;
$filter = '';
$option = '';
$socid = "";
}

// Mass actions
Expand Down
2 changes: 1 addition & 1 deletion htdocs/societe/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -1388,7 +1388,7 @@ function formatCustomerSelection (selection) {
if (getDolGlobalString('THIRDPARTY_SUPPLIER_BY_DEFAULT')) {
$default = 1;
}
print $form->selectyesno("fournisseur", ((GETPOST("type") == '' ? $default : $object->fournisseur)), 1, 0, (GETPOST("type") == '' ? 1 : 0), 1);
print $form->selectyesno("fournisseur", (GETPOSTINT('fournisseur') > 0 ? GETPOSTINT('fournisseur') : (GETPOST("type") == '' ? $default : $object->fournisseur)), 1, 0, (GETPOST("type") == '' ? 1 : 0), 1);
print '</td>';


Expand Down
43 changes: 26 additions & 17 deletions htdocs/supplier_proposal/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@
$search_user = GETPOST('search_user', 'intcomma');
$search_sale = GETPOST('search_sale', 'intcomma');
$search_ref = GETPOST('sf_ref') ? GETPOST('sf_ref', 'alpha') : GETPOST('search_ref', 'alpha');
$search_societe = GETPOST('search_societe', 'alpha');
$search_societe_alias = GETPOST('search_societe_alias', 'alpha');
$search_company = GETPOST('search_company', 'alpha');
$search_company_alias = GETPOST('search_company_alias', 'alpha');
$search_login = GETPOST('search_login', 'alpha');
$search_town = GETPOST('search_town', 'alpha');
$search_zip = GETPOST('search_zip', 'alpha');
Expand Down Expand Up @@ -198,7 +198,8 @@
$arrayfields = dol_sort_array($arrayfields, 'position');
'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields'; // dol_sort_array looses type for Phan

if (!$user->hasRight('societe', 'client', 'voir')) {
// Check only if it's an internal user
if (empty($user->socid) && !$user->hasRight('societe', 'client', 'voir')) {
$search_sale = $user->id;
}

Expand Down Expand Up @@ -236,8 +237,8 @@
$search_user = '';
$search_sale = '';
$search_ref = '';
$search_societe = '';
$search_societe_alias = '';
$search_company = '';
$search_company_alias = '';
$search_montant_ht = '';
$search_montant_vat = '';
$search_montant_ttc = '';
Expand Down Expand Up @@ -294,6 +295,14 @@

$now = dol_now();

if ($socid > 0) {
$soc = new Societe($db);
$soc->fetch($socid);
if (empty($search_company)) {
$search_company = $soc->name;
}
}

$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields

Expand Down Expand Up @@ -362,14 +371,14 @@
if ($search_ref) {
$sql .= natural_search('sp.ref', $search_ref);
}
if (empty($arrayfields['s.name_alias']['checked']) && $search_societe) {
$sql .= natural_search(array("s.nom", "s.name_alias"), $search_societe);
if (empty($arrayfields['s.name_alias']['checked']) && $search_company) {
$sql .= natural_search(array("s.nom", "s.name_alias"), $search_company);
} else {
if ($search_societe) {
$sql .= natural_search('s.nom', $search_societe);
if ($search_company) {
$sql .= natural_search('s.nom', $search_company);
}
if ($search_societe_alias) {
$sql .= natural_search('s.name_alias', $search_societe_alias);
if ($search_company_alias) {
$sql .= natural_search('s.name_alias', $search_company_alias);
}
}
if ($search_login) {
Expand Down Expand Up @@ -571,11 +580,11 @@
if ($search_ref) {
$param .= '&search_ref='.urlencode($search_ref);
}
if ($search_societe) {
$param .= '&search_societe='.urlencode($search_societe);
if ($search_company) {
$param .= '&search_company='.urlencode($search_company);
}
if ($search_societe_alias) {
$param .= '&search_societe_alias='.urlencode($search_societe_alias);
if ($search_company_alias) {
$param .= '&search_company_alias='.urlencode($search_company_alias);
}
if ($search_user > 0) {
$param .= '&search_user='.urlencode((string) ($search_user));
Expand Down Expand Up @@ -742,12 +751,12 @@
}
if (!empty($arrayfields['s.nom']['checked'])) {
print '<td class="liste_titre left">';
print '<input class="flat" type="text" size="12" name="search_societe" value="'.dol_escape_htmltag($search_societe).'">';
print '<input class="flat" type="text" size="12" name="search_company" value="'.dol_escape_htmltag($search_company).'">';
print '</td>';
}
if (!empty($arrayfields['s.name_alias']['checked'])) {
print '<td class="liste_titre left">';
print '<input class="flat" type="text" size="12" name="search_societe_alias" value="'.dol_escape_htmltag($search_societe_alias).'">';
print '<input class="flat" type="text" size="12" name="search_company_alias" value="'.dol_escape_htmltag($search_company_alias).'">';
print '</td>';
}
if (!empty($arrayfields['s.town']['checked'])) {
Expand Down
Loading