WStudio Posted May 2, 2011 Share Posted May 2, 2011 Hi, I need some help with my coding. Mate (MySQL Ajax Table Editor) is a grid system. There are 4 files that the grid needs to work: - Index.php: the page to display the grid (the grid configurations) - AjaxTableEditor.php: the PHP classes for the grid - ajax_table_editor.js: the javascript to handle the Ajax functions - Common.php: not sure what to call this file, but it hold the header of the grid pages. I've managed to load my tables but having problems with the follow areas: 1) Master/Detail (pop up): The developer provided the codes to make this happen, but he never seems to be able to tell where to put the codes and how to configure it. Anyway, after working on it, I figured out where the most of the codes should go and now it pops up. Only, it pops up in a new window instead of a lightbox. My tables/grids: - TableA: holds the Customers details. - TableB: holds the Jobs that the customers posted by the customers to be done. A Job could have multiple tasks - TableC: holds the Workers detials. - TableD: holds the Tasks for the Jobs. My Grid for TableB. When I click on a row, I what the Tasks for that job to show up in the popup. Right now, ALL the jobs shows up. Master Gird: sns-prm.php (the index.php): <?php /* * Mysql Ajax Table Editor * * Copyright (c) 2008 Chris Kitchen <info@mysqlajaxtableeditor.com> * All rights reserved. * * See COPYING file for license information. * * Download the latest version from * http://www.mysqlajaxtableeditor.com */ require_once('sns-common.php'); require_once('php/lang/LangVars-en.php'); require_once('php/AjaxTableEditor.php'); class Example1 extends Common { var $Editor; function displayHtml() { ?> <br /> <div align="left" style="position: relative;"><div id="ajaxLoader1"><img src="images/ajax_loader.gif" alt="Loading..." /></div></div> <br /> <div id="historyButtonsLayer" align="left"> </div> <div id="cm-header"><h1>Shop n Ship Jamaica</h1><h3>Purchase Request Manager</h3></div> <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="searchButtonsLayer" align="center"> </div> <div id="tableLayer" align="center"> </div> <div id="recordLayer" align="center"> </div> </div> <script type="text/javascript"> trackHistory = true; var ajaxUrl = '<?php echo $_SERVER['PHP_SELF']; ?>'; toAjaxTableEditor('update_html',''); </script> <?php } function initiateEditor() { $tableColumns['PRID'] = array('display_text' => 'PR ID', 'perms' => 'TVQSXO'); $tableColumns['SNSID'] = array('display_text' => 'SNS ID', 'perms' => 'EVTAXQSHO'); $tableColumns['RequestDate'] = array('display_text' => 'Request Date', 'perms' => 'VTXQSHO', 'display_mask' => 'date_format(RequestDate,"%d %M %Y")', 'calendar' => '%d %B %Y'); $tableColumns['PaymentCodes'] = array('display_text' => 'Transaction #', 'perms' => 'EVTAXQSHO'); $tableColumns['StatusID'] = array('display_text' => 'Status', 'perms' => 'VTEAXQSHO', 'join' => array('table' => 'cm_status', 'column' => 'StatusID', 'display_mask' => "Status", 'type' => 'left')); $tableColumns['UJID'] = array('display_text' => 'Agent', 'perms' => 'EVAXQSHO', 'join' => array('table' => 'cm_users', 'column' => 'user_id', 'display_mask' => "concat(cm_users.first_name,' ',cm_users.last_name)", 'type' => 'left')); $tableColumns['ProcessDate'] = array('display_text' => 'Process Date', 'perms' => 'EVTAXQSHO', 'display_mask' => 'date_format(ProcessDate,"%d %M %Y")', 'calendar' => '%d %B %Y'); $tableName = 'cm_requests'; $primaryCol = 'PRID'; $errorFun = array(&$this,'logError'); $permissions = 'EAVIDQSXHO'; $this->Editor = new AjaxTableEditor($tableName,$primaryCol,$errorFun,$permissions,$tableColumns); $this->Editor->setConfig('tableInfo','cellpadding="1" width="98%" class="mateTable"'); $this->Editor->setConfig('orderByColumn','PRID'); $this->Editor->setConfig('ascOrDesc','desc'); $this->Editor->setConfig('addRowTitle','Add Log Entry'); $this->Editor->setConfig('editRowTitle','Edit Log Entry'); //$this->Editor->setConfig('iconTitle','Edit Employee'); // This goes in the initiate editor function $userActions = array('show_row_details' => array(&$this,'showRowDetails')); $this->Editor->setConfig('userActions',$userActions); $this->Editor->setConfig('extraRowInfo','onclick="showRowDetails(\'#primaryColValue#\',\'#rowNum#\');" style="cursor: pointer;"'); } function Example1() { if(isset($_POST['json'])) { session_start(); // Initiating lang vars here is only necessary for the logError, and mysqlConnect functions in Common.php. // If you are not using Common.php or you are using your own functions you can remove the following line of code. $this->langVars = new LangVars(); $this->mysqlConnect(); 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'])) { session_start(); ob_start(); $this->mysqlConnect(); $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="'.$this->Editor->tableName.'.csv"'); exit(); } else { $this->displayHeaderHtml(); $this->displayHtml(); $this->displayFooterHtml(); } } } $lte = new Example1(); ?> Detail Grid: sns-prim.php (the index.php): <?php /* * Mysql Ajax Table Editor * * Copyright (c) 2008 Chris Kitchen <info@mysqlajaxtableeditor.com> * All rights reserved. * * See COPYING file for license information. * * Download the latest version from * http://www.mysqlajaxtableeditor.com */ require_once('sns-common.php'); require_once('php/lang/LangVars-en.php'); require_once('php/AjaxTableEditor.php'); class Example1 extends Common { var $Editor; function displayHtml() { ?> <br /> <div align="left" style="position: relative;"><div id="ajaxLoader1"><img src="images/ajax_loader.gif" alt="Loading..." /></div></div> <br /> <div id="historyButtonsLayer" align="left"> </div> <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="searchButtonsLayer" align="center"> </div> <div id="tableLayer" align="center"> </div> <div id="recordLayer" align="center"> </div> </div> <script type="text/javascript"> trackHistory = false; var ajaxUrl = '<?php echo $_SERVER['PHP_SELF']; ?>'; toAjaxTableEditor('update_html',''); </script> <?php } function initiateEditor() { $tableColumns['PRIID'] = array('display_text' => 'PRI ID', 'perms' => 'TVQSXO'); $tableColumns['SNSID'] = array('display_text' => 'SNS ID', 'perms' => 'VTXQSHO'); $tableColumns['PRID'] = array('display_text' => 'PR ID', 'perms' => 'TVQSXO'); $tableColumns['ItemURL'] = array('display_text' => 'Item URL', 'perms' => 'VTXQSHO'); $tableColumns['ItemDesc'] = array('display_text' => 'Description', 'perms' => 'VTXQSHO'); $tableColumns['ItemQty'] = array('display_text' => 'Qty', 'perms' => 'VTXQSHO'); $tableColumns['ItemCost'] = array('display_text' => 'Unit Cost', 'perms' => 'VTXQSHO'); $tableColumns['ItemTax'] = array('display_text' => 'Sale Tax', 'perms' => 'VXQSHO'); $tableColumns['ItemShipCost'] = array('display_text' => 'Shipping Cost', 'perms' => 'VXQSHO'); $tableColumns['ItemTotalCost'] = array('display_text' => 'Total Cost', 'perms' => 'VXQSHO'); $tableColumns['ItemWeight'] = array('display_text' => 'Weight', 'perms' => 'VXQSHO'); $tableColumns['ItemLength'] = array('display_text' => 'Length', 'perms' => 'VXQSHO'); $tableColumns['ItemWidth'] = array('display_text' => 'Width', 'perms' => 'VXQSHO'); $tableColumns['ItemHeight'] = array('display_text' => 'Height', 'perms' => 'VXQSHO'); $tableColumns['Instructions'] = array('display_text' => 'Instructions', 'perms' => 'VXQSHO'); $tableColumns['StatusID'] = array('display_text' => 'Status', 'perms' => 'VTEAXQSHO', 'join' => array('table' => 'cm_status', 'column' => 'StatusID', 'display_mask' => "Status", 'type' => 'left')); $tableName = 'cm_request_items'; $primaryCol = 'PRIID'; $errorFun = array(&$this,'logError'); $permissions = 'VIQSXHO'; $this->Editor = new AjaxTableEditor($tableName,$primaryCol,$errorFun,$permissions,$tableColumns); $this->Editor->setConfig('tableInfo','cellpadding="1" width="98%" class="mateTable"'); $this->Editor->setConfig('orderByColumn','PRIID'); $this->Editor->setConfig('ascOrDesc','asc'); //$this->Editor->setConfig('addRowTitle','Add Log Entry'); //$this->Editor->setConfig('editRowTitle','Edit Log Entry'); //$this->Editor->setConfig('iconTitle','Edit Employee'); if(isset($_GET['client_id'])) { $this->Editor->setConfig('sqlFilters',"cm_request_items.PRID = '".$_GET['client_id']."'"); } } function Example1() { if(isset($_POST['json'])) { session_start(); // Initiating lang vars here is only necessary for the logError, and mysqlConnect functions in Common.php. // If you are not using Common.php or you are using your own functions you can remove the following line of code. $this->langVars = new LangVars(); $this->mysqlConnect(); 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'])) { session_start(); ob_start(); $this->mysqlConnect(); $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="'.$this->Editor->tableName.'.csv"'); exit(); } else { $this->displayHeaderHtml(); $this->displayHtml(); //$this->displayFooterHtml(); } } } $lte = new Example1(); ?> These are the codes that the developer gave: To be added to the master grid page: // This goes in the initiate editor function $userActions = array('show_row_details' => array(&$this,'showRowDetails')); $this->Editor->setConfig('userActions',$userActions); $this->Editor->setConfig('extraRowInfo','onclick="showRowDetails(\'#primaryColValue#\',\'#rowNum#\');" style="cursor: pointer;"'); To be added to AjaxTableEditor.php: // php function function showRowDetails($info) { // Select and format row details here $html = '<tr id="'.$info->rowNum.'_row_details" style="display: table-row;"><td colspan="99">Row details for id '.$info->id.' go here</td></tr>'; $this->Editor->retArr[] = array('where' => 'javascript', 'value' => '$(\'row_'.$info->rowNum.'\').insert({after: \''.$html.'\'});'); } To be added to ajax_table_editor.js: // javascript function function showRowDetails(id,rowNum) { var info = {id: id, rowNum: rowNum}; if($(rowNum+'_row_details') != null) { $(rowNum+'_row_details').remove(); } else { toAjaxTableEditor('show_row_details',info); } } Alternative code for the ajax_table_editor.js file to be used instead of the one above: /// javascript function function showRowDetails(id,rowNum) { window.open('RowDetails.php?id='+id,'detail_popup','toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=800,height=600,left=100,top=100'); } I sent him a private message about this problem and he sent me this piece of code but with no instructions as to what to do with it: if(isset($_GET['client_id'])) { $this->Editor->setConfig('sqlFilters',"client_id = '".$_GET['client_id']."'"); } 2) There are some tables that I need to join to the main tables to get certain information. For instance (from my Tables examples above), I want to add the customer and the worker's name to the Detail grid view. TableA doesn't have a column for the TableC ID, but TableC has the TableA ID. With this grid system I can join TableA and TableC to TableB easily, but I need to join TableD to TableA to get the name of the Customer. Please help!! I'm almost out of time on this part of the project and the developer of Mate seems to be very busy. - Mate download page (free version): http://www.mysqlajaxtableeditor.com/GetMateNow.php - Mate forum page: http://www.mysqlajaxtableeditor.com/discussmate/index.php Best Regards, ___________ Winchester Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.