diff --git a/Models/ClientMapper.php b/Models/ClientMapper.php index d27f6be..bfe422a 100755 --- a/Models/ClientMapper.php +++ b/Models/ClientMapper.php @@ -29,6 +29,9 @@ use phpOMS\Stdlib\Base\SmartDateTime; */ class ClientMapper extends DataMapperFactory { + /** + * @todo Re-implement, still in use? + */ public static function mtdYtdClientAttribute( \DateTime $startCurrent, \DateTime $endCurrent, @@ -36,7 +39,8 @@ class ClientMapper extends DataMapperFactory \DateTime $endComparison, int $businessStart = 1, string $language = 'en' - ) { + ) : array + { $endCurrentIndex = SmartDateTime::calculateMonthIndex((int) $endCurrent->format('m'), $businessStart); // @todo this query doesn't return clients that have not segment etc. defined. @@ -81,7 +85,7 @@ class ClientMapper extends DataMapperFactory MONTH(billing_bill_performance_date) ASC' ); - $results = $query->execute()->fetchAll(\PDO::FETCH_ASSOC); + $results = $query->execute()?->fetchAll(\PDO::FETCH_ASSOC) ?? []; $oldIndex = 1; $period = 1; diff --git a/Models/GeneralMapper.php b/Models/GeneralMapper.php index 4de5dd9..da33564 100755 --- a/Models/GeneralMapper.php +++ b/Models/GeneralMapper.php @@ -29,13 +29,17 @@ use phpOMS\Stdlib\Base\SmartDateTime; */ class GeneralMapper extends DataMapperFactory { + /** + * @todo Probably re-implement, still used? + */ public static function monthlySalesProfit( \DateTime $startCurrent, \DateTime $endCurrent, \DateTime $startComparison, \DateTime $endComparison, int $businessStart = 1 - ) { + ) : array + { $endCurrentIndex = SmartDateTime::calculateMonthIndex((int) $endCurrent->format('m'), $businessStart); $query = new Builder(self::$db); @@ -58,7 +62,7 @@ class GeneralMapper extends DataMapperFactory MONTH(billing_bill_performance_date) ASC' ); - $results = $query->execute()->fetchAll(\PDO::FETCH_ASSOC); + $results = $query->execute()?->fetchAll(\PDO::FETCH_ASSOC) ?? []; $oldIndex = 1; $period = 1; @@ -123,6 +127,9 @@ class GeneralMapper extends DataMapperFactory ]; } + /** + * @todo Probably re-implement, still used? + */ public static function annualSalesProfit( SmartDateTime $historyStart, \DateTime $endCurrent, @@ -148,7 +155,7 @@ class GeneralMapper extends DataMapperFactory MONTH(billing_bill_performance_date) ASC' ); - $results = $query->execute()->fetchAll(\PDO::FETCH_ASSOC); + $results = $query->execute()?->fetchAll(\PDO::FETCH_ASSOC) ?? []; $annualSales = []; for ($i = 1; $i < 11; ++$i) { diff --git a/Models/ItemMapper.php b/Models/ItemMapper.php index b718c5a..c14dfa6 100755 --- a/Models/ItemMapper.php +++ b/Models/ItemMapper.php @@ -29,6 +29,9 @@ use phpOMS\Stdlib\Base\SmartDateTime; */ class ItemMapper extends DataMapperFactory { + /** + * @todo Re-implement, still in use? + */ public static function mtdYtdItemAttribute( \DateTime $startCurrent, \DateTime $endCurrent, @@ -36,7 +39,8 @@ class ItemMapper extends DataMapperFactory \DateTime $endComparison, int $businessStart = 1, string $language = 'en' - ) { + ) : array + { $endCurrentIndex = SmartDateTime::calculateMonthIndex((int) $endCurrent->format('m'), $businessStart); // @todo this query doesn't return clients that have not segment etc. defined. @@ -83,7 +87,7 @@ class ItemMapper extends DataMapperFactory MONTH(billing_bill_performance_date) ASC' ); - $results = $query->execute()->fetchAll(\PDO::FETCH_ASSOC); + $results = $query->execute()?->fetchAll(\PDO::FETCH_ASSOC) ?? []; $oldIndex = 1; $period = 1; diff --git a/Models/RegionMapper.php b/Models/RegionMapper.php index 65b3132..22af8e6 100755 --- a/Models/RegionMapper.php +++ b/Models/RegionMapper.php @@ -33,11 +33,15 @@ use phpOMS\Stdlib\Base\SmartDateTime; */ class RegionMapper extends DataMapperFactory { + /** + * @todo Re-implement, still in use? + */ public static function monthlySalesProfit( \DateTime $start, \DateTime $end, int $businessStart = 1 - ) { + ) : array + { $endCurrentIndex = SmartDateTime::calculateMonthIndex((int) $end->format('m'), $businessStart); $query = new Builder(self::$db); @@ -67,7 +71,7 @@ class RegionMapper extends DataMapperFactory address_country' ); - $results = $query->execute()->fetchAll(\PDO::FETCH_ASSOC); + $results = $query->execute()?->fetchAll(\PDO::FETCH_ASSOC) ?? []; $monthlySales = []; @@ -113,6 +117,9 @@ class RegionMapper extends DataMapperFactory return [$mtd, $ytd, $monthlySales]; } + /** + * @todo Re-implement, still in use? + */ public static function annualCustomerCountry( SmartDateTime $historyStart, \DateTime $endCurrent, @@ -144,7 +151,7 @@ class RegionMapper extends DataMapperFactory address_country' ); - $results = $query->execute()->fetchAll(\PDO::FETCH_ASSOC); + $results = $query->execute()?->fetchAll(\PDO::FETCH_ASSOC) ?? []; $annualCustomer = []; @@ -186,6 +193,9 @@ class RegionMapper extends DataMapperFactory return $annualCustomer; } + /** + * @todo Re-implement, still in use? + */ public static function mtdYtdClientCountry( \DateTime $startCurrent, \DateTime $endCurrent, @@ -222,7 +232,7 @@ class RegionMapper extends DataMapperFactory address_country ASC' ); - $results = $query->execute()->fetchAll(\PDO::FETCH_ASSOC); + $results = $query->execute()?->fetchAll(\PDO::FETCH_ASSOC) ?? []; $oldIndex = 1; $period = 1; @@ -293,9 +303,12 @@ class RegionMapper extends DataMapperFactory // @todo remove businessStart, that should be baked into the historyStart // Explanation: in the past I had to compare periods which weren't even business years!!! + /** + * @todo Re-implement, still in use? + */ public static function salesProfitCountry( - SmartDateTime $historyStart, - SmartDateTime $historyEnd, + \DateTime $historyStart, + \DateTime $historyEnd, \DateTime $currentStart, \DateTime $currentEnd ) : array { @@ -322,7 +335,7 @@ class RegionMapper extends DataMapperFactory address_country' ); - $results = $query->execute()->fetchAll(\PDO::FETCH_ASSOC); + $results = $query->execute()?->fetchAll(\PDO::FETCH_ASSOC) ?? []; $sales = []; $period = 0; @@ -354,6 +367,9 @@ class RegionMapper extends DataMapperFactory return $sales; } + /** + * @todo Re-implement, still in use? + */ public static function mtdYtdCountry( \DateTime $startCurrent, \DateTime $endCurrent, @@ -390,7 +406,7 @@ class RegionMapper extends DataMapperFactory address_country ASC' ); - $results = $query->execute()->fetchAll(\PDO::FETCH_ASSOC); + $results = $query->execute()?->fetchAll(\PDO::FETCH_ASSOC) ?? []; $oldIndex = 1; $period = 1; @@ -464,6 +480,9 @@ class RegionMapper extends DataMapperFactory ]; } + /** + * @todo Re-implement, still in use? + */ public static function countryToRegion(array $countries, array $region, array $columns) : array { $tempStruct = []; @@ -472,6 +491,7 @@ class RegionMapper extends DataMapperFactory } $regions = ['Other' => $tempStruct]; + $definitions = []; foreach ($region as $r) { $definitions[$r] = ($temp = ISO3166TwoEnum::getRegion($r)) === [] ? [$r] : $temp; @@ -500,6 +520,9 @@ class RegionMapper extends DataMapperFactory return $regions; } + /** + * @todo Re-implement, still in use? + */ public static function countryIntervalToRegion(array $countries, array $region, array $columns) : array { if (empty($countries)) { @@ -517,6 +540,8 @@ class RegionMapper extends DataMapperFactory 'Other' => \array_fill(1, $count, $tempStruct), ]; + $definitions = []; + foreach ($region as $r) { $definitions[$r] = ($temp = ISO3166TwoEnum::getRegion($r)) === [] ? [$r] : $temp; $regions[$r] = \array_fill(1, $count, $tempStruct); diff --git a/Theme/Backend/Lang/en.lang.php b/Theme/Backend/Lang/en.lang.php index 3ee26ec..ebc444d 100755 --- a/Theme/Backend/Lang/en.lang.php +++ b/Theme/Backend/Lang/en.lang.php @@ -13,55 +13,51 @@ declare(strict_types=1); return ['SalesAnalysis' => [ - 'ItemAttribute' => 'Item Attribute', - 'ClientAttribute' => 'Client Attribute', - 'Months' => 'Months', - 'Total' => 'Total', - 'Year' => 'Year', - 'Month' => 'Month', - 'All' => 'All', - 'New' => 'New', - 'Lost' => 'Lost', - 'Continent' => 'Continent', - 'SalesPY' => 'Sales PY', - 'SalesA' => 'Sales A', - 'ProfitPY' => 'Profit PY', - 'ProfitA' => 'Profit A', - 'DiffPY' => 'Δ PY', - 'Data' => 'Data', - 'Actual' => 'Actual', - 'Segment' => 'Segment', - 'Section' => 'Section', - 'Group' => 'Group', - 'Region' => 'Region', - 'Filter' => 'Filter', - 'Country' => 'Country', - 'Category' => 'Category', - 'General' => 'General', - 'MTD' => 'MTD', - 'YTD' => 'YTD', - 'GrossProfit' => 'Gross Profit', - 'SalesProfit' => 'Sales / Profit', - 'monthly' => 'monthly', - 'annually' => 'annually', - 'Profit' => 'Profit', - 'Start' => 'Start', - 'End' => 'End', - 'Sales' => 'Sales', - 'Client' => 'Client', - 'Clients' => 'Clients', - 'World' => 'World', - 'DomesticExport' => 'Domestic & Export', - 'Comparison' => 'Comparison', - 'Continents' => 'Continents', - 'Data' => 'Data', - 'Domestic' => 'Domestic', - 'Export' => 'Export', - 'Month' => 'Month', - 'Current' => 'Current', - 'Analyze' => 'Analyze', - 'Regions' => 'Regions', - 'Total' => 'Total', - 'Type' => 'Type', - 'Year' => 'Year', + 'ItemAttribute' => 'Item Attribute', + 'ClientAttribute' => 'Client Attribute', + 'Months' => 'Months', + 'Year' => 'Year', + 'Month' => 'Month', + 'All' => 'All', + 'New' => 'New', + 'Lost' => 'Lost', + 'Continent' => 'Continent', + 'SalesPY' => 'Sales PY', + 'SalesA' => 'Sales A', + 'ProfitPY' => 'Profit PY', + 'ProfitA' => 'Profit A', + 'DiffPY' => 'Δ PY', + 'Actual' => 'Actual', + 'Segment' => 'Segment', + 'Section' => 'Section', + 'Group' => 'Group', + 'Region' => 'Region', + 'Filter' => 'Filter', + 'Country' => 'Country', + 'Category' => 'Category', + 'General' => 'General', + 'MTD' => 'MTD', + 'YTD' => 'YTD', + 'GrossProfit' => 'Gross Profit', + 'SalesProfit' => 'Sales / Profit', + 'monthly' => 'monthly', + 'annually' => 'annually', + 'Profit' => 'Profit', + 'Start' => 'Start', + 'End' => 'End', + 'Sales' => 'Sales', + 'Client' => 'Client', + 'Clients' => 'Clients', + 'World' => 'World', + 'DomesticExport' => 'Domestic & Export', + 'Comparison' => 'Comparison', + 'Continents' => 'Continents', + 'Data' => 'Data', + 'Domestic' => 'Domestic', + 'Export' => 'Export', + 'Current' => 'Current', + 'Analyze' => 'Analyze', + 'Regions' => 'Regions', + 'Total' => 'Total', + 'Type' => 'Type', ]];