Fix: bad error management
This commit is contained in:
parent
6838247724
commit
cb5fde8c62
@ -24,8 +24,8 @@
|
||||
*/
|
||||
|
||||
require('../main.inc.php');
|
||||
include_once(DOL_DOCUMENT_ROOT."/compta/chargesociales.class.php");
|
||||
include_once(DOL_DOCUMENT_ROOT."/compta/bank/account.class.php");
|
||||
include_once(DOL_DOCUMENT_ROOT."/compta/sociales/class/chargesociales.class.php");
|
||||
include_once(DOL_DOCUMENT_ROOT."/compta/bank/class/account.class.php");
|
||||
|
||||
$langs->load("bills");
|
||||
|
||||
@ -44,10 +44,12 @@ if ($user->societe_id > 0)
|
||||
*/
|
||||
if ($_POST["action"] == 'add_paiement')
|
||||
{
|
||||
$error=0;
|
||||
|
||||
if ($_POST["cancel"])
|
||||
{
|
||||
$loc = DOL_URL_ROOT.'/compta/sociales/charges.php?id='.$chid;
|
||||
Header("Location: $loc");
|
||||
Header("Location: ".$loc);
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -63,12 +65,18 @@ if ($_POST["action"] == 'add_paiement')
|
||||
$mesg = $langs->trans("ErrorFieldRequired",$langs->transnoentities("Date"));
|
||||
$error++;
|
||||
}
|
||||
if ($conf->banque->enabled && ! $_POST["accountid"] > 0)
|
||||
{
|
||||
$mesg = $langs->trans("ErrorFieldRequired",$langs->transnoentities("AccountToCredit"));
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$paiement_id = 0;
|
||||
$paymentid = 0;
|
||||
|
||||
// Read possible payments
|
||||
// FIXME add error message if no payment is defined
|
||||
$amounts = array();
|
||||
foreach ($_POST as $key => $value)
|
||||
{
|
||||
@ -90,9 +98,9 @@ if ($_POST["action"] == 'add_paiement')
|
||||
$paiement->paiementtype = $_POST["paiementtype"];
|
||||
$paiement->num_paiement = $_POST["num_paiement"];
|
||||
$paiement->note = $_POST["note"];
|
||||
$paiement_id = $paiement->create($user);
|
||||
$paymentid = $paiement->create($user);
|
||||
|
||||
if ($paiement_id > 0)
|
||||
if ($paymentid > 0)
|
||||
{
|
||||
// On determine le montant total du paiement
|
||||
$total=0;
|
||||
@ -108,7 +116,7 @@ if ($_POST["action"] == 'add_paiement')
|
||||
$langs->load("banks");
|
||||
$label = $langs->transnoentities("SocialContributionPayment");
|
||||
$acc = new Account($db, $_POST["accountid"]);
|
||||
$bank_line_id = $acc->addline($paiement->datepaye, $paiement->paiementtype, $label, -abs($total), $paiement->num_paiement, '', $user);
|
||||
$bank_line_id = $acc->addline($paiement->datepaye, $paiement->paiementtype, $label, -$total, $paiement->num_paiement, '', $user);
|
||||
|
||||
// Mise a jour fk_bank dans llx_paiementcharge. On connait ainsi le paiement qui a genere l'ecriture bancaire
|
||||
if ($bank_line_id > 0)
|
||||
@ -125,7 +133,7 @@ if ($_POST["action"] == 'add_paiement')
|
||||
$db->commit();
|
||||
|
||||
$loc = DOL_URL_ROOT.'/compta/sociales/charges.php?id='.$chid;
|
||||
Header("Location: $loc");
|
||||
Header("Location: ".$loc);
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
@ -136,7 +144,7 @@ if ($_POST["action"] == 'add_paiement')
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
$mesg = "Failed to create payment: paiement_id=$paiement_id ".$db->error();
|
||||
$mesg = "Failed to create payment: paiement_id=".$paymentid." ".$db->error();
|
||||
}
|
||||
}
|
||||
|
||||
@ -208,13 +216,14 @@ if ($_GET["action"] == 'create')
|
||||
print "<input type=\"hidden\" name=\"chid\" value=\"$chid\">";
|
||||
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Date").'</td><td>';
|
||||
$datepayment=empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0;
|
||||
$datepaye = dol_mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
|
||||
$datepayment=empty($conf->global->MAIN_AUTOFILL_DATE)?(empty($_POST["remonth"])?-1:$datepaye):0;
|
||||
$html->select_date($datepayment,'','','','',"add_paiement",1,1);
|
||||
print "</td>";
|
||||
print '<td>'.$langs->trans("Comments").'</td></tr>';
|
||||
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td>';
|
||||
$html->select_types_paiements($charge->paiementtype, "paiementtype");
|
||||
$html->select_types_paiements(isset($_POST["paiementtype"])?$_POST["paiementtype"]:$charge->paiementtype, "paiementtype");
|
||||
print "</td>\n";
|
||||
|
||||
print '<td rowspan="3" valign="top"><textarea name="comment" wrap="soft" cols="40" rows="'.ROWS_3.'"></textarea></td></tr>';
|
||||
@ -222,7 +231,7 @@ if ($_GET["action"] == 'create')
|
||||
print '<tr>';
|
||||
print '<td class="fieldrequired">'.$langs->trans('AccountToCredit').'</td>';
|
||||
print '<td>';
|
||||
$html->select_comptes($charge->accountid, "accountid", 0, "courant=1"); // Affiche liste des comptes courant
|
||||
$html->select_comptes(isset($_POST["accountid"])?$_POST["accountid"]:$charge->accountid, "accountid", 0, "courant=1",1); // Affiche liste des comptes courant
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans('Numero');
|
||||
@ -235,7 +244,8 @@ if ($_GET["action"] == 'create')
|
||||
$num = 1;
|
||||
$i = 0;
|
||||
print '<tr><td colspan="3">';
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
||||
print '<table class="nobordernopadding" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
//print '<td>'.$langs->trans("SocialContribution").'</td>';
|
||||
print '<td align="left">'.$langs->trans("DateDue").'</td>';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user