init
This commit is contained in:
1749
include/ListView/ListView.php
Executable file
1749
include/ListView/ListView.php
Executable file
File diff suppressed because it is too large
Load Diff
704
include/ListView/ListViewData.php
Executable file
704
include/ListView/ListViewData.php
Executable file
@@ -0,0 +1,704 @@
|
||||
<?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
|
||||
);
|
||||
$_SESSION ['lvd'] ['last_ob'] = $orderBy;
|
||||
} else {
|
||||
if (! empty ( $_SESSION [$this->var_order_by] )) {
|
||||
$orderBy = $_SESSION [$this->var_order_by] ['orderBy'];
|
||||
$direction = $_SESSION [$this->var_order_by] ['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') {
|
||||
global $current_user;
|
||||
|
||||
// add mz 2014-08-19
|
||||
$where = str_replace ( "like '", "like '%", $where );
|
||||
// end mz
|
||||
|
||||
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'];
|
||||
}
|
||||
|
||||
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'] = '';
|
||||
|
||||
// add mz 2014-05-13
|
||||
if (isset ( $_REQUEST ['custom_parent_id'] )) {
|
||||
$params ['custom_where'] = " AND parent_id='" . $_REQUEST ['custom_parent_id'] . "'";
|
||||
$ret_array ['where'] = ' where ecmstockoperations.deleted=0';
|
||||
}
|
||||
if (! isset ( $params ['custom_where'] ))
|
||||
$params ['custom_where'] = '';
|
||||
if (! isset ( $params ['custom_order_by'] ))
|
||||
$params ['custom_order_by'] = '';
|
||||
|
||||
$main_query = $ret_array ['select'] . $params ['custom_select'] . $ret_array ['from'] . $params ['custom_from'] . $ret_array ['inner_join'] . $ret_array ['where'] . $params ['custom_where'] . $ret_array ['order_by'] . $params ['custom_order_by'];
|
||||
// C.L. - Fix for 23461
|
||||
if ($_REQUEST ['parent_id'] != "") {
|
||||
if ($_REQUEST ['module'] == 'Documents') {
|
||||
|
||||
$custom_join = " inner join documents_accounts on documents.id = documents_accounts.document_id ";
|
||||
$custom_where = " and documents_accounts.parent_id='" . $_REQUEST ['parent_id'] . "'";
|
||||
$main_query = $ret_array ['select'] . $params ['custom_select'] . $ret_array ['from'] . $params ['custom_from'] . $ret_array ['inner_join'] . $custom_join . $ret_array ['where'] . $params ['custom_where'] . $custom_where . $ret_array ['order_by'] . $params ['custom_order_by'];
|
||||
} else {
|
||||
$main_query = $ret_array ['select'] . $params ['custom_select'] . $ret_array ['from'] . $params ['custom_from'] . $ret_array ['inner_join'] . $ret_array ['where'] . $params ['custom_where'] . $ret_array ['order_by'] . $params ['custom_order_by'];
|
||||
|
||||
}
|
||||
} else {
|
||||
if($_REQUEST['module']=='EcmWorkCards'){
|
||||
|
||||
|
||||
|
||||
|
||||
if($orderBy=='date asc'){
|
||||
$innerString=' inner join ecmworkers on ecmworkers.id=ecmworkcards.worker_id';
|
||||
$orderString=' order by ecmworkcards.date asc, ecmworkers.last_name asc,ecmworkcards.time_from asc';
|
||||
}
|
||||
|
||||
if($orderBy=='date desc'){
|
||||
$innerString=' inner join ecmworkers on ecmworkers.id=ecmworkcards.worker_id';
|
||||
$orderString=' order by ecmworkcards.date desc, ecmworkers.last_name desc,ecmworkcards.time_from desc';
|
||||
}
|
||||
|
||||
if($orderBy=='worker_name asc'){
|
||||
$innerString=' inner join ecmworkers on ecmworkers.id=ecmworkcards.worker_id';
|
||||
$orderString=' order by ecmworkers.last_name asc';
|
||||
}
|
||||
|
||||
|
||||
if($orderBy=='worker_name desc'){
|
||||
$innerString=' inner join ecmworkers on ecmworkers.id=ecmworkcards.worker_id';
|
||||
$orderString=' order by ecmworkers.last_name desc';
|
||||
}
|
||||
|
||||
$main_query = $ret_array ['select'] . $params ['custom_select'] . $ret_array ['from'] . $params ['custom_from'] . $ret_array ['inner_join'] . $innerString . $ret_array ['where'] . $params ['custom_where'].$orderString;
|
||||
|
||||
// echo $main_query;
|
||||
} else {
|
||||
$main_query = $ret_array ['select'] . $params ['custom_select'] . $ret_array ['from'] . $params ['custom_from'] . $ret_array ['inner_join'] . $ret_array ['where'] . $params ['custom_where'] . $ret_array ['order_by'] . $params ['custom_order_by'];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (empty ( $_REQUEST ['action'] ) || $_REQUEST ['action'] != 'Popup') {
|
||||
$_SESSION ['export_where'] = $ret_array ['where'];
|
||||
}
|
||||
if ($_REQUEST ['module'] == 'Accounts') {
|
||||
$lead_query = str_replace ( 'accounts', 'leads', $main_query );
|
||||
$leads = $this->db->query ( $lead_query );
|
||||
if ($leads->num_rows > 0)
|
||||
echo '<H1>Uwaga! W bazie potencjalnych kontrahentów istnieje obiekt o zadanych kryteriach!</H1>';
|
||||
}
|
||||
|
||||
if ($_REQUEST ['module'] == 'Leads') {
|
||||
$account_query = str_replace ( 'leads', 'accounts', $main_query );
|
||||
$accounts = $this->db->query ( $account_query );
|
||||
if ($accounts->num_rows > 0)
|
||||
echo '<H1>Uwaga! W bazie kontrahentów istnieje obiekt o zadanych kryteriach!</H1>';
|
||||
}
|
||||
|
||||
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 ();
|
||||
}
|
||||
}
|
||||
|
||||
if ($_REQUEST ['module'] == 'EcmStockDocIns') {
|
||||
$_SESSION [$current_user->id . '_pdf_ecmstockdocins'] = $main_query;
|
||||
}
|
||||
|
||||
if ($_REQUEST ['module'] == 'EcmStockDocOuts') {
|
||||
$_SESSION [$current_user->id . '_pdf_ecmstockdocouts'] = $main_query;
|
||||
}
|
||||
|
||||
if ($_REQUEST ['module'] == 'EcmStockDocCorrects') {
|
||||
$_SESSION [$current_user->id . '_pdf_ecmstockdoccorrects'] = $main_query;
|
||||
}
|
||||
|
||||
$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 ['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';
|
||||
}
|
||||
|
||||
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 (
|
||||
"'",
|
||||
"'"
|
||||
), '\'', $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 (
|
||||
"'",
|
||||
"'"
|
||||
), '\'', $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
|
||||
);
|
||||
}
|
||||
}
|
||||
707
include/ListView/ListViewDisplay.php
Executable file
707
include/ListView/ListViewDisplay.php
Executable file
@@ -0,0 +1,707 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$data = $this->lvd->getListViewData($seed, $where, $offset, $limit, $filter_fields, $params, $id_field);
|
||||
// add mz 2015-03-18
|
||||
// add summary row to list view
|
||||
$sum = array ();
|
||||
$db = $GLOBALS ['db'];
|
||||
$showSumRow = false;
|
||||
foreach ( $this->displayColumns as $name => $val ) {
|
||||
if ($this->displayColumns [$name] ['sumType'] == 'sum') {
|
||||
$sum_q = "SELECT SUM(" . strtolower ( $name ) . ") as sum FROM " . $this->seed->table_name;
|
||||
|
||||
$kursy = $db->fetchByAssoc ( $db->query ( "select * from currency_nbp_archive order by date desc limit 1" ) );
|
||||
//print_r($kursy);
|
||||
if ($where && $where != " ")
|
||||
$sum_q .= " WHERE " . $where;
|
||||
|
||||
$sum [$name] = ($db->fetchByAssoc ( $db->query ( $sum_q ) )['sum']) ;
|
||||
$showSumRow = true;
|
||||
} 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 " . $where;
|
||||
$sum [$name] = format_number($db->fetchByAssoc ( $db->query ( $sum_q ) )['avg']);
|
||||
$showSumRow = true;
|
||||
} 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] = format_number(call_user_func(array($seed->object_name, $func), $where));
|
||||
}
|
||||
}
|
||||
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
|
||||
* @return string select link html
|
||||
* @param echo Bool set true if you want it echo'd, set false to have contents returned
|
||||
*/
|
||||
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']} ({$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']} ({$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
|
||||
|
||||
global $current_user;
|
||||
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>';
|
||||
}
|
||||
if ($_REQUEST['module'] == 'Contacts')
|
||||
$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 usunąć zaznaczone kontakty?\');if(r == true){document.MassUpdate.action.value=\'multidelete\';document.MassUpdate.submit();}"/>Usuń zaznaczone</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;} var r = confirm(\'Czy napewno chcesz usunąć zaznaczonych kontrahentów?\');if(r == true){document.MassUpdate.action.value=\'multidelete\';document.MassUpdate.submit();}"/>Usuń zaznaczone</a>';
|
||||
if ($_REQUEST['module'] == 'ContactLeads')
|
||||
$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 usunąć zaznaczone kontakty?\');if(r == true){document.MassUpdate.action.value=\'multidelete\';document.MassUpdate.submit();}"/>Usuń zaznaczone</a>';
|
||||
if ($_REQUEST['module'] == 'Leads')
|
||||
$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 usunąć zaznaczonych kontrahentów?\');if(r == true){document.MassUpdate.action.value=\'multidelete\';document.MassUpdate.submit();}"/>Usuń zaznaczone</a>';
|
||||
|
||||
|
||||
//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>';
|
||||
|
||||
//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>';
|
||||
$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>';
|
||||
|
||||
}
|
||||
if ($_REQUEST['module'] == 'Documents')
|
||||
if($current_user->is_admin==1){
|
||||
$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>';
|
||||
$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>';
|
||||
}
|
||||
//realizationList
|
||||
if ($_REQUEST['module'] == 'EcmSales'){
|
||||
if($current_user->fetched_row['delete_zs']==1){
|
||||
$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 usunąć zaznaczone dokumenty?\');if (r == true) {document.MassUpdate.action.value=\'delete_selected\';document.MassUpdate.submit();}"/>Usuń zaznaczone</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>';
|
||||
$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=\'massAction_PDF\';document.MassUpdate.submit();"/> Generuj zbiorczy PDF </a>';
|
||||
}
|
||||
if ($_REQUEST['module'] == 'EcmStockDocIns')
|
||||
$this->actionsMenuExtraItems[] = '<a href="#" class="menuItem" style="width: 150px;" onmouseover=\'hiliteItem(this,"yes");\' onmouseout="unhiliteItem(this);" onclick="document.MassUpdate.action.value=\'pdfMerge\';document.MassUpdate.submit();"/>Wygeneruj zbiorczy pdf</a>';
|
||||
|
||||
//sale order from quote
|
||||
if ($_REQUEST['module'] == 'EcmQuotes')
|
||||
$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>';
|
||||
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>';
|
||||
//end mz
|
||||
|
||||
if ($_REQUEST['module'] == 'EcmProducts')
|
||||
if($current_user->is_admin==1){
|
||||
$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=\'EditView\';document.MassUpdate.module.value=\'EcmProductGroups\';document.MassUpdate.return_module.value=\'0\';document.MassUpdate.submit();"/>Utwórz grupę produktową</a>';
|
||||
}
|
||||
|
||||
if ($_REQUEST['module'] == 'EcmStockDocOuts')
|
||||
$this->actionsMenuExtraItems[] = '<a href="#" class="menuItem" style="width: 150px;" onmouseover=\'hiliteItem(this,"yes");\' onmouseout="unhiliteItem(this);" onclick="document.MassUpdate.action.value=\'pdfMerge\';document.MassUpdate.submit();"/>Wygeneruj zbiorczy pdf</a>';
|
||||
|
||||
|
||||
if ($_REQUEST['module'] == 'EcmStockDocCorrects')
|
||||
$this->actionsMenuExtraItems[] = '<a href="#" class="menuItem" style="width: 150px;" onmouseover=\'hiliteItem(this,"yes");\' onmouseout="unhiliteItem(this);" onclick="document.MassUpdate.action.value=\'pdfMerge\';document.MassUpdate.submit();"/>Wygeneruj zbiorczy pdf</a>';
|
||||
|
||||
|
||||
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 {
|
||||
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']} <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;
|
||||
}
|
||||
|
||||
}
|
||||
176
include/ListView/ListViewFacade.php
Executable file
176
include/ListView/ListViewFacade.php
Executable 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;
|
||||
}
|
||||
}
|
||||
?>
|
||||
177
include/ListView/ListViewGeneric.tpl
Executable file
177
include/ListView/ListViewGeneric.tpl
Executable file
@@ -0,0 +1,177 @@
|
||||
{*
|
||||
|
||||
/*********************************************************************************
|
||||
* 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".
|
||||
********************************************************************************/
|
||||
|
||||
|
||||
|
||||
*}
|
||||
|
||||
<script type='text/javascript' src='{sugar_getjspath file='include/javascript/popup_helper.js'}'></script>
|
||||
<script type='text/javascript' src='{sugar_getjspath file='include/javascript/action_helper.js'}'></script>
|
||||
|
||||
{if $overlib}
|
||||
<script type='text/javascript' src='{sugar_getjspath file='include/javascript/sugar_grp_overlib.js'}'></script>
|
||||
<div id='overDiv' style='position:absolute; visibility:hidden; z-index:1000;'></div>
|
||||
{/if}
|
||||
{if $prerow}
|
||||
{$multiSelectData}
|
||||
{/if}
|
||||
<table cellpadding='0' cellspacing='0' width='100%' border='0' class='list view'>
|
||||
{include file='include/ListView/ListViewPagination.tpl'}
|
||||
<tr height='20'>
|
||||
{if $prerow}
|
||||
<th scope='col' nowrap="nowrap" width='1%' class="selectCol">
|
||||
<div>
|
||||
<input type='checkbox' class='checkbox' name='massall' id='massall' value='' onclick='sListView.check_all(document.MassUpdate, "mass[]", this.checked);' />
|
||||
{$selectLink}
|
||||
</div>
|
||||
</th>
|
||||
{/if}
|
||||
{if !empty($quickViewLinks)}
|
||||
<th scope='col' width='1%' style="padding: 0px;"> </th>
|
||||
{/if}
|
||||
{counter start=0 name="colCounter" print=false assign="colCounter"}
|
||||
{foreach from=$displayColumns key=colHeader item=params}
|
||||
<th scope='col' width='{$params.width}%' nowrap="nowrap">
|
||||
<div style='white-space: nowrap;'width='100%' align='{$params.align|default:'left'}'>
|
||||
{if $params.sortable|default:true}
|
||||
{if $params.url_sort}
|
||||
<a href='{$pageData.urls.orderBy}{$params.orderBy|default:$colHeader|lower}' class='listViewThLinkS1'>
|
||||
{else}
|
||||
{if $params.orderBy|default:$colHeader|lower == $pageData.ordering.orderBy}
|
||||
<a href='javascript:sListView.order_checks("{$pageData.ordering.sortOrder|default:ASCerror}", "{$params.orderBy|default:$colHeader|lower}" , "{$pageData.bean.moduleDir}{"2_"}{$pageData.bean.objectName|upper}{"_ORDER_BY"}")' class='listViewThLinkS1'>
|
||||
{else}
|
||||
<a href='javascript:sListView.order_checks("ASC", "{$params.orderBy|default:$colHeader|lower}" , "{$pageData.bean.moduleDir}{"2_"}{$pageData.bean.objectName|upper}{"_ORDER_BY"}")' class='listViewThLinkS1'>
|
||||
{/if}
|
||||
{/if}
|
||||
{sugar_translate label=$params.label module=$pageData.bean.moduleDir}
|
||||
</a>
|
||||
{if $params.orderBy|default:$colHeader|lower == $pageData.ordering.orderBy}
|
||||
{if $pageData.ordering.sortOrder == 'ASC'}
|
||||
{capture assign="imageName"}arrow_down.{$arrowExt}{/capture}
|
||||
<img border='0' src='{sugar_getimagepath file=$imageName}' width='{$arrowWidth}' height='{$arrowHeight}' align='absmiddle' alt='{$arrowAlt}'>
|
||||
{else}
|
||||
{capture assign="imageName"}arrow_up.{$arrowExt}{/capture}
|
||||
<img border='0' src='{sugar_getimagepath file=$imageName}' width='{$arrowWidth}' height='{$arrowHeight}' align='absmiddle' alt='{$arrowAlt}'>
|
||||
{/if}
|
||||
{else}
|
||||
{capture assign="imageName"}arrow.{$arrowExt}{/capture}
|
||||
<img border='0' src='{sugar_getimagepath file=$imageName}' width='{$arrowWidth}' height='{$arrowHeight}' align='absmiddle' alt='{$arrowAlt}'>
|
||||
{/if}
|
||||
{else}
|
||||
{sugar_translate label=$params.label module=$pageData.bean.moduleDir}
|
||||
{/if}
|
||||
</div>
|
||||
</th>
|
||||
{counter name="colCounter"}
|
||||
{/foreach}
|
||||
<th scope='col' nowrap="nowrap" width='1%'> </th>
|
||||
</tr>
|
||||
|
||||
{counter start=$pageData.offsets.current print=false assign="offset" name="offset"}
|
||||
{foreach name=rowIteration from=$data key=id item=rowData name=foo}
|
||||
{* add mz 2015-03-25 *}
|
||||
{* listView summary *}
|
||||
{if $smarty.foreach.foo.last && $rowData.showSumRow==1}{assign var="isLastRow" value="true"}{/if}
|
||||
{counter name="offset" print=false}
|
||||
|
||||
{if $smarty.foreach.rowIteration.iteration is odd}
|
||||
{assign var='_rowColor' value=$rowColor[0]}
|
||||
{else}
|
||||
{assign var='_rowColor' value=$rowColor[1]}
|
||||
{/if}
|
||||
<tr height='20' class='{$_rowColor}S1' {if $isLastRow}style="background:rgb(78,140,207);"{/if}>
|
||||
{if $prerow}
|
||||
<td width='1%' class='nowrap'>
|
||||
{if $isLastRow!="true"}
|
||||
{if !$is_admin && is_admin_for_user && $rowData.IS_ADMIN==1}
|
||||
<input type='checkbox' disabled="disabled" class='checkbox' value='{$rowData.ID}'>
|
||||
{else}
|
||||
<input onclick='sListView.check_item(this, document.MassUpdate)' type='checkbox' class='checkbox' name='mass[]' value='{$rowData.ID}'>
|
||||
{/if}
|
||||
{/if}
|
||||
</td>
|
||||
{/if}
|
||||
{if !empty($quickViewLinks)}
|
||||
<td width='2%' nowrap>
|
||||
{if $pageData.access.edit}
|
||||
<a title='{$editLinkString}' href="#" onMouseOver="javascript:lvg_nav('{if $params.dynamic_module}{$rowData[$params.dynamic_module]}{else}{$pageData.bean.moduleDir}{/if}', '{$rowData.ID}', {if $act}'{$act}'{else}'e'{/if}, {$offset}, this)" onFocus="javascript:lvg_nav('{if $params.dynamic_module}{$rowData[$params.dynamic_module]}{else}{$pageData.bean.moduleDir}{/if}', '{$rowData.ID}', {if $act}'{$act}'{else}'e'{/if}, {$offset}, this)">
|
||||
<img border=0 src='{sugar_getimagepath file='edit_inline.gif'}'>
|
||||
</a>
|
||||
{/if}
|
||||
</td>
|
||||
{/if}
|
||||
{counter start=0 name="colCounter" print=false assign="colCounter"}
|
||||
{foreach from=$displayColumns key=col item=params}
|
||||
{strip}
|
||||
<td scope='row' align='{$params.align|default:'left'}' valign="top" {if ($params.type == 'teamset')}class="nowrap"{/if}>
|
||||
{if $col == 'NAME' || $params.bold || $isLastRow=="true"}<b>{/if}
|
||||
{if $params.link && !$params.customCode && $isLastRow!="true"}
|
||||
<{$pageData.tag.$id[$params.ACLTag]|default:$pageData.tag.$id.MAIN} href="#" onMouseOver="javascript:lvg_nav('{if $params.dynamic_module}{$rowData[$params.dynamic_module]}{else}{$params.module|default:$pageData.bean.moduleDir}{/if}', '{$rowData[$params.id]|default:$rowData.ID}', 'd', {$offset}, this)" onFocus="javascript:lvg_nav('{if $params.dynamic_module}{$rowData[$params.dynamic_module]}{else}{$params.module|default:$pageData.bean.moduleDir}{/if}', '{$rowData[$params.id]|default:$rowData.ID}', 'd', {$offset}, this)">
|
||||
{/if}
|
||||
{if $params.customCode}
|
||||
{sugar_evalcolumn_old var=$params.customCode rowData=$rowData}
|
||||
{else}
|
||||
{sugar_field parentFieldArray=$rowData vardef=$params displayType=ListView field=$col}
|
||||
{/if}
|
||||
{if empty($rowData.$col) && empty($params.customCode)} {/if}
|
||||
{if $params.link && !$params.customCode}
|
||||
</{$pageData.tag.$id[$params.ACLTag]|default:$pageData.tag.$id.MAIN}>
|
||||
{/if}
|
||||
{if $col == 'NAME' || $params.bold || $isLastRow=="true"}</b>{/if}
|
||||
</td>
|
||||
{/strip}
|
||||
{counter name="colCounter"}
|
||||
{/foreach}
|
||||
<td align='right'>{$pageData.additionalDetails.$id}</td>
|
||||
</tr>
|
||||
{foreachelse}
|
||||
<tr height='20' class='{$rowColor[0]}S1'>
|
||||
<td colspan="{$colCount}">
|
||||
<em>{$APP.LBL_NO_DATA}</em>
|
||||
</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
<tr>{$summary}</tr>
|
||||
{include file='include/ListView/ListViewPagination.tpl'}
|
||||
</table>
|
||||
{if $contextMenus}
|
||||
<script type="text/javascript">
|
||||
{$contextMenuScript}
|
||||
{literal}function lvg_nav(m,id,act,offset,t){if(t.href.search(/#/) < 0){return;}else{if(act=='pte'){act='ProjectTemplatesEditView';}else if(act=='d'){ act='DetailView';}else if( act =='ReportsWizard'){act = 'ReportsWizard';}else{ act='EditView';}{/literal}url = 'index.php?module='+m+'&offset=' + offset + '&stamp={$pageData.stamp}&return_module='+m+'&action='+act+'&record='+id;t.href=url;{literal}}}{/literal}
|
||||
{literal}function lvg_dtails(id){{/literal}return SUGAR.util.getAdditionalDetails( '{$params.module|default:$pageData.bean.moduleDir}',id, 'adspan_'+id);{literal}}{/literal}
|
||||
</script>
|
||||
{/if}
|
||||
135
include/ListView/ListViewNoMassUpdate.tpl
Executable file
135
include/ListView/ListViewNoMassUpdate.tpl
Executable file
@@ -0,0 +1,135 @@
|
||||
{*
|
||||
|
||||
/*********************************************************************************
|
||||
* 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".
|
||||
********************************************************************************/
|
||||
|
||||
|
||||
|
||||
*}
|
||||
|
||||
{if $overlib}
|
||||
<script type='text/javascript' src='include/javascript/overlibmws.js'></script>
|
||||
<script type='text/javascript' src='include/javascript/overlibmws_iframe.js'></script>
|
||||
<div id='overDiv' style='position:absolute; visibility:hidden; z-index:1000;'></div>
|
||||
{/if}
|
||||
|
||||
<table cellpadding='0' cellspacing='0' width='100%' border='0' class='list View'>
|
||||
{include file='include/ListView/ListViewPagination.tpl'}
|
||||
|
||||
<tr height='20'>
|
||||
{if !empty($quickViewLinks)}
|
||||
<th scope='col' nowrap="nowrap" width='1%'> </th>
|
||||
{/if}
|
||||
{counter start=0 name="colCounter" print=false assign="colCounter"}
|
||||
{foreach from=$displayColumns key=colHeader item=params}
|
||||
<th scope='col' width='{$params.width}%' nowrap="nowrap">
|
||||
<span sugar="sugar{$colCounter}"><div style='white-space: nowrap;'width='100%' align='{$params.align|default:'left'}'>
|
||||
{if $params.sortable|default:true}
|
||||
<a href='{$pageData.urls.orderBy}{$params.orderBy|default:$colHeader|lower}' class='listViewThLinkS1'>{sugar_translate label=$params.label module=$pageData.bean.moduleDir}</a>
|
||||
{if $params.orderBy|default:$colHeader|lower == $pageData.ordering.orderBy}
|
||||
{if $pageData.ordering.sortOrder == 'ASC'}
|
||||
{capture assign="imageName"}arrow_down.{$arrowExt}{/capture}
|
||||
<img border='0' src='{sugar_getimagepath file=$imageName}' width='{$arrowWidth}' height='{$arrowHeight}' align='absmiddle' alt='{$arrowAlt}'>
|
||||
{else}
|
||||
{capture assign="imageName"}arrow_up.{$arrowExt}{/capture}
|
||||
<img border='0' src='{sugar_getimagepath file=$imageName}' width='{$arrowWidth}' height='{$arrowHeight}' align='absmiddle' alt='{$arrowAlt}'>
|
||||
{/if}
|
||||
{else}
|
||||
{capture assign="imageName"}arrow.{$arrowExt}{/capture}
|
||||
<img border='0' src='{sugar_getimagepath file=$imageName}' width='{$arrowWidth}' height='{$arrowHeight}' align='absmiddle' alt='{$arrowAlt}'>
|
||||
{/if}
|
||||
{else}
|
||||
{sugar_translate label=$params.label module=$pageData.bean.moduleDir}
|
||||
{/if}
|
||||
</div></span sugar='sugar{$colCounter}'>
|
||||
</th>
|
||||
{counter name="colCounter"}
|
||||
{/foreach}
|
||||
</tr>
|
||||
|
||||
{foreach name=rowIteration from=$data key=id item=rowData}
|
||||
{* add mz 2015-03-25 *}
|
||||
{* listView summary *}
|
||||
{if $smarty.foreach.foo.last && $rowData.showSumRow==1}{assign var="isLastRow" value="true"}{/if}
|
||||
{if $smarty.foreach.rowIteration.iteration is odd}
|
||||
{assign var='_rowColor' value=$rowColor[0]}
|
||||
{else}
|
||||
{assign var='_rowColor' value=$rowColor[1]}
|
||||
{/if}
|
||||
<tr height='20' class='{$_rowColor}S1' {if $isLastRow}style="background:rgb(78,140,207);"{/if}>
|
||||
{if !empty($quickViewLinks)}
|
||||
<td width='1%' nowrap>
|
||||
{if $pageData.access.edit && $pageData.bean.moduleDir != "Employees"}
|
||||
<a title='{$editLinkString}' href='index.php?action=EditView&module={$params.module|default:$pageData.bean.moduleDir}&record={$rowData[$params.id]|default:$rowData.ID}&offset={$pageData.offsets.current+$smarty.foreach.rowIteration.iteration}&stamp={$pageData.stamp}&return_module={$params.module|default:$pageData.bean.moduleDir}'><img border="0" src="{sugar_getimagepath file="edit_inline.gif"}"></a>
|
||||
{/if}
|
||||
</td>
|
||||
{/if}
|
||||
{counter start=0 name="colCounter" print=false assign="colCounter"}
|
||||
{foreach from=$displayColumns key=col item=params}
|
||||
<td scope='row' align='{$params.align|default:'left'}' {if $params.nowrap}nowrap='nowrap' {/if}valign='top'><span sugar="sugar{$colCounter}b">
|
||||
{if $col == 'NAME' || $params.bold || $isLastRow=="true"}<b>{/if}
|
||||
{if $params.link && !$params.customCode && $isLastRow!="true"}
|
||||
<{$pageData.tag.$id[$params.ACLTag]|default:$pageData.tag.$id.MAIN} href="#" onMouseOver="javascript:lvg_nav('{if $params.dynamic_module}{$rowData[$params.dynamic_module]}{else}{$params.module|default:$pageData.bean.moduleDir}{/if}', '{$rowData[$params.id]|default:$rowData.ID}', 'd', {$smarty.foreach.rowIteration.iteration}, this);" onFocus="javascript:lvg_nav('{if $params.dynamic_module}{$rowData[$params.dynamic_module]}{else}{$params.module|default:$pageData.bean.moduleDir}{/if}', '{$rowData[$params.id]|default:$rowData.ID}', 'd', {$smarty.foreach.rowIteration.iteration}, this);">
|
||||
{/if}
|
||||
{if $params.customCode}
|
||||
{sugar_evalcolumn_old var=$params.customCode rowData=$rowData}
|
||||
{else}
|
||||
{sugar_field parentFieldArray=$rowData vardef=$params displayType=ListView field=$col}
|
||||
{/if}
|
||||
{if empty($rowData.$col)} {/if}
|
||||
{if $params.link && !$params.customCode}
|
||||
</{$pageData.tag.$id[$params.ACLTag]|default:$pageData.tag.$id.MAIN}>
|
||||
{/if}
|
||||
{if $col == 'NAME' || $params.bold || $isLastRow=="true"}</b>{/if}
|
||||
</span sugar='sugar{$colCounter}b'></td>
|
||||
{counter name="colCounter"}
|
||||
{/foreach}
|
||||
</tr>
|
||||
{foreachelse}
|
||||
<tr height='20' class='{$rowColor[0]}S1'>
|
||||
<td colspan="{$colCount}">
|
||||
<em>{$APP.LBL_NO_DATA}</em>
|
||||
</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
{include file='include/ListView/ListViewPagination.tpl'}
|
||||
</table>
|
||||
<script type='text/javascript'>
|
||||
{literal}function lvg_nav(m,id,act,offset,t){if(t.href.search(/#/) < 0){return;}else{if(act=='pte'){act='ProjectTemplatesEditView';}else if(act=='d'){ act='DetailView';}else if( act =='ReportsWizard'){act = 'ReportsWizard';}else{ act='EditView';}{/literal}url = 'index.php?module='+m+'&offset=' + offset + '&stamp={$pageData.stamp}&return_module='+m+'&action='+act+'&record='+id;t.href=url;{literal}}}{/literal}
|
||||
{literal}function lvg_dtails(id){{/literal}return SUGAR.util.getAdditionalDetails( '{$params.module|default:$pageData.bean.moduleDir}',id, 'adspan_'+id);{literal}}{/literal}
|
||||
{if $contextMenus}
|
||||
{$contextMenuScript}
|
||||
{/if}
|
||||
</script>
|
||||
90
include/ListView/ListViewPagination.tpl
Executable file
90
include/ListView/ListViewPagination.tpl
Executable file
@@ -0,0 +1,90 @@
|
||||
{*
|
||||
|
||||
/*********************************************************************************
|
||||
* 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".
|
||||
********************************************************************************/
|
||||
|
||||
|
||||
*}
|
||||
<tr class='pagination'>
|
||||
<td colspan='{if $prerow}{$colCount+1}{else}{$colCount}{/if}'>
|
||||
<table border='0' cellpadding='0' cellspacing='0' width='100%' class='paginationTable'>
|
||||
<tr>
|
||||
<td nowrap="nowrap" width='2%' class='paginationActionButtons'>
|
||||
{$actionsLink}
|
||||
{$selectedObjectsSpan}
|
||||
</td>
|
||||
<td nowrap='nowrap' width='1%' align="right" class='paginationChangeButtons'>
|
||||
{if $pageData.urls.startPage}
|
||||
<button type='button' id='listViewStartButton' name='listViewStartButton' title='{$navStrings.start}' class='button' {if $prerow}onclick='return sListView.save_checks(0, "{$moduleString}");'{else} onClick='location.href="{$pageData.urls.startPage}"' {/if}>
|
||||
<img src='{sugar_getimagepath file='start.png'}' alt='{$navStrings.start}' align='absmiddle' border='0'>
|
||||
</button>
|
||||
{else}
|
||||
<button type='button' id='listViewStartButton' name='listViewStartButton' title='{$navStrings.start}' class='button' disabled='disabled'>
|
||||
<img src='{sugar_getimagepath file='start_off.png'}' alt='{$navStrings.start}' align='absmiddle' border='0'>
|
||||
</button>
|
||||
{/if}
|
||||
{if $pageData.urls.prevPage}
|
||||
<button type='button' id='listViewPrevButton' name='listViewPrevButton' title='{$navStrings.previous}' class='button' {if $prerow}onclick='return sListView.save_checks({$pageData.offsets.prev}, "{$moduleString}")' {else} onClick='location.href="{$pageData.urls.prevPage}"'{/if}>
|
||||
<img src='{sugar_getimagepath file='previous.png'}' alt='{$navStrings.previous}' align='absmiddle' border='0'>
|
||||
</button>
|
||||
{else}
|
||||
<button type='button' id='listViewPrevButton' name='listViewPrevButton' class='button' title='{$navStrings.previous}' disabled='disabled'>
|
||||
<img src='{sugar_getimagepath file='previous_off.png'}' alt='{$navStrings.previous}' align='absmiddle' border='0'>
|
||||
</button>
|
||||
{/if}
|
||||
<span class='pageNumbers'>({if $pageData.offsets.lastOffsetOnPage == 0}0{else}{$pageData.offsets.current+1}{/if} - {$pageData.offsets.lastOffsetOnPage} {$navStrings.of} {if $pageData.offsets.totalCounted}{$pageData.offsets.total}{else}{$pageData.offsets.total}{if $pageData.offsets.lastOffsetOnPage != $pageData.offsets.total}+{/if}{/if})</span>
|
||||
{if $pageData.urls.nextPage}
|
||||
<button type='button' id='listViewNextButton' name='listViewNextButton' title='{$navStrings.next}' class='button' {if $prerow}onclick='return sListView.save_checks({$pageData.offsets.next}, "{$moduleString}")' {else} onClick='location.href="{$pageData.urls.nextPage}"'{/if}>
|
||||
<img src='{sugar_getimagepath file='next.png'}' alt='{$navStrings.next}' align='absmiddle' border='0'>
|
||||
</button>
|
||||
{else}
|
||||
<button type='button' id='listViewNextButton' name='listViewNextButton' class='button' title='{$navStrings.next}' disabled='disabled'>
|
||||
<img src='{sugar_getimagepath file='next_off.png'}' alt='{$navStrings.next}' align='absmiddle' border='0'>
|
||||
</button>
|
||||
{/if}
|
||||
{if $pageData.urls.endPage && $pageData.offsets.total != $pageData.offsets.lastOffsetOnPage}
|
||||
<button type='button' id='listViewEndButton' name='listViewEndButton' title='{$navStrings.end}' class='button' {if $prerow}onclick='return sListView.save_checks("end", "{$moduleString}")' {else} onClick='location.href="{$pageData.urls.endPage}"'{/if}>
|
||||
<img src='{sugar_getimagepath file='end.png'}' alt='{$navStrings.end}' align='absmiddle' border='0'>
|
||||
</button>
|
||||
{elseif !$pageData.offsets.totalCounted || $pageData.offsets.total == $pageData.offsets.lastOffsetOnPage}
|
||||
<button type='button' id='listViewEndButton' name='listViewEndButton' title='{$navStrings.end}' class='button' disabled='disabled'>
|
||||
<img src='{sugar_getimagepath file='end_off.png'}' alt='{$navStrings.end}' align='absmiddle'>
|
||||
</button>
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
344
include/ListView/ListViewSmarty.php
Executable file
344
include/ListView/ListViewSmarty.php
Executable file
@@ -0,0 +1,344 @@
|
||||
<?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'];
|
||||
}
|
||||
|
||||
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">';
|
||||
$createxml='<input class="button" value="Stwórz XML Merlin" onclick="document.forms[\'MassUpdate\'].action.value=\'CreateXMLMerlin\';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 : '');
|
||||
return $str . $this->ss->fetch($this->tpl). (($end) ? '<br>'.$createxls.'<br>'.'<br>'.$createxml.'<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
220
include/ListView/ListViewXTPL.php
Executable 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 = " <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', " <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'")." ".$app_strings['LNK_LIST_START'];
|
||||
$prevLink = SugarThemeRegistry::current()->getImage("previous_off", "alt='".$app_strings['LNK_LIST_PREVIOUS']."' border='0' align='absmiddle'")." ".$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'")." ".$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'")." ".$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'")." ".$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'")." ".$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'")." ".$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'")." ".$app_strings['LNK_LIST_PREVIOUS']."</a>";
|
||||
// }
|
||||
}
|
||||
|
||||
if(!$this->data['pageData']['offsets']['totalCounted']) {
|
||||
$endLink = $app_strings['LNK_LIST_END']." ".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']." ".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']." ".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']." ".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']." ".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']." ".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']." ".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']." ".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." ".$prevLink." <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> ".$nextLink." ";
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user