Renamed all methods valide() into validate()
This commit is contained in:
parent
9cc8e6ac99
commit
520645a02c
@ -26,6 +26,8 @@ Following changes may create regressions for some external modules, but were nec
|
||||
* If you have links in your code with '&action=delete' as a parameter, you must also add '&token='.newToken() as another parameter to avoid CSRF protection errors.
|
||||
* The API addPayment for api_invoice has evolved to accept amount into a foreign currency. You must provide array(amount=>X,mutlicurrency_ammount=>Y) instead of amount.
|
||||
* The method select_thirdparty(), deprecated since 3.8, into html.form.class.php has been removed.
|
||||
* Depreciate all methods with name valide(). Use instead methods validate().
|
||||
|
||||
|
||||
***** ChangeLog for 12.0.3 compared to 12.0.2 *****
|
||||
FIX: 10.0 - when the mime file name is different from the filesystem name, the attachment name should be the mime filename
|
||||
|
||||
@ -141,7 +141,7 @@ for ($i = 0; $i < $nbtoshow; $i++)
|
||||
</fieldset>
|
||||
|
||||
<!-- ========================= Cadre "Amount" ============================= -->
|
||||
<form id="frmDifference" class="formulaire1" method="post" onsubmit="javascript: return verifReglement()" action="validation_verif.php?action=valide_achat">
|
||||
<form id="frmDifference" class="formulaire1" method="post" onsubmit="javascript: return verifReglement()" action="validation_verif.php?action=validate_sell">
|
||||
<input type="hidden" name="hdnChoix" value="" />
|
||||
<input type="hidden" name="token" value="<?php echo newToken(); ?>" />
|
||||
<fieldset class="cadre_facturation"><legend class="titre1"><?php echo $langs->trans("Amount"); ?></legend>
|
||||
|
||||
@ -97,7 +97,7 @@ if ($obj_facturation->amountReturned()) {
|
||||
|
||||
</table>
|
||||
|
||||
<form id="frmValidation" class="formulaire2" method="post" action="validation_verif.php?action=valide_facture">
|
||||
<form id="frmValidation" class="formulaire2" method="post" action="validation_verif.php?action=validate_invoice">
|
||||
<input type="hidden" name="token" value="<?php echo newToken(); ?>" />
|
||||
<p class="note_label">
|
||||
<?php
|
||||
|
||||
@ -42,7 +42,7 @@ switch ($action)
|
||||
$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=validation';
|
||||
break;
|
||||
|
||||
case 'valide_achat':
|
||||
case 'validate_sell':
|
||||
$thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY'];
|
||||
|
||||
$company = new Societe($db);
|
||||
@ -112,7 +112,7 @@ switch ($action)
|
||||
break;
|
||||
|
||||
|
||||
case 'valide_facture':
|
||||
case 'validate_invoice':
|
||||
$now = dol_now();
|
||||
|
||||
// Recuperation de la date et de l'heure
|
||||
@ -344,7 +344,7 @@ switch ($action)
|
||||
}
|
||||
break;
|
||||
|
||||
// End of case: valide_facture
|
||||
// End of case: validate_invoice
|
||||
}
|
||||
|
||||
unset($_SESSION['serObjFacturation']);
|
||||
|
||||
@ -96,12 +96,12 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->facture->
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->facture->paiement)
|
||||
if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->facture->paiement)
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
$object->fetch($id);
|
||||
if ($object->valide($user) > 0)
|
||||
if ($object->validate($user) > 0)
|
||||
{
|
||||
$db->commit();
|
||||
|
||||
@ -189,7 +189,7 @@ if ($action == 'delete')
|
||||
if ($action == 'valide')
|
||||
{
|
||||
$facid = $_GET['facid'];
|
||||
print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&facid='.$facid, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide', '', 0, 2);
|
||||
print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&facid='.$facid, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_validate', '', 0, 2);
|
||||
}
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/paiement/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
@ -178,7 +178,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->banque->c
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->banque->cheque)
|
||||
if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->banque->cheque)
|
||||
{
|
||||
$result = $object->fetch($id);
|
||||
$result = $object->validate($user);
|
||||
@ -324,7 +324,7 @@ if ($action == 'new')
|
||||
*/
|
||||
if ($action == 'valide')
|
||||
{
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans("ValidateCheckReceipt"), $langs->trans("ConfirmValidateCheckReceipt"), 'confirm_valide', '', '', 1);
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans("ValidateCheckReceipt"), $langs->trans("ConfirmValidateCheckReceipt"), 'confirm_validate', '', '', 1);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@ -858,13 +858,25 @@ class Paiement extends CommonObject
|
||||
return -1; //no num given or already validated
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Validate payment
|
||||
*
|
||||
* @param User $user User making validation
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* @deprecated
|
||||
*/
|
||||
public function valide(User $user = null)
|
||||
{
|
||||
return $this->validate($user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate payment
|
||||
*
|
||||
* @param User $user User making validation
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function valide(User $user = null)
|
||||
public function validate(User $user = null)
|
||||
{
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET statut = 1 WHERE rowid = '.$this->id;
|
||||
|
||||
|
||||
@ -72,46 +72,6 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->tax->char
|
||||
}
|
||||
}
|
||||
|
||||
// Validate social contribution
|
||||
/*
|
||||
if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->tax->charges->creer)
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
$result=$object->valide();
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
$db->commit();
|
||||
|
||||
$factures=array(); // TODO Get all id of invoices linked to this payment
|
||||
foreach($factures as $id)
|
||||
{
|
||||
$fac = new Facture($db);
|
||||
$fac->fetch($id);
|
||||
|
||||
$outputlangs = $langs;
|
||||
if (! empty($_REQUEST['lang_id']))
|
||||
{
|
||||
$outputlangs = new Translate("",$conf);
|
||||
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
|
||||
}
|
||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
|
||||
$fac->generateDocument($fac->modelpdf, $outputlangs);
|
||||
}
|
||||
}
|
||||
|
||||
header('Location: card.php?id='.$object->id);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
@ -146,19 +106,6 @@ if ($action == 'delete')
|
||||
print $form->formconfirm('card.php?id='.$object->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete', '', 0, 2);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validation confirmation of payment
|
||||
*/
|
||||
/*
|
||||
if ($action == 'valide')
|
||||
{
|
||||
$facid = $_GET['facid'];
|
||||
print $form->formconfirm('card.php?id='.$object->id.'&facid='.$facid, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide','',0,2);
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/sociales/payments.php">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'id', '');
|
||||
|
||||
@ -168,7 +168,7 @@ class RejetPrelevement
|
||||
}
|
||||
|
||||
// Payment validation
|
||||
if ($pai->valide() < 0)
|
||||
if ($pai->validate($user) < 0)
|
||||
{
|
||||
$error++;
|
||||
dol_syslog("RejetPrelevement::Create Error payment validation");
|
||||
|
||||
@ -59,14 +59,19 @@ class DolibarrCollector extends DataCollector implements Renderable, AssetProvid
|
||||
protected function getDolibarrInfo()
|
||||
{
|
||||
global $conf, $langs;
|
||||
global $dolibarr_main_prod, $dolibarr_nocsrfcheck;
|
||||
|
||||
$info = $langs->trans('Version').': <strong>'.DOL_VERSION.'</strong><br>';
|
||||
$info .= $langs->trans('Theme').': <strong>'.$conf->theme.'</strong><br>';
|
||||
$info .= $langs->trans('Locale').': <strong>'.$conf->global->MAIN_LANG_DEFAULT.'</strong><br>';
|
||||
$info .= $langs->trans('Currency').': <strong>'.$conf->currency.'</strong><br>';
|
||||
$info .= $langs->trans('DolEntity').': <strong>'.$conf->entity.'</strong><br>';
|
||||
$info .= $langs->trans('ListLimit').': <strong>'.($conf->liste_limit ?: $conf->global->MAIN_SIZE_LISTE_LIMIT).'</strong><br>';
|
||||
$info .= $langs->trans('MaxSizeForUploadedFiles').': <strong>'.$conf->global->MAIN_UPLOAD_DOC.'</strong>';
|
||||
$info .= $langs->trans('Entity').': <strong>'.$conf->entity.'</strong><br>';
|
||||
$info .= $langs->trans('MaxSizeList').': <strong>'.($conf->liste_limit ?: $conf->global->MAIN_SIZE_LISTE_LIMIT).'</strong><br>';
|
||||
$info .= $langs->trans('MaxSizeForUploadedFiles').': <strong>'.$conf->global->MAIN_UPLOAD_DOC.'</strong><br>';
|
||||
$info .= '$dolibarr_main_prod = <strong>'.$dolibarr_main_prod.'</strong><br>';
|
||||
$info .= '$dolibarr_nocsrfcheck = <strong>'.$dolibarr_nocsrfcheck.'</strong><br>';
|
||||
$info .= 'MAIN_SECURITY_CSRF_WITH_TOKEN = <strong>'.$conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN.'</strong><br>';
|
||||
$info .= 'MAIN_FEATURES_LEVEL = <strong>'.$conf->global->MAIN_FEATURES_LEVEL.'</strong><br>';
|
||||
|
||||
return $info;
|
||||
}
|
||||
@ -79,6 +84,7 @@ class DolibarrCollector extends DataCollector implements Renderable, AssetProvid
|
||||
protected function getMailInfo()
|
||||
{
|
||||
global $conf, $langs;
|
||||
global $dolibarr_mailing_limit_sendbyweb;
|
||||
|
||||
$info = $langs->trans('Method').': <strong>'.$conf->global->MAIN_MAIL_SENDMODE.'</strong><br>';
|
||||
$info .= $langs->trans('Server').': <strong>'.$conf->global->MAIN_MAIL_SMTP_SERVER.'</strong><br>';
|
||||
@ -86,7 +92,8 @@ class DolibarrCollector extends DataCollector implements Renderable, AssetProvid
|
||||
$info .= $langs->trans('ID').': <strong>'.$conf->global->MAIN_MAIL_SMTPS_ID.'</strong><br>';
|
||||
$info .= $langs->trans('Pwd').': <strong>'.preg_replace('/./', '*', $conf->global->MAIN_MAIL_SMTPS_PW).'</strong><br>';
|
||||
$info .= $langs->trans('TLS/STARTTLS').': <strong>'.$conf->global->MAIN_MAIL_EMAIL_TLS.'</strong> / <strong>'.$conf->global->MAIN_MAIL_EMAIL_STARTTLS.'</strong><br>';
|
||||
$info .= $langs->trans('MAIN_DISABLE_ALL_MAILS').': <strong>'.($conf->global->MAIN_DISABLE_ALL_MAILS ? $langs->trans('Yes') : $langs->trans('No')).'</strong>';
|
||||
$info .= $langs->trans('MAIN_DISABLE_ALL_MAILS').': <strong>'.($conf->global->MAIN_DISABLE_ALL_MAILS ? $langs->trans('Yes') : $langs->trans('No')).'</strong><br>';
|
||||
$info .= 'dolibarr_mailing_limit_sendbyweb = <strong>'.$dolibarr_mailing_limit_sendbyweb.'</strong><br>';
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
@ -167,14 +167,14 @@ class Don extends CommonObject
|
||||
{
|
||||
global $langs;
|
||||
$langs->load("donations");
|
||||
$this->labelStatus[-1] = $langs->trans("Canceled");
|
||||
$this->labelStatus[0] = $langs->trans("DonationStatusPromiseNotValidated");
|
||||
$this->labelStatus[1] = $langs->trans("DonationStatusPromiseValidated");
|
||||
$this->labelStatus[2] = $langs->trans("DonationStatusPaid");
|
||||
$this->labelStatusShort[-1] = $langs->trans("Canceled");
|
||||
$this->labelStatusShort[0] = $langs->trans("DonationStatusPromiseNotValidatedShort");
|
||||
$this->labelStatusShort[1] = $langs->trans("DonationStatusPromiseValidatedShort");
|
||||
$this->labelStatusShort[2] = $langs->trans("DonationStatusPaidShort");
|
||||
$this->labelStatus[-1] = $langs->transnoentitiesnoconv("Canceled");
|
||||
$this->labelStatus[0] = $langs->transnoentitiesnoconv("DonationStatusPromiseNotValidated");
|
||||
$this->labelStatus[1] = $langs->transnoentitiesnoconv("DonationStatusPromiseValidated");
|
||||
$this->labelStatus[2] = $langs->transnoentitiesnoconv("DonationStatusPaid");
|
||||
$this->labelStatusShort[-1] = $langs->transnoentitiesnoconv("Canceled");
|
||||
$this->labelStatusShort[0] = $langs->transnoentitiesnoconv("DonationStatusPromiseNotValidatedShort");
|
||||
$this->labelStatusShort[1] = $langs->transnoentitiesnoconv("DonationStatusPromiseValidatedShort");
|
||||
$this->labelStatusShort[2] = $langs->transnoentitiesnoconv("DonationStatusPaidShort");
|
||||
}
|
||||
|
||||
$statusType = 'status'.$status;
|
||||
|
||||
@ -69,42 +69,6 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->don->supp
|
||||
}
|
||||
}
|
||||
|
||||
// Create payment
|
||||
if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->don->creer)
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
$result = $object->valide();
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
$db->commit();
|
||||
|
||||
$donations = array(); // TODO Get all id of donation linked to this payment
|
||||
foreach ($donations as $id)
|
||||
{
|
||||
$donation = new Don($db);
|
||||
$donation->fetch($id);
|
||||
|
||||
$outputlangs = $langs;
|
||||
if (!empty(GETPOST('lang_id')))
|
||||
{
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang(GETPOST('lang_id'));
|
||||
}
|
||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
|
||||
$donation->generateDocument($donation->model_pdf, $outputlangs);
|
||||
}
|
||||
}
|
||||
|
||||
header('Location: card.php?id='.$object->id);
|
||||
exit;
|
||||
} else {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
@ -132,14 +96,6 @@ if ($action == 'delete')
|
||||
print $form->formconfirm('card.php?id='.$object->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete', '', 0, 2);
|
||||
}
|
||||
|
||||
/*
|
||||
* Confirm validation of the payment
|
||||
*/
|
||||
if ($action == 'valide')
|
||||
{
|
||||
print $form->formconfirm('card.php?id='.$object->id, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide', '', 0, 2);
|
||||
}
|
||||
|
||||
|
||||
dol_banner_tab($object, 'id', '', 1, 'rowid', 'id');
|
||||
|
||||
@ -148,13 +104,6 @@ print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
print '<table class="border centpercent">';
|
||||
|
||||
// Ref
|
||||
/*print '<tr><td class=">'.$langs->trans('Ref').'</td>';
|
||||
print '<td colspan="3">';
|
||||
print $form->showrefnav($object,'id','',1,'rowid','id');
|
||||
print '</td></tr>';
|
||||
*/
|
||||
|
||||
// Date
|
||||
print '<tr><td class="titlefield">'.$langs->trans('Date').'</td><td>'.dol_print_date($object->datep, 'day').'</td></tr>';
|
||||
|
||||
|
||||
@ -70,42 +70,6 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->expensere
|
||||
}
|
||||
}
|
||||
|
||||
// Create payment
|
||||
if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->expensereport->creer)
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
$result = $object->valide();
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
$db->commit();
|
||||
|
||||
$factures = array(); // TODO Get all id of invoices linked to this payment
|
||||
foreach ($factures as $invoiceid)
|
||||
{
|
||||
$fac = new Facture($db);
|
||||
$fac->fetch($invoiceid);
|
||||
|
||||
$outputlangs = $langs;
|
||||
if (!empty($_REQUEST['lang_id']))
|
||||
{
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
|
||||
}
|
||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
|
||||
$fac->generateDocument($fac->model_pdf, $outputlangs);
|
||||
}
|
||||
}
|
||||
|
||||
header('Location: card.php?id='.$object->id);
|
||||
exit;
|
||||
} else {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
@ -127,15 +91,6 @@ if ($action == 'delete')
|
||||
print $form->formconfirm('card.php?id='.$object->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete', '', 0, 2);
|
||||
}
|
||||
|
||||
/*
|
||||
* Confirm validation of the payment
|
||||
*/
|
||||
if ($action == 'valide')
|
||||
{
|
||||
$facid = $_GET['facid'];
|
||||
print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&facid='.$facid, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide', '', 0, 2);
|
||||
}
|
||||
|
||||
$linkback = '';
|
||||
// $linkback = '<a href="' . DOL_URL_ROOT . '/expensereport/payment/list.php">' . $langs->trans("BackToList") . '</a>';
|
||||
|
||||
|
||||
@ -82,7 +82,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->fournisse
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'confirm_valide' && $confirm == 'yes' &&
|
||||
if ($action == 'confirm_validate' && $confirm == 'yes' &&
|
||||
((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->facture->creer))
|
||||
|| (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->supplier_invoice_advance->validate)))
|
||||
)
|
||||
@ -90,7 +90,7 @@ if ($action == 'confirm_valide' && $confirm == 'yes' &&
|
||||
$db->begin();
|
||||
|
||||
$object->fetch($id);
|
||||
if ($object->valide() >= 0)
|
||||
if ($object->validate() >= 0)
|
||||
{
|
||||
$db->commit();
|
||||
header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id);
|
||||
@ -161,9 +161,9 @@ if ($result > 0)
|
||||
/*
|
||||
* Confirmation of payment's validation
|
||||
*/
|
||||
if ($action == 'valide')
|
||||
if ($action == 'validate')
|
||||
{
|
||||
print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide');
|
||||
print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_validate');
|
||||
}
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/fourn/paiement/list.php'.(!empty($socid) ? '?socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
|
||||
@ -343,7 +343,7 @@ if ($result > 0)
|
||||
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->facture->creer))
|
||||
|| (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->fournisseur->supplier_invoice_advance->validate)))
|
||||
{
|
||||
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=valide">'.$langs->trans('Valid').'</a>';
|
||||
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=validate">'.$langs->trans('Valid').'</a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,6 +52,8 @@ $object = new Loan($db);
|
||||
|
||||
$hookmanager->initHooks(array('loancard', 'globalcard'));
|
||||
|
||||
$error = 0;
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
@ -62,7 +64,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
|
||||
if (empty($reshook))
|
||||
{
|
||||
// Classify paid
|
||||
if ($action == 'confirm_paid' && $confirm == 'yes')
|
||||
if ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->loan->write)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$result = $object->set_paid($user);
|
||||
@ -75,7 +77,7 @@ if (empty($reshook))
|
||||
}
|
||||
|
||||
// Delete loan
|
||||
if ($action == 'confirm_delete' && $confirm == 'yes')
|
||||
if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->loan->write)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$result = $object->delete($user);
|
||||
@ -146,7 +148,7 @@ if (empty($reshook))
|
||||
if ($id <= 0)
|
||||
{
|
||||
$error++;
|
||||
setEventMessages($object->db->lastqueryerror, $object->errors, 'errors');
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$action = 'create';
|
||||
}
|
||||
}
|
||||
|
||||
@ -417,6 +417,30 @@ class PaymentLoan extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee)
|
||||
*
|
||||
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
|
||||
* @return string Libelle
|
||||
*/
|
||||
public function getLibStatut($mode = 0)
|
||||
{
|
||||
return $this->LibStatut($this->statut, $mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renvoi le libelle d'un statut donne
|
||||
*
|
||||
* @param int $status Statut
|
||||
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
|
||||
* @return string Libelle du statut
|
||||
*/
|
||||
public function LibStatut($status, $mode = 0)
|
||||
{
|
||||
//
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Add record into bank for payment with links between this bank record and invoices of payment.
|
||||
* All payment properties must have been set first like after a call to create().
|
||||
|
||||
@ -71,42 +71,6 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->loan->del
|
||||
}
|
||||
}
|
||||
|
||||
// Create payment
|
||||
if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->loan->write)
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
$result = $payment->valide();
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
$db->commit();
|
||||
|
||||
$factures = array(); // TODO Get all id of invoices linked to this payment
|
||||
foreach ($factures as $id)
|
||||
{
|
||||
$fac = new Facture($db);
|
||||
$fac->fetch($id);
|
||||
|
||||
$outputlangs = $langs;
|
||||
if (!empty($_REQUEST['lang_id']))
|
||||
{
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
|
||||
}
|
||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
|
||||
$fac->generateDocument($fac->model_pdf, $outputlangs);
|
||||
}
|
||||
}
|
||||
|
||||
header('Location: card.php?id='.$payment->id);
|
||||
exit;
|
||||
} else {
|
||||
setEventMessages($payment->error, $payment->errors, 'errors');
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
@ -124,7 +88,7 @@ $head[$h][1] = $langs->trans("PaymentLoan");
|
||||
$hselected = $h;
|
||||
$h++;
|
||||
|
||||
dol_fiche_head($head, $hselected, $langs->trans("PaymentLoan"), 0, 'payment');
|
||||
dol_fiche_head($head, $hselected, $langs->trans("PaymentLoan"), -1, 'payment');
|
||||
|
||||
/*
|
||||
* Confirm deletion of the payment
|
||||
@ -134,24 +98,17 @@ if ($action == 'delete')
|
||||
print $form->formconfirm('card.php?id='.$payment->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete', '', 0, 2);
|
||||
}
|
||||
|
||||
/*
|
||||
* Confirm validation of the payment
|
||||
*/
|
||||
if ($action == 'valide')
|
||||
{
|
||||
$facid = $_GET['facid'];
|
||||
print $form->formconfirm('card.php?id='.$payment->id.'&facid='.$facid, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide', '', 0, 2);
|
||||
}
|
||||
$linkback = '';
|
||||
$morehtmlref = '';
|
||||
$morehtmlright = '';
|
||||
|
||||
dol_banner_tab($payment, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright);
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
print '<table class="border centpercent">';
|
||||
|
||||
// Ref
|
||||
print '<tr><td class="titlefield">'.$langs->trans('Ref').'</td>';
|
||||
print '<td>';
|
||||
print $form->showrefnav($payment, 'id', '', 1, 'rowid', 'id');
|
||||
print '</td></tr>';
|
||||
|
||||
// Date
|
||||
print '<tr><td>'.$langs->trans('Date').'</td><td>'.dol_print_date($payment->datep, 'day').'</td></tr>';
|
||||
|
||||
@ -188,6 +145,8 @@ if (!empty($conf->banque->enabled))
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '</div>';
|
||||
|
||||
|
||||
/*
|
||||
* List of loans payed
|
||||
@ -262,20 +221,8 @@ print '</div>';
|
||||
/*
|
||||
* Actions buttons
|
||||
*/
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
/*
|
||||
if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION))
|
||||
{
|
||||
if ($user->socid == 0 && $payment->statut == 0 && $_GET['action'] == '')
|
||||
{
|
||||
if ($user->rights->facture->paiement)
|
||||
{
|
||||
print '<a class="butAction" href="card.php?id='.$_GET['id'].'&facid='.$objp->facid.'&action=valide">'.$langs->trans('Valid').'</a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if (empty($action) && !empty($user->rights->loan->delete))
|
||||
{
|
||||
|
||||
@ -272,14 +272,13 @@ if ($action == 'create')
|
||||
print '<input type="hidden" name="id" value="'.$chid.'">';
|
||||
print '<input type="hidden" name="chid" value="'.$chid.'">';
|
||||
print '<input type="hidden" name="line_id" value="'.$line_id.'">';
|
||||
print '<input type="hidden" name="remaindertopay" value="'.($total-$sumpaid).'">';
|
||||
print '<input type="hidden" name="remaindertopay" value="'.($total - $sumpaid).'">';
|
||||
print '<input type="hidden" name="action" value="add_payment">';
|
||||
|
||||
dol_fiche_head();
|
||||
dol_fiche_head();
|
||||
|
||||
print '<table cellspacing="0" class="border" width="100%" cellpadding="2">';
|
||||
|
||||
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Loan").'</td>';
|
||||
/*
|
||||
print '<table class="border centpercent">';
|
||||
|
||||
print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td colspan="2"><a href="'.DOL_URL_ROOT.'/loan/card.php?id='.$chid.'">'.$chid.'</a></td></tr>';
|
||||
if ($echance > 0)
|
||||
@ -295,13 +294,9 @@ if ($action == 'create')
|
||||
print '</tr>';
|
||||
|
||||
print '</table>';
|
||||
*/
|
||||
|
||||
print '<br>';
|
||||
|
||||
print '<table cellspacing="0" class="border" width="100%" cellpadding="2">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td colspan="3">'.$langs->trans("Payment").'</td>';
|
||||
print '</tr>';
|
||||
print '<table class="border centpercent">';
|
||||
|
||||
print '<tr><td class="titlefield fieldrequired">'.$langs->trans("Date").'</td><td colspan="2">';
|
||||
if (empty($datepaid))
|
||||
@ -310,7 +305,6 @@ if ($action == 'create')
|
||||
else $datepayment = $datepaid;
|
||||
print $form->selectDate($datepayment, '', '', '', '', "add_payment", 1, 1);
|
||||
print "</td>";
|
||||
|
||||
print '</tr>';
|
||||
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td colspan="2">';
|
||||
@ -321,14 +315,15 @@ if ($action == 'create')
|
||||
print '<tr>';
|
||||
print '<td class="fieldrequired">'.$langs->trans('AccountToDebit').'</td>';
|
||||
print '<td colspan="2">';
|
||||
$form->select_comptes(isset($_POST["accountid"])?$_POST["accountid"]:$loan->accountid, "accountid", 0, 'courant = '.Account::TYPE_CURRENT, 1); // Show opend bank account list
|
||||
$form->select_comptes(GETPOSTISSET("accountid") ? GETPOST("accountid", 'int') : $loan->accountid, "accountid", 0, 'courant = '.Account::TYPE_CURRENT, 1); // Show opend bank account list
|
||||
print '</td></tr>';
|
||||
|
||||
// Number
|
||||
print '<tr><td>'.$langs->trans('Numero');
|
||||
print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
|
||||
print '</td>';
|
||||
print '<td colspan="2"><input name="num_payment" type="text" value="'.GETPOST('num_payment', 'alphanohtml').'"></td></tr>'."\n";
|
||||
print '<td colspan="2"><input name="num_payment" type="text" value="'.GETPOST('num_payment', 'alphanohtml').'"></td>'."\n";
|
||||
print "</tr>";
|
||||
|
||||
print '<tr>';
|
||||
print '<td class="tdtop">'.$langs->trans("NotePrivate").'</td>';
|
||||
@ -344,6 +339,7 @@ if ($action == 'create')
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td class="left">'.$langs->trans("DateDue").'</td>';
|
||||
|
||||
@ -376,7 +376,7 @@ if ((!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && !empty($conf->gl
|
||||
// Check all cases that need a token (all POST actions, all actions and mass actions on pages with CSRFCHECK_WITH_TOKEN set, all sensitive GET actions)
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST' ||
|
||||
((GETPOSTISSET('action') || GETPOSTISSET('massaction')) && defined('CSRFCHECK_WITH_TOKEN')) ||
|
||||
in_array(GETPOST('action', 'aZ09'), array('add', 'addtimespent', 'update', 'install', 'delete', 'deleteprof', 'deletepayment', 'confirm_create_user', 'confirm_create_thirdparty')))
|
||||
in_array(GETPOST('action', 'aZ09'), array('add', 'addtimespent', 'update', 'install', 'delete', 'deleteprof', 'deletepayment', 'confirm_create_user', 'confirm_create_thirdparty', 'confirm_reject_check')))
|
||||
{
|
||||
if (!GETPOSTISSET('token')) {
|
||||
if (GETPOST('uploadform', 'int')) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user