--- /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('SocialContribution').' | '; - print ''.$langs->trans('Type').' | '; + print ''.$langs->trans('Type').' | '; print ''.$langs->trans('Label').' | '; print ''.$langs->trans('ExpectedToPay').' | '; print ''.$langs->trans('Status').' | '; @@ -203,17 +258,17 @@ print $socialcontrib->getNomUrl(1); print "\n"; // Type - print ''; - print $socialcontrib->type_label; - /*print $socialcontrib->type;*/ - print " | \n"; + print ''; + print $socialcontrib->type_label; + /*print $socialcontrib->type;*/ + print " | \n"; // Label print ''.$objp->label.' | '; // Expected to pay print ''.price($objp->sc_amount).' | '; // Status print ''.$socialcontrib->getLibStatut(4, $objp->amount).' | '; - // Amount paid + // Amount payed print ''.price($objp->amount).' | '; print "