晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。 林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。 见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝) 既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。 南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。
|
Server : Apache System : Linux srv.rainic.com 4.18.0-553.47.1.el8_10.x86_64 #1 SMP Wed Apr 2 05:45:37 EDT 2025 x86_64 User : rainic ( 1014) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/akaindir/public_html/crm/modules/Vtiger/models/ |
Upload File : |
<?php
/*+***********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
* ("License"); You may not use this file except in compliance with the License
* The Original Code is: vtiger CRM Open Source
* The Initial Developer of the Original Code is vtiger.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
*************************************************************************************/
/**
* Vtiger Widget Model Class
*/
class Vtiger_Widget_Model extends Vtiger_Base_Model {
public function getWidth() {
$largerSizedWidgets = array('GroupedBySalesPerson', 'PipelinedAmountPerSalesPerson', 'GroupedBySalesStage', 'Funnel Amount');
$title = $this->getName();
if(in_array($title, $largerSizedWidgets)) {
$this->set('width', '2');
}
$width = $this->get('width');
if(empty($width)) {
$this->set('width', '1');
}
return $this->get('width');
}
public function getHeight() {
//Special case for History widget
$title = $this->getTitle();
if($title == 'History') {
$this->set('height', '2');
}
$height = $this->get('height');
if(empty($height)) {
$this->set('height', '1');
}
return $this->get('height');
}
public function getSizeX() {
$size = $this->get('size');
if ($size) {
$size = Zend_Json::decode(decode_html($size));
$width = intval($size['sizex']);
$this->set('width', $width);
return $width;
}
return $this->getWidth();
}
public function getSizeY() {
$size = $this->get('size');
if ($size) {
$size = Zend_Json::decode(decode_html($size));
$height = intval($size['sizey']);
$this->set('height', $height);
return $height;
}
return $this->getHeight();
}
public function getPositionCol($default=0) {
$position = $this->get('position');
if ($position) {
$position = Zend_Json::decode(decode_html($position));
return intval($position['col']);
}
return $default;
}
public function getPositionRow($default=0) {
$position = $this->get('position');
if ($position) {
$position = Zend_Json::decode(decode_html($position));
return intval($position['row']);
}
return $default;
}
/**
* Function to get the url of the widget
* @return <String>
*/
public function getUrl() {
$url = decode_html($this->get('linkurl')).'&linkid='.$this->get('linkid');
if($this->get('reportid')){
$chartReportLinkUrl = "index.php?module=Reports&view=ShowWidget&name=ChartReportWidget&reportid=".$this->get('reportid');
$url = decode_html($chartReportLinkUrl);
}
$widgetid = $this->has('widgetid')? $this->get('widgetid') : $this->get('id');
if ($widgetid) $url .= '&widgetid=' . $widgetid;
return $url;
}
/**
* Function to get the Title of the widget
*/
public function getTitle() {
$title = $this->get('title');
if(!$title) {
$title = $this->get('linklabel');
}
return $title;
}
public function getName() {
$widgetName = $this->get('name');
if(empty($widgetName)){
//since the html entitites will be encoded
//TODO : See if you need to push decode_html to base model
$linkUrl = decode_html($this->getUrl());
preg_match('/name=[a-zA-Z]+/', $linkUrl, $matches);
$matches = explode('=', $matches[0]);
$widgetName = $matches[1];
$this->set('name', $widgetName);
}
return $widgetName;
}
/**
* Function to get the instance of Vtiger Widget Model from the given array of key-value mapping
* @param <Array> $valueMap
* @return Vtiger_Widget_Model instance
*/
public static function getInstanceFromValues($valueMap) {
$self = new self();
$self->setData($valueMap);
return $self;
}
public static function getInstance($linkId, $userId) {
$db = PearDatabase::getInstance();
$result = $db->pquery('SELECT * FROM vtiger_module_dashboard_widgets
INNER JOIN vtiger_links ON vtiger_links.linkid = vtiger_module_dashboard_widgets.linkid
WHERE linktype = ? AND vtiger_links.linkid = ? AND userid = ?', array('DASHBOARDWIDGET', $linkId, $userId));
$self = new self();
if($db->num_rows($result)) {
$row = $db->query_result_rowdata($result, 0);
$self->setData($row);
}
return $self;
}
public static function updateWidgetPosition($position, $linkId, $widgetId, $userId) {
if (!$linkId && !$widgetId) return;
$db = PearDatabase::getInstance();
$sql = 'UPDATE vtiger_module_dashboard_widgets SET position=? WHERE userid=?';
$params = array($position, $userId);
if ($linkId) {
$sql .= ' AND linkid = ?';
$params[] = $linkId;
} else if ($widgetId) {
$sql .= ' AND id = ?';
$params[] = $widgetId;
}
$db->pquery($sql, $params);
}
public static function updateWidgetSize($size, $linkId, $widgetId, $userId, $tabId) {
if ($linkId || $widgetId) {
$db = PearDatabase::getInstance();
$sql = 'UPDATE vtiger_module_dashboard_widgets SET size=? WHERE userid=?';
$params = array($size, $userId);
if ($linkId) {
$sql .= ' AND linkid=?';
$params[] = $linkId;
} else if ($widgetId) {
$sql .= ' AND id=?';
$params[] = $widgetId;
}
$sql .= ' AND dashboardtabid=?';
$params[] = $tabId;
$db->pquery($sql, $params);
}
}
public static function getInstanceWithWidgetId($widgetId, $userId) {
$db = PearDatabase::getInstance();
$result = $db->pquery('SELECT * FROM vtiger_module_dashboard_widgets
INNER JOIN vtiger_links ON vtiger_links.linkid = vtiger_module_dashboard_widgets.linkid
WHERE linktype = ? AND vtiger_module_dashboard_widgets.id = ? AND userid = ?', array('DASHBOARDWIDGET', $widgetId, $userId));
$self = new self();
if($db->num_rows($result)) {
$row = $db->query_result_rowdata($result, 0);
$self->setData($row);
}
return $self;
}
public static function getInstanceWithReportId($reportId, $userId) {
$db = PearDatabase::getInstance();
$result = $db->pquery('SELECT * FROM vtiger_module_dashboard_widgets
WHERE reportid = ? AND userid = ?', array($reportId, $userId));
$self = new self();
if($db->num_rows($result)) {
$row = $db->query_result_rowdata($result, 0);
$self->setData($row);
}
return $self;
}
/**
* Function to add a widget from the Users Dashboard
*/
public function add() {
$db = PearDatabase::getInstance();
$tabid = 1;
if ($this->get("tabid")) {
$tabid = $this->get("tabid");
}
$sql = 'SELECT id FROM vtiger_module_dashboard_widgets WHERE linkid = ? AND userid = ? AND dashboardtabid=?';
$params = array($this->get('linkid'), $this->get('userid'), $tabid);
$filterid = $this->get('filterid');
if (!empty($filterid)) {
$sql .= ' AND filterid = ?';
$params[] = $this->get('filterid');
}
$result = $db->pquery($sql, $params);
if(!$db->num_rows($result)) {
$db->pquery('INSERT INTO vtiger_module_dashboard_widgets(linkid, userid, filterid, title, data,dashboardtabid) VALUES(?,?,?,?,?,?)',
array($this->get('linkid'), $this->get('userid'), $this->get('filterid'), $this->get('title'), Zend_Json::encode($this->get('data')),$tabid));
$this->set('id', $db->getLastInsertID());
} else if($this->has('data')){
$db->pquery('INSERT INTO vtiger_module_dashboard_widgets(linkid, userid, filterid, title, data,dashboardtabid) VALUES(?,?,?,?,?,?)',
array($this->get('linkid'), $this->get('userid'), $this->get('filterid'), $this->get('title'), Zend_Json::encode($this->get('data')),$tabid));
$this->set('id', $db->getLastInsertID());
}
else {
$this->set('id', $db->query_result($result, 0, 'id'));
}
}
/**
* Function to remove the widget from the Users Dashboard
*/
public function remove() {
$db = PearDatabase::getInstance();
$db->pquery('DELETE FROM vtiger_module_dashboard_widgets WHERE id = ? AND userid = ?',
array($this->get('id'), $this->get('userid')));
}
/**
* Function deletes all dashboard widgets with the reportId
* @param type $reportId
*/
public static function deleteChartReportWidgets($reportId) {
$db = PearDatabase::getInstance();
$db->pquery('DELETE FROM vtiger_module_dashboard_widgets WHERE reportid = ?',
array($reportId));
}
/**
* Function returns URL that will remove a widget for a User
* @return <String>
*/
public function getDeleteUrl() {
$url = 'index.php?module=Vtiger&action=RemoveWidget&linkid='. $this->get('linkid');
$widgetid = $this->has('widgetid')? $this->get('widgetid') : $this->get('id');
if ($widgetid) $url .= '&widgetid=' . $widgetid;
if ($this->get('reportid')) $url .= '&reportid=' .$this->get('reportid');
return $url;
}
/**
* Function to check the Widget is Default widget or not
* @return <boolean> true/false
*/
public function isDefault() {
$defaultWidgets = $this->getDefaultWidgets();
$widgetName = $this->getName();
if (in_array($widgetName, $defaultWidgets)) {
return true;
}
return false;
}
/**
* Function to get Default widget Names
* @return <type>
*/
public function getDefaultWidgets() {
return array();
}
}