--- /tmp/dsg/dolibarr/htdocs/don/payment/github_19.0.3_card.php
+++ /tmp/dsg/dolibarr/htdocs/don/payment/client_card.php
@@ -25 +24,0 @@
-// Load Dolibarr environment
@@ -31,3 +30 @@
-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';
@@ -36 +33 @@
-$langs->loadLangs(array("bills", "banks", "companies", "donations"));
+$langs->loadLangs(array("bills", "banks", "companies"));
@@ -39 +36 @@
-$id = GETPOST('rowid') ? GETPOST('rowid', 'int') : GETPOST('id', 'int');
+$id = GETPOST('rowid') ?GETPOST('rowid', 'int') : GETPOST('id', 'int');
@@ -41,4 +38,2 @@
-$confirm = GETPOST('confirm', 'alpha');
-if ($user->socid) {
- $socid = $user->socid;
-}
+$confirm = GETPOST('confirm');
+if ($user->socid) $socid = $user->socid;
@@ -49 +44,2 @@
-if ($id > 0) {
+if ($id > 0)
+{
@@ -51,3 +47 @@
- if (!$result) {
- dol_print_error($db, 'Failed to get payment id '.$id);
- }
+ if (!$result) dol_print_error($db, 'Failed to get payment id '.$id);
@@ -62 +56,2 @@
-if ($action == 'confirm_delete' && $confirm == 'yes' && $user->hasRight('don', 'supprimer')) {
+if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->don->supprimer)
+{
@@ -66 +61,22 @@
- if ($result > 0) {
+ if ($result > 0)
+ {
+ $db->commit();
+ header("Location: ".DOL_URL_ROOT."/don/index.php");
+ exit;
+ }
+ else
+ {
+ setEventMessages($object->error, $object->errors, 'errors');
+ $db->rollback();
+ }
+}
+
+// Create payment
+if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->don->creer)
+{
+ $db->begin();
+
+ $result = $object->valide();
+
+ if ($result > 0)
+ {
@@ -68 +84,19 @@
- header("Location: ".DOL_URL_ROOT."/don/index.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);
@@ -70 +104,3 @@
- } else {
+ }
+ else
+ {
@@ -77 +112,0 @@
-
@@ -89 +123,0 @@
-$head = array();
@@ -95 +129 @@
-print dol_get_fiche_head($head, $hselected, $langs->trans("DonationPayment"), -1, 'payment');
+dol_fiche_head($head, $hselected, $langs->trans("DonationPayment"), -1, 'payment');
@@ -100 +134,2 @@
-if ($action == 'delete') {
+if ($action == 'delete')
+{
@@ -101,0 +137,9 @@
+}
+
+/*
+ * Confirm validation of the payment
+ */
+if ($action == 'valide')
+{
+ $facid = GETPOST('facid', 'int');
+ print $form->formconfirm('card.php?id='.$object->id.'&facid='.$facid, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide', '', 0, 2);
@@ -111,0 +156,7 @@
+// Ref
+/*print '
';
+print $form->showrefnav($object,'id','',1,'rowid','id');
+print ' |
';
+*/
+
@@ -119 +170 @@
-print ''.$langs->trans('Numero').' | '.dol_escape_htmltag($object->num_payment).' |
';
+print ''.$langs->trans('Number').' | '.$object->num_payment.' |
';
@@ -125 +176 @@
-print ''.$langs->trans('Note').' | '.dol_string_onlythesehtmltags(dol_htmlcleanlastbr($object->note_public)).' |
';
+print ''.$langs->trans('Note').' | '.nl2br($object->note_public).' |
';
@@ -128,7 +179,9 @@
-if (isModEnabled("banque")) {
- if ($object->bank_account) {
- $bankline = new AccountLine($db);
- $bankline->fetch($object->bank_line);
-
- print '';
- print ''.$langs->trans('BankTransactionLine').' | ';
+if (!empty($conf->banque->enabled))
+{
+ if ($object->bank_account)
+ {
+ $bankline = new AccountLine($db);
+ $bankline->fetch($object->bank_line);
+
+ print '
';
+ print ''.$langs->trans('BankTransactionLine').' | ';
@@ -137,3 +190,3 @@
- print '';
- print '
';
- }
+ print '';
+ print '';
+ }
@@ -154 +207 @@
-$sql .= ' AND pd.rowid = '.((int) $id);
+$sql .= ' AND pd.rowid = '.$id;
@@ -158 +211,2 @@
-if ($resql) {
+if ($resql)
+{
@@ -166 +220 @@
- print ''.$langs->trans('ExpectedToPay').' | ';
+ print ''.$langs->trans('ExpectedToPay').' | ';
@@ -171,2 +225,4 @@
- if ($num > 0) {
- while ($i < $num) {
+ if ($num > 0)
+ {
+ while ($i < $num)
+ {
@@ -184,2 +240,2 @@
- print ''.$don->getLibStatut(4).' | ';
- // Amount paid
+ print ''.$don->getLibStatut(4, $objp->amount).' | ';
+ // Amount payed
@@ -189 +245 @@
- // If at least one invoice is paid, disable delete
+ // If at least one invoice is paid, disable delete
@@ -200 +256,3 @@
-} else {
+}
+else
+{
@@ -206 +264 @@
-print dol_get_fiche_end();
+dol_fiche_end();
@@ -214,6 +272,24 @@
-if (empty($action)) {
- if ($user->hasRight('don', 'supprimer')) {
- if (!$disable_delete) {
- print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), '', 1);
- } else {
- print dolGetButtonAction($langs->trans("CantRemovePaymentWithOneInvoicePaid"), $langs->trans('Delete'), '', $_SERVER["PHP_SELF"].'?id='.$object->id.'#', '', 1, [ 'attr' => ['classOverride' => 'butActionRefused']]);
+/*
+if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION))
+{
+ if ($user->socid == 0 && $object->statut == 0 && $_GET['action'] == '')
+ {
+ if ($user->rights->facture->paiement)
+ {
+ print ''.$langs->trans('Valid').'';
+ }
+ }
+}
+*/
+
+if (empty($action))
+{
+ if ($user->rights->don->supprimer)
+ {
+ if (!$disable_delete)
+ {
+ print ''.$langs->trans('Delete').'';
+ }
+ else
+ {
+ print ''.$langs->trans('Delete').'';
--- /tmp/dsg/dolibarr/htdocs/don/payment/github_19.0.3_payment.php
+++ /tmp/dsg/dolibarr/htdocs/don/payment/client_payment.php
@@ -25 +24,0 @@
-// Load Dolibarr environment
@@ -33 +32 @@
-$chid = GETPOST("rowid", 'int');
+$chid = GETPOST("rowid");
@@ -36 +34,0 @@
-$cancel = GETPOST('cancel');
@@ -51 +49,2 @@
-if ($action == 'add_payment') {
+if ($action == 'add_payment')
+{
@@ -54 +53,2 @@
- if ($cancel) {
+ if ($_POST["cancel"])
+ {
@@ -60,3 +60,4 @@
- $datepaid = dol_mktime(12, 0, 0, GETPOST("remonth"), GETPOST("reday"), GETPOST("reyear"));
-
- if (!(GETPOST("paymenttype") > 0)) {
+ $datepaid = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
+
+ if (!$_POST["paymenttype"] > 0)
+ {
@@ -66 +67,2 @@
- if ($datepaid == '') {
+ if ($datepaid == '')
+ {
@@ -70,6 +72,8 @@
- if (isModEnabled("banque") && !(GETPOST("accountid", 'int') > 0)) {
- setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountToCredit")), null, 'errors');
- $error++;
- }
-
- if (!$error) {
+ if (!empty($conf->banque->enabled) && !$_POST["accountid"] > 0)
+ {
+ setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountToCredit")), null, 'errors');
+ $error++;
+ }
+
+ if (!$error)
+ {
@@ -79,2 +83,4 @@
- foreach ($_POST as $key => $value) {
- if (substr($key, 0, 7) == 'amount_') {
+ foreach ($_POST as $key => $value)
+ {
+ if (substr($key, 0, 7) == 'amount_')
+ {
@@ -82 +88 @@
- $amounts[$other_chid] = price2num(GETPOST($key));
+ $amounts[$other_chid] = price2num($_POST[$key]);
@@ -86,45 +92,54 @@
- if (count($amounts) <= 0) {
- $error++;
- $errmsg = 'ErrorNoPaymentDefined';
- setEventMessages($errmsg, null, 'errors');
- }
-
- if (!$error) {
- $db->begin();
-
- // Create a line of payments
- $payment = new PaymentDonation($db);
- $payment->chid = $chid;
- $payment->datep = $datepaid;
- $payment->amounts = $amounts; // Tableau de montant
- $payment->paymenttype = GETPOST("paymenttype", 'int');
- $payment->num_payment = GETPOST("num_payment", 'alphanohtml');
- $payment->note_public = GETPOST("note_public", 'restricthtml');
-
- if (!$error) {
- $paymentid = $payment->create($user);
- if ($paymentid < 0) {
- $errmsg = $payment->error;
- setEventMessages($errmsg, null, 'errors');
- $error++;
- }
- }
-
- if (!$error) {
- $result = $payment->addPaymentToBank($user, 'payment_donation', '(DonationPayment)', GETPOST('accountid', 'int'), '', '');
- if (!($result > 0)) {
- $errmsg = $payment->error;
- setEventMessages($errmsg, null, 'errors');
- $error++;
- }
- }
-
- if (!$error) {
- $db->commit();
- $loc = DOL_URL_ROOT.'/don/card.php?rowid='.$chid;
- header('Location: '.$loc);
- exit;
- } else {
- $db->rollback();
- }
- }
+ if (count($amounts) <= 0)
+ {
+ $error++;
+ $errmsg = 'ErrorNoPaymentDefined';
+ setEventMessages($errmsg, null, 'errors');
+ }
+
+ if (!$error)
+ {
+ $db->begin();
+
+ // Create a line of payments
+ $payment = new PaymentDonation($db);
+ $payment->chid = $chid;
+ $payment->datepaid = $datepaid;
+ $payment->amounts = $amounts; // Tableau de montant
+ $payment->paymenttype = GETPOST("paymenttype", 'int');
+ $payment->num_payment = GETPOST("num_payment", 'alphanohtml');
+ $payment->note_public = GETPOST("note_public", 'none');
+
+ if (!$error)
+ {
+ $paymentid = $payment->create($user);
+ if ($paymentid < 0)
+ {
+ $errmsg = $payment->error;
+ setEventMessages($errmsg, null, 'errors');
+ $error++;
+ }
+ }
+
+ if (!$error)
+ {
+ $result = $payment->addPaymentToBank($user, 'payment_donation', '(DonationPayment)', $_POST['accountid'], '', '');
+ if (!$result > 0)
+ {
+ $errmsg = $payment->error;
+ setEventMessages($errmsg, null, 'errors');
+ $error++;
+ }
+ }
+
+ if (!$error)
+ {
+ $db->commit();
+ $loc = DOL_URL_ROOT.'/don/card.php?rowid='.$chid;
+ header('Location: '.$loc);
+ exit;
+ }
+ else
+ {
+ $db->rollback();
+ }
+ }
@@ -148 +163 @@
-$sql .= " WHERE p.fk_donation = ".((int) $chid);
+$sql .= " WHERE p.fk_donation = ".$chid;
@@ -150 +165,2 @@
-if ($resql) {
+if ($resql)
+{
@@ -153 +169 @@
- $db->free($resql);
+ $db->free();
@@ -158 +174,2 @@
-if ($action == 'create') {
+if ($action == 'create')
+{
@@ -164,12 +180,0 @@
-
- if (!empty($conf->use_javascript_ajax)) {
- print "\n".''."\n";
- }
@@ -183 +188 @@
- print dol_get_fiche_head();
+ dol_fiche_head();
@@ -188,2 +193,2 @@
- $datepaid = dol_mktime(12, 0, 0, GETPOST("remonth"), GETPOST("reday"), GETPOST("reyear"));
- $datepayment = !getDolGlobalString('MAIN_AUTOFILL_DATE') ? (GETPOST("remonth") ? $datepaid : -1) : 0;
+ $datepaid = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
+ $datepayment = empty($conf->global->MAIN_AUTOFILL_DATE) ? (empty($_POST["remonth"]) ?-1 : $datepaid) : 0;
@@ -195 +200 @@
- $form->select_types_paiements(GETPOSTISSET("paymenttype") ? GETPOST("paymenttype") : $object->fk_typepayment, "paymenttype");
+ $form->select_types_paiements(GETPOSTISSET("paymenttype") ? GETPOST("paymenttype") : $object->paymenttype, "paymenttype");
@@ -202 +207 @@
- $form->select_comptes(GETPOSTISSET("accountid") ? GETPOST("accountid") : "0", "accountid", 0, '', 2); // Show open bank account list
+ $form->select_comptes(GETPOSTISSET("accountid") ? GETPOST("accountid") : $object->accountid, "accountid", 0, '', 1); // Show open bank account list
@@ -218 +223 @@
- print dol_get_fiche_end();
+ dol_fiche_end();
@@ -221 +226 @@
- * List of payments on donation
+ * List of payments on donation
@@ -239 +244,2 @@
- while ($i < $num) {
+ while ($i < $num)
+ {
@@ -253 +259,2 @@
- if ($sumpaid < $objp->amount) {
+ if ($sumpaid < $objp->amount)
+ {
@@ -255,3 +261,0 @@
- if (!empty($conf->use_javascript_ajax)) {
- print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".price($objp->amount - $sumpaid)."'");
- }
@@ -259 +263,3 @@
- } else {
+ }
+ else
+ {
@@ -267 +273 @@
- $totalrecu+=$objp->am;*/ //Useless code ?
+ $totalrecu+=$objp->am;*/ //Useless code ?
@@ -280 +286 @@
- }*/ //Useless code ?
+ }*/ //Useless code ?
@@ -284 +290,5 @@
- print $form->buttonsSaveCancel();
+ print '
';
+ print '';
+ print ' ';
+ print '';
+ print '
';