';
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 = '
';
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();
?>