diff --git a/htdocs/comm/mailing/advtargetemailing.php b/htdocs/comm/mailing/advtargetemailing.php index be8a63225fe7d..9cd40a55b8b81 100644 --- a/htdocs/comm/mailing/advtargetemailing.php +++ b/htdocs/comm/mailing/advtargetemailing.php @@ -221,7 +221,7 @@ if ((count($advTarget->thirdparty_lines) > 0) || (count($advTarget->contact_lines) > 0)) { // Add targets into database $obj = new mailing_advthirdparties($db); - $result = $obj->add_to_target($id, $advTarget->thirdparty_lines, $array_query['type_of_target'], $advTarget->contact_lines); + $result = $obj->add_to_target_spec($id, $advTarget->thirdparty_lines, $array_query['type_of_target'], $advTarget->contact_lines); } else { $result = 0; } @@ -967,11 +967,11 @@ print ''; print '
'; } - - if (empty($conf->mailchimp->enabled) || (! empty($conf->mailchimp->enabled) && $object->statut != 3)) + + if (empty($conf->mailchimp->enabled) || (! empty($conf->mailchimp->enabled) && $object->statut != 3)) { - // List of recipients (TODO Move code of page cibles.php into a .tpl.php file and make an include here to avoid duplicate content) + // List of recipients (TODO Move code of page cibles.php into a .tpl.php file and make an include here to avoid duplicate content) } } diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index a4aff6d71c145..b682b214da87e 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -32,6 +32,8 @@ $langs->load("bills"); $langs->load("companies"); +$id=GETPOST('id','int'); + $action=GETPOST('action','alpha'); $backtopage=GETPOST('backtopage','alpha'); @@ -58,6 +60,9 @@ //if ($user->rights->societe->creer) //if ($user->rights->facture->creer) + $amount_ttc_1=GETPOST('amount_ttc_1'); + $amount_ttc_2=GETPOST('amount_ttc_2'); + $error=0; $remid=GETPOST("remid")?GETPOST("remid"):0; $discount=new DiscountAbsolute($db); @@ -67,7 +72,7 @@ $error++; setEventMessages($langs->trans("ErrorFailedToLoadDiscount"), null, 'errors'); } - if (! $error && price2num($_POST["amount_ttc_1"]+$_POST["amount_ttc_2"]) != $discount->amount_ttc) + if (! $error && price2num($amount_ttc_1+$amount_ttc_2) != $discount->amount_ttc) { $error++; setEventMessages($langs->trans("TotalOfTwoDiscountMustEqualsOriginal"), null, 'errors'); @@ -120,7 +125,7 @@ if ($res > 0 && $newid1 > 0 && $newid2 > 0) { $db->commit(); - header("Location: ".$_SERVER["PHP_SELF"].'?id='.$_REQUEST['id']); // To avoid pb whith back + header("Location: ".$_SERVER["PHP_SELF"].'?id='.$id); // To avoid pb whith back exit; } else @@ -135,10 +140,14 @@ //if ($user->rights->societe->creer) //if ($user->rights->facture->creer) - if (price2num($_POST["amount_ht"]) > 0) + $amount_ht=GETPOST('amount_ht'); + $desc=GETPOST('desc','alpha'); + $tva_tx=GETPOST('tva_tx','alpha'); + + if (price2num($amount_ht) > 0) { $error=0; - if (empty($_POST["desc"])) + if (empty($desc)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("ReasonDiscount")), null, 'errors'); $error++; @@ -147,8 +156,8 @@ if (! $error) { $soc = new Societe($db); - $soc->fetch($_GET["id"]); - $discountid=$soc->set_remise_except($_POST["amount_ht"],$user,$_POST["desc"],$_POST["tva_tx"]); + $soc->fetch($id); + $discountid=$soc->set_remise_except($amount_ht,$user,$desc,$tva_tx); if ($discountid > 0) { @@ -159,7 +168,7 @@ } else { - header("Location: remx.php?id=".$_GET["id"]); + header("Location: remx.php?id=".$id); exit; } } @@ -189,7 +198,7 @@ if ($result > 0) { $db->commit(); - header("Location: ".$_SERVER["PHP_SELF"].'?id='.GETPOST('id','int')); // To avoid pb whith back + header("Location: ".$_SERVER["PHP_SELF"].'?id='.$id); // To avoid pb whith back exit; } else @@ -227,11 +236,11 @@ print ''; dol_fiche_head($head, 'absolutediscount', $langs->trans("ThirdParty"),0,'company'); - + dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom'); - + print '
'; - + print '
'; print ''; @@ -264,22 +273,22 @@ print load_fiche_titre($langs->trans("NewGlobalDiscount"),'',''); print '
'; - print ''; + print ''; print ''; print ''; print ''; - print ''; - print ''; + print ''; + print ''; print "
'.$langs->trans("AmountHT").'
'.$langs->trans("AmountHT").''; print ' '.$langs->trans("Currency".$conf->currency).'
'.$langs->trans("VAT").''; print $form->load_tva('tva_tx',GETPOST('tva_tx'),$mysoc,$object); print '
'.$langs->trans("NoteReason").'
'.$langs->trans("NoteReason").'
"; print '
'; - + dol_fiche_end(); - + print '
'; print ''; if (! empty($backtopage)) @@ -296,7 +305,7 @@ if ($_GET['action'] == 'remove') { - print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&remid='.$_GET["remid"], $langs->trans('RemoveDiscount'), $langs->trans('ConfirmRemoveDiscount'), 'confirm_remove', '', 0, 1); + print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&remid='.GETPOST('remid'), $langs->trans('RemoveDiscount'), $langs->trans('ConfirmRemoveDiscount'), 'confirm_remove', '', 0, 1); } /* @@ -383,7 +392,7 @@ else print ' '; print ''; - if ($_GET["action"]=='split' && $_GET['remid'] == $obj->rowid) + if ($_GET["action"]=='split' && GETPOST('remid') == $obj->rowid) { $showconfirminfo['rowid']=$obj->rowid; $showconfirminfo['amount_ttc']=$obj->amount_ttc; diff --git a/htdocs/core/lib/emailing.lib.php b/htdocs/core/lib/emailing.lib.php index 443b9b6156a4e..9ddd05f7faaf6 100644 --- a/htdocs/core/lib/emailing.lib.php +++ b/htdocs/core/lib/emailing.lib.php @@ -39,14 +39,14 @@ function emailing_prepare_head(Mailing $object) $head[$h][2] = 'card'; $h++; - if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->mailing->mailing_advance->recipient)) + if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->mailing->mailing_advance->recipient)) { $head[$h][0] = DOL_URL_ROOT."/comm/mailing/cibles.php?id=".$object->id; $head[$h][1] = $langs->trans("MailRecipients"); $head[$h][2] = 'targets'; $h++; - - if (! empty($conf->global->EMAILING_USE_ADVANCED_SELECTOR)) // Still need debug + + if (! empty($conf->global->EMAILING_USE_ADVANCED_SELECTOR)) { $head[$h][0] = DOL_URL_ROOT."/comm/mailing/advtargetemailing.php?id=".$object->id; $head[$h][1] = $langs->trans("MailAdvTargetRecipients"); @@ -54,7 +54,7 @@ function emailing_prepare_head(Mailing $object) $h++; } } - + $head[$h][0] = DOL_URL_ROOT."/comm/mailing/info.php?id=".$object->id; $head[$h][1] = $langs->trans("Info"); $head[$h][2] = 'info'; diff --git a/htdocs/core/modules/mailings/advthirdparties.modules.php b/htdocs/core/modules/mailings/advthirdparties.modules.php index cba8af72295a4..1e04fe5459d76 100644 --- a/htdocs/core/modules/mailings/advthirdparties.modules.php +++ b/htdocs/core/modules/mailings/advthirdparties.modules.php @@ -56,7 +56,7 @@ function __construct($db) * @param array $contactid Array of contact id to add * @return int <0 if error, number of emails added if ok */ - function add_to_target($mailing_id,$socid,$type_of_target, $contactid) + function add_to_target_spec($mailing_id,$socid,$type_of_target, $contactid) { global $conf, $langs; @@ -80,14 +80,14 @@ function add_to_target($mailing_id,$socid,$type_of_target, $contactid) { $num = $this->db->num_rows($result); $i = 0; - + dol_syslog(get_class($this)."::add_to_target mailing ".$num." targets found", LOG_DEBUG); - + $old = ''; while ($i < $num) { $obj = $this->db->fetch_object($result); - + if (!empty($obj->email) && filter_var($obj->email, FILTER_VALIDATE_EMAIL)) { if (!array_key_exists($obj->email, $cibles)) { $cibles[$obj->email] = array( @@ -102,7 +102,7 @@ function add_to_target($mailing_id,$socid,$type_of_target, $contactid) ); } } - + $i++; } } @@ -129,21 +129,21 @@ function add_to_target($mailing_id,$socid,$type_of_target, $contactid) $sql.= " AND socp.fk_soc IN (".implode(',',$socid).")"; } $sql.= " ORDER BY email"; - + // Stock recipients emails into targets table $result=$this->db->query($sql); if ($result) { $num = $this->db->num_rows($result); $i = 0; - + dol_syslog(get_class($this)."::add_to_target mailing ".$num." targets found"); - + $old = ''; while ($i < $num) { $obj = $this->db->fetch_object($result); - + if (!empty($obj->email) && filter_var($obj->email, FILTER_VALIDATE_EMAIL)) { if (!array_key_exists($obj->email, $cibles)) { $cibles[$obj->email] = array( @@ -158,7 +158,7 @@ function add_to_target($mailing_id,$socid,$type_of_target, $contactid) ); } } - + $i++; } } @@ -202,7 +202,7 @@ function getSqlArrayForStats() * * @return int Nb of recipients */ - function getNbOfRecipients() + function getNbOfRecipients($sql) { global $conf;