From dbe94526ef8b03d3ebcba8932ad597928a54c68f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 10 Oct 2008 21:53:16 +0000 Subject: [PATCH] Fix: Invoice date not defined by default unless option is set --- htdocs/fourn/facture/fiche.php | 62 ++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index ac353478aac..5b0d0bf9ee6 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -117,17 +117,30 @@ if ($_POST['action'] == 'update' && ! $_POST['cancel']) $result = $db->query( $sql); } /* - * Action cr�ation + * Action creation */ if ($_POST['action'] == 'add' && $user->rights->fournisseur->facture->creer) { - if ($_POST['facnumber']) + $datefacture=dolibarr_mktime(12,0,0,$_POST['remonth'],$_POST['reday'],$_POST['reyear']); + $datedue=dolibarr_mktime(12,0,0,$_POST['echmonth'],$_POST['echday'],$_POST['echyear']); + + if ($datefacture == '') { - $datefacture = dolibarr_mktime(12,0,0, - $_POST['remonth'], - $_POST['reday'], - $_POST['reyear']); + $mesg='
'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('DateInvoice')).'
'; + $_GET['action']='create'; + $_GET['socid']=$_POST['socid']; + $error++; + } + if (empty($_POST['facnumber'])) + { + $mesg='
'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('RefSupplier')).'
'; + $_GET['action']='create'; + $_GET['socid']=$_POST['socid']; + $error++; + } + if (! $error) + { $db->begin(); // Creation facture @@ -137,7 +150,7 @@ if ($_POST['action'] == 'add' && $user->rights->fournisseur->facture->creer) $facfou->socid = $_POST['socid']; $facfou->libelle = $_POST['libelle']; $facfou->date = $datefacture; - $facfou->date_echeance = dolibarr_mktime(12,0,0,$_POST['echmonth'],$_POST['echday'],$_POST['echyear']); + $facfou->date_echeance = $datedue; $facfou->note = $_POST['note']; $facid = $facfou->create($user); @@ -190,12 +203,6 @@ if ($_POST['action'] == 'add' && $user->rights->fournisseur->facture->creer) $_GET['socid']=$_POST['socid']; } } - else - { - $mesg='
'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('RefSupplier')).'
'; - $_GET['action']='create'; - $_GET['socid']=$_POST['socid']; - } } if ($_GET['action'] == 'del_ligne') @@ -337,11 +344,17 @@ if ($_GET['action'] == 'create' or $_GET['action'] == 'copy') $societe->fetch($_GET['socid']); } + $datefacture=dolibarr_mktime(12,0,0,$_POST['remonth'],$_POST['reday'],$_POST['reyear']); + $datedue=dolibarr_mktime(12,0,0,$_POST['echmonth'],$_POST['echday'],$_POST['echyear']); + + $dateinvoice=($datefacture==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0):$datefacture); + print '
'; print ''; print ''; + + // Third party print ''; - print ''; print ''; - if($_GET['action'] == 'copy'){ - print ''; - }else{ - print ''; - } - + print ''; print ''; - if ($_GET['action'] == 'copy') - { - print ''; - } - else - { - print ''; - } + print ''; + + // Date invoice print ''; + // Due date print '';
'.$langs->trans('Company').''; if ($_GET['socid']) @@ -356,26 +369,17 @@ if ($_GET['action'] == 'create' or $_GET['action'] == 'copy') print ''.$langs->trans('NotePublic').'
'.$langs->trans('RefSupplier').'
'.$langs->trans('RefSupplier').'
'.$langs->trans('RefSupplier').'
'.$langs->trans('Label').'
'.$langs->trans('Label').'
'.$langs->trans('Label').'
'.$langs->trans('DateInvoice').''; - $html->select_date('','','','','',"add"); + $html->select_date($dateinvoice,'','','','',"add"); print '
'.$langs->trans('DateEcheance').''; $html->select_date('','ech','','','',"add"); print '