Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2022-08-31 17:57:40 +02:00
commit 57bcc2177a
5 changed files with 51 additions and 41 deletions

View File

@ -29,6 +29,8 @@
* \brief Card of a contact
*/
// Load Dolibarr environment
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
@ -49,12 +51,14 @@ $langs->loadLangs(array('companies', 'users', 'other', 'commercial'));
$mesg = ''; $error = 0; $errors = array();
// Get parameters
$action = (GETPOST('action', 'alpha') ? GETPOST('action', 'alpha') : 'view');
$confirm = GETPOST('confirm', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
$id = GETPOST('id', 'int');
$socid = GETPOST('socid', 'int');
// Initialize objects
$object = new Contact($db);
$extrafields = new ExtraFields($db);

View File

@ -23,6 +23,8 @@
* \brief Onglet info d'un contact
*/
// Load Dolibarr environment
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';

View File

@ -498,3 +498,5 @@ RestOfEurope=Rest of Europe (EEC)
OutOfEurope=Out of Europe (EEC)
CurrentOutstandingBillLate=Current outstanding bill late
BecarefullChangeThirdpartyBeforeAddProductToInvoice=Be carefull, depending on your product price settings, you should change thirdparty before adding product to POS.
EmailAlreadyExistsPleaseRewriteYourCompanyName=email already exists please rewrite your company name
TwoRecordsOfCompanyName=more than one record exists for this company please contact us to complete your partnership request"

View File

@ -28,6 +28,7 @@ PartnershipCheckBacklink=Partnership: Check referring backlink
# Menu
#
NewPartnership=New Partnership
NewPartnershipbyWeb= Your partnership was added successfully.
ListOfPartnerships=List of partnership
#

View File

@ -67,7 +67,7 @@ $backtopage = GETPOST('backtopage', 'alpha');
$action = GETPOST('action', 'aZ09');
// Load translation files
$langs->loadLangs(array("main", "members", "companies", "install", "other"));
$langs->loadLangs(array("main", "members", "partnership", "companies", "install", "other"));
// Security check
if (empty($conf->partnership->enabled)) {
@ -178,10 +178,10 @@ if (empty($reshook) && $action == 'add') {
$db->begin();
/*if (GETPOST('typeid') <= 0) {
if (GETPOST('partnershiptype', 'int') <= 0) {
$error++;
$errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type"))."<br>\n";
}*/
}
if (!GETPOST('societe')) {
$error++;
$errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("societe"))."<br>\n";
@ -208,7 +208,6 @@ if (empty($reshook) && $action == 'add') {
if (!$error) {
$partnership = new Partnership($db);
$partnershipt = new PartnershipType($db);
// We try to find the thirdparty or the member
if (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR', 'thirdparty') == 'thirdparty') {
@ -217,47 +216,27 @@ if (empty($reshook) && $action == 'add') {
$partnership->fk_soc = 0;
}
$partnership->status = 0;
$partnership->note_private = GETPOST('note_private');
$partnership->date_creation = dol_now();
$partnership->status = 0;
$partnership->note_private = GETPOST('note_private');
$partnership->date_creation = dol_now();
$partnership->date_partnership_start = dol_now();
$partnership->fk_user_creat = 0;
/*$partnershipt->fetch(0, 'default');
if ($partnershipt->id > 0) {
$partnership->fk_type = $partnershipt->id;
}*/
$partnership->fk_type = GETPOST('partnershiptype', 'int');
//$partnership->firstname = GETPOST('firstname');
//$partnership->lastname = GETPOST('lastname');
//$partnership->address = GETPOST('address');
//$partnership->zip = GETPOST('zipcode');
//$partnership->town = GETPOST('town');
//$partnership->email = GETPOST('email');
//$partnership->country_id = GETPOST('country_id', 'int');
//$partnership->state_id = GETPOST('state_id', 'int');
//$partnership->typeid = $conf->global->PARTNERSHIP_NEWFORM_FORCETYPE ? $conf->global->PARTNERSHIP_NEWFORM_FORCETYPE : GETPOST('typeid', 'int');
$partnership->fk_user_creat = 0;
$partnership->fk_type = GETPOST('partnershiptype', 'int');
//$partnership->typeid = $conf->global->PARTNERSHIP_NEWFORM_FORCETYPE ? $conf->global->PARTNERSHIP_NEWFORM_FORCETYPE : GETPOST('typeid', 'int');
// test if societe already exist
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe WHERE nom='".$db->escape(GETPOST('societe'))."'";
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows($result);
}
if ($num = 0) { // si il ya pas d'entree sur le nom on teste l'email
$sql1 = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe WHERE email='".$db->escape(GETPOST('email'))."'";
$result1 = $db->query($sql1);
if ($result1) {
$num1 = $db->num_rows($result1);
}
if ($num1 != 0) {
$company = new Societe($db);
$result = $company->fetch(0, GETPOST('societe'));
if ($result == 0) { // si il ya pas d'entree sur le nom on teste l'email
$result1 = $company->fetch(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, GETPOST('email'));
if ($result1 > 0) {
$error++;
$errmsg = "email already exists please rewrite your company name";
$errmsg = $langs->trans("EmailAlreadyExistsPleaseRewriteYourCompanyName");
} else {
//create thirdparty
$company = new Societe($db);
$company->name = GETPOST('societe');
$company->address = GETPOST('address');
$company->zip = GETPOST('zipcode');
$company->town = GETPOST('town');
@ -274,12 +253,34 @@ if (empty($reshook) && $action == 'add') {
$partnership->fk_soc = $company->id;
}
} elseif ($num > 1) {
} elseif ($result == -2) {
$error++;
$errmsg = 'more than one entry exist for this company please contact us to complete your partnership request';
$errmsg = $langs->trans("TwoRecordsOfCompanyName");
} else {
$company = $db->fetch_object($result);
$partnership->fk_soc = $company->rowid;
$partnership->fk_soc = $company->id;
// update thirdparty fields
if (empty($company->address)) {
$company->address = GETPOST('address');
}
if (empty($company->zip)) {
$company->zip = GETPOST('zipcode');
}
if (empty($company->town)) {
$company->town = GETPOST('town');
}
if (empty($company->country_id)) {
$company->country_id = GETPOST('country_id', 'int');
}
if (empty($company->email)) {
$company->email = GETPOST('email');
}
if (empty($company->state_id)) {
$company->state_id = GETPOST('state_id', 'int');
}
if (empty($company->name_alias)) {
$company->name_alias = dolGetFirstLastname(GETPOST('firstname'), GETPOST('lastname'));
}
$company->update(0);
}
// Fill array 'array_options' with data from add form