Merge pull request #21809 from badre-agtaib/partnership
public partnership request
This commit is contained in:
commit
d3701eae9e
@ -182,6 +182,10 @@ if (empty($reshook) && $action == 'add') {
|
|||||||
$error++;
|
$error++;
|
||||||
$errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type"))."<br>\n";
|
$errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type"))."<br>\n";
|
||||||
}*/
|
}*/
|
||||||
|
if (!GETPOST('societe')) {
|
||||||
|
$error++;
|
||||||
|
$errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("societe"))."<br>\n";
|
||||||
|
}
|
||||||
if (!GETPOST('lastname')) {
|
if (!GETPOST('lastname')) {
|
||||||
$error++;
|
$error++;
|
||||||
$errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Lastname"))."<br>\n";
|
$errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Lastname"))."<br>\n";
|
||||||
@ -190,6 +194,7 @@ if (empty($reshook) && $action == 'add') {
|
|||||||
$error++;
|
$error++;
|
||||||
$errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Firstname"))."<br>\n";
|
$errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Firstname"))."<br>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty(GETPOST('email'))) {
|
if (empty(GETPOST('email'))) {
|
||||||
$error++;
|
$error++;
|
||||||
$errmsg .= $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Email'))."<br>\n";
|
$errmsg .= $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Email'))."<br>\n";
|
||||||
@ -203,6 +208,7 @@ 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') {
|
||||||
@ -211,17 +217,70 @@ if (empty($reshook) && $action == 'add') {
|
|||||||
$partnership->fk_soc = 0;
|
$partnership->fk_soc = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$partnership->statut = -1;
|
$partnership->status = 0;
|
||||||
$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->note_private = GETPOST('note_private');
|
$partnership->note_private = GETPOST('note_private');
|
||||||
|
$partnership->date_creation = dol_now();
|
||||||
|
$partnership->date_partnership_start = dol_now();
|
||||||
|
$partnership->fk_user_creat=$user->id;
|
||||||
|
|
||||||
|
$partnershipt->fetch(0, 'default');
|
||||||
|
if ($partnershipt->id > 0) {
|
||||||
|
$partnership->fk_type = $partnershipt->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//$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
|
||||||
|
$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) {
|
||||||
|
$error++;
|
||||||
|
$errmsg = "email already exists please rewrite your company name";
|
||||||
|
} else {
|
||||||
|
//create thirdparty
|
||||||
|
$company = new Societe($db);
|
||||||
|
|
||||||
|
$company->address = GETPOST('address');
|
||||||
|
$company->zip = GETPOST('zipcode');
|
||||||
|
$company->town = GETPOST('town');
|
||||||
|
$company->email = GETPOST('email');
|
||||||
|
$company->country_id = GETPOST('country_id', 'int');
|
||||||
|
$company->state_id = GETPOST('state_id', 'int');
|
||||||
|
$company->name_alias = dolGetFirstLastname(GETPOST('firstname'), GETPOST('lastname'));
|
||||||
|
|
||||||
|
$resultat=$company->create($user);
|
||||||
|
if ($resultat < 0) {
|
||||||
|
$error++;
|
||||||
|
$errmsg .= join('<br>', $company->errors);
|
||||||
|
}
|
||||||
|
|
||||||
|
$partnership->fk_soc = $company->id;
|
||||||
|
}
|
||||||
|
} elseif ($num > 1) {
|
||||||
|
$error++;
|
||||||
|
$errmsg = 'more than one entry exist for this company please contact us to complete your partnership request';
|
||||||
|
} else {
|
||||||
|
$company = $db->fetch_object($result);
|
||||||
|
$partnership->fk_soc = $company->rowid;
|
||||||
|
}
|
||||||
|
|
||||||
// Fill array 'array_options' with data from add form
|
// Fill array 'array_options' with data from add form
|
||||||
$extrafields->fetch_name_optionals_label($partnership->table_element);
|
$extrafields->fetch_name_optionals_label($partnership->table_element);
|
||||||
@ -230,12 +289,14 @@ if (empty($reshook) && $action == 'add') {
|
|||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$error) {
|
||||||
$result = $partnership->create($user);
|
$result = $partnership->create($user);
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
|
/*
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
|
||||||
$object = $partnership;
|
$object = $partnership;
|
||||||
|
|
||||||
/*
|
|
||||||
$partnershipt = new PartnershipType($db);
|
$partnershipt = new PartnershipType($db);
|
||||||
$partnershipt->fetch($object->typeid);
|
$partnershipt->fetch($object->typeid);
|
||||||
|
|
||||||
@ -275,9 +336,10 @@ if (empty($reshook) && $action == 'add') {
|
|||||||
$result = $object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader);
|
$result = $object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
// Send email to the foundation to say a new member subscribed with autosubscribe form
|
// Send email to the foundation to say a new member subscribed with autosubscribe form
|
||||||
|
/*
|
||||||
if (getDolGlobalString('MAIN_INFO_SOCIETE_MAIL') && !empty($conf->global->PARTNERSHIP_AUTOREGISTER_NOTIF_MAIL_SUBJECT) &&
|
if (getDolGlobalString('MAIN_INFO_SOCIETE_MAIL') && !empty($conf->global->PARTNERSHIP_AUTOREGISTER_NOTIF_MAIL_SUBJECT) &&
|
||||||
!empty($conf->global->PARTNERSHIP_AUTOREGISTER_NOTIF_MAIL)) {
|
!empty($conf->global->PARTNERSHIP_AUTOREGISTER_NOTIF_MAIL)) {
|
||||||
// Define link to login card
|
// Define link to login card
|
||||||
@ -314,7 +376,7 @@ if (empty($reshook) && $action == 'add') {
|
|||||||
if (!$mailfile->sendfile()) {
|
if (!$mailfile->sendfile()) {
|
||||||
dol_syslog($langs->trans("ErrorFailedToSendMail", $from, $to), LOG_ERR);
|
dol_syslog($langs->trans("ErrorFailedToSendMail", $from, $to), LOG_ERR);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
if (!empty($backtopage)) {
|
if (!empty($backtopage)) {
|
||||||
$urlback = $backtopage;
|
$urlback = $backtopage;
|
||||||
@ -325,6 +387,7 @@ if (empty($reshook) && $action == 'add') {
|
|||||||
$urlback = $_SERVER["PHP_SELF"]."?action=added&token=".newToken();
|
$urlback = $_SERVER["PHP_SELF"]."?action=added&token=".newToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
if (!empty($conf->global->PARTNERSHIP_NEWFORM_PAYONLINE) && $conf->global->PARTNERSHIP_NEWFORM_PAYONLINE != '-1') {
|
if (!empty($conf->global->PARTNERSHIP_NEWFORM_PAYONLINE) && $conf->global->PARTNERSHIP_NEWFORM_PAYONLINE != '-1') {
|
||||||
if ($conf->global->PARTNERSHIP_NEWFORM_PAYONLINE == 'all') {
|
if ($conf->global->PARTNERSHIP_NEWFORM_PAYONLINE == 'all') {
|
||||||
$urlback = DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?from=partnershipnewform&source=membersubscription&ref='.urlencode($partnership->ref);
|
$urlback = DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?from=partnershipnewform&source=membersubscription&ref='.urlencode($partnership->ref);
|
||||||
@ -390,7 +453,7 @@ if (empty($reshook) && $action == 'add') {
|
|||||||
dol_print_error('', "Autosubscribe form is setup to ask an online payment for a not managed online payment");
|
dol_print_error('', "Autosubscribe form is setup to ask an online payment for a not managed online payment");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
if (!empty($entity)) {
|
if (!empty($entity)) {
|
||||||
$urlback .= '&entity='.$entity;
|
$urlback .= '&entity='.$entity;
|
||||||
@ -401,6 +464,7 @@ if (empty($reshook) && $action == 'add') {
|
|||||||
$errmsg .= join('<br>', $partnership->errors);
|
$errmsg .= join('<br>', $partnership->errors);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
$db->commit();
|
$db->commit();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user