From 5ef00d200fe83f98e57b7fd9fb990c7af75878fc Mon Sep 17 00:00:00 2001 From: Rui Strecht Date: Wed, 28 Feb 2018 12:26:05 +0000 Subject: [PATCH 1/5] Added idprof1 check to country PT --- htdocs/societe/class/societe.class.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index f5c0f004794..9cf14b4bc9d 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2876,6 +2876,29 @@ class Societe extends CommonObject return -4; } + //Verify NIF if country is PT + //Returns: 1 if NIF ok, -1 if NIF bad, 0 if unexpected bad + if ($idprof == 1 && $soc->country_code == 'PT') + { + $string=trim($this->idprof1); + $string=preg_replace('/(\s)/','',$string); + + for ($i = 0; $i < 9; $i ++) { + $num[$i] = substr($string, $i, 1); + } + + //Check NIF + if (preg_match('/(^[0-9]{9}$)/', $string)) { + return 1; + } + else { + return -1; + } + + //Wrong format + return 0; + } + return $ok; } From 9eb922826880c03a3632ab49059c7ebb60bdd7f4 Mon Sep 17 00:00:00 2001 From: Rui Strecht Date: Wed, 28 Feb 2018 12:51:29 +0000 Subject: [PATCH 2/5] Added idprof url for country PT --- htdocs/societe/class/societe.class.php | 35 ++++++++++++++++++-------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 9cf14b4bc9d..9aa872fb064 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2920,20 +2920,35 @@ class Societe extends CommonObject $hookmanager->initHooks(array('idprofurl')); $parameters=array('idprof'=>$idprof, 'company'=>$thirdparty); $reshook=$hookmanager->executeHooks('getIdProfUrl',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) - { - if (! empty($conf->global->MAIN_DISABLEPROFIDRULES)) return ''; + if (empty($reshook)) { + if (! empty($conf->global->MAIN_DISABLEPROFIDRULES)) { + return ''; + } // TODO Move links to validate professional ID into a dictionary table "country" + "link" - if ($idprof == 1 && $thirdparty->country_code == 'FR') $url='http://www.societe.com/cgi-bin/search?champs='.$thirdparty->idprof1; // See also http://avis-situation-sirene.insee.fr/ - //if ($idprof == 1 && ($thirdparty->country_code == 'GB' || $thirdparty->country_code == 'UK')) $url='http://www.companieshouse.gov.uk/WebCHeck/findinfolink/'; // Link no more valid - if ($idprof == 1 && $thirdparty->country_code == 'ES') $url='http://www.e-informa.es/servlet/app/portal/ENTP/screen/SProducto/prod/ETIQUETA_EMPRESA/nif/'.$thirdparty->idprof1; - if ($idprof == 1 && $thirdparty->country_code == 'IN') $url='http://www.tinxsys.com/TinxsysInternetWeb/dealerControllerServlet?tinNumber='.$thirdparty->idprof1.';&searchBy=TIN&backPage=searchByTin_Inter.jsp'; + if ($idprof == 1 && $thirdparty->country_code == 'FR') { + $url='http://www.societe.com/cgi-bin/search?champs='.$thirdparty->idprof1; // See also http://avis-situation-sirene.insee.fr/ + } + /* + if ($idprof == 1 && ($thirdparty->country_code == 'GB' || $thirdparty->country_code == 'UK')) { + $url='http://www.companieshouse.gov.uk/WebCHeck/findinfolink/'; // Link no more valid + } + */ + if ($idprof == 1 && $thirdparty->country_code == 'ES') { + $url='http://www.e-informa.es/servlet/app/portal/ENTP/screen/SProducto/prod/ETIQUETA_EMPRESA/nif/'.$thirdparty->idprof1; + } + if ($idprof == 1 && $thirdparty->country_code == 'IN') { + $url='http://www.tinxsys.com/TinxsysInternetWeb/dealerControllerServlet?tinNumber='.$thirdparty->idprof1.';&searchBy=TIN&backPage=searchByTin_Inter.jsp'; + } + if ($idprof == 1 && $thirdparty->country_code == 'PT') { + $url='http://www.nif.pt/'.$thirdparty->idprof1.'/'; + } - if ($url) return ''.$langs->trans("Check").''; + if ($url) { + return ''.$langs->trans("Check").''; + } } - else - { + else { return $hookmanager->resPrint; } From 97f7de9d3a24fa9bdb87c11b34754983dceb3e22 Mon Sep 17 00:00:00 2001 From: Rui Strecht Date: Wed, 28 Feb 2018 14:36:49 +0000 Subject: [PATCH 3/5] Fixed GB check url --- htdocs/societe/class/societe.class.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 9aa872fb064..48c35c7143e 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2929,11 +2929,9 @@ class Societe extends CommonObject if ($idprof == 1 && $thirdparty->country_code == 'FR') { $url='http://www.societe.com/cgi-bin/search?champs='.$thirdparty->idprof1; // See also http://avis-situation-sirene.insee.fr/ } - /* if ($idprof == 1 && ($thirdparty->country_code == 'GB' || $thirdparty->country_code == 'UK')) { - $url='http://www.companieshouse.gov.uk/WebCHeck/findinfolink/'; // Link no more valid + $url='https://beta.companieshouse.gov.uk/company/'.$thirdparty->idprof1; } - */ if ($idprof == 1 && $thirdparty->country_code == 'ES') { $url='http://www.e-informa.es/servlet/app/portal/ENTP/screen/SProducto/prod/ETIQUETA_EMPRESA/nif/'.$thirdparty->idprof1; } @@ -2941,7 +2939,7 @@ class Societe extends CommonObject $url='http://www.tinxsys.com/TinxsysInternetWeb/dealerControllerServlet?tinNumber='.$thirdparty->idprof1.';&searchBy=TIN&backPage=searchByTin_Inter.jsp'; } if ($idprof == 1 && $thirdparty->country_code == 'PT') { - $url='http://www.nif.pt/'.$thirdparty->idprof1.'/'; + $url='http://www.nif.pt/'.$thirdparty->idprof1; } if ($url) { From 09385574955c56268a1830164f8b87a8046fbd26 Mon Sep 17 00:00:00 2001 From: Rui Strecht Date: Wed, 28 Feb 2018 15:55:24 +0000 Subject: [PATCH 4/5] Added profid validation dictionnary tables --- .../mysql/data/llx_c_profid_validate.sql | 31 +++++++++++++++++++ .../tables/llx_c_profid_validate.key.sql | 21 +++++++++++++ .../mysql/tables/llx_c_profid_validate.sql | 29 +++++++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 htdocs/install/mysql/data/llx_c_profid_validate.sql create mode 100644 htdocs/install/mysql/tables/llx_c_profid_validate.key.sql create mode 100644 htdocs/install/mysql/tables/llx_c_profid_validate.sql diff --git a/htdocs/install/mysql/data/llx_c_profid_validate.sql b/htdocs/install/mysql/data/llx_c_profid_validate.sql new file mode 100644 index 00000000000..f9a92ff27e8 --- /dev/null +++ b/htdocs/install/mysql/data/llx_c_profid_validate.sql @@ -0,0 +1,31 @@ +-- Copyright (C) 2001-2004 Rodolphe Quiedeville +-- Copyright (C) 2003 Jean-Louis Bergamo +-- Copyright (C) 2004-2012 Laurent Destailleur +-- Copyright (C) 2004 Benoit Mortier +-- Copyright (C) 2004 Guillaume Delecourt +-- Copyright (C) 2005-2012 Regis Houssin +-- Copyright (C) 2007 Patrick Raguin +-- Copyright (C) 2011 Juanjo Menent +-- +-- 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 . + +-- +-- ProfId Validation URL (country code - profid number - validation url) +-- + +INSERT INTO llx_c_profid_validate ( country_code, profid_field_number, validation_url_prefix, validation_url_suffix, active ) VALUES ( 'FR', 1, 'http://www.societe.com/cgi-bin/search?champs=', '', 1); +INSERT INTO llx_c_profid_validate ( country_code, profid_field_number, validation_url_prefix, validation_url_suffix, active ) VALUES ( 'GB', 1, 'https://beta.companieshouse.gov.uk/company/', '', 1); +INSERT INTO llx_c_profid_validate ( country_code, profid_field_number, validation_url_prefix, validation_url_suffix, active ) VALUES ( 'ES', 1, 'http://www.e-informa.es/servlet/app/portal/ENTP/screen/SProducto/prod/ETIQUETA_EMPRESA/nif/', '', 1); +INSERT INTO llx_c_profid_validate ( country_code, profid_field_number, validation_url_prefix, validation_url_suffix, active ) VALUES ( 'IN', 1, 'http://www.tinxsys.com/TinxsysInternetWeb/dealerControllerServlet?tinNumber=', ';&searchBy=TIN&backPage=searchByTin_Inter.jsp', 1); +INSERT INTO llx_c_profid_validate ( country_code, profid_field_number, validation_url_prefix, validation_url_suffix, active ) VALUES ( 'PT', 1, 'http://www.nif.pt/', '', 1); diff --git a/htdocs/install/mysql/tables/llx_c_profid_validate.key.sql b/htdocs/install/mysql/tables/llx_c_profid_validate.key.sql new file mode 100644 index 00000000000..0aac3c7a3e8 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_c_profid_validate.key.sql @@ -0,0 +1,21 @@ +-- ======================================================================== +-- Copyright (C) 2005 Laurent Destailleur +-- Copyright (C) 2018 Rui Strecht +-- +-- 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 . +-- +-- ======================================================================== + + +ALTER TABLE llx_c_profid_validate ADD CONSTRAINT uk_profid_validate_fieldnumber_country UNIQUE (country_code, profid_field_number); diff --git a/htdocs/install/mysql/tables/llx_c_profid_validate.sql b/htdocs/install/mysql/tables/llx_c_profid_validate.sql new file mode 100644 index 00000000000..8ee14c03e5f --- /dev/null +++ b/htdocs/install/mysql/tables/llx_c_profid_validate.sql @@ -0,0 +1,29 @@ +-- ======================================================================== +-- Copyright (C) 2005 Laurent Destailleur +-- Copyright (C) 2018 Rui Strecht +-- +-- 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 . +-- +-- ======================================================================== + +create table llx_c_profid_validate +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + country_code varchar(2) NOT NULL, + profid_field_number int(1) DEFAULT 1 NOT NULL, + validation_url_prefix varchar(255) DEFAULT NOT NULL, + validation_url_suffix varchar(255) DEFAULT NULL, + active tinyint DEFAULT 1 NOT NULL +)ENGINE=innodb; + From 3b268b143635366ce8cdbc0324938fa9ca2c2be5 Mon Sep 17 00:00:00 2001 From: Rui Strecht Date: Wed, 28 Feb 2018 16:27:56 +0000 Subject: [PATCH 5/5] Revert "Added profid validation dictionnary tables" This reverts commit 09385574955c56268a1830164f8b87a8046fbd26. --- .../mysql/data/llx_c_profid_validate.sql | 31 ------------------- .../tables/llx_c_profid_validate.key.sql | 21 ------------- .../mysql/tables/llx_c_profid_validate.sql | 29 ----------------- 3 files changed, 81 deletions(-) delete mode 100644 htdocs/install/mysql/data/llx_c_profid_validate.sql delete mode 100644 htdocs/install/mysql/tables/llx_c_profid_validate.key.sql delete mode 100644 htdocs/install/mysql/tables/llx_c_profid_validate.sql diff --git a/htdocs/install/mysql/data/llx_c_profid_validate.sql b/htdocs/install/mysql/data/llx_c_profid_validate.sql deleted file mode 100644 index f9a92ff27e8..00000000000 --- a/htdocs/install/mysql/data/llx_c_profid_validate.sql +++ /dev/null @@ -1,31 +0,0 @@ --- Copyright (C) 2001-2004 Rodolphe Quiedeville --- Copyright (C) 2003 Jean-Louis Bergamo --- Copyright (C) 2004-2012 Laurent Destailleur --- Copyright (C) 2004 Benoit Mortier --- Copyright (C) 2004 Guillaume Delecourt --- Copyright (C) 2005-2012 Regis Houssin --- Copyright (C) 2007 Patrick Raguin --- Copyright (C) 2011 Juanjo Menent --- --- 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 . - --- --- ProfId Validation URL (country code - profid number - validation url) --- - -INSERT INTO llx_c_profid_validate ( country_code, profid_field_number, validation_url_prefix, validation_url_suffix, active ) VALUES ( 'FR', 1, 'http://www.societe.com/cgi-bin/search?champs=', '', 1); -INSERT INTO llx_c_profid_validate ( country_code, profid_field_number, validation_url_prefix, validation_url_suffix, active ) VALUES ( 'GB', 1, 'https://beta.companieshouse.gov.uk/company/', '', 1); -INSERT INTO llx_c_profid_validate ( country_code, profid_field_number, validation_url_prefix, validation_url_suffix, active ) VALUES ( 'ES', 1, 'http://www.e-informa.es/servlet/app/portal/ENTP/screen/SProducto/prod/ETIQUETA_EMPRESA/nif/', '', 1); -INSERT INTO llx_c_profid_validate ( country_code, profid_field_number, validation_url_prefix, validation_url_suffix, active ) VALUES ( 'IN', 1, 'http://www.tinxsys.com/TinxsysInternetWeb/dealerControllerServlet?tinNumber=', ';&searchBy=TIN&backPage=searchByTin_Inter.jsp', 1); -INSERT INTO llx_c_profid_validate ( country_code, profid_field_number, validation_url_prefix, validation_url_suffix, active ) VALUES ( 'PT', 1, 'http://www.nif.pt/', '', 1); diff --git a/htdocs/install/mysql/tables/llx_c_profid_validate.key.sql b/htdocs/install/mysql/tables/llx_c_profid_validate.key.sql deleted file mode 100644 index 0aac3c7a3e8..00000000000 --- a/htdocs/install/mysql/tables/llx_c_profid_validate.key.sql +++ /dev/null @@ -1,21 +0,0 @@ --- ======================================================================== --- Copyright (C) 2005 Laurent Destailleur --- Copyright (C) 2018 Rui Strecht --- --- 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 . --- --- ======================================================================== - - -ALTER TABLE llx_c_profid_validate ADD CONSTRAINT uk_profid_validate_fieldnumber_country UNIQUE (country_code, profid_field_number); diff --git a/htdocs/install/mysql/tables/llx_c_profid_validate.sql b/htdocs/install/mysql/tables/llx_c_profid_validate.sql deleted file mode 100644 index 8ee14c03e5f..00000000000 --- a/htdocs/install/mysql/tables/llx_c_profid_validate.sql +++ /dev/null @@ -1,29 +0,0 @@ --- ======================================================================== --- Copyright (C) 2005 Laurent Destailleur --- Copyright (C) 2018 Rui Strecht --- --- 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 . --- --- ======================================================================== - -create table llx_c_profid_validate -( - rowid integer AUTO_INCREMENT PRIMARY KEY, - country_code varchar(2) NOT NULL, - profid_field_number int(1) DEFAULT 1 NOT NULL, - validation_url_prefix varchar(255) DEFAULT NOT NULL, - validation_url_suffix varchar(255) DEFAULT NULL, - active tinyint DEFAULT 1 NOT NULL -)ENGINE=innodb; -