search by name or email

This commit is contained in:
Frédéric FRANCE 2021-06-06 10:32:04 +02:00
parent 3c51eac66f
commit efb5ec2901
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1
2 changed files with 18 additions and 2 deletions

View File

@ -19,6 +19,12 @@ module.exports = {
type: 'string', type: 'string',
label: 'Name', label: 'Name',
helpText: 'Name to limit to the search to (i.e. The company or %company%).' helpText: 'Name to limit to the search to (i.e. The company or %company%).'
},
{
key: 'email',
type: 'string',
label: 'Email',
helpText: 'Email to limit to the search to.'
} }
], ],
@ -32,12 +38,22 @@ module.exports = {
sqlfilters: "t.nom like \'%"+bundle.inputData.name+"%\'" sqlfilters: "t.nom like \'%"+bundle.inputData.name+"%\'"
} }
}; };
let filter = '';
if (bundle.inputData.name) {
filter = "t.nom like \'%"+bundle.inputData.name+"%\'";
}
if (bundle.inputData.email) {
if (bundle.inputData.name) {
filter += " and ";
}
filter += "t.email like \'"+bundle.inputData.email+"\'";
}
const response = await z.request({ const response = await z.request({
url: url, url: url,
// this parameter avoid throwing errors and let us manage them // this parameter avoid throwing errors and let us manage them
skipThrowForStatus: true, skipThrowForStatus: true,
params: { params: {
sqlfilters: "t.nom like \'%"+bundle.inputData.name+"%\'" sqlfilters: filter
} }
}); });
//z.console.log(response); //z.console.log(response);

View File

@ -1043,7 +1043,7 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $
$regType = array(); $regType = array();
if (preg_match('/\{(t+)\}/i', $mask, $regType)) { if (preg_match('/\{(t+)\}/i', $mask, $regType)) {
$masktype = $regType[1]; $masktype = $regType[1];
$masktype_value = substr(preg_replace('/^TE_/', '', $objsoc->typent_code), 0, dol_strlen($regType[1])); // get n first characters of thirdpaty typent_code (where n is length in mask) $masktype_value = substr(preg_replace('/^TE_/', '', $objsoc->typent_code), 0, dol_strlen($regType[1])); // get n first characters of thirdparty typent_code (where n is length in mask)
$masktype_value = str_pad($masktype_value, dol_strlen($regType[1]), "#", STR_PAD_RIGHT); // we fill on right with # to have same number of char than into mask $masktype_value = str_pad($masktype_value, dol_strlen($regType[1]), "#", STR_PAD_RIGHT); // we fill on right with # to have same number of char than into mask
} else { } else {
$masktype = ''; $masktype = '';