Skip to content

Commit

Permalink
code review
Browse files Browse the repository at this point in the history
  • Loading branch information
atm-florian committed Jun 30, 2016
1 parent bdba5dc commit 388bd5c
Showing 1 changed file with 27 additions and 18 deletions.
45 changes: 27 additions & 18 deletions htdocs/comm/remx.php
Expand Up @@ -32,6 +32,8 @@
$langs->load("bills");
$langs->load("companies");

$id=GETPOST('id','int');

$action=GETPOST('action','alpha');
$backtopage=GETPOST('backtopage','alpha');

Expand All @@ -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);
Expand All @@ -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');
Expand Down Expand Up @@ -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
Expand All @@ -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++;
Expand All @@ -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)
{
Expand All @@ -159,7 +168,7 @@
}
else
{
header("Location: remx.php?id=".$_GET["id"]);
header("Location: remx.php?id=".$id);
exit;
}
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -227,11 +236,11 @@
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';

dol_fiche_head($head, 'absolutediscount', $langs->trans("ThirdParty"),0,'company');

dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom');

print '<div class="fichecenter">';

print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">';

Expand Down Expand Up @@ -264,22 +273,22 @@

print load_fiche_titre($langs->trans("NewGlobalDiscount"),'','');
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 '<span class="hideonsmartphone">&nbsp;'.$langs->trans("Currency".$conf->currency).'</span></td></tr>';
print '<tr><td width="38%">'.$langs->trans("VAT").'</td>';
print '<td>';
print $form->load_tva('tva_tx',GETPOST('tva_tx'),$mysoc,$object);
print '</td></tr>';
print '<tr><td>'.$langs->trans("NoteReason").'</td>';
print '<td><input type="text" size="60" name="desc" value="'.$_POST["desc"].'"></td></tr>';
print '<tr><td class="fieldrequired" >'.$langs->trans("NoteReason").'</td>';
print '<td><input type="text" size="60" name="desc" value="'.GETPOST('desc').'"></td></tr>';

print "</table>";

print '</div>';

dol_fiche_end();

print '<div class="center">';
print '<input type="submit" class="button" name="submit" value="'.$langs->trans("AddGlobalDiscount").'">';
if (! empty($backtopage))
Expand All @@ -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);
}

/*
Expand Down Expand Up @@ -383,7 +392,7 @@
else print '<td>&nbsp;</td>';
print '</tr>';

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;
Expand Down

0 comments on commit 388bd5c

Please sign in to comment.