Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once('DBC.php');
- require_once('Common.php');
- require_once('php/lang/LangVars-en.php');
- require_once('php/AjaxTableEditor.php');
- /* http://www.mysqlajaxtableeditor.com */
- // ========== Script Settings =============
- $p = isAdmin() ? "ADEFHIUOQSVX" : "";
- $str_admin = isAdmin() ? " - Logged in as Admin" : " - Not Admin - ";
- define("tblMain", "fundflow");
- define("primaryCol", "id");
- define("sortOn", "id");
- define("ascOrDesc", "ASC");
- define("displayNum", 100);
- define("displayNumInc", 100);
- define("orderByColumn", "tr_date");
- define("tableTitle", 'FundFlow ' . $str_admin);
- define("permissions", $p); //Available : ADEFHIOQSUVX
- define("addRowTitle", "Add ".tbleMain);
- define("editRowTitle", "Edit ".tbleMain);
- define("addInPlace", true);
- define("editInPlace", true);
- define("viewQuery", false);
- define("paginationLinks", true);
- class Blank extends Common
- {
- var $Editor;
- var $mateInstances = array('mate1_');
- protected function displayHtml()
- {
- $html = '
- <br />
- <div class="mateAjaxLoaderDiv">
- <div id="ajaxLoader1"><img src="images/ajax_loader.gif" alt="Loading..." />
- </div>
- </div>
- <br />
- <br />
- <div id="'.$this->mateInstances[0].'information"></div>
- <div id="mateTooltipErrorDiv" style="display: none;"></div>
- <div id="'.$this->mateInstances[0].'titleLayer" class="mateTitleDiv"></div>
- <div id="'.$this->mateInstances[0].'tableLayer" class="mateTableDiv"></div>
- <div id="'.$this->mateInstances[0].'updateInPlaceLayer" class="mateUpdateInPlaceDiv"></div>
- <div id="'.$this->mateInstances[0].'recordLayer" class="mateRecordLayerDiv"></div>
- <div id="'.$this->mateInstances[0].'searchButtonsLayer" class="mateSearchBtnsDiv"></div>
- <div style="align: center; valign: middle;"><div><center><a href="http://mukeshdak.com/apps/fundflow/">FundFlow</a></center></div></div>
- ';
- echo $html;
- // Set default session configuration variables here
- $defaultSessionData['orderByColumn'] = orderByColumn;
- $defaultSessionData['ascOrDesc'] = ascOrDesc;
- // $defaultSessionData['displayNum'] = displayNum;
- //$defaultSessionData['displayNumInc'] = displayNumInc;
- $defaultSessionData = base64_encode($this->Editor->jsonEncode($defaultSessionData));
- $javascript = '
- <script type="text/javascript">
- var ' . $this->mateInstances[0] . ' = new mate("' . $this->mateInstances[0] . '");
- ' . $this->mateInstances[0] . '.setAjaxInfo({url: "' . $_SERVER['PHP_SELF'] . '", history: true});
- ' . $this->mateInstances[0] . '.init("' . $defaultSessionData . '");
- </script>';
- echo $javascript;
- }
- function storeRow($col,$val,$row)
- {
- $_SESSION['old_row'] = $row;
- return $val;
- }
- function logEdit($val,$col,$row)
- {
- $changes = array();
- foreach($row as $col => $val)
- {
- if(isset($_SESSION['old_row'][$col]) && $_SESSION['old_row'][$col] != $val)
- {
- $changes[] = $col.' changed from '.$_SESSION['old_row'][$col].' to '.$val;
- }
- }
- if(count($changes) > 0)
- {
- // log changes
- $log_file_name = basename(__FILE__, ".php")."_".date("Y-m").".csv" ;
- $change_time = date("Y-m-d_H-i-s");
- $file = fopen($log_file_name, "a");
- $changes = "\n". $change_time." Changes by ".$_SESSION['oauth_user']['email']." for " . primaryCol . ": ". $_SESSION['old_row'][primaryCol] . " are ".implode(", ", $changes);
- fwrite ($file, $changes);
- fclose($file);// log changes
- }
- }
- protected function initiateEditor()
- {
- $tableColumns['id'] = array(
- 'display_text' => 'ID',
- 'perms' => 'TVQFSXO',
- 'view_fun' => array(&$this,'showDeleteOnEdit')
- );
- $tableColumns['tr_name'] = array(
- 'display_text' => 'Transaction Name',
- 'perms' => 'AEVCTXQSHOF'
- );
- $tableColumns['tr_date'] = array(
- 'display_text' => 'Tr Date',
- 'perms' => 'AEFVCTXQSHO',
- 'display_mask' => 'date_format(tr_date,"%d %M %Y")',
- 'order_mask' => 'date_format(tr_date,"%Y-%m-%d %T")',
- 'calendar' => array('js_format' => 'dd MM yy')
- );
- $tableColumns['tr_value'] = array(
- 'display_text' => 'Value',
- 'perms' => 'AEVCTAXQSHOF',
- 'input_info' => 'size="32"',
- 'table_fun' => array(&$this,'limit_characters'),
- 'edit_fun' => array(&$this,'storeRow')
- );
- $tableColumns['notes'] = array(
- 'display_text' => 'Notes',
- 'perms' => 'EVCTAXQSFHO',
- 'textarea' => array('cols' => 40, 'rows' => 3),
- 'sub_str' => 30
- );
- $tableColumns['modified'] = array(
- 'display_text' => 'Modified',
- 'perms' => 'VCXQSHO',
- 'display_mask' => 'date_format(modified,"%d %M %Y")',
- 'calendar' => array('js_format' => 'dd MM yy')
- );
- $errorFun = array(&$this,'logError');
- $this->Editor = new AjaxTableEditor(tblMain, primaryCol, $errorFun, permissions, $tableColumns);
- $this->Editor->setConfig('tableInfo','cellpadding="1" cellspacing="1" align="center" class="mateTable"'); /* width="90%" */
- $this->Editor->setConfig('orderByColumn', orderByColumn);
- $this->Editor->setConfig('removeIcons', "CD");
- $this->Editor->setConfig('tableTitle', tableTitle);
- $this->Editor->setConfig('addRowTitle', addRowTitle);
- $this->Editor->setConfig('editRowTitle', editRowTitle);
- $this->Editor->setConfig('addInPlace', addInPlace);
- $this->Editor->setConfig('editInPlace', editInPlace);
- $this->Editor->setConfig('viewQuery', viewQuery);
- $this->Editor->setConfig('paginationLinks', paginationLinks);
- $this->Editor->setConfig('instanceName',$this->mateInstances[0]);
- $this->Editor->setConfig('afterDeleteFun', array(&$this, 'refreshAfterDelete'));
- $this->Editor->setConfig('afterEditFun',array(&$this,'logEdit'));
- // $this->Editor->setConfig('modifyRowSets',array(&$this,'changeBgColor'));
- $this->Editor->setConfig('storageType','web');
- // $userButtons[] = array('label' => 'Show Info', 'call_back_fun' => array(&$this,'testUserBtn'));
- // $this->Editor->setConfig('userButtons',$userButtons);
- //$this->Editor->setConfig('escapeHtml',true);
- }
- function __construct()
- {
- session_start();
- ob_start();
- $this->initiateEditor();
- if(isset($_POST['json']))
- {
- if(ini_get('magic_quotes_gpc'))
- {
- $_POST['json'] = stripslashes($_POST['json']);
- }
- $this->Editor->data = $this->Editor->jsonDecode($_POST['json'],true);
- $this->Editor->setDefaults();
- $this->Editor->main();
- }
- else if(isset($_GET['mate_export']))
- {
- $this->Editor->data['sessionData'] = $_GET['session_data'];
- $this->Editor->setDefaults();
- ob_end_clean();
- header('Cache-Control: no-cache, must-revalidate');
- header('Pragma: no-cache');
- header('Content-type: application/x-msexcel');
- header('Content-Type: text/csv');
- header('Content-Disposition: attachment; filename="' . $this->Editor->tableName . '.csv"');
- // Add utf-8 signature for windows/excel
- echo chr(0xEF).chr(0xBB).chr(0xBF);
- echo $this->Editor->exportInfo();
- exit();
- }
- else
- {
- $this->allowIfLoggedIn();
- $this->displayHeaderHtml();
- $this->displayHtml();
- $this->displayFooterHtml();
- }
- }
- }
- $page = new Blank();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement