Add php files

This commit is contained in:
2025-05-12 15:44:39 +00:00
parent c951760058
commit 82d5804ac4
9534 changed files with 2638137 additions and 0 deletions

1761
include/ListView/ListView.php Executable file

File diff suppressed because it is too large Load Diff

640
include/ListView/ListViewData.php Executable file
View File

@@ -0,0 +1,640 @@
<?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".
********************************************************************************/
require_once('include/EditView/SugarVCR.php');
class ListViewData {
var $additionalDetails = true;
var $listviewName = null;
var $additionalDetailsAllow = null;
var $additionalDetailsAjax = true; // leave this true when using filter fields
var $additionalDetailsFieldToAdd = 'NAME'; // where the span will be attached to
var $base_url = null;
/*
* If you want overwrite the query for the count of the listview set this to your query
* otherwise leave it empty and it will use SugarBean::create_list_count_query
*/
var $count_query = '';
/**
* Constructor sets the limitName to look up the limit in $sugar_config
*
* @return ListViewData
*/
function ListViewData() {
$this->limitName = 'list_max_entries_per_page';
$this->db = &DBManagerFactory::getInstance('listviews');
}
/**
* checks the request for the order by and if that is not set then it checks the session for it
*
* @return array containing the keys orderBy => field being ordered off of and sortOrder => the sort order of that field
*/
function getOrderBy($orderBy = '', $direction = '') {
if (!empty($orderBy) || !empty($_REQUEST[$this->var_order_by])) {
if(!empty($_REQUEST[$this->var_order_by])) {
$direction = 'ASC';
$orderBy = $_REQUEST[$this->var_order_by];
if(!empty($_REQUEST['lvso']) && (empty($_SESSION['lvd']['last_ob']) || strcmp($orderBy, $_SESSION['lvd']['last_ob']) == 0) ){
$direction = $_REQUEST['lvso'];
$trackerManager = TrackerManager::getInstance();
if($monitor = $trackerManager->getMonitor('tracker')){
$monitor->setValue('module_name', $GLOBALS['module']);
$monitor->setValue('item_summary', "lvso=".$direction."&".$this->var_order_by."=".$_REQUEST[$this->var_order_by]);
$monitor->setValue('action', 'listview');
$monitor->setValue('user_id', $GLOBALS['current_user']->id);
$monitor->setValue('date_modified', gmdate($GLOBALS['timedate']->get_db_date_time_format()));
$monitor->save();
}
}
}
$_SESSION[$this->var_order_by] = array('orderBy'=>$orderBy, 'direction'=> $direction);
}
else {
if(!empty($_SESSION[$this->var_order_by])) {
$orderBy = $_SESSION[$this->var_order_by]['orderBy'];
$direction = $_SESSION[$this->var_order_by]['direction'];
}
}
$_SESSION[$_REQUEST['module'].'_order'] = $orderBy;
$_SESSION[$_REQUEST['module'].'_direction']=$direction;
return array('orderBy' => $orderBy, 'sortOrder' => $direction);
}
/**
* gets the reverse of the sort order for use on links to reverse a sort order from what is currently used
*
* @param STRING (ASC or DESC) $current_order
* @return STRING (ASC or DESC)
*/
function getReverseSortOrder($current_order){
return (strcmp(strtolower($current_order), 'asc') == 0)?'DESC':'ASC';
}
/**
* gets the limit of how many rows to show per page
*
* @return INT (the limit)
*/
function getLimit() {
return $GLOBALS['sugar_config'][$this->limitName];
}
/**
* returns the current offset
*
* @return INT (current offset)
*/
function getOffset() {
return (!empty($_REQUEST[$this->var_offset])) ? $_REQUEST[$this->var_offset] : 0;
}
/**
* generates the base url without
* any files in the block variables will not be part of the url
*
*
* @return STRING (the base url)
*/
function getBaseURL() {
global $beanList;
if(empty($this->base_url)) {
$blockVariables = array('mass', 'uid', 'massupdate', 'delete', 'merge', 'selectCount',$this->var_order_by, $this->var_offset, 'lvso', 'sortOrder', 'orderBy', 'request_data', 'current_query_by_page');
$base_url = 'index.php?';
foreach($beanList as $bean) {
$blockVariables[] = 'Home2_'.strtoupper($bean).'_ORDER_BY';
}
$blockVariables[] = 'Home2_CASE_ORDER_BY';
$params = array();
if ( isset($_POST) && is_array($_POST) ) {
$params = array_merge($params,$_POST);
}
if ( isset($_GET) && is_array($_GET) ) {
$params = array_merge($params,$_GET);
}
foreach($params as $name=>$value) {
if(!in_array($name, $blockVariables)){
if(is_array($value)) {
foreach($value as $v) {
$base_url .= $name.urlencode('[]').'='.urlencode($v) . '&';
}
}
else {
$base_url .= $name.'='.urlencode($value) . '&';
}
}
}
$this->base_url = $base_url;
}
return $this->base_url;
}
/**
* based off of a base name it sets base, offset, and order by variable names to retrieve them from requests and sessions
*
* @param unknown_type $baseName
*/
function setVariableName($baseName, $where, $listviewName = null){
global $timedate;
$module = (!empty($listviewName)) ? $listviewName: $_REQUEST['module'];
$this->var_name = $module .'2_'. strtoupper($baseName);
$this->var_order_by = $this->var_name .'_ORDER_BY';
$this->var_offset = $this->var_name . '_offset';
$timestamp = $timedate->get_microtime_string();
$this->stamp = $timestamp;
$_SESSION[$module .'2_QUERY_QUERY'] = $where;
$_SESSION[strtoupper($baseName) . "_FROM_LIST_VIEW"] = $timestamp;
$_SESSION[strtoupper($baseName) . "_DETAIL_NAV_HISTORY"] = false;
}
function getTotalCount($main_query){
if(!empty($this->count_query)){
$count_query = $this->count_query;
}else{
$count_query = SugarBean::create_list_count_query($main_query);
}
$result = $this->db->query($count_query);
if($row = $this->db->fetchByAssoc($result)){
return $row['c'];
}
return 0;
}
/**
* takes in a seed and creates the list view query based off of that seed
* if the $limit value is set to -1 then it will use the default limit and offset values
*
* it will return an array with two key values
* 1. 'data'=> this is an array of row data
* 2. 'pageData'=> this is an array containg three values
* a.'ordering'=> array('orderBy'=> the field being ordered by , 'sortOrder'=> 'ASC' or 'DESC')
* b.'urls'=>array('baseURL'=>url used to generate other urls ,
* 'orderBy'=> the base url for order by
* //the following may not be set (so check empty to see if they are set)
* 'nextPage'=> the url for the next group of results,
* 'prevPage'=> the url for the prev group of results,
* 'startPage'=> the url for the start of the group,
* 'endPage'=> the url for the last set of results in the group
* c.'offsets'=>array(
* 'current'=>current offset
* 'next'=> next group offset
* 'prev'=> prev group offset
* 'end'=> the offset of the last group
* 'total'=> the total count (only accurate if totalCounted = true otherwise it is either the total count if less than the limit or the total count + 1 )
* 'totalCounted'=> if a count query was used to get the total count
*
* @param SugarBean $seed
* @param string $where
* @param int:0 $offset
* @param int:-1 $limit
* @param string[]:array() $filter_fields
* @param array:array() $params
* Potential $params are
$params['distinct'] = use distinct key word
$params['include_custom_fields'] = (on by default)
$params['custom_XXXX'] = append custom statements to query
* @param string:'id' $id_field
* @return array('data'=> row data 'pageData' => page data information
*/
function getListViewData($seed, $where, $offset=-1, $limit = -1, $filter_fields=array(),$params=array(),$id_field = 'id') {
//add mz 2014-09-25
global $current_user;
//sztuczka z nipem
if ($_REQUEST['module']=='Accounts') {
$new_where = array();
$wh = explode(" AND ", $where);
foreach ($wh as $w) {
if (preg_match('/to_vatid like/', $w)) {
$tmp2 = explode(" like ",$w);
$nip = $tmp2[1];
$nip = str_replace("%", "", $nip);
$nip = str_replace(" ", "", $nip);
$nip = str_replace("-", "", $nip);
$nip = str_replace(")", "", $nip);
$nip = str_replace("'", "", $nip);
$new_w = "REPLACE(REPLACE(accounts.to_vatid, ' ',''),'-','') like '$nip%'";
$new_where[] = $new_w;
} else
$new_where[] = $w;
}
$where = implode(" AND ", $new_where);
if(strpos($where,"(accounts.isHidden = '0' OR accounts.isHidden IS NULL)")!==false){
} else {
if(strpos($where,"( accounts.isHidden like '1%')")!==false){
} else {
if(strlen($where)>0){
$where.=" and (accounts.isHidden = '0' OR accounts.isHidden IS NULL)";
} else {
$where= " (accounts.isHidden = '0' OR accounts.isHidden IS NULL)";
}
}
}
}
//echo $where;
//end mz
//add mz 2014-08-19
$where=str_replace("\\","",$where);
$where = str_replace("like '", "like '%", $where);
//end mz
$where = str_replace("(ecmstockstates.empty = '0' OR ecmstockstates.empty IS NULL)", "", $where);
$where = str_replace("AND ( ecmstockstates.empty = '0' OR ecmstockstates.empty IS NULL)", "", $where);
global $current_user;
SugarVCR::erase($seed->module_dir);
$this->seed =& $seed;
$totalCounted = empty($GLOBALS['sugar_config']['disable_count_query']);
$_SESSION['MAILMERGE_MODULE_FROM_LISTVIEW'] = $seed->module_dir;
if(empty($_REQUEST['action']) || $_REQUEST['action'] != 'Popup'){
$_SESSION['MAILMERGE_MODULE'] = $seed->module_dir;
}
$this->setVariableName($seed->object_name, $where, $this->listviewName);
$this->seed->id = '[SELECT_ID_LIST]';
// if $params tell us to override all ordering
if(!empty($params['overrideOrder']) && !empty($params['orderBy'])) {
$order = $this->getOrderBy(strtolower($params['orderBy']), (empty($params['sortOrder']) ? '' : $params['sortOrder'])); // retreive from $_REQUEST
}
else {
$order = $this->getOrderBy(); // retreive from $_REQUEST
}
// else use stored preference
$userPreferenceOrder = $current_user->getPreference('listviewOrder', $this->var_name);
if(empty($order['orderBy']) && !empty($userPreferenceOrder)) {
$order = $userPreferenceOrder;
}
// still empty? try to use settings passed in $param
if(empty($order['orderBy']) && !empty($params['orderBy'])) {
$order['orderBy'] = $params['orderBy'];
$order['sortOrder'] = (empty($params['sortOrder']) ? '' : $params['sortOrder']);
}
//rrs - bug: 21788. Do not use Order by stmts with fields that are not in the query.
// Bug 22740 - Tweak this check to strip off the table name off the order by parameter.
// Samir Gandhi : Do not remove the report_cache.date_modified condition as the report list view is broken
$orderby = $order['orderBy'];
if (strpos($order['orderBy'],'.') && ($order['orderBy'] != "report_cache.date_modified"))
$orderby = substr($order['orderBy'],strpos($order['orderBy'],'.')+1);
if(!in_array($orderby, array_keys($filter_fields))){
$order['orderBy'] = '';
$order['sortOrder'] = '';
}
if(empty($order['orderBy'])) {
$orderBy= '';
}
else {
$orderBy = $order['orderBy'] . ' ' . $order['sortOrder'];
//wdong, Bug 25476, fix the sorting problem of Oracle.
if (isset($params['custom_order_by_override']['ori_code']) && $order['orderBy'] == $params['custom_order_by_override']['ori_code'])
$orderBy = $params['custom_order_by_override']['custom_code'] . ' ' . $order['sortOrder'];
}
// mz 2021-07-21 fix problem with documents order
$orderBy = str_replace('register_date', 'date_entered', $orderBy);
if(empty($params['skipOrderSave'])) // don't save preferences if told so
$current_user->setPreference('listviewOrder', $order, 0, $this->var_name); // save preference
$ret_array = $seed->create_new_list_query($orderBy, $where, $filter_fields, $params, 0, '', true, $seed, true);
$ret_array['inner_join'] = '';
if(!empty($this->seed->listview_inner_join)) {
$ret_array['inner_join'] = ' ' . implode(' ', $this->seed->listview_inner_join) . ' ';
}
if(!is_array($params)) $params = array();
if(!isset($params['custom_select'])) $params['custom_select'] = '';
if(!isset($params['custom_from'])) $params['custom_from'] = '';
if(!isset($params['custom_where'])) $params['custom_where'] = '';
if(!isset($params['custom_order_by'])) $params['custom_order_by'] = '';
$custom_group='';
if($_REQUEST['module']=='EcmProducts'){
if($_REQUEST['part_no_basic']!=''){
$params['custom_from']=' inner join ecmstockoperations oo on oo.product_id = ecmproducts.id';
$params['custom_where']= ' and oo.part_no like "%'.$_REQUEST['part_no_basic'].'%"';
$custom_group=' group by ecmproducts.id';
}
}
//var_dump($params);
$main_query = $ret_array['select'] . $params['custom_select'] . $ret_array['from'] . $params['custom_from'] . $ret_array['inner_join']. $ret_array['where'] . $params['custom_where'] .$custom_group. $ret_array['order_by'] . $params['custom_order_by'];
//C.L. - Fix for 23461
if(empty($_REQUEST['action']) || $_REQUEST['action'] != 'Popup') {
$_SESSION['export_where'] = $ret_array['where'];
}
if($limit < -1) {
$result = $this->db->query($main_query);
}
else {
if($limit == -1) {
$limit = $this->getLimit();
}
$dyn_offset = $this->getOffset();
if($dyn_offset > 0 || !is_int($dyn_offset))$offset = $dyn_offset;
if(strcmp($offset, 'end') == 0){
$totalCount = $this->getTotalCount($main_query);
$offset = (floor(($totalCount -1) / $limit)) * $limit;
}
if($this->seed->ACLAccess('ListView')) {
$result = $this->db->limitQuery($main_query, $offset, $limit + 1);
}
else {
$result = array();
}
}
$data = array();
$temp = clone $seed;
$rows = array();
$count = 0;
$idIndex = array();
$id_list = '';
while($row = $this->db->fetchByAssoc($result)) {
if($count < $limit) {
if(!empty($id_list)) {
$id_list = '(';
}else{
$id_list .= ',';
}
$id_list .= '\''.$row[$id_field].'\'';
//handles date formating and such
$idIndex[$row[$id_field]][] = count($rows);
$rows[] = $row;
}
$count++;
}
if (!empty($id_list)) $id_list .= ')';
SugarVCR::store($this->seed->module_dir, $main_query);
if($count != 0) {
//NOW HANDLE SECONDARY QUERIES
if(!empty($ret_array['secondary_select'])) {
$secondary_query = $ret_array['secondary_select'] . $ret_array['secondary_from'] . ' WHERE '.$this->seed->table_name.'.id IN ' .$id_list;
$secondary_result = $this->db->query($secondary_query);
while($row = $this->db->fetchByAssoc($secondary_result)) {
foreach($row as $name=>$value) {
//add it to every row with the given id
foreach($idIndex[$row['ref_id']] as $index){
$rows[$index][$name]=$value;
}
}
}
}
// retrieve parent names
if(!empty($filter_fields['parent_name']) && !empty($filter_fields['parent_id']) && !empty($filter_fields['parent_type'])) {
foreach($idIndex as $id => $rowIndex) {
if(!isset($post_retrieve[$rows[$rowIndex[0]]['parent_type']])) {
$post_retrieve[$rows[$rowIndex[0]]['parent_type']] = array();
}
if(!empty($rows[$rowIndex[0]]['parent_id'])) $post_retrieve[$rows[$rowIndex[0]]['parent_type']][] = array('child_id' => $id , 'parent_id'=> $rows[$rowIndex[0]]['parent_id'], 'parent_type' => $rows[$rowIndex[0]]['parent_type'], 'type' => 'parent');
}
if(isset($post_retrieve)) {
$parent_fields = $seed->retrieve_parent_fields($post_retrieve);
foreach($parent_fields as $child_id => $parent_data) {
//add it to every row with the given id
foreach($idIndex[$child_id] as $index){
$rows[$index]['parent_name']= $parent_data['parent_name'];
}
}
}
}
$pageData = array();
$additionalDetailsAllow = $this->additionalDetails && $this->seed->ACLAccess('DetailView') && (file_exists('modules/' . $this->seed->module_dir . '/metadata/additionalDetails.php') || file_exists('custom/modules/' . $this->seed->module_dir . '/metadata/additionalDetails.php'));
if($additionalDetailsAllow) $pageData['additionalDetails'] = array();
$additionalDetailsEdit = $this->seed->ACLAccess('EditView');
reset($rows);
while($row = current($rows)){
$temp = clone $seed;
$dataIndex = count($data);
$temp->setupCustomFields($temp->module_dir);
$temp->loadFromRow($row);
if($idIndex[$row[$id_field]][0] == $dataIndex){
$pageData['tag'][$dataIndex] = $temp->listviewACLHelper();
}else{
$pageData['tag'][$dataIndex] = $pageData['tag'][$idIndex[$row[$id_field]][0]];
}
$data[$dataIndex] = $temp->get_list_view_data($filter_fields);
if($additionalDetailsAllow) {
if($this->additionalDetailsAjax) {
$ar = $this->getAdditionalDetailsAjax($data[$dataIndex]['ID']);
}
else {
$additionalDetailsFile = 'modules/' . $this->seed->module_dir . '/metadata/additionalDetails.php';
if(file_exists('custom/modules/' . $this->seed->module_dir . '/metadata/additionalDetails.php')){
$additionalDetailsFile = 'custom/modules/' . $this->seed->module_dir . '/metadata/additionalDetails.php';
}
require_once($additionalDetailsFile);
$ar = $this->getAdditionalDetails($data[$dataIndex],
(empty($this->additionalDetailsFunction) ? 'additionalDetails' : $this->additionalDetailsFunction) . $this->seed->object_name,
$additionalDetailsEdit);
}
$pageData['additionalDetails'][$dataIndex] = $ar['string'];
$pageData['additionalDetails']['fieldToAddTo'] = $ar['fieldToAddTo'];
}
next($rows);
}
}
$nextOffset = -1;
$prevOffset = -1;
$endOffset = -1;
if($count > $limit) {
$nextOffset = $offset + $limit;
}
if($offset > 0) {
$prevOffset = $offset - $limit;
if($prevOffset < 0)$prevOffset = 0;
}
$totalCount = $count + $offset;
if( $count >= $limit && $totalCounted){
$totalCount = $this->getTotalCount($main_query);
}
SugarVCR::recordIDs($this->seed->module_dir, array_keys($idIndex), $offset, $totalCount);
$endOffset = (floor(($totalCount - 1) / $limit)) * $limit;
$pageData['ordering'] = $order;
$pageData['pages']['count']=ceil($totalCount/100);
$pageData['pages']['current']=ceil($nextOffset/100);
$pageData['ordering']['sortOrder'] = $this->getReverseSortOrder($pageData['ordering']['sortOrder']);
$pageData['urls'] = $this->generateURLS($pageData['ordering']['sortOrder'], $offset, $prevOffset, $nextOffset, $endOffset, $totalCounted);
$pageData['offsets'] = array( 'current'=>$offset, 'next'=>$nextOffset, 'prev'=>$prevOffset, 'end'=>$endOffset, 'total'=>$totalCount, 'totalCounted'=>$totalCounted);
$pageData['bean'] = array('objectName' => $seed->object_name, 'moduleDir' => $seed->module_dir);
$pageData['stamp'] = $this->stamp;
$pageData['access'] = array('view' => $this->seed->ACLAccess('DetailView'), 'edit' => $this->seed->ACLAccess('EditView'));
$pageData['idIndex'] = $idIndex;
if(!$this->seed->ACLAccess('ListView')) {
$pageData['error'] = 'ACL restricted access';
}
$_SESSION[$_REQUEST['module'].'_order']=$orderBy;
return array('data'=>$data , 'pageData'=>$pageData);
}
/**
* generates urls for use by the display layer
*
* @param int $sortOrder
* @param int $offset
* @param int $prevOffset
* @param int $nextOffset
* @param int $endOffset
* @param int $totalCounted
* @return array of urls orderBy and baseURL are always returned the others are only returned according to values passed in.
*/
function generateURLS($sortOrder, $offset, $prevOffset, $nextOffset, $endOffset, $totalCounted) {
$urls = array();
$urls['baseURL'] = $this->getBaseURL(). 'lvso=' . $sortOrder. '&';
$urls['orderBy'] = $urls['baseURL'] .$this->var_order_by.'=';
$dynamicUrl = '';
if($nextOffset > -1) {
$urls['nextPage'] = $urls['baseURL'] . $this->var_offset . '=' . $nextOffset . $dynamicUrl;
}
if($offset > 0) {
$urls['startPage'] = $urls['baseURL'] . $this->var_offset . '=0' . $dynamicUrl;
}
if($prevOffset > -1) {
$urls['prevPage'] = $urls['baseURL'] . $this->var_offset . '=' . $prevOffset . $dynamicUrl;
}
if($totalCounted) {
$urls['endPage'] = $urls['baseURL'] . $this->var_offset . '=' . $endOffset . $dynamicUrl;
}else{
$urls['endPage'] = $urls['baseURL'] . $this->var_offset . '=end' . $dynamicUrl;
}
return $urls;
}
/**
* generates the additional details span to be retrieved via ajax
*
* @param GUID id id of the record
* @return array string to attach to field
*/
function getAdditionalDetailsAjax($id)
{
global $app_strings;
$jscalendarImage = SugarThemeRegistry::current()->getImageURL('info_inline.gif');
$extra = "<span id='adspan_" . $id . "' onmouseout=\"return SUGAR.util.clearAdditionalDetailsCall()\" "
. "onmouseover=\"lvg_dtails('$id')\" "
. "onmouseout=\"return nd(1000);\" style='position: relative;'><img vertical-align='middle' class='info' border='0' src='$jscalendarImage'></span>";
// return array('fieldToAddTo' => $this->additionalDetailsFieldToAdd, 'string' => $extra);
}
/**
* generates the additional details values
*
* @param unknown_type $fields
* @param unknown_type $adFunction
* @param unknown_type $editAccess
* @return array string to attach to field
*/
function getAdditionalDetails($fields, $adFunction, $editAccess)
{
global $app_strings;
$results = $adFunction($fields);
$results['string'] = str_replace(array("&#039", "'"), '\&#039', $results['string']); // no xss!
if(trim($results['string']) == '') $results['string'] = $app_strings['LBL_NONE'];
$extra = "<span onmouseover=\"return overlib('" .
str_replace(array("\rn", "\r", "\n"), array('','','<br />'), $results['string'])
. "', CAPTION, '<div style=\'float:left\'>{$app_strings['LBL_ADDITIONAL_DETAILS']}</div><div style=\'float: right\'>";
if($editAccess) $extra .= (!empty($results['editLink']) ? "<a title=\'{$app_strings['LBL_EDIT_BUTTON']}\' href={$results['editLink']}><img border=0 src=".SugarThemeRegistry::current()->getImageURL('edit_inline.gif')."></a>" : '');
$extra .= (!empty($results['viewLink']) ? "<a title=\'{$app_strings['LBL_VIEW_BUTTON']}\' href={$results['viewLink']}><img style=\'margin-left: 2px;\' border=0 src=".SugarThemeRegistry::current()->getImageURL('view_inline.gif')."></a>" : '')
. "', DELAY, 200, STICKY, MOUSEOFF, 1000, WIDTH, "
. (empty($results['width']) ? '300' : $results['width'])
. ", CLOSETEXT, '<img border=0 style=\'margin-left:2px; margin-right: 2px;\' src='".SugarThemeRegistry::current()->getImageURL('close.gif')."'></div>', "
. "CLOSETITLE, '{$app_strings['LBL_ADDITIONAL_DETAILS_CLOSE_TITLE']}', CLOSECLICK, FGCLASS, 'olFgClass', "
. "CGCLASS, 'olCgClass', BGCLASS, 'olBgClass', TEXTFONTCLASS, 'olFontClass', CAPTIONFONTCLASS, 'olCapFontClass', CLOSEFONTCLASS, 'olCloseFontClass');\" "
. "onmouseout=\"return nd(1000);\"><img style='padding: 0px 5px 0px 2px' border='0' src='".SugarThemeRegistry::current()->getImageURL('info_inline.png')."' ></span>";
$results = $adFunction($fields);
$results['string'] = str_replace(array("&#039", "'"), '\&#039', $results['string']); // no xss!
if(trim($results['string']) == '') $results['string'] = $app_strings['LBL_NONE'];
$extra = "<span onmouseover=\"return overlib('" .
str_replace(array("\rn", "\r", "\n"), array('','','<br />'), $results['string'])
. "', CAPTION, '<div style=\'float:left\'>{$app_strings['LBL_ADDITIONAL_DETAILS']}</div><div style=\'float: right\'>";
if($editAccess) $extra .= (!empty($results['editLink']) ? "<a title=\'{$app_strings['LBL_EDIT_BUTTON']}\' href={$results['editLink']}><img border=0 src=".SugarThemeRegistry::current()->getImageURL('edit_inline.gif')."></a>" : '');
$extra .= (!empty($results['viewLink']) ? "<a title=\'{$app_strings['LBL_VIEW_BUTTON']}\' href={$results['viewLink']}><img style=\'margin-left: 2px;\' border=0 src=".SugarThemeRegistry::current()->getImageURL('view_inline.gif')."></a>" : '')
. "', DELAY, 200, STICKY, MOUSEOFF, 1000, WIDTH, "
. (empty($results['width']) ? '300' : $results['width'])
. ", CLOSETEXT, '<img border=0 style=\'margin-left:2px; margin-right: 2px;\' src=".SugarThemeRegistry::current()->getImageURL('close.gif')."></div>', "
. "CLOSETITLE, '{$app_strings['LBL_ADDITIONAL_DETAILS_CLOSE_TITLE']}', CLOSECLICK, FGCLASS, 'olFgClass', "
. "CGCLASS, 'olCgClass', BGCLASS, 'olBgClass', TEXTFONTCLASS, 'olFontClass', CAPTIONFONTCLASS, 'olCapFontClass', CLOSEFONTCLASS, 'olCloseFontClass');\" "
. "onmouseout=\"return nd(1000);\"><img style='padding: 0px 5px 0px 2px' border='0' src='".SugarThemeRegistry::current()->getImageURL('info_inline.png')."' ></span>";
return array('fieldToAddTo' => $results['fieldToAddTo'], 'string' => $extra);
}
}

View File

@@ -0,0 +1,797 @@
<?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".
* ****************************************************************************** */
require_once('include/ListView/ListViewData.php');
require_once('include/MassUpdate.php');
class ListViewDisplay
{
var $show_mass_update_form = false;
var $show_action_dropdown = true;
var $rowCount;
var $mass = null;
var $seed;
var $multi_select_popup;
var $lvd;
var $moduleString;
var $export = true;
var $multiSelect = true;
var $mailMerge = true;
var $should_process = true;
/*
* Used in view.popup.php. Sometimes there are fields on the search form that are not referenced in the listviewdefs. If this
* is the case, then the filterFields will be set and the related fields will not be referenced when calling create_new_list_query.
*/
var $mergeDisplayColumns = false;
public $actionsMenuExtraItems = array();
/**
* Constructor
* @return null
*/
function ListViewDisplay()
{
$this->lvd = new ListViewData();
$this->searchColumns = array();
}
function shouldProcess($moduleDir)
{
if (!empty($GLOBALS['sugar_config']['save_query']) && $GLOBALS['sugar_config']['save_query'] == 'populate_only') {
if (empty($GLOBALS['displayListView']) && (!empty($_REQUEST['clear_query']) || $_REQUEST['module'] == $moduleDir && ((empty($_REQUEST['query']) || $_REQUEST['query'] == 'MSI') && (empty($_SESSION['last_search_mod']) || $_SESSION['last_search_mod'] != $moduleDir)))) {
$_SESSION['last_search_mod'] = $_REQUEST['module'];
$this->should_process = false;
return false;
}
}
$this->should_process = true;
return true;
}
/**
* Setup the class
* @param seed SugarBean Seed SugarBean to use
* @param file File Template file to use
* @param string $where
* @param offset:0 int offset to start at
* @param int:-1 $limit
* @param string[]:array() $filter_fields
* @param array:array() $params
* Potential $params are
* $params['distinct'] = use distinct key word
* $params['include_custom_fields'] = (on by default)
* $params['massupdate'] = true by default;
* $params['handleMassupdate'] = true by default, have massupdate.php handle massupdates?
* @param string:'id' $id_field
*/
function setup($seed, $file, $where, $params = array(), $offset = 0, $limit = -1, $filter_fields = array(), $id_field = 'id')
{
$this->should_process = true;
if (isset ($seed->module_dir) && !$this->shouldProcess($seed->module_dir)) {
return false;
}
if (isset ($params ['export'])) {
$this->export = $params ['export'];
}
if (!empty ($params ['multiSelectPopup'])) {
$this->multi_select_popup = $params ['multiSelectPopup'];
}
if (!empty ($params ['massupdate']) && $params ['massupdate'] != false) {
$this->show_mass_update_form = true;
$this->mass = new MassUpdate ();
$this->mass->setSugarBean($seed);
if (!empty ($params ['handleMassupdate']) || !isset ($params ['handleMassupdate'])) {
$this->mass->handleMassUpdate();
}
}
$this->seed = $seed;
// create filter fields based off of display columns
if (empty ($filter_fields) || $this->mergeDisplayColumns) {
foreach ($this->displayColumns as $columnName => $def) {
$filter_fields [strtolower($columnName)] = true;
if (isset ($this->seed->field_defs [strtolower($columnName)] ['type']) && strtolower($this->seed->field_defs [strtolower($columnName)] ['type']) == 'currency' && isset ($this->seed->field_defs ['currency_id'])) {
$filter_fields ['currency_id'] = true;
}
if (!empty ($def ['related_fields'])) {
foreach ($def ['related_fields'] as $field) {
// id column is added by query construction function. This addition creates duplicates
// and causes issues in oracle. #10165
if ($field != 'id') {
$filter_fields [$field] = true;
}
}
}
if (!empty ($this->seed->field_defs [strtolower($columnName)] ['db_concat_fields'])) {
foreach ($this->seed->field_defs [strtolower($columnName)] ['db_concat_fields'] as $index => $field) {
if (!isset ($filter_fields [strtolower($field)]) || !$filter_fields [strtolower($field)]) {
$filter_fields [strtolower($field)] = true;
}
}
}
}
foreach ($this->searchColumns as $columnName => $def) {
$filter_fields [strtolower($columnName)] = true;
}
}
$filter_fields['canceled'] = true;
$data = $this->lvd->getListViewData($seed, $where, $offset, $limit, $filter_fields, $params, $id_field);
// add mz 2015-03-18
//var_dump($filter_fields);
// add summary row to list view
//echo '<pre>';
//var_dump($_REQUEST);
//echo '</pre>';
$sum = array();
$db = $GLOBALS ['db'];
$showSumRow = false;
$list_pdf_settings = array();
$list_pdf_settings['module'] = $_REQUEST['module'];
$list_pdf_settings['table'] = $this->seed->table_name;
$list_pdf_settings['where'] = base64_encode($where);
$list_pdf_settings['order'] = $_SESSION['lvd']['last_ob'];
$list_pdf_settings['direction'] = $_SESSION['lvd']['direction'];
$list_pdf_settings['fields'] = array();
//filter fields
if ($_REQUEST['searchFormTab'] == "basic_search")
$formType = 'basic';
else
$formType = 'advanced';
if ($_REQUEST['register_date_' . $formType . '_from'] != "")
$list_pdf_settings['date_from'] = $_REQUEST['register_date_' . $formType . '_from'];
if ($_REQUEST['register_date_' . $formType . '_to'] != "")
$list_pdf_settings['date_to'] = $_REQUEST['register_date_' . $formType . '_to'];
if ($_REQUEST['ecmproductstockindex_id_' . $formType])
$list_pdf_settings['ecmproductstockindex_id'] = $_REQUEST['ecmproductstockindex_id_' . $formType];
if (is_array($_REQUEST['stock_in_id_' . $formType])) {
$list_pdf_settings['stocks_in'] = array();
foreach ($_REQUEST['stock_in_id_' . $formType] as $k => $v)
$list_pdf_settings['stocks_in'][] = $v;
}
if (is_array($_REQUEST['stock_out_id_' . $formType])) {
$list_pdf_settings['stocks_out'] = array();
foreach ($_REQUEST['stock_out_id_' . $formType] as $k => $v)
$list_pdf_settings['stocks_out'][] = $v;
}
if (is_array($_REQUEST['stock_id_' . $formType])) {
$list_pdf_settings['stocks'] = array();
foreach ($_REQUEST['stock_id_' . $formType] as $k => $v)
$list_pdf_settings['stocks'][] = $v;
}
foreach ($this->displayColumns as $name => $val) {
$tmp = array();
$tmp['name'] = strtolower($name);
$tmp['label'] = $this->displayColumns[$name]['label'];
if ($this->displayColumns [$name] ['sumType'] == 'sum') {
$innerJoin = "";
$aditiona_where = "";
$wal_query = "select * from currency_nbp_archive order by date desc limit 3";
$ik = $db->query($wal_query);
$wal = [];
while ($walutki = $db->fetchByAssoc($ik)) {
$wal[$walutki['currency_id']] = $walutki['value'];
}
if ($_REQUEST['module'] != 'EcmSales') {
$sum_q = "SELECT SUM(" . strtolower($name) . ") as sum FROM " . $this->seed->table_name;
$aditiona_where = " AND canceled ='0'";
} else {
$sum_q = "SELECT
SUM(IF(ecmsales.currency_id = '6336d9a0-ee5f-52e3-7d0c-4e6f1472b2bf',
total_netto * " . $wal['6336d9a0-ee5f-52e3-7d0c-4e6f1472b2bf'] . ",
IF(ecmsales.currency_id = '98b2b752-b0be-37c2-d2eb-511e29f81cab',
total_netto * " . $wal['98b2b752-b0be-37c2-d2eb-511e29f81cab'] . ",
IF(ecmsales.currency_id = '3c8d317e-513b-9a9b-d0e6-511e2abee625',
total_netto * " . $wal['3c8d317e-513b-9a9b-d0e6-511e2abee625'] . ",
total_netto)))) AS sum
FROM
ecmsales";
}
if ($where && $where != " ") {
$sum_q .= $innerJoin . " WHERE deleted='0' AND " . $where . ' ' . $aditiona_where;
} else {
$sum_q .= $innerJoin . " WHERE deleted='0' " . $aditiona_where;
}
$back = $db->fetchByAssoc($db->query($sum_q));
$sum [$name] = $back['sum'];
$showSumRow = true;
$tmp['summary'] = $back['sum'];
$list_pdf_settings['showSum'] = '1';
} else if ($this->displayColumns [$name] ['sumType'] == 'avg') {
$sum_q = "SELECT AVG(" . strtolower($name) . ") as avg FROM " . $this->seed->table_name;
if ($where && $where != " ")
$sum_q .= " WHERE canceled='0' AND " . $where;
$back = $db->fetchByAssoc($db->query($sum_q));
$sum [$name] = $back['avg'];
$showSumRow = true;
$tmp['summary'] = $back['avg'];
$list_pdf_settings['showSum'] = '1';
} else if ($this->displayColumns [$name] ['sumType'] == 'func') {
$func = $this->displayColumns [$name] ['sumFunc'];
if (method_exists($seed->object_name, $func) == false)
echo '<b>ListView Summary Error: Method ' . $seed->object_name . ':' . $func . ' not exist.<br>';
else {
$sum[$name] = call_user_func(array($seed->object_name, $func), $where);
$tmp['summary'] = $sum[$name];
$list_pdf_settings['showSum'] = '1';
}
}
$list_pdf_settings['fields'][] = $tmp;
unset($tmp);
}
$_SESSION['ee'] = base64_encode(json_encode($list_pdf_settings));
if ($showSumRow == true) {
$sum['showSumRow'] = true;
$data ['data'] [] = $sum;
}
foreach ($this->displayColumns as $columnName => $def) {
$seedName = strtolower($columnName);
if (!empty ($this->lvd->seed->field_defs [$seedName])) {
$seedDef = $this->lvd->seed->field_defs [$seedName];
}
if (empty ($this->displayColumns [$columnName] ['type'])) {
if (!empty ($seedDef ['type'])) {
$this->displayColumns [$columnName] ['type'] = (!empty ($seedDef ['custom_type'])) ? $seedDef ['custom_type'] : $seedDef ['type'];
} else {
$this->displayColumns [$columnName] ['type'] = '';
}
} // fi empty(...)
if (!empty ($seedDef ['options'])) {
$this->displayColumns [$columnName] ['options'] = $seedDef ['options'];
}
// C.L. Fix for 11177
if ($this->displayColumns [$columnName] ['type'] == 'html') {
$cField = $this->seed->custom_fields;
if (isset ($cField) && isset ($cField->bean->$seedName)) {
$seedName2 = strtoupper($columnName);
$htmlDisplay = html_entity_decode($cField->bean->$seedName);
$count = 0;
while ($count < count($data ['data'])) {
$data ['data'] [$count] [$seedName2] = &$htmlDisplay;
$count++;
}
}
} // fi == 'html'
if (!empty ($seedDef ['sort_on'])) {
$this->displayColumns [$columnName] ['orderBy'] = $seedDef ['sort_on'];
}
if (isset ($seedDef)) {
// Merge the two arrays together, making sure the seedDef doesn't override anything explicitly set in the displayColumns array.
$this->displayColumns [$columnName] = $this->displayColumns [$columnName] + $seedDef;
}
// C.L. Bug 38388 - ensure that ['id'] is set for related fields
if (!isset ($this->displayColumns [$columnName] ['id']) && isset ($this->displayColumns [$columnName] ['id_name'])) {
$this->displayColumns [$columnName] ['id'] = strtoupper($this->displayColumns [$columnName] ['id_name']);
}
}
$this->process($file, $data, $seed->object_name);
return true;
}
/**
* Any additional processing
* @param file File template file to use
* @param data array row data
* @param html_var string html string to be passed back and forth
*/
function process($file, $data, $htmlVar)
{
$this->rowCount = count($data['data']);
$this->moduleString = $data['pageData']['bean']['moduleDir'] . '2_' . strtoupper($htmlVar) . '_offset';
}
/**
* Display the listview
* @return string ListView contents
*/
function display()
{
if (!$this->should_process)
return '';
$str = '';
if ($this->multiSelect == true && $this->show_mass_update_form)
$str = $this->mass->getDisplayMassUpdateForm(true, $this->multi_select_popup) . $this->mass->getMassUpdateFormHeader($this->multi_select_popup);
return $str;
}
/**
* Display the select link
* @param echo Bool set true if you want it echo'd, set false to have contents returned
* @return string select link html
*/
function buildSelectLink($id = 'select_link', $total = 0, $pageTotal = 0)
{
global $app_strings;
if ($pageTotal < 0)
$pageTotal = $total;
$script = "<script>
function select_overlib() {
return overlib('<a style=\'width: 150px\' class=\'menuItem\' onmouseover=\'hiliteItem(this,\"yes\");\' onmouseout=\'unhiliteItem(this);\' onclick=\'if (document.MassUpdate.select_entire_list.value==1){document.MassUpdate.select_entire_list.value=0;sListView.check_all(document.MassUpdate, \"mass[]\", true, $pageTotal)}else {sListView.check_all(document.MassUpdate, \"mass[]\", true)};\' href=\'#\'>{$app_strings['LBL_LISTVIEW_OPTION_CURRENT']}&nbsp;({$pageTotal})</a>"
. "<a style=\'width: 150px\' class=\'menuItem\' onmouseover=\'hiliteItem(this,\"yes\");\' onmouseout=\'unhiliteItem(this);\' onclick=\'sListView.check_entire_list(document.MassUpdate, \"mass[]\",true,{$total});\' href=\'#\'>{$app_strings['LBL_LISTVIEW_OPTION_ENTIRE']}&nbsp;({$total})</a>"
. "<a style=\'width: 150px\' class=\'menuItem\' onmouseover=\'hiliteItem(this,\"yes\");\' onmouseout=\'unhiliteItem(this);\' onclick=\'sListView.clear_all(document.MassUpdate, \"mass[]\", false);\' href=\'#\'>{$app_strings['LBL_LISTVIEW_NONE']}</a>"
. "', CENTER, '"
. "', STICKY, MOUSEOFF, 3000, CLOSETEXT, '<img border=0 src=" . SugarThemeRegistry::current()->getImageURL('close_inline.gif')
. ">', WIDTH, 150, CLOSETITLE, '" . $app_strings['LBL_ADDITIONAL_DETAILS_CLOSE_TITLE'] . "', CLOSECLICK, FGCLASS, 'olOptionsFgClass', "
. "CGCLASS, 'olOptionsCgClass', BGCLASS, 'olBgClass', TEXTFONTCLASS, 'olFontClass', CAPTIONFONTCLASS, 'olOptionsCapFontClass', CLOSEFONTCLASS, 'olOptionsCloseFontClass',TIMEOUT,1000);
}
</script>";
$script .= "<a id='$id' onclick='return select_overlib();' href=\"#\"><img src='" . SugarThemeRegistry::current()->getImageURL('MoreDetail.png') . "' border='0''>" . "</a>";
return $script;
}
/**
* Display the actions link
*
* @param string $id link id attribute, defaults to 'actions_link'
* @return string HTML source
*/
protected function buildActionsLink($id = 'actions_link')
{
global $app_strings;
$closeText = "<img border=0 src=" . SugarThemeRegistry::current()->getImageURL('close_inline.gif') . " />";
$moreDetailImage = SugarThemeRegistry::current()->getImageURL('MoreDetail.png');
$menuItems = '';
/* // delete
if ( ACLController::checkAccess($this->seed->module_dir,'delete',true) && $this->delete )
$menuItems .= $this->buildDeleteLink();
// compose email
if ( isset($_REQUEST['module']) && $_REQUEST['module'] != 'Users' && $_REQUEST['module'] != 'Employees' &&
( SugarModule::get($_REQUEST['module'])->moduleImplements('Company')
|| SugarModule::get($_REQUEST['module'])->moduleImplements('Person') ) )
$menuItems .= $this->buildComposeEmailLink($this->data['pageData']['offsets']['total']);
// mass update
$mass = new MassUpdate();
$mass->setSugarBean($this->seed);
if ( ACLController::checkAccess($this->seed->module_dir,'edit',true) && $this->showMassupdateFields && $mass->doMassUpdateFieldsExistForFocus() )
$menuItems .= $this->buildMassUpdateLink();
// merge
if ( $this->mailMerge )
$menuItems .= $this->buildMergeLink();
if ( $this->mergeduplicates )
$menuItems .= $this->buildMergeDuplicatesLink();
// add to target list
if ( isset($_REQUEST['module']) && in_array($_REQUEST['module'],array('Contacts','Prospects','Leads','Accounts')))
$menuItems .= $this->buildTargetList();
// favorites ( for reports )
if ( isset($_REQUEST['module'])
&& ($_REQUEST['module'] == 'Reports')
&& (isset($_REQUEST['favorite']) && $_REQUEST['favorite'] == 1) )
$menuItems .= $this->buildRemoveFavoritesLink();
elseif ( isset($_REQUEST['module']) && ($_REQUEST['module'] == 'Reports') )
$menuItems .= $this->buildFavoritesLink();
// export
if ( ACLController::checkAccess($this->seed->module_dir,'export',true) && $this->export )
$menuItems .= $this->buildExportLink(); */
// mh
if ($_REQUEST['module'] == 'EcmServices') {
// Close
$this->actionsMenuExtraItems[] = '<a href="#" class="menuItem" style="width: 150px;" onmouseover=\'hiliteItem(this, "yes");\' onmouseout="unhiliteItem(this);" onclick="sugarListView.get_checks(); if(sugarListView.get_checks_count() < 1) { alert(\'' . $app_strings['LBL_LISTVIEW_NO_SELECTED'] . '\'); return false; } document.MassUpdate.action.value=\'close\'; document.MassUpdate.submit();"/>' . $GLOBALS['mod_strings']['LBL_LISTVIEW_SERVICE_CLOSE'] . '</a>';
// FK
$this->actionsMenuExtraItems[] = '<a href="#" class="menuItem" style="width: 150px;" onmouseover=\'hiliteItem(this, "yes");\' onmouseout="unhiliteItem(this);" onclick="sugarListView.get_checks(); if(sugarListView.get_checks_count() < 1) { alert(\'' . $app_strings['LBL_LISTVIEW_NO_SELECTED'] . '\'); return false; } if(sugarListView.get_checks_count() > 1) { alert(\'' . $app_strings['LBL_LISTVIEW_GT_1'] . '\'); return false; } document.MassUpdate.action.value=\'invoice\'; document.MassUpdate.submit();"/>' . $GLOBALS['mod_strings']['LBL_LISTVIEW_SERVICE_INVOICE'] . '</a>';
// RW
$this->actionsMenuExtraItems[] = '<a href="#" class="menuItem" style="width: 150px;" onmouseover=\'hiliteItem(this, "yes");\' onmouseout="unhiliteItem(this);" onclick="sugarListView.get_checks(); if(sugarListView.get_checks_count() < 1) { alert(\'' . $app_strings['LBL_LISTVIEW_NO_SELECTED'] . '\'); return false; } if(sugarListView.get_checks_count() > 1) { alert(\'' . $app_strings['LBL_LISTVIEW_GT_1'] . '\'); return false; } document.MassUpdate.action.value=\'rw\'; document.MassUpdate.submit();"/>' . $GLOBALS['mod_strings']['LBL_LISTVIEW_SERVICE_RW'] . '</a>';
}
global $current_user;
//add mz 2012-04-02
//add component in InsideOrders
if ($_REQUEST['module'] == 'EcmInsideOrders')
$this->actionsMenuExtraItems[] = '<a href="#" class="menuItem" style="width: 150px;" onmouseover=\'hiliteItem(this,"yes");\' onmouseout="unhiliteItem(this);" onclick="sugarListView.get_checks();if(sugarListView.get_checks_count() < 1) {alert(\'' . $app_strings['LBL_LISTVIEW_NO_SELECTED'] . '\');return false;}if(sugarListView.get_checks_count() > 1) {alert(\'' . $app_strings['LBL_LISTVIEW_TO_MANY_SELECTED'] . '\');return false;}document.MassUpdate.action.value=\'displaypassedids\';document.MassUpdate.submit();"/>' . $GLOBALS['mod_strings']['LBL_LISTVIEW_IMPORT_COMPONENTS'] . '</a>';
if ($_REQUEST['module'] == 'Documents') {
$this->actionsMenuExtraItems[] = '<a href="#" class="menuItem" style="width: 150px;" onmouseover=\'hiliteItem(this,"yes");\' onmouseout="unhiliteItem(this);" onclick="sugarListView.get_checks();if(sugarListView.get_checks_count() < 1) {alert(\'' . $app_strings['LBL_LISTVIEW_NO_SELECTED'] . '\');return false;}document.MassUpdate.action.value=\'changeStatus\';document.MassUpdate.return_module.value=\'0\';document.MassUpdate.submit();"/>Zmień status na: do zapłaty</a>';
$this->actionsMenuExtraItems[] = '<a href="#" class="menuItem" style="width: 150px;" onmouseover=\'hiliteItem(this,"yes");\' onmouseout="unhiliteItem(this);" onclick="sugarListView.get_checks();if(sugarListView.get_checks_count() < 1) {alert(\'' . $app_strings['LBL_LISTVIEW_NO_SELECTED'] . '\');return false;}document.MassUpdate.action.value=\'changeStatus\';document.MassUpdate.return_module.value=\'1\';document.MassUpdate.submit();"/>Zmień status na: przekazano do autoryzacji</a>';
$this->actionsMenuExtraItems[] = '<a href="#" class="menuItem" style="width: 150px;" onmouseover=\'hiliteItem(this,"yes");\' onmouseout="unhiliteItem(this);" onclick="sugarListView.get_checks();if(sugarListView.get_checks_count() < 1) {alert(\'' . $app_strings['LBL_LISTVIEW_NO_SELECTED'] . '\');return false;}document.MassUpdate.action.value=\'changeStatus\';document.MassUpdate.return_module.value=\'2\';document.MassUpdate.submit();"/>Zmień status na: zapłacono</a>';
$this->actionsMenuExtraItems[] = '<a href="#" class="menuItem" style="width: 150px;" onmouseover=\'hiliteItem(this,"yes");\' onmouseout="unhiliteItem(this);" onclick="sugarListView.get_checks();if(sugarListView.get_checks_count() < 1) {alert(\'' . $app_strings['LBL_LISTVIEW_NO_SELECTED'] . '\');return false;}document.MassUpdate.action.value=\'changeStatus\';document.MassUpdate.return_module.value=\'3\';document.MassUpdate.submit();"/>Zmień status na: kompensata</a>';
if ($current_user->id != '6826e9ec-9e04-4f3b-76fc-4ce320b4e459' || $current_user->id != 'd8d28f31-6f5c-cd1c-f196-4ce31f2cb55e') {
$this->actionsMenuExtraItems[] = '<a href="#" class="menuItem" style="width: 150px;" onmouseover=\'hiliteItem(this,"yes");\' onmouseout="unhiliteItem(this);" onclick="sugarListView.get_checks();if(sugarListView.get_checks_count() < 1) {alert(\'' . $app_strings['LBL_LISTVIEW_NO_SELECTED'] . '\');return false;}document.MassUpdate.action.value=\'changeStatus\';document.MassUpdate.return_module.value=\'_empty_\';document.MassUpdate.submit();"/>Zmień status na: Inne</a>';
}
}
//create PZ from selected PurchaseOrders in action menu
if ($_REQUEST['module'] == 'EcmPurchaseOrders')
$this->actionsMenuExtraItems[] = '<a href="#" class="menuItem" style="width: 150px;" onmouseover=\'hiliteItem(this,"yes");\' onmouseout="unhiliteItem(this);" onclick="sugarListView.get_checks();if(sugarListView.get_checks_count() < 1) {alert(\'' . $app_strings['LBL_LISTVIEW_NO_SELECTED'] . '\');return false;}document.MassUpdate.action.value=\'displaypassedids\';document.MassUpdate.submit();"/>Wystaw fakturę</a>';
//create Invoice from selected WZ Documents in action menu
if ($_REQUEST['module'] == 'EcmStockDocOuts')
$this->actionsMenuExtraItems[] = '<a href="#" class="menuItem" style="width: 150px;" onmouseover=\'hiliteItem(this,"yes");\' onmouseout="unhiliteItem(this);" onclick="sugarListView.get_checks();if(sugarListView.get_checks_count() < 1) {alert(\'' . $app_strings['LBL_LISTVIEW_NO_SELECTED'] . '\');return false;}document.MassUpdate.action.value=\'displaypassedids\';document.MassUpdate.submit();"/>' . $GLOBALS['mod_strings']['LBL_LISTVIEW_CREATE_INVOICE'] . '</a>';
if ($_REQUEST['module'] == 'Accounts') {
$this->actionsMenuExtraItems[] = '<a href="#" class="menuItem" style="width: 150px;" onmouseover=\'hiliteItem(this,"yes");\' onmouseout="unhiliteItem(this);" onclick="sugarListView.get_checks();if(sugarListView.get_checks_count() < 1) {alert(\'' . $app_strings['LBL_LISTVIEW_NO_SELECTED'] . '\');return false;}document.MassUpdate.action.value=\'showMap\';document.MassUpdate.submit();"/> Pokaż na mapie </a>';
$this->actionsMenuExtraItems[] = '<a href="#" class="menuItem" style="width: 150px;" onmouseover=\'hiliteItem(this,"yes");\' onmouseout="unhiliteItem(this);" onclick="sugarListView.get_checks();if(sugarListView.get_checks_count() < 1) {alert(\'' . $app_strings['LBL_LISTVIEW_NO_SELECTED'] . '\');return false;}document.MassUpdate.action.value=\'SendEmail\';document.MassUpdate.submit();"/> Wyślij email </a>';
$this->actionsMenuExtraItems[] = '<a href="#" class="menuItem" style="width: 150px;" onmouseover=\'hiliteItem(this,"yes");\' onmouseout="unhiliteItem(this);" onclick="sugarListView.get_checks();if(sugarListView.get_checks_count() < 1) {alert(\'' . $app_strings['LBL_LISTVIEW_NO_SELECTED'] . '\');return false;}document.MassUpdate.action.value=\'share\';document.MassUpdate.submit();"/> Udostępnij </a>';
}
if ($_REQUEST['module'] == 'EcmProducts') {
$this->actionsMenuExtraItems[] = '<a href="#" class="menuItem" style="width: 150px;" onmouseover=\'hiliteItem(this,"yes");\' onmouseout="unhiliteItem(this);" onclick="sugarListView.get_checks();if(sugarListView.get_checks_count() < 1) {alert(\'' . $app_strings['LBL_LISTVIEW_NO_SELECTED'] . '\');return false;}document.MassUpdate.action.value=\'share\';document.MassUpdate.submit();"/> Udostępnij </a>';
}
if ($_REQUEST['module'] == 'EcmSales') {
$this->actionsMenuExtraItems[] = '<a href="#" class="menuItem" style="width: 150px;" onmouseover=\'hiliteItem(this,"yes");\' onmouseout="unhiliteItem(this);" onclick="sugarListView.get_checks();if(sugarListView.get_checks_count() < 1) {alert(\'' . $app_strings['LBL_LISTVIEW_NO_SELECTED'] . '\');return false;}document.MassUpdate.action.value=\'wzCreator\';document.MassUpdate.setAttribute(\'target\',\'_blank\');document.MassUpdate.submit();"/> Wystaw dokument WZ </a>';
$this->actionsMenuExtraItems[] = '<a href="#" class="menuItem" style="width: 150px;" onmouseover=\'hiliteItem(this,"yes");\' onmouseout="unhiliteItem(this);" onclick="sugarListView.get_checks();if(sugarListView.get_checks_count() < 1) {alert(\'' . $app_strings['LBL_LISTVIEW_NO_SELECTED'] . '\');return false;}document.MassUpdate.action.value=\'ComponentsList\';document.MassUpdate.removeAttribute(\'target\');document.MassUpdate.submit();"/> Lista komponentów </a>';
// $this->actionsMenuExtraItems[] = '<a href="#" class="menuItem" style="width: 150px;" onmouseover=\'hiliteItem(this,"yes");\' onmouseout="unhiliteItem(this);" onclick="sugarListView.get_checks();if(sugarListView.get_checks_count() < 1) {alert(\'' . $app_strings['LBL_LISTVIEW_NO_SELECTED'] . '\');return false;}var r = confirm(\'Czy napewno chcesz zmienić status zaznaczonych dokumentów?\');if (r == true) {document.MassUpdate.action.value=\'change_status\';document.MassUpdate.submit();}"/>Zmień status</a>';
}
if ($_REQUEST['module'] == 'EcmInvoiceOuts') {
$this->actionsMenuExtraItems[] = '<a href="#" class="menuItem" style="width: 150px;" onmouseover=\'hiliteItem(this,"yes");\' onmouseout="unhiliteItem(this);" onclick="sugarListView.get_checks();if(sugarListView.get_checks_count() < 1) {alert(\'' . $app_strings['LBL_LISTVIEW_NO_SELECTED'] . '\');return false;}document.MassUpdate.action.value=\'generuj\';document.MassUpdate.submit();"/> Generuj zbiorczy PDF </a>';
}
if ($_REQUEST['module'] == 'EcmSales') {
$this->actionsMenuExtraItems[] = '<a target="new" href="#" class="menuItem" style="width: 150px;" onmouseover=\'hiliteItem(this,"yes");\' onmouseout="unhiliteItem(this);" onclick="sugarListView.get_checks();if(sugarListView.get_checks_count() < 1) {alert(\'' . $app_strings['LBL_LISTVIEW_NO_SELECTED'] . '\');return false;}document.MassUpdate.action.value=\'massAction_PDF\';document.MassUpdate.submit();"/> Generuj zbiorczy PDF </a>';
}
if ($_REQUEST['module'] == 'EcmStockDocOuts') {
$this->actionsMenuExtraItems[] = '<a href="#" class="menuItem" style="width: 150px;" onmouseover=\'hiliteItem(this,"yes");\' onmouseout="unhiliteItem(this);" onclick="sugarListView.get_checks();if(sugarListView.get_checks_count() < 1) {alert(\'' . $app_strings['LBL_LISTVIEW_NO_SELECTED'] . '\');return false;}if(checkIsTheSameContractor()) {alert(\'Proszę o wybranie tego samego kontrahenta lub dokumentów bez wystawionej faktury.\');return false;} else { gotoInvoice(); return false;}document.MassUpdate.action.value=\'createInvoice\';document.MassUpdate.submit();"/> Wystaw fakturę zbiorczą </a>';
}
//end mz
foreach ($this->actionsMenuExtraItems as $item)
$menuItems .= $item;
$menuItems = str_replace('"', '\"', $menuItems);
if (empty($menuItems))
return '';
return <<<EOHTML
<script type="text/javascript">
<!--
function actions_overlib()
{
if($('#overDiv').css('visibility')=='visible'){
$('#overDiv').css('visibility','hidden');
} else {
return overlib("{$menuItems}", CENTER, '', STICKY, MOUSEOFF, 3000, CLOSETEXT, "{$closeText}", WIDTH, 150,
CLOSETITLE, "{$app_strings['LBL_ADDITIONAL_DETAILS_CLOSE_TITLE']}", CLOSECLICK,
FGCLASS, 'olOptionsFgClass', CGCLASS, 'olOptionsCgClass', BGCLASS, 'olBgClass',
TEXTFONTCLASS, 'olFontClass', CAPTIONFONTCLASS, 'olOptionsCapFontClass',
CLOSEFONTCLASS, 'olOptionsCloseFontClass');
}
}
-->
</script>
<a id='$id' onclick='return actions_overlib();' href="#">
{$app_strings['LBL_LINK_ACTIONS']}&nbsp;<img src='{$moreDetailImage}' border='0' />
</a>
EOHTML;
}
/**
* Builds the export link
*
* @return string HTML
*/
protected function buildExportLink()
{
global $app_strings;
return "<a href='#' style='width: 150px' class='menuItem' onmouseover='hiliteItem(this,\"yes\");' onmouseout='unhiliteItem(this);' onclick=\"return sListView.send_form(true, '{$_REQUEST['module']}', 'index.php?entryPoint=export','{$app_strings['LBL_LISTVIEW_NO_SELECTED']}')\">{$app_strings['LBL_EXPORT']}</a>";
}
/**
* Builds the massupdate link
*
* @return string HTML
*/
protected function buildMassUpdateLink()
{
global $app_strings;
return "<a href='#massupdate_form' style='width: 150px' class='menuItem' onmouseover='hiliteItem(this,\"yes\");' onmouseout='unhiliteItem(this);' onclick=\"document.getElementById('massupdate_form').style.display = '';\">{$app_strings['LBL_MASS_UPDATE']}</a>";
}
/**
* Builds the compose email link
*
* @return string HTML
*/
protected function buildComposeEmailLink(
$totalCount
)
{
global $app_strings, $dictionary;
if (!is_array($this->seed->field_defs)) {
return '';
}
$foundEmailField = false;
// Search for fields that look like an email address
foreach ($this->seed->field_defs as $field) {
if (isset($field['type']) && $field['type'] == 'link'
&& isset($field['relationship']) && isset($dictionary[$this->seed->object_name]['relationships'][$field['relationship']])
&& $dictionary[$this->seed->object_name]['relationships'][$field['relationship']]['rhs_module'] == 'EmailAddresses') {
$foundEmailField = true;
break;
}
}
if (!$foundEmailField) {
return '';
}
$userPref = $GLOBALS['current_user']->getPreference('email_link_type');
$defaultPref = $GLOBALS['sugar_config']['email_default_client'];
if ($userPref != '')
$client = $userPref;
else
$client = $defaultPref;
if ($client == 'sugar')
$script = "<a href='#' style='width: 150px' class='menuItem' onmouseover='hiliteItem(this,\"yes\");' onmouseout='unhiliteItem(this);' " .
'onclick="return sListView.send_form_for_emails(true, \'' . "Emails" . '\', \'index.php?module=Emails&action=Compose&ListView=true\',\'' . $app_strings['LBL_LISTVIEW_NO_SELECTED'] . '\', \'' . $_REQUEST['module'] . '\', \'' . $totalCount . '\', \'' . $app_strings['LBL_LISTVIEW_LESS_THAN_TEN_SELECT'] . '\')">' .
$app_strings['LBL_EMAIL_COMPOSE'] . '</a>';
else
$script = "<a href='#' style='width: 150px' class='menuItem' onmouseover='hiliteItem(this,\"yes\");' onmouseout='unhiliteItem(this);' " .
'onclick="return sListView.use_external_mail_client(\'' . $app_strings['LBL_LISTVIEW_NO_SELECTED'] . '\');">' .
$app_strings['LBL_EMAIL_COMPOSE'] . '</a>';
return $script;
}
// fn
/**
* Builds the favorites link ( for reports )
*
* @return string HTML
*/
protected function buildFavoritesLink()
{
global $app_strings;
return "<a href='#' style='width: 150px' class='menuItem' onmouseover='hiliteItem(this,\"yes\");' onmouseout='unhiliteItem(this);' name='Mark as Favorites' onclick='document.MassUpdate.massupdate.value = false; document.MassUpdate.action.value = document.MassUpdate.return_action.value; document.MassUpdate.addtofavorites.value = true; document.MassUpdate.submit();'>{$app_strings['LBL_MARK_AS_FAVORITES']}</a>";
}
/**
* Builds the remote favorites link ( for reports )
*
* @return string HTML
*/
protected function buildRemoveFavoritesLink()
{
global $app_strings;
return "<a href='#' style='width: 150px' class='menuItem' onmouseover='hiliteItem(this,\"yes\");' onmouseout='unhiliteItem(this);' name='Add to Favorites' onclick='document.MassUpdate.massupdate.value = false; document.MassUpdate.action.value = document.MassUpdate.return_action.value; document.MassUpdate.removefromfavorites.value = true; document.MassUpdate.submit();'>{$app_strings['LBL_REMOVE_FROM_FAVORITES']}</a>";
}
/**
* Builds the delete link
*
* @return string HTML
*/
protected function buildDeleteLink()
{
global $app_strings;
return "<a href='#' style='width: 150px' class='menuItem' onmouseover='hiliteItem(this,\"yes\");' onmouseout='unhiliteItem(this);' onclick=\"return sListView.send_mass_update('selected', '{$app_strings['LBL_LISTVIEW_NO_SELECTED']}', 1)\">{$app_strings['LBL_DELETE_BUTTON_LABEL']}</a>";
}
/**
* Display the selected object span object
*
* @return string select object span
*/
function buildSelectedObjectsSpan($echo = true, $total = 0)
{
global $app_strings;
$selectedObjectSpan = "{$app_strings['LBL_LISTVIEW_SELECTED_OBJECTS']}<input style='border: 0px; background: transparent; font-size: inherit; color: inherit' type='text' id='selectCountTop' readonly name='selectCount[]' value='{$total}' />";
return $selectedObjectSpan;
}
/**
* Builds the mail merge link
* The link can be disabled by setting module level duplicate_merge property to false
* in the moudle's vardef file.
*
* @return string HTML
*/
protected function buildMergeDuplicatesLink()
{
global $app_strings, $dictionary;
$return_string = '';
$return_string .= isset($_REQUEST['module']) ? "&return_module={$_REQUEST['module']}" : "";
$return_string .= isset($_REQUEST['action']) ? "&return_action={$_REQUEST['action']}" : "";
$return_string .= isset($_REQUEST['record']) ? "&return_id={$_REQUEST['record']}" : "";
//need delete and edit access.
if (!(ACLController::checkAccess($_REQUEST['module'], 'edit', true)) or !(ACLController::checkAccess($_REQUEST['module'], 'delete', true))) {
return '';
}
if (isset($dictionary[$this->seed->object_name]['duplicate_merge']) && $dictionary[$this->seed->object_name]['duplicate_merge'] == true) {
return "<a href='#' style='width: 150px' class='menuItem' onmouseover='hiliteItem(this,\"yes\");' onmouseout='unhiliteItem(this);' " .
"onclick='if (sugarListView.get_checks_count()> 1) {sListView.send_form(true, \"MergeRecords\", \"index.php\", \"{$app_strings['LBL_LISTVIEW_NO_SELECTED']}\", \"{$this->seed->module_dir}\",\"$return_string\");} else {alert(\"{$app_strings['LBL_LISTVIEW_TWO_REQUIRED']}\");return false;}'>" .
$app_strings['LBL_MERGE_DUPLICATES'] . '</a>';
}
return '';
}
/**
* Builds the mail merge link
*
* @return string HTML
*/
protected function buildMergeLink()
{
require_once('modules/MailMerge/modules_array.php');
global $current_user, $app_strings;
$admin = new Administration();
$admin->retrieveSettings('system');
$user_merge = $current_user->getPreference('mailmerge_on');
$module_dir = (!empty($this->seed->module_dir) ? $this->seed->module_dir : '');
$str = '';
if ($user_merge == 'on' && isset($admin->settings['system_mailmerge_on']) && $admin->settings['system_mailmerge_on'] && !empty($modules_array[$module_dir])) {
$str = "<a href='#' style='width: 150px' class='menuItem' onmouseover='hiliteItem(this,\"yes\");' onmouseout='unhiliteItem(this);' " .
'onclick="if (document.MassUpdate.select_entire_list.value==1){document.location.href=\'index.php?action=index&module=MailMerge&entire=true\'} else {return sListView.send_form(true, \'MailMerge\',\'index.php\',\'' . $app_strings['LBL_LISTVIEW_NO_SELECTED'] . '\');}">' .
$app_strings['LBL_MAILMERGE'] . '</a>';
}
return $str;
}
/**
* Builds the add to target list link
*
* @return string HTML
*/
protected function buildTargetList()
{
global $app_strings;
$js = <<<EOF
if(sugarListView.get_checks_count() < 1) {
alert('{$app_strings['LBL_LISTVIEW_NO_SELECTED']}');
return false;
}
if ( document.forms['targetlist_form'] ) {
var form = document.forms['targetlist_form'];
form.reset;
} else
var form = document.createElement ( 'form' ) ;
form.setAttribute ( 'name' , 'targetlist_form' );
form.setAttribute ( 'method' , 'post' ) ;
form.setAttribute ( 'action' , 'index.php' );
document.body.appendChild ( form ) ;
if ( !form.module ) {
var input = document.createElement('input');
input.setAttribute ( 'name' , 'module' );
input.setAttribute ( 'value' , '{$_REQUEST['module']}' );
input.setAttribute ( 'type' , 'hidden' );
form.appendChild ( input ) ;
var input = document.createElement('input');
input.setAttribute ( 'name' , 'action' );
input.setAttribute ( 'value' , 'TargetListUpdate' );
input.setAttribute ( 'type' , 'hidden' );
form.appendChild ( input ) ;
}
if ( !form.uids ) {
var input = document.createElement('input');
input.setAttribute ( 'name' , 'uids' );
input.setAttribute ( 'type' , 'hidden' );
form.appendChild ( input ) ;
}
if ( !form.prospect_list ) {
var input = document.createElement('input');
input.setAttribute ( 'name' , 'prospect_list' );
input.setAttribute ( 'type' , 'hidden' );
form.appendChild ( input ) ;
}
if ( !form.return_module ) {
var input = document.createElement('input');
input.setAttribute ( 'name' , 'return_module' );
input.setAttribute ( 'type' , 'hidden' );
form.appendChild ( input ) ;
}
if ( !form.return_action ) {
var input = document.createElement('input');
input.setAttribute ( 'name' , 'return_action' );
input.setAttribute ( 'type' , 'hidden' );
form.appendChild ( input ) ;
}
open_popup('ProspectLists','600','400','',true,false,{ 'call_back_function':'set_return_and_save_targetlist','form_name':'targetlist_form','field_to_name_array':{'id':'prospect_list'} } );
EOF;
$js = str_replace(array("\r", "\n"), '', $js);
return "<a href='#' style='width: 150px' class='menuItem' onmouseover='hiliteItem(this,\"yes\");' onmouseout='unhiliteItem(this);' onclick=\"$js\">{$app_strings['LBL_ADD_TO_PROSPECT_LIST_BUTTON_LABEL']}</a>";
}
/**
* Display the bottom of the ListView (ie MassUpdate
* @return string contents
*/
function displayEnd()
{
$str = '';
if ($this->show_mass_update_form) {
$str .= $this->mass->getMassUpdateForm(true);
$str .= $this->mass->endMassUpdateForm();
}
return $str;
}
/**
* Display the multi select data box etc.
* @return string contents
*/
function getMultiSelectData()
{
$str = "<script>YAHOO.util.Event.addListener(window, \"load\", sListView.check_boxes);</script>\n";
$massUpdateRun = isset($_REQUEST['massupdate']) && $_REQUEST['massupdate'] == 'true';
$uids = empty($_REQUEST['uid']) || $massUpdateRun ? '' : $_REQUEST['uid'];
$select_entire_list = isset($_REQUEST['select_entire_list']) && !$massUpdateRun ? $_REQUEST['select_entire_list'] : 0;
$str .= "<textarea style='display: none' name='uid'>{$uids}</textarea>\n" .
"<input type='hidden' name='select_entire_list' value='{$select_entire_list}'>\n" .
"<input type='hidden' name='{$this->moduleString}' value='0'>\n";
return $str;
}
}

View File

@@ -0,0 +1,176 @@
<?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".
********************************************************************************/
/*
* Created on Sep 10, 2007
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
require_once('include/ListView/ListViewSmarty.php');
/**
* A Facade to ListView and ListViewSmarty
*/
class ListViewFacade{
var $focus = null;
var $module = '';
var $type = 0;
var $lv;
//ListView fields
var $template;
var $title;
var $where = '';
var $params = array();
var $offset = 0;
var $limit = -1;
var $filter_fields = array();
var $id_field = 'id';
var $prefix = '';
var $mod_strings = array();
/**
* Constructor
* @param $focus - the bean
* @param $module - the module name
* @param - 0 = decide for me, 1 = ListView.html, 2 = ListViewSmarty
*/
function ListViewFacade($focus, $module, $type = 0){
$this->focus = $focus;
$this->module = $module;
$this->type = $type;
$this->build();
}
function build(){
//we will assume that if the ListView.html file exists we will want to use that one
if(file_exists('modules/'.$this->module.'/ListView.html')){
$this->type = 1;
$this->lv = new ListView();
$this->template = 'modules/'.$this->module.'/ListView.html';
}else{
$metadataFile = null;
$foundViewDefs = false;
if(file_exists('custom/modules/' . $this->module. '/metadata/listviewdefs.php')){
$metadataFile = 'custom/modules/' . $this->module . '/metadata/listviewdefs.php';
$foundViewDefs = true;
}else{
if(file_exists('custom/modules/'. $this->module.'/metadata/metafiles.php')){
require_once('custom/modules/'. $this->module.'/metadata/metafiles.php');
if(!empty($metafiles[ $this->module]['listviewdefs'])){
$metadataFile = $metafiles[ $this->module]['listviewdefs'];
$foundViewDefs = true;
}
}elseif(file_exists('modules/'. $this->module.'/metadata/metafiles.php')){
require_once('modules/'. $this->module.'/metadata/metafiles.php');
if(!empty($metafiles[ $this->module]['listviewdefs'])){
$metadataFile = $metafiles[ $this->module]['listviewdefs'];
$foundViewDefs = true;
}
}
}
if(!$foundViewDefs && file_exists('modules/'. $this->module.'/metadata/listviewdefs.php')){
$metadataFile = 'modules/'. $this->module.'/metadata/listviewdefs.php';
}
require_once($metadataFile);
$this->lv = new ListViewSmarty();
$displayColumns = array();
if(!empty($_REQUEST['displayColumns'])) {
foreach(explode('|', $_REQUEST['displayColumns']) as $num => $col) {
if(!empty($listViewDefs[$this->module][$col]))
$displayColumns[$col] = $listViewDefs[$this->module][$col];
}
}
else {
foreach($listViewDefs[$this->module] as $col => $params) {
if(!empty($params['default']) && $params['default'])
$displayColumns[$col] = $params;
}
}
$this->lv->displayColumns = $displayColumns;
$this->type = 2;
$this->template = 'include/ListView/ListViewGeneric.tpl';
}
}
function setup($template = '', $where = '', $params = array(), $mod_strings = array(), $offset = 0, $limit = -1, $orderBy = '', $prefix = '', $filter_fields = array(), $id_field = 'id'){
if(!empty($template))
$this->template = $template;
$this->mod_strings = $mod_strings;
if($this->type == 1){
$this->lv->initNewXTemplate($this->template,$this->mod_strings);
$this->prefix = $prefix;
$this->lv->setQuery($where, $limit, $orderBy, $prefix);
$this->lv->show_select_menu = false;
$this->lv->show_export_button = false;
$this->lv->show_delete_button = false;
$this->lv->show_mass_update = false;
$this->lv->show_mass_update_form = false;
}else{
$this->lv->export = false;
$this->lv->delete = false;
$this->lv->select = false;
$this->lv->mailMerge = false;
$this->lv->multiSelect = false;
$this->lv->setup($this->focus, $this->template, $where, $params, $offset, $limit, $filter_fields, $id_field);
}
}
function display($title = '', $section = 'main'){
if($this->type == 1){
$this->lv->setHeaderTitle($title);
$this->lv->processListView($this->focus, $section, $this->prefix);
}else{
echo get_form_header($title, '', false);
echo $this->lv->display();
}
}
function setTitle($title = ''){
$this->title = $title;
}
}
?>

View File

@@ -0,0 +1,351 @@
<?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".
********************************************************************************/
require_once('include/ListView/ListViewDisplay.php');
include_once("modules/EcmStockOperations/EcmStockOperation.php");
require_once('include/contextMenus/contextMenu.php');
class ListViewSmarty extends ListViewDisplay{
var $data;
var $ss; // the smarty object
var $displayColumns;
var $searchColumns; // set by view.list.php
var $tpl;
var $moduleString;
var $export = true;
var $delete = true;
var $select = true;
var $mailMerge = true;
var $multiSelect = true;
var $overlib = true;
var $quickViewLinks = true;
var $lvd;
var $mergeduplicates = true;
var $contextMenus = true;
var $showMassupdateFields = true;
/**
* Constructor, Smarty object immediately available after
*
*/
function ListViewSmarty() {
parent::ListViewDisplay();
$this->ss = new Sugar_Smarty();
}
/**
* Processes the request. Calls ListViewData process. Also assigns all lang strings, export links,
* This is called from ListViewDisplay
*
* @param file file Template file to use
* @param data array from ListViewData
* @param html_var string the corresponding html var in xtpl per row
*
*/
function process($file, $data, $htmlVar) {
if(!$this->should_process)return;
global $odd_bg, $even_bg, $hilite_bg, $click_bg, $app_strings;
parent::process($file, $data, $htmlVar);
$this->tpl = $file;
$this->data = $data;
$totalWidth = 0;
foreach($this->displayColumns as $name => $params) {
$totalWidth += $params['width'];
}
$adjustment = $totalWidth / 100;
$contextMenuObjectsTypes = array();
foreach($this->displayColumns as $name => $params) {
$this->displayColumns[$name]['width'] = floor($this->displayColumns[$name]['width'] / $adjustment);
// figure out which contextMenu objectsTypes are required
if(!empty($params['contextMenu']['objectType']))
$contextMenuObjectsTypes[$params['contextMenu']['objectType']] = true;
}
$this->ss->assign('displayColumns', $this->displayColumns);
$this->ss->assign('APP',$app_strings);
$this->ss->assign('bgHilite', $hilite_bg);
$this->ss->assign('colCount', count($this->displayColumns) + 2);
$this->ss->assign('htmlVar', strtoupper($htmlVar));
$this->ss->assign('moduleString', $this->moduleString);
$this->ss->assign('editLinkString', $app_strings['LBL_EDIT_BUTTON']);
$this->ss->assign('viewLinkString', $app_strings['LBL_VIEW_BUTTON']);
$this->ss->assign('allLinkString',$app_strings['LBL_LINK_ALL']);
$this->ss->assign('noneLinkString',$app_strings['LBL_LINK_NONE']);
$this->ss->assign('recordsLinkString',$app_strings['LBL_LINK_RECORDS']);
$this->ss->assign('selectLinkString',$app_strings['LBL_LINK_SELECT']);
if($this->overlib) $this->ss->assign('overlib', true);
if($this->select)$this->ss->assign('selectLink', $this->buildSelectLink('select_link', $this->data['pageData']['offsets']['total'], $this->data['pageData']['offsets']['next']-$this->data['pageData']['offsets']['current']));
if($this->show_action_dropdown)
{
$this->ss->assign('actionsLink', $this->buildActionsLink());
}
$this->ss->assign('quickViewLinks', $this->quickViewLinks);
// handle save checks and stuff
if($this->multiSelect) {
//if($this->data['pageData']['bean']['moduleDir']== 'KBDocuments')
//{
// $this->ss->assign('selectedObjectsSpan', $this->buildSelectedObjectsSpan(true, $this->data['pageData']['offsets']['current']));
//} else {
$this->ss->assign('selectedObjectsSpan', $this->buildSelectedObjectsSpan(true, $this->data['pageData']['offsets']['total']));
//}
$this->ss->assign('multiSelectData', $this->getMultiSelectData());
}
// include button for Adding to Target List if in one of four applicable modules
if ( isset ( $_REQUEST['module']) && in_array ( $_REQUEST['module'] , array ( 'Contacts','Prospects','Leads','Accounts' )))
$this->ss->assign( 'targetLink', $this->buildTargetList() ) ;
$this->processArrows($data['pageData']['ordering']);
$this->ss->assign('prerow', $this->multiSelect);
$this->ss->assign('clearAll', $app_strings['LBL_CLEARALL']);
$this->ss->assign('rowColor', array('oddListRow', 'evenListRow'));
$this->ss->assign('bgColor', array($odd_bg, $even_bg));
$this->ss->assign('contextMenus', $this->contextMenus);
$this->ss->assign('is_admin_for_user', is_admin_for_module($GLOBALS['current_user'],'Users'));
$this->ss->assign('is_admin', is_admin($GLOBALS['current_user']));
if($this->contextMenus && !empty($contextMenuObjectsTypes)) {
$script = '';
$cm = new contextMenu();
foreach($contextMenuObjectsTypes as $type => $value) {
$cm->loadFromFile($type);
$script .= $cm->getScript();
$cm->menuItems = array(); // clear menuItems out
}
$this->ss->assign('contextMenuScript', $script);
}
}
/**
* Assigns the sort arrows in the tpl
*
* @param ordering array data that contains the ordering info
*
*/
function processArrows($ordering)
{
$pathParts = pathinfo(SugarThemeRegistry::current()->getImageURL('arrow.gif',false));
list($width,$height) = getimagesize($pathParts['dirname'].'/'.$pathParts['basename']);
$this->ss->assign('arrowExt', $pathParts['extension']);
$this->ss->assign('arrowWidth', $width);
$this->ss->assign('arrowHeight', $height);
$this->ss->assign('arrowAlt', translate('LBL_SORT'));
}
/**
* Displays the xtpl, either echo or returning the contents
*
* @param end bool display the ending of the listview data (ie MassUpdate)
*
*/
function display($end = true) {
if(!$this->should_process) return $GLOBALS['app_strings']['LBL_SEARCH_POPULATE_ONLY'];
global $app_strings,$current_user;
$this->ss->assign('data', $this->data['data']);
$this->data['pageData']['offsets']['lastOffsetOnPage'] = $this->data['pageData']['offsets']['current'] + count($this->data['data']);
$this->ss->assign('pageData', $this->data['pageData']);
$navStrings = array('next' => $app_strings['LNK_LIST_NEXT'],
'previous' => $app_strings['LNK_LIST_PREVIOUS'],
'end' => $app_strings['LNK_LIST_END'],
'start' => $app_strings['LNK_LIST_START'],
'of' => $app_strings['LBL_LIST_OF']);
$this->ss->assign('navStrings', $navStrings);
$str = parent::display();
$strend = $this->displayEnd();
$sum_mag=0;
/*
if($_REQUEST['query'] && $_REQUEST['module']=="EcmProducts"){
$wh=array();
if($_REQUEST['searchFormTab']=="basic_search"){
if($_REQUEST['name_basic'])$wh[]="name like '".$_REQUEST['name_basic']."%'";
if($_REQUEST['code_basic'])$wh[]="code like '%".$_REQUEST['code_basic']."%'";
if($_REQUEST['manufacturer_id_basic'])$wh[]="manufacturer_id like '%".$_REQUEST['manufacturer_id_basic']."%'";
if($_REQUEST['manufacturer_name_basic'])$wh[]="manufacturer_name like '%".$_REQUEST['manufacturer_name_basic']."%'";
if($_REQUEST['product_category_id_basic'])$wh[]="product_category_id like '%".$_REQUEST['product_category_id_basic']."%'";
if($_REQUEST['product_category_name_basic']){$wh[]="product_category_name like '%".$_REQUEST['product_category_name_basic']."%'";
$bd=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("SELECT id FROM crm.ecmproductcategories WHERE name like '".$_REQUEST['product_category_name_advanced']."'"));
}
if($_REQUEST['purchase_price_basic'])$wh[]="purchase_price='".$_REQUEST['purchase_price_basic']."'";
if($_REQUEST['production_basic']==1)$wh[]="production='1'";
if($_REQUEST['end_of_line_basic']==1)$wh[]="end_of_line='1'";
if($_REQUEST['production_basic']==0 && $_REQUEST['production_basic']!="")$wh[]="production='0'";
if($_REQUEST['end_of_line_basic']==0 && $_REQUEST['end_of_line_basic']!="")$wh[]="end_of_line='0'";
}else{
if($_REQUEST['name_advanced'])$wh[]="name like '".$_REQUEST['name_advanced']."%'";
if($_REQUEST['code_advanced'])$wh[]="code like '%".$_REQUEST['code_advanced']."%'";
if($_REQUEST['manufacturer_id_advanced'])$wh[]="manufacturer_id like '%".$_REQUEST['manufacturer_id_advanced']."%'";
if($_REQUEST['manufacturer_name_advanced'])$wh[]="manufacturer_name like '%".$_REQUEST['manufacturer_name_advanced']."%'";
if($_REQUEST['product_category_id_advanced'])$wh[]="product_category_id like '%".$_REQUEST['product_category_id_advanced']."%'";
if($_REQUEST['product_category_name_advanced']){$wh[]="product_category_name like '%".$_REQUEST['product_category_name_advanced']."%'";
$bd=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("SELECT id FROM crm.ecmproductcategories WHERE name like '".$_REQUEST['product_category_name_advanced']."'"));
}
if(($_REQUEST['product_active_advanced']==0 || $_REQUEST['product_active_advanced']==1) && $_REQUEST['product_active_advanced']!="")$wh[]="product_active like '%".$_REQUEST['product_active_advanced']."%'";
if($_REQUEST['commission_rate_advanced'])$wh[]="commission_rate like '%".$_REQUEST['commission_rate_advanced']."%'";
if($_REQUEST['qty_per_unit_advanced'])$wh[]="qty_per_unit like '%".$_REQUEST['qty_per_unit_advanced']."%'";
if($_REQUEST['sales_start_date_advanced'])$wh[]="sales_start_date>='".$_REQUEST['sales_start_date_advanced']."'";
if($_REQUEST['sales_start_date_2_advanced'])$wh[]="sales_start_date<='".$_REQUEST['sales_start_date_2_advanced']."'";
if($_REQUEST['sales_end_date_advanced'])$wh[]="sales_end_date>='".$_REQUEST['sales_end_date_advanced']."'";
if($_REQUEST['sales_end_date_2_advanced'])$wh[]="sales_end_date<='".$_REQUEST['sales_end_date_2_advanced']."'";
if($_REQUEST['production_advanced']==1)$wh[]="production='1'";
if($_REQUEST['end_of_line_advanced']==1)$wh[]="end_of_line='1'";
if($_REQUEST['production_advanced']==0 && $_REQUEST['production_advanced']!="")$wh[]="production='0'";
if($_REQUEST['end_of_line_advanced']==0 && $_REQUEST['end_of_line_advanced']!="")$wh[]="end_of_line='0'";
}
$where=implode(" and ",$wh);
$_SESSION['EcmProductsForXLSwhere']=$where;
$_SESSION['EcmProductsForXLSorder_by']=$_REQUEST['orderBy'];
$_SESSION['EcmProductsForXLSsorder']=$_REQUEST['sorder'];
}
//wylaczone
if($_REQUEST['module']=="EcmProducts"){
$op=new EcmStockOperation();
// $createxls='<input class="button" value="Stwórz XLS" onclick="document.forms[\'MassUpdate\'].action.value=\'CreateXLS\';document.forms[\'MassUpdate\'].to_pdf.value=\'1\';" type="submit">';
if($where)$where1="and ".$where;
else $where1="";
global $current_user;
$z1="select id from ecmproducts where 1=1 ".$where1." and deleted='0'";
$lol=$GLOBALS['db']->query($z1);
$ids = array();
$ac=0;
while($rs2=$GLOBALS['db']->fetchByAssoc($lol)){
$ids[] = $rs2['id'];
$ac++;
}
$acc="select avg(pieces_per_carton) as ppc from ecmproducts where 1=1 ".$where1;
$rs=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query($acc));
if($_REQUEST['name_advanced'] || $_REQUEST['name_basic']){
$row_mz = $GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("SELECT sum(quantity) as sum FROM ecmstockstates as ss INNER JOIN ecmproducts as p ON ss.product_id = p.id WHERE p.id IN ('".implode("','", $ids)."')"));
}else{
$row_mz = $GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("SELECT sum(quantity) as sum FROM ecmstockstates as ss INNER JOIN ecmproducts as p ON ss.product_id = p.id ".$where1));
//echo $row_mz ['sum'];
}
if($_REQUEST['product_category_name_advanced'] || $_REQUEST['product_category_name_basis']){
$x="select sum(pp.product_quantity) as l from ecmproducts_ecmpurchaseorders as pp inner join ecmpurchaseorders as p on p.id=pp.ecmpurchaseorder_id where p.status='accepted' and pp.ecmproduct_id IN ('".implode("','", $ids)."')";
} else {
$x="select sum(pp.product_quantity) as l from ecmproducts_ecmpurchaseorders as pp inner join ecmpurchaseorders as p on p.id=pp.ecmpurchaseorder_id where p.status='accepted'".$where1;
}
//echo $ac;
//echo $rs['id'];
//ilosc
//end mz
$wss=$GLOBALS['db']->query("select p0,p3 from ecmproducts where 1=1 ".$where1);
while($rss=$GLOBALS['db']->fetchByAssoc($wss)){
//$arrr=$op->getStockArray($this->id);
if($rss['p0']>0){
$p0+=$rss['p0'];
$i0++;
}
if($rss['p3']>0){
$p3+=$rss['p3'];
$i3++;
}
}
//print_r($ids);
if($_REQUEST['searchFormTab']=="basic_search" || $_REQUEST['searchFormTab']=="advanced_search" ){
$x="select sum(pp.product_quantity) as l from ecmproducts_ecmpurchaseorders as pp inner join ecmpurchaseorders as p on p.id=pp.ecmpurchaseorder_id where p.status='accepted' and pp.ecmproduct_id IN ('".implode("','", $ids)."')";
$ros=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query($x));
} else {
$x="select sum(pp.product_quantity) as l from ecmproducts_ecmpurchaseorders as pp inner join ecmpurchaseorders as p on p.id=pp.ecmpurchaseorder_id where p.status='accepted'".$where1;
$ros=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query($x));
}
//print_r($ros);
$summary='<td style="padding:4px;font-weight:bold;">Razem</td><td style="padding:4px;font-weight:bold;"></td><td style="padding:4px;font-weight:bold;"></td><td style="padding:4px;font-weight:bold;"></td><td style="padding:4px;font-weight:bold;">'.number_format($row_mz['sum'],2,',','').'</td><td style="padding:4px;font-weight:bold;">'.number_format($ros['l'],0,'','').'</td><td style="padding:4px;font-weight:bold;">'.number_format($rs['ppc'],0,'','').'</td><td style="padding:4px;font-weight:bold;"></td>';
$this->ss->assign('summary', $summary);
}
*/
//return $str . $this->ss->fetch($this->tpl) . (($end) ? $strend : '');
if($_REQUEST['module']=='EcmStockStates'){
$createxls ='<input title="PDF" class="button" onclick="if($(\'#div_xls\').css(\'display\') == \'none\'){$(\'#div_xls\').show(\'slow\'); } else { $(\'#div_xls\').hide(\'slow\'); }" type="button" name="productxls" id="productxls" value="PDF">';
$createxls .= '<div id="div_xls" style="border: 1px solid #cccccc;background:#e6e6e6;padding:5px;position:absolute;display:none;">';
$createxls .= 'Typ: <select name="xls_ean" id="xls_ean"><option value="1">Arkusze spisu z natury</option></select><br /><br />';
$createxls.=" <input type='hidden' id='list_pdf_settings' name='list_pdf_settigns' value='".$_SESSION['ee']."'/>";
$createxls .= '<input name="cat_xls" id="cat_xls" title="Generuj XLS" accessKey="" class="button"
onclick=\'window.open("index.php?to_pdf=1&module=Home&action=StanyPDF&settings="+document.getElementById("list_pdf_settings").value);\' type="button" value="Pokaż PDF"></div>';
}
return $str .$createxls. $this->ss->fetch($this->tpl). (($end) ? '<br>' . $strend : '');
}
function displayEnd() {
$str = '';
if($this->show_mass_update_form) {
if($this->showMassupdateFields){
$str .= $this->mass->getMassUpdateForm(true);
}
$str .= $this->mass->endMassUpdateForm();
}
return $str;
}
}
?>

220
include/ListView/ListViewXTPL.php Executable file
View File

@@ -0,0 +1,220 @@
<?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".
********************************************************************************/
require_once('include/ListView/ListViewDisplay.php');
class ListViewXTPL extends ListViewDisplay{
var $row_block = 'main.row';
var $main_block = 'main';
var $pro_block = 'main.row.pro';
var $os_block = 'main.row.os';
var $nav_block = 'main.list_nav_row';
var $pro_nav_block = 'main.pro_nav';
var $data;
var $xtpl;
function ListViewXTPL() {
parent::ListViewDisplay();
}
/**
* Processes the request. Calls ListViewData process. Also assigns all lang strings, export links,
* This is called from ListViewDisplay
*
* @param file file Template file to use
* @param data array from ListViewData
* @param html_var string the corresponding html var in xtpl per row
*
*/
function process($file, $data, $html_var) {
global $odd_bg, $even_bg, $hilite_bg, $click_bg;
parent::process($file, $data, $html_var);
$this->data = $data;
$html_var = strtoupper($html_var);
$this->xtpl = new XTemplate($file);
$this->xtpl->assign('MOD', $GLOBALS['mod_strings']);
$this->xtpl->assign('APP', $GLOBALS['app_strings']);
$this->xtpl->assign('BG_HILITE', $hilite_bg);
$this->xtpl->assign('ORDER_BY', $data['pageData']['urls']['orderBy']);
$this->processPagination();
$this->xtpl->parse($this->nav_block);
$this->processArrows($data['pageData']['ordering']);
$oddRow = false;
if($this->xtpl->exists($this->pro_nav_block)) $this->xtpl->parse($this->pro_nav_block);
$this->xtpl->assign('CHECKALL', "<input type='checkbox' class='checkbox' id='massall' name='massall' value='' onclick='sListView.check_all(document.MassUpdate, \"mass[]\", this.checked);' />");
foreach($data['data'] as $id=>$row) {
$this->xtpl->assign($html_var, $row);
if(!empty($data['pageData']['tag'][$id])) {
$this->xtpl->assign('TAG', $data['pageData']['tag'][$id]);
}
$this->xtpl->assign('ROW_COLOR', ($oddRow) ? 'oddListRow' : 'evenListRow');
$this->xtpl->assign('BG_COLOR', ($oddRow) ? $odd_bg : $even_bg);
$oddRow = !$oddRow;
if($this->xtpl->exists($this->pro_block)) $this->xtpl->parse($this->pro_block);
// if($this->xtpl->exists($this->os_block)) $this->xtpl->parse($this->os_block);
$prerow = "&nbsp;<input onclick='sListView.check_item(this, document.MassUpdate)' type='checkbox' class='checkbox' name='mass[]' value='". $id. "'>";
$this->xtpl->assign('PREROW', $prerow);
$this->xtpl->parse($this->row_block);
}
}
/**
* Assigns the sort arrows in the tpl
*
* @param ordering array data that contains the ordering info
*
*/
function processArrows($ordering) {
$pathParts = pathinfo(SugarThemeRegistry::current()->getImageURL('arrow.gif',false));
list($width,$height) = getimagesize($pathParts['dirname'].'/'.$pathParts['basename']);
$this->xtpl->assign('arrow_start', "&nbsp;<img border='0' src='".getJSPath($pathParts['dirname'].'/'.$pathParts['filename']));
$this->xtpl->assign('arrow_end', "' width='$width' height='$height' align='absmiddle' alt=".translate('LBL_SORT').">");
$arrow_order = (strcmp($ordering['sortOrder'], 'ASC'))?'_up': '_down';
$this->xtpl->assign($ordering['orderBy'].'_arrow', $arrow_order);
}
/**
* Assigns the pagination links at the top and bottom of the listview
*
*/
function processPagination() {
global $app_strings;
//_pp($this->data['pageData']);
if(empty($this->data['pageData']['urls']['prevPage'])) {
$startLink = SugarThemeRegistry::current()->getImage("start_off", "alt='".$app_strings['LNK_LIST_START']."' border='0' align='absmiddle'")."&nbsp;".$app_strings['LNK_LIST_START'];
$prevLink = SugarThemeRegistry::current()->getImage("previous_off", "alt='".$app_strings['LNK_LIST_PREVIOUS']."' border='0' align='absmiddle'")."&nbsp;".$app_strings['LNK_LIST_PREVIOUS'];
}
else {
// if($this->multi_select_popup) {// nav links for multiselect popup, submit form to save checks.
// $start_link = "<a href=\"#\" onclick=\"javascript:save_checks(0, '{$moduleString}')\" >".SugarThemeRegistry::current()->getImage("start","alt='".$app_strings['LNK_LIST_START']."' border='0' align='absmiddle'")."&nbsp;".$app_strings['LNK_LIST_START']."</a>";
// $previous_link = "<a href=\"#\" onclick=\"javascript:save_checks($previous_offset, '{$moduleString}')\" >".SugarThemeRegistry::current()->getImage("previous","alt='".$app_strings['LNK_LIST_PREVIOUS']."' border='0' align='absmiddle'")."&nbsp;".$app_strings['LNK_LIST_PREVIOUS']."</a>";
// }
// elseif($this->shouldProcess) {
// // TODO: make popups / listview check saving the same
// $start_link = "<a href=\"$start_URL\" onclick=\"javascript:return sListView.save_checks(0, '{$moduleString}')\" >".SugarThemeRegistry::current()->getImage("start","alt='".$app_strings['LNK_LIST_START']."' border='0' align='absmiddle'")."&nbsp;".$app_strings['LNK_LIST_START']."</a>";
// $previous_link = "<a href=\"$previous_URL\" onclick=\"javascript:return sListView.save_checks($previous_offset, '{$moduleString}')\" >".SugarThemeRegistry::current()->getImage("previous","alt='".$app_strings['LNK_LIST_PREVIOUS']."' border='0' align='absmiddle'")."&nbsp;".$app_strings['LNK_LIST_PREVIOUS']."</a>";
// }
// else {
$startLink = "<a href=\"{$this->data['pageData']['urls']['startPage']}\" >".SugarThemeRegistry::current()->getImage("start","alt='".$app_strings['LNK_LIST_START']."' border='0' align='absmiddle'")."&nbsp;".$app_strings['LNK_LIST_START']."</a>";
$prevLink = "<a href=\"{$this->data['pageData']['urls']['prevPage']}\" >".SugarThemeRegistry::current()->getImage("previous","alt='".$app_strings['LNK_LIST_PREVIOUS']."' border='0' align='absmiddle'")."&nbsp;".$app_strings['LNK_LIST_PREVIOUS']."</a>";
// }
}
if(!$this->data['pageData']['offsets']['totalCounted']) {
$endLink = $app_strings['LNK_LIST_END']."&nbsp;".SugarThemeRegistry::current()->getImage("end_off","alt='".$app_strings['LNK_LIST_END']."' border='0' align='absmiddle'");
}
else {
// if($this->multi_select_popup) { // nav links for multiselect popup, submit form to save checks.
// $end_link = "<a href=\"#\" onclick=\"javascript:save_checks($last_offset, '{$moduleString}')\" >".$app_strings['LNK_LIST_END']."&nbsp;".SugarThemeRegistry::current()->getImage("end","alt='".$app_strings['LNK_LIST_END']."' border='0' align='absmiddle'")."</a>";
// $next_link = "<a href=\"#\" onclick=\"javascript:save_checks($next_offset, '{$moduleString}')\" >".$app_strings['LNK_LIST_NEXT']."&nbsp;".SugarThemeRegistry::current()->getImage("next","alt='".$app_strings['LNK_LIST_NEXT']."' border='0' align='absmiddle'")."</a>";
// }
// elseif($this->shouldProcess) {
// $end_link = "<a href=\"$end_URL\" onclick=\"javascript:return sListView.save_checks($last_offset, '{$moduleString}')\" >".$app_strings['LNK_LIST_END']."&nbsp;".SugarThemeRegistry::current()->getImage("end","alt='".$app_strings['LNK_LIST_END']."' border='0' align='absmiddle'")."</a>";
// $next_link = "<a href=\"$next_URL\" onclick=\"javascript:return sListView.save_checks($next_offset, '{$moduleString}')\" >".$app_strings['LNK_LIST_NEXT']."&nbsp;".SugarThemeRegistry::current()->getImage("next","alt='".$app_strings['LNK_LIST_NEXT']."' border='0' align='absmiddle'")."</a>";
// }
// else {
$endLink = "<a href=\"{$this->data['pageData']['urls']['endPage']}\" >".$app_strings['LNK_LIST_END']."&nbsp;".SugarThemeRegistry::current()->getImage("end","alt='".$app_strings['LNK_LIST_END']."' border='0' align='absmiddle'")."</a>";
// }
}
if(empty($this->data['pageData']['urls']['nextPage'])){
$nextLink = $app_strings['LNK_LIST_NEXT']."&nbsp;".SugarThemeRegistry::current()->getImage("next_off","alt='".$app_strings['LNK_LIST_NEXT']."' border='0' align='absmiddle'");
}else{
$nextLink = "<a href=\"{$this->data['pageData']['urls']['nextPage']}\" >".$app_strings['LNK_LIST_NEXT']."&nbsp;".SugarThemeRegistry::current()->getImage("next","alt='".$app_strings['LNK_LIST_NEXT']."' border='0' align='absmiddle'")."</a>";
}
if($this->export) $export_link = $this->buildExportLink();
else $export_link = '';
if($this->mailMerge)$merge_link = $this->buildMergeLink();
else $merge_link = '';
if($this->multiSelect) $selected_objects_span = $this->buildSelectedObjectsSpan();
else $selected_objects_span = '';
$htmlText = "<tr class='pagination'>\n"
. "<td COLSPAN=\"20\" align=\"right\">\n"
. "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td align=\"left\">$export_link$merge_link$selected_objects_span</td>\n"
. "<td nowrap align=\"right\">".$startLink."&nbsp;&nbsp;".$prevLink."&nbsp;&nbsp;<span class='pageNumbers'>(".($this->data['pageData']['offsets']['current'] + 1) ." - ".($this->data['pageData']['offsets']['current'] + $this->rowCount)
. " ".$app_strings['LBL_LIST_OF']." ".$this->data['pageData']['offsets']['total'];
if(!$this->data['pageData']['offsets']['totalCounted']){
$htmlText .= '+';
}
$htmlText .=")</span>&nbsp;&nbsp;".$nextLink."&nbsp;&nbsp;";
if($this->data['pageData']['offsets']['totalCounted']){
$htmlText .= $endLink;
}
$htmlText .="</td></tr></table>\n</td>\n</tr>\n";
$this->xtpl->assign("PAGINATION", $htmlText);
}
/**
* Displays the xtpl, either echo or returning the contents
*
* @param echo bool echo or return contents
*
*/
function display($echo = true) {
$str = parent::display();
$strend = parent::displayEnd();
$this->xtpl->parse($this->main_block);
if($echo) {
echo $str;
$this->xtpl->out($this->main_block);
echo $strend;
}
else {
return $str . $this->xtpl->text() . $strend;
}
}
}
?>