diff --git a/htdocs/admin/subcontractors.php b/htdocs/admin/subcontractors.php index d6f6b13af05..b8a7aa18d83 100644 --- a/htdocs/admin/subcontractors.php +++ b/htdocs/admin/subcontractors.php @@ -62,38 +62,74 @@ if ($reshook < 0) { } if (($action == 'update' && !GETPOST("cancel", 'alpha')) || ($action == 'updateedit')) { - dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_NAME", GETPOST("nom", 'alphanohtml'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_ADDRESS", GETPOST("address", 'alphanohtml'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_TOWN", GETPOST("town", 'alphanohtml'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_ZIP", GETPOST("zipcode", 'alphanohtml'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_STATE", GETPOSTINT("state_id"), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_REGION", GETPOST("region_code", 'alphanohtml'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_COUNTRY", GETPOSTINT('country_id'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_PHONE", GETPOST("phone", 'alphanohtml'), 'chaine', 0, '', $conf->entity); - //dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_FAX", GETPOST("fax", 'alphanohtml'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_MAIL", GETPOST("mail", 'alphanohtml'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_WEB", GETPOST("web", 'alphanohtml'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_IDPROF1", GETPOST("idprof1", 'alphanohtml'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_CODE", GETPOST("code", 'alphanohtml'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_NOTE", GETPOST("note", 'restricthtml'), 'chaine', 0, '', $conf->entity); + $error = 0; - dolibarr_set_const($db, "MAIN_INFO_ITPROVIDER_NAME", GETPOST("itprovider_nom", 'alphanohtml'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_ITPROVIDER_ADDRESS", GETPOST("itprovider_address", 'alphanohtml'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_ITPROVIDER_TOWN", GETPOST("itprovider_town", 'alphanohtml'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_ITPROVIDER_ZIP", GETPOST("itprovider_zipcode", 'alphanohtml'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_ITPROVIDER_STATE", GETPOSTINT("itprovider_state_id"), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_ITPROVIDER_REGION", GETPOST("itprovider_region_code", 'alphanohtml'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_ITPROVIDER_COUNTRY", GETPOSTINT('itprovider_country_id'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_ITPROVIDER_PHONE", GETPOST("itprovider_phone", 'alphanohtml'), 'chaine', 0, '', $conf->entity); - //dolibarr_set_const($db, "MAIN_INFO_ITPROVIDER_FAX", GETPOST("itprovider_fax", 'alphanohtml'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_ITPROVIDER_MAIL", GETPOST("itprovider_mail", 'alphanohtml'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_ITPROVIDER_WEB", GETPOST("itprovider_web", 'alphanohtml'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_ITPROVIDER_IDPROF1", GETPOST("itprovider_idprof1", 'alphanohtml'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_ITPROVIDER_CODE", GETPOST("itprovider_code", 'alphanohtml'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_ITPROVIDER_NOTE", GETPOST("itprovider_note", 'restricthtml'), 'chaine', 0, '', $conf->entity); + // Test the idprof1 and 2 of accountant + // Not required - if ($action != 'updateedit') { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + // Test the idprof1 and 2 of IT supplier + $country_code_itprovider_array = getCountry(GETPOSTINT('itprovider_country_id'), 'all', $db, $langs, 0); + $country_code_itprovider = $country_code_itprovider_array['code']; + $tmpthirdparty = new Societe($db); + $tmpthirdparty->country_code = $country_code_itprovider; + $tmpthirdparty->country_id = getCountry($country_code_itprovider, '3', $db, $langs, 0); + $tmpthirdparty->idprof1 = GETPOST("itprovider_idprof1"); + $tmpthirdparty->idprof2 = GETPOST("itprovider_idprof2"); + + if ($mysoc->country_code == 'FR') { + if (empty($tmpthirdparty->country_code)) { + $langs->loadLangs(array("errors", "companies")); + setEventMessages($langs->trans("ErrorBadValueForParameter", $tmpthirdparty->country_code, $langs->trans("Country")), null, 'errors'); + $error++; + } + if ($tmpthirdparty->idprof1 && isValidProfIds(1, $tmpthirdparty) <= 0) { + $langs->loadLangs(array("errors", "companies")); + setEventMessages($langs->trans("ErrorBadValueForParameter", $tmpthirdparty->idprof1, $langs->transcountry("ProfId1Short", $tmpthirdparty->country_code)), null, 'errors'); + $error++; + } + if ($tmpthirdparty->idprof2 && isValidProfIds(2, $tmpthirdparty) <= 0) { + $langs->loadLangs(array("errors", "companies")); + setEventMessages($langs->trans("ErrorBadValueForParameter", $tmpthirdparty->idprof2, $langs->transcountry("ProfId2Short", $tmpthirdparty->country_code)), null, 'errors'); + $error++; + } + } + + if (!$error) { + dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_NAME", GETPOST("nom", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_ADDRESS", GETPOST("address", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_TOWN", GETPOST("town", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_ZIP", GETPOST("zipcode", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_STATE", GETPOSTINT("state_id"), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_REGION", GETPOST("region_code", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_COUNTRY", GETPOSTINT('country_id'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_PHONE", GETPOST("phone", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + //dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_FAX", GETPOST("fax", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_MAIL", GETPOST("mail", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_WEB", GETPOST("web", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_IDPROF1", GETPOST("idprof1", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_IDPROF2", GETPOST("idprof2", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_CODE", GETPOST("code", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_NOTE", GETPOST("note", 'restricthtml'), 'chaine', 0, '', $conf->entity); + + dolibarr_set_const($db, "MAIN_INFO_ITPROVIDER_NAME", GETPOST("itprovider_nom", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ITPROVIDER_ADDRESS", GETPOST("itprovider_address", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ITPROVIDER_TOWN", GETPOST("itprovider_town", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ITPROVIDER_ZIP", GETPOST("itprovider_zipcode", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ITPROVIDER_STATE", GETPOSTINT("itprovider_state_id"), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ITPROVIDER_REGION", GETPOST("itprovider_region_code", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ITPROVIDER_COUNTRY", GETPOSTINT('itprovider_country_id'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ITPROVIDER_PHONE", GETPOST("itprovider_phone", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + //dolibarr_set_const($db, "MAIN_INFO_ITPROVIDER_FAX", GETPOST("itprovider_fax", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ITPROVIDER_MAIL", GETPOST("itprovider_mail", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ITPROVIDER_WEB", GETPOST("itprovider_web", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ITPROVIDER_IDPROF1", GETPOST("itprovider_idprof1", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ITPROVIDER_IDPROF2", GETPOST("itprovider_idprof2", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ITPROVIDER_CODE", GETPOST("itprovider_code", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_ITPROVIDER_NOTE", GETPOST("itprovider_note", 'restricthtml'), 'chaine', 0, '', $conf->entity); + + if ($action != 'updateedit') { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } } } @@ -207,11 +243,15 @@ print img_picto('', 'globe', '', 0, 0, 0, '', 'pictofixedwidth'); print ''; print ''."\n"; -// Id prof +// Id prof 1 print ''; print ''."\n"; -// Code +// Id prof 2 +print ''; +print ''."\n"; + +// Accountancy code print ''; print ''."\n"; @@ -291,11 +331,15 @@ print img_picto('', 'globe', '', 0, 0, 0, '', 'pictofixedwidth'); print ''; print ''."\n"; -// Code +// Prof ID 1 print ''; print ''."\n"; -// Code +// Prof ID 2 +print ''; +print ''."\n"; + +// Accountancy code print ''; print ''."\n"; diff --git a/htdocs/blockedlog/admin/registration.php b/htdocs/blockedlog/admin/registration.php index 8f0ddc083a8..e04ed4192d1 100644 --- a/htdocs/blockedlog/admin/registration.php +++ b/htdocs/blockedlog/admin/registration.php @@ -123,6 +123,11 @@ if ($action == 'update') { setEventMessages($langs->trans("ErrorBadValueForParameter", $tmpthirdparty->idprof1, $langs->transcountry("ProfId1Short", $tmpthirdparty->country_code)), null, 'errors'); $error++; } + if ($tmpthirdparty->idprof2 && isValidProfIds(2, $tmpthirdparty) <= 0) { + $langs->loadLangs(array("errors", "companies")); + setEventMessages($langs->trans("ErrorBadValueForParameter", $tmpthirdparty->idprof2, $langs->transcountry("ProfId2Short", $tmpthirdparty->country_code)), null, 'errors'); + $error++; + } $company_name = GETPOST("BLOCKEDLOG_REGISTRATION_NAME"); $company_email = GETPOST("BLOCKEDLOG_REGISTRATION_EMAIL"); @@ -138,6 +143,7 @@ if ($action == 'update') { $provider_email = GETPOST("MAIN_INFO_ITPROVIDER_MAIL"); $provider_country_id = GETPOST("MAIN_INFO_ITPROVIDER_COUNTRY"); $provider_idprof1 = GETPOST("MAIN_INFO_ITPROVIDER_IDPROF1"); + $provider_idprof2 = GETPOST("MAIN_INFO_ITPROVIDER_IDPROF2"); $provider_address = GETPOST("MAIN_INFO_ITPROVIDER_ADDRESS"); $provider_state = GETPOST("MAIN_INFO_ITPROVIDER_STATE"); $provider_zip = GETPOST("MAIN_INFO_ITPROVIDER_ZIP"); @@ -199,6 +205,10 @@ if ($action == 'update') { if ($res <= 0) { $error++; } + $res = dolibarr_set_const($db, "MAIN_INFO_ITPROVIDER_IDPROF2", $provider_idprof1, 'chaine', 0, '', $conf->entity); + if ($res <= 0) { + $error++; + } $res = dolibarr_set_const($db, "MAIN_INFO_ITPROVIDER_ADDRESS", $provider_address, 'chaine', 0, '', $conf->entity); if ($res <= 0) { $error++; @@ -388,7 +398,8 @@ if ($mode == "forceregistration") { 'provider_zip' => getDolGlobalString('MAIN_INFO_ITPROVIDER_ZIP'), 'provider_town' => getDolGlobalString('MAIN_INFO_ITPROVIDER_TOWN'), 'provider_country' => getDolGlobalString('MAIN_INFO_ITPROVIDER_COUNTRY'), - 'provider_idprof1' => getDolGlobalString('MAIN_INFO_ITPROVIDER_IDPROF1') + 'provider_idprof1' => getDolGlobalString('MAIN_INFO_ITPROVIDER_IDPROF1'), + 'provider_idprof2' => getDolGlobalString('MAIN_INFO_ITPROVIDER_IDPROF2') ); // Output js code to register data. @@ -501,6 +512,10 @@ if (empty($mode)) { $item = $formSetup->newItem('MAIN_INFO_ITPROVIDER_IDPROF1'); $item->defaultFieldValue = getDolGlobalString('MAIN_INFO_ITPROVIDER_IDPROF1'); + //IT provider IDPROF1 + $item = $formSetup->newItem('MAIN_INFO_ITPROVIDER_IDPROF2'); + $item->defaultFieldValue = getDolGlobalString('MAIN_INFO_ITPROVIDER_IDPROF2'); + //IT provider country code $item = $formSetup->newItem('MAIN_INFO_ITPROVIDER_COUNTRY'); $item->defaultFieldValue = getDolGlobalString('MAIN_INFO_ITPROVIDER_COUNTRY'); diff --git a/htdocs/langs/en_US/blockedlog.lang b/htdocs/langs/en_US/blockedlog.lang index 81ed624830c..c875d84fc24 100644 --- a/htdocs/langs/en_US/blockedlog.lang +++ b/htdocs/langs/en_US/blockedlog.lang @@ -89,6 +89,7 @@ MAIN_INFO_ITPROVIDER_NAME=IT supplier name MAIN_INFO_ITPROVIDER_MAIL=IT supplier email MAIN_INFO_ITPROVIDER_COUNTRY=IT supplier country MAIN_INFO_ITPROVIDER_IDPROF1=IT supplier Prof Id 1 (SIREN) +MAIN_INFO_ITPROVIDER_IDPROF2=IT supplier Prof Id 2 (SIRET) MAIN_INFO_ITPROVIDER_ADDRESS=IT supplier address MAIN_INFO_ITPROVIDER_STATE=IT supplier state/province MAIN_INFO_ITPROVIDER_ZIP=IT supplier zip diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index a9e161d34d0..cb5ac39d3aa 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -3979,7 +3979,8 @@ if (!function_exists("llxFooter")) { 'provider_zip' => getDolGlobalString('MAIN_INFO_ITPROVIDER_ZIP'), 'provider_town' => getDolGlobalString('MAIN_INFO_ITPROVIDER_TOWN'), 'provider_country' => getDolGlobalString('MAIN_INFO_ITPROVIDER_COUNTRY'), - 'provider_idprof1' => getDolGlobalString('MAIN_INFO_ITPROVIDER_IDPROF1') + 'provider_idprof1' => getDolGlobalString('MAIN_INFO_ITPROVIDER_IDPROF1'), + 'provider_idprof2' => getDolGlobalString('MAIN_INFO_ITPROVIDER_IDPROF2') ); printCodeForPing($constanttosavelastko, $constanttosavefirstok, $arrayofdata, $forceregistration); } else {