--- /tmp/dsg/dolibarr/htdocs/compta/payment_sc/github_card.php +++ /tmp/dsg/dolibarr/htdocs/compta/payment_sc/client_card.php @@ -20,9 +20,9 @@ /** * \file htdocs/compta/payment_sc/card.php - * \ingroup tax - * \brief Tab with payment of a social contribution - * \remarks File similar to fourn/paiement/card.php + * \ingroup facture + * \brief Onglet payment of a social contribution + * \remarks Fichier presque identique a fournisseur/paiement/card.php */ require '../../main.inc.php'; @@ -38,7 +38,7 @@ // Security check $id = GETPOST("id", 'int'); $action = GETPOST('action', 'aZ09'); -$confirm = GETPOST('confirm', 'aZ09'); +$confirm = GETPOST('confirm'); if ($user->socid) $socid = $user->socid; // TODO ajouter regle pour restreindre acces paiement //$result = restrictedArea($user, 'facture', $id,''); @@ -63,14 +63,56 @@ $result = $object->delete($user); 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) + { $db->commit(); - 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); exit; - } else { + } + else + { setEventMessages($object->error, $object->errors, 'errors'); $db->rollback(); } } +*/ /* @@ -96,7 +138,7 @@ */ -print dol_get_fiche_head($head, $hselected, $langs->trans("PaymentSocialContribution"), -1, 'payment'); +dol_fiche_head($head, $hselected, $langs->trans("PaymentSocialContribution"), -1, 'payment'); /* * Deletion confirmation of payment @@ -105,6 +147,19 @@ { 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 = ''.$langs->trans("BackToList").''; @@ -129,9 +184,9 @@ print ''.$langs->trans('Mode').''.$langs->trans("PaymentType".$object->type_code).''; // Numero -print ''.$langs->trans('Numero').''.$object->num_payment.''; - -// Amount +print ''.$langs->trans('Numero').''.$object->num_paiement.''; + +// Montant print ''.$langs->trans('Amount').''.price($object->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).''; // Note @@ -140,29 +195,29 @@ // Bank account if (!empty($conf->banque->enabled)) { - if ($object->bank_account) - { - $bankline = new AccountLine($db); - $bankline->fetch($object->bank_line); - - print ''; - print ''.$langs->trans('BankTransactionLine').''; + if ($object->bank_account) + { + $bankline = new AccountLine($db); + $bankline->fetch($object->bank_line); + + print ''; + print ''.$langs->trans('BankTransactionLine').''; print ''; print $bankline->getNomUrl(1, 0, 'showall'); - print ''; - print ''; - } + print ''; + print ''; + } } print ''; print ''; -print dol_get_fiche_end(); - - -/* - * List of social contributions paid +dol_fiche_end(); + + +/* + * List of social contributions payed */ $disable_delete = 0; @@ -183,7 +238,7 @@ print '
'; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -203,17 +258,17 @@ print $socialcontrib->getNomUrl(1); print "\n"; // Type - print '\n"; + print '\n"; // Label print ''; // Expected to pay print ''; // Status print ''; - // Amount paid + // Amount payed print ''; print "\n"; if ($objp->paye == 1) // If at least one invoice is paid, disable delete @@ -228,14 +283,16 @@ print "
'.$langs->trans('SocialContribution').''.$langs->trans('Type').''.$langs->trans('Type').''.$langs->trans('Label').''.$langs->trans('ExpectedToPay').''.$langs->trans('Status').''; - print $socialcontrib->type_label; - /*print $socialcontrib->type;*/ - print "'; + print $socialcontrib->type_label; + /*print $socialcontrib->type;*/ + print "'.$objp->label.''.price($objp->sc_amount).''.$socialcontrib->getLibStatut(4, $objp->amount).''.price($objp->amount).'
\n"; $db->free($resql); -} else { +} +else +{ dol_print_error($db); } /* - * Actions Buttons + * Boutons Actions */ print '
'; @@ -258,8 +315,10 @@ { if (!$disable_delete) { - print ''.$langs->trans('Delete').''; - } else { + print ''.$langs->trans('Delete').''; + } + else + { print ''.$langs->trans('Delete').''; } }