Merge pull request #10736 from OPEN-DSI/fix-margin-agents3

Fix remove "canceled" invoices in margin by user
This commit is contained in:
Laurent Destailleur 2019-03-07 20:45:40 +01:00 committed by GitHub
commit ef56b020e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 4 deletions

View File

@ -132,6 +132,8 @@ dol_fiche_end();
print '</form>';
$invoice_status_except_list = array(Facture::STATUS_DRAFT, Facture::STATUS_ABANDONED);
$sql = "SELECT";
$sql.= " s.rowid as socid, s.nom as name, s.code_client, s.client,";
$sql.= " u.rowid as agent, u.login, u.lastname, u.firstname,";
@ -153,7 +155,7 @@ if (! empty($conf->global->AGENT_CONTACT_TYPE))
$sql.= " AND ((e.fk_socpeople IS NULL AND sc.fk_user = u.rowid) OR (e.fk_socpeople IS NOT NULL AND e.fk_socpeople = u.rowid))";
else
$sql .= " AND sc.fk_user = u.rowid";
$sql.= " AND f.fk_statut > 0";
$sql.= " AND f.fk_statut NOT IN (" . implode(', ', $invoice_status_except_list) . ")";
$sql.= ' AND s.entity IN ('.getEntity('societe').')';
$sql.= " AND d.fk_facture = f.rowid";
if ($agentid > 0) {

View File

@ -183,6 +183,7 @@ dol_fiche_end();
$arrayfields=array();
$massactionbutton='';
$invoice_status_except_list = array(Facture::STATUS_DRAFT, Facture::STATUS_ABANDONED);
$sql = "SELECT";
$sql .= " f.ref, f.rowid as invoiceid, d.rowid as invoicedetid, d.buy_price_ht, d.total_ht, d.subprice, d.label, d.description , d.qty";
@ -190,7 +191,7 @@ $sql .= " ,d.fk_product";
$sql .= " FROM " . MAIN_DB_PREFIX . "facture as f ";
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facturedet as d ON d.fk_facture = f.rowid";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON d.fk_product = p.rowid";
$sql .= " WHERE f.fk_statut > 0";
$sql .= " WHERE f.fk_statut NOT IN (" . implode(', ', $invoice_status_except_list) . ")";
$sql .= " AND f.entity IN (" . getEntity('invoice') . ") ";
if (! empty($startdate)) $sql .= " AND f.datef >= '" . $db->idate($startdate) . "'";
if (! empty($enddate)) $sql .= " AND f.datef <= '" . $db->idate($enddate) . "'";

View File

@ -200,6 +200,8 @@ dol_fiche_end();
print '</form>';
$invoice_status_except_list = array(Facture::STATUS_DRAFT, Facture::STATUS_ABANDONED);
$sql = "SELECT";
$sql.= " s.rowid as socid, s.nom as name, s.code_client, s.client,";
if ($client) $sql.= " f.rowid as facid, f.ref, f.total as total_ht, f.datef, f.paye, f.fk_statut as statut,";
@ -218,7 +220,7 @@ if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PRE
$sql.= " WHERE f.fk_soc = s.rowid";
if ($socid > 0) $sql.= ' AND s.rowid = '.$socid;
if (!$user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql.= " AND f.fk_statut > 0";
$sql.= " AND f.fk_statut NOT IN (" . implode(', ', $invoice_status_except_list) . ")";
$sql.= ' AND s.entity IN ('.getEntity('societe').')';
$sql.= " AND d.fk_facture = f.rowid";
$sql.= " AND (d.product_type = 0 OR d.product_type = 1)";

View File

@ -174,6 +174,8 @@ dol_fiche_end();
print '</form>';
$invoice_status_except_list = array(Facture::STATUS_DRAFT, Facture::STATUS_ABANDONED);
$sql = "SELECT p.label, p.rowid, p.fk_product_type, p.ref, p.entity as pentity,";
if ($id > 0) $sql.= " d.fk_product,";
if ($id > 0) $sql.= " f.rowid as facid, f.ref, f.total as total_ht, f.datef, f.paye, f.fk_statut as statut,";
@ -190,7 +192,7 @@ if (! empty($TSelectedCats)) {
}
$sql.= " WHERE f.fk_soc = s.rowid";
$sql.= ' AND f.entity IN ('.getEntity('invoice').')';
$sql.= " AND f.fk_statut > 0";
$sql.= " AND f.fk_statut NOT IN (" . implode(', ', $invoice_status_except_list) . ")";
$sql.= " AND d.fk_facture = f.rowid";
if ($id > 0)
$sql.= " AND d.fk_product =".$id;