FIX bad consistency in list of invoice for direct debit order.
This commit is contained in:
parent
d1a5be20ea
commit
bc7bf3b4b5
@ -739,14 +739,13 @@ class BonPrelevement extends CommonObject
|
|||||||
$sql = "SELECT count(f.rowid) as nb";
|
$sql = "SELECT count(f.rowid) as nb";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
|
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
|
$sql.= ", ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
|
||||||
$sql.= " WHERE f.fk_statut = 1";
|
$sql.= " WHERE f.fk_statut = ".Facture::STATUS_VALIDATED;
|
||||||
$sql.= " AND f.entity IN (".getEntity('invoice').")";
|
$sql.= " AND f.entity IN (".getEntity('invoice').")";
|
||||||
$sql.= " AND f.rowid = pfd.fk_facture";
|
$sql.= " AND f.rowid = pfd.fk_facture";
|
||||||
$sql.= " AND f.paye = 0";
|
|
||||||
$sql.= " AND pfd.traite = 0";
|
$sql.= " AND pfd.traite = 0";
|
||||||
$sql.= " AND f.total_ttc > 0";
|
$sql.= " AND f.total_ttc > 0";
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::SommeAPrelever");
|
dol_syslog(get_class($this)."::NbFactureAPrelever");
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
|
|
||||||
if ( $resql )
|
if ( $resql )
|
||||||
@ -759,7 +758,7 @@ class BonPrelevement extends CommonObject
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=get_class($this)."::SommeAPrelever Erreur -1 sql=".$this->db->error();
|
$this->error=get_class($this)."::NbFactureAPrelever Erreur -1 sql=".$this->db->error();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,31 +35,43 @@ $langs->loadLangs(array('banks', 'categories', 'withdrawals', 'companies'));
|
|||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
$socid = GETPOST('socid', 'int');
|
$socid = GETPOST('socid', 'int');
|
||||||
|
$status = GETPOST('status', 'int');
|
||||||
if ($user->societe_id) $socid=$user->societe_id;
|
if ($user->societe_id) $socid=$user->societe_id;
|
||||||
$result = restrictedArea($user, 'prelevement', '', '', 'bons');
|
$result = restrictedArea($user, 'prelevement', '', '', 'bons');
|
||||||
|
|
||||||
// Get supervariables
|
$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'myobjectlist'; // To manage different context of search
|
||||||
$page = GETPOST('page', 'int');
|
$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
|
||||||
$sortorder = GETPOST('sortorder', 'alpha');
|
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
|
||||||
$sortfield = GETPOST('sortfield', 'alpha');
|
|
||||||
|
|
||||||
|
// Load variable for pagination
|
||||||
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
|
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
|
||||||
$sortfield = GETPOST("sortfield", 'alpha');
|
$sortfield = GETPOST("sortfield", 'alpha');
|
||||||
$sortorder = GETPOST("sortorder", 'alpha');
|
$sortorder = GETPOST("sortorder", 'alpha');
|
||||||
$page = GETPOST("page", 'int');
|
$page = GETPOST("page", 'int');
|
||||||
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
|
||||||
$offset = $limit * $page;
|
$offset = $limit * $page;
|
||||||
$pageprev = $page - 1;
|
$pageprev = $page - 1;
|
||||||
$pagenext = $page + 1;
|
$pagenext = $page + 1;
|
||||||
if (! $sortorder) $sortorder="DESC";
|
if (! $sortorder) $sortorder="DESC";
|
||||||
if (! $sortfield) $sortfield="f.ref";
|
if (! $sortfield) $sortfield="f.ref";
|
||||||
|
|
||||||
|
$massactionbutton = '';
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
|
||||||
llxHeader();
|
if (!$status)
|
||||||
|
{
|
||||||
|
$title = $langs->trans("RequestStandingOrderToTreat");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$title = $langs->trans("RequestStandingOrderTreated");
|
||||||
|
}
|
||||||
|
|
||||||
|
llxHeader('', $title);
|
||||||
|
|
||||||
$thirdpartystatic=new Societe($db);
|
$thirdpartystatic=new Societe($db);
|
||||||
$invoicestatic=new Facture($db);
|
$invoicestatic=new Facture($db);
|
||||||
@ -78,32 +90,64 @@ $sql.= " WHERE s.rowid = f.fk_soc";
|
|||||||
$sql.= " AND f.entity IN (".getEntity('invoice').")";
|
$sql.= " AND f.entity IN (".getEntity('invoice').")";
|
||||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
if ($socid) $sql.= " AND f.fk_soc = ".$socid;
|
if ($socid) $sql.= " AND f.fk_soc = ".$socid;
|
||||||
if (!$statut) $sql.= " AND pfd.traite = 0";
|
if (!$status) $sql.= " AND pfd.traite = 0";
|
||||||
if ($statut) $sql.= " AND pfd.traite = ".$statut;
|
if ($status) $sql.= " AND pfd.traite = ".$status;
|
||||||
|
$sql.= " AND f.fk_statut = ".Facture::STATUS_VALIDATED;
|
||||||
$sql.= " AND pfd.fk_facture = f.rowid";
|
$sql.= " AND pfd.fk_facture = f.rowid";
|
||||||
if (dol_strlen(trim(GETPOST('search_societe', 'alpha'))))
|
if (dol_strlen(trim(GETPOST('search_societe', 'alpha'))))
|
||||||
{
|
{
|
||||||
$sql.= natural_search("s.nom", 'search_societe');
|
$sql.= natural_search("s.nom", 'search_societe');
|
||||||
}
|
}
|
||||||
$sql.= " ORDER BY $sortfield $sortorder ";
|
$sql.=$db->order($sortfield, $sortorder);
|
||||||
$sql.= $db->plimit($limit+1, $offset);
|
|
||||||
|
|
||||||
|
|
||||||
|
// Count total nb of records
|
||||||
|
$nbtotalofrecords = '';
|
||||||
|
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||||
|
{
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
$nbtotalofrecords = $db->num_rows($resql);
|
||||||
|
if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0
|
||||||
{
|
{
|
||||||
$num = $db->num_rows($resql);
|
$page = 0;
|
||||||
$i = 0;
|
$offset = 0;
|
||||||
|
}
|
||||||
if (!$statut)
|
}
|
||||||
|
// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
|
||||||
|
if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords)
|
||||||
{
|
{
|
||||||
print_barre_liste($langs->trans("RequestStandingOrderToTreat"), $page, "demandes.php", $urladd, $sortfield, $sortorder, '', $num);
|
$num = $nbtotalofrecords;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print_barre_liste($langs->trans("RequestStandingOrderTreated"), $page, "demandes.php", $urladd, $sortfield, $sortorder, '', $num);
|
$sql.= $db->plimit($limit+1, $offset);
|
||||||
|
|
||||||
|
$resql=$db->query($sql);
|
||||||
|
if (! $resql)
|
||||||
|
{
|
||||||
|
dol_print_error($db);
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="GET">';
|
$num = $db->num_rows($resql);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$newcardbutton = '<a href="'.DOL_URL_ROOT.'/compta/prelevement/index.php">'.$langs->trans("Back").'</a>';
|
||||||
|
|
||||||
|
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_generic', 0, $newcardbutton, '', $limit);
|
||||||
|
|
||||||
|
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||||
|
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||||
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
|
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
||||||
|
print '<input type="hidden" name="action" value="list">';
|
||||||
|
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
||||||
|
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||||
|
print '<input type="hidden" name="page" value="'.$page.'">';
|
||||||
|
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
|
||||||
|
|
||||||
|
|
||||||
print '<table class="liste" width="100%">';
|
print '<table class="liste" width="100%">';
|
||||||
|
|
||||||
@ -129,9 +173,11 @@ if ($resql)
|
|||||||
|
|
||||||
$users = array();
|
$users = array();
|
||||||
|
|
||||||
|
$i = 0;
|
||||||
while ($i < min($num, $limit))
|
while ($i < min($num, $limit))
|
||||||
{
|
{
|
||||||
$obj = $db->fetch_object($resql);
|
$obj = $db->fetch_object($resql);
|
||||||
|
if (empty($obj)) break; // Should not happen
|
||||||
|
|
||||||
print '<tr class="oddeven">';
|
print '<tr class="oddeven">';
|
||||||
|
|
||||||
@ -161,11 +207,7 @@ if ($resql)
|
|||||||
print "</table><br>";
|
print "</table><br>";
|
||||||
|
|
||||||
print '</form>';
|
print '</form>';
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dol_print_error($db);
|
|
||||||
}
|
|
||||||
|
|
||||||
// End of page
|
// End of page
|
||||||
llxFooter();
|
llxFooter();
|
||||||
|
|||||||
@ -71,6 +71,7 @@ $thirdpartystatic=new Societe($db);
|
|||||||
$invoicestatic=new Facture($db);
|
$invoicestatic=new Facture($db);
|
||||||
$bprev = new BonPrelevement($db);
|
$bprev = new BonPrelevement($db);
|
||||||
|
|
||||||
|
|
||||||
print '<table class="noborder" width="100%">';
|
print '<table class="noborder" width="100%">';
|
||||||
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").'</th></tr>';
|
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").'</th></tr>';
|
||||||
|
|
||||||
@ -100,6 +101,8 @@ if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX
|
|||||||
$sql.= " , ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
|
$sql.= " , ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
|
||||||
$sql.= " WHERE s.rowid = f.fk_soc";
|
$sql.= " WHERE s.rowid = f.fk_soc";
|
||||||
$sql.= " AND f.entity IN (".getEntity('invoice').")";
|
$sql.= " AND f.entity IN (".getEntity('invoice').")";
|
||||||
|
$sql.= " AND f.total_ttc > 0";
|
||||||
|
$sql.= " AND f.fk_statut = ".Facture::STATUS_VALIDATED;
|
||||||
$sql.= " AND pfd.traite = 0 AND pfd.fk_facture = f.rowid";
|
$sql.= " AND pfd.traite = 0 AND pfd.fk_facture = f.rowid";
|
||||||
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
if ($socid) $sql.= " AND f.fk_soc = ".$socid;
|
if ($socid) $sql.= " AND f.fk_soc = ".$socid;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user