Error management

This commit is contained in:
Laurent Destailleur 2010-08-29 00:06:23 +00:00
parent a881307f01
commit 5cb43e1521

View File

@ -89,9 +89,6 @@ if ($_POST['action'] == 'confirm_valide' && $_POST['confirm'] == 'yes' && $user-
llxHeader(); llxHeader();
$paiement = new PaiementFourn($db);
$paiement->fetch($_GET['id']);
$html = new Form($db); $html = new Form($db);
$h=0; $h=0;
@ -108,36 +105,41 @@ $h++;
dol_fiche_head($head, $hselected, $langs->trans('SupplierPayment'), 0, 'payment'); dol_fiche_head($head, $hselected, $langs->trans('SupplierPayment'), 0, 'payment');
/* $paiement = new PaiementFourn($db);
$result=$paiement->fetch($_GET['id']);
if ($result > 0)
{
/*
* Confirmation de la suppression du paiement * Confirmation de la suppression du paiement
*/ */
if ($_GET['action'] == 'delete') if ($_GET['action'] == 'delete')
{ {
$ret=$html->form_confirm('fiche.php?id='.$paiement->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete'); $ret=$html->form_confirm('fiche.php?id='.$paiement->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete');
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }
/* /*
* Confirmation de la validation du paiement * Confirmation de la validation du paiement
*/ */
if ($_GET['action'] == 'valide') if ($_GET['action'] == 'valide')
{ {
$ret=$html->form_confirm('fiche.php?id='.$paiement->id, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide'); $ret=$html->form_confirm('fiche.php?id='.$paiement->id, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide');
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }
if (!empty($_POST['action']) && $_POST['action'] == 'update_num' && !empty($_POST['new_num'])) if (!empty($_POST['action']) && $_POST['action'] == 'update_num' && !empty($_POST['new_num']))
{ {
$res = $paiement->update_num($_POST['new_num']); $res = $paiement->update_num($_POST['new_num']);
if ($res === 0) { if ($res === 0) {
$mesg = '<div class="ok">'.$langs->trans('PaymentNumberUpdateSucceeded').'</div>'; $mesg = '<div class="ok">'.$langs->trans('PaymentNumberUpdateSucceeded').'</div>';
} else { } else {
$mesg = '<div class="error">'.$langs->trans('PaymentNumberUpdateFailed').'</div>'; $mesg = '<div class="error">'.$langs->trans('PaymentNumberUpdateFailed').'</div>';
} }
} }
if (!empty($_POST['action']) && $_POST['action'] == 'update_date' && !empty($_POST['reday'])) if (!empty($_POST['action']) && $_POST['action'] == 'update_date' && !empty($_POST['reday']))
{ {
$datepaye = dol_mktime(12, 0 , 0, $datepaye = dol_mktime(12, 0 , 0,
$_POST['remonth'], $_POST['remonth'],
$_POST['reday'], $_POST['reday'],
@ -148,17 +150,17 @@ if (!empty($_POST['action']) && $_POST['action'] == 'update_date' && !empty($_PO
} else { } else {
$mesg = '<div class="error">'.$langs->trans('PaymentDateUpdateFailed').'</div>'; $mesg = '<div class="error">'.$langs->trans('PaymentDateUpdateFailed').'</div>';
} }
} }
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr>'; print '<tr>';
print '<td valign="top" width="20%" colspan="2">'.$langs->trans('Ref').'</td><td colspan="3">'.$paiement->id.'</td></tr>'; print '<td valign="top" width="20%" colspan="2">'.$langs->trans('Ref').'</td><td colspan="3">'.$paiement->id.'</td></tr>';
//switch through edition options for date (only available when statut is -not 1- (=validated)) //switch through edition options for date (only available when statut is -not 1- (=validated))
if (empty($_GET['action']) || $_GET['action']!='edit_date') if (empty($_GET['action']) || $_GET['action']!='edit_date')
{ {
print '<tr><td colspan="2">'; print '<tr><td colspan="2">';
print '<table class="nobordernopadding" width="100%"><tr><td nowrap="nowrap">'; print '<table class="nobordernopadding" width="100%"><tr><td nowrap="nowrap">';
print $langs->trans('Date'); print $langs->trans('Date');
@ -167,9 +169,9 @@ if (empty($_GET['action']) || $_GET['action']!='edit_date')
print '</tr></table>'; print '</tr></table>';
print '</td>'; print '</td>';
print '<td colspan="3">'.dol_print_date($paiement->date,'day').'</td></tr>'; print '<td colspan="3">'.dol_print_date($paiement->date,'day').'</td></tr>';
} }
else else
{ {
print '<tr>'; print '<tr>';
print '<td valign="top" colspan="2">'.$langs->trans('Date').'</td>'; print '<td valign="top" colspan="2">'.$langs->trans('Date').'</td>';
print '<td colspan="3">'; print '<td colspan="3">';
@ -184,13 +186,13 @@ else
print '</form>'; print '</form>';
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} }
print '<tr><td valign="top" colspan="2">'.$langs->trans('Type').'</td><td colspan="3">'.$paiement->type_libelle.'</td></tr>'; print '<tr><td valign="top" colspan="2">'.$langs->trans('Type').'</td><td colspan="3">'.$paiement->type_libelle.'</td></tr>';
//switch through edition options for number (only available when statut is -not 1- (=validated)) //switch through edition options for number (only available when statut is -not 1- (=validated))
if (empty($_GET['action']) || $_GET['action'] != 'edit_num') if (empty($_GET['action']) || $_GET['action'] != 'edit_num')
{ {
print '<tr><td colspan="2">'; print '<tr><td colspan="2">';
print '<table class="nobordernopadding" width="100%"><tr><td nowrap="nowrap">'; print '<table class="nobordernopadding" width="100%"><tr><td nowrap="nowrap">';
print $langs->trans('Numero'); print $langs->trans('Numero');
@ -199,9 +201,9 @@ if (empty($_GET['action']) || $_GET['action'] != 'edit_num')
print '</tr></table>'; print '</tr></table>';
print '</td>'; print '</td>';
print '<td colspan="3">'.$paiement->numero.'</td></tr>'; print '<td colspan="3">'.$paiement->numero.'</td></tr>';
} }
else else
{ {
print '<tr>'; print '<tr>';
print '<td valign="top" colspan="2">'.$langs->trans('Numero').'</td>'; print '<td valign="top" colspan="2">'.$langs->trans('Numero').'</td>';
print '<td colspan="3">'; print '<td colspan="3">';
@ -215,18 +217,18 @@ else
print '<input type="submit" class="button" name="submit" value="'.$langs->trans('Validate').'" />'; print '<input type="submit" class="button" name="submit" value="'.$langs->trans('Validate').'" />';
print '</form></td>'; print '</form></td>';
print '</tr>'; print '</tr>';
} }
print '<tr><td valign="top" colspan="2">'.$langs->trans('Amount').'</td><td colspan="3">'.price($paiement->montant).'&nbsp;'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>'; print '<tr><td valign="top" colspan="2">'.$langs->trans('Amount').'</td><td colspan="3">'.price($paiement->montant).'&nbsp;'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
if ($conf->global->BILL_ADD_PAYMENT_VALIDATION) if ($conf->global->BILL_ADD_PAYMENT_VALIDATION)
{ {
print '<tr><td valign="top" colspan="2">'.$langs->trans('Status').'</td><td colspan="3">'.$paiement->getLibStatut(4).'</td></tr>'; print '<tr><td valign="top" colspan="2">'.$langs->trans('Status').'</td><td colspan="3">'.$paiement->getLibStatut(4).'</td></tr>';
} }
print '<tr><td valign="top" colspan="2">'.$langs->trans('Note').'</td><td colspan="3">'.nl2br($paiement->note).'</td></tr>'; print '<tr><td valign="top" colspan="2">'.$langs->trans('Note').'</td><td colspan="3">'.nl2br($paiement->note).'</td></tr>';
if ($conf->banque->enabled) if ($conf->banque->enabled)
{ {
if ($paiement->bank_account) if ($paiement->bank_account)
{ {
// Si compte renseigne, on affiche libelle // Si compte renseigne, on affiche libelle
@ -242,25 +244,25 @@ if ($conf->banque->enabled)
print '<td>'.$langs->trans('BankLineConciliated').'</td><td>'.yn($bankline->rappro).'</td>'; print '<td>'.$langs->trans('BankLineConciliated').'</td><td>'.yn($bankline->rappro).'</td>';
print '</tr>'; print '</tr>';
} }
} }
print '</table>'; print '</table>';
if ($mesg) print '<br>'.$mesg; if ($mesg) print '<br>'.$mesg;
print '<br>'; print '<br>';
/** /**
* Liste des factures * Liste des factures
*/ */
$allow_delete = 1 ; $allow_delete = 1 ;
$sql = 'SELECT f.rowid as ref, f.facnumber as ref_supplier, f.total_ttc, pf.amount, f.rowid as facid, f.paye, f.fk_statut, s.nom, s.rowid as socid'; $sql = 'SELECT f.rowid as ref, f.facnumber as ref_supplier, f.total_ttc, pf.amount, f.rowid as facid, f.paye, f.fk_statut, s.nom, s.rowid as socid';
$sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf,'.MAIN_DB_PREFIX.'facture_fourn as f,'.MAIN_DB_PREFIX.'societe as s'; $sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf,'.MAIN_DB_PREFIX.'facture_fourn as f,'.MAIN_DB_PREFIX.'societe as s';
$sql .= ' WHERE pf.fk_facturefourn = f.rowid AND f.fk_soc = s.rowid'; $sql .= ' WHERE pf.fk_facturefourn = f.rowid AND f.fk_soc = s.rowid';
$sql .= ' AND pf.fk_paiementfourn = '.$paiement->id; $sql .= ' AND pf.fk_paiementfourn = '.$paiement->id;
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
{ {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
@ -314,22 +316,22 @@ if ($resql)
print "</table>\n"; print "</table>\n";
$db->free($resql); $db->free($resql);
} }
else else
{ {
dol_print_error($db); dol_print_error($db);
} }
print '</div>'; print '</div>';
/* /*
* Boutons Actions * Boutons Actions
*/ */
print '<div class="tabsAction">'; print '<div class="tabsAction">';
if ($conf->global->BILL_ADD_PAYMENT_VALIDATION) if ($conf->global->BILL_ADD_PAYMENT_VALIDATION)
{ {
if ($user->societe_id == 0 && $paiement->statut == 0 && $_GET['action'] == '') if ($user->societe_id == 0 && $paiement->statut == 0 && $_GET['action'] == '')
{ {
if ($user->rights->fournisseur->facture->valider) if ($user->rights->fournisseur->facture->valider)
@ -338,16 +340,25 @@ if ($conf->global->BILL_ADD_PAYMENT_VALIDATION)
} }
} }
} }
if ($user->societe_id == 0 && $allow_delete && $paiement->statut == 0 && $_GET['action'] == '') if ($user->societe_id == 0 && $allow_delete && $paiement->statut == 0 && $_GET['action'] == '')
{ {
if ($user->rights->fournisseur->facture->supprimer) if ($user->rights->fournisseur->facture->supprimer)
{ {
print '<a class="butActionDelete" href="fiche.php?id='.$_GET['id'].'&amp;action=delete">'.$langs->trans('Delete').'</a>'; print '<a class="butActionDelete" href="fiche.php?id='.$_GET['id'].'&amp;action=delete">'.$langs->trans('Delete').'</a>';
} }
}
print '</div>';
} }
print '</div>'; else
{
$langs->load("errors");
print $langs->trans("ErrorRecordNotFound");
}
dol_fiche_end();
$db->close(); $db->close();