Merge pull request #3967 from grandoc/develop

[Qual] Uniformize code
This commit is contained in:
Laurent Destailleur 2015-11-12 15:01:20 +01:00
commit 8a26e27ef3
8 changed files with 56 additions and 56 deletions

View File

@ -112,7 +112,7 @@ if (empty($reshook))
if (empty($object->ref)) if (empty($object->ref))
{ {
$error++; $error++;
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")),'errors'); setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")), null, 'errors');
} }
if (! $error) if (! $error)
@ -152,7 +152,7 @@ if (empty($reshook))
if (empty($object->ref)) if (empty($object->ref))
{ {
$error++; $error++;
setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")),null,'errors'); setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")), null, 'errors');
} }
if (! $error) if (! $error)
@ -189,8 +189,8 @@ if (empty($reshook))
} }
else else
{ {
if (! empty($object->errors)) setEventMessages(null,$object->errors,'errors'); if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
else setEventMessages($object->error,null,'errors'); else setEventMessages($object->error, null, 'errors');
} }
} }
} }

View File

@ -71,7 +71,7 @@ if ($action == 'validate' && $user->rights->deplacement->creer)
} }
else else
{ {
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
} }
@ -89,7 +89,7 @@ else if ($action == 'classifyrefunded' && $user->rights->deplacement->creer)
} }
else else
{ {
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
} }
@ -104,7 +104,7 @@ else if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->depl
} }
else else
{ {
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
@ -150,7 +150,7 @@ else if ($action == 'add' && $user->rights->deplacement->creer)
} }
else else
{ {
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$action='create'; $action='create';
} }
} }
@ -190,7 +190,7 @@ else if ($action == 'update' && $user->rights->deplacement->creer)
} }
else else
{ {
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
else else
@ -412,7 +412,7 @@ else if ($id)
else else
{ {
/* /*
* Confirmation de la suppression du deplacement * Confirm delete trip
*/ */
if ($action == 'delete') if ($action == 'delete')
{ {

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2005 Patrick Rouillon <patrick@rouillon.net> /* Copyright (C) 2005 Patrick Rouillon <patrick@rouillon.net>
* Copyright (C) 2005-2009 Destailleur Laurent <eldy@users.sourceforge.net> * Copyright (C) 2005-2009 Destailleur Laurent <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011-2012 Philippe Grand <philippe.grand@atoo-net.com> * Copyright (C) 2011-2015 Philippe Grand <philippe.grand@atoo-net.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -48,7 +48,7 @@ $object = new Facture($db);
/* /*
* Ajout d'un nouveau contact * Add a new contact
*/ */
if ($action == 'addcontact' && $user->rights->facture->creer) if ($action == 'addcontact' && $user->rights->facture->creer)
@ -71,16 +71,16 @@ if ($action == 'addcontact' && $user->rights->facture->creer)
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{ {
$langs->load("errors"); $langs->load("errors");
setEventMessage($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), 'errors'); setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors');
} }
else else
{ {
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
} }
// Bascule du statut d'un contact // Toggle the status of a contact
else if ($action == 'swapstatut' && $user->rights->facture->creer) else if ($action == 'swapstatut' && $user->rights->facture->creer)
{ {
if ($object->fetch($id)) if ($object->fetch($id))
@ -93,7 +93,7 @@ else if ($action == 'swapstatut' && $user->rights->facture->creer)
} }
} }
// Efface un contact // Deletes a contact
else if ($action == 'deletecontact' && $user->rights->facture->creer) else if ($action == 'deletecontact' && $user->rights->facture->creer)
{ {
$object->fetch($id); $object->fetch($id);
@ -124,7 +124,7 @@ $userstatic=new User($db);
/* *************************************************************************** */ /* *************************************************************************** */
/* */ /* */
/* Mode vue et edition */ /* View and edit mode */
/* */ /* */
/* *************************************************************************** */ /* *************************************************************************** */
@ -139,7 +139,7 @@ if ($id > 0 || ! empty($ref))
dol_fiche_head($head, 'contact', $langs->trans('InvoiceCustomer'), 0, 'bill'); dol_fiche_head($head, 'contact', $langs->trans('InvoiceCustomer'), 0, 'bill');
/* /*
* Facture synthese pour rappel * Summary invoice for reminder
*/ */
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';

View File

@ -70,7 +70,7 @@ if ($action == 'add')
{ {
if (! GETPOST('titre')) if (! GETPOST('titre'))
{ {
setEventMessage($langs->transnoentities("ErrorFieldRequired",$langs->trans("Title")), 'errors'); setEventMessages($langs->transnoentities("ErrorFieldRequired",$langs->trans("Title")), null, 'errors');
$action = "create"; $action = "create";
$error++; $error++;
} }
@ -88,13 +88,13 @@ if ($action == 'add')
} }
else else
{ {
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$action = "create"; $action = "create";
} }
} }
} }
// Suppression // Delete
if ($action == 'delete' && $user->rights->facture->supprimer) if ($action == 'delete' && $user->rights->facture->supprimer)
{ {
$object->fetch($id); $object->fetch($id);

View File

@ -107,14 +107,14 @@ if ($action == 'presend' && GETPOST('sendmail'))
if (!isset($user->email)) if (!isset($user->email))
{ {
$error++; $error++;
setEventMessage("NoSenderEmailDefined"); setEventMessages($langs->trans("NoSenderEmailDefined"), null, 'warnings');
} }
$countToSend = count($_POST['toSend']); $countToSend = count($_POST['toSend']);
if (empty($countToSend)) if (empty($countToSend))
{ {
$error++; $error++;
setEventMessage("InvoiceNotChecked","warnings"); setEventMessages($langs->trans("InvoiceNotChecked"), null, 'warnings');
} }
if (! $error) if (! $error)
@ -260,11 +260,11 @@ if ($action == 'presend' && GETPOST('sendmail'))
if ($nbsent) if ($nbsent)
{ {
$action=''; // Do not show form post if there was at least one successfull sent $action=''; // Do not show form post if there was at least one successfull sent
setEventMessage($nbsent. '/'.$countToSend.' '.$langs->trans("RemindSent")); setEventMessages($nbsent. '/'.$countToSend.' '.$langs->trans("RemindSent"), null, 'mesgs');
} }
else else
{ {
setEventMessage($langs->trans("NoRemindSent"), 'warnings'); // May be object has no generated PDF file setEventMessages($langs->trans("NoRemindSent"), null, 'warnings'); // May be object has no generated PDF file
} }
} }
} }
@ -349,16 +349,16 @@ if ($action == "builddoc" && $user->rights->facture->lire && ! GETPOST('button_s
@chmod($file, octdec($conf->global->MAIN_UMASK)); @chmod($file, octdec($conf->global->MAIN_UMASK));
$langs->load("exports"); $langs->load("exports");
setEventMessage($langs->trans('FileSuccessfullyBuilt',$filename.'_'.dol_print_date($now,'dayhourlog'))); setEventMessages($langs->trans('FileSuccessfullyBuilt',$filename.'_'.dol_print_date($now,'dayhourlog')), null, 'mesgs');
} }
else else
{ {
setEventMessage($langs->trans('NoPDFAvailableForChecked'),'errors'); setEventMessages($langs->trans('NoPDFAvailableForChecked'), null, 'errors');
} }
} }
else else
{ {
setEventMessage($langs->trans('InvoiceNotChecked'), 'warnings'); setEventMessages($langs->trans('InvoiceNotChecked'), null, 'warnings');
} }
} }
@ -371,8 +371,8 @@ if ($action == 'remove_file')
$upload_dir = $diroutputpdf; $upload_dir = $diroutputpdf;
$file = $upload_dir . '/' . GETPOST('file'); $file = $upload_dir . '/' . GETPOST('file');
$ret=dol_delete_file($file); $ret=dol_delete_file($file);
if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs');
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors');
$action=''; $action='';
} }

View File

@ -75,12 +75,12 @@ if ($action == "new")
{ {
$db->commit(); $db->commit();
setEventMessage($langs->trans("RecordSaved")); setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
} }
else else
{ {
$db->rollback(); $db->rollback();
setEventMessage($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
$action=''; $action='';

View File

@ -66,7 +66,7 @@ if ($action == 'setnote' && $user->rights->facture->paiement)
} }
else else
{ {
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$db->rollback(); $db->rollback();
} }
} }
@ -86,7 +86,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->facture->
else else
{ {
$langs->load("errors"); $langs->load("errors");
setEventMessage($langs->trans($object->error), 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$db->rollback(); $db->rollback();
} }
} }
@ -124,7 +124,7 @@ if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->facture->
else else
{ {
$langs->load("errors"); $langs->load("errors");
setEventMessage($langs->trans($object->error), 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$db->rollback(); $db->rollback();
} }
} }
@ -135,11 +135,11 @@ if ($action == 'setnum_paiement' && ! empty($_POST['num_paiement']))
$res = $object->update_num($_POST['num_paiement']); $res = $object->update_num($_POST['num_paiement']);
if ($res === 0) if ($res === 0)
{ {
setEventMessage($langs->trans('PaymentNumberUpdateSucceeded')); setEventMessages($langs->trans('PaymentNumberUpdateSucceeded'), null, 'mesgs');
} }
else else
{ {
setEventMessage($langs->trans('PaymentNumberUpdateFailed'), 'errors'); setEventMessages($langs->trans('PaymentNumberUpdateFailed'), null, 'errors');
} }
} }
@ -150,11 +150,11 @@ if ($action == 'setdatep' && ! empty($_POST['datepday']))
$res = $object->update_date($datepaye); $res = $object->update_date($datepaye);
if ($res === 0) if ($res === 0)
{ {
setEventMessage($langs->trans('PaymentDateUpdateSucceeded')); setEventMessages($langs->trans('PaymentDateUpdateSucceeded'), null, 'mesgs');
} }
else else
{ {
setEventMessage($langs->trans('PaymentDateUpdateFailed'), 'errors'); setEventMessages($langs->trans('PaymentDateUpdateFailed'), null, 'errors');
} }
} }

View File

@ -79,12 +79,12 @@ if ($action == 'setdate' && $user->rights->banque->cheque)
$result=$object->set_date($user,$date); $result=$object->set_date($user,$date);
if ($result < 0) if ($result < 0)
{ {
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
else else
{ {
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
@ -98,12 +98,12 @@ if ($action == 'setrefext' && $user->rights->banque->cheque)
$result=$object->setValueFrom('ref_ext', $ref_ext); $result=$object->setValueFrom('ref_ext', $ref_ext);
if ($result < 0) if ($result < 0)
{ {
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
else else
{ {
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
@ -117,12 +117,12 @@ if ($action == 'setref' && $user->rights->banque->cheque)
$result=$object->set_number($user,$number); $result=$object->set_number($user,$number);
if ($result < 0) if ($result < 0)
{ {
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
else else
{ {
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
@ -154,12 +154,12 @@ if ($action == 'create' && $_POST["accountid"] > 0 && $user->rights->banque->che
} }
else else
{ {
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
else else
{ {
setEventMessage($langs->trans("ErrorSelectAtLeastOne")); setEventMessages($langs->trans("ErrorSelectAtLeastOne"), null, 'mesgs');
$action='new'; $action='new';
} }
} }
@ -175,7 +175,7 @@ if ($action == 'remove' && $id > 0 && $_GET["lineid"] > 0 && $user->rights->banq
} }
else else
{ {
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
@ -190,7 +190,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->banque->c
} }
else else
{ {
setEventMessage($paiement->error, 'errors'); setEventMessages($paiement->error, $paiement->errors, 'errors');
} }
} }
@ -217,7 +217,7 @@ if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->banque->c
} }
else else
{ {
setEventMessage($object->error, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
@ -230,7 +230,7 @@ if ($action == 'confirm_reject_check' && $confirm == 'yes' && $user->rights->ban
$paiement_id = $object->rejectCheck($rejected_check, $reject_date); $paiement_id = $object->rejectCheck($rejected_check, $reject_date);
if ($paiement_id > 0) if ($paiement_id > 0)
{ {
setEventMessage($langs->trans("CheckRejectedAndInvoicesReopened")); setEventMessages($langs->trans("CheckRejectedAndInvoicesReopened"), null, 'mesgs');
//header("Location: ".DOL_URL_ROOT.'/compta/paiement/card.php?id='.$paiement_id); //header("Location: ".DOL_URL_ROOT.'/compta/paiement/card.php?id='.$paiement_id);
//exit; //exit;
$action=''; $action='';
@ -282,8 +282,8 @@ else if ($action == 'remove_file' && $user->rights->banque->cheque)
$file=$dir.get_exdir($object->number,0,1,0,$object,'cheque') . GETPOST('file'); $file=$dir.get_exdir($object->number,0,1,0,$object,'cheque') . GETPOST('file');
$ret=dol_delete_file($file,0,0,0,$object); $ret=dol_delete_file($file,0,0,0,$object);
if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('file'))); if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs');
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), 'errors'); else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors');
} }
} }