--- /tmp/dsg/dolibarr/htdocs/compta/payment_sc/github_19.0.3_card.php +++ /tmp/dsg/dolibarr/htdocs/compta/payment_sc/client_card.php @@ -2,5 +2,4 @@ -/* Copyright (C) 2004 Rodolphe Quiedeville - * Copyright (C) 2004-2014 Laurent Destailleur - * Copyright (C) 2005 Marc Barilley / Ocebo - * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2022 Alexandre Spangaro +/* Copyright (C) 2004 Rodolphe Quiedeville + * Copyright (C) 2004-2014 Laurent Destailleur + * Copyright (C) 2005 Marc Barilley / Ocebo + * Copyright (C) 2005-2009 Regis Houssin @@ -24,6 +23,5 @@ - * \ingroup tax - * \brief Tab with payment of a social contribution - * \remarks File similar to fourn/paiement/card.php - */ - -// Load Dolibarr environment + * \ingroup facture + * \brief Onglet payment of a social contribution + * \remarks Fichier presque identique a fournisseur/paiement/card.php + */ + @@ -35,3 +33 @@ -if (isModEnabled("banque")) { - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; -} +if (!empty($conf->banque->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; @@ -45,4 +41,4 @@ -$confirm = GETPOST('confirm', 'aZ09'); -if ($user->socid) { - $socid = $user->socid; -} +$confirm = GETPOST('confirm'); +if ($user->socid) $socid = $user->socid; +// TODO ajouter regle pour restreindre acces paiement +//$result = restrictedArea($user, 'facture', $id,''); @@ -51 +47,2 @@ -if ($id > 0) { +if ($id > 0) +{ @@ -53,6 +50,2 @@ - if (!$result) { - dol_print_error($db, 'Failed to get payment id '.$id); - } -} - -$result = restrictedArea($user, 'payment_sc', $object, ''); + if (!$result) dol_print_error($db, 'Failed to get payment id '.$id); +} @@ -66 +59,2 @@ -if ($action == 'confirm_delete' && $confirm == 'yes' && $user->hasRight('tax', 'charges', 'supprimer')) { +if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->tax->charges->supprimer) +{ @@ -70 +64,23 @@ - if ($result > 0) { + if ($result > 0) + { + $db->commit(); + header("Location: ".DOL_URL_ROOT."/compta/sociales/payments.php?mode=sconly"); + exit; + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + $db->rollback(); + } +} + +// Validate social contribution +/* +if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->tax->charges->creer) +{ + $db->begin(); + + $result=$object->valide(); + + if ($result > 0) + { @@ -72 +88,19 @@ - header("Location: ".DOL_URL_ROOT."/compta/sociales/payments.php"); + + $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); @@ -74 +108,3 @@ - } else { + } + else + { @@ -79,10 +115 @@ - -/*if ($action == 'setdatep' && GETPOST('datepday') && $user->hasRight('tax', 'charges', 'creer')) { - $datepaye = dol_mktime(GETPOST('datephour', 'int'), GETPOST('datepmin', 'int'), GETPOST('datepsec', 'int'), GETPOST('datepmonth', 'int'), GETPOST('datepday', 'int'), GETPOST('datepyear', 'int')); - $res = $object->update_date($datepaye); - if ($res === 0) { - setEventMessages($langs->trans('PaymentDateUpdateSucceeded'), null, 'mesgs'); - } else { - setEventMessages($langs->trans('PaymentDateUpdateFailed'), null, 'errors'); - } -}*/ +*/ @@ -114 +141 @@ -print dol_get_fiche_head($head, $hselected, $langs->trans("PaymentSocialContribution"), -1, 'payment'); +dol_fiche_head($head, $hselected, $langs->trans("PaymentSocialContribution"), -1, 'payment'); @@ -119 +146,2 @@ -if ($action == 'delete') { +if ($action == 'delete') +{ @@ -121,0 +150,13 @@ + +/* + * 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); + +} +*/ + @@ -132,0 +174,6 @@ +// Ref +/*print ''.$langs->trans('Ref').''; +print ''; +print $form->showrefnav($object,'id','',1,'rowid','id'); +print '';*/ + @@ -134 +181 @@ -print ''.$langs->trans('Date').''.dol_print_date($object->datep, 'day').''; +print ''.$langs->trans('Date').''.dol_print_date($object->datep, 'day').''; @@ -137 +184 @@ -print ''.$langs->trans('Mode').''.$langs->trans("PaymentType".$object->type_code).''; +print ''.$langs->trans('Mode').''.$langs->trans("PaymentType".$object->type_code).''; @@ -140,4 +187,4 @@ -print ''.$langs->trans('Numero').''.dol_escape_htmltag($object->num_payment).''; - -// Amount -print ''.$langs->trans('Amount').''.price($object->amount, 0, $langs, 1, -1, -1, $conf->currency).''; +print ''.$langs->trans('Numero').''.$object->num_paiement.''; + +// Montant +print ''.$langs->trans('Amount').''.price($object->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).''; @@ -146 +193 @@ -print ''.$langs->trans('Note').''.dol_string_onlythesehtmltags(dol_htmlcleanlastbr($object->note_private)).''; +print ''.$langs->trans('Note').''.nl2br($object->note).''; @@ -149,8 +196,10 @@ -if (isModEnabled("banque")) { - if ($object->bank_account) { - $bankline = new AccountLine($db); - $bankline->fetch($object->bank_line); - - print ''; - print ''.$langs->trans('BankTransactionLine').''; - print ''; +if (!empty($conf->banque->enabled)) +{ + if ($object->bank_account) + { + $bankline = new AccountLine($db); + $bankline->fetch($object->bank_line); + + print ''; + print ''.$langs->trans('BankTransactionLine').''; + print ''; @@ -158,3 +207,3 @@ - print ''; - print ''; - } + print ''; + print ''; + } @@ -167,5 +216,5 @@ -print dol_get_fiche_end(); - - -/* - * List of social contributions paid +dol_fiche_end(); + + +/* + * List of social contributions payed @@ -179 +228 @@ -$sql .= ' AND pf.rowid = '.((int) $object->id); +$sql .= ' AND pf.rowid = '.$object->id; @@ -183 +232,2 @@ -if ($resql) { +if ($resql) +{ @@ -191 +241 @@ - print ''.$langs->trans('Type').''; + print ''.$langs->trans('Type').''; @@ -198,2 +248,4 @@ - if ($num > 0) { - while ($i < $num) { + if ($num > 0) + { + while ($i < $num) + { @@ -209,4 +261,4 @@ - print ''; - print $socialcontrib->type_label; - /*print $socialcontrib->type;*/ - print "\n"; + print ''; + print $socialcontrib->type_label; + /*print $socialcontrib->type;*/ + print "\n"; @@ -216 +268 @@ - print ''.price($objp->sc_amount).''; + print ''.price($objp->sc_amount).''; @@ -219,2 +271,2 @@ - // Amount paid - print ''.price($objp->amount).''; + // Amount payed + print ''.price($objp->amount).''; @@ -222 +274,2 @@ - if ($objp->paye == 1) { // If at least one invoice is paid, disable delete + if ($objp->paye == 1) // If at least one invoice is paid, disable delete + { @@ -233 +286,3 @@ -} else { +} +else +{ @@ -240 +295 @@ - * Actions Buttons + * Boutons Actions @@ -245 +300 @@ -if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) +if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) @@ -249,2 +304,3 @@ - if ($user->hasRight('facture', 'paiement')){ - print ''.$langs->trans('Valid').''; + if ($user->rights->facture->paiement) + { + print ''.$langs->trans('Valid').''; @@ -256,6 +312,11 @@ -if ($action == '') { - if ($user->hasRight('tax', 'charges', 'supprimer')) { - if (!$disable_delete) { - print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', 1); - } else { - print dolGetButtonAction($langs->trans("CantRemovePaymentWithOneInvoicePaid"), $langs->trans("Delete"), 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', 0); +if ($action == '') +{ + if ($user->rights->tax->charges->supprimer) + { + if (!$disable_delete) + { + print ''.$langs->trans('Delete').''; + } + else + { + print ''.$langs->trans('Delete').'';