diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index b3f946e9245..8ffdd18c520 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -727,7 +727,9 @@ if (!empty($arrayfields['t.piece_num']['checked'])) { } // Code journal if (!empty($arrayfields['t.code_journal']['checked'])) { - print ''; + print ''; + print $formaccounting->multi_select_journal($search_ledger_code, 'search_ledger_code', 0, 1, 1, 1); + print ''; } // Date document if (!empty($arrayfields['t.doc_date']['checked'])) { diff --git a/htdocs/compta/stats/byratecountry.php b/htdocs/compta/stats/byratecountry.php index 9f40eab226a..d65bed019fc 100644 --- a/htdocs/compta/stats/byratecountry.php +++ b/htdocs/compta/stats/byratecountry.php @@ -301,6 +301,7 @@ if ($modecompta == 'CREANCES-DETTES') { } print ''.$langs->trans("TotalHT").''; + // Sales invoices $sql = "SELECT fd.tva_tx AS vatrate,"; $sql .= " fd.product_type AS product_type,"; $sql .= " cc.code, cc.label AS country,"; @@ -324,7 +325,6 @@ if ($modecompta == 'CREANCES-DETTES') { $sql .= " GROUP BY fd.tva_tx,fd.product_type, cc.label, cc.code "; $sql .= " ORDER BY country, product_type, vatrate"; - dol_syslog("htdocs/compta/tva/index.php sql=".$sql, LOG_DEBUG); $resql = $db->query($sql); if ($resql) { @@ -374,7 +374,6 @@ if ($modecompta == 'CREANCES-DETTES') { print $db->lasterror(); // Show last sql error } - print ''.$langs->trans("PurchasebyVatrate").''; print ''.$langs->trans("ProductOrService").''; print ''.$langs->trans("Country").''; @@ -389,6 +388,7 @@ if ($modecompta == 'CREANCES-DETTES') { } print ''.$langs->trans("TotalHT").''; + // Purchase invoices $sql2 = "SELECT ffd.tva_tx AS vatrate,"; $sql2 .= " ffd.product_type AS product_type,"; $sql2 .= " cc.code, cc.label AS country,"; diff --git a/htdocs/compta/stats/cabyprodserv.php b/htdocs/compta/stats/cabyprodserv.php index 16f4a850f83..d48a931ca2c 100644 --- a/htdocs/compta/stats/cabyprodserv.php +++ b/htdocs/compta/stats/cabyprodserv.php @@ -315,7 +315,7 @@ if ($modecompta == 'CREANCES-DETTES') { $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; } if ($selected_type >= 0) { - $sql .= " AND l.product_type = ".$selected_type; + $sql .= " AND l.product_type = ".((int) $selected_type); } if ($selected_cat === -2) { // Without any category $sql .= " AND cp.fk_product is null"; @@ -342,7 +342,7 @@ if ($modecompta == 'CREANCES-DETTES') { $sql .= "))"; } if ($selected_soc > 0) { - $sql .= " AND soc.rowid=".$selected_soc; + $sql .= " AND soc.rowid=".((int) $selected_soc); } $sql .= " AND f.entity IN (".getEntity('invoice').")"; diff --git a/htdocs/compta/stats/cabyuser.php b/htdocs/compta/stats/cabyuser.php index 0c0621fde76..ce2cb2ad333 100644 --- a/htdocs/compta/stats/cabyuser.php +++ b/htdocs/compta/stats/cabyuser.php @@ -243,7 +243,7 @@ if ($modecompta == 'CREANCES-DETTES') { if ($date_start && $date_end) { $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; } -} else { +} elseif ($modecompta == "RECETTES-DEPENSES") { /* * Liste des paiements (les anciens paiements ne sont pas vus par cette requete car, sur les * vieilles versions, ils n'etaient pas lies via paiement_facture. On les ajoute plus loin) @@ -257,6 +257,8 @@ if ($modecompta == 'CREANCES-DETTES') { if ($date_start && $date_end) { $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; } +} elseif ($modecompta == "BOOKKEEPING") { +} elseif ($modecompta == "BOOKKEEPINGCOLLECTED") { } $sql .= " AND f.entity IN (".getEntity('invoice').")"; if ($socid) { @@ -286,7 +288,7 @@ if ($result) { } // Adding old-version payments, non-bound by "paiement_facture" then without User -if ($modecompta != 'CREANCES-DETTES') { +if ($modecompta == 'RECETTES-DEPENSES') { $sql = "SELECT -1 as rowidx, '' as name, '' as firstname, sum(DISTINCT p.amount) as amount_ttc"; $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; diff --git a/htdocs/compta/stats/casoc.php b/htdocs/compta/stats/casoc.php index 1be022cca2f..52e41c20672 100644 --- a/htdocs/compta/stats/casoc.php +++ b/htdocs/compta/stats/casoc.php @@ -267,14 +267,14 @@ if ($modecompta == 'CREANCES-DETTES') { if ($selected_cat === -2) { // Without any category $sql .= " AND cs.fk_soc is null"; } elseif ($selected_cat) { // Into a specific category - $sql .= " AND (c.rowid = ".$db->escape($selected_cat); + $sql .= " AND (c.rowid = ".((int) $selected_cat); if ($subcat) { - $sql .= " OR c.fk_parent = ".$db->escape($selected_cat); + $sql .= " OR c.fk_parent = ".((int) $selected_cat); } $sql .= ")"; $sql .= " AND cs.fk_categorie = c.rowid AND cs.fk_soc = s.rowid"; } -} else { +} elseif ($modecompta == "RECETTES-DEPENSES") { /* * Liste des paiements (les anciens paiements ne sont pas vus par cette requete car, sur les * vieilles versions, ils n'etaient pas lies via paiement_facture. On les ajoute plus loin) @@ -298,13 +298,15 @@ if ($modecompta == 'CREANCES-DETTES') { if ($selected_cat === -2) { // Without any category $sql .= " AND cs.fk_soc is null"; } elseif ($selected_cat) { // Into a specific category - $sql .= " AND (c.rowid = ".$selected_cat; + $sql .= " AND (c.rowid = ".((int) $selected_cat); if ($subcat) { - $sql .= " OR c.fk_parent = ".$selected_cat; + $sql .= " OR c.fk_parent = ".((int) $selected_cat); } $sql .= ")"; $sql .= " AND cs.fk_categorie = c.rowid AND cs.fk_soc = s.rowid"; } +} elseif ($modecompta == "BOOKKEEPING") { +} elseif ($modecompta == "BOOKKEEPINGCOLLECTED") { } if (!empty($search_societe)) { $sql .= natural_search('s.nom', $search_societe); @@ -316,11 +318,11 @@ if (!empty($search_town)) { $sql .= natural_search('s.town', $search_town); } if ($search_country > 0) { - $sql .= ' AND s.fk_pays = '.$search_country.''; + $sql .= ' AND s.fk_pays = '.((int) $search_country); } $sql .= " AND f.entity IN (".getEntity('invoice').")"; if ($socid) { - $sql .= " AND f.fk_soc = ".$socid; + $sql .= " AND f.fk_soc = ".((int) $socid); } $sql .= " GROUP BY s.rowid, s.nom, s.zip, s.town, s.fk_pays"; $sql .= " ORDER BY s.rowid"; @@ -350,7 +352,7 @@ if ($result) { } // On ajoute les paiements anciennes version, non lies par paiement_facture -if ($modecompta != 'CREANCES-DETTES') { +if ($modecompta == "RECETTES-DEPENSES") { $sql = "SELECT '0' as socid, 'Autres' as name, sum(p.amount) as amount_ttc"; $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index 057ba461559..81f681d7528 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -209,7 +209,7 @@ if ($modecompta == 'CREANCES-DETTES') { } $sql .= " AND f.entity IN (".getEntity('invoice').")"; if ($socid) { - $sql .= " AND f.fk_soc = ".$socid; + $sql .= " AND f.fk_soc = ".((int) $socid); } } elseif ($modecompta == "RECETTES-DEPENSES") { /* @@ -224,7 +224,7 @@ if ($modecompta == 'CREANCES-DETTES') { $sql .= " AND pf.fk_facture = f.rowid"; $sql .= " AND f.entity IN (".getEntity('invoice').")"; if ($socid) { - $sql .= " AND f.fk_soc = ".$socid; + $sql .= " AND f.fk_soc = ".((int) $socid); } } elseif ($modecompta == "BOOKKEEPING") { $sql = "SELECT date_format(b.doc_date,'%Y-%m') as dm, sum(b.credit) as amount_ttc"; diff --git a/htdocs/compta/stats/supplier_turnover_by_prodserv.php b/htdocs/compta/stats/supplier_turnover_by_prodserv.php index 1c78b51a185..1af51249433 100644 --- a/htdocs/compta/stats/supplier_turnover_by_prodserv.php +++ b/htdocs/compta/stats/supplier_turnover_by_prodserv.php @@ -288,20 +288,20 @@ if ($modecompta == 'CREANCES-DETTES') { $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; } if ($selected_type >= 0) { - $sql .= " AND l.product_type = ".$selected_type; + $sql .= " AND l.product_type = ".((int) $selected_type); } if ($selected_cat === -2) { // Without any category $sql .= " AND cp.fk_product is null"; } elseif ($selected_cat) { // Into a specific category - $sql .= " AND (c.rowid = ".$selected_cat; + $sql .= " AND (c.rowid = ".((int) $selected_cat); if ($subcat) { - $sql .= " OR c.fk_parent = ".$selected_cat; + $sql .= " OR c.fk_parent = ".((int) $selected_cat); } $sql .= ")"; $sql .= " AND cp.fk_categorie = c.rowid AND cp.fk_product = p.rowid"; } if ($selected_soc > 0) { - $sql .= " AND soc.rowid=".$selected_soc; + $sql .= " AND soc.rowid=".((int) $selected_soc); } $sql .= " AND f.entity IN (".getEntity('supplier_invoice').")"; $sql .= " GROUP BY p.rowid, p.ref, p.label, p.fk_product_type"; diff --git a/htdocs/compta/stats/supplier_turnover_by_thirdparty.php b/htdocs/compta/stats/supplier_turnover_by_thirdparty.php index 664a4fbc62d..4e19d81f94a 100644 --- a/htdocs/compta/stats/supplier_turnover_by_thirdparty.php +++ b/htdocs/compta/stats/supplier_turnover_by_thirdparty.php @@ -251,9 +251,9 @@ if ($modecompta == 'CREANCES-DETTES') { if ($selected_cat === -2) { // Without any category $sql .= " AND cs.fk_soc is null"; } elseif ($selected_cat) { // Into a specific category - $sql .= " AND (c.rowid = ".$db->escape($selected_cat); + $sql .= " AND (c.rowid = ".((int) $selected_cat); if ($subcat) { - $sql .= " OR c.fk_parent = ".$db->escape($selected_cat); + $sql .= " OR c.fk_parent = ".((int) $selected_cat); } $sql .= ")"; $sql .= " AND cs.fk_categorie = c.rowid AND cs.fk_soc = s.rowid"; @@ -278,9 +278,9 @@ if ($modecompta == 'CREANCES-DETTES') { if ($selected_cat === -2) { // Without any category $sql .= " AND cs.fk_soc is null"; } elseif ($selected_cat) { // Into a specific category - $sql .= " AND (c.rowid = ".$selected_cat; + $sql .= " AND (c.rowid = ".((int) $selected_cat); if ($subcat) { - $sql .= " OR c.fk_parent = ".$selected_cat; + $sql .= " OR c.fk_parent = ".((int) $selected_cat); } $sql .= ")"; $sql .= " AND cs.fk_categorie = c.rowid AND cs.fk_soc = s.rowid";