This commit is contained in:
2024-04-27 09:23:34 +02:00
commit 11e713ca6f
11884 changed files with 3263371 additions and 0 deletions

View File

@@ -0,0 +1,121 @@
<?php
class ChartAnnualSalesHelper
{
private $outputOptions = null;
private $options = null;
private $db = null;
private $monthName = null;
private $comparativeData = null;
private $months;
public function ChartAnnualSalesHelper($db, $options, $lang, $comparativeData = null)
{
$this->options = $options;
$this->db = $db;
$this->comparativeData = $comparativeData;
$this->monthName = array($lang['LBL_JANUARY'],
$lang['LBL_FEBRUARY'],
$lang['LBL_MARCH'],
$lang['LBL_APRIL'],
$lang['LBL_MAY'],
$lang['LBL_JUNE'],
$lang['LBL_JULY'],
$lang['LBL_AUGUST'],
$lang['LBL_SEPTEMBER'],
$lang['LBL_OCTOBER'],
$lang['LBL_NOVEMBER'],
$lang['LBL_DECEMBER']);
}
// Zwraca ustawienia Google Charts
public function getChartOptions()
{
$months = $this->getMonths();
$data = "";
for( $i = 0; $i < count($months); $i++ )
{
if( $months[$i] != 0 && $months[$i] != null)
{
$value = sprintf("%.2f", (float)$months[$i]);
$data .= "['".$this->monthName[$i]."', ". $value;
if( $this->options["comparativeData"] == "enabled" )
$data .= ", ".$this->comparativeData[$i].'0';
$data .= "],";
}
}
$data = rtrim($data, ",");
return $data;
}
// Pobiera tablice z wartościami sum netto dla każdego roku
private function getMonths()
{
$months = array();
$thisYear = date("Y");
$thisMonth = date("m");
for( $i = 1; $i <= 12; $i++ )
{
$result = $this->getSubtotalByMonth(($i <= 9 ? '0'.$i : $i), $this->options['year']);
array_push($months, $result);
}
$this->months = $months;
return $months;
}
// Metoda zwraca cenę netto dla danego miesiąca w danym roku
private function getSubtotalByMonth($month, $year)
{
$type = $this->options["type"];
$query = "
SELECT
SUM(CASE WHEN e.currency_value = '0' OR e.currency_value = '' OR e.currency_value=0 OR e.currency_value is null
THEN
e.total_netto
ELSE
e.total_netto*e.currency_value
END
) as 'subtotal'
FROM
ecminvoiceouts e
WHERE e.canceled = '0'
AND e.deleted = '0'
AND e.type LIKE '$type'
AND e.register_date LIKE '$year-$month-%'
";
//echo $query."<br><br>";
if( $this->options["contractor_id"] && $this->options["contractor_name"])
{
$query .= "AND e.parent_id = '".$this->options["contractor_id"]."'";
}
$results = $this->db->query($query);
$result = $this->db->fetchByAssoc( $results );
return $result['subtotal'];
}
public function getMonthsArray()
{
return $this->months;
}
public function haveComparativeData()
{
if( $this->comparativeData != null )
return true;
else
return false;
}
}
?>

View File

@@ -0,0 +1,45 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/**
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2009 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
*/
global $mod_strings;
$dashletMeta['MyChartsAnnualSalesDashlet'] = array(
'title' => 'Raport sprzedaży rocznej z podziałem na miesiące',
'description' => 'Wykres słupkowy, w widoku poziomym przedstawiający sprzedaż w aktualnym roku z danymi porównawczymi sprzed roku i możliwością filtrowania',
'category' => 'Charts');
?>

View File

@@ -0,0 +1,152 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
require_once('include/Dashlets/Dashlet.php');
require_once('include/Sugar_Smarty.php');
require_once('ChartAnnualSalesHelper.php');
class MyChartsAnnualSalesDashlet extends Dashlet {
var $savedText; // users's saved text
var $height = '300'; // height of the pad
var $firstLoad = 'yes';
function MyChartsAnnualSalesDashlet($id, $def = null) {
global $current_user, $mod_strings, $app_strings;
require('modules/EcmCharts/Dashlets/MyChartsAnnualSalesDashlet/MyChartsAnnualSalesDashlet.meta.php');
require('modules/EcmCharts/language/pl_pl.lang.php');
parent::Dashlet($id); // call parent constructor
$this->isConfigurable = true; // dashlet is configurable
$this->hasScript = false; // dashlet has java ipt attached to it
$options = $this->loadOptions();
// if no custom title, use default
if(!$options["title"])
$options["title"] = "Wykres sprzedaży rocznej z podziałem na miesiące";
$this->title = $options["title"];
}
function display() {
global $current_user, $mod_strings, $app_strings;
$options = $this->loadOptions();
$comparativeData = null;
$options2 = null;
$db_connection_handler = $GLOBALS["db"];
$options = $this->loadOptions();
// Data od
if(!$options['year'])
$options['year'] = date("Y");
if(!$options["comparativeData"])
$options["comparativeData"] = 'disabled';
if(!$options["type"])
$options["type"] = '%';
if(!$options["chartType"])
$options["chartType"] = 'column';
if( $options["comparativeData"] == 'enabled')
{
$options2 = $this->loadOptions();
$options2["year"] -= 1;
$helper2 = new ChartAnnualSalesHelper($db_connection_handler, $options2, $mod_strings);
$helper2->getChartOptions();
// Pobieram dane sprzed roku
$comparativeData = $helper2->getMonthsArray();
$helper = new ChartAnnualSalesHelper($db_connection_handler, $options, $mod_strings, $comparativeData);
$data = $helper->getChartOptions();
} else {
$helper = new ChartAnnualSalesHelper($db_connection_handler, $options, $mod_strings);
$data = $helper->getChartOptions();
}
/*
* SMARTY
*/
$smarty = new Sugar_Smarty();
$smarty->assign('chartOptions', $data);
$smarty->assign('comparativeData', $options['comparativeData']);
$smarty->assign('year', $options["year"]);
$smarty->assign('chartType', $options["chartType"]);
$smarty->assign('LANG', $mod_strings);
if( $helper->haveComparativeData() )
$smarty->assign('comparative_data_on', 'true');
else
$smarty->assign('comparative_data_on', 'false');
// Pobieranie widoku
$output = $smarty->fetch('modules/EcmCharts/Dashlets/MyChartsAnnualSalesDashlet/MyChartsAnnualSalesDashlet.tpl');
// return parent::display for title and smarty template
return parent::display($this->dashletStrings['LBL_DBLCLICK_HELP']) . $output;
}
function displayOptions() {
global $mod_strings,$current_user;
// format daty
$smarty = new Sugar_Smarty();
// Pobieram ustawienia
$options = $this->loadOptions();
// Data od
if(!$options['year'])
$options['year'] = date("Y");
if(!$options["comparativeData"])
$options["comparativeData"] = 'disabled';
if(!$options["type"])
$options["type"] = '%';
if(!$options["chartType"])
$options["chartType"] = 'column';
if(!$options["title"])
$options["title"] = "Raport sprzedaży w roku z podziałem na miesiące";
// Generowanie lat do selektora
$y = range(2000, date("Y"));
$years = array_reverse($y,true);
//The id must be assigned in all dashlet options pages
$smarty->assign('id', $this->id);
// Typ dokumentu: all, normal, correct
$smarty->assign('type', $options['type']);
$smarty->assign('year', $options['year']);
$smarty->assign('contractor_id', $options["contractor_id"]);;
$smarty->assign('contractor_name', $options["contractor_name"]);
$smarty->assign('chartType', $options["chartType"]);
$smarty->assign('years', $years);
$smarty->assign('LANG', $mod_strings);
$smarty->assign('title', $options["title"]);
// Pokazywać dane porównawcze? Tak: enabled, nie: disabled
$smarty->assign('comparativeData', $options['comparativeData']);
// Przekazuję widok opcji do metody displayOptions()
return parent::displayOptions() . $smarty->fetch('modules/EcmCharts/Dashlets/MyChartsAnnualSalesDashlet/MyChartsAnnualSalesDashletOptions.tpl');
}
// Zapisywanie opcji dashletu
function saveOptions($req) {
$options = array();
$options["year"] = $req["year"];
$options["comparativeData"] = $req["comparativeData"];
$options["type"] = $req["type"];
$options["chartType"] = $req["chartType"];
$options["title"] = $req["title"];
if( $req["account_name"] == '' )
{
$options["contractor_name"] = '';
$options["contractor_id"] = '';
} else {
$options["contractor_name"] = $req['account_name'];
$options["contractor_id"] = $req['account_id'];
}
return $options;
}
}
?>

View File

@@ -0,0 +1,152 @@
{*
/**
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2009 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
*/
*}
{if $chartOptions == ''}
{literal}
<style type="text/css">
.no-data {
display: table;
width: 100%;
height: 100%;
}
.textCenter {
display: table-cell;
vertical-align: middle;
text-align: center;
}
.textCenter span {
font-size: 16px;
border: 1px dashed #E03E3E;
padding: 10px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
box-shadow: 10px 10px 5px #AAAAAA;
background-color: #FFDEDE;
color: #E03E3E;
}
</style>
{/literal}
{/if}
{if $chartOptions == ''}
<div id='jotpsadad_{$id}' ondblclick='JotPad.edit(this, "{$id}")' style='overflow: auto; width: 100%; height: 200px; border: 1px #ddd solid'>
<div id="annual_sales_chart{$id}" style="width: 100%; height: 100%;">
<div class="no-data">
<div class="textCenter">
<span>
{$LANG.LBL_NO_DATA_CHANGE_FILTER}
</span>
</div>
</div>
</div>
</div>
{else}
<div style='overflow: auto; width: 100%; height: 800px; border: 1px #ddd solid'>
<div id="annual_sales_chart{$id}" style="width: 100%; height: 97%;"></div>
</div>
{/if}
<!-- GOOGLE CHARTS API -->
{if $chartOptions != ''}
{literal}
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript" src="modules/EcmCharts/Dashlets/MyChartsSalesDashlet/js/salesChart.js"></script>
<script type="text/javascript">
// Load the Visualization API and the piechart package.
google.load('visualization', '1', {'packages':['corechart','geochart','table']});
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Rok', {/literal}'{$LANG.LBL_SALE}'
{if $comparativeData == 'enabled'} , '{$LANG.LBL_SALE_IN_PAST_YEAR}'{/if}
{literal}],
{/literal}
{$chartOptions}
{literal}
]);
var formatter = new google.visualization.NumberFormat({
suffix: 'zł'
});
formatter.format(data, 1); // Apply formatter to second column.
{/literal}
{if $comparative_data_on == 'true' }
formatter.format(data, 2); // Apply formatter to second column.
{/if}
{literal}
var options = {
{/literal}
title: '{ $LANG.LBL_SALES_CHART_IN }{$year}',
{literal}
legend: {position: 'bottom', textStyle: {fontSize: 10}},
tooltip:{textStyle:{fontSize:'10'}},
vAxis:{title: {/literal}'{$LANG.LBL_VALUEOFSALES}'{literal},textStyle:{color: '#000000',fontSize: '11', paddingRight: '100',marginRight: '100'}},
hAxis:{title:'',textStyle:{color: '#000000',fontSize: '10', paddingRight: '100',marginRight: '100'}}
};
{/literal}
{if $chartType == 'column' or $chartType == ''}
var chart = new google.visualization.ColumnChart(document.getElementById('annual_sales_chart{$id}'));
{elseif $chartType == 'pie'}
var chart = new google.visualization.PieChart(document.getElementById('annual_sales_chart{$id}'));
{elseif $chartType == 'line'}
var chart = new google.visualization.LineChart(document.getElementById('annual_sales_chart{$id}'));
{elseif $chartType == 'stepped'}
var chart = new google.visualization.SteppedAreaChart(document.getElementById('annual_sales_chart{$id}'));
{else}
var chart = new google.visualization.AreaChart(document.getElementById('annual_sales_chart{$id}'));
{/if}
{literal}
chart.draw(data, options);
}
// sekunda opóźnienia, żeby zdążył wczytać się moduł "visualization"
setTimeout(drawChart, 1000);
</script>
{/literal}
{/if}

View File

@@ -0,0 +1,160 @@
{*
/**
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2009 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
*/
*}
<script type="text/javascript" src="modules/EcmCharts/javascript/jquery-2.1.1.min.js"></script>
<script type="text/javascript">
{literal}
function listenerFunction() {
//location.reload();
};
$("#chartTypeSelector").change(function() {
if( $(this).val() == 'pie' )
{
$("#documentTypeSelector").val("normal");
}
});
$("#documentTypeSelector").change(function(){
if( $(this).val() == 'correct' && $("#chartTypeSelector").val() == 'pie' )
{
$("#chartTypeSelector").val("column");
}
});
{/literal}
</script>
<style type="text/css">
{literal}
table tr td {
padding-top: 20px;
}
table tr td select {
width: 140px;
}
{/literal}
</style>
<div style='width: 600px'>
<form name="configure_{$id}" action="index.php" method="post" onSubmit='return SUGAR.dashlets.postForm("configure_{$id}", SUGAR.mySugar.uncoverPage);'>
<input type='hidden' name='id' value='{$id}'>
<input type='hidden' name='module' value='Home'>
<input type='hidden' name='action' value='ConfigureDashlet'>
<input type='hidden' name='to_pdf' value='true'>
<input type='hidden' name='configure' value='true'>
<table width="600" cellpadding="0" cellspacing="0" border="0" class="tabForm" align="center">
<tr>
<td>{$LANG.LBL_TITLE}: </td>
<td>
<input type="text" value="{$title}" name="title" />
</td>
</tr>
<tr>
<td>{$LANG.LBL_SELECT_YEAR}: </td>
<td>
<select name="year">
{foreach from=$years item=y}
<option value="{$y}" { if $y == $year || $year == ""} selected="true" {/if}>{$y}</option>
{/foreach}
</select>
</td>
</tr>
<tr>
<td>{$LANG.LBL_INCLUDED_DOCUMENT_TYPE}: </td>
<td>
<select id="documentTypeSelector" name="type">
<option value="%" { if $type == "%" || $type == ""} selected="true" {/if}>{$LANG.LBL_NORMAL_AND_CORRECT}</option>
<option value="normal" { if $type == "normal"} selected="true" {/if}>{$LANG.LBL_NORMAL_ONLY}</option>
<option value="correct" { if $type == "correct"} selected="true" {/if}>{$LANG.LBL_CORRECT_ONLY}</option>
</select>
</td>
</tr>
<tr>
{* Search by contractor *}
<td>{$LANG.LBL_CONTRACTOR}</td>
<td>
<input id="search_account_name" type="text" value="{$contractor_name}" name="account_name">
<input id="search_account_id" type="hidden" value="{$contractor_id}" name="account_id">
<input class="button" type="button" value="{$LANG.LBL_SELECT}" accesskey="T" title="Select [Alt+T]" value="" name="btn_account_name" onClick="getContractor()">
{* Open popup window to select contractor *}
<script type="text/javascript">
function getContractor()
{ldelim}
open_popup("Accounts", 600, 400, "", true, false,
{ldelim}
"call_back_function":"set_return","form_name":"configure_{$id}","field_to_name_array":
{ldelim}"id":"search_account_id","name":"search_account_name"{rdelim}
{rdelim}, "single", true);
{rdelim};
</script>
</td>
</tr>
<tr>
<td>{$LANG.LBL_CHARTTYPE}: </td>
<td>
<select id="chartTypeSelector" name="chartType">
<option value="column" { if $chartType == "column" || $chartType == ""} selected="true" {/if}>{$LANG.LBL_CHARTTYPECOLUMN}</option>
<option value="pie" { if $chartType == "pie"} selected="true" {/if}>{$LANG.LBL_CHARTTYPEPIE}</option>
<option value="line" { if $chartType == "line"} selected="true" {/if}>{$LANG.LBL_CHARTTYPELINE}</option>
<option value="area" { if $chartType == "area"} selected="true" {/if}>{$LANG.LBL_CHARTTYPEAREA}</option>
<option value="stepped" { if $chartType == "stepped"} selected="true" {/if}>{$LANG.LBL_CHARTTYPESTEPPEDAREA}</option>
</select>
</td>
</tr>
<tr>
<td>{$LANG.LBL_VIEW_COMPARATIVE_DATA}: </td>
<td>
<input type="radio" name="comparativeData" value="enabled" { if $comparativeData == "enabled" || $comparativeData == "" } checked {/if}> {$LANG.LBL_YES}
<input type="radio" name="comparativeData" style="margin-left: 20px" value="disabled" { if $comparativeData == "disabled" || $comparativeData == "" } checked {/if}> {$LANG.LBL_NO}
</td>
</tr>
<tr>
<td colspan="4" style="text-align: center;">
<input id="submitButton" type="submit" class="button" style="margin-top: 30px;" value="{$LANG.LBL_SAVECHANGES}" onclick="setTimeout(listenerFunction, 1000);">
</td>
</tr>
</table>
</form>
</div>

View File

@@ -0,0 +1,121 @@
<?php
class ChartAnnualSalesHelper
{
private $outputOptions = null;
private $options = null;
private $db = null;
private $monthName = null;
private $comparativeData = null;
private $months;
public function ChartAnnualSalesHelper($db, $options, $lang, $comparativeData = null)
{
$this->options = $options;
$this->db = $db;
$this->comparativeData = $comparativeData;
$this->monthName = array($lang['LBL_JANUARY'],
$lang['LBL_FEBRUARY'],
$lang['LBL_MARCH'],
$lang['LBL_APRIL'],
$lang['LBL_MAY'],
$lang['LBL_JUNE'],
$lang['LBL_JULY'],
$lang['LBL_AUGUST'],
$lang['LBL_SEPTEMBER'],
$lang['LBL_OCTOBER'],
$lang['LBL_NOVEMBER'],
$lang['LBL_DECEMBER']);
}
// Zwraca ustawienia Google Charts
public function getChartOptions()
{
$months = $this->getMonths();
$data = "";
for( $i = 0; $i < count($months); $i++ )
{
if( $months[$i] != 0 && $months[$i] != null)
{
$value = sprintf("%.2f", (float)$months[$i]);
$data .= "['".$this->monthName[$i]."', ". $value;
if( $this->options["comparativeData"] == "enabled" )
$data .= ", ".$this->comparativeData[$i].'0';
$data .= "],";
}
}
$data = rtrim($data, ",");
return $data;
}
// Pobiera tablice z wartościami sum netto dla każdego roku
private function getMonths()
{
$months = array();
$thisYear = date("Y");
$thisMonth = date("m");
for( $i = 1; $i <= 12; $i++ )
{
$result = $this->getSubtotalByMonth(($i <= 9 ? '0'.$i : $i), $this->options['year']);
array_push($months, $result);
}
$this->months = $months;
return $months;
}
// Metoda zwraca cenę netto dla danego miesiąca w danym roku
private function getSubtotalByMonth($month, $year)
{
$type = $this->options["type"];
$query = "
SELECT
SUM(CASE WHEN e.currency_value = '0' OR e.currency_value = '' OR e.currency_value=0 OR e.currency_value is null
THEN
e.total_netto
ELSE
e.total_netto*e.currency_value
END
) as 'subtotal'
FROM
ecminvoiceouts e
WHERE e.canceled = '0'
AND e.deleted = '0'
AND e.type LIKE '$type'
AND e.register_date LIKE '$year-$month-%'
";
//echo $query."<br><br>";
if( $this->options["contractor_id"] && $this->options["contractor_name"])
{
$query .= "AND e.parent_id = '".$this->options["contractor_id"]."'";
}
$results = $this->db->query($query);
$result = $this->db->fetchByAssoc( $results );
return $result['subtotal'];
}
public function getMonthsArray()
{
return $this->months;
}
public function haveComparativeData()
{
if( $this->comparativeData != null )
return true;
else
return false;
}
}
?>

View File

@@ -0,0 +1,45 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/**
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2009 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
*/
global $mod_strings;
$dashletMeta['MyChartsAnnualSalesDashlet'] = array(
'title' => 'Raport sprzedaży rocznej z podziałem na miesiące',
'description' => 'Wykres słupkowy, w widoku poziomym przedstawiający sprzedaż w aktualnym roku z danymi porównawczymi sprzed roku i możliwością filtrowania',
'category' => 'Charts');
?>

View File

@@ -0,0 +1,152 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
require_once('include/Dashlets/Dashlet.php');
require_once('include/Sugar_Smarty.php');
require_once('ChartAnnualSalesHelper.php');
class MyChartsAnnualSalesDashlet extends Dashlet {
var $savedText; // users's saved text
var $height = '300'; // height of the pad
var $firstLoad = 'yes';
function MyChartsAnnualSalesDashlet($id, $def = null) {
global $current_user, $mod_strings, $app_strings;
require('modules/EcmCharts/Dashlets/MyChartsAnnualSalesDashlet/MyChartsAnnualSalesDashlet.meta.php');
require('modules/EcmCharts/language/pl_pl.lang.php');
parent::Dashlet($id); // call parent constructor
$this->isConfigurable = true; // dashlet is configurable
$this->hasScript = false; // dashlet has java ipt attached to it
$options = $this->loadOptions();
// if no custom title, use default
if(!$options["title"])
$options["title"] = "Wykres sprzedaży rocznej z podziałem na miesiące";
$this->title = $options["title"];
}
function display() {
global $current_user, $mod_strings, $app_strings;
$options = $this->loadOptions();
$comparativeData = null;
$options2 = null;
$db_connection_handler = $GLOBALS["db"];
$options = $this->loadOptions();
// Data od
if(!$options['year'])
$options['year'] = date("Y");
if(!$options["comparativeData"])
$options["comparativeData"] = 'disabled';
if(!$options["type"])
$options["type"] = '%';
if(!$options["chartType"])
$options["chartType"] = 'column';
if( $options["comparativeData"] == 'enabled')
{
$options2 = $this->loadOptions();
$options2["year"] -= 1;
$helper2 = new ChartAnnualSalesHelper($db_connection_handler, $options2, $mod_strings);
$helper2->getChartOptions();
// Pobieram dane sprzed roku
$comparativeData = $helper2->getMonthsArray();
$helper = new ChartAnnualSalesHelper($db_connection_handler, $options, $mod_strings, $comparativeData);
$data = $helper->getChartOptions();
} else {
$helper = new ChartAnnualSalesHelper($db_connection_handler, $options, $mod_strings);
$data = $helper->getChartOptions();
}
/*
* SMARTY
*/
$smarty = new Sugar_Smarty();
$smarty->assign('chartOptions', $data);
$smarty->assign('comparativeData', $options['comparativeData']);
$smarty->assign('year', $options["year"]);
$smarty->assign('chartType', $options["chartType"]);
$smarty->assign('LANG', $mod_strings);
if( $helper->haveComparativeData() )
$smarty->assign('comparative_data_on', 'true');
else
$smarty->assign('comparative_data_on', 'false');
// Pobieranie widoku
$output = $smarty->fetch('modules/EcmCharts/Dashlets/MyChartsAnnualSalesDashlet/MyChartsAnnualSalesDashlet.tpl');
// return parent::display for title and smarty template
return parent::display($this->dashletStrings['LBL_DBLCLICK_HELP']) . $output;
}
function displayOptions() {
global $mod_strings,$current_user;
// format daty
$smarty = new Sugar_Smarty();
// Pobieram ustawienia
$options = $this->loadOptions();
// Data od
if(!$options['year'])
$options['year'] = date("Y");
if(!$options["comparativeData"])
$options["comparativeData"] = 'disabled';
if(!$options["type"])
$options["type"] = '%';
if(!$options["chartType"])
$options["chartType"] = 'column';
if(!$options["title"])
$options["title"] = "Raport sprzedaży w roku z podziałem na miesiące";
// Generowanie lat do selektora
$y = range(2000, date("Y"));
$years = array_reverse($y,true);
//The id must be assigned in all dashlet options pages
$smarty->assign('id', $this->id);
// Typ dokumentu: all, normal, correct
$smarty->assign('type', $options['type']);
$smarty->assign('year', $options['year']);
$smarty->assign('contractor_id', $options["contractor_id"]);;
$smarty->assign('contractor_name', $options["contractor_name"]);
$smarty->assign('chartType', $options["chartType"]);
$smarty->assign('years', $years);
$smarty->assign('LANG', $mod_strings);
$smarty->assign('title', $options["title"]);
// Pokazywać dane porównawcze? Tak: enabled, nie: disabled
$smarty->assign('comparativeData', $options['comparativeData']);
// Przekazuję widok opcji do metody displayOptions()
return parent::displayOptions() . $smarty->fetch('modules/EcmCharts/Dashlets/MyChartsAnnualSalesDashlet/MyChartsAnnualSalesDashletOptions.tpl');
}
// Zapisywanie opcji dashletu
function saveOptions($req) {
$options = array();
$options["year"] = $req["year"];
$options["comparativeData"] = $req["comparativeData"];
$options["type"] = $req["type"];
$options["chartType"] = $req["chartType"];
$options["title"] = $req["title"];
if( $req["account_name"] == '' )
{
$options["contractor_name"] = '';
$options["contractor_id"] = '';
} else {
$options["contractor_name"] = $req['account_name'];
$options["contractor_id"] = $req['account_id'];
}
return $options;
}
}
?>

View File

@@ -0,0 +1,152 @@
{*
/**
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2009 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
*/
*}
{if $chartOptions == ''}
{literal}
<style type="text/css">
.no-data {
display: table;
width: 100%;
height: 100%;
}
.textCenter {
display: table-cell;
vertical-align: middle;
text-align: center;
}
.textCenter span {
font-size: 16px;
border: 1px dashed #E03E3E;
padding: 10px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
box-shadow: 10px 10px 5px #AAAAAA;
background-color: #FFDEDE;
color: #E03E3E;
}
</style>
{/literal}
{/if}
{if $chartOptions == ''}
<div id='jotpsadad_{$id}' ondblclick='JotPad.edit(this, "{$id}")' style='overflow: auto; width: 100%; height: 200px; border: 1px #ddd solid'>
<div id="annual_sales_chart{$id}" style="width: 100%; height: 100%;">
<div class="no-data">
<div class="textCenter">
<span>
{$LANG.LBL_NO_DATA_CHANGE_FILTER}
</span>
</div>
</div>
</div>
</div>
{else}
<div style='overflow: auto; width: 100%; height: 800px; border: 1px #ddd solid'>
<div id="annual_sales_chart{$id}" style="width: 100%; height: 97%;"></div>
</div>
{/if}
<!-- GOOGLE CHARTS API -->
{if $chartOptions != ''}
{literal}
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript" src="modules/EcmCharts/Dashlets/MyChartsSalesDashlet/js/salesChart.js"></script>
<script type="text/javascript">
// Load the Visualization API and the piechart package.
google.load('visualization', '1', {'packages':['corechart','geochart','table']});
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Rok', {/literal}'{$LANG.LBL_SALE}'
{if $comparativeData == 'enabled'} , '{$LANG.LBL_SALE_IN_PAST_YEAR}'{/if}
{literal}],
{/literal}
{$chartOptions}
{literal}
]);
var formatter = new google.visualization.NumberFormat({
suffix: 'zł'
});
formatter.format(data, 1); // Apply formatter to second column.
{/literal}
{if $comparative_data_on == 'true' }
formatter.format(data, 2); // Apply formatter to second column.
{/if}
{literal}
var options = {
{/literal}
title: '{ $LANG.LBL_SALES_CHART_IN }{$year}',
{literal}
legend: {position: 'bottom', textStyle: {fontSize: 10}},
tooltip:{textStyle:{fontSize:'10'}},
vAxis:{title: {/literal}'{$LANG.LBL_VALUEOFSALES}'{literal},textStyle:{color: '#000000',fontSize: '11', paddingRight: '100',marginRight: '100'}},
hAxis:{title:'',textStyle:{color: '#000000',fontSize: '10', paddingRight: '100',marginRight: '100'}}
};
{/literal}
{if $chartType == 'column' or $chartType == ''}
var chart = new google.visualization.ColumnChart(document.getElementById('annual_sales_chart{$id}'));
{elseif $chartType == 'pie'}
var chart = new google.visualization.PieChart(document.getElementById('annual_sales_chart{$id}'));
{elseif $chartType == 'line'}
var chart = new google.visualization.LineChart(document.getElementById('annual_sales_chart{$id}'));
{elseif $chartType == 'stepped'}
var chart = new google.visualization.SteppedAreaChart(document.getElementById('annual_sales_chart{$id}'));
{else}
var chart = new google.visualization.AreaChart(document.getElementById('annual_sales_chart{$id}'));
{/if}
{literal}
chart.draw(data, options);
}
// sekunda opóźnienia, żeby zdążył wczytać się moduł "visualization"
setTimeout(drawChart, 1000);
</script>
{/literal}
{/if}

View File

@@ -0,0 +1,160 @@
{*
/**
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2009 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
*/
*}
<script type="text/javascript" src="modules/EcmCharts/javascript/jquery-2.1.1.min.js"></script>
<script type="text/javascript">
{literal}
function listenerFunction() {
//location.reload();
};
$("#chartTypeSelector").change(function() {
if( $(this).val() == 'pie' )
{
$("#documentTypeSelector").val("normal");
}
});
$("#documentTypeSelector").change(function(){
if( $(this).val() == 'correct' && $("#chartTypeSelector").val() == 'pie' )
{
$("#chartTypeSelector").val("column");
}
});
{/literal}
</script>
<style type="text/css">
{literal}
table tr td {
padding-top: 20px;
}
table tr td select {
width: 140px;
}
{/literal}
</style>
<div style='width: 600px'>
<form name="configure_{$id}" action="index.php" method="post" onSubmit='return SUGAR.dashlets.postForm("configure_{$id}", SUGAR.mySugar.uncoverPage);'>
<input type='hidden' name='id' value='{$id}'>
<input type='hidden' name='module' value='Home'>
<input type='hidden' name='action' value='ConfigureDashlet'>
<input type='hidden' name='to_pdf' value='true'>
<input type='hidden' name='configure' value='true'>
<table width="600" cellpadding="0" cellspacing="0" border="0" class="tabForm" align="center">
<tr>
<td>{$LANG.LBL_TITLE}: </td>
<td>
<input type="text" value="{$title}" name="title" />
</td>
</tr>
<tr>
<td>{$LANG.LBL_SELECT_YEAR}: </td>
<td>
<select name="year">
{foreach from=$years item=y}
<option value="{$y}" { if $y == $year || $year == ""} selected="true" {/if}>{$y}</option>
{/foreach}
</select>
</td>
</tr>
<tr>
<td>{$LANG.LBL_INCLUDED_DOCUMENT_TYPE}: </td>
<td>
<select id="documentTypeSelector" name="type">
<option value="%" { if $type == "%" || $type == ""} selected="true" {/if}>{$LANG.LBL_NORMAL_AND_CORRECT}</option>
<option value="normal" { if $type == "normal"} selected="true" {/if}>{$LANG.LBL_NORMAL_ONLY}</option>
<option value="correct" { if $type == "correct"} selected="true" {/if}>{$LANG.LBL_CORRECT_ONLY}</option>
</select>
</td>
</tr>
<tr>
{* Search by contractor *}
<td>{$LANG.LBL_CONTRACTOR}</td>
<td>
<input id="search_account_name" type="text" value="{$contractor_name}" name="account_name">
<input id="search_account_id" type="hidden" value="{$contractor_id}" name="account_id">
<input class="button" type="button" value="{$LANG.LBL_SELECT}" accesskey="T" title="Select [Alt+T]" value="" name="btn_account_name" onClick="getContractor()">
{* Open popup window to select contractor *}
<script type="text/javascript">
function getContractor()
{ldelim}
open_popup("Accounts", 600, 400, "", true, false,
{ldelim}
"call_back_function":"set_return","form_name":"configure_{$id}","field_to_name_array":
{ldelim}"id":"search_account_id","name":"search_account_name"{rdelim}
{rdelim}, "single", true);
{rdelim};
</script>
</td>
</tr>
<tr>
<td>{$LANG.LBL_CHARTTYPE}: </td>
<td>
<select id="chartTypeSelector" name="chartType">
<option value="column" { if $chartType == "column" || $chartType == ""} selected="true" {/if}>{$LANG.LBL_CHARTTYPECOLUMN}</option>
<option value="pie" { if $chartType == "pie"} selected="true" {/if}>{$LANG.LBL_CHARTTYPEPIE}</option>
<option value="line" { if $chartType == "line"} selected="true" {/if}>{$LANG.LBL_CHARTTYPELINE}</option>
<option value="area" { if $chartType == "area"} selected="true" {/if}>{$LANG.LBL_CHARTTYPEAREA}</option>
<option value="stepped" { if $chartType == "stepped"} selected="true" {/if}>{$LANG.LBL_CHARTTYPESTEPPEDAREA}</option>
</select>
</td>
</tr>
<tr>
<td>{$LANG.LBL_VIEW_COMPARATIVE_DATA}: </td>
<td>
<input type="radio" name="comparativeData" value="enabled" { if $comparativeData == "enabled" || $comparativeData == "" } checked {/if}> {$LANG.LBL_YES}
<input type="radio" name="comparativeData" style="margin-left: 20px" value="disabled" { if $comparativeData == "disabled" || $comparativeData == "" } checked {/if}> {$LANG.LBL_NO}
</td>
</tr>
<tr>
<td colspan="4" style="text-align: center;">
<input id="submitButton" type="submit" class="button" style="margin-top: 30px;" value="{$LANG.LBL_SAVECHANGES}" onclick="setTimeout(listenerFunction, 1000);">
</td>
</tr>
</table>
</form>
</div>

View File

@@ -0,0 +1,499 @@
<?php
/*
* Klasa reprezentująca produkt
*/
class Product {
// Name
var $name;
// Total sum
var $total;
// Subtotal sum
var $subtotal;
// Quantity
var $quantity;
// Category
var $category;
// Subcategory
var $subcategory;
// Item is from correct
var $fromCorrect;
// Currency_value
var $currency_value = 0;
public function __construct($name, $total, $subtotal, $subprice, $quantity, $currency_value, $old_quantity, $subtotal_corrected, $old_total, $type)
{
//echo "W konstruktorze Product: ".$name." ".$total." ".$subtotal." ".$subprice." ".$quantity."<br>";
$cv = $currency_value == 0 ? 1 : $currency_value;
$oldSubtotal = ($old_subtotal == 0 || $old_subtotal == null) ? 0 : $old_subtotal;
$oldTotal = ($old_total == 0 || $old_total == null) ? 0 : $old_total;
$oldQuantity = ($old_quantity == 0 || $old_quantity == null) ? 0 : $old_quantity;
$this->name = $name;
if( $type == 'correct' )
{
$this->total = ($total-$oldTotal)*$cv;
$this->subtotal = ($subtotal_corrected)*$cv;
$this->quantity = $quantity-$oldQuantity;
$this->subprice = $subprice*$cv;
$this->currency_value = $currency_value;
$this->fromCorrect = true;
} else {
$this->total = $total*$cv;
$this->subtotal = $subtotal*$cv;
$this->subprice = $subprice*$cv;
$this->quantity = $quantity;
$this->currency_value = $cv;
$this->fromCorrect = false;
}
}
}
/*
* Klasa reprezentująca podkategorię produktową
*/
class Subcategory {
// Subcategory id
var $id;
// Name
var $name;
// Total sum
var $total;
// Subtotal sum
var $subtotal;
// Cost sum in category
var $cost;
// Count all products in category
var $quantity;
// Products in category
var $products = array();
// IsEmpty
var $isEmpty = true;
public function __construct($id, $name, $total = 0.00, $subtotal = 0.00, $cost = 0.00, array $products = NULL)
{
$this->id = $id;
$this->name = $name;
$this->total = $total;
$this->subtotal = $subtotal;
$this->cost = $cost;
$this->products = $products;
if( $products != null )
if( count($products) > 0 )
$this->isEmpty = false;
}
public function id()
{
return $this->id;
}
public function cost()
{
return $this->cost;
}
public function products()
{
return $this->products;
}
public function setProducts( array $products )
{
$this->products = $products;
if( count($this->products) > 0 )
$this->isEmpty = false;
foreach( $this->products as $product )
{
$this->total += $product->total;
$this->subtotal += $product->subtotal;
$this->quantity += $product->quantity;
}
}
public function showProducts()
{
if( !$this->isEmpty )
{
echo "<br><br>";
foreach( $this->products as $product) {
echo $product->name.", ".$product->subtotal."<br>";
}
} else {
echo "<br><br>";
echo "Brak produktów w kategorii ".$this->name;
}
}
public function toString()
{
echo "<br>";
echo $this->id." <br>";
echo $this->name.": <br>";
echo "Cena netto: ".$this->subtotal."<br>";
echo "Cena brutto: ".$this->total."<br>";
echo "Cena ilość produktów: ".$this->quantity."<br>";
}
}
/*
* Klasa reprezentująca kategorię produktową
*/
class Category extends Subcategory {
public function __construct($id, $name = '', $total = 0, $subtotal = 0, $cost = 0, $products = null)
{
parent::__construct($id, $name, $total, $subtotal, $cost, $products);
}
}
/*
* Klasa pomocnicza przy generowaniu wykresów dla MyChartsSalesDashlet
*/
class ChartSalesHelper {
// Global database connection instance
var $db_connection;
// Chart options
var $options;
// Product category array
var $categories = array();
// Product subcategory array
var $subcategories = array();
// Enable log function
var $logEnabled = false;
// Constructor
public function __construct($db_connection, $options, $comparativeData = null)
{
//$this->log("Parametry dashletu: ", $options );
$this->db_connection = $db_connection;
$this->options = $options;
$this->compData = null;
$this->getCategories();
if( $this->options["detail"] == 'category')
{
if( $comparativeData != null )
{
$this->compData = $comparativeData;
}
} else {
if( $comparativeData != null )
{
$this->compData = $comparativeData;
}
}
}
public function haveComparativeData()
{
if( $this->compData != null )
return true;
else
return false;
}
public function getAllCategories()
{
return $this->categories;
}
public function getAllSubcategories()
{
return $this->subcategories;
}
//----------------------------------------
// Private methods
//----------------------------------------
/**
* Metoda pobiera wszystkie kategorie z bazy
*/
private function getCategories($getSubcategories = false)
{
// Pobieram kategorie, albo podkategorie
// w zależności od podanej wartości parametru
if( $this->options["detail"] == 'subcategory' )
$depression = 1;
else
$depression = 0;
$query = "
SELECT
category.id,
category.name
FROM ecmproductcategories category
JOIN
ecmproductcategories_bean bean
ON bean.ecmproductcategory_id = category.id
WHERE
category.deleted='0'
AND bean.position='$depression'
AND bean.deleted='0'
GROUP BY
category.id
ORDER BY
category.name
";
$results = $this->db_connection->query($query);
$all = array();
if( $this->options["detail"] == 'subcategory' )
{
while( $result = $this->db_connection->fetchByAssoc( $results ) )
{
$subcategory = new Subcategory($result['id'], $result['name']);
$all[] = $subcategory;
}
$this->subcategories = $all;
$this->log( "Ilość podkategorii: ".count($this->subcategories));
foreach( $this->subcategories as $subcategory )
$this->getCategoryItems($subcategory);
} else {
while( $result = $this->db_connection->fetchByAssoc( $results ) )
{
$category = new Category($result['id'], $result['name']);
$all[] = $category;
}
$this->categories = $all;
$this->log( "Ilość kategorii: ".count($this->categories));
foreach( $this->categories as $category )
$this->getCategoryItems($category);
}
// Sort categories
usort( $this->categories, array($this, 'sortCategoriesAndSubcategoriesFunction') );
// Sort subcategories
usort( $this->subcategories, array($this, 'sortCategoriesAndSubcategoriesFunction') );
}
private static function sortCategoriesAndSubcategoriesFunction( $a, $b )
{
if( $a->subtotal > $b->subtotal )
return false;
else if( $a->subtotal < $b->subtotal )
return true;
else
return 0;
}
/**
* Metoda pobiera wszystkie itemy danej kategorii w podanym przedziale czasowym
*/
private function getCategoryItems( $obj )
{
$date_from = $this->prepareDateToQuery( new DateTime($this->options["date_from"]) );
$date_to = $this->prepareDateToQuery( new DateTime($this->options["date_to"]) );
$type = $this->options["type"];
$category_id = $obj->id();
if( $obj instanceof Category )
$position = 0;
else
$position = 1;
$query = "
SELECT
item.ecmproduct_id AS 'id',
item.name AS 'name',
item.total_brutto AS 'total',
item.total_netto AS 'subtotal',
item.price_start AS 'subprice',
item.quantity AS 'quantity',
item.old_quantity AS 'old_quantity',
item.total_netto_corrected AS 'subtotal_corrected',
item.old_total_brutto AS 'old_total',
item.old_ecminvoiceoutitem_id,
faktura.currency_value,
faktura.type AS 'type'
FROM
ecminvoiceoutitems item
JOIN ecminvoiceouts faktura
ON item.ecminvoiceout_id = faktura.id
JOIN ecmproducts produkt
ON item.ecmproduct_id = produkt.id
JOIN ecmproductcategories_bean bean
ON bean.bean_id = produkt.id
JOIN ecmproductcategories kategoria
ON bean.ecmproductcategory_id = kategoria.id
WHERE
faktura.register_date BETWEEN '$date_from' AND '$date_to'
AND faktura.type LIKE '$type'
AND kategoria.id = '$category_id'
AND bean.position = '$position'
AND bean.deleted = '0'
AND kategoria.deleted = '0'
AND faktura.canceled = '0'
AND faktura.deleted = '0'
AND item.deleted = '0'
ORDER BY item.name
";
$results = $this->db_connection->query( $query );
$productArray = array();
while( $result = $this->db_connection->fetchByAssoc( $results ) )
{
if( $result["type"] == 'correct')
{
if( $result["old_ecminvoiceoutitem_id"] != '' ||
$result["old_ecminvoiceoutitem_id"] != null ||
$result["old_ecminvoiceoutitem_id"] != 0)
{
$product = new Product($result["name"],
$result["total"],
$result["subtotal"],
$result["subprice"],
$result["quantity"],
$result["currency_value"],
$result["old_quantity"],
$result["subtotal_corrected"],
$result["old_total"],
$result["type"]);
} else {
$product = null;
}
} else if($result["type"] == 'normal') {
$product = new Product($result["name"],
$result["total"],
$result["subtotal"],
$result["subprice"],
$result["quantity"],
$result["currency_value"],
$result["old_quantity"],
$result["subtotal_corrected"],
$result["old_total"],
$result["type"]);
}
if( $product != null )
$productArray[] = $product;
}
$obj->setProducts( $productArray );
/* if( $obj->name == 'Środki czystości' ){
$obj->showProducts();
}*/
}
/**
* Wyświetla kategorie w których są jakieś produkty
*/
public function showCategories()
{
echo "WYświetlam";
foreach( $this->categories as $category )
{
if( !$category->isEmpty )
{
echo $category->id;
echo "<br>";
echo $category->name;
echo "<br>";
}
}
echo "<br>";
}
/**
* Wyświetla podkategorie w których są jakieś produkty
*/
public function showSubcategories()
{
foreach( $this->subcategories as $subcategory )
{
if( !$subcategory->isEmpty )
{
echo $subcategory->id;
echo "<br>";
echo $subcategory->name;
echo "<br>";
}
}
echo "<br>";
}
/**
* Metoda przygotowuje datę do wstawienia w zapytanie SQL
*/
private function prepareDateToQuery( DateTime $d )
{
return $d->format('Y-m-d');
}
/**
* Render data to Google Charts options
*/
public function renderGoogleChartOptions( $fromCategories = true )
{
$data = "";
if( $this->options["detail"] == "category" ) {
for( $i = 0; $i < count($this->categories); $i++)
{
if( !$this->categories[$i]->isEmpty ) {
$data .= "['".$this->categories[$i]->name."', ".$this->categories[$i]->subtotal;
if( $this->options["comparativeData"] == 'enabled' )
$data .= ", ".$this->compData[$i]->subtotal."0],";
else
$data .= "],";
//echo "['".$this->categories[$i]->name."', ".$this->categories[$i]->subtotal.", ".$this->compData[$i]->subtotal."],<br>";
}
}
} else {
for( $i = 0; $i < count($this->subcategories); $i++)
{
if( !$this->subcategories[$i]->isEmpty ) {
$data .= "['".$this->subcategories[$i]->name."', ".$this->subcategories[$i]->subtotal;
if( $this->options["comparativeData"] == 'enabled' )
$data .= ", ".$this->compData[$i]->subtotal."0],";
else
$data .= "],";
}
}
}
$data = rtrim($data, ",");
//echo $data;
return $data;
}
/**
* Log functions
*/
private function log( $msg , $arrayOrObject = '')
{
if( $this->logEnabled == true )
{
echo "<br>";
echo $msg;
if( $arrayOrObject )
print_r( $arrayOrObject );
echo "<br>";
}
}
} // end class
?>

View File

@@ -0,0 +1,46 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/**
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2009 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
*/
global $app_strings;
$dashletMeta['MyChartsSalesDashlet'] = array(
'title' => 'Wykres sprzedaży z podziałem na kategorie/podkategorie',
'description' => 'Wykres słupkowy, w widoku poziomym przedstawiający sprzedaż w zadanym okresie z podziałem na kategorie i podkategorie wraz z możliwością wyboru przedziału danych porównawczych',
'category' => 'Charts');
?>

View File

@@ -0,0 +1,181 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
require_once('include/Dashlets/Dashlet.php');
require_once('include/Sugar_Smarty.php');
require_once('ChartSalesHelper.php');
class MyChartsSalesDashlet extends Dashlet {
var $savedText; // users's saved text
var $height = '300'; // height of the pad
var $firstLoad = 'yes';
function MyChartsSalesDashlet($id, $def) {
global $current_user, $mod_strings, $app_strings;
require('modules/EcmCharts/Dashlets/MyChartsSalesDashlet/MyChartsSalesDashlet.meta.php');
require('modules/EcmCharts/language/pl_pl.lang.php');
parent::Dashlet($id); // call parent constructor
$this->isConfigurable = true; // dashlet is configurable
$this->hasScript = false; // dashlet has java ipt attached to it
$options = $this->loadOptions();
if( !$options["title"] )
$options["title"] = "Wykres sprzedaży z podziałem na kategorie/podkategorie";
// if no custom title, use default
$this->title = $options["title"];
}
function display() {
global $current_user, $mod_strings, $app_strings;
$options = $this->loadOptions();
// Data od
if(!$options['date_from'])
$options['date_from'] = date("01.m.Y");
// Data do
if(!$options['date_to'])
$options['date_to'] = date("d.m.Y");
if(!$options['type'])
$options['type'] = "%";
if(!$options['comparativeData'])
$options['comparativeData'] = "disabled";
if(!$options['detail'])
$options['detail'] = "category";
if(!$options['chartType'])
$options['chartType'] = "column";
if(!$options["title"])
$options["title"] = "Wykres sprzedaży z podziałem na kategorie/podkategorie";
$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();
/*
* SMARTY
*/
$smarty = new Sugar_Smarty();
//$ss->assign('account_id',$optionsArray['account_id']);
$smarty->assign('id', $this->id);
$smarty->assign('height', $this->height);
$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('firstLoad', $this->firstLoad);
$smarty->assign('comparativeData', $options['comparativeData']);
if( $helper->haveComparativeData() )
$smarty->assign('comparative_data_on', 'true');
else
$smarty->assign('comparative_data_on', 'false');
$smarty->assign('chartType', $options['chartType']);
$smarty->assign('LANG', $mod_strings);
// Pobieranie widoku
$output = $smarty->fetch('modules/EcmCharts/Dashlets/MyChartsSalesDashlet/MyChartsSalesDashlet.tpl');
// return parent::display for title and smarty template
return parent::display($this->dashletStrings['LBL_DBLCLICK_HELP']) . $output;
}
function displayOptions() {
global $current_user, $mod_strings, $app_strings;
// format daty
$smarty = new Sugar_Smarty();
// Pobieram ustawienia
$options = $this->loadOptions();
// Data od
if(!$options['date_from'])
$options['date_from'] = date("01.m.Y");
// Data do
if(!$options['date_to'])
$options['date_to'] = date("d.m.Y");
if(!$options['type'])
$options['type'] = "%";
if(!$options['comparativeData'])
$options['comparativeData'] = "disabled";
if(!$options['detail'])
$options['detail'] = "category";
if(!$options['chartType'])
$options['chartType'] = "column";
if(!$options["title"])
$options["title"] = "Wykres sprzedaży z podziałem na kategorie/podkategorie";
// Format daty
$Calendar_daFormat = str_replace("d","%d",str_replace("m","%m",str_replace("Y","%Y",$GLOBALS['timedate']->get_date_format())));
$smarty->assign("dateFormat", $Calendar_daFormat);
//The id must be assigned in all dashlet options pages
$smarty->assign('id', $this->id);
$smarty->assign('date_from', $options['date_from']);
$smarty->assign('date_to', $options['date_to']);
// Sczegółowość wykresu: category, subcategory
$smarty->assign('detail', $options['detail']);
// Typ dokumentu: all, normal, correct
$smarty->assign('type', $options['type']);
// Pokazywać dane porównawcze? Tak: enabled, nie: disabled
$smarty->assign('comparativeData', $options['comparativeData']);
// Typ wykresu
$smarty->assign('chartType', $options['chartType']);
// Tytuł
$smarty->assign('title', $options['title']);
// Lang
$smarty->assign('LANG', $mod_strings);
// Przekazuję widok opcji do metody displayOptions()
return parent::displayOptions() . $smarty->fetch('modules/EcmCharts/Dashlets/MyChartsSalesDashlet/MyChartsSalesDashletOptions.tpl');
}
// Zapisywanie opcji dashletu
function saveOptions($req) {
$options = array();
$options["date_from"] = $req["date_from"];
$options["date_to"] = $req["date_to"];
$options["detail"] = $req["detail"];
$options["comparativeData"] = $req["comparativeData"];
$options["type"] = $req["type"];
$options["chartType"] = $req["chartType"];
$options["title"] = $req["title"];
return $options;
}
}
?>

View File

@@ -0,0 +1,155 @@
{*
/**
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2009 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
*/
*}
{if $chartOptions == ''}
{literal}
<style type="text/css">
.no-data {
display: table;
width: 100%;
height: 100%;
}
.textCenter {
display: table-cell;
vertical-align: middle;
text-align: center;
}
.textCenter span {
font-size: 16px;
border: 1px dashed #E03E3E;
padding: 10px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
box-shadow: 10px 10px 5px #AAAAAA;
background-color: #FFDEDE;
color: #E03E3E;
}
</style>
{/literal}
{/if}
{if $chartOptions == ''}
<div id='jotpsadad_{$id}' ondblclick='JotPad.edit(this, "{$id}")' style='overflow: auto; width: 100%; height: 200px; border: 1px #ddd solid'>
<div id="sales_chart{$id}" style="width: 100%; height: 100%;">
<div class="no-data">
<div class="textCenter">
<span>
Brak danych od {$date_from} do {$date_to}, wybierz inny przedział dat.
</span>
</div>
</div>
</div>
</div>
{else}
<div id='jotpsadad_{$id}' ondblclick='JotPad.edit(this, "{$id}")' style='overflow: auto; width: 100%; height: 800px; border: 1px #ddd solid'>
<div id="sales_chart{$id}" style="width: 100%; height: 98%;"></div>
</div>
{/if}
<!-- GOOGLE CHARTS API -->
{if $chartOptions != ''}
{literal}
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript" src="modules/EcmCharts/Dashlets/MyChartsSalesDashlet/js/salesChart.js"></script>
<script type="text/javascript">
// Load the Visualization API and the piechart package.
google.load('visualization', '1', {'packages':['corechart','geochart','table']});
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Kategoria', 'Sprzedaż w aktualnym roku'{/literal}
{if $comparativeData == 'enabled'} , 'Sprzedaż z poprzedniego roku'{/if}
{literal}],
{/literal}
{$chartOptions}
{literal}
]);
var formatter = new google.visualization.NumberFormat({
suffix: 'zł'
});
formatter.format(data, 1); // Apply formatter to second column.
{/literal}
{if $comparative_data_on == 'true' }
formatter.format(data, 2); // Apply formatter to second column.
{/if}
{literal}
var options = {
{/literal}
title: '{$LANG.LBL_CHARTSALES} {$LANG.LBL_FROM} {$date_from} {$LANG.LBL_TO} {$date_to}',
{literal}
legend: {position: 'bottom', textStyle: {fontSize: 10}},
tooltip:{textStyle:{fontSize:'10'}},
vAxis:{title: {/literal}'{$LANG.LBL_VALUEOFSALES}'{literal},textStyle:{color: '#000000',fontSize: '10', paddingRight: '100',marginRight: '100'}},
hAxis:{title:{/literal}{if $detail == 'category'}'{$LANG_LBL_CATEGORY}'{else}'{$LANG_LBL_SUBCATEGORY}'{/if}{literal}, titleTextStyle: {color: 'red'},textStyle:{color: '#000000',fontSize: '11', paddingRight: '100',marginRight: '100'}}
};
{/literal}
{if $chartType == 'column' or $chartType == ''}
var chart = new google.visualization.ColumnChart(document.getElementById('sales_chart{$id}'));
{elseif $chartType == 'pie'}
var chart = new google.visualization.PieChart(document.getElementById('sales_chart{$id}'));
{elseif $chartType == 'line'}
var chart = new google.visualization.LineChart(document.getElementById('sales_chart{$id}'));
{elseif $chartType == 'stepped'}
var chart = new google.visualization.SteppedAreaChart(document.getElementById('sales_chart{$id}'));
{else}
var chart = new google.visualization.AreaChart(document.getElementById('sales_chart{$id}'));
{/if}
{literal}
chart.draw(data, options);
}
// sekunda opóźnienia, żeby zdążył wczytać się moduł "visualization"
setTimeout(drawChart, 1000);
</script>
{/literal}
{/if}

View File

@@ -0,0 +1,176 @@
{*
/**
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2009 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
*/
*}
<script type="text/javascript" src="modules/EcmCharts/javascript/jquery-2.1.1.min.js"></script>
<script type="text/javascript">
{literal}
function listenerFunction() {
//location.reload();
};
$("#chartTypeSelector").change(function() {
if( $(this).val() == 'pie' )
{
$("#documentTypeSelector").val("normal");
}
});
$("#documentTypeSelector").change(function(){
if( $(this).val() != 'normal' && $("#chartTypeSelector").val() == 'pie' )
{
$("#chartTypeSelector").val("column");
}
});
{/literal}
</script>
<style type="text/css">
{literal}
table tr td {
padding-top: 20px;
}
table tr td select {
width: 140px;
}
{/literal}
</style>
<div style='width: 600px'>
<form name="configure_{$id}" action="index.php" method="post" onSubmit='return SUGAR.dashlets.postForm("configure_{$id}", SUGAR.mySugar.uncoverPage);'>
<input type='hidden' name='id' value='{$id}'>
<input type='hidden' name='module' value='Home'>
<input type='hidden' name='action' value='ConfigureDashlet'>
<input type='hidden' name='to_pdf' value='true'>
<input type='hidden' name='configure' value='true'>
<table width="600" cellpadding="0" cellspacing="0" border="0" class="tabForm" align="center">
<tr>
<td>{$LANG.LBL_TITLE}: </td>
<td>
<input type="text" value="{$title}" name="title" />
</td>
</tr>
<tr>
<td>{$LANG.LBL_INCLUDEDATE} {$LANG.LBL_FROM}: </td>
<td>
{* Search by date_from *}
<input id="date_from" name="date_from" type="text" maxlength="10" size="11" tabindex="" title="" value="{$date_from}" autocomplete="off">
<img id="date_from_trigger" border="0" align="absmiddle" alt="Enter Date" src="themes/default/images/jscalendar.gif">
<script language="JavaScript" type="text/javascript">
Calendar.setup ({ldelim}
inputField : "date_from",
daFormat : "{$dateFormat}",
button : "date_from_trigger",
singleClick : true,
dateStr : "",
step : 1
{rdelim}
);
</script>
</td>
<td> {$LANG.LBL_TO}: </td>
<td>
{* Search by date_to *}
<input autocomplete="off" name="date_to" id="date_to" value="{$date_to}" title="" tabindex="" size="11" maxlength="10" type="text">
<img src="themes/default/images/jscalendar.gif" alt="Enter Date" id="date_to_trigger" align="absmiddle" border="0">
<script language="JavaScript" type="text/javascript">
Calendar.setup ({ldelim}
inputField : "date_to",
daFormat : "{$dateFormat}",
button : "date_to_trigger",
singleClick : true,
dateStr : "",
step : 1
{rdelim}
);
</script>
</td>
</tr>
<tr>
<td>{$LANG.LBL_SHOW}: </td>
<td>
<select name="detail">
<option value="category" { if $detail == "category" || $detail == ""} selected="true" {/if} >Kategorii</option>
<option value="subcategory" { if $detail=="subcategory"} selected {/if} >Podkategorii</option>
</select>
</td>
</tr>
<tr>
<td>{$LANG.LBL_INCLUDED_DOCUMENT_TYPE}: </td>
<td>
<select id="documentTypeSelector" name="type">
<option value="%" { if $type == "%" || $type == ""} selected="true" {/if}>{$LANG.LBL_NORMAL_AND_CORRECT}</option>
<option value="normal" { if $type == "normal"} selected="true" {/if}>{$LANG.LBL_NORMAL_ONLY}</option>
<option value="correct" { if $type == "correct"} selected="true" {/if}>{$LANG.LBL_CORRECT_ONLY}</option>
</select>
</td>
</tr>
<tr>
<td>{$LANG.LBL_CHARTTYPE}: </td>
<td>
<select id="chartTypeSelector" name="chartType">
<option value="column" { if $chartType == "column" || $chartType == ""} selected="true" {/if}>{$LANG.LBL_CHARTTYPECOLUMN}</option>
<option value="pie" { if $chartType == "pie"} selected="true" {/if}>{$LANG.LBL_CHARTTYPEPIE}</option>
<option value="line" { if $chartType == "line"} selected="true" {/if}>{$LANG.LBL_CHARTTYPELINE}</option>
<option value="area" { if $chartType == "area"} selected="true" {/if}>{$LANG.LBL_CHARTTYPEAREA}</option>
<option value="stepped" { if $chartType == "stepped"} selected="true" {/if}>{$LANG.LBL_CHARTTYPESTEPPEDAREA}</option>
</select>
</td>
</tr>
<tr>
<td>{$LANG.LBL_VIEW_COMPARATIVE_DATA}: </td>
<td>
<input type="radio" name="comparativeData" value="enabled" { if $comparativeData == "enabled" || $comparativeData == "" } checked {/if}> {$LANG.LBL_YES}
<input type="radio" name="comparativeData" style="margin-left: 20px" value="disabled" { if $comparativeData == "disabled" || $comparativeData == "" } checked {/if}> {$LANG.LBL_NO}
</td>
</tr>
<tr>
<td colspan="4" style="text-align: center;">
<input id="submitButton" type="submit" class="button" style="margin-top: 30px;" value="{$LANG.LBL_SAVECHANGES}" onclick="setTimeout(listenerFunction, 1000);">
</td>
</tr>
</table>
</form>
</div>

View File

@@ -0,0 +1,193 @@
<?php
/*
* Klasa reprezentująca kontrahenta
*/
class Contractor {
// Nazwa kontrahenta
var $name;
// Cena netto
var $subtotal;
// Koszty
var $cost;
public function __construct($name, $subtotal, $cost)
{
$this->name = $name;
$this->subtotal = $subtotal;
$this->cost = $cost;
}
}
/*
* Klasa pomocnicza przy generowaniu wykresów dla MyContractorsChartsSalesDashlet
*/
class MyContractorChartSalesHelper {
// Global database connection instance
var $db_connection;
// Chart options
var $options;
// Tablica kontrahentów
var $contractors = array();
// Dane porównawcze
var $compData = null;
// Constructor
public function __construct($db_connection, $options, $comparativeData = null)
{
//$this->log("Parametry dashletu: ", $options );
$this->db_connection = $db_connection;
$this->options = $options;
$this->compData = $comparativeData;
$this->getData();
}
public function haveComparativeData()
{
if( $this->compData != null )
return true;
else
return false;
}
//----------------------------------------
// Private methods
//----------------------------------------
/**
* Metoda pobiera wszystkie dane o kontrahentach
*/
private function getData()
{
$date_from = $this->prepareDateToQuery( new DateTime($this->options["date_from"]) );
$date_to = $this->prepareDateToQuery( new DateTime($this->options["date_to"]) );
$type = $this->options["type"];
$count = $this->options["count"];
$query = "
SELECT
acco.name as 'name',
acco.parent_id as 'parent',
sum(
CASE WHEN faktura.type!='correct'
THEN
CASE WHEN faktura.currency_value is null or faktura.currency_value='' or faktura.currency_value=0
THEN
pozycja.total_netto
ELSE
pozycja.total_netto*faktura.currency_value
END
ELSE
CASE WHEN faktura.currency_value is null or faktura.currency_value='' or faktura.currency_value=0
THEN
pozycja.total_netto-pozycja.old_total_netto
ELSE
(pozycja.total_netto-pozycja.old_total_netto)*faktura.currency_value
END
END
) as netto,
sum(
CASE WHEN faktura.type!='correct'
THEN
pozycja.price_purchase*pozycja.quantity
ELSE
0
END
) as cost
FROM
ecminvoiceoutitems pozycja
JOIN
ecminvoiceouts faktura ON pozycja.ecminvoiceout_id = faktura.id
JOIN
accounts acco ON acco.id = faktura.parent_id
WHERE
faktura.register_date BETWEEN
'$date_from' AND '$date_to'
and faktura.type like '$type'
and faktura.canceled = 0
and faktura.deleted= 0
and pozycja.deleted= 0";
if( $this->options["group_media_saturn_holding"] == 'enabled' )
$query .= " GROUP BY IFNULL(acco.parent_id, acco.id) ";
else
$query .= " GROUP BY acco.id ";
$query .= "ORDER BY netto DESC
LIMIT $count;
";
$results = $this->db_connection->query( $query );
$allContractors = array();
while( $result = $this->db_connection->fetchByAssoc( $results ) )
{
if( $result['parent'] == "1249" && $this->options["group_media_saturn_holding"] == 'enabled')
$name = "Media Saturn Holding";
else
$name = $result["name"];
$contractor = new Contractor($name,
$result["netto"],
$result["cost"]);
if( $contractor != null )
$allContractors[] = $contractor;
}
$this->contractors = $allContractors;
}
public function showContractors()
{
print_r( $this->contractors );
}
public function getContractors()
{
return $this->contractors;
}
/**
* Metoda przygotowuje datę do wstawienia w zapytanie SQL
*/
private function prepareDateToQuery( DateTime $d )
{
return $d->format('Y-m-d');
}
/**
* Render data to Google Charts options
*/
public function renderGoogleChartOptions()
{
$data = "";
for( $i = 0; $i < count($this->contractors); $i++)
{
if( !$this->contractors[$i]->isEmpty ) {
$data .= "['".$this->contractors[$i]->name."', ".$this->contractors[$i]->subtotal;
if( $this->options["comparativeData"] == 'enabled' )
$data .= ", ".$this->compData[$i]->subtotal."0],";
else
$data .= "],";
//echo "['".$this->categories[$i]->name."', ".$this->categories[$i]->subtotal.", ".$this->compData[$i]->subtotal."],<br>";
}
}
$data = rtrim($data, ",");
return $data;
}
} // end class
?>

View File

@@ -0,0 +1,46 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/**
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2009 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
*/
global $app_strings;
$dashletMeta['MyContractorsChartsSalesDashlet'] = array(
'title' => 'Wykres sprzedaży z podziałem na kontrahentów',
'description' => 'Wykres słupkowy, w widoku poziomym przedstawiający sprzedaż w zadanym okresie z podziałem na kontrahentów wraz z możliwością wyboru przedziału danych porównawczych',
'category' => 'Charts');
?>

View File

@@ -0,0 +1,185 @@
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
require_once('include/Dashlets/Dashlet.php');
require_once('include/Sugar_Smarty.php');
require_once('MyContractorChartSalesHelper.php');
class MyContractorsChartsSalesDashlet extends Dashlet {
var $savedText; // users's saved text
var $height = '300'; // height of the pad
function MyContractorsChartsSalesDashlet($id, $def) {
global $current_user, $mod_strings, $app_strings;
require('modules/EcmCharts/Dashlets/MyContractorsChartsSalesDashlet/MyContractorsChartsSalesDashlet.meta.php');
require('modules/EcmCharts/language/pl_pl.lang.php');
parent::Dashlet($id); // call parent constructor
$this->isConfigurable = true; // dashlet is configurable
$this->hasScript = false; // dashlet has java ipt attached to it
$options = $this->loadOptions();
if( !$options["title"] )
$options["title"] = "Wykres z podziałem na kontrahentów";
// if no custom title, use default
$this->title = $options["title"];
}
function display() {
global $current_user, $mod_strings, $app_strings;
$options = $this->loadOptions();
// Data od
if(!$options['date_from'])
$options['date_from'] = date("01.m.Y");
// Data do
if(!$options['date_to'])
$options['date_to'] = date("d.m.Y");
if(!$options['type'])
$options['type'] = "%";
if(!$options['comparativeData'])
$options['comparativeData'] = "disabled";
if(!$options['chartType'])
$options['chartType'] = "column";
if(!$options['count'])
$options['count'] = "10";
if(!$options["title"])
$options["title"] = "Wykres sprzedaży z podziałem na kontrahentów";
$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 MyContractorChartSalesHelper( $db_connection_handler, $optionsForComparativeData);
$cd = $comparativeData->getContractors();
}
$helper = new MyContractorChartSalesHelper( $db_connection_handler, $options, $cd );
$data = $helper->renderGoogleChartOptions();
/*
* SMARTY
*/
$smarty = new Sugar_Smarty();
//$ss->assign('account_id',$optionsArray['account_id']);
if( $helper->haveComparativeData() )
$smarty->assign('comparative_data_on', 'true');
else
$smarty->assign('comparative_data_on', 'false');
$smarty->assign('id', $this->id);
$smarty->assign('height', $this->height);
$smarty->assign('date_from', $options["date_from"]);
$smarty->assign('date_to', $options["date_to"]);
$smarty->assign('chartOptions', $data);
$smarty->assign('comparativeData', $options['comparativeData']);
$smarty->assign('chartType', $options['chartType']);
$smarty->assign('contractorsCount', $options['count']);
$smarty->assign('group_media_saturn_holding', $options["group_media_saturn_holding"]);
$smarty->assign('LANG', $mod_strings);
// Pobieranie widoku
$output = $smarty->fetch('modules/EcmCharts/Dashlets/MyContractorsChartsSalesDashlet/MyContractorsChartsSalesDashlet.tpl');
// return parent::display for title and smarty template
return parent::display($this->dashletStrings['LBL_DBLCLICK_HELP']) . $output;
}
function displayOptions() {
global $current_user, $mod_strings, $app_strings;
// format daty
$smarty = new Sugar_Smarty();
// Pobieram ustawienia
$options = $this->loadOptions();
// Data od
if(!$options['date_from'])
$options['date_from'] = date("01.m.Y");
// Data do
if(!$options['date_to'])
$options['date_to'] = date("d.m.Y");
if(!$options['type'])
$options['type'] = "%";
if(!$options['comparativeData'])
$options['comparativeData'] = "disabled";
if(!$options['chartType'])
$options['chartType'] = "column";
if(!$options["title"])
$options["title"] = "Wykres sprzedaży z podziałem na kategorie/podkategorie";
if(!$options["count"])
$options["count"] = "10";
$numbers = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20];
// Format daty
$Calendar_daFormat = str_replace("d","%d",str_replace("m","%m",str_replace("Y","%Y",$GLOBALS['timedate']->get_date_format())));
$smarty->assign("dateFormat", $Calendar_daFormat);
//The id must be assigned in all dashlet options pages
$smarty->assign('id', $this->id);
$smarty->assign('date_from', $options['date_from']);
$smarty->assign('date_to', $options['date_to']);
// Typ dokumentu: all, normal, correct
$smarty->assign('type', $options['type']);
// Pokazywać dane porównawcze? Tak: enabled, nie: disabled
$smarty->assign('comparativeData', $options['comparativeData']);
// Typ wykresu
$smarty->assign('chartType', $options['chartType']);
// Tytuł
$smarty->assign('title', $options['title']);
// Ilość kontrahentów na wykresie
$smarty->assign('contractorsCount', $options['count']);
// Liczby do wyboru ilości kontrahentów
$smarty->assign('numbers', $numbers);
// Ilość kontrahentów
$smarty->assign('count', $options['count']);
// Grupowanie mediaków i saturnów
$smarty->assign('group_media_saturn_holding', $options["group_media_saturn_holding"]);
// Lang
$smarty->assign('LANG', $mod_strings);
// Przekazuję widok opcji do metody displayOptions()
return parent::displayOptions() . $smarty->fetch('modules/EcmCharts/Dashlets/MyContractorsChartsSalesDashlet/MyContractorsChartsSalesDashletOptions.tpl');
}
// Zapisywanie opcji dashletu
function saveOptions($req) {
$options = array();
$options["date_from"] = $req["date_from"];
$options["date_to"] = $req["date_to"];
$options["comparativeData"] = $req["comparativeData"];
$options["type"] = $req["type"];
$options["chartType"] = $req["chartType"];
$options["count"] = $req["contractorsCount"];
$options["title"] = $req["title"];
$options["group_media_saturn_holding"] = $req["group_media_saturn_holding"];
return $options;
}
}
?>

View File

@@ -0,0 +1,155 @@
{*
/**
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2009 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
*/
*}
{if $chartOptions == ''}
{literal}
<style type="text/css">
.no-data {
display: table;
width: 100%;
height: 100%;
}
.textCenter {
display: table-cell;
vertical-align: middle;
text-align: center;
}
.textCenter span {
font-size: 16px;
border: 1px dashed #E03E3E;
padding: 10px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
box-shadow: 10px 10px 5px #AAAAAA;
background-color: #FFDEDE;
color: #E03E3E;
}
</style>
{/literal}
{/if}
{if $chartOptions == ''}
<div id='jotpsadad_{$id}' ondblclick='JotPad.edit(this, "{$id}")' style='overflow: auto; width: 100%; height: 200px; border: 1px #ddd solid'>
<div id="contractors_sales_chart{$id}" style="width: 100%; height: 100%;">
<div class="no-data">
<div class="textCenter">
<span>
Brak danych od {$date_from} do {$date_to}, wybierz inny przedział dat.
</span>
</div>
</div>
</div>
</div>
{else}
<div id='jotpsadad_{$id}' ondblclick='JotPad.edit(this, "{$id}")' style='overflow: auto; width: 100%; height: 800px; border: 1px #ddd solid'>
<div id="contractors_sales_chart{$id}" style="width: 100%; height: 98%;"></div>
</div>
{/if}
<!-- GOOGLE CHARTS API -->
{if $chartOptions != ''}
{literal}
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript" src="modules/EcmCharts/Dashlets/MyChartsSalesDashlet/js/salesChart.js"></script>
<script type="text/javascript">
// Load the Visualization API and the piechart package.
google.load('visualization', '1', {'packages':['corechart','geochart','table']});
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Kategoria', 'Sprzedaż w aktualnym roku'{/literal}
{if $comparativeData == 'enabled'} , 'Sprzedaż z poprzedniego roku'{/if}
{literal}],
{/literal}
{$chartOptions}
{literal}
]);
var formatter = new google.visualization.NumberFormat({
suffix: 'zł'
});
formatter.format(data, 1); // Apply formatter to second column.
{/literal}
{if $comparative_data_on == 'true' }
formatter.format(data, 2); // Apply formatter to second column.
{/if}
{literal}
var options = {
{/literal}
title: '{$LANG.LBL_CHARTSALES} {$LANG.LBL_FROM} {$date_from} {$LANG.LBL_TO} {$date_to}',
{literal}
legend: {position: 'bottom', textStyle: {fontSize: 10}},
tooltip:{textStyle:{fontSize:'10'}},
vAxis:{title: {/literal}'{$LANG.LBL_VALUEOFSALES}'{literal},textStyle:{color: '#000000',fontSize: '10', paddingRight: '100',marginRight: '100'}},
hAxis:{title:{/literal}{if $detail == 'category'}'{$LANG_LBL_CATEGORY}'{else}'{$LANG_LBL_SUBCATEGORY}'{/if}{literal}, titleTextStyle: {color: 'red'},textStyle:{color: '#000000',fontSize: '11', paddingRight: '100',marginRight: '100'}}
};
{/literal}
{if $chartType == 'column' or $chartType == ''}
var chart = new google.visualization.ColumnChart(document.getElementById('contractors_sales_chart{$id}'));
{elseif $chartType == 'pie'}
var chart = new google.visualization.PieChart(document.getElementById('contractors_sales_chart{$id}'));
{elseif $chartType == 'line'}
var chart = new google.visualization.LineChart(document.getElementById('contractors_sales_chart{$id}'));
{elseif $chartType == 'stepped'}
var chart = new google.visualization.SteppedAreaChart(document.getElementById('contractors_sales_chart{$id}'));
{else}
var chart = new google.visualization.AreaChart(document.getElementById('contractors_sales_chart{$id}'));
{/if}
{literal}
chart.draw(data, options);
}
// sekunda opóźnienia, żeby zdążył wczytać się moduł "visualization"
setTimeout(drawChart, 1000);
</script>
{/literal}
{/if}

View File

@@ -0,0 +1,183 @@
{*
/**
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004 - 2009 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
*/
*}
<script type="text/javascript" src="modules/EcmCharts/javascript/jquery-2.1.1.min.js"></script>
<script type="text/javascript">
{literal}
function listenerFunction() {
//location.reload();
};
$("#chartTypeSelector").change(function() {
if( $(this).val() == 'pie' )
{
$("#documentTypeSelector").val("normal");
}
});
$("#documentTypeSelector").change(function(){
if( $(this).val() != 'normal' && $("#chartTypeSelector").val() == 'pie' )
{
$("#chartTypeSelector").val("column");
}
});
{/literal}
</script>
<style type="text/css">
{literal}
table tr td {
padding-top: 20px;
}
table tr td select {
width: 140px;
}
{/literal}
</style>
<div style='width: 600px'>
<form name="configure_{$id}" action="index.php" method="post" onSubmit='return SUGAR.dashlets.postForm("configure_{$id}", SUGAR.mySugar.uncoverPage);'>
<input type='hidden' name='id' value='{$id}'>
<input type='hidden' name='module' value='Home'>
<input type='hidden' name='action' value='ConfigureDashlet'>
<input type='hidden' name='to_pdf' value='true'>
<input type='hidden' name='configure' value='true'>
<table width="600" cellpadding="0" cellspacing="0" border="0" class="tabForm" align="center">
<tr>
<td>{$LANG.LBL_TITLE}: </td>
<td>
<input type="text" value="{$title}" name="title" />
</td>
</tr>
<tr>
<td>{$LANG.LBL_INCLUDEDATE} {$LANG.LBL_FROM}: </td>
<td>
{* Search by date_from *}
<input id="date_from" name="date_from" type="text" maxlength="10" size="11" tabindex="" title="" value="{$date_from}" autocomplete="off">
<img id="date_from_trigger" border="0" align="absmiddle" alt="Enter Date" src="themes/default/images/jscalendar.gif">
<script language="JavaScript" type="text/javascript">
Calendar.setup ({ldelim}
inputField : "date_from",
daFormat : "{$dateFormat}",
button : "date_from_trigger",
singleClick : true,
dateStr : "",
step : 1
{rdelim}
);
</script>
</td>
<td> {$LANG.LBL_TO}: </td>
<td>
{* Search by date_to *}
<input autocomplete="off" name="date_to" id="date_to" value="{$date_to}" title="" tabindex="" size="11" maxlength="10" type="text">
<img src="themes/default/images/jscalendar.gif" alt="Enter Date" id="date_to_trigger" align="absmiddle" border="0">
<script language="JavaScript" type="text/javascript">
Calendar.setup ({ldelim}
inputField : "date_to",
daFormat : "{$dateFormat}",
button : "date_to_trigger",
singleClick : true,
dateStr : "",
step : 1
{rdelim}
);
</script>
</td>
</tr>
<tr>
<td>{$LANG.LBL_INCLUDED_DOCUMENT_TYPE}: </td>
<td>
<select id="documentTypeSelector" name="type">
<option value="%" { if $type == "%" || $type == ""} selected="true" {/if}>{$LANG.LBL_NORMAL_AND_CORRECT}</option>
<option value="normal" { if $type == "normal"} selected="true" {/if}>{$LANG.LBL_NORMAL_ONLY}</option>
<option value="correct" { if $type == "correct"} selected="true" {/if}>{$LANG.LBL_CORRECT_ONLY}</option>
</select>
</td>
</tr>
<tr>
<td>{$LANG.LBL_CHARTTYPE}: </td>
<td>
<select id="chartTypeSelector" name="chartType">
<option value="column" { if $chartType == "column"} selected="true" {/if}>{$LANG.LBL_CHARTTYPECOLUMN}</option>
<option value="pie" { if $chartType == "pie"} selected="true" {/if}>{$LANG.LBL_CHARTTYPEPIE}</option>
<option value="line" { if $chartType == "line"} selected="true" {/if}>{$LANG.LBL_CHARTTYPELINE}</option>
<option value="area" { if $chartType == "area"} selected="true" {/if}>{$LANG.LBL_CHARTTYPEAREA}</option>
<option value="stepped" { if $chartType == "stepped"} selected="true" {/if}>{$LANG.LBL_CHARTTYPESTEPPEDAREA}</option>
</select>
</td>
</tr>
<tr>
<td>{$LANG.LBL_SELECT_CONTRACTORSCOUNT}: </td>
<td>
<select name="contractorsCount">
{foreach from=$numbers item=n}
<option value="{$n}" { if $n == $count || $count == ""} selected="true" {/if}>{$n}</option>
{/foreach}
</select>
</td>
</tr>
<tr>
<td>{$LANG.LBL_VIEW_COMPARATIVE_DATA}: </td>
<td>
<input type="radio" name="comparativeData" value="enabled" { if $comparativeData == "enabled" || $comparativeData == "" } checked {/if}> {$LANG.LBL_YES}
<input type="radio" name="comparativeData" style="margin-left: 20px" value="disabled" { if $comparativeData == "disabled" || $comparativeData == "" } checked {/if}> {$LANG.LBL_NO}
</td>
</tr>
<tr>
<td> {$LANG.LBL_GROUP_MEDIASATURNHOLDING}</td>
<td>
<input type="checkbox" value="enabled" name="group_media_saturn_holding"
{if $group_media_saturn_holding == 'enabled'}checked{/if}>
</td>
</tr>
<tr>
<td colspan="4" style="text-align: center;">
<input id="submitButton" type="submit" class="button" style="margin-top: 30px;" value="{$LANG.LBL_SAVECHANGES}" onclick="setTimeout(listenerFunction, 1000);">
</td>
</tr>
</table>
</form>
</div>