📄 mypipelinebysalesstagedashlet.php
字号:
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/**
* The contents of this file are subject to the SugarCRM Public License Version
* 1.1.3 ("License"); You may not use this file except in compliance with the
* License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* All copies of the Covered Code must include on each user interface screen:
* (i) the "Powered by SugarCRM" logo and
* (ii) the SugarCRM copyright notice
* in the same form as they appear in the distribution. See full license for
* requirements.
*
* The Original Code is: SugarCRM Open Source
* The Initial Developer of the Original Code is SugarCRM, Inc.
* Portions created by SugarCRM are Copyright (C) 2004-2006 SugarCRM, Inc.;
* All Rights Reserved.
* Contributor(s): ______________________________________.
*/
// $Id: MyPipelineBySalesStageDashlet.php,v 1.6 2006/08/22 20:14:45 wayne Exp $
require_once('include/Dashlets/Dashlet.php');
require_once('include/Sugar_Smarty.php');
require_once('include/charts/Charts.php');
require_once('modules/Charts/code/Chart_pipeline_by_sales_stage.php');
require_once('modules/Dashboard/Forms.php');
class MyPipelineBySalesStageDashlet extends Dashlet {
var $mypbss_date_start;
var $mypbss_date_end;
var $mypbss_sales_stages = null;
var $refresh = false;
function MyPipelineBySalesStageDashlet($id, $options) {
global $timedate;
parent::Dashlet($id);
$this->isConfigurable = true;
$this->isRefreshable = false;
if(empty($options['mypbss_date_start']))
$this->mypbss_date_start = date($timedate->get_date_format(), time());
else
$this->mypbss_date_start = $options['mypbss_date_start'];
if(empty($options['mypbss_date_end']))
$this->mypbss_date_end = date($timedate->get_date_format(), strtotime('2010-01-01'));
else
$this->mypbss_date_end = $options['mypbss_date_end'];
if(empty($options['mypbss_sales_stages']))
$this->mypbss_sales_stages = array();
else
$this->mypbss_sales_stages = $options['mypbss_sales_stages'];
if(empty($options['title'])) $this->title = translate('LBL_PIPELINE_FORM_TITLE', 'Home');
}
function saveOptions($req) {
global $sugar_config, $timedate, $current_user, $theme;
$options = array();
$date_start = $this->mypbss_date_start;
$date_end = $this->mypbss_date_end;
$dateStartDisplay = strftime($timedate->get_user_date_format(), strtotime($date_start));
$dateEndDisplay = strftime($timedate->get_user_date_format(), strtotime($date_end));
$seps = array("-", "/");
$dates = array($dateStartDisplay, $dateEndDisplay);
$dateFileNameSafe = str_replace($seps, "_", $dates);
if(is_file($sugar_config['tmp_dir'] . $current_user->getUserPrivGuid()."_".$theme."_my_pipeline_".$dateFileNameSafe[0]."_".$dateFileNameSafe[1].".xml"))
unlink($sugar_config['tmp_dir'] . $current_user->getUserPrivGuid()."_".$theme."_my_pipeline_".$dateFileNameSafe[0]."_".$dateFileNameSafe[1].".xml");
$options['mypbss_sales_stages'] = $_REQUEST['mypbss_sales_stages'];
$options['mypbss_date_start'] = $_REQUEST['mypbss_date_start'];
$options['mypbss_date_end'] = $_REQUEST['mypbss_date_end'];
return $options;
}
function displayOptions() {
global $timedate, $image_path, $app_strings, $current_user, $app_list_strings;
$ss = new Sugar_Smarty();
$ss->assign('id', $this->id);
$ss->assign('LBL_DATE_START', translate('LBL_DATE_START', 'Charts'));
$ss->assign('LBL_DATE_END', translate('LBL_DATE_END', 'Charts'));
$ss->assign('LBL_SALES_STAGES', translate('LBL_SALES_STAGES', 'Charts'));
$ss->assign('LBL_ENTER_DATE', translate('LBL_ENTER_DATE', 'Charts'));
$ss->assign('LBL_SELECT_BUTTON_TITLE', $app_strings['LBL_SELECT_BUTTON_TITLE']);
$ss->assign('image_path', $image_path);
//get the dates to display
$date_start = $this->mypbss_date_start;
$date_end = $this->mypbss_date_end;
$ss->assign('date_start', $date_start);
$ss->assign('date_end', $date_end);
$tempx = array();
$datax = array();
$selected_datax = array();
//get list of sales stage keys to display
$user_sales_stage = $this->mypbss_sales_stages;
$tempx = $user_sales_stage;
//set $datax using selected sales stage keys
if (count($tempx) > 0) {
foreach ($tempx as $key) {
$datax[$key] = $app_list_strings['sales_stage_dom'][$key];
array_push($selected_datax, $key);
}
}
else {
$datax = $app_list_strings['sales_stage_dom'];
$selected_datax = array_keys($app_list_strings['sales_stage_dom']);
}
$ss->assign('selected_datax', get_select_options_with_id($app_list_strings['sales_stage_dom'], $selected_datax));
$ss->assign('user_date_format', $timedate->get_user_date_format());
$ss->assign('cal_dateformat', $timedate->get_cal_date_format());
return parent::displayOptions() . $ss->fetch('modules/Charts/Dashlets/MyPipelineBySalesStageDashlet/MyPipelineBySalesStageConfigure.tpl');
}
function display() {
global $app_list_strings, $current_language, $sugar_config, $currentModule, $action, $current_user, $theme, $timedate, $image_path;
$this->loadLanguage('MyPipelineBySalesStageDashlet', 'modules/Charts/Dashlets/');
$returnStr = '';
$user_dateFormat = $timedate->get_date_format();
$current_module_strings = return_module_language($current_language, 'Charts');
if(isset($_REQUEST['mypbss_refresh'])) {
$refresh = $_REQUEST['mypbss_refresh'];
}
else {
$refresh = false;
}
$date_start = $this->mypbss_date_start;
$date_end = $this->mypbss_date_end;
// cn: format date_start|end to user's preferred
$dateStartDisplay = strftime($timedate->get_user_date_format(), strtotime($date_start));
$dateEndDisplay = strftime($timedate->get_user_date_format(), strtotime($date_end));
$seps = array("-", "/");
$dates = array($date_start, $date_end);
$dateFileNameSafe = str_replace($seps, "_", $dates);
$dateXml[0] = $timedate->swap_formats($date_start, $user_dateFormat, $timedate->dbDayFormat);
$dateXml[1] = $timedate->swap_formats($date_end, $user_dateFormat, $timedate->dbDayFormat);
$datax = array();
$selected_datax = array();
//get list of sales stage keys to display
$user_sales_stage = $this->mypbss_sales_stages;
$tempx = $user_sales_stage;
//set $datax using selected sales stage keys
if (count($tempx) > 0) {
foreach ($tempx as $key) {
$datax[$key] = $app_list_strings['sales_stage_dom'][$key];
array_push($selected_datax, $key);
}
}
else {
$datax = $app_list_strings['sales_stage_dom'];
$selected_datax = array_keys($app_list_strings['sales_stage_dom']);
}
$GLOBALS['log']->debug("datax is:");
$GLOBALS['log']->debug($datax);
$ids = array($current_user->id);
//create unique prefix based on selected users for image files
$id_hash = '1';
if (isset($ids)) {
sort($ids);
$id_hash = crc32(implode('',$ids));
if($id_hash < 0)
{
$id_hash = $id_hash * -1;
}
}
$GLOBALS['log']->debug("ids is:");
$GLOBALS['log']->debug($ids);
$id_md5 = substr(md5($current_user->id),0,9);
$seps = array("-", "/");
$dates = array($dateStartDisplay, $dateEndDisplay);
$dateFileNameSafe = str_replace($seps, "_", $dates);
$cache_file_name = $current_user->getUserPrivGuid()."_".$theme."_my_pipeline_".$dateFileNameSafe[0]."_".$dateFileNameSafe[1].".xml";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -