From 51837690fe20a92c7a3cde93ac366abc53e76ef0 Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Thu, 7 Apr 2022 01:10:29 +0100 Subject: [PATCH 1/9] Avoid duplicate 3rd partires --- htdocs/societe/card.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 45bbefabdab..b72f41e436a 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1291,8 +1291,10 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''.$form->editfieldkey('ThirdPartyName', 'name', '', $object, 0).''; } print 'global->SOCIETE_USEPREFIX) ? ' colspan="3"' : '').'>'; - print ''; - print $form->widgetForTranslation("name", $object, $permissiontoadd, 'string', 'alpahnohtml', 'minwidth300'); + //print ''; + //print $form->widgetForTranslation("name", $object, $permissiontoadd, 'string', 'alpahnohtml', 'minwidth300'); + print $form->select_company(0, 'name', '(s.client = 1 OR s.client = 3) AND status=1', ' '); + print ""; print ''; if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field print ''.$langs->trans('Prefix').''; From 5d9cfaa823e220ec9087f59b64daa90c534b183a Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Wed, 13 Apr 2022 01:09:44 +0100 Subject: [PATCH 2/9] Update card.php --- htdocs/societe/card.php | 86 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 84 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index b72f41e436a..e25d515ff7b 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1293,8 +1293,90 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print 'global->SOCIETE_USEPREFIX) ? ' colspan="3"' : '').'>'; //print ''; //print $form->widgetForTranslation("name", $object, $permissiontoadd, 'string', 'alpahnohtml', 'minwidth300'); - print $form->select_company(0, 'name', '(s.client = 1 OR s.client = 3) AND status=1', ' '); - print ""; + //print $form->select_company(0, 'name', '(s.client = 1 OR s.client = 3) AND status=1', ' '); + //print ""; + print ''; +?> + +'; if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field print ''.$langs->trans('Prefix').''; From 150a21820f5c0342c7082e604aeb8913921f4258 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 13 Apr 2022 00:14:23 +0000 Subject: [PATCH 3/9] Fixing style errors. --- htdocs/societe/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index e25d515ff7b..83c6975e3c7 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1296,7 +1296,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { //print $form->select_company(0, 'name', '(s.client = 1 OR s.client = 3) AND status=1', ' '); //print ""; print ''; -?> + ?> -'; if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field print ''.$langs->trans('Prefix').''; From 9c8d21c63aecd42b87801b8e3c3b2856d4884a9a Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Wed, 13 Apr 2022 01:14:36 +0100 Subject: [PATCH 4/9] Create ajaxcompanies.php --- htdocs/core/ajax/ajaxcompanies.php | 126 +++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 htdocs/core/ajax/ajaxcompanies.php diff --git a/htdocs/core/ajax/ajaxcompanies.php b/htdocs/core/ajax/ajaxcompanies.php new file mode 100644 index 00000000000..aeda242e53e --- /dev/null +++ b/htdocs/core/ajax/ajaxcompanies.php @@ -0,0 +1,126 @@ + + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2007-2010 Laurent Destailleur + * Copyright (C) 2010 Cyrille de Lambert + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/ajax/ajaxcompanies.php + * \brief File to return Ajax response on third parties request + */ + +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); + +require '../../main.inc.php'; + + +/* + * View + */ + +// Ajout directives pour resoudre bug IE +//header('Cache-Control: Public, must-revalidate'); +//header('Pragma: public'); + +//top_htmlhead("", "", 1); // Replaced with top_httphead. An ajax page does not need html header. +top_httphead(); + +//print ''."\n"; + +dol_syslog(join(',', $_GET)); + + +// Generation liste des societes +if (GETPOST('newcompany') || GETPOST('socid', 'int') || GETPOST('id_fourn')) +{ + $return_arr = array(); + + // Define filter on text typed + $socid = $_GET['newcompany'] ? $_GET['newcompany'] : ''; + if (!$socid) $socid = $_GET['socid'] ? $_GET['socid'] : ''; + if (!$socid) $socid = $_GET['id_fourn'] ? $_GET['id_fourn'] : ''; + + $sql = "SELECT s.rowid, s.nom, s.name_alias, s.code_client, s.code_fournisseur, s.address, s.zip, s.town, s.email, s.siren, s.siret, s.ape, s.idprof4, s.client, s.fournisseur, s.datec"; + $sql .= " , c.label as country, d.nom as departement"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d ON d.rowid = s.fk_departement"; + $sql .= " WHERE s.entity IN (".getEntity('societe').")"; + if ($socid) + { + $sql .= " AND ("; + // Add criteria on name/code + if (!empty($conf->global->COMPANY_DONOTSEARCH_ANYWHERE)) // Can use index + { + $sql .= "s.nom LIKE '".$db->escape($socid)."%'"; + $sql .= " OR s.code_client LIKE '".$db->escape($socid)."%'"; + $sql .= " OR s.code_fournisseur LIKE '".$db->escape($socid)."%'"; + } else { + $sql .= "s.nom LIKE '%".$db->escape($socid)."%'"; + $sql .= " OR s.code_client LIKE '%".$db->escape($socid)."%'"; + $sql .= " OR s.code_fournisseur LIKE '%".$db->escape($socid)."%'"; + } + if (!empty($conf->global->SOCIETE_ALLOW_SEARCH_ON_ROWID)) $sql .= " OR s.rowid = '".$db->escape($socid)."'"; + $sql .= ")"; + } + //if (GETPOST("filter")) $sql.= " AND (".GETPOST("filter", "alpha").")"; // Add other filters + $sql .= " ORDER BY s.nom ASC"; + + //dol_syslog("ajaxcompanies", LOG_DEBUG); + $resql = $db->query($sql); + + if ($resql) + { + while ($row = $db->fetch_array($resql)) + { + $label = $row['nom']; + if ($socid) $label = $label; + $row_array['label'] = $label; + $row_array['value'] = $row['nom']; + $row_array['key'] = $row['rowid']; + $row_array['name_alias'] = $row['name_alias']; + $row_array['code_client'] = $row['code_client']; + $row_array['code_fournisseur'] = $row['code_fournisseur']; + $row_array['address'] = $row['address']; + $row_array['zip'] = $row['zip']; + $row_array['town'] = $row['town']; + $row_array['email'] = $row['email']; + $row_array['siren'] = $row['siren']; + $row_array['siret'] = $row['siret']; + $row_array['ape'] = $row['ape']; + $row_array['idprof4'] = $row['idprof4']; + $row_array['client'] = $row['client']; + $row_array['fournisseur'] = $row['fournisseur']; + $row_array['datec'] = $row['datec']; + $row_array['country'] = $row['country']; + $row_array['departement'] = $row['departement']; + + array_push($return_arr, $row_array); + } + + echo json_encode($return_arr); + } else { + echo json_encode(array('nom'=>'Error', 'label'=>'Error', 'key'=>'Error', 'value'=>'Error')); + } +} else { + echo json_encode(array('nom'=>'ErrorBadParameter', 'label'=>'ErrorBadParameter', 'key'=>'ErrorBadParameter', 'value'=>'ErrorBadParameter')); +} From 02435a616b1250e018f5e4cce217443271faf68e Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 13 Apr 2022 00:19:15 +0000 Subject: [PATCH 5/9] Fixing style errors. --- htdocs/core/ajax/ajaxcompanies.php | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/htdocs/core/ajax/ajaxcompanies.php b/htdocs/core/ajax/ajaxcompanies.php index aeda242e53e..173d176c031 100644 --- a/htdocs/core/ajax/ajaxcompanies.php +++ b/htdocs/core/ajax/ajaxcompanies.php @@ -50,8 +50,7 @@ dol_syslog(join(',', $_GET)); // Generation liste des societes -if (GETPOST('newcompany') || GETPOST('socid', 'int') || GETPOST('id_fourn')) -{ +if (GETPOST('newcompany') || GETPOST('socid', 'int') || GETPOST('id_fourn')) { $return_arr = array(); // Define filter on text typed @@ -65,12 +64,10 @@ if (GETPOST('newcompany') || GETPOST('socid', 'int') || GETPOST('id_fourn')) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d ON d.rowid = s.fk_departement"; $sql .= " WHERE s.entity IN (".getEntity('societe').")"; - if ($socid) - { + if ($socid) { $sql .= " AND ("; // Add criteria on name/code - if (!empty($conf->global->COMPANY_DONOTSEARCH_ANYWHERE)) // Can use index - { + if (!empty($conf->global->COMPANY_DONOTSEARCH_ANYWHERE)) { // Can use index $sql .= "s.nom LIKE '".$db->escape($socid)."%'"; $sql .= " OR s.code_client LIKE '".$db->escape($socid)."%'"; $sql .= " OR s.code_fournisseur LIKE '".$db->escape($socid)."%'"; @@ -87,11 +84,9 @@ if (GETPOST('newcompany') || GETPOST('socid', 'int') || GETPOST('id_fourn')) //dol_syslog("ajaxcompanies", LOG_DEBUG); $resql = $db->query($sql); - - if ($resql) - { - while ($row = $db->fetch_array($resql)) - { + + if ($resql) { + while ($row = $db->fetch_array($resql)) { $label = $row['nom']; if ($socid) $label = $label; $row_array['label'] = $label; From b07096ad453a4066b4041a9610e53d78086b0eb7 Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Wed, 13 Apr 2022 17:07:23 +0100 Subject: [PATCH 6/9] Update ajaxcompanies.php Add logo --- htdocs/core/ajax/ajaxcompanies.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/ajax/ajaxcompanies.php b/htdocs/core/ajax/ajaxcompanies.php index 173d176c031..350f03398aa 100644 --- a/htdocs/core/ajax/ajaxcompanies.php +++ b/htdocs/core/ajax/ajaxcompanies.php @@ -58,7 +58,7 @@ if (GETPOST('newcompany') || GETPOST('socid', 'int') || GETPOST('id_fourn')) { if (!$socid) $socid = $_GET['socid'] ? $_GET['socid'] : ''; if (!$socid) $socid = $_GET['id_fourn'] ? $_GET['id_fourn'] : ''; - $sql = "SELECT s.rowid, s.nom, s.name_alias, s.code_client, s.code_fournisseur, s.address, s.zip, s.town, s.email, s.siren, s.siret, s.ape, s.idprof4, s.client, s.fournisseur, s.datec"; + $sql = "SELECT s.rowid, s.nom, s.name_alias, s.code_client, s.code_fournisseur, s.address, s.zip, s.town, s.email, s.siren, s.siret, s.ape, s.idprof4, s.client, s.fournisseur, s.datec, s.logo"; $sql .= " , c.label as country, d.nom as departement"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays"; @@ -106,6 +106,7 @@ if (GETPOST('newcompany') || GETPOST('socid', 'int') || GETPOST('id_fourn')) { $row_array['client'] = $row['client']; $row_array['fournisseur'] = $row['fournisseur']; $row_array['datec'] = $row['datec']; + $row_array['logo'] = $row['logo']; $row_array['country'] = $row['country']; $row_array['departement'] = $row['departement']; From 88a6b6535349314e7f5bbee259cab2a694f0b2e5 Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Wed, 13 Apr 2022 17:11:51 +0100 Subject: [PATCH 7/9] Update card.php Add logo --- htdocs/societe/card.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 83c6975e3c7..363d8e8d69d 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1301,7 +1301,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $(document).ready(function () { $('#name').select2({ ajax: { - url: '/htdocs/core/ajax/ajaxcompanies.php', + url: '/core/ajax/ajaxcompanies.php', dataType: 'json', delay: 250, data: function (params) { @@ -1330,13 +1330,22 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { function formatCustomer (Customer) { - if (Customer.loading) { + if(Customer.label === undefined) { return Customer.text; } + var logo = ''; + if(Customer.logo !== undefined) { + logo = "" + - "
" + - "
" + + "
" + logo + + "
" + "
" + "
" + "
" + From db96173189b72fb1c9a55ae260dfea2cb61ff196 Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Wed, 13 Apr 2022 18:00:24 +0100 Subject: [PATCH 8/9] Update card.php --- htdocs/societe/card.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 363d8e8d69d..03a8bf30fa1 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1340,7 +1340,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { logo += "/viewimage.php?modulepart=societe&entity=1&file=" + Customer.key + "%2Flogos%2Fthumbs%2F" + Customer.logo.replace('.', '_mini.') + "&cache=0"; logo += "' />
"; } else { - logo = '
'; + logo = '
'; } var $container = $("
" + @@ -1365,17 +1365,17 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { ); $container.find('.select2-result-repository__title').text(Customer.label); - $container.find('.select2-result-repository__name_alias').text(Customer.name_alias); - $container.find('.select2-result-repository__code_client').text(Customer.code_client); - $container.find('.select2-result-repository__code_fournisseur').text(Customer.code_fournisseur); - $container.find('.select2-result-repository__email').append('Mail: ' + Customer.email); - $container.find('.select2-result-repository__address').append('Address: ' + Customer.address); - $container.find('.select2-result-repository__country').append('Country: ' + Customer.country); - $container.find('.select2-result-repository__departement').append('Departement: ' + Customer.departement); - $container.find('.select2-result-repository__zip').append('Zip: ' + Customer.zip); - $container.find('.select2-result-repository__town').append('Town: ' + Customer.town); - $container.find('.select2-result-repository__siren').append('Siren: ' + Customer.siren); - $container.find('.select2-result-repository__datec').append('Created: ' + Customer.datec); + $container.find('.select2-result-repository__name_alias').text(Customer.name_alias ? Customer.name_alias : ''); + $container.find('.select2-result-repository__code_client').text(Customer.code_client ? Customer.code_client : ''); + $container.find('.select2-result-repository__code_fournisseur').text((Customer.code_fournisseur!==null) ? Customer.code_fournisseur : ''); + $container.find('.select2-result-repository__email').append('Mail: ' + (Customer.email !== null ? Customer.email : '')); + $container.find('.select2-result-repository__address').append('Address: ' + (Customer.address !== null ? Customer.address : '')); + $container.find('.select2-result-repository__country').append('Country: ' + (Customer.country !== null ? Customer.country : '')); + $container.find('.select2-result-repository__departement').append('Departement: ' + (Customer.departement !== null ? Customer.departement : '')); + $container.find('.select2-result-repository__zip').append('Zip: ' + (Customer.zip !== null ? Customer.zip : '')); + $container.find('.select2-result-repository__town').append('Town: ' + (Customer.town !== null ? Customer.town : '')); + $container.find('.select2-result-repository__siren').append('Siren: ' + (Customer.siren !== null ? Customer.siren : '')); + $container.find('.select2-result-repository__datec').append('Created: ' + (Customer.datec !== null ? Customer.datec : '')); return $container; } From fb2243dacde39ae8ebac2fa3f573d1f4de9b7c82 Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Thu, 14 Apr 2022 16:19:55 +0100 Subject: [PATCH 9/9] Update card.php --- htdocs/societe/card.php | 179 +++++++++++++++++++--------------------- 1 file changed, 87 insertions(+), 92 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 03a8bf30fa1..6ff756b6021 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1293,99 +1293,94 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print 'global->SOCIETE_USEPREFIX) ? ' colspan="3"' : '').'>'; //print ''; //print $form->widgetForTranslation("name", $object, $permissiontoadd, 'string', 'alpahnohtml', 'minwidth300'); - //print $form->select_company(0, 'name', '(s.client = 1 OR s.client = 3) AND status=1', ' '); - //print ""; - print ''; - ?> - - + '; print ''; if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field print ''.$langs->trans('Prefix').'';