Merge pull request #5434 from atm-florian/dev_fix4672

Dev fix4672
This commit is contained in:
Laurent Destailleur 2016-06-30 21:00:48 +02:00 committed by GitHub
commit db0b806c7b
4 changed files with 46 additions and 37 deletions

View File

@ -221,7 +221,7 @@ if ($action == 'add') {
if ((count($advTarget->thirdparty_lines) > 0) || (count($advTarget->contact_lines) > 0)) { if ((count($advTarget->thirdparty_lines) > 0) || (count($advTarget->contact_lines) > 0)) {
// Add targets into database // Add targets into database
$obj = new mailing_advthirdparties($db); $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 { } else {
$result = 0; $result = 0;
} }

View File

@ -32,6 +32,8 @@ $langs->load("orders");
$langs->load("bills"); $langs->load("bills");
$langs->load("companies"); $langs->load("companies");
$id=GETPOST('id','int');
$action=GETPOST('action','alpha'); $action=GETPOST('action','alpha');
$backtopage=GETPOST('backtopage','alpha'); $backtopage=GETPOST('backtopage','alpha');
@ -58,6 +60,9 @@ if ($action == 'confirm_split' && GETPOST("confirm") == 'yes')
//if ($user->rights->societe->creer) //if ($user->rights->societe->creer)
//if ($user->rights->facture->creer) //if ($user->rights->facture->creer)
$amount_ttc_1=GETPOST('amount_ttc_1');
$amount_ttc_2=GETPOST('amount_ttc_2');
$error=0; $error=0;
$remid=GETPOST("remid")?GETPOST("remid"):0; $remid=GETPOST("remid")?GETPOST("remid"):0;
$discount=new DiscountAbsolute($db); $discount=new DiscountAbsolute($db);
@ -67,7 +72,7 @@ if ($action == 'confirm_split' && GETPOST("confirm") == 'yes')
$error++; $error++;
setEventMessages($langs->trans("ErrorFailedToLoadDiscount"), null, 'errors'); 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++; $error++;
setEventMessages($langs->trans("TotalOfTwoDiscountMustEqualsOriginal"), null, 'errors'); setEventMessages($langs->trans("TotalOfTwoDiscountMustEqualsOriginal"), null, 'errors');
@ -120,7 +125,7 @@ if ($action == 'confirm_split' && GETPOST("confirm") == 'yes')
if ($res > 0 && $newid1 > 0 && $newid2 > 0) if ($res > 0 && $newid1 > 0 && $newid2 > 0)
{ {
$db->commit(); $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; exit;
} }
else else
@ -135,10 +140,14 @@ if ($action == 'setremise')
//if ($user->rights->societe->creer) //if ($user->rights->societe->creer)
//if ($user->rights->facture->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; $error=0;
if (empty($_POST["desc"])) if (empty($desc))
{ {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("ReasonDiscount")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("ReasonDiscount")), null, 'errors');
$error++; $error++;
@ -147,8 +156,8 @@ if ($action == 'setremise')
if (! $error) if (! $error)
{ {
$soc = new Societe($db); $soc = new Societe($db);
$soc->fetch($_GET["id"]); $soc->fetch($id);
$discountid=$soc->set_remise_except($_POST["amount_ht"],$user,$_POST["desc"],$_POST["tva_tx"]); $discountid=$soc->set_remise_except($amount_ht,$user,$desc,$tva_tx);
if ($discountid > 0) if ($discountid > 0)
{ {
@ -159,7 +168,7 @@ if ($action == 'setremise')
} }
else else
{ {
header("Location: remx.php?id=".$_GET["id"]); header("Location: remx.php?id=".$id);
exit; exit;
} }
} }
@ -189,7 +198,7 @@ if (GETPOST("action") == 'confirm_remove' && GETPOST("confirm")=='yes')
if ($result > 0) if ($result > 0)
{ {
$db->commit(); $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; exit;
} }
else else
@ -264,15 +273,15 @@ if ($socid > 0)
print load_fiche_titre($langs->trans("NewGlobalDiscount"),'',''); print load_fiche_titre($langs->trans("NewGlobalDiscount"),'','');
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td width="38%">'.$langs->trans("AmountHT").'</td>'; print '<tr><td width="38%" class="fieldrequired">'.$langs->trans("AmountHT").'</td>';
print '<td><input type="text" size="5" name="amount_ht" value="'.$_POST["amount_ht"].'">'; print '<td><input type="text" size="5" name="amount_ht" value="'.$_POST["amount_ht"].'">';
print '<span class="hideonsmartphone">&nbsp;'.$langs->trans("Currency".$conf->currency).'</span></td></tr>'; print '<span class="hideonsmartphone">&nbsp;'.$langs->trans("Currency".$conf->currency).'</span></td></tr>';
print '<tr><td width="38%">'.$langs->trans("VAT").'</td>'; print '<tr><td width="38%">'.$langs->trans("VAT").'</td>';
print '<td>'; print '<td>';
print $form->load_tva('tva_tx',GETPOST('tva_tx'),$mysoc,$object); print $form->load_tva('tva_tx',GETPOST('tva_tx'),$mysoc,$object);
print '</td></tr>'; print '</td></tr>';
print '<tr><td>'.$langs->trans("NoteReason").'</td>'; print '<tr><td class="fieldrequired" >'.$langs->trans("NoteReason").'</td>';
print '<td><input type="text" size="60" name="desc" value="'.$_POST["desc"].'"></td></tr>'; print '<td><input type="text" size="60" name="desc" value="'.GETPOST('desc').'"></td></tr>';
print "</table>"; print "</table>";
@ -296,7 +305,7 @@ if ($socid > 0)
if ($_GET['action'] == 'remove') 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 @@ if ($socid > 0)
else print '<td>&nbsp;</td>'; else print '<td>&nbsp;</td>';
print '</tr>'; print '</tr>';
if ($_GET["action"]=='split' && $_GET['remid'] == $obj->rowid) if ($_GET["action"]=='split' && GETPOST('remid') == $obj->rowid)
{ {
$showconfirminfo['rowid']=$obj->rowid; $showconfirminfo['rowid']=$obj->rowid;
$showconfirminfo['amount_ttc']=$obj->amount_ttc; $showconfirminfo['amount_ttc']=$obj->amount_ttc;

View File

@ -46,7 +46,7 @@ function emailing_prepare_head(Mailing $object)
$head[$h][2] = 'targets'; $head[$h][2] = 'targets';
$h++; $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][0] = DOL_URL_ROOT."/comm/mailing/advtargetemailing.php?id=".$object->id;
$head[$h][1] = $langs->trans("MailAdvTargetRecipients"); $head[$h][1] = $langs->trans("MailAdvTargetRecipients");

View File

@ -56,7 +56,7 @@ class mailing_advthirdparties extends MailingTargets
* @param array $contactid Array of contact id to add * @param array $contactid Array of contact id to add
* @return int <0 if error, number of emails added if ok * @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; global $conf, $langs;
@ -202,7 +202,7 @@ class mailing_advthirdparties extends MailingTargets
* *
* @return int Nb of recipients * @return int Nb of recipients
*/ */
function getNbOfRecipients() function getNbOfRecipients($sql)
{ {
global $conf; global $conf;