diff --git a/ChangeLog b/ChangeLog index e221e29f097..88fdeafe29b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -65,6 +65,7 @@ For developers: action buttons into an element. - New: Normalize code for barcode generation to match other modules. - New: Uniformize code for contacts forms. +- New: Add some hooks for financial reports. WARNING: Following change may create regression for some external modules, but was necessary to make Dolibarr better: @@ -116,6 +117,7 @@ Fix: [ bug #1280 ] service with not end of date was tagged as expired. Fix: [ bug #1295 ] Error when creating an agenda extrafield with a number as reference Fix: [ bug #1306 ] Fatal error when adding an external calendar New: Added es_CL language +Fix: Margin tabs bad data show ***** ChangeLog for 3.5 compared to 3.4.* ***** For users: diff --git a/htdocs/compta/localtax/clients.php b/htdocs/compta/localtax/clients.php index 72b02194bc1..097a89c3918 100644 --- a/htdocs/compta/localtax/clients.php +++ b/htdocs/compta/localtax/clients.php @@ -1,5 +1,6 @@ + * Copyright (C) 2014 Ferran Marcet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -153,6 +154,17 @@ print "".$vatcust.""; print "\n"; $coll_list = vat_by_thirdparty($db,0,$date_start,$date_end,$modetax,'sell'); + +$action = "tvaclient"; +$object = &$coll_list; +$parameters["mode"] = $modetax; +$parameters["start"] = $date_start; +$parameters["end"] = $date_end; +$parameters["direction"] = 'sell'; +// Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('externalbalance')); +$reshook=$hookmanager->executeHooks('addStatisticLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks + if (is_array($coll_list)) { $var=true; @@ -160,7 +172,7 @@ if (is_array($coll_list)) $i = 1; foreach($coll_list as $coll) { - if(($min == 0 or ($min > 0 && $coll->amount > $min)) && $coll->localtax2>0) + if(($min == 0 or ($min > 0 && $coll->amount > $min)) && $coll->localtax2!=0) { $var=!$var; $intra = str_replace($find,$replace,$coll->tva_intra); @@ -222,6 +234,8 @@ print "\n"; $company_static=new Societe($db); $coll_list = vat_by_thirdparty($db,0,$date_start,$date_end,$modetax,'buy'); +$parameters["direction"] = 'buy'; +$reshook=$hookmanager->executeHooks('addStatisticLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks if (is_array($coll_list)) { $var=true; @@ -229,7 +243,7 @@ if (is_array($coll_list)) $i = 1; foreach($coll_list as $coll) { - if(($min == 0 or ($min > 0 && $coll->amount > $min)) && $coll->localtax2>0) + if(($min == 0 or ($min > 0 && $coll->amount > $min)) && $coll->localtax2!=0) { $var=!$var; $intra = str_replace($find,$replace,$coll->tva_intra); diff --git a/htdocs/compta/localtax/index.php b/htdocs/compta/localtax/index.php index aaa36a7edd7..25f0e95fd5c 100644 --- a/htdocs/compta/localtax/index.php +++ b/htdocs/compta/localtax/index.php @@ -1,5 +1,6 @@ + * Copyright (C) 2014 Ferran Marcet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -134,6 +135,15 @@ for ($m = 1 ; $m < 13 ; $m++ ) { $coll_listsell = vat_by_date($db, $y, 0, 0, 0, $modetax, 'sell', $m); $coll_listbuy = vat_by_date($db, $y, 0, 0, 0, $modetax, 'buy', $m); + + $action = "tva"; + $object = array(&$coll_listsell, &$coll_listbuy); + $parameters["mode"] = $modetax; + $parameters["year"] = $y; + $parameters["month"] = $m; + // Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array + $hookmanager->initHooks(array('externalbalance')); + $reshook=$hookmanager->executeHooks('addStatisticLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks if (! is_array($coll_listbuy) && $coll_listbuy == -1) { @@ -181,7 +191,7 @@ for ($m = 1 ; $m < 13 ; $m++ ) print ''.$langs->trans("SubTotal").':'; print ''.price($subtotalcoll).''; print ''.price($subtotalpaye).''; - print ''.price($subtotalpaye).''; + print ''.price($subtotal).''; print ' '; $i = 0; $subtotalcoll=0; $subtotalpaye=0; $subtotal=0; diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index d28f457fb2b..15722966004 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -2,6 +2,7 @@ /* Copyright (C) 2002-2006 Rodolphe Quiedeville * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2014 Ferran Marcet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -729,6 +730,16 @@ if ($mysoc->tva_assuj != 'franchise') // Assujeti print ''; } +$action = "balanceclient"; +$object = array(&$total_ht, &$total_ttc); +$parameters["mode"] = $modecompta; +$parameters["date_start"] = $date_start; +$parameters["date_end"] = $date_end; +$parameters["bc"] = $bc; +// Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('externalbalance')); +$reshook=$hookmanager->executeHooks('addStatisticLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +print $hookmanager->resPrint; if ($mysoc->tva_assuj != 'franchise') // Assujeti { diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index e4ead871b42..a56551f234b 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -2,6 +2,7 @@ /* Copyright (C) 2003 Rodolphe Quiedeville * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2014 Ferran Marcet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -461,8 +462,12 @@ if ($result) { } else { dol_print_error($db); } - - +$action = "balance"; +$object = array(&$encaiss, &$encaiss_ttc, &$decaiss, &$decaiss_ttc); +$parameters["mode"] = $modecompta; +// Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('externalbalance')); +$reshook=$hookmanager->executeHooks('addStatisticLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks /* * Show result array diff --git a/htdocs/compta/tva/clients.php b/htdocs/compta/tva/clients.php index fbde1584541..84857a35130 100644 --- a/htdocs/compta/tva/clients.php +++ b/htdocs/compta/tva/clients.php @@ -3,6 +3,7 @@ * Copyright (C) 2004 Eric Seigne * Copyright (C) 2004-2013 Laurent Destailleur * Copyright (C) 2006 Yannick Warnier + * Copyright (C) 2014 Ferran Marcet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -185,6 +186,17 @@ print "".$vatcust.""; print "\n"; $coll_list = vat_by_thirdparty($db,0,$date_start,$date_end,$modetax,'sell'); + +$action = "tvaclient"; +$object = &$coll_list; +$parameters["mode"] = $modetax; +$parameters["start"] = $date_start; +$parameters["end"] = $date_end; +$parameters["direction"] = 'sell'; +// Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('externalbalance')); +$reshook=$hookmanager->executeHooks('addStatisticLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks + if (is_array($coll_list)) { $var=true; @@ -263,6 +275,9 @@ print "\n"; $company_static=new Societe($db); $coll_list = vat_by_thirdparty($db,0,$date_start,$date_end,$modetax,'buy'); + +$parameters["direction"] = 'buy'; +$reshook=$hookmanager->executeHooks('addStatisticLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks if (is_array($coll_list)) { $var=true; diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index 4bab6f143d1..91094e7b52d 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -3,6 +3,7 @@ * Copyright (C) 2004 Eric Seigne * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2014 Ferran Marcet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -153,6 +154,15 @@ for ($m = 1 ; $m < 13 ; $m++ ) { $coll_listsell = vat_by_date($db, $y, 0, 0, 0, $modetax, 'sell', $m); $coll_listbuy = vat_by_date($db, $y, 0, 0, 0, $modetax, 'buy', $m); + + $action = "tva"; + $object = array(&$coll_listsell, &$coll_listbuy); + $parameters["mode"] = $modetax; + $parameters["year"] = $y; + $parameters["month"] = $m; + // Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array + $hookmanager->initHooks(array('externalbalance')); + $reshook=$hookmanager->executeHooks('addStatisticLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks if (! is_array($coll_listbuy) && $coll_listbuy == -1) { diff --git a/htdocs/compta/tva/quadri_detail.php b/htdocs/compta/tva/quadri_detail.php index cc084655bf0..b39befd8ad6 100644 --- a/htdocs/compta/tva/quadri_detail.php +++ b/htdocs/compta/tva/quadri_detail.php @@ -3,6 +3,7 @@ * Copyright (C) 2004 Eric Seigne * Copyright (C) 2004-2013 Laurent Destailleur * Copyright (C) 2006-2007 Yannick Warnier + * Copyright (C) 2014 Ferran Marcet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -318,7 +319,16 @@ else print ''.$langs->trans("AmountHTVATRealReceived").''; print ''.$vatcust.''; print ''; - + + $action = "tvadetail"; + $parameters["mode"] = $modetax; + $parameters["start"] = $date_start; + $parameters["end"] = $date_end; + $object = array(&$x_coll, &$x_paye, &$x_both); + // Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array + $hookmanager->initHooks(array('externalbalance')); + $reshook=$hookmanager->executeHooks('addStatisticLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks + foreach(array_keys($x_coll) as $rate) { $subtot_coll_total_ht = 0; diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index b7c5b8d4701..cc8f4d067eb 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -1,5 +1,6 @@ + * Copyright (C) 2014 Ferran Marcet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -130,11 +131,14 @@ if ($agentid > 0) { else $sql .= " AND sc.fk_user = ".$agentid; } -if (!empty($startdate)) $sql.= " AND f.datef >= '".$db->idate($startdate)."'"; -if (!empty($enddate)) $sql.= " AND f.datef <= '".$db->idate($enddate)."'"; +if (!empty($startdate)) + $sql.= " AND f.datef >= '".$db->idate($startdate)."'"; +if (!empty($enddate)) + $sql.= " AND f.datef <= '".$db->idate($enddate)."'"; $sql .= " AND d.buy_price_ht IS NOT NULL"; if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) $sql .= " AND d.buy_price_ht <> 0"; -$sql.= " GROUP BY s.rowid, s.nom, s.code_client, s.client, u.rowid, u.login, u.lastname, u.firstname"; +if($agentid) $sql.= " GROUP BY s.rowid, s.nom, s.code_client, s.client, u.rowid, u.login, u.lastname, u.firstname"; +else $sql.= " GROUP BY u.rowid, u.login, u.lastname, u.firstname"; $sql.= " ORDER BY ".$sortfield." ".$sortorder; // TODO: calculate total to display then restore pagination //$sql.= $db->plimit($conf->liste_limit +1, $offset); diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index e9a0bbfe102..e5226040794 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -1,5 +1,6 @@ + * Copyright (C) 2014 Ferran Marcet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -172,13 +173,18 @@ $sql.= " WHERE f.fk_soc = s.rowid"; $sql.= " AND f.fk_statut > 0"; $sql.= " AND s.entity = ".$conf->entity; $sql.= " AND d.fk_facture = f.rowid"; -if ($client) $sql.= " AND f.fk_soc = ".$socid; -if (!empty($startdate)) $sql.= " AND f.datef >= '".$db->idate($startdate)."'"; -if (!empty($enddate)) $sql.= " AND f.datef <= '".$db->idate($enddate)."'"; +if ($client) + $sql.= " AND f.fk_soc = ".$socid; +if (!empty($startdate)) + $sql.= " AND f.datef >= '".$db->idate($startdate)."'"; +if (!empty($enddate)) + $sql.= " AND f.datef <= '".$db->idate($enddate)."'"; $sql .= " AND d.buy_price_ht IS NOT NULL"; -if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) $sql .= " AND d.buy_price_ht <> 0"; -$sql.= " GROUP BY s.rowid, s.nom, s.code_client, s.client, f.rowid, f.facnumber, f.total, f.datef, f.paye, f.fk_statut"; -$sql.= " ORDER BY ".$sortfield." ".$sortorder; +if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) + $sql .= " AND d.buy_price_ht <> 0"; +if ($client) $sql.= " GROUP BY s.rowid, s.nom, s.code_client, s.client, f.rowid, f.facnumber, f.total, f.datef, f.paye, f.fk_statut"; +else $sql.= " GROUP BY s.rowid, s.nom, s.code_client, s.client"; +$sql.= " ORDER BY $sortfield $sortorder "; // TODO: calculate total to display then restore pagination //$sql.= $db->plimit($conf->liste_limit +1, $offset); diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index c4ba7b54c20..3152b8387b6 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -1,5 +1,6 @@ + * Copyright (C) 2014 Ferran Marcet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -178,12 +179,19 @@ $sql.= " AND f.fk_soc = s.rowid"; $sql.= " AND d.fk_product = p.rowid"; $sql.= " AND f.fk_statut > 0"; $sql.= " AND d.fk_facture = f.rowid"; -if ($id > 0) $sql.= " AND d.fk_product =".$id; -if (!empty($startdate)) $sql.= " AND f.datef >= '".$db->idate($startdate)."'"; -if (!empty($enddate)) $sql.= " AND f.datef <= '".$db->idate($enddate)."'"; +if ($id > 0) + $sql.= " AND d.fk_product =".$id; +if (!empty($startdate)) + $sql.= " AND f.datef >= '".$db->idate($startdate)."'"; +if (!empty($enddate)) + $sql.= " AND f.datef <= '".$db->idate($enddate)."'"; $sql .= " AND d.buy_price_ht IS NOT NULL"; -if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) $sql .= " AND d.buy_price_ht <> 0"; -$sql.= " GROUP BY p.label, p.rowid, p.fk_product_type, p.ref, d.fk_product, f.rowid, f.facnumber, f.total, f.datef, f.paye, f.fk_statut"; +if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) + $sql .= " AND d.buy_price_ht <> 0"; +if ($id > 0) + $sql.= " GROUP BY p.label, p.rowid, p.fk_product_type, p.ref, d.fk_product, f.rowid, f.facnumber, f.total, f.datef, f.paye, f.fk_statut"; +else + $sql.= " GROUP BY p.label, p.rowid, p.fk_product_type, p.ref"; $sql.= " ORDER BY ".$sortfield." ".$sortorder; // TODO: calculate total to display then restore pagination //$sql.= $db->plimit($conf->liste_limit +1, $offset);