Files
crm.twinpol.com/modules/EcmCharts/Dashlets/MyChartsAgreementsDashlet/MyChartsAgreementsDashlet.php
2025-05-12 15:44:39 +00:00

113 lines
3.7 KiB
PHP
Executable File

<?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('ChartsAgreementsDashlet.php');
class MyChartsAgreementsDashlet extends Dashlet {
var $savedText; // users's saved text
var $height = '300'; // height of the pad
var $firstLoad = 'yes';
function MyChartsAgreementsDashlet($id, $def = null) {
global $current_user, $mod_strings, $app_strings;
require('modules/EcmCharts/Dashlets/MyChartsAgreementsDashlet/MyChartsAgreementsDashlet.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 należności";
$this->title = $options["title"];
}
function display() {
global $current_user, $mod_strings, $app_strings;
$Calendar_daFormat = str_replace("d","%d",str_replace("m","%m",str_replace("Y","%Y",$GLOBALS['timedate']->get_date_format())));
$options = $this->loadOptions();
$comparativeData = null;
$options2 = null;
$db_connection_handler = $GLOBALS["db"];
$options = $this->loadOptions();
// Data od
if(!$options['date_from'])
$options['date_from'] = '01.01.2010';
/*
* SMARTY
*/
$n= New ChartsAgreementsDashlet();
$smarty = new Sugar_Smarty();
$smarty->assign('date_from', $options["date_from"]);
$smarty->assign("dateFormat", $Calendar_daFormat);
$smarty->assign('LANG', $mod_strings);
$smarty->assign('TABLE',$n->getTable($GLOBALS['db'],$options['date_from']));
// Pobieranie widoku
$output = $smarty->fetch('modules/EcmCharts/Dashlets/MyChartsAgreementsDashlet/MyChartsAgreementsDashlet.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
$Calendar_daFormat = str_replace("d","%d",str_replace("m","%m",str_replace("Y","%Y",$GLOBALS['timedate']->get_date_format())));
if(!$options['date_from'])
$options['date_from'] = '01.01.2010';
//The id must be assigned in all dashlet options pages
$smarty->assign('id', $this->id);
// Typ dokumentu: all, normal, correct
$smarty->assign('date_from', $options["date_from"]);
$smarty->assign("dateFormat", $Calendar_daFormat);
$smarty->assign('LANG', $mod_strings);
$smarty->assign('title', $options["title"]);
// Pokazywać dane porównawcze? Tak: enabled, nie: disabled
// Przekazuję widok opcji do metody displayOptions()
return parent::displayOptions() . $smarty->fetch('modules/EcmCharts/Dashlets/MyChartsAgreementsDashlet/MyChartsAgreementsDashletOptions.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;
}
}
?>