This commit is contained in:
Laurent Destailleur 2015-04-08 12:22:52 +02:00
parent 15ba6716f5
commit 17fa1ce5b6
2 changed files with 64 additions and 57 deletions

View File

@ -167,6 +167,8 @@ ErrorGlobalVariableUpdater2=Missing parameter '%s'
ErrorGlobalVariableUpdater3=The requested data was not found in result ErrorGlobalVariableUpdater3=The requested data was not found in result
ErrorGlobalVariableUpdater4=SOAP client failed with error '%s' ErrorGlobalVariableUpdater4=SOAP client failed with error '%s'
ErrorGlobalVariableUpdater5=No global variable selected ErrorGlobalVariableUpdater5=No global variable selected
ErrorFieldMustBeANumeric=Field <b>%s</b> must be a numeric value
ErrorFieldMustBeAnInteger=Field <b>%s</b> must be an integer
# Warnings # Warnings
WarningMandatorySetupNotComplete=Mandatory setup parameters are not yet defined WarningMandatorySetupNotComplete=Mandatory setup parameters are not yet defined

View File

@ -43,6 +43,7 @@ $id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha'); $ref = GETPOST('ref', 'alpha');
$rowid=GETPOST('rowid','int'); $rowid=GETPOST('rowid','int');
$action=GETPOST('action', 'alpha'); $action=GETPOST('action', 'alpha');
$cancel=GETPOST('cancel', 'alpha');
$socid=GETPOST('socid', 'int'); $socid=GETPOST('socid', 'int');
$backtopage=GETPOST('backtopage','alpha'); $backtopage=GETPOST('backtopage','alpha');
$error=0; $error=0;
@ -77,6 +78,8 @@ if (! $sortorder) $sortorder="ASC";
* Actions * Actions
*/ */
if ($cancel) $action='';
$parameters=array('socid'=>$socid, 'id_prod'=>$id); $parameters=array('socid'=>$socid, 'id_prod'=>$id);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$product,$action); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('doActions',$parameters,$product,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
@ -97,8 +100,8 @@ if (empty($reshook))
} }
} }
if ($action == 'updateprice' && GETPOST('cancel') <> $langs->trans("Cancel")) if ($action == 'updateprice')
{ {
$id_fourn=GETPOST("id_fourn"); $id_fourn=GETPOST("id_fourn");
if (empty($id_fourn)) $id_fourn=GETPOST("search_id_fourn"); if (empty($id_fourn)) $id_fourn=GETPOST("search_id_fourn");
$ref_fourn=GETPOST("ref_fourn"); $ref_fourn=GETPOST("ref_fourn");
@ -114,21 +117,31 @@ if ($action == 'updateprice' && GETPOST('cancel') <> $langs->trans("Cancel"))
if ($tva_tx == '') if ($tva_tx == '')
{ {
$error++; $error++;
$langs->load("errors");
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("VATRateForSupplierProduct")), 'errors'); setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("VATRateForSupplierProduct")), 'errors');
} }
if (! is_numeric($tva_tx))
{
$error++;
$langs->load("errors");
setEventMessage($langs->trans("ErrorFieldMustBeANumeric",'eeee'), 'errors');
}
if (empty($quantity)) if (empty($quantity))
{ {
$error++; $error++;
$langs->load("errors");
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Qty")), 'errors'); setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Qty")), 'errors');
} }
if (empty($ref_fourn)) if (empty($ref_fourn))
{ {
$error++; $error++;
$langs->load("errors");
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("RefSupplier")), 'errors'); setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("RefSupplier")), 'errors');
} }
if ($id_fourn <= 0) if ($id_fourn <= 0)
{ {
$error++; $error++;
$langs->load("errors");
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Supplier")), 'errors'); setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Supplier")), 'errors');
} }
if ($_POST["price"] < 0 || $_POST["price"] == '') if ($_POST["price"] < 0 || $_POST["price"] == '')
@ -136,6 +149,7 @@ if ($action == 'updateprice' && GETPOST('cancel') <> $langs->trans("Cancel"))
if ($price_expression === '') // Return error of missing price only if price_expression not set if ($price_expression === '') // Return error of missing price only if price_expression not set
{ {
$error++; $error++;
$langs->load("errors");
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Price")), 'errors'); setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Price")), 'errors');
} }
else else
@ -149,7 +163,7 @@ if ($action == 'updateprice' && GETPOST('cancel') <> $langs->trans("Cancel"))
if ($result <= 0) if ($result <= 0)
{ {
$error++; $error++;
setEventMessage($product->error, 'errors'); setEventMessages($product->error, $product->errors, 'errors');
} }
if (! $error) if (! $error)
@ -222,13 +236,10 @@ if ($action == 'updateprice' && GETPOST('cancel') <> $langs->trans("Cancel"))
$db->rollback(); $db->rollback();
} }
} }
} else
if (GETPOST('cancel') == $langs->trans("Cancel"))
{ {
$action = ''; $action = 'add_price';
header("Location: fournisseurs.php?id=".$_GET["id"]); }
exit;
} }
} }
@ -253,10 +264,6 @@ if ($id || $ref)
{ {
if ($action <> 'edit' && $action <> 're-edit') if ($action <> 'edit' && $action <> 're-edit')
{ {
/*
* En mode visu
*/
$head=product_prepare_head($product); $head=product_prepare_head($product);
$titre=$langs->trans("CardProduct".$product->type); $titre=$langs->trans("CardProduct".$product->type);
$picto=($product->type== Product::TYPE_SERVICE?'service':'product'); $picto=($product->type== Product::TYPE_SERVICE?'service':'product');
@ -325,6 +332,8 @@ if ($id || $ref)
print '<input type="hidden" name="id_fourn" value="'.$socid.'">'; print '<input type="hidden" name="id_fourn" value="'.$socid.'">';
print '<input type="hidden" name="ref_fourn" value="'.$product->fourn_ref.'">'; print '<input type="hidden" name="ref_fourn" value="'.$product->fourn_ref.'">';
print '<input type="hidden" name="ref_fourn_price_id" value="'.$rowid.'">'; print '<input type="hidden" name="ref_fourn_price_id" value="'.$rowid.'">';
print '<input type="hidden" name="rowid" value="'.$rowid.'">';
print '<input type="hidden" name="socid" value="'.$socid.'">';
} }
else else
{ {
@ -487,11 +496,7 @@ if ($id || $ref)
print '</form>'; print '</form>';
} }
/* ************************************************************************** */ // Actions buttons
/* */
/* Barre d'action */
/* */
/* ************************************************************************** */
print "\n<div class=\"tabsAction\">\n"; print "\n<div class=\"tabsAction\">\n";