Add php files
This commit is contained in:
121
modules/EcmCharts/Dashlets/MyChartsProductsDashlet/6.php
Executable file
121
modules/EcmCharts/Dashlets/MyChartsProductsDashlet/6.php
Executable file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
session_start();
|
||||
include_once( '/var/www/html/e5crm/config.php');
|
||||
$sql=mysql_connect($sugar_config['dbconfig']['db_host_name'],$sugar_config['dbconfig']['db_user_name'],$sugar_config['dbconfig']['db_password']);
|
||||
mysql_select_db($sugar_config['dbconfig']['db_name']);
|
||||
mysql_query("set names utf8");
|
||||
include_once( '/var/www/html/e5crm/include/ECM/open_flash_chart/ofc-library/open-flash-chart.php' );
|
||||
//include_once('/var/www/html/e5crm/modules/EcmCharts/chartHelper.php');
|
||||
include_once("/var/www/html/e5crm/modules/EcmReports/cache.php");
|
||||
function repl($t){
|
||||
$a1=array("ą","ś","ę","ż","ź","ć","ń","ó","ł","Ą","Ś","Ę","Ż","Ź","Ć","Ń","Ó","Ł");
|
||||
$a2=array("a","s","e","z","z","c","n","o","l","A","S","E","Z","Z","C","N","O","L");
|
||||
return str_replace($a1,$a2,$t);
|
||||
}
|
||||
function getCallTime($id,$year){
|
||||
if($id){$acc_ids=array();
|
||||
$acc_ids[]="e.bean_id='".$id."'";
|
||||
$w=mysql_query("select contact_id from accounts_contacts where deleted='0' and account_id='".$id."'");
|
||||
while($r=mysql_fetch_array($w)){
|
||||
$acc_ids[]="e.bean_id='".$r['contact_id']."'";
|
||||
}
|
||||
$w=mysql_query("select id from accounts where deleted='0' and parent_id='".$id."'");
|
||||
while($r=mysql_fetch_array($w)){
|
||||
$acc_ids[]="e.bean_id='".$r['id']."'";
|
||||
}
|
||||
}
|
||||
|
||||
if(count($acc_ids)>0)$where="(".implode(" or ",$acc_ids).") and ";
|
||||
else $where="";
|
||||
$z="select sum(c.duration) as d,Month(e.date_modified) as m from ecmcalls_beans as e inner join cdr as c on c.id=e.ecmcall_id where ".$where."e.date_modified like '".$year."%' group by Month(e.date_modified)";
|
||||
$w=mysql_query($z);
|
||||
while($r=mysql_fetch_array($w)){
|
||||
$d[$year."-".$r['m']]+=$r['d'];
|
||||
}
|
||||
return $d;
|
||||
|
||||
}
|
||||
function getMinSec($v){
|
||||
$min=floor($v/60);
|
||||
$min1=$min;
|
||||
$h=floor($min/60);
|
||||
$min-=$h*60;
|
||||
$sec=$v-$min1*60;
|
||||
if($min1>0 || $sec>0 || $h>0)$str=$h."h ".$min."m ".$sec."s";
|
||||
return $str;
|
||||
}
|
||||
|
||||
$year=$_SESSION['EcmCharts_6_year'];
|
||||
$category=$_SESSION['EcmCharts_6_category'];
|
||||
$account=$_SESSION['EcmCharts_6_account'];
|
||||
|
||||
$months=array('styczeń','luty','marzec','kwiecień','maj','czerwiec','lipiec','sierpień','wrzesień','październik','listopad','grudzień');
|
||||
|
||||
$s=sum($year,$account,$category);
|
||||
$time=getCallTime($account,$year);
|
||||
for($i=1;$i<=12;$i++){
|
||||
if($i<10)$n="0".$i;
|
||||
else $n=$i;
|
||||
$ss=getSum($s,$year."-".$n,"",$category);
|
||||
if($temp<$ss['total'])$temp=$ss['total'];
|
||||
$arr_s[]=array(
|
||||
"name"=>repl($months[$i-1]),
|
||||
"value"=>$ss['total'],
|
||||
);
|
||||
if($tempr<$time[$year."-".$i])$tempr=$time[$year."-".$i];
|
||||
$arr_c[]=array(
|
||||
"name"=>repl($months[$i-1]),
|
||||
"value"=>$time[$year."-".$i],
|
||||
);
|
||||
}
|
||||
for($i=0;$i<count($arr_s);$i++){
|
||||
$data_1[]=$arr_s[$i]['value'];
|
||||
$data_2[]=$arr_c[$i]['value'];
|
||||
$cats[]=$arr_s[$i]['name'];
|
||||
}
|
||||
|
||||
$g = new graph();
|
||||
|
||||
//$g->title( 'Sales: '.$year_month, '{font-size:20px; color: #000000; margin: 5px; background-color: #ffffff; padding:5px; padding-left: 20px; padding-right: 20px;}' );
|
||||
|
||||
$g->bg_colour = '#ffffff';
|
||||
|
||||
$d1 = new bar( 75, '#D54C78' );
|
||||
$d2 = new bar( 75, '#3334AD' );
|
||||
$d2->key( 'Czas rozmowy', 10 );
|
||||
$d1->key( 'Sprzedaż', 10 );
|
||||
for($i=0;$i<count($data_1);$i++){
|
||||
$d1->add_data_tip($data_1[$i],"Sprzedaż: ".round($data_1[$i],2)."\nCzas rozmowy: ".getMinSec(round($data_2[$i],2)));
|
||||
$d2->add_data_tip($data_2[$i],"Sprzedaż: ".round($data_1[$i],2)."\nCzas rozmowy ".getMinSec(round($data_2[$i],2)));
|
||||
}
|
||||
$g->data_sets[]=$d1;
|
||||
$g->data_sets[]=$d2;
|
||||
|
||||
$g->set_tool_tip( '#x_label#<br>#tip#<br>' );
|
||||
|
||||
//$g->set_data($data_1);
|
||||
//$g->bar( 75, '#D54C78', '', 10 );
|
||||
//$g->set_data($data_2);
|
||||
//$g->bar( 75, '#3334AD', '', 10 );
|
||||
|
||||
$g->attach_to_y_right_axis(2);
|
||||
|
||||
$g->x_axis_colour( '#909090', '#ADB5C7' );
|
||||
$g->y_axis_colour( '#909090', '#ADB5C7' );
|
||||
$g->y_right_axis_colour( '#909090' );
|
||||
|
||||
$g->set_x_labels( $cats );
|
||||
$g->set_x_label_style( 10, '#000000', 2 );
|
||||
|
||||
$g->set_y_max( $temp );
|
||||
$g->set_y_right_max( $tempr );
|
||||
|
||||
$g->y_label_steps( 20 );
|
||||
//$g->y_right_label_steps( 20 );
|
||||
|
||||
$g->set_y_legend( '', 12, '#736AFF' );
|
||||
$g->set_y_right_legend( '' ,12 , '#164166' );
|
||||
|
||||
echo $g->render();
|
||||
mysql_close($sql);
|
||||
?>
|
||||
0
modules/EcmCharts/Dashlets/MyChartsProductsDashlet/Manifest.php
Executable file
0
modules/EcmCharts/Dashlets/MyChartsProductsDashlet/Manifest.php
Executable 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 $current_user;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
@@ -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['MyChartsProductsDashlet'] = array(
|
||||
'title' => 'Wykres: Czas rozmów & Sprzedaż',
|
||||
'description' => 'A customizable view into Tasks',
|
||||
'category' => 'Charts');
|
||||
?>
|
||||
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
|
||||
|
||||
require_once('include/Dashlets/Dashlet.php');
|
||||
require_once('include/Sugar_Smarty.php');
|
||||
include_once('include/ECM/open_flash_chart/ofc-library/open_flash_chart_object.php');
|
||||
|
||||
|
||||
class MyChartsProductsDashlet extends Dashlet {
|
||||
|
||||
var $savedText; // users's saved text
|
||||
var $height = '300'; // height of the pad
|
||||
|
||||
function MyChartsProductsDashlet($id, $def) {
|
||||
|
||||
global $current_user;
|
||||
|
||||
|
||||
parent::Dashlet($id); // call parent constructor
|
||||
|
||||
$this->isConfigurable = true; // dashlet is configurable
|
||||
$this->hasScript = false; // dashlet has java ipt attached to it
|
||||
|
||||
if($current_user->id=='2e72f487-d92b-954e-f50c-528b10ce81c9'){
|
||||
|
||||
|
||||
}
|
||||
// if no custom title, use default
|
||||
if(empty($def['title'])) $this->title = 'Wykres: Czas rozmów & Sprzedaż ';
|
||||
else $this->title = $def['title'];
|
||||
}
|
||||
|
||||
function display() {
|
||||
global $current_user;
|
||||
$ss = new Sugar_Smarty();
|
||||
$optionsArray = $this->loadOptions();
|
||||
//$ss->assign('account_id',$optionsArray['account_id']);
|
||||
$ss->assign('id', $this->id);
|
||||
$ss->assign('height', $this->height);
|
||||
$ss->assign('year', $optionsArray['year']);
|
||||
$_SESSION['EcmCharts_6_year']=$optionsArray['year'];
|
||||
$_SESSION['EcmCharts_6_category']=$category;
|
||||
$_SESSION['EcmCharts_6_account']=$optionsArray['account_id'];
|
||||
if(!isset($_SESSION['EcmCharts_6_year']))$_SESSION['EcmCharts_6_year']=(int)date("Y");
|
||||
if(!isset($_SESSION['EcmCharts_6_category']))$_SESSION['EcmCharts_6_category']='';
|
||||
if(!isset($_SESSION['EcmCharts_6_account']))$_SESSION['EcmCharts_6_account']='';
|
||||
//$_SESSION['EcmCharts_6_mmm']=$mmm;
|
||||
|
||||
$str = $ss->fetch('modules/EcmCharts/Dashlets/MyChartsProductsDashlet/MyChartsProductsDashlet.tpl');
|
||||
return parent::display('') . $str . '<br />'; // return parent::display for title and such
|
||||
}
|
||||
|
||||
function displayOptions() {
|
||||
|
||||
global $app_strings,$current_user;
|
||||
|
||||
$ss = new Sugar_Smarty();
|
||||
|
||||
$ss->assign('year',$_SESSION['EcmCharts_6_year']);
|
||||
$ss->assign('id', $this->id); //The id must be assigned in all dashlet options pages
|
||||
|
||||
return parent::displayOptions() . $ss->fetch('modules/EcmCharts/Dashlets/MyChartsProductsDashlet/MyChartsProductsDashletOptions.tpl');
|
||||
|
||||
}
|
||||
|
||||
function saveOptions($req) {
|
||||
global $sugar_config, $timedate, $current_user, $theme;
|
||||
$options = array();
|
||||
$options['account_name']=$_REQUEST['account_name'];
|
||||
$options['account_id']=$_REQUEST['account_id'];
|
||||
$options['year']=$_REQUEST['year'];
|
||||
$options['category']=$_REQUEST['category'];
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user