From a7fc2b3779b94552ef7311a799846feff11d2f5a Mon Sep 17 00:00:00 2001 From: KreizIT Date: Mon, 5 Jan 2015 17:55:59 +0100 Subject: [PATCH] Fix / Improve : [ bug #1747 ] Remove creation of batch 'Undefined' --- ChangeLog | 2 + htdocs/product/stock/product.php | 73 +++++++++++++++++++++++++++++--- 2 files changed, 68 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 61c83e5bcbf..9ae46a57e40 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,8 @@ English Dolibarr ChangeLog For users: - New: Use new combobox. - New: Add hidden option MAXTABS_IN_CARD. +- Fix / Improve : [ bug #1747 ] Remove creation of batch 'Undefined' + For translators: - Update language files. diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index b7eb79e5ab7..eaa12794688 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -6,7 +6,7 @@ * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2013 Juanjo Menent - * Copyright (C) 2014 Cédric Gross + * Copyright (C) 2014-2015 Cédric Gross * * 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 @@ -239,7 +239,45 @@ if ($action == "transfert_stock" && ! $cancel) } } +if ($action == 'updateline' && GETPOST('save') == $langs->trans('Save')) +{ + $pdluo = new Productbatch($db); + $result=$pdluo->fetch(GETPOST('pdluoid','int')); + + if ($result>0) + { + if ($pdluo->id) + { + if ((! GETPOST("sellby")) && (! GETPOST("eatby")) && (! GETPOST("batch_number"))) { + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("atleast1batchfield")), 'errors'); + } + else + { + $d_eatby=dol_mktime(12, 0, 0, $_POST['eatbymonth'], $_POST['eatbyday'], $_POST['eatbyyear']); + $d_sellby=dol_mktime(12, 0, 0, $_POST['sellbymonth'], $_POST['sellbyday'], $_POST['sellbyyear']); + $pdluo->batch=GETPOST("batch_number",'san_alpha'); + $pdluo->eatby=$d_eatby; + $pdluo->sellby=$d_sellby; + $result=$pdluo->update($user); + if ($result<0) + { + setEventMessages($pdluo->error,$pdluo->errors, 'errors'); + } + } + } + else + { + setEventMessages($langs->trans('BatchInformationNotfound'),null, 'errors'); + } + } + else + { + setEventMessages($pdluo->error,null, 'errors'); + } + header("Location: product.php?id=".$id); + exit; +} /* * View */ @@ -663,12 +701,33 @@ if ($resql) if ($details<0) dol_print_error($db); foreach ($details as $pdluo) { - print "\n".''; - print ''.$pdluo->batch.''; - print ''. dol_print_date($pdluo->eatby,'day') .''; - print ''. dol_print_date($pdluo->sellby,'day') .''; - print ''.$pdluo->qty.($pdluo->qty<0?' '.img_warning():'').''; - print ''; + if ( $action == 'editline' && GETPOST('lineid',int)==$pdluo->id ) + { //Current line edit + print "\n".''; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + $form->select_date($pdluo->eatby,'eatby','','',1,""); + print ''; + $form->select_date($pdluo->sellby,'sellby','','',1,""); + print ''.$pdluo->qty.($pdluo->qty<0?' '.img_warning():'').''; + print '
'; + } + else + { + print "\n".''; + print 'id.'#'.$pdluo->id.'">'; + print img_edit().''; + print ''.$pdluo->batch.''; + print ''. dol_print_date($pdluo->eatby,'day') .''; + print ''. dol_print_date($pdluo->sellby,'day') .''; + print ''.$pdluo->qty.($pdluo->qty<0?' '.img_warning():'').''; + print ''; + } } } $i++;