init
This commit is contained in:
446
include/DetailView/DetailView.php
Executable file
446
include/DetailView/DetailView.php
Executable file
@@ -0,0 +1,446 @@
|
||||
<?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-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero 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 Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero 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 Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero 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".
|
||||
********************************************************************************/
|
||||
|
||||
|
||||
class DetailView extends ListView {
|
||||
|
||||
var $list_row_count = null;
|
||||
var $return_to_list_only=false;
|
||||
var $offset_key_mismatch=false;
|
||||
var $no_record_found=false;
|
||||
|
||||
function DetailView(){
|
||||
parent::ListView();
|
||||
|
||||
global $theme, $app_strings, $currentModule;
|
||||
$this->local_theme = $theme;
|
||||
$this->local_app_strings =$app_strings;
|
||||
}
|
||||
|
||||
function processSugarBean($html_varName, $seed, &$offset, $isfirstview=0) {
|
||||
global $row_count, $sugar_config;
|
||||
|
||||
global $next_offset;
|
||||
global $previous_offset;
|
||||
global $list_view_row_count;
|
||||
global $current_offset;
|
||||
if (!empty($sugar_config['disable_vcr']) ) {
|
||||
$seed->retrieve($_REQUEST['record']);
|
||||
return $seed;
|
||||
}
|
||||
$isfirstview = 0;
|
||||
|
||||
$nav_history_set=false;
|
||||
$nav_history_array=array();
|
||||
$nav_offset='';
|
||||
$nav_ids_visited=array();
|
||||
$nav_stamp='';
|
||||
|
||||
//get the session variable DETAIL_NAV_HISTORY,
|
||||
//the format of the variable stamp,offset, array of IDs visited.
|
||||
$nav_history=$this->getLocalSessionVariable($html_varName, "DETAIL_NAV_HISTORY");
|
||||
if (!empty($nav_history)) {
|
||||
$nav_history_set=true;
|
||||
$nav_history_array=explode(":",$nav_history);
|
||||
$nav_stamp=$nav_history_array[0];
|
||||
$nav_offset=$nav_history_array[1];
|
||||
eval("\$nav_ids_visited= ".$nav_history_array[2].";");
|
||||
}
|
||||
|
||||
//from list offset is there but $bNavHistorySet is false.
|
||||
//from next,previous,start and end buttons offset and $bNavHistorySet is true.
|
||||
//from tracker offset is not there but $bNavHistorySet may or may not exist.
|
||||
if (isset($_REQUEST['offset']) && !empty($_REQUEST['offset'])) {
|
||||
//get offset values.
|
||||
$offset = $_REQUEST['offset'];
|
||||
if($offset < 0){
|
||||
$offset = 0;
|
||||
}
|
||||
//if the stamp has changed, ignore the offset and navigate to the record.
|
||||
//use case, search, navigate to detail, copy URL, search again, paste URL.
|
||||
if (!$this->isRequestFromListView($html_varName)) {
|
||||
$result = $seed->retrieve($_REQUEST['record']);
|
||||
return $result;
|
||||
}
|
||||
|
||||
if ($nav_history_set) {
|
||||
if (isset($nav_ids_visited[$offset])) {
|
||||
unset($nav_ids_visited[$offset]);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if ($nav_history_set) {
|
||||
//try to locate the ID in the nav_history array.
|
||||
|
||||
$key = array_search($_REQUEST['record'], $nav_ids_visited);
|
||||
if ($key === false) {
|
||||
//do not show the VCR buttons.
|
||||
|
||||
$result = $seed->retrieve($_REQUEST['record']);
|
||||
return $result;
|
||||
}
|
||||
$offset=$key;
|
||||
$_REQUEST['offset'] = $offset;
|
||||
$_GET['offset'] = $offset;
|
||||
$_POST['offset'] = $offset;
|
||||
|
||||
$_REQUEST['stamp'] = $nav_stamp;
|
||||
$_GET['stamp'] = $nav_stamp;
|
||||
$_POST['stamp'] = $nav_stamp;
|
||||
if (isset($nav_ids_visited[$offset])) {
|
||||
unset($nav_ids_visited[$offset]);
|
||||
}
|
||||
|
||||
} else {
|
||||
if(!empty($seed->id))return $seed;
|
||||
|
||||
$result = $seed->retrieve($_REQUEST['record']);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
//Check if this is the first time we have viewed this record
|
||||
$var = $this->getLocalSessionVariable($html_varName, "IS_FIRST_VIEW");
|
||||
if(!isset($var) || !$var){
|
||||
$isFirstView = true;
|
||||
}
|
||||
else{
|
||||
$isFirstView = false;
|
||||
}
|
||||
//indicate that this is not the first time anymore
|
||||
$this->setLocalSessionVariable($html_varName, "IS_FIRST_VIEW", false);
|
||||
|
||||
// All 3 databases require this because the limit query does a > db_offset comparision.
|
||||
$db_offset=$offset-1;
|
||||
|
||||
$this->populateQueryWhere($isFirstView, $html_varName);
|
||||
if(ACLController::requireOwner($seed->module_dir, 'view')) {
|
||||
global $current_user;
|
||||
$seed->getOwnerWhere($current_user->id);
|
||||
if(!empty($this->query_where)) {
|
||||
$this->query_where .= ' AND ';
|
||||
}
|
||||
$this->query_where .= $seed->getOwnerWhere($current_user->id);
|
||||
}
|
||||
|
||||
$order = $this->getLocalSessionVariable($seed->module_dir.'2_'.$html_varName, "ORDER_BY");
|
||||
$orderBy = '';
|
||||
if(!empty($order['orderBy']))
|
||||
$orderBy = $order['orderBy'];
|
||||
if(!empty($orderBy) && !empty($order['direction']))
|
||||
$orderBy .= ' ' . $order['direction'];
|
||||
|
||||
$this->query_orderby = $seed->process_order_by($orderBy,null);
|
||||
$current_offset = $_REQUEST['offset'] -1;
|
||||
$response = $seed->process_detail_query(SugarVCR::retrieve($seed->module_dir), 0, -1, -1, '', $current_offset);
|
||||
//$response = $seed->get_detail(, $this->query_where, $db_offset);
|
||||
$object = $response['bean'];
|
||||
$row_count = $response['row_count'];
|
||||
$next_offset = $response['next_offset'];
|
||||
$previous_offset = $response['previous_offset'];
|
||||
$list_view_row_count = $row_count;
|
||||
$this->setListViewRowCount($row_count);
|
||||
|
||||
//if the retrieved id is not same as the request ID then hide the VCR buttons.
|
||||
if (empty($object->id)) {
|
||||
$this->no_record_found=true;
|
||||
}
|
||||
if (empty($_REQUEST['InDetailNav']) and strcmp($_REQUEST['record'],$object->id)!=0) {
|
||||
$this->offset_key_mismatch=true;
|
||||
}
|
||||
if ($this->no_record_found or $this->offset_key_mismatch ) {
|
||||
if ($nav_history_set) {
|
||||
$this->return_to_list_only=true;
|
||||
}
|
||||
$result = $seed->retrieve($_REQUEST['record']);
|
||||
return $result;
|
||||
}
|
||||
|
||||
//update the request with correct value for the record attribute.
|
||||
//need only when using the VCR buttuoms. This is a workaround need to fix the values
|
||||
//set in the VCR links.
|
||||
$_REQUEST['record'] = $object->id;
|
||||
$_GET['record'] = $object->id;
|
||||
$_POST['record'] = $object->id;
|
||||
|
||||
//set nav_history.
|
||||
if (empty($nav_stamp)) {
|
||||
$nav_stamp=$_GET['stamp'];
|
||||
}
|
||||
if (empty($nav_offset)) {
|
||||
$nav_offset=$offset;
|
||||
}
|
||||
//store a maximum of 20 entries in the nav_ids_visited array.
|
||||
//remove the oldest entry when this limit is reached.
|
||||
if (count($nav_ids_visited) >= 20) {
|
||||
reset($nav_ids_visited);
|
||||
unset($nav_ids_visited[key($nav_ids_visited)]);
|
||||
}
|
||||
$nav_ids_visited[$offset]=$object->id;
|
||||
$nav_history=sprintf("%s:%s:%s",$nav_stamp,$nav_offset,var_export($nav_ids_visited,true));
|
||||
$this->setLocalSessionVariable($html_varName, "DETAIL_NAV_HISTORY",$nav_history);
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
function populateQueryWhere($isfirstview, $html_varName){
|
||||
if($isfirstview){
|
||||
$this->query_where = $this->getVariableFromSession($_REQUEST['module'], 'QUERY_WHERE');
|
||||
|
||||
//this is a fail safe, in case the old ListView is still in use
|
||||
if(empty($this->query_where)){
|
||||
$this->query_where = $this->getLocalSessionVariable($html_varName, "QUERY_WHERE");
|
||||
}
|
||||
//SETTING QUERY FOR LATER USE
|
||||
$this->setSessionVariable("QUERY_DETAIL", "where", $this->query_where);
|
||||
}
|
||||
else{
|
||||
$this->query_where = $this->getSessionVariable("QUERY_DETAIL", "where");
|
||||
}
|
||||
}
|
||||
|
||||
function processListNavigation( &$xtpl, $html_varName, $current_offset, $display_audit_link = false){
|
||||
global $export_module, $sugar_config, $current_user;
|
||||
//intialize audit_link
|
||||
$audit_link = '';
|
||||
|
||||
$row_count = $this->getListViewRowCount();
|
||||
|
||||
if($display_audit_link && (!isset($sugar_config['disc_client']) || $sugar_config['disc_client'] == false))
|
||||
{
|
||||
//Audit link
|
||||
$popup_request_data = array(
|
||||
'call_back_function' => 'set_return',
|
||||
'form_name' => 'EditView',
|
||||
'field_to_name_array' => array(),
|
||||
);
|
||||
$json = getJSONobj();
|
||||
$encoded_popup_request_data = $json->encode($popup_request_data);
|
||||
$audit_link = "<a href='#' onclick='open_popup(\"Audit\", \"600\", \"400\", \"&record=".$_REQUEST['record']."&module_name=".$_REQUEST['module']."\", true, false, $encoded_popup_request_data);'>".$this->local_app_strings['LNK_VIEW_CHANGE_LOG']."</a>";
|
||||
}
|
||||
|
||||
$html_text = "";
|
||||
$pre_html_text = "";
|
||||
$pre_html_text .= "<tr class='pagination'>\n";
|
||||
$pre_html_text .= "<td COLSPAN=\"20\">\n";
|
||||
$pre_html_text .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td style=\"text-align: left\" > ".$audit_link."</td>\n";
|
||||
|
||||
|
||||
|
||||
if ($this->return_to_list_only == true) {
|
||||
if($current_offset != 0 && $this->isRequestFromListView($html_varName))
|
||||
{
|
||||
if($current_offset < 0){
|
||||
$current_offset = 1;
|
||||
}
|
||||
else if($current_offset > $row_count){
|
||||
$current_offset = $row_count;
|
||||
}
|
||||
|
||||
$this->set_base_URL($html_varName);
|
||||
$list_URL = $this->base_URL.'&action=index&module='.$_REQUEST['module'];
|
||||
$current_page = floor($current_offset / $this->records_per_page) * $this->records_per_page;
|
||||
|
||||
$list_URL .= '&'.$this->getSessionVariableName($html_varName,"offset").'='.$current_page;
|
||||
//$list_link = "<a href=\"$list_URL\" >".$this->local_app_strings['LNK_LIST_RETURN']." </a>";
|
||||
$list_link = "<button type='button' class='button' title='{$GLOBALS['app_strings']['LNK_LIST_RETURN']}' onClick='location.href=\"$list_URL\";'>".$this->local_app_strings['LNK_LIST_RETURN']."</button>";
|
||||
|
||||
$html_text .= "<td nowrap align='right' scope='row'>".$list_link;
|
||||
|
||||
if ($row_count != 0) {
|
||||
$resume_URL = $this->base_URL.$current_offset."&InDetailNav=1";
|
||||
//$resume_link = "<a href=\"$resume_URL\" >".$this->local_app_strings['LNK_RESUME']." </a>";
|
||||
$resume_link = "<button type='button' class='button' title='$this->local_app_strings['LNK_RESUME']' onClick='location.href=\"$resume_URL\";'>".$this->local_app_strings['LNK_RESUME']."</button>";
|
||||
|
||||
$html_text .= " ".$resume_link;
|
||||
}
|
||||
$html_text .= "</td>";
|
||||
}
|
||||
}
|
||||
else {
|
||||
if($current_offset != 0 && $this->isRequestFromListView($html_varName))
|
||||
{
|
||||
if($current_offset < 0){
|
||||
$current_offset = 1;
|
||||
}
|
||||
else if($current_offset > $row_count){
|
||||
$current_offset = $row_count;
|
||||
}
|
||||
|
||||
$next_offset = $current_offset + 1;
|
||||
$previous_offset = $current_offset - 1;
|
||||
|
||||
$this->set_base_URL($html_varName);
|
||||
|
||||
$start_URL = $this->base_URL."1"."&InDetailNav=1";
|
||||
$current_URL = $this->base_URL.$current_offset."&InDetailNav=1";
|
||||
$previous_URL = $this->base_URL.$previous_offset."&InDetailNav=1";
|
||||
$next_URL = $this->base_URL.$next_offset."&InDetailNav=1";
|
||||
$end_URL = $this->base_URL.$row_count."&InDetailNav=1";
|
||||
|
||||
$current_page = floor($current_offset / $this->records_per_page) * $this->records_per_page;
|
||||
|
||||
if(1 == $current_offset){
|
||||
//$start_link = SugarThemeRegistry::current()->getImage("start_off","alt='".$this->local_app_strings['LNK_LIST_START']."' border='0' align='absmiddle'")." ".$this->local_app_strings['LNK_LIST_START'];
|
||||
//$previous_link = SugarThemeRegistry::current()->getImage("previous_off","alt='".$this->local_app_strings['LNK_LIST_PREVIOUS']."' border='0' align='absmiddle'")." ".$this->local_app_strings['LNK_LIST_PREVIOUS']."";
|
||||
$start_link = "<button type='button' title='{$this->local_app_strings['LNK_LIST_START']}' class='button' disabled>".SugarThemeRegistry::current()->getImage("start_off","alt='".$this->local_app_strings['LNK_LIST_START']."' border='0' align='absmiddle'")."</button>";
|
||||
$previous_link = "<button type='button' title='{$this->local_app_strings['LNK_LIST_PREVIOUS']}' class='button' disabled>".SugarThemeRegistry::current()->getImage("previous_off","alt='".$this->local_app_strings['LNK_LIST_PREVIOUS']."' border='0' align='absmiddle'")."</button>";
|
||||
|
||||
}else{
|
||||
//$start_link = "<a href=\"$start_URL\">".SugarThemeRegistry::current()->getImage("start","alt='".$this->local_app_strings['LNK_LIST_START']."' border='0' align='absmiddle'")."</a> <a href=\"$start_URL\">".$this->local_app_strings['LNK_LIST_START']."</a>";
|
||||
$start_link = "<button type='button' class='button' title='{$this->local_app_strings['LNK_LIST_START']}' onClick='location.href=\"$start_URL\";'>".SugarThemeRegistry::current()->getImage("start","alt='".$this->local_app_strings['LNK_LIST_START']."' border='0' align='absmiddle'")."</button>";
|
||||
|
||||
if(0 != $current_offset){
|
||||
//$previous_link = "<a href=\"$previous_URL\">".SugarThemeRegistry::current()->getImage("previous","alt='".$this->local_app_strings['LNK_LIST_PREVIOUS']."' border='0' align='absmiddle'")."</a> <a href=\"$previous_URL\" >".$this->local_app_strings['LNK_LIST_PREVIOUS']."</a>";
|
||||
$previous_link = "<button type='button' class='button' title='{$this->local_app_strings['LNK_LIST_PREVIOUS']}' onClick='location.href=\"$previous_URL\";'>".SugarThemeRegistry::current()->getImage("previous","alt='".$this->local_app_strings['LNK_LIST_PREVIOUS']."' border='0' align='absmiddle'")."</button>";
|
||||
}
|
||||
else {
|
||||
//$previous_link = SugarThemeRegistry::current()->getImage("previous_off","alt='".$this->local_app_strings['LNK_LIST_PREVIOUS']."' border='0' align='absmiddle'")." ".$this->local_app_strings['LNK_LIST_PREVIOUS'];
|
||||
$previous_link = "<button type='button' title='{$this->local_app_strings['LNK_LIST_PREVIOUS']}' class='button' disabled>".SugarThemeRegistry::current()->getImage("previous_off","alt='".$this->local_app_strings['LNK_LIST_PREVIOUS']."' border='0' align='absmiddle'")."</button>";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($row_count <= $current_offset){
|
||||
//$end_link = $this->local_app_strings['LNK_LIST_END']." ".SugarThemeRegistry::current()->getImage("end_off","alt='".$this->local_app_strings['LNK_LIST_END']."' border='0' align='absmiddle'");
|
||||
//$next_link = $this->local_app_strings['LNK_LIST_NEXT']." ".SugarThemeRegistry::current()->getImage("next_off","alt='".$this->local_app_strings['LNK_LIST_NEXT']."' border='0' align='absmiddle'");
|
||||
$end_link = "<button type='button' title='{$this->local_app_strings['LNK_LIST_END']}' class='button' disabled>".SugarThemeRegistry::current()->getImage("end_off","alt='".$this->local_app_strings['LNK_LIST_END']."' border='0' align='absmiddle'")."</button>";
|
||||
$next_link = "<button type='button' title='{$this->local_app_strings['LNK_LIST_NEXT']}' class='button' disabled>".SugarThemeRegistry::current()->getImage("next_off","alt='".$this->local_app_strings['LNK_LIST_NEXT']."' border='0' align='absmiddle'")."</button>";
|
||||
}
|
||||
else{
|
||||
//$end_link = "<a href=\"$end_URL\">".$this->local_app_strings['LNK_LIST_END']."</a> <a href=\"$end_URL\">".SugarThemeRegistry::current()->getImage("end","alt='".$this->local_app_strings['LNK_LIST_END']."' border='0' align='absmiddle'")."</a>";
|
||||
//$next_link = "<a href=\"$next_URL\">".$this->local_app_strings['LNK_LIST_NEXT']."</a> <a href=\"$next_URL\">".SugarThemeRegistry::current()->getImage("next","alt='".$this->local_app_strings['LNK_LIST_NEXT']."' border='0' align='absmiddle'")."</a>";
|
||||
$end_link = "<button type='button' class='button' title='{$this->local_app_strings['LNK_LIST_END']}' onClick='location.href=\"$end_URL\";'>".SugarThemeRegistry::current()->getImage("end","alt='".$this->local_app_strings['LNK_LIST_END']."' border='0' align='absmiddle'")."</button>";
|
||||
$next_link = "<button type='button' class='button' title='{$this->local_app_strings['LNK_LIST_NEXT']}' onClick='location.href=\"$next_URL\";'>".SugarThemeRegistry::current()->getImage("next","alt='".$this->local_app_strings['LNK_LIST_NEXT']."' border='0' align='absmiddle'")."</button>";
|
||||
|
||||
}
|
||||
|
||||
$html_text .= "<td nowrap align='right' >".$start_link." ".$previous_link." (".$current_offset." ".$this->local_app_strings['LBL_LIST_OF']." ".$row_count.") ".$next_link." ".$end_link."</td>";
|
||||
|
||||
}
|
||||
}
|
||||
$post_html_text = "</tr></table>\n";
|
||||
$post_html_text .= "</td>\n";
|
||||
$post_html_text .= "</tr>\n";
|
||||
if ( $html_text != "" )
|
||||
$xtpl->assign("PAGINATION",$pre_html_text.$html_text.$post_html_text);
|
||||
}
|
||||
|
||||
|
||||
function set_base_URL($html_varName) {
|
||||
|
||||
if(!isset($this->base_URL)){
|
||||
|
||||
$this->base_URL = $_SERVER['PHP_SELF'];
|
||||
if(empty($this->base_URL)){
|
||||
$this->base_URL = 'index.php';
|
||||
}
|
||||
|
||||
/*fixes an issue with
|
||||
deletes when doing a search*/
|
||||
foreach($_GET as $name=>$value){
|
||||
if(!empty($value)){
|
||||
if($name != $this->getSessionVariableName($html_varName,"ORDER_BY") && $name != "offset" && substr_count($name, "ORDER_BY")==0 && $name!="isfirstview"){
|
||||
if (is_array($value)) {
|
||||
foreach($value as $valuename=>$valuevalue){
|
||||
$this->base_URL .= "&{$name}[]=".$valuevalue;
|
||||
}
|
||||
} else {
|
||||
if(substr_count( $this->base_URL, '?') > 0){
|
||||
$this->base_URL .= "&$name=$value";
|
||||
}else{
|
||||
$this->base_URL .= "?$name=$value";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($_SERVER['REQUEST_METHOD'] == 'POST'){
|
||||
$this->base_URL .= '?';
|
||||
if(isset($_REQUEST['action'])) $this->base_URL .= '&action='.$_REQUEST['action'];
|
||||
if(isset($_REQUEST['record'])) $this->base_URL .= '&record='.$_REQUEST['record'];
|
||||
if(isset($_REQUEST['module'])) $this->base_URL .= '&module='.$_REQUEST['module'];
|
||||
}
|
||||
$this->base_URL .= "&offset=";
|
||||
}
|
||||
}
|
||||
function setListViewRowCount($count)
|
||||
{
|
||||
$this->list_row_count = $count;
|
||||
}
|
||||
|
||||
function getListViewRowCount()
|
||||
{
|
||||
return $this->list_row_count;
|
||||
}
|
||||
|
||||
/* This method will return in all of these cases: When selecting any of the VCR buttons (start,prev,next or last)
|
||||
* and navigating from list to detail for the first time.
|
||||
* if false in this case: the user changes the list query (which generates a new stamp) and pastes a URL
|
||||
* from a previously navigated item.
|
||||
*/
|
||||
function isRequestFromListView($html_varName)
|
||||
{
|
||||
$varList = $this->getLocalSessionVariable($html_varName, "FROM_LIST_VIEW");
|
||||
if(isset($_GET['stamp']) && isset($varList) && $varList == $_GET['stamp']){
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a variable from the session. uses the new ListView session data. Hence the '2'
|
||||
*
|
||||
* @param unknown_type $name - the name of the variable to set in the session
|
||||
* @param unknown_type $value - the value of the variable to set
|
||||
*/
|
||||
function getVariableFromSession($name, $value){
|
||||
if(isset($_SESSION[$name."2_".$value])){
|
||||
return $_SESSION[$name."2_".$value];
|
||||
}
|
||||
else{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
142
include/DetailView/DetailView.tpl
Executable file
142
include/DetailView/DetailView.tpl
Executable file
@@ -0,0 +1,142 @@
|
||||
{*
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero 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 Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero 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 Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero 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".
|
||||
********************************************************************************/
|
||||
*}
|
||||
{{include file=$headerTpl}}
|
||||
{sugar_include include=$includes}
|
||||
<div id="{{$module}}_detailview_tabs"
|
||||
{{if $useTabs}}
|
||||
class="yui-navset detailview_tabs"
|
||||
{{/if}}
|
||||
>
|
||||
{{if $useTabs}}
|
||||
{* Generate the Tab headers *}
|
||||
{{counter name="tabCount" start=-1 print=false assign="tabCount"}}
|
||||
<ul class="yui-nav">
|
||||
{{foreach name=section from=$sectionPanels key=label item=panel}}
|
||||
{{counter name="tabCount" print=false}}
|
||||
<li><a id="tab{{$tabCount}}" href="#tab{{$tabCount}}"><em>{sugar_translate label='{{$label}}' module='{{$module}}'}</em></a></li>
|
||||
{{/foreach}}
|
||||
</ul>
|
||||
{{/if}}
|
||||
<div {{if $useTabs}}class="yui-content"{{/if}}>
|
||||
{{* Loop through all top level panels first *}}
|
||||
{{counter name="panelCount" print=false start=0 assign="panelCount"}}
|
||||
{{foreach name=section from=$sectionPanels key=label item=panel}}
|
||||
{{assign var='panel_id' value=$panelCount}}
|
||||
<div id='{{$label}}' class='detail view'>
|
||||
{counter name="panelFieldCount" start=0 print=false assign="panelFieldCount"}
|
||||
{{* Print out the panel title if one exists*}}
|
||||
|
||||
{{* Check to see if the panel variable is an array, if not, we'll attempt an include with type param php *}}
|
||||
{{* See function.sugar_include.php *}}
|
||||
{{if !is_array($panel)}}
|
||||
{sugar_include type='php' file='{{$panel}}'}
|
||||
{{else}}
|
||||
|
||||
{{if !empty($label) && !is_int($label) && $label != 'DEFAULT' && !$useTabs}}
|
||||
<h4>{sugar_translate label='{{$label}}' module='{{$module}}'}</h4>
|
||||
{{/if}}
|
||||
{{* Print out the table data *}}
|
||||
<table id='detailpanel_{{$smarty.foreach.section.iteration}}' cellspacing='{$gridline}'>
|
||||
|
||||
|
||||
|
||||
{{foreach name=rowIteration from=$panel key=row item=rowData}}
|
||||
<tr>
|
||||
{{assign var='columnsInRow' value=$rowData|@count}}
|
||||
{{assign var='columnsUsed' value=0}}
|
||||
{{foreach name=colIteration from=$rowData key=col item=colData}}
|
||||
<td width='{{$def.templateMeta.widths[$smarty.foreach.colIteration.index].label}}%' scope="row">
|
||||
{{if isset($colData.field.customLabel)}}
|
||||
{{$colData.field.customLabel}}
|
||||
{{elseif isset($colData.field.label) && strpos($colData.field.label, '$')}}
|
||||
{capture name="label" assign="label"}
|
||||
{{$colData.field.label}}
|
||||
{/capture}
|
||||
{$label|strip_semicolon}:
|
||||
{{elseif isset($colData.field.label)}}
|
||||
{capture name="label" assign="label"}
|
||||
{sugar_translate label='{{$colData.field.label}}' module='{{$module}}'}
|
||||
{/capture}
|
||||
{$label|strip_semicolon}:
|
||||
{{elseif isset($fields[$colData.field.name])}}
|
||||
{capture name="label" assign="label"}
|
||||
{sugar_translate label='{{$fields[$colData.field.name].vname}}' module='{{$module}}'}
|
||||
{/capture}
|
||||
{$label|strip_semicolon}:
|
||||
{{else}}
|
||||
|
||||
{{/if}}
|
||||
</td>
|
||||
<td width='{{$def.templateMeta.widths[$smarty.foreach.colIteration.index].field}}%' {{if $colData.colspan}}colspan='{{$colData.colspan}}'{{/if}}>
|
||||
{{if $colData.field.customCode || $colData.field.assign}}
|
||||
{counter name="panelFieldCount"}
|
||||
{{sugar_evalcolumn var=$colData.field colData=$colData}}
|
||||
{{elseif $fields[$colData.field.name] && !empty($colData.field.fields) }}
|
||||
{{foreach from=$colData.field.fields item=subField}}
|
||||
{{if $fields[$subField]}}
|
||||
{counter name="panelFieldCount"}
|
||||
{{sugar_field parentFieldArray='fields' tabindex=$tabIndex vardef=$fields[$subField] displayType='DetailView'}}
|
||||
{{else}}
|
||||
{counter name="panelFieldCount"}
|
||||
{{$subField}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
{{elseif $fields[$colData.field.name]}}
|
||||
{counter name="panelFieldCount"}
|
||||
{{sugar_field parentFieldArray='fields' vardef=$fields[$colData.field.name] displayType='DetailView' displayParams=$colData.field.displayParams typeOverride=$colData.field.type}}
|
||||
{{/if}}
|
||||
</td>
|
||||
{{/foreach}}
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
</table>
|
||||
{{/if}}
|
||||
</div>
|
||||
{if $panelFieldCount == 0}
|
||||
|
||||
<script>document.getElementById("{{$label}}").style.display='none';</script>
|
||||
{/if}
|
||||
{{/foreach}}
|
||||
</div></div>
|
||||
{{include file=$footerTpl}}
|
||||
{{if $useTabs}}
|
||||
<script type="text/javascript" src="include/javascript/sugar_grp_yui_widgets.js"></script>
|
||||
<script type="text/javascript">
|
||||
var {{$module}}_detailview_tabs = new YAHOO.widget.TabView("{{$module}}_detailview_tabs");
|
||||
{{$module}}_detailview_tabs.selectTab(0);
|
||||
</script>
|
||||
{{/if}}
|
||||
103
include/DetailView/DetailView2.php
Executable file
103
include/DetailView/DetailView2.php
Executable file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero 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 Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero 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 Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero 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".
|
||||
********************************************************************************/
|
||||
require_once('include/TemplateHandler/TemplateHandler.php');
|
||||
require_once('include/EditView/EditView2.php');
|
||||
|
||||
class DetailView2 extends EditView
|
||||
{
|
||||
var $view = 'DetailView';
|
||||
|
||||
/**
|
||||
* DetailView constructor
|
||||
* This is the DetailView constructor responsible for processing the new
|
||||
* Meta-Data framework
|
||||
*
|
||||
* @param $module String value of module this detail view is for
|
||||
* @param $focus An empty sugarbean object of module
|
||||
* @param $id The record id to retrieve and populate data for
|
||||
* @param $metadataFile String value of file location to use in overriding default metadata file
|
||||
* @param tpl String value of file location to use in overriding default Smarty template
|
||||
*
|
||||
*/
|
||||
function setup(
|
||||
$module,
|
||||
$focus,
|
||||
$metadataFile = null,
|
||||
$tpl = 'include/DetailView/DetailView.tpl'
|
||||
)
|
||||
{
|
||||
$this->th = new TemplateHandler();
|
||||
$this->th->ss =& $this->ss;
|
||||
$this->focus = $focus;
|
||||
$this->tpl = $tpl;
|
||||
$this->module = $module;
|
||||
$this->metadataFile = $metadataFile;
|
||||
if(!empty($sugar_config['disable_vcr'])) {
|
||||
$this->showVCRControl = $sugar_config['disable_vcr'];
|
||||
}
|
||||
if(!empty($this->metadataFile) && file_exists($this->metadataFile)){
|
||||
require_once($this->metadataFile);
|
||||
}else {
|
||||
//If file doesn't exist we create a best guess
|
||||
if(!file_exists("modules/$this->module/metadata/detailviewdefs.php") &&
|
||||
file_exists("modules/$this->module/DetailView.html")) {
|
||||
global $dictionary;
|
||||
$htmlFile = "modules/" . $this->module . "/DetailView.html";
|
||||
$parser = new DetailViewMetaParser();
|
||||
if(!file_exists('modules/'.$this->module.'/metadata')) {
|
||||
sugar_mkdir('modules/'.$this->module.'/metadata');
|
||||
}
|
||||
$fp = sugar_fopen('modules/'.$this->module.'/metadata/detailviewdefs.php', 'w');
|
||||
fwrite($fp, $parser->parse($htmlFile, $dictionary[$focus->object_name]['fields'], $this->module));
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
//Flag an error... we couldn't create the best guess meta-data file
|
||||
if(!file_exists("modules/$this->module/metadata/detailviewdefs.php")) {
|
||||
global $app_strings;
|
||||
$error = str_replace("[file]", "modules/$this->module/metadata/detailviewdefs.php", $app_strings['ERR_CANNOT_CREATE_METADATA_FILE']);
|
||||
$GLOBALS['log']->fatal($error);
|
||||
echo $error;
|
||||
die();
|
||||
}
|
||||
require_once("modules/$this->module/metadata/detailviewdefs.php");
|
||||
}
|
||||
|
||||
$this->defs = $viewdefs[$this->module][$this->view];
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
37
include/DetailView/footer.tpl
Executable file
37
include/DetailView/footer.tpl
Executable file
@@ -0,0 +1,37 @@
|
||||
{*
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero 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 Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero 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 Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero 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".
|
||||
********************************************************************************/
|
||||
*}
|
||||
</form>
|
||||
114
include/DetailView/header.tpl
Executable file
114
include/DetailView/header.tpl
Executable file
@@ -0,0 +1,114 @@
|
||||
{*
|
||||
/*********************************************************************************
|
||||
* SugarCRM is a customer relationship management program developed by
|
||||
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Affero 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 Affero General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero 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 Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero 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".
|
||||
********************************************************************************/
|
||||
*}
|
||||
{{* Add the preForm code if it is defined (used for vcards) *}}
|
||||
{{if $preForm}}
|
||||
{{$preForm}}
|
||||
{{/if}}
|
||||
<table cellpadding="1" cellspacing="0" border="0" width="100%" class="actionsContainer">
|
||||
<tr>
|
||||
<td class="buttons" align="left" NOWRAP>
|
||||
<form action="index.php" method="post" name="DetailView" id="form">
|
||||
<input type="hidden" name="module" value="{$module}">
|
||||
<input type="hidden" name="record" value="{$fields.id.value}">
|
||||
<input type="hidden" name="return_action">
|
||||
<input type="hidden" name="return_module">
|
||||
<input type="hidden" name="return_id">
|
||||
<input type="hidden" name="module_tab">
|
||||
<input type="hidden" name="isDuplicate" value="false">
|
||||
<input type="hidden" name="offset" value="{$offset}">
|
||||
<input type="hidden" name="action" value="EditView">
|
||||
{{if isset($form.hidden)}}
|
||||
{{foreach from=$form.hidden item=field}}
|
||||
{{$field}}
|
||||
{{/foreach}}
|
||||
{{/if}}
|
||||
|
||||
{{if !isset($form.buttons)}}
|
||||
{{sugar_button module="$module" id="EDIT" view="$view"}}
|
||||
{{sugar_button module="$module" id="DUPLICATE" view="EditView"}}
|
||||
{{sugar_button module="$module" id="DELETE" view="$view"}}
|
||||
{{else}}
|
||||
{{counter assign="num_buttons" start=0 print=false}}
|
||||
{{foreach from=$form.buttons key=val item=button}}
|
||||
{{if !is_array($button) && in_array($button, $built_in_buttons)}}
|
||||
{{counter print=false}}
|
||||
{{sugar_button module="$module" id="$button" view="EditView"}}
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
{{if isset($closeFormBeforeCustomButtons)}}
|
||||
</form>
|
||||
</td>
|
||||
{{/if}}
|
||||
{{if count($form.buttons) > $num_buttons}}
|
||||
{{foreach from=$form.buttons key=val item=button}}
|
||||
{{if is_array($button) && $button.customCode}}
|
||||
<td class="buttons" align="left" NOWRAP>
|
||||
{{sugar_button module="$module" id="$button" view="EditView"}}
|
||||
</td>
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{if !isset($closeFormBeforeCustomButtons)}}
|
||||
</form>
|
||||
</td>
|
||||
{{/if}}
|
||||
{{if empty($form.hideAudit) || !$form.hideAudit}}
|
||||
<td class="buttons" align="left" NOWRAP>
|
||||
{{sugar_button module="$module" id="Audit" view="EditView"}}
|
||||
</td>
|
||||
{{/if}}
|
||||
<td align="right" width="100%">{$ADMIN_EDIT}
|
||||
{{if $panelCount == 0}}
|
||||
{{* Render tag for VCR control if SHOW_VCR_CONTROL is true *}}
|
||||
{{if $SHOW_VCR_CONTROL}}
|
||||
{$PAGINATION}
|
||||
{{/if}}
|
||||
{{counter name="panelCount" print=false}}
|
||||
{{/if}}
|
||||
</td>
|
||||
{{* Add $form.links if they are defined *}}
|
||||
{{if !empty($form) && isset($form.links)}}
|
||||
<td align="right" width="10%"> </td>
|
||||
<td align="right" width="100%" NOWRAP>
|
||||
{{foreach from=$form.links item=link}}
|
||||
{{$link}}
|
||||
{{/foreach}}
|
||||
</td>
|
||||
{{/if}}
|
||||
</tr>
|
||||
</table>
|
||||
Reference in New Issue
Block a user