<?php
require_once('Common.php');
require_once(
'../shared/php/mate/php/lang/LangVars-en.php');
require_once(
'../shared/php/mate/php/AjaxTableEditor.php');
class 
Example1 extends Common
{

    var 
$loginTable;
    var 
$empTable;

    function 
displayHtml()
    {
        
?>    
        <!-- start content -->
        <div id="content">
            <div class="flower"></div>
            <div class="post">
                <h1 class="title title-big">Simple Demo</h1>
                <div class="entry">
    
                    <div><a target="_blank" href="ShowSourceCode.php?file_name=Example1.php">Configuration File Source</a></div>
                    <div><a target="_blank" href="ShowTableData.php?table_name=<?=$this->empTable?>">Raw Table Data</a></div>
                    <div><a href="Example2.php">Join Demo</a></div>
    
                    <div align="left" style="position: relative;"><div id="ajaxLoader1"><img src="http://www.marketingemailautomator.com/shared/images/ajax_loader.gif" alt="Loading..." /></div></div>
                    
                    <div id="historyButtonsLayer" align="left">
                    </div>
                    <br />
                    <div id="historyContainer">
                        <div id="information">
                        </div>
                
                        <div id="titleLayer" style="padding: 2px; font-weight: bold; font-size: 18px; text-align: center;">
                        </div>
                
                        <div id="tableLayer" align="center">
                        </div>
                        
                        <div id="recordLayer" align="center">
                        </div>        
                        
                        <div id="searchButtonsLayer" align="center">
                        </div>
                    </div>
                </div>
            </div>
            <br /><br /><br />
        </div>
        <!-- end content --> 
        
        <script type="text/javascript">
            trackHistory = false;
            var ajaxUrl = '<?php echo $_SERVER['PHP_SELF']; ?>';
            toAjaxTableEditor('update_html','');
        </script>
            
        <?php
    
}
    
    function 
initiateEditor()
    {
        
$tableColumns['id'] = array('display_text' => 'ID''perms' => 'TVQSXO');
        
$tableColumns['first_name'] = array('display_text' => 'First Name''perms' => 'EVCTAXQSHO');
        
$tableColumns['last_name'] = array('display_text' => 'Last Name''perms' => 'EVCTAXQSHO');
        
$tableColumns['email'] = array('display_text' => 'Email''perms' => 'EVCTAXQSHO');
        
$tableColumns['department'] = array('display_text' => 'Department''perms' => 'EVCTAXQSHO''select_array' => array('Accounting' => 'Accounting''Marketing' => 'Marketing''Sales' => 'Sales''Production' => 'Production')); 
        
$tableColumns['hire_date'] = array('display_text' => 'Hire Date''perms' => 'EVCTAXQSHO''display_mask' => 'date_format(hire_date,"%d %M %Y")''calendar' => array('format' => '%d %B %Y''reset' => true),'col_header_info' => 'style="width: 250px;"'); 
        
        
$tableName $this->empTable;
        
$primaryCol 'id';
        
$errorFun = array(&$this,'logError');
        
$permissions 'EAVIDQCSXHO';
        
        
$this->Editor = new AjaxTableEditor($tableName,$primaryCol,$errorFun,$permissions,$tableColumns);
        
$this->Editor->setConfig('tableInfo','cellpadding="1" width="900" class="mateTable"');
        
$this->Editor->setConfig('orderByColumn','first_name');
        
$this->Editor->setConfig('addRowTitle','Add Employee');
        
$this->Editor->setConfig('editRowTitle','Edit Employee');
        
$this->Editor->setConfig('tableTitle','Employees');
    }
    
    
    
    function 
Example1()
    {
        
$this->mysqlConnect();
        
$this->startSession();
        
$this->setTableNames();
        
$this->checkForTables();
        if(isset(
$_POST['json']))
        {
            if(
ini_get('magic_quotes_gpc'))
            {
                
$_POST['json'] = stripslashes($_POST['json']);
            }
            if(
function_exists('json_decode'))
            {
                
$data json_decode($_POST['json']);
            }
            else
            {
                require_once(
'php/JSON.php');
                
$js = new Services_JSON();
                
$data $js->decode($_POST['json']);
            }
            if(empty(
$data->info) && strlen(trim($data->info)) == 0)
            {
                
$data->info '';
            }
            
$this->initiateEditor();
            
$this->Editor->main($data->action,$data->info);
            if(
function_exists('json_encode'))
            {
                echo 
json_encode($this->Editor->retArr);
            }
            else
            {
                echo 
$js->encode($this->Editor->retArr);
            }
        }
        else if(isset(
$_GET['export']))
        {
            
$this->initiateEditor();
            echo 
$this->Editor->exportInfo();
            
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="employees.csv"');
            exit();
        }
        else
        {
            
$this->dispAds false;
            
$this->displayHeaderHtml();
            
$this->displayHtml();
            
$this->displayFooterHtml();
        }
    }
}
$lte = new Example1();
?>
1