diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 2e1526c89cb82..a223d4b35ba16 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -1378,7 +1378,7 @@ function initfieldrequired() array('label' => $langs->trans("AliasNames"), 'type' => 'text', 'name' => 'companyalias', 'value' => $companyalias, 'morecss' => 'minwidth300', 'moreattr' => 'maxlength="128"') ); - print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id,$langs->trans("CreateDolibarrThirdParty"),$langs->trans("ConfirmCreateThirdParty"),"confirm_create_thirdparty",$formquestion,1); + print $form->formconfirm($_SERVER["PHP_SELF"]."?rowid=".$object->id, $langs->trans("CreateDolibarrThirdParty"), $langs->trans("ConfirmCreateThirdParty"), "confirm_create_thirdparty", $formquestion, 'yes'); } // Confirm validate member @@ -1438,15 +1438,9 @@ function initfieldrequired() if (! empty($conf->mailman->enabled) && ! empty($conf->global->ADHERENT_USE_SPIP)) { $formquestion[]=array('type'=>'other','label'=>$langs->transnoentitiesnoconv("SynchroSpipEnabled"),'value'=>''); } - print $form->formconfirm("card.php?rowid=".$id, $langs->trans("ValidateMember"), $langs->trans("ConfirmValidateMember"), "confirm_valid", $formquestion, '1', 1, 220); + print $form->formconfirm("card.php?rowid=".$id, $langs->trans("ValidateMember"), $langs->trans("ConfirmValidateMember"), "confirm_valid", $formquestion, 'yes', 1, 220); } - // Confirm send card by mail - /*if ($action == 'sendinfo') - { - print $form->formconfirm("card.php?rowid=".$id,$langs->trans("SendCardByMail"),$langs->trans("ConfirmSendCardByMail",$object->email),"confirm_sendinfo",'',0,1); - }*/ - // Confirm terminate if ($action == 'resign') { @@ -1499,7 +1493,7 @@ function initfieldrequired() $formquestion=array(); if ($object->email) $formquestion[]=array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => (! empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL)?'true':'false')); if ($backtopage) $formquestion[]=array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"])); - print $form->formconfirm("card.php?rowid=".$id,$langs->trans("ResiliateMember"),$langs->trans("ConfirmResiliateMember"),"confirm_resign",$formquestion,'no',1); + print $form->formconfirm("card.php?rowid=".$id, $langs->trans("ResiliateMember"), $langs->trans("ConfirmResiliateMember"), "confirm_resign", $formquestion, 'no', 1, 220); } // Confirm remove member @@ -1507,7 +1501,7 @@ function initfieldrequired() { $formquestion=array(); if ($backtopage) $formquestion[]=array('type' => 'hidden', 'name' => 'backtopage', 'value' => ($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"])); - print $form->formconfirm("card.php?rowid=".$id,$langs->trans("DeleteMember"),$langs->trans("ConfirmDeleteMember"),"confirm_delete",$formquestion,0,1); + print $form->formconfirm("card.php?rowid=".$id, $langs->trans("DeleteMember"), $langs->trans("ConfirmDeleteMember"), "confirm_delete", $formquestion, 'no', 1); } // Confirm add in spip diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 5323355eb110f..b158263c3a0d1 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1668,6 +1668,8 @@ function validate($user) if ($result < 0) { $error++; $this->db->rollback(); return -1; } // End call triggers + $this->datevalid = $now; + $this->db->commit(); return 1; } diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 4d23637dfe793..705138f4df8b4 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -531,7 +531,7 @@ function addPaymentToBank($user,$mode,$label,$accountid,$emetteur_nom,$emetteur_ { if ($accountid <= 0) { - $this->error='Bad value for parameter accountid'; + $this->error='Bad value for parameter accountid='.$accountid; dol_syslog(get_class($this).'::addPaymentToBank '.$this->error, LOG_ERR); return -1; } diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php index dbcce928ccf39..d6c62ea107939 100644 --- a/htdocs/core/lib/payments.lib.php +++ b/htdocs/core/lib/payments.lib.php @@ -210,7 +210,7 @@ function getOnlinePaymentUrl($mode, $type, $ref='', $amount='9.99', $freetag='yo } // For multicompany - if (! empty($out)) $out.="&entity=".$conf->entity; // Check the entity because He may be the same reference in several entities + if (! empty($out) && ! empty($conf->multicompany->enabled)) $out.="&entity=".$conf->entity; // Check the entity because we may have the same reference in several entities return $out; } diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 63924ac6b1d78..1ba869796ede4 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -142,12 +142,17 @@ function llxFooterVierge() // Action called when page is submitted if ($action == 'add') { + $error = 0; + $urlback=''; + + $db->begin(); + // test if login already exists if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { if(! GETPOST('login')) { - $error+=1; + $error++; $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Login"))."
\n"; } $sql = "SELECT login FROM ".MAIN_DB_PREFIX."adherent WHERE login='".$db->escape(GETPOST('login'))."'"; @@ -158,52 +163,52 @@ function llxFooterVierge() } if ($num !=0) { - $error+=1; + $error++; $langs->load("errors"); $errmsg .= $langs->trans("ErrorLoginAlreadyExists")."
\n"; } if (!isset($_POST["pass1"]) || !isset($_POST["pass2"]) || $_POST["pass1"] == '' || $_POST["pass2"] == '' || $_POST["pass1"]!=$_POST["pass2"]) { - $error+=1; + $error++; $langs->load("errors"); $errmsg .= $langs->trans("ErrorPasswordsMustMatch")."
\n"; } if (! GETPOST("email")) { - $error+=1; + $error++; $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("EMail"))."
\n"; } } if (GETPOST('type') <= 0) { - $error+=1; + $error++; $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type"))."
\n"; } if (! in_array(GETPOST('morphy'),array('mor','phy'))) { - $error+=1; + $error++; $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv('Nature'))."
\n"; } if (empty($_POST["lastname"])) { - $error+=1; + $error++; $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Lastname"))."
\n"; } if (empty($_POST["firstname"])) { - $error+=1; + $error++; $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Firstname"))."
\n"; } if (GETPOST("email") && ! isValidEmail(GETPOST("email"))) { - $error+=1; + $error++; $langs->load("errors"); $errmsg .= $langs->trans("ErrorBadEMail",GETPOST("email"))."
\n"; } $birthday=dol_mktime($_POST["birthhour"],$_POST["birthmin"],$_POST["birthsec"],$_POST["birthmonth"],$_POST["birthday"],$_POST["birthyear"]); if ($_POST["birthmonth"] && empty($birthday)) { - $error+=1; + $error++; $langs->load("errors"); $errmsg .= $langs->trans("ErrorBadDateFormat")."
\n"; } @@ -211,7 +216,7 @@ function llxFooterVierge() { if (GETPOST("morphy") == 'mor' && GETPOST('budget') <= 0) { - $error+=1; + $error++; $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("TurnoverOrBudget"))."
\n"; } } @@ -258,6 +263,9 @@ function llxFooterVierge() require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; $object = $adh; + $adht = new AdherentType($db); + $adht->fetch($object->typeid); + if ($object->email) { $subject = ''; @@ -302,10 +310,23 @@ function llxFooterVierge() if (! empty($conf->global->MAIN_INFO_SOCIETE_MAIL) && ! empty($conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT) && ! empty($conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL) ) { + // Define link to login card + $appli=constant('DOL_APPLICATION_TITLE'); + if (! empty($conf->global->MAIN_APPLICATION_TITLE)) + { + $appli=$conf->global->MAIN_APPLICATION_TITLE; + if (preg_match('/\d\.\d/', $appli)) + { + if (! preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) $appli.=" (".DOL_VERSION.")"; // If new title contains a version that is different than core + } + else $appli.=" ".DOL_VERSION; + } + else $appli.=" ".DOL_VERSION; + $to=$adh->makeSubstitution($conf->global->MAIN_INFO_SOCIETE_MAIL); $from=$conf->global->ADHERENT_MAIL_FROM; $mailfile = new CMailFile( - $conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT, + '['.$appli.'] '.$conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT, $to, $from, $adh->makeSubstitution($conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL), @@ -332,7 +353,7 @@ function llxFooterVierge() } else $urlback=$_SERVER["PHP_SELF"]."?action=added"; - if (! empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) + if (! empty($conf->global->MEMBER_NEWFORM_PAYONLINE) && $conf->global->MEMBER_NEWFORM_PAYONLINE != '-1') { if ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'all') { @@ -343,7 +364,7 @@ function llxFooterVierge() { if (! empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { - $urlback.='&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'membersubscription' . $adh->ref, 2)); + $urlback.='&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'membersubscription' . $adh->ref, 2)); } else { @@ -377,7 +398,7 @@ function llxFooterVierge() { if (! empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) { - $urlback.='&securekey='.urlencode(dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'membersubscription' . $adh->ref, 2)); + $urlback.='&securekey='.urlencode(dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'membersubscription' . $adh->ref, 2)); } else { @@ -394,7 +415,7 @@ function llxFooterVierge() { if (! empty($conf->global->STRIPE_SECURITY_TOKEN_UNIQUE)) { - $urlback.='&securekey='.urlencode(dol_hash($conf->global->STRIPE_SECURITY_TOKEN . 'membersubscription' . $adh->ref, 2)); + $urlback.='&securekey='.urlencode(dol_hash($conf->global->STRIPE_SECURITY_TOKEN . 'membersubscription' . $adh->ref, 2)); } else { @@ -411,14 +432,25 @@ function llxFooterVierge() if (! empty($entity)) $urlback.='&entity='.$entity; dol_syslog("member ".$adh->ref." was created, we redirect to ".$urlback); - Header("Location: ".$urlback); - exit; } else { + $error++; $errmsg .= join('
',$adh->errors); } } + + if (! $error) + { + $db->commit(); + + Header("Location: ".$urlback); + exit; + } + else + { + $db->rollback(); + } } // Action called after a submitted was send and member created successfully diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index daeb43ba465c5..7eb9aa95b75da 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -312,13 +312,26 @@ // Do action only if $FinalPaymentAmt is set (session variable is cleaned after this page to avoid duplicate actions when page is POST a second time) if (! empty($FinalPaymentAmt) && $paymentTypeId > 0) { + $result = $object->validate($user); + if ($result < 0 || empty($object->datevalid)) + { + $error++; + $errmsg=$object->error; + $postactionmessages[] = $errmsg; + $postactionmessages = array_merge($postactionmessages, $object->errors); + $ispostactionok = -1; + } + // Subscription informations $datesubscription=$object->datevalid; if ($object->datefin > 0) { $datesubscription=dol_time_plus_duree($object->datefin,1,'d'); } - $datesubend=dol_time_plus_duree(dol_time_plus_duree($datesubscription,$defaultdelay,$defaultdelayunit),-1,'d'); + + $datesubend = null; + if ($datesubscription && $defaultdelay && $defaultdelayunit) $datesubend=dol_time_plus_duree(dol_time_plus_duree($datesubscription, $defaultdelay, $defaultdelayunit),-1,'d'); + $paymentdate=$now; $amount = $FinalPaymentAmt; $label='Online subscription '.dol_print_date($now, 'standard').' using '.$paymentmethod.' from '.$ipaddress.' - Transaction ID = '.$TRANSACTIONID; @@ -328,6 +341,14 @@ if ($paymentmethod == 'paybox') $accountid = $conf->global->PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS; if ($paymentmethod == 'paypal') $accountid = $conf->global->PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS; if ($paymentmethod == 'stripe') $accountid = $conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS; + if ($accountid < 0) + { + $error++; + $errmsg='Setup of bank accout to use for payment is not correctly done for payment method '.$paymentmethod; + $postactionmessages[] = $errmsg; + $ispostactionok = -1; + } + $operation=$paymentType; // Payment mode code $num_chq=''; $emetteur_nom=''; @@ -344,18 +365,21 @@ $db->begin(); // Create subscription - $crowid=$object->subscription($datesubscription, $amount, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend); - if ($crowid <= 0) - { - $error++; - $errmsg=$object->error; - $postactionmessages[] = $errmsg; - $ispostactionok = -1; - } - else + if (! $error) { - $postactionmessages[]='Subscription created'; - $ispostactionok=1; + $crowid=$object->subscription($datesubscription, $amount, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend); + if ($crowid <= 0) + { + $error++; + $errmsg=$object->error; + $postactionmessages[] = $errmsg; + $ispostactionok = -1; + } + else + { + $postactionmessages[]='Subscription created'; + $ispostactionok=1; + } } if (! $error) @@ -404,7 +428,7 @@ $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); $outputlangs->loadLangs(array("main", "members")); - // Get email content fro mtemplae + // Get email content from templae $arraydefaultmessage=null; $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION;