diff --git a/htdocs/compta/stats/supplier_turnover.php b/htdocs/compta/stats/supplier_turnover.php
index c255d1a125f..a4839a74cbb 100644
--- a/htdocs/compta/stats/supplier_turnover.php
+++ b/htdocs/compta/stats/supplier_turnover.php
@@ -40,12 +40,12 @@ $nbofyear = 4;
// Date range
$year = GETPOSTINT('year');
if (empty($year)) {
- $year_current = dol_print_date(dol_now(), "%Y");
- $month_current = dol_print_date(dol_now(), "%m");
+ $year_current = (int) dol_print_date(dol_now(), "%Y");
+ $month_current = (int) dol_print_date(dol_now(), "%m");
$year_start = $year_current - ($nbofyear - 1);
} else {
$year_current = $year;
- $month_current = dol_print_date(dol_now(), "%m");
+ $month_current = (int) dol_print_date(dol_now(), "%m");
$year_start = $year - $nbofyear + (getDolGlobalInt('SOCIETE_FISCAL_MONTH_START') > 1 ? 0 : 1);
}
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear, 'tzserver'); // We use timezone of server so report is same from everywhere
diff --git a/htdocs/compta/stats/supplier_turnover_by_prodserv.php b/htdocs/compta/stats/supplier_turnover_by_prodserv.php
index a7f779a0bfe..94c9b1d2a7a 100644
--- a/htdocs/compta/stats/supplier_turnover_by_prodserv.php
+++ b/htdocs/compta/stats/supplier_turnover_by_prodserv.php
@@ -37,6 +37,7 @@ if (GETPOST("modecompta")) {
$modecompta = GETPOST("modecompta");
}
+// Sort Order
$sortorder = GETPOST("sortorder", 'aZ09comma');
$sortfield = GETPOST("sortfield", 'aZ09comma');
if (!$sortorder) {
@@ -75,12 +76,12 @@ $nbofyear = 1;
$year = GETPOSTINT("year");
$month = GETPOSTINT("month");
if (empty($year)) {
- $year_current = dol_print_date(dol_now(), "%Y");
- $month_current = dol_print_date(dol_now(), "%m");
+ $year_current = (int) dol_print_date(dol_now(), "%Y");
+ $month_current = (int) dol_print_date(dol_now(), "%m");
$year_start = $year_current - ($nbofyear - 1);
} else {
$year_current = $year;
- $month_current = dol_print_date(dol_now(), "%m");
+ $month_current = (int) dol_print_date(dol_now(), "%m");
$year_start = $year - $nbofyear + (getDolGlobalInt('SOCIETE_FISCAL_MONTH_START') > 1 ? 0 : 1);
}
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear, 'tzserver'); // We use timezone of server so report is same from everywhere
@@ -94,7 +95,7 @@ if (empty($date_start) || empty($date_end)) { // We define date_start and date_e
$year_end = $year_start + $nbofyear - (getDolGlobalInt('SOCIETE_FISCAL_MONTH_START') > 1 ? 0 : 1);
$month_start = GETPOSTISSET("month") ? GETPOSTINT("month") : getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1);
if (!GETPOST("month")) { // If month not forced
- if (!year && $month_start > $month_current) {
+ if (!$year && $month_start > $month_current) {
$year_start--;
$year_end--;
}
@@ -231,18 +232,18 @@ if ($modecompta == "CREANCES-DETTES") {
//$calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')';
$description = $langs->trans("RulesPurchaseTurnoverDue");
- $builddate = dol_now();
} elseif ($modecompta == "RECETTES-DEPENSES") {
$name = $langs->trans("PurchaseTurnoverCollected").', '.$langs->trans("ByProductsAndServices");
$calcmode = $langs->trans("CalcModePayment");
//$calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')';
$description = $langs->trans("RulesPurchaseTurnoverIn");
-
- $builddate = dol_now();
} elseif ($modecompta == "BOOKKEEPING") {
+ // TODO
} elseif ($modecompta == "BOOKKEEPINGCOLLECTED") {
+ // TODO
}
+$builddate = dol_now();
$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver');
$period .= ' - ';
$period .= $form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver');
@@ -363,7 +364,7 @@ if ($modecompta == 'CREANCES-DETTES') {
dol_print_error($db);
}
- // Show Array
+ // Show array
$i = 0;
print '
';
} else {
diff --git a/htdocs/compta/stats/supplier_turnover_by_thirdparty.php b/htdocs/compta/stats/supplier_turnover_by_thirdparty.php
index c89d4b96c38..367666b0692 100644
--- a/htdocs/compta/stats/supplier_turnover_by_thirdparty.php
+++ b/htdocs/compta/stats/supplier_turnover_by_thirdparty.php
@@ -71,46 +71,48 @@ $search_zip = GETPOST("search_zip", 'alpha');
$search_town = GETPOST("search_town", 'alpha');
$search_country = GETPOST("search_country", 'aZ09');
-
-// Date range
-$year = GETPOSTINT("year");
-$month = GETPOSTINT("month");
$date_startyear = GETPOST("date_startyear", 'alpha');
$date_startmonth = GETPOST("date_startmonth", 'alpha');
$date_startday = GETPOST("date_startday", 'alpha');
$date_endyear = GETPOST("date_endyear", 'alpha');
$date_endmonth = GETPOST("date_endmonth", 'alpha');
$date_endday = GETPOST("date_endday", 'alpha');
+
+$nbofyear = 1;
+
+// Date range
+$year = GETPOSTINT("year");
+$month = GETPOSTINT("month");
if (empty($year)) {
- $year_current = dol_print_date(dol_now(), '%Y');
- $month_current = dol_print_date(dol_now(), '%m');
- $year_start = $year_current;
+ $year_current = (int) dol_print_date(dol_now(), "%Y");
+ $month_current = (int) dol_print_date(dol_now(), "%m");
+ $year_start = $year_current - ($nbofyear - 1);
} else {
$year_current = $year;
- $month_current = dol_print_date(dol_now(), '%m');
- $year_start = $year;
+ $month_current = (int) dol_print_date(dol_now(), "%m");
+ $year_start = $year - $nbofyear + (getDolGlobalInt('SOCIETE_FISCAL_MONTH_START') > 1 ? 0 : 1);
}
-$date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear"), 'tzserver'); // We use timezone of server so report is same from everywhere
-$date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear"), 'tzserver'); // We use timezone of server so report is same from everywhere
-// Quarter
+$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear, 'tzserver'); // We use timezone of server so report is same from everywhere
+$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear, 'tzserver'); // We use timezone of server so report is same from everywhere
+
+// We define date_start and date_end
if (empty($date_start) || empty($date_end)) { // We define date_start and date_end
- $q = GETPOSTINT("q") ? GETPOSTINT("q") : 0;
+ $q = GETPOSTINT("q");
if (empty($q)) {
// We define date_start and date_end
- $month_start = GETPOST("month") ? GETPOST("month") : getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1);
- $year_end = $year_start;
- $month_end = $month_start;
+ $year_end = $year_start + $nbofyear - (getDolGlobalInt('SOCIETE_FISCAL_MONTH_START') > 1 ? 0 : 1);
+ $month_start = GETPOSTISSET("month") ? GETPOSTINT("month") : getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1);
if (!GETPOST("month")) { // If month not forced
- if (!GETPOST('year') && $month_start > $month_current) {
+ if (!$year && $month_start > $month_current) {
$year_start--;
$year_end--;
}
$month_end = $month_start - 1;
if ($month_end < 1) {
$month_end = 12;
- } else {
- $year_end++;
}
+ } else {
+ $month_end = $month_start;
}
$date_start = dol_get_first_day($year_start, $month_start, false);
$date_end = dol_get_last_day($year_end, $month_end, false);
@@ -131,8 +133,6 @@ if (empty($date_start) || empty($date_end)) { // We define date_start and date_e
$date_start = dol_get_first_day($year_start, 10, false);
$date_end = dol_get_last_day($year_start, 12, false);
}
-} else {
- // TODO We define q
}
// $date_start and $date_end are defined. We force $year_start and $nbofyear
@@ -209,18 +209,20 @@ if ($modecompta == "CREANCES-DETTES") {
$calcmode = $langs->trans("CalcModeDebt");
//$calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')';
$description = $langs->trans("RulesPurchaseTurnoverDue");
- //$exportlink=$langs->trans("NotYetAvailable");
+ $builddate = dol_now();
} elseif ($modecompta == "RECETTES-DEPENSES") {
$name = $langs->trans("PurchaseTurnoverCollected").', '.$langs->trans("ByThirdParties");
$calcmode = $langs->trans("CalcModePayment");
//$calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')';
$description = $langs->trans("RulesPurchaseTurnoverIn");
- //$exportlink=$langs->trans("NotYetAvailable");
+
+ $builddate = dol_now();
} elseif ($modecompta == "BOOKKEEPING") {
// TODO
} elseif ($modecompta == "BOOKKEEPINGCOLLECTED") {
// TODO
}
+
$builddate = dol_now();
$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver');
$period .= ' - ';
@@ -235,8 +237,33 @@ $exportlink = '';
report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink, $tableparams, $calcmode);
-if (isModEnabled('accounting') && $modecompta != 'BOOKKEEPING') {
- print info_admin($langs->trans("WarningReportNotReliable"), 0, 0, 1);
+if (isModEnabled('accounting')) {
+ if ($modecompta != 'BOOKKEEPING') {
+ print info_admin($langs->trans("WarningReportNotReliable"), 0, 0, 1);
+ } else {
+ // Test if there is at least one line in bookkeeping
+ $pcgverid = getDolGlobalInt('CHARTOFACCOUNTS');
+ $pcgvercode = dol_getIdFromCode($db, $pcgverid, 'accounting_system', 'rowid', 'pcg_version');
+ if (empty($pcgvercode)) {
+ $pcgvercode = $pcgverid;
+ }
+
+ $sql = "SELECT b.rowid ";
+ $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b,";
+ $sql .= " ".MAIN_DB_PREFIX."accounting_account as aa";
+ $sql .= " WHERE b.entity = ".$conf->entity; // In module double party accounting, we never share entities
+ $sql .= " AND b.numero_compte = aa.account_number";
+ $sql .= " AND aa.entity = ".$conf->entity;
+ $sql .= " AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'";
+ $sql .= $db->plimit(1);
+
+ $resql = $db->query($sql);
+ $nb = $db->num_rows($resql);
+ if ($nb == 0) {
+ $langs->load("errors");
+ print info_admin($langs->trans("WarningNoDataTransferedInAccountancyYet"), 0, 0, 1);
+ }
+ }
}
// Show Array
@@ -248,6 +275,7 @@ $amount_ht = array();
$address_zip = array();
$address_town = array();
$address_pays = array();
+
if ($modecompta == 'CREANCES-DETTES') {
$sql = "SELECT DISTINCT s.rowid as socid, s.nom as name, s.zip, s.town, s.fk_pays,";
$sql .= " sum(f.total_ht) as amount, sum(f.total_ttc) as amount_ttc";
@@ -370,7 +398,7 @@ print img_picto('', 'category', 'class="paddingrightonly"');
print $formother->select_categories(Categorie::TYPE_SUPPLIER, $selected_cat, 'search_categ', 0, $langs->trans("Category"));
print ' ';
print ' ';
-print '