From f36b9effe8fb5332570ffae0eed1b139941a1ee4 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Sat, 10 May 2014 17:22:12 +0200
Subject: [PATCH] Fix: [ bug #1373 ] Required type of payment input is not
 visible

---
 htdocs/compta/salaries/fiche.php | 32 ++++++++++++++++++++------------
 1 file changed, 20 insertions(+), 12 deletions(-)

diff --git a/htdocs/compta/salaries/fiche.php b/htdocs/compta/salaries/fiche.php
index 26bc30907e0..5476fd595be 100644
--- a/htdocs/compta/salaries/fiche.php
+++ b/htdocs/compta/salaries/fiche.php
@@ -79,6 +79,11 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
 	$sal->type_payment=GETPOST("paymenttype");
 	$sal->num_payment=GETPOST("num_payment");
 
+	if (empty($datep) || empty($datesp) || empty($dateep))
+	{
+		setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")),'errors');
+		$error++;
+	}
 	if (empty($sal->fk_user) || $sal->fk_user < 0)
 	{
 		setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Employee")),'errors');
@@ -98,7 +103,7 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
 	if (! $error)
 	{
 		$db->begin();
-	  
+
 		$ret=$sal->create($user);
 		if ($ret > 0)
 		{
@@ -210,11 +215,11 @@ if ($action == 'create')
 
 	print "<tr>";
 	print '<td class="fieldrequired">'.$langs->trans("DatePayment").'</td><td>';
-	print $form->select_date($datep,"datep",'','','','add');
+	print $form->select_date((empty($datep)?-1:$datep),"datep",'','','','add');
 	print '</td></tr>';
 
-	print '<tr><td class="fieldrequired">'.$langs->trans("DateValue").'</td><td>';
-	print $form->select_date($datev,"datev",'','','','add');
+	print '<tr><td>'.$langs->trans("DateValue").'</td><td>';
+	print $form->select_date((empty($datev)?-1:$datev),"datev",'','','','add');
 	print '</td></tr>';
 
 	// Employee
@@ -244,19 +249,22 @@ if ($action == 'create')
 		print '<tr><td class="fieldrequired">'.$langs->trans("Account").'</td><td>';
 		$form->select_comptes($_POST["accountid"],"accountid",0,"courant=1",1);  // Affiche liste des comptes courant
 		print '</td></tr>';
-		
-		// Type payment
-		print '<tr><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td>';
-		$form->select_types_paiements(GETPOST("paymenttype"), "paymenttype");
-		print "</td>\n";
-		print "</tr>";
-	 
+	}
+
+	// Type payment
+	print '<tr><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td>';
+	$form->select_types_paiements(GETPOST("paymenttype"), "paymenttype");
+	print "</td>\n";
+	print "</tr>";
+
+	if (! empty($conf->banque->enabled))
+	{
 		// Number
 		print '<tr><td>'.$langs->trans('Numero');
 		print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
 		print '<td><input name="num_payment" type="text" value="'.GETPOST("num_payment").'"></td></tr>'."\n";
 	}
- 
+
 	// Other attributes
 	$parameters=array('colspan' => ' colspan="1"');
 	$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action);    // Note that $action and $object may have been modified by hook
-- 
GitLab