Added missing error messages in supplier & customer's orders

This commit is contained in:
Marcos García 2012-08-15 15:52:51 +02:00
parent f714897873
commit b4471a4bd7
2 changed files with 55 additions and 8 deletions

View File

@ -7,6 +7,7 @@
* Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2012 Marcos García <marcosgdf@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -517,18 +518,34 @@ else if ($action == 'setnote' && $user->rights->commande->creer)
*/
else if ($action == 'addline' && $user->rights->commande->creer)
{
$result=0;
$langs->load('errors');
$result = 0;
if ((GETPOST('np_price') < 0) && (GETPOST('qty') < 0))
{
$mesgs[] = '<div class="error">'.$langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPrice'),$langs->transnoentitiesnoconv('Qty')).'</div>';
$result = -1 ;
}
if (! GETPOST('idprod') && GETPOST('type') < 0)
{
$mesg = '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")).'</div>';
$mesgs[] = '<div class="error">'.$langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')).'</div>';
$result = -1 ;
}
if (! GETPOST('idprod') && GETPOST('np_price')=='') // Unit price can be 0 but not ''
if (! GETPOST('idprod') && GETPOST('np_price') == '') // Unit price can be 0 but not ''
{
$mesg = '<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("UnitPriceHT")).'</div>';
$mesgs[] = '<div class="error">'.$langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('UnitPrice')).'</div>';
$result = -1 ;
}
if (! GETPOST('qty') && GETPOST('qty') == '')
{
$mesgs[] = '<div class="error">'.$langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')).'</div>';
$result = -1 ;
}
if (! GETPOST('idprod') && (GETPOST('np_desc') == '') && (GETPOST('dp_desc') == ''))
{
$mesgs[] = '<div class="error">'.$langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')).'</div>';
$result = -1 ;
}
if ($result >= 0 && GETPOST('qty') && ((GETPOST('np_price') != '' && (GETPOST('np_desc') || GETPOST('dp_desc'))) || GETPOST('idprod')))
{

View File

@ -5,6 +5,7 @@
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2012 Marcos García <marcosgdf@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -169,7 +170,36 @@ else if ($action == 'reopen' && $user->rights->fournisseur->commande->approuver)
*/
else if ($action == 'addline' && $user->rights->fournisseur->commande->creer)
{
if (($_POST['qty'] || $_POST['pqty']) && (($_POST['pu'] && ($_POST['np_desc'] || $_POST['dp_desc'])) || $_POST['idprodfournprice']))
$langs->load('errors');
$result = 0;
if ($_POST['pu'] < 0 && $_POST['qty'] < 0)
{
$mesgs[]='<div class="error">'.$langs->trans("ErrorBothFieldCantBeNegative",$langs->transnoentitiesnoconv("UnitPriceHT"),$langs->transnoentitiesnoconv("Qty")).'</div>';
$result = -1 ;
}
if (empty($_POST['idprodfournprice']) && $_POST['type'] < 0)
{
$mesgs[]='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")).'</div>';
$result = -1 ;
}
if (empty($_POST['idprodfournprice']) && (! isset($_POST['pu']) || $_POST['pu']=='')) // Unit price can be 0 but not ''
{
$mesgs[]='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("UnitPrice")).'</div>';
$result = -1 ;
}
if (empty($_POST['idprodfournprice']) && empty($_POST["np_desc"]) && empty($_POST["dp_desc"]))
{
$mesgs[]='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Description")).'</div>';
$result = -1 ;
}
if ((empty($_POST['idprodfournprice']) && (! isset($_POST['qty']) || $_POST['qty']=='')) || (empty($_POST['idprodfournprice']) && (! isset($_POST['pqty']) || $_POST['qty'] == '')))
{
$mesgs[]='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv('Qty')).'</div>';
$result = -1 ;
}
if ($result >= 0 && (($_POST['qty'] || $_POST['pqty']) && (($_POST['pu'] && ($_POST['np_desc'] || $_POST['dp_desc'])) || $_POST['idprodfournprice'])))
{
if ($object->fetch($id) < 0) dol_print_error($db,$object->error);
if ($object->fetch_thirdparty() < 0) dol_print_error($db,$object->error);
@ -223,7 +253,6 @@ else if ($action == 'addline' && $user->rights->fournisseur->commande->creer)
if ($idprod == -1)
{
// Quantity too low
$langs->load("errors");
$mesg='<div class="error">'.$langs->trans("ErrorQtyTooLowForThisSupplier").'</div>';
}
}
@ -288,9 +317,9 @@ else if ($action == 'addline' && $user->rights->fournisseur->commande->creer)
unset($localtax1_tx);
unset($localtax2_tx);
}
else if (empty($mesg))
else
{
$mesg='<div class="error">'.$object->error.'</div>';
$mesgs[] ='<div class="error">'.$object->error.'</div>';
}
}
}
@ -1787,6 +1816,7 @@ if ($id > 0 || ! empty($ref))
}
}
dol_htmloutput_mesg('', $mesgs);
// End of page
llxFooter();