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,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>