Debug and fix v13

This commit is contained in:
Laurent Destailleur 2020-11-03 14:19:54 +01:00
parent 97c5747455
commit b0e2d40533
9 changed files with 133 additions and 27 deletions

View File

@ -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.'/adherents/class/adherent.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.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/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.'/compta/tva/class/tva.class.php';
require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.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/bank/class/paymentvarious.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.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/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.'/expensereport/class/paymentexpensereport.class.php';
require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
@ -369,12 +371,14 @@ $userstatic = new User($db);
$chargestatic = new ChargeSociales($db); $chargestatic = new ChargeSociales($db);
$loanstatic = new Loan($db); $loanstatic = new Loan($db);
$memberstatic = new Adherent($db); $memberstatic = new Adherent($db);
$donstatic = new Don($db);
$paymentstatic = new Paiement($db); $paymentstatic = new Paiement($db);
$paymentsupplierstatic = new PaiementFourn($db); $paymentsupplierstatic = new PaiementFourn($db);
$paymentscstatic = new PaymentSocialContribution($db);
$paymentvatstatic = new TVA($db); $paymentvatstatic = new TVA($db);
$paymentsalstatic = new PaymentSalary($db); $paymentsalstatic = new PaymentSalary($db);
$paymentdonationstatic = new PaymentDonation($db);
$paymentvariousstatic = new PaymentVarious($db); $paymentvariousstatic = new PaymentVarious($db);
$donstatic = new Don($db);
$paymentexpensereportstatic = new PaymentExpenseReport($db); $paymentexpensereportstatic = new PaymentExpenseReport($db);
$bankstatic = new Account($db); $bankstatic = new Account($db);
$banklinestatic = new AccountLine($db); $banklinestatic = new AccountLine($db);
@ -1199,10 +1203,10 @@ if ($resql)
print ' '.$paymentsupplierstatic->getNomUrl(2); print ' '.$paymentsupplierstatic->getNomUrl(2);
} elseif ($links[$key]['type'] == 'payment_sc') } elseif ($links[$key]['type'] == 'payment_sc')
{ {
print '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/card.php?id='.$links[$key]['url_id'].'">'; $paymentscstatic->id = $links[$key]['url_id'];
print ' '.img_object($langs->trans('ShowPayment'), 'payment').' '; $paymentscstatic->ref = $links[$key]['url_id'];
//print $langs->trans("SocialContributionPayment"); $paymentscstatic->label = $links[$key]['label'];
print '</a>'; print ' '.$paymentscstatic->getNomUrl(2);
} elseif ($links[$key]['type'] == 'payment_vat') } elseif ($links[$key]['type'] == 'payment_vat')
{ {
$paymentvatstatic->id = $links[$key]['url_id']; $paymentvatstatic->id = $links[$key]['url_id'];
@ -1212,6 +1216,7 @@ if ($resql)
{ {
$paymentsalstatic->id = $links[$key]['url_id']; $paymentsalstatic->id = $links[$key]['url_id'];
$paymentsalstatic->ref = $links[$key]['url_id']; $paymentsalstatic->ref = $links[$key]['url_id'];
$paymentsalstatic->label = $links[$key]['label'];
print ' '.$paymentsalstatic->getNomUrl(2); print ' '.$paymentsalstatic->getNomUrl(2);
} elseif ($links[$key]['type'] == 'payment_loan') } elseif ($links[$key]['type'] == 'payment_loan')
{ {
@ -1220,9 +1225,9 @@ if ($resql)
print '</a>'; print '</a>';
} elseif ($links[$key]['type'] == 'payment_donation') } elseif ($links[$key]['type'] == 'payment_donation')
{ {
print '<a href="'.DOL_URL_ROOT.'/don/payment/card.php?id='.$links[$key]['url_id'].'">'; $paymentdonationstatic->id = $links[$key]['url_id'];
print ' '.img_object($langs->trans('ShowPayment'), 'payment').' '; $paymentdonationstatic->ref = $links[$key]['url_id'];
print '</a>'; print ' '.$paymentdonationstatic->getNomUrl(2);
} elseif ($links[$key]['type'] == 'payment_expensereport') } elseif ($links[$key]['type'] == 'payment_expensereport')
{ {
$paymentexpensereportstatic->id = $links[$key]['url_id']; $paymentexpensereportstatic->id = $links[$key]['url_id'];

View File

@ -680,7 +680,21 @@ class PaymentSocialContribution extends CommonObject
$result = ''; $result = '';
if (empty($this->ref)) $this->ref = $this->lib; if (empty($this->ref)) $this->ref = $this->lib;
$label = $langs->trans("Payment").': '.$this->ref;
$label = img_picto('', $this->picto).' <u>'.$langs->trans("SocialContributionPayment").'</u>';
$label .= '<br><b>'.$langs->trans('Ref').':</b> '.$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 .= '<br><b>'.$langs->trans('Label').':</b> '.$labeltoshow;
}
if ($this->date) $label .= '<br><b>'.$langs->trans('Date').':</b> '.dol_print_date($this->date, 'day');
if (!empty($this->id)) { if (!empty($this->id)) {
$link = '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/card.php?id='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; $link = '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/card.php?id='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';

View File

@ -8248,8 +8248,11 @@ abstract class CommonObject
$this->db->begin(); $this->db->begin();
$statusfield = 'status';
if ($this->element == 'don' || $this->element == 'donation') $statusfield = 'fk_statut';
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql .= " SET status = ".$status; $sql .= " SET ".$statusfield." = ".((int) $status);
$sql .= " WHERE rowid = ".$this->id; $sql .= " WHERE rowid = ".$this->id;
if ($this->db->query($sql)) if ($this->db->query($sql))

View File

@ -3190,7 +3190,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
'1downarrow', '1uparrow', '1leftarrow', '1rightarrow', '1uparrow_selected', '1downarrow_selected', '1leftarrow_selected', '1rightarrow_selected', '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', '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', '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', 'filter', 'file-code', 'file-export', 'file-import', 'file-upload', 'folder', 'folder-open', 'globe', 'globe-americas', 'grip', 'grip_title', 'group',
'help', 'holiday', 'help', 'holiday',
'intervention', 'label', 'language', 'list', 'listlight', 'lot', 'intervention', 'label', 'language', 'list', 'listlight', 'lot',

View File

@ -49,7 +49,9 @@ $langs->loadLangs(array("bills", "companies", "donations"));
$id = GETPOST('rowid') ?GETPOST('rowid', 'int') : GETPOST('id', 'int'); $id = GETPOST('rowid') ?GETPOST('rowid', 'int') : GETPOST('id', 'int');
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'alpha'); $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')); $donation_date = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
$projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0); $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 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('doncard', 'globalcard')); $hookmanager->initHooks(array('doncard', 'globalcard'));
$upload_dir = $conf->don->dir_output;
$permissiontoadd = $user->rights->don->creer;
/* /*
* Actions * Actions
*/ */
$parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some $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'); 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 ($action == 'update')
{ {
if (!empty($cancel)) if (!empty($cancel))
@ -240,8 +280,6 @@ if ($action == 'set_paid')
} }
// Actions to build doc // Actions to build doc
$upload_dir = $conf->don->dir_output;
$permissiontoadd = $user->rights->don->creer;
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
@ -784,20 +822,26 @@ if (!empty($id) && $action != 'edit')
print '<div class="tabsAction">'; print '<div class="tabsAction">';
// Re-open
if ($permissiontoadd && $object->statut == $object::STATUS_CANCELED)
{
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_reopen&confirm=yes&token='.newToken().'">'.$langs->trans("ReOpen").'</a>';
}
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&rowid='.$object->id.'">'.$langs->trans('Modify').'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&rowid='.$object->id.'">'.$langs->trans('Modify').'</a></div>';
if ($object->statut == 0) if ($object->statut == $object::STATUS_DRAFT)
{ {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=valid_promesse&token='.newToken().'">'.$langs->trans("ValidPromess").'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=valid_promesse&token='.newToken().'">'.$langs->trans("ValidPromess").'</a></div>';
} }
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 '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=set_cancel&token='.newToken().'">'.$langs->trans("ClassifyCanceled")."</a></div>"; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=set_cancel&token='.newToken().'">'.$langs->trans("ClassifyCanceled")."</a></div>";
} }
// Create payment // 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) if ($remaintopay == 0)
{ {
@ -808,7 +852,7 @@ if (!empty($id) && $action != 'edit')
} }
// Classify 'paid' // 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 '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=set_paid">'.$langs->trans("ClassifyPaid")."</a></div>"; print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=set_paid">'.$langs->trans("ClassifyPaid")."</a></div>";
} }
@ -816,7 +860,7 @@ if (!empty($id) && $action != 'edit')
// Delete // Delete
if ($user->rights->don->supprimer) if ($user->rights->don->supprimer)
{ {
if ($object->statut == -1 || $object->statut == 0) if ($object->statut == $object::STATUS_CANCELED || $object->statut == $object::STATUS_DRAFT)
{ {
print '<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?rowid='.$object->id.'&action=delete&token='.newToken().'">'.$langs->trans("Delete")."</a></div>"; print '<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?rowid='.$object->id.'&action=delete&token='.newToken().'">'.$langs->trans("Delete")."</a></div>";
} else { } else {

View File

@ -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 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Sum of donations * Sum of donations
@ -900,6 +925,7 @@ class Don extends CommonObject
$label = img_picto('', $this->picto).' <u>'.$langs->trans("Donation").'</u>'; $label = img_picto('', $this->picto).' <u>'.$langs->trans("Donation").'</u>';
if (!empty($this->id)) { if (!empty($this->id)) {
$label .= '<br><b>'.$langs->trans('Ref').':</b> '.$this->id; $label .= '<br><b>'.$langs->trans('Ref').':</b> '.$this->id;
$label .= '<br><b>'.$langs->trans('Date').':</b> '.dol_print_date($this->date, 'day');
} }
if ($moretitle) $label .= ' - '.$moretitle; if ($moretitle) $label .= ' - '.$moretitle;

View File

@ -622,8 +622,8 @@ class PaymentDonation extends CommonObject
* Return clicable name (with picto eventually) * Return clicable name (with picto eventually)
* *
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
* @param int $maxlen Longueur max libelle * @param int $maxlen Max length
* @return string Chaine avec URL * @return string String with URL
*/ */
public function getNomUrl($withpicto = 0, $maxlen = 0) public function getNomUrl($withpicto = 0, $maxlen = 0)
{ {
@ -631,7 +631,9 @@ class PaymentDonation extends CommonObject
$result = ''; $result = '';
$label = $langs->trans("ShowPayment").': '.$this->ref; $label = '<u>'.$langs->trans("DonationPayment").'</u>';
$label .= '<br>';
$label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
if (!empty($this->id)) if (!empty($this->id))
{ {

View File

@ -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'; if (!empty($conf->banque->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("bills", "banks", "companies")); $langs->loadLangs(array("bills", "banks", "companies", "donations"));
// Security check // Security check
$id = GETPOST('rowid') ? GETPOST('rowid', 'int') : GETPOST('id', 'int'); $id = GETPOST('rowid') ? GETPOST('rowid', 'int') : GETPOST('id', 'int');
@ -70,6 +70,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->don->supp
} }
/* /*
* View * View
*/ */
@ -81,6 +82,7 @@ $form = new Form($db);
$h = 0; $h = 0;
$head = array();
$head[$h][0] = DOL_URL_ROOT.'/don/payment/card.php?id='.$id; $head[$h][0] = DOL_URL_ROOT.'/don/payment/card.php?id='.$id;
$head[$h][1] = $langs->trans("DonationPayment"); $head[$h][1] = $langs->trans("DonationPayment");
$hselected = $h; $hselected = $h;
@ -111,7 +113,7 @@ print '<tr><td class="titlefield">'.$langs->trans('Date').'</td><td>'.dol_print_
print '<tr><td>'.$langs->trans('Mode').'</td><td>'.$langs->trans("PaymentType".$object->type_code).'</td></tr>'; print '<tr><td>'.$langs->trans('Mode').'</td><td>'.$langs->trans("PaymentType".$object->type_code).'</td></tr>';
// Number // Number
print '<tr><td>'.$langs->trans('Number').'</td><td>'.$object->num_payment.'</td></tr>'; print '<tr><td>'.$langs->trans('Numero').'</td><td>'.$object->num_payment.'</td></tr>';
// Amount // Amount
print '<tr><td>'.$langs->trans('Amount').'</td><td>'.price($object->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).'</td></tr>'; print '<tr><td>'.$langs->trans('Amount').'</td><td>'.price($object->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).'</td></tr>';

View File

@ -578,9 +578,19 @@ class PaymentSalary extends CommonObject
$result = ''; $result = '';
$label = '<u>'.$langs->trans("ShowSalaryPayment").'</u>'; $label = img_picto('', $this->picto).' <u>'.$langs->trans("SalaryPayment").'</u>';
$label .= '<br>'; $label .= '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
$label .= '<b>'.$langs->trans('Ref').':</b> '.$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 .= '<br><b>'.$langs->trans('Label').':</b> '.$labeltoshow;
}
$url = DOL_URL_ROOT.'/salaries/card.php?id='.$this->id; $url = DOL_URL_ROOT.'/salaries/card.php?id='.$this->id;