Fix: Error when duplicate ref
This commit is contained in:
parent
fef6419c75
commit
633a45e5a4
@ -43,7 +43,7 @@ $langs->load('bills');
|
|||||||
$langs->load('suppliers');
|
$langs->load('suppliers');
|
||||||
$langs->load('companies');
|
$langs->load('companies');
|
||||||
|
|
||||||
$facid = isset($_GET["facid"])?$_GET["facid"]:(isset($_POST["facid"])?$_POST["facid"]:'');
|
$facid = GETPOST("facid");
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
if ($user->societe_id) $socid=$user->societe_id;
|
if ($user->societe_id) $socid=$user->societe_id;
|
||||||
@ -51,7 +51,7 @@ $result = restrictedArea($user, 'fournisseur', $facid, 'facture_fourn', 'facture
|
|||||||
|
|
||||||
$html = new Form($db);
|
$html = new Form($db);
|
||||||
$mesg='';
|
$mesg='';
|
||||||
$action=isset($_GET['action'])?$_GET['action']:$_POST['action'];
|
$action=GETPOST(action);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -210,7 +210,7 @@ if ($_POST['action'] == 'add' && $user->rights->fournisseur->facture->creer)
|
|||||||
$_GET['socid']=$_POST['socid'];
|
$_GET['socid']=$_POST['socid'];
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
if (empty($_POST['facnumber']))
|
if (! GETPOST('facnumber'))
|
||||||
{
|
{
|
||||||
$mesg='<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('RefSupplier')).'</div>';
|
$mesg='<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('RefSupplier')).'</div>';
|
||||||
$_GET['action']='create';
|
$_GET['action']='create';
|
||||||
@ -320,40 +320,48 @@ if ($_POST['action'] == 'add' && $user->rights->fournisseur->facture->creer)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$facid = $facfou->create($user);
|
$facid = $facfou->create($user);
|
||||||
|
if ($facid < 0)
|
||||||
for ($i = 1 ; $i < 9 ; $i++)
|
|
||||||
{
|
{
|
||||||
$label = $_POST['label'.$i];
|
$error++;
|
||||||
$amountht = price2num($_POST['amount'.$i]);
|
|
||||||
$amountttc = price2num($_POST['amountttc'.$i]);
|
|
||||||
$tauxtva = price2num($_POST['tauxtva'.$i]);
|
|
||||||
$qty = $_POST['qty'.$i];
|
|
||||||
$fk_product = $_POST['fk_product'.$i];
|
|
||||||
if ($label)
|
|
||||||
{
|
|
||||||
if ($amountht)
|
|
||||||
{
|
|
||||||
$price_base='HT'; $amount=$amountht;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$price_base='TTC'; $amount=$amountttc;
|
|
||||||
}
|
|
||||||
$atleastoneline=1;
|
|
||||||
|
|
||||||
$product=new Product($db);
|
|
||||||
$product->fetch($_POST['idprod'.$i]);
|
|
||||||
|
|
||||||
$ret=$facfou->addline($label, $amount, $tauxtva, $product->localtax1_tx, $product->localtax2_tx, $qty, $fk_product, $remise_percent, '', '', '', 0, $price_base);
|
|
||||||
if ($ret < 0) $error++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
for ($i = 1 ; $i < 9 ; $i++)
|
||||||
|
{
|
||||||
|
$label = $_POST['label'.$i];
|
||||||
|
$amountht = price2num($_POST['amount'.$i]);
|
||||||
|
$amountttc = price2num($_POST['amountttc'.$i]);
|
||||||
|
$tauxtva = price2num($_POST['tauxtva'.$i]);
|
||||||
|
$qty = $_POST['qty'.$i];
|
||||||
|
$fk_product = $_POST['fk_product'.$i];
|
||||||
|
if ($label)
|
||||||
|
{
|
||||||
|
if ($amountht)
|
||||||
|
{
|
||||||
|
$price_base='HT'; $amount=$amountht;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$price_base='TTC'; $amount=$amountttc;
|
||||||
|
}
|
||||||
|
$atleastoneline=1;
|
||||||
|
|
||||||
|
$product=new Product($db);
|
||||||
|
$product->fetch($_POST['idprod'.$i]);
|
||||||
|
|
||||||
|
$ret=$facfou->addline($label, $amount, $tauxtva, $product->localtax1_tx, $product->localtax2_tx, $qty, $fk_product, $remise_percent, '', '', '', 0, $price_base);
|
||||||
|
if ($ret < 0) $error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($error)
|
if ($error)
|
||||||
{
|
{
|
||||||
|
$langs->load("errors");
|
||||||
$db->rollback();
|
$db->rollback();
|
||||||
$mesg='<div class="error">'.$facfou->error.'</div>';
|
$mesg='<div class="error">'.$langs->trans($facfou->error).'</div>';
|
||||||
$_GET['action']='create';
|
$_GET['action']='create';
|
||||||
$_GET['socid']=$_POST['socid'];
|
$_GET['socid']=$_POST['socid'];
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user