diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 5d0df32cd3e..437516df50b 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -42,11 +42,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/paymentsocialcontribution.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; +require_once DOL_DOCUMENT_ROOT.'/don/class/paymentdonation.class.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; @@ -369,12 +371,14 @@ $userstatic = new User($db); $chargestatic = new ChargeSociales($db); $loanstatic = new Loan($db); $memberstatic = new Adherent($db); +$donstatic = new Don($db); $paymentstatic = new Paiement($db); $paymentsupplierstatic = new PaiementFourn($db); +$paymentscstatic = new PaymentSocialContribution($db); $paymentvatstatic = new TVA($db); $paymentsalstatic = new PaymentSalary($db); +$paymentdonationstatic = new PaymentDonation($db); $paymentvariousstatic = new PaymentVarious($db); -$donstatic = new Don($db); $paymentexpensereportstatic = new PaymentExpenseReport($db); $bankstatic = new Account($db); $banklinestatic = new AccountLine($db); @@ -1199,10 +1203,10 @@ if ($resql) print ' '.$paymentsupplierstatic->getNomUrl(2); } elseif ($links[$key]['type'] == 'payment_sc') { - print ''; - print ' '.img_object($langs->trans('ShowPayment'), 'payment').' '; - //print $langs->trans("SocialContributionPayment"); - print ''; + $paymentscstatic->id = $links[$key]['url_id']; + $paymentscstatic->ref = $links[$key]['url_id']; + $paymentscstatic->label = $links[$key]['label']; + print ' '.$paymentscstatic->getNomUrl(2); } elseif ($links[$key]['type'] == 'payment_vat') { $paymentvatstatic->id = $links[$key]['url_id']; @@ -1212,6 +1216,7 @@ if ($resql) { $paymentsalstatic->id = $links[$key]['url_id']; $paymentsalstatic->ref = $links[$key]['url_id']; + $paymentsalstatic->label = $links[$key]['label']; print ' '.$paymentsalstatic->getNomUrl(2); } elseif ($links[$key]['type'] == 'payment_loan') { @@ -1220,9 +1225,9 @@ if ($resql) print ''; } elseif ($links[$key]['type'] == 'payment_donation') { - print ''; - print ' '.img_object($langs->trans('ShowPayment'), 'payment').' '; - print ''; + $paymentdonationstatic->id = $links[$key]['url_id']; + $paymentdonationstatic->ref = $links[$key]['url_id']; + print ' '.$paymentdonationstatic->getNomUrl(2); } elseif ($links[$key]['type'] == 'payment_expensereport') { $paymentexpensereportstatic->id = $links[$key]['url_id']; diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index c4e8313faa4..6f3074262a2 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -680,7 +680,21 @@ class PaymentSocialContribution extends CommonObject $result = ''; if (empty($this->ref)) $this->ref = $this->lib; - $label = $langs->trans("Payment").': '.$this->ref; + + $label = img_picto('', $this->picto).' '.$langs->trans("SocialContributionPayment").''; + $label .= '
'.$langs->trans('Ref').': '.$this->ref; + if (!empty($this->label)) { + $labeltoshow = $this->label; + $reg = array(); + if (preg_match('/^\((.*)\)$/i', $this->label, $reg)) + { + // Label generique car entre parentheses. On l'affiche en le traduisant + if ($reg[1] == 'paiement') $reg[1] = 'Payment'; + $labeltoshow = $langs->trans($reg[1]); + } + $label .= '
'.$langs->trans('Label').': '.$labeltoshow; + } + if ($this->date) $label .= '
'.$langs->trans('Date').': '.dol_print_date($this->date, 'day'); if (!empty($this->id)) { $link = ''; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 27309ac811e..5d6771d88df 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -8248,8 +8248,11 @@ abstract class CommonObject $this->db->begin(); + $statusfield = 'status'; + if ($this->element == 'don' || $this->element == 'donation') $statusfield = 'fk_statut'; + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; - $sql .= " SET status = ".$status; + $sql .= " SET ".$statusfield." = ".((int) $status); $sql .= " WHERE rowid = ".$this->id; if ($this->db->query($sql)) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 923334208d0..19d9c039736 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3190,7 +3190,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ '1downarrow', '1uparrow', '1leftarrow', '1rightarrow', '1uparrow_selected', '1downarrow_selected', '1leftarrow_selected', '1rightarrow_selected', 'accountancy', 'account', 'accountline', 'action', 'add', 'address', 'bank_account', 'barcode', 'bank', 'bill', 'bookmark', 'bom', 'building', 'cash-register', 'category', 'check', 'clock', 'close_title', 'company', 'contact', 'contract', 'cubes', - 'delete', 'dolly', 'dollyrevert', 'edit', 'ellipsis-h', 'email', 'external-link-alt', 'external-link-square-alt', + 'delete', 'dolly', 'dollyrevert', 'donation', 'edit', 'ellipsis-h', 'email', 'external-link-alt', 'external-link-square-alt', 'filter', 'file-code', 'file-export', 'file-import', 'file-upload', 'folder', 'folder-open', 'globe', 'globe-americas', 'grip', 'grip_title', 'group', 'help', 'holiday', 'intervention', 'label', 'language', 'list', 'listlight', 'lot', diff --git a/htdocs/don/card.php b/htdocs/don/card.php index 60890d2e005..cec185e757e 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -49,7 +49,9 @@ $langs->loadLangs(array("bills", "companies", "donations")); $id = GETPOST('rowid') ?GETPOST('rowid', 'int') : GETPOST('id', 'int'); $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'alpha'); -$amount = GETPOST('amount'); +$confirm = GETPOST('confirm', 'alpha'); + +$amount = price2num(GETPOST('amount', 'alphanohtml'), 'MT'); $donation_date = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); $projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0); @@ -65,14 +67,52 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('doncard', 'globalcard')); +$upload_dir = $conf->don->dir_output; +$permissiontoadd = $user->rights->don->creer; + /* * Actions */ +$parameters = array(); + $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +// Action reopen object +if ($action == 'confirm_reopen' && $confirm == 'yes' && $permissiontoadd) +{ + $object->fetch($id); + + $result = $object->reopen($user); + if ($result >= 0) + { + // Define output language + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + if (method_exists($object, 'generateDocument')) { + $outputlangs = $langs; + $newlang = ''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; + if (!empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + $model = $object->model_pdf; + $ret = $object->fetch($id); // Reload to get new records + + $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + } + + header("Location: ".$_SERVER["PHP_SELF"].'?id='.$object->id); + exit; + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } +} + if ($action == 'update') { if (!empty($cancel)) @@ -240,8 +280,6 @@ if ($action == 'set_paid') } // Actions to build doc -$upload_dir = $conf->don->dir_output; -$permissiontoadd = $user->rights->don->creer; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; @@ -784,20 +822,26 @@ if (!empty($id) && $action != 'edit') print '
'; + // Re-open + if ($permissiontoadd && $object->statut == $object::STATUS_CANCELED) + { + print ''.$langs->trans("ReOpen").''; + } + print '
id.'">'.$langs->trans('Modify').'
'; - if ($object->statut == 0) + if ($object->statut == $object::STATUS_DRAFT) { print '
'.$langs->trans("ValidPromess").'
'; } - if (($object->statut == 0 || $object->statut == 1) && $totalpaid == 0 && $object->paid == 0) + if (($object->statut == $object::STATUS_DRAFT || $object->statut == $object::STATUS_VALIDATED) && $totalpaid == 0 && $object->paid == 0) { print '
'.$langs->trans("ClassifyCanceled")."
"; } // Create payment - if ($object->statut == 1 && $object->paid == 0 && $user->rights->don->creer) + if ($object->statut == $object::STATUS_VALIDATED && $object->paid == 0 && $user->rights->don->creer) { if ($remaintopay == 0) { @@ -808,7 +852,7 @@ if (!empty($id) && $action != 'edit') } // Classify 'paid' - if ($object->statut == 1 && round($remaintopay) == 0 && $object->paid == 0 && $user->rights->don->creer) + if ($object->statut == $object::STATUS_VALIDATED && round($remaintopay) == 0 && $object->paid == 0 && $user->rights->don->creer) { print '
'.$langs->trans("ClassifyPaid")."
"; } @@ -816,7 +860,7 @@ if (!empty($id) && $action != 'edit') // Delete if ($user->rights->don->supprimer) { - if ($object->statut == -1 || $object->statut == 0) + if ($object->statut == $object::STATUS_CANCELED || $object->statut == $object::STATUS_DRAFT) { print '
'.$langs->trans("Delete")."
"; } else { diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index 7479dd3ce7c..bb4f0717a5a 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -818,6 +818,31 @@ class Don extends CommonObject } } + /** + * Set cancel status + * + * @param User $user Object user that modify + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @return int <0 if KO, 0=Nothing done, >0 if OK + */ + public function reopen($user, $notrigger = 0) + { + // Protection + if ($this->statut != self::STATUS_CANCELED) + { + return 0; + } + + /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bom->write)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bom->bom_advance->validate)))) + { + $this->error='Permission denied'; + return -1; + }*/ + + return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'DON_REOPEN'); + } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Sum of donations @@ -900,6 +925,7 @@ class Don extends CommonObject $label = img_picto('', $this->picto).' '.$langs->trans("Donation").''; if (!empty($this->id)) { $label .= '
'.$langs->trans('Ref').': '.$this->id; + $label .= '
'.$langs->trans('Date').': '.dol_print_date($this->date, 'day'); } if ($moretitle) $label .= ' - '.$moretitle; diff --git a/htdocs/don/class/paymentdonation.class.php b/htdocs/don/class/paymentdonation.class.php index fdfe177f9eb..710e21f76b7 100644 --- a/htdocs/don/class/paymentdonation.class.php +++ b/htdocs/don/class/paymentdonation.class.php @@ -622,8 +622,8 @@ class PaymentDonation extends CommonObject * Return clicable name (with picto eventually) * * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto - * @param int $maxlen Longueur max libelle - * @return string Chaine avec URL + * @param int $maxlen Max length + * @return string String with URL */ public function getNomUrl($withpicto = 0, $maxlen = 0) { @@ -631,7 +631,9 @@ class PaymentDonation extends CommonObject $result = ''; - $label = $langs->trans("ShowPayment").': '.$this->ref; + $label = ''.$langs->trans("DonationPayment").''; + $label .= '
'; + $label .= ''.$langs->trans('Ref').': '.$this->ref; if (!empty($this->id)) { diff --git a/htdocs/don/payment/card.php b/htdocs/don/payment/card.php index 9d4bc3ac268..c7c16ee970b 100644 --- a/htdocs/don/payment/card.php +++ b/htdocs/don/payment/card.php @@ -30,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; if (!empty($conf->banque->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page -$langs->loadLangs(array("bills", "banks", "companies")); +$langs->loadLangs(array("bills", "banks", "companies", "donations")); // Security check $id = GETPOST('rowid') ? GETPOST('rowid', 'int') : GETPOST('id', 'int'); @@ -70,6 +70,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->don->supp } + /* * View */ @@ -81,6 +82,7 @@ $form = new Form($db); $h = 0; +$head = array(); $head[$h][0] = DOL_URL_ROOT.'/don/payment/card.php?id='.$id; $head[$h][1] = $langs->trans("DonationPayment"); $hselected = $h; @@ -111,7 +113,7 @@ print ''.$langs->trans('Date').''.dol_print_ print ''.$langs->trans('Mode').''.$langs->trans("PaymentType".$object->type_code).''; // Number -print ''.$langs->trans('Number').''.$object->num_payment.''; +print ''.$langs->trans('Numero').''.$object->num_payment.''; // Amount print ''.$langs->trans('Amount').''.price($object->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).''; diff --git a/htdocs/salaries/class/paymentsalary.class.php b/htdocs/salaries/class/paymentsalary.class.php index 0a50ed00718..6aee986396b 100644 --- a/htdocs/salaries/class/paymentsalary.class.php +++ b/htdocs/salaries/class/paymentsalary.class.php @@ -578,9 +578,19 @@ class PaymentSalary extends CommonObject $result = ''; - $label = ''.$langs->trans("ShowSalaryPayment").''; - $label .= '
'; - $label .= ''.$langs->trans('Ref').': '.$this->ref; + $label = img_picto('', $this->picto).' '.$langs->trans("SalaryPayment").''; + $label .= '
'.$langs->trans('Ref').': '.$this->ref; + if (!empty($this->label)) { + $labeltoshow = $this->label; + $reg = array(); + if (preg_match('/^\((.*)\)$/i', $this->label, $reg)) + { + // Label generique car entre parentheses. On l'affiche en le traduisant + if ($reg[1] == 'paiement') $reg[1] = 'Payment'; + $labeltoshow = $langs->trans($reg[1]); + } + $label .= '
'.$langs->trans('Label').': '.$labeltoshow; + } $url = DOL_URL_ROOT.'/salaries/card.php?id='.$this->id;