CoolFace
Apppublic

kenken999/php

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
listpage_dashboard.php388 linesDownload Raw Back to classes
1<?php2 3class ListPage_Dashboard extends ListPage_Embed4{5	public $showNoData = false;6 7	/**8	 * @constructor9	 * @param array params10	 */11	function __construct(&$params)12	{13		parent::__construct($params);14		$this->showAddInPopup = true;15 16		$this->formBricks["header"] = array(17			array( "name" => "details_block", "align" => "right" ),18			array( "name" => "newrecord_controls_block", "align" => "right" ),19			array( "name" => "record_controls_block", "align" => "right" ),20			array( "name" => "details_found", "align" => "right" )21		);22 23		$this->formBricks["footer"] = array( "pagination_block" );24 25		if( $this->mapRefresh )26			$this->pageSize = -1;27 28		$this->listAjax = false;29	}30 31	/**32	 * Assign seesion prefix33	 */34	protected function assignSessionPrefix()35	{36		$this->sessionPrefix = $this->dashTName."_".$this->dashElementName;37	}38 39	/**40	 * Fill table settings41	 * @intellisense42	 */43	protected function fillTableSettings( $table = "", $pSet = null )44	{45		parent::fillTableSettings( $table, $pSet );46 47		if( $this->addAvailable() )48			$this->jsSettings["tableSettings"][ $this->tName ]["showAddInPopup"] = true;49 50		if( $this->editAvailable() || $this->updateSelectedAvailable() )51			$this->jsSettings["tableSettings"][ $this->tName ]["showEditInPopup"] = true;52 53		if( $this->viewAvailable() )54			$this->jsSettings["tableSettings"][ $this->tName ]["showViewInPopup"] = true;55 56		if( $this->inlineEditAvailable() )57			$this->jsSettings["tableSettings"][ $this->tName ]["inlineEditAvailable"] = true;58	}59 60	/**61	 * Checks if need to display grid62	 */63	function isDispGrid()64	{65		return $this->permis[ $this->tName ]['search'];66	}67 68	function addCommonJs()69	{70		$this->addJsForGrid();71		$this->addControlsJSAndCSS();72		$this->addButtonHandlers();73	}74 75	function addJsForGrid()76	{77		if( $this->isResizeColumns )78			$this->prepareForResizeColumns();79 80		$this->jsSettings['tableSettings'][ $this->tName ]['showRows'] = ($this->numRowsFromSQL ? true : false);81	}82 83	function prepareForResizeColumns()84	{85		parent::prepareForResizeColumns();86 87		include_once getabspath("classes/paramsLogger.php");88		$logger = new paramsLogger( $this->dashTName."_".$this->dashElementName, CRESIZE_PARAMS_TYPE );89 90		$columnsData = $logger->getData();91		if( $columnsData )92			$this->pageData[ "resizableColumnsData" ] = $columnsData;93	}94 95	function commonAssign()96	{97		parent::commonAssign();98		$this->xt->assign("details_block", true);99		$this->xt->assign("withSelected", $this->inlineEditAvailable() || $this->deleteAvailable() );100 101		$this->hideElement("printpanel");102	}103 104	protected function prepareBreadcrumbs() {105		//	do nothing106	}107 108	public function getSubsetDataCommand( $ignoreFilterField = "" ) {109		$dc = parent::getSubsetDataCommand();110 111		if( $this->showNoData ) {112			$dc->filter = DataCondition::_False();113		}114		return $dc;115	}116 117	/**118	 *119	 */120	function showPage()121	{122		$this->BeforeShowList();123 124		$this->prepareGridTabs();125 126		$this->xt->prepare_template($this->templatefile);127		$this->showPageAjax();128	}129 130	/**131	 * Display blocks after loaded template of page132	 */133	function showPageAjax()134	{135		$this->addControlsJSAndCSS();136		$this->fillSetCntrlMaps();137 138		global $pagesData;139 140		$returnJSON = array();141		$returnJSON["pagesData"] = $pagesData;142		$returnJSON['controlsMap'] = $this->controlsHTMLMap;143		$returnJSON['viewControlsMap'] = $this->viewControlsHTMLMap;144		$returnJSON['settings'] = $this->jsSettings;145 146		$this->xt->assign("header",false);147		$this->xt->assign("footer",false);148 149		$this->hideForm("above-grid");150		$returnJSON["html"] = $this->fetchBlocksList( array( "above-grid_block", "grid_tabs", "grid_block" ) );151		152		if ( $this->mode == LIST_DASHDETAILS 153			&& $this->dashElementData["item"]["customLabel"]154			&& $this->dashElementData["item"]["dashLabel"] ) {155				156			$returnJSON['headerCont'] = '<span class="rnr-dbebrick">'157				. GetMLString( $this->dashElementData["item"]["dashLabel"] )158				. "</span>";			159		} else {160			$returnJSON['headerCont'] = '<span class="rnr-dbebrick">'161				. $this->getPageTitle( $this->pageName, GoodFieldName($this->tName) )162				. "</span>";			163		}164	165		$returnJSON["footerCont"] = $this->fetchForms( array( "below-grid" ) );166		$icon = getIconHTML( $this->dashElementData["item"]["icon"] );167		if( $icon )168			$returnJSON["iconHtml"] = $icon;169 170 171		$returnJSON['idStartFrom'] = $this->flyId;172		$returnJSON['success'] = true;173 174		$returnJSON["additionalJS"] = $this->grabAllJsFiles();175		$returnJSON["CSSFiles"] = $this->grabAllCSSFiles();176 177		echo printJSON($returnJSON);178	}179 180	function fillSetCntrlMaps()181	{182		parent::fillSetCntrlMaps();183		$this->controlsHTMLMap[ $this->tName ][ $this->pageType ][ $this->id ]["pageNumber"] = $this->myPage;184		$this->controlsHTMLMap[ $this->tName ][ $this->pageType ][ $this->id ]["numberOfPages"] = $this->maxPages;185	}186 187	function fillCheckAttr(&$record, $data, $keyblock)188	{189		if( $this->deleteAvailable() || $this->inlineEditAvailable() || $this->updateSelectedAvailable() )190			$record["checkbox"] = true;191 192		$record["checkbox_attrs"]= "name=\"selection[]\" value=\"".runner_htmlspecialchars($keyblock)."\" id=\"check".$this->id."_".$this->recId."\"";193	}194 195	function deleteAvailable() {196		return parent::deleteAvailable() && $this->dashElementData["deleteRecord"];197	}198 199	function editAvailable() {200		return parent::editAvailable() && $this->dashElementData["popupEdit"];201	}202 203	function copyAvailable() {204		return parent::copyAvailable() && $this->dashElementData["copy"];205	}206 207	function addAvailable() {208		return parent::addAvailable() && $this->dashElementData["popupAdd"];209	}210 211	function inlineEditAvailable() {212		return parent::inlineEditAvailable() && $this->dashElementData["inlineEdit"];213	}214 215	function inlineAddAvailable() {216		return parent::inlineAddAvailable() && $this->dashElementData["inlineAdd"];217	}218 219	function updateSelectedAvailable() {220		return parent::updateSelectedAvailable() && $this->dashElementData["updateSelected"];221	}222 223	function viewAvailable() {224		return parent::viewAvailable() && $this->dashElementData["popupView"];225	}226 227 228	/**229	 * @return Boolean230	 */231	protected function hasDependentDashMapElem()232	{233		foreach( $this->dashSet->getDashboardElements() as $dElem )234		{235			if( $dElem["table"] == $this->tName && $dElem["type"] == DASHBOARD_MAP && !$dElem["updateMoved"] )236				return true;237		}238 239		return false;240	}241 242	/**243	 * @return Boolean244	 */245	protected function hasMainDashMapElem()246	{247		foreach( $this->dashSet->getDashboardElements() as $dElem )248		{249			if( $dElem["table"] == $this->tName && $dElem["type"] == DASHBOARD_MAP && $dElem["updateMoved"] )250				return true;251		}252 253		return false;254	}255 256	/**257	 * @return Boolean258	 */259	protected function hasBigMap()260	{261		return parent::hasBigMap() || $this->hasDependentDashMapElem();262	}263 264	/**265	 * @param &Array data266	 * @param Array keys267	 * @param String editLink268	 */269	function addBigGoogleMapMarkers(&$data, $keys, $editLink = '')270	{271		parent::addBigGoogleMapMarkers( $data, $keys, $editLink );272 273		foreach( $this->dashSet->getDashboardElements() as $dElem )274		{275			if( $dElem["elementName"] == $this->dashElementName || $dElem["table"] != $this->tName || $dElem["type"] != DASHBOARD_MAP || $dElem["updateMoved"] )276				continue;277 278			$markerData = array();279 280			$markerData["lat"] = str_replace( ",", ".", ($data[ $dElem["latF"] ] ? $data[ $dElem["latF"] ] : "") );281			$markerData["lng"] = str_replace( ",", ".", ($data[ $dElem["lonF"] ] ? $data[ $dElem["lonF"] ] : "") );282			$markerData["address"] = $data[ $dElem["addressF"] ] ? $data[ $dElem["addressF"] ] : "";283			$markerData["desc"] = $data[ $dElem["descF"] ] ? $data[ $dElem["descF"] ] : $markerData["address"];284			$markerData["mapIcon"] = $this->dashSet->getDashMapIcon( $dElem["elementName"], $data );285 286			$markerData["recId"] = $this->recId;287			$markerData["keys"] = $keys;288 289			$markerData["masterKeys"] = $this->getDetailTablesMasterKeys( $data );290 291			$mapId = GoodFieldName( $this->dashTName )."_".$dElem["elementName"]."_dashMap";292 293			if( !isset( $this->googleMapCfg["mapsData"][ $mapId ] ) )294			{295				$this->googleMapCfg["mapsData"][ $mapId ] = array();296				$this->googleMapCfg["mapsData"][ $mapId ]["skipped"] = true;297				$this->googleMapCfg["mapsData"][ $mapId ]["dashMap"] = true;298				$this->googleMapCfg["mapsData"][ $mapId ]["heatMap"] = $dElem["heatMap"];299			}300 301			if( !isset( $this->googleMapCfg["mapsData"][ $mapId ]["markers"] ) )302				$this->googleMapCfg["mapsData"][ $mapId ]["markers"] = array();303 304			if( $markerData["lat"] == "" || $markerData["lng"] == "" )305				continue;306 307			$this->googleMapCfg['mapsData'][ $mapId ]['markers'][] = $markerData;308		}309	}310 311	protected function isInlineAreaToSet()312	{313		if( $this->mode == LIST_DASHBOARD )314			return true;315 316		return parent::isInlineAreaToSet();317	}318 319	/**320	 * A stub321	 */322	function rulePRG() {}323 324	/**325	 * A stub326	 */327	function buildSearchPanel() {}328	public function assignSimpleSearch() {}329 330 331	/**332	 *333	 */334	function printAvailable()335	{336		return false;337	}338 339	function getTabDataCommand( $tab )340	{341		$this->skipMapFilter = true;342		$dc = parent::getTabDataCommand( $tab );343		$this->skipMapFilter = false;344		return $dc;345	}346 347	public function setGoogleMapsParams( $params ) {348		parent::setGoogleMapsParams( $params );349		$this->googleMapCfg['isUseMainMaps'] = false;350	}351 352	function addCenterLink(&$value, $fName) {353		return $value;354	}355 356	function inDashboardMode() {357		return true;358	}359	function dependsOnDashMap() {360		return $this->hasMainDashMapElem() && $this->mapRefresh;361	}362 363	protected function detailInGridAvailable( $detailTableData ) {364		$detTable = $detailTableData['dDataSourceTable'];365		if( $this->pSet->detailsPreview( $detTable ) == DP_NONE ) {366			return false;367		}368 369		return true;370	}371 372	protected function proceedLinkAvailable( $dTable ) {373		return false;374	}375 376	protected function detailsHrefAvailable() {377		return false;378	}379 380	function displayTabsInPage()381	{382		return $this->dashElementData["tabLocation"] == "body";383 384	}385 386 387}388?>