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 * \brief Card of a contact
*/ */
// Load Dolibarr environment
require '../main.inc.php'; require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.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(); $mesg = ''; $error = 0; $errors = array();
// Get parameters
$action = (GETPOST('action', 'alpha') ? GETPOST('action', 'alpha') : 'view'); $action = (GETPOST('action', 'alpha') ? GETPOST('action', 'alpha') : 'view');
$confirm = GETPOST('confirm', 'alpha'); $confirm = GETPOST('confirm', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha');
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
$socid = GETPOST('socid', 'int'); $socid = GETPOST('socid', 'int');
// Initialize objects
$object = new Contact($db); $object = new Contact($db);
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);

View File

@ -23,6 +23,8 @@
* \brief Onglet info d'un contact * \brief Onglet info d'un contact
*/ */
// Load Dolibarr environment
require '../main.inc.php'; require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.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) OutOfEurope=Out of Europe (EEC)
CurrentOutstandingBillLate=Current outstanding bill late CurrentOutstandingBillLate=Current outstanding bill late
BecarefullChangeThirdpartyBeforeAddProductToInvoice=Be carefull, depending on your product price settings, you should change thirdparty before adding product to POS. 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 # Menu
# #
NewPartnership=New Partnership NewPartnership=New Partnership
NewPartnershipbyWeb= Your partnership was added successfully.
ListOfPartnerships=List of partnership ListOfPartnerships=List of partnership
# #

View File

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