init
This commit is contained in:
87
modules/EcmCharts/SalesChart.php
Normal file
87
modules/EcmCharts/SalesChart.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
if (! defined ( 'sugarEntry' ) || ! sugarEntry)
|
||||
die ( 'Not A Valid Entry Point' );
|
||||
|
||||
/*****************************************************/
|
||||
/*********************** PREPARE *********************/
|
||||
/*****************************************************/
|
||||
$db = $GLOBALS ['db'];
|
||||
|
||||
require_once('include/Dashlets/Dashlet.php');
|
||||
require_once('include/Sugar_Smarty.php');
|
||||
require_once('modules/EcmCharts/Dashlets/MyChartsSalesDashlet/ChartSalesHelper.php');
|
||||
global $mod_strings;
|
||||
|
||||
$options = array();
|
||||
|
||||
// Data od
|
||||
if(!$_GET['date_from'])
|
||||
$options['date_from'] = date("01.m.Y");
|
||||
else
|
||||
$options['date_from'] = $_GET['date_from'];
|
||||
|
||||
// Data do
|
||||
if(!$_GET['date_to'])
|
||||
$options['date_to'] = date("d.m.Y");
|
||||
else
|
||||
$options['date_to'] = $_GET['date_to'];
|
||||
|
||||
if(!$_GET['type'])
|
||||
$options['type'] = "%";
|
||||
else
|
||||
$options['type'] = $_GET['type'];
|
||||
|
||||
if(!$_GET['comparativeData'])
|
||||
$options['comparativeData'] = "disabled";
|
||||
else
|
||||
$options['comparativeData'] = $_GET['comparativeData'];
|
||||
|
||||
if(!$_GET['detail'])
|
||||
$options['detail'] = "category";
|
||||
else
|
||||
$options['detail'] = $_GET['detail'];
|
||||
|
||||
if(!$_GET['chartType']) {
|
||||
$options['chartType'] = "column";
|
||||
} else {
|
||||
$options['chartType'] = $_GET['chartType'];
|
||||
}
|
||||
|
||||
$optionsForComparativeData = $options;
|
||||
$optionsForComparativeData["date_from"] = date("Y-m-d",strtotime(date("Y-m-d", strtotime($optionsForComparativeData["date_from"]))." -1 year"));
|
||||
$optionsForComparativeData["date_to"] = date("Y-m-d",strtotime(date("Y-m-d", strtotime($optionsForComparativeData["date_to"]))." -1 year"));
|
||||
|
||||
$db_connection_handler = $GLOBALS["db"];
|
||||
|
||||
/*
|
||||
* DATA
|
||||
*/
|
||||
$cd = null;
|
||||
|
||||
if( $options["comparativeData"] == "enabled")
|
||||
{
|
||||
$comparativeData = new ChartSalesHelper( $db_connection_handler, $optionsForComparativeData);
|
||||
if( $options["detail"] == 'category')
|
||||
{
|
||||
$cd = $comparativeData->getAllCategories();
|
||||
} else {
|
||||
$cd = $comparativeData->getAllSubcategories();
|
||||
}
|
||||
}
|
||||
|
||||
$helper = new ChartSalesHelper( $db_connection_handler, $options, $cd );
|
||||
$data = $helper->renderGoogleChartOptions();
|
||||
|
||||
// create & execute smarty
|
||||
$Calendar_daFormat = str_replace("d","%d",str_replace("m","%m",str_replace("Y","%Y",$GLOBALS['timedate']->get_date_format())));
|
||||
$smarty = new Sugar_Smarty();
|
||||
$smarty -> assign( "dateFormat", $Calendar_daFormat);
|
||||
$smarty -> assign('date_from', $options["date_from"]);
|
||||
$smarty -> assign('date_to', $options["date_to"]);
|
||||
$smarty -> assign('chartOptions', $data);
|
||||
$smarty -> assign('detail', $options["detail"]);
|
||||
$smarty -> assign('comparativeData', $options['comparativeData']);
|
||||
$smarty -> assign('chartType', $options['chartType']);
|
||||
$smarty -> assign('LANG', $mod_strings);
|
||||
echo $smarty->display ( 'modules/EcmCharts/tpls/SalesChart.tpl' );
|
||||
?>
|
||||
Reference in New Issue
Block a user