Merge branch '18.0' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2023-08-16 21:12:23 +02:00
commit d2f8b5dbfa
5 changed files with 74 additions and 27 deletions

View file

@ -521,11 +521,11 @@ if ($id > 0 || $ref) {
print '<td class="right">';
if ($obj->statut == 3) {
print '<b>'.$langs->trans("StatusRefused").'</b>';
print '<span class="error">'.$langs->trans("StatusRefused").'</span>';
} else {
if ($object->statut == BonPrelevement::STATUS_CREDITED) {
if ($obj->statut == 2) {
if ($user->rights->prelevement->bons->credit) {
if ($obj->statut == LignePrelevement::STATUS_CREDITED) {
if ($user->hasRight('prelevement', 'bons', 'credit')) {
//print '<a class="butActionDelete" href="line.php?action=rejet&id='.$obj->rowid.'">'.$langs->trans("StandingOrderReject").'</a>';
print '<a href="line.php?action=rejet&type='.$object->type.'&id='.$obj->rowid.'&token='.newToken().'">'.$langs->trans("StandingOrderReject").'</a>';
} else {

View file

@ -43,6 +43,12 @@ class LignePrelevement
public $statuts = array();
const STATUS_DRAFT = 0;
const STATUS_NOT_USED = 1;
const STATUS_CREDITED = 2; // STATUS_CREDITED and STATUS_DEBITED is same. Difference is in ->type
const STATUS_DEBITED = 2; // STATUS_CREDITED and STATUS_DEBITED is same. Difference is in ->type
const STATUS_REJECTED = 3;
/**
* Constructor

View file

@ -34,7 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
// Load translation files required by the page
$langs->loadLangs(array('banks', 'categories', 'bills', 'companies', 'withdrawals'));
$langs->loadLangs(array('banks', 'categories', 'bills', 'companies', 'withdrawals', 'suppliers'));
// Get supervariables
$id = GETPOST('id', 'int');
@ -231,7 +231,7 @@ if ($object->type != 'bank-transfer') {
if ($object->id > 0) {
$sql .= " AND p.rowid = ".((int) $object->id);
}
if ($socid) {
if ($socid > 0) {
$sql .= " AND s.rowid = ".((int) $socid);
}
$sql .= $db->order($sortfield, $sortorder);
@ -312,17 +312,17 @@ if ($resql) {
print '<tr class="oddeven">';
print "<td>";
print '<td class="nowraponall">';
print $invoicetmp->getNomUrl(1);
print "</td>\n";
if ($object->type == 'bank-transfer') {
print '<td>';
print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($invoicetmp->ref_supplier).'">';
print dol_escape_htmltag($invoicetmp->ref_supplier);
print "</td>\n";
}
print '<td>';
print '<td class="tdoverflowmax125">';
print $thirdpartytmp->getNomUrl(1);
print "</td>\n";
@ -344,7 +344,7 @@ if ($resql) {
print $langs->trans("StatusCredited");
}
} elseif ($obj->statut == 3) {
print '<b>'.$langs->trans("StatusRefused").'</b>';
print '<span class="error">'.$langs->trans("StatusRefused").'</span>';
}
print "</td>";

View file

@ -28,6 +28,9 @@
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/prelevement.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/rejetprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
@ -84,6 +87,12 @@ if ($type == 'bank-transfer') {
$form = new Form($db);
$thirdpartystatic = new Societe($db);
$invoicestatic = new Facture($db);
$invoicesupplierstatic = new FactureFournisseur($db);
$rej = new RejetPrelevement($db, $user, $type);
llxHeader('', $langs->trans("WithdrawalsReceipts"));
if ($id > 0 || $ref) {
@ -194,11 +203,8 @@ if ($id > 0 || $ref) {
}
$rej = new RejetPrelevement($db, $user, $type);
// List errors
/*
* List errors
*/
$sql = "SELECT pl.rowid, pl.amount, pl.statut";
$sql .= " , s.rowid as socid, s.nom as name";
$sql .= " , pr.motif, pr.afacturer, pr.fk_facture";
@ -208,7 +214,7 @@ $sql .= " , ".MAIN_DB_PREFIX."societe as s";
$sql .= " , ".MAIN_DB_PREFIX."prelevement_rejet as pr";
$sql .= " WHERE p.rowid=".((int) $object->id);
$sql .= " AND pl.fk_prelevement_bons = p.rowid";
$sql .= " AND p.entity = ".$conf->entity;
$sql .= " AND p.entity IN (".getEntity('facture').")";
$sql .= " AND pl.fk_soc = s.rowid";
$sql .= " AND pl.statut = 3 ";
$sql .= " AND pr.fk_prelevement_lignes = pl.rowid";
@ -234,14 +240,19 @@ $resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
print_barre_liste($langs->trans("Rejects"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '');
print_barre_liste($langs->trans("Rejects"), $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', $num, $nbtotalofrecords, '');
print"\n<!-- debut table -->\n";
print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Line").'</td><td>'.$langs->trans("ThirdParty").'</td><td class="right">'.$langs->trans("Amount").'</td>';
print '<td>'.$langs->trans("Reason").'</td><td align="center">'.$langs->trans("ToBill").'</td><td class="center">'.$langs->trans("Invoice").'</td></tr>';
print '<td>'.$langs->trans("Reason").'</td><td align="center">'.$langs->trans("ToBill").'</td>';
print '<td class="center">';
// Invoice to charge the error. No yet implemented.
//print $langs->trans("Invoice");
print '</td>';
print '</tr>';
$total = 0;
@ -250,19 +261,39 @@ if ($resql) {
while ($i < $num) {
$obj = $db->fetch_object($resql);
print '<tr class="oddeven"><td>';
$thirdpartystatic->id = $obj->socid;
$thirdpartystatic->name = $obj->name;
if ($obj->fk_facture > 0) {
$invoicestatic->fetch($obj->fk_facture);
}
print '<tr class="oddeven">';
print '<td>';
print '<a href="'.DOL_URL_ROOT.'/compta/prelevement/line.php?id='.$obj->rowid.'">';
print img_picto('', 'statut'.$obj->statut).' ';
print substr('000000'.$obj->rowid, -6);
print '</a></td>';
print '<td><a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.$obj->name."</a></td>\n";
print '<td>';
if ($type != 'bank-transfer') {
print $thirdpartystatic->getNomUrl(1, 'customer');
} else {
print $thirdpartystatic->getNomUrl(1, 'supplier');
}
print '</td>'."\n";
print '<td class="right"><span class="amount">'.price($obj->amount)."</span></td>\n";
print '<td>'.$rej->motifs[$obj->motif].'</td>';
print '<td>'.dol_escape_htmltag($rej->motifs[$obj->motif]).'</td>';
print '<td class="center">'.yn($obj->afacturer).'</td>';
print '<td class="center">'.$obj->fk_facture.'</td>';
// Invoice used to charge the error
print '<td class="center">';
if ($obj->fk_facture > 0) {
print $invoicestatic->getNomUrl(1);
}
print '</td>';
print "</tr>\n";
$total += $obj->amount;

View file

@ -34,7 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
// Load translation files required by the page
$langs->loadlangs(array('banks', 'categories', 'bills', 'withdrawals'));
$langs->loadlangs(array('banks', 'categories', 'bills', 'companies', 'withdrawals'));
// Get supervariables
$action = GETPOST('action', 'aZ09');
@ -69,12 +69,20 @@ if ($type == 'bank-transfer') {
$result = restrictedArea($user, 'prelevement', '', '', 'bons');
}
if ($type == 'bank-transfer') {
$permissiontoadd = $user->hasRight('paymentbybanktransfer', 'create');
} else {
$permissiontoadd = $user->hasRight('prelevement', 'bons', 'creer');
}
$error = 0;
/*
* Actions
*/
if ($action == 'confirm_rejet') {
if ($action == 'confirm_rejet' && $permissiontoadd) {
if (GETPOST("confirm") == 'yes') {
if (GETPOST('remonth', 'int')) {
$daterej = mktime(2, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
@ -119,6 +127,8 @@ if ($action == 'confirm_rejet') {
* View
*/
$form = new Form($db);
if ($type == 'bank-transfer') {
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
$invoicestatic = new FactureFournisseur($db);
@ -137,7 +147,7 @@ llxHeader('', $title);
$head = array();
$h = 0;
$head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/line.php?id='.$id.'&type='.$type;
$head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/line.php?id='.((int) $id).'&type='.urlencode($type);
$head[$h][1] = $title;
$hselected = $h;
$h++;
@ -149,7 +159,7 @@ if ($id) {
$bon = new BonPrelevement($db);
$bon->fetch($lipre->bon_rowid);
print dol_get_fiche_head($head, $hselected, $title);
print dol_get_fiche_head($head, $hselected, $title, -1, 'payment');
print '<table class="border centpercent tableforfield">';
@ -193,8 +203,6 @@ if ($id) {
}
if ($action == 'rejet' && $user->rights->prelevement->bons->credit) {
$form = new Form($db);
$soc = new Societe($db);
$soc->fetch($lipre->socid);
@ -304,7 +312,9 @@ if ($id) {
print"\n<!-- debut table -->\n";
print '<table class="noborder" width="100%" cellpadding="4">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Invoice").'</td><td>'.$langs->trans("ThirdParty").'</td><td class="right">'.$langs->trans("Amount").'</td><td class="right">'.$langs->trans("Status").'</td>';
print '<td>'.$langs->trans("Invoice").'</td>';
print '<td>'.$langs->trans("ThirdParty").'</td>';
print '<td class="right">'.$langs->trans("Amount").'</td><td class="right">'.$langs->trans("Status").'</td>';
print '</tr>';
$total = 0;