<?php 
$form_name = "User Privilages";
$table_name = "custom_menu_access";
$primary_key = "mnu_acs_id";

$mode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : "";
	
include_once("includes/config.php");
include_once("includes/common_functions.php");

$common = new General_Functions();
$css_class = "x-gray";
// $common->SetCssClass($css_class);

$mode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : "";
$act_type = isset($_REQUEST['act_type']) ? $_REQUEST['act_type'] : "";
$cancel_link = $_SERVER['SCRIPT_NAME'].'?page='.$_REQUEST['page'];
$action = $_SERVER['SCRIPT_NAME']."?page=".$_REQUEST['page']."&mode=submit";

switch($mode)
{
	default:
                $query = "SELECT * FROM ".$table_name." INNER JOIN custom_main_menu ON (custom_main_menu.min_mnu_id = ".$table_name.".min_mnu_id_fk)";
		$common->sql->query($query, SQL_ALL, SQL_ASSOC);
		$rec = $common->sql->record;
		?>
                <link rel="stylesheet" href="includes/media/css/demo_page.css" type="text/css" />
                <link rel="stylesheet" href="includes/media/css/demo_table.css" type="text/css" />
		<script type="text/javascript" language="javascript" src="includes/media/js/jquery.js"></script>
		<script type="text/javascript" language="javascript" src="includes/media/js/jquery.dataTables.js"></script>
                <script type="text/javascript" charset="utf-8">
			var asInitVals = new Array();
			
			$(document).ready(function() {
				var oTable = $('#example').dataTable( {
					"bJQueryUI": true,
					"sPaginationType": "full_numbers",
				} );
				
				$("thead input").keyup( function () {
					oTable.fnFilter( this.value, $("thead input").index(this) );
				} );
				
				$("thead input").each( function (i) {
					asInitVals[i] = this.value;
				} );
				
				$("thead input").focus( function () {
					if ( this.className == "search_init" )
					{
						this.className = "";
						this.value = "";
					}
				} );
				
				$("thead input").blur( function (i) {
					if ( this.value == "" )
					{
						this.className = "search_init";
						this.value = asInitVals[$("thead input").index(this)];
					}
				} );
				
				$(".fg-toolbar").height(40);
				$(".dataTables_length").hide();
				$(".dataTables_filter").hide();
				$("#example_info").hide();
				
				$('#example tbody tr').live('click', function () {
					var frmval = new Array();
                                        var nTds = $('td', this);
                                        var row = $(nTds[0]).text();
					var frmval = new Array();
					// alert('Row: ' + row + ', Column: ' + col);
					
					j = row;
					sub_mnu_id = '#sub_mnu_id_'+j;
					min_mnu_id_fk = '#min_mnu_id_fk_'+j;
					sub_mnu_name = '#sub_mnu_name_'+j;
					sub_mnu_desc = '#sub_mnu_desc_'+j;
					sub_mnu_preference = '#sub_mnu_preference_'+j;
					status = '#status_'+j;
					frmval["sub_mnu_id"] = $(sub_mnu_id).val();
					frmval["min_mnu_id_fk"] = $(min_mnu_id_fk).val();
					frmval["sub_mnu_name"] = $(sub_mnu_name).val();
					frmval["sub_mnu_desc"] = $(sub_mnu_desc).val();
					frmval["sub_mnu_preference"] = $(sub_mnu_preference).val();
					frmval["status"] = $(status).val();
                                        
					parent.frm_edit_val(frmval);
				});
			} );
		</script>
        <br /><br />
        <div id="demo" style="width: 95%; margin: 0 auto;">
            <form name="view" method="post">
                <table cellpadding="0" cellspacing="0" border="0" class="display" id="example" width="100%">
                    <thead>
                        <tr>
                            <th style="display: none;">&nbsp;</th>
                            <th>Main Menu</th>
                            <th>Sub Menu Name</th>
                            <th>Sub Menu Title</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                            $part_id = "";
                            
                            for($i=0; $i<count($rec); $i++)
                            {
                                echo '<tr>
                                        <td style="display: none;">'.$i.'</td>
                                        <td>
                                            '.$rec[$i]['min_mnu_desc'].'
                                            <input type="hidden" name="sub_mnu_id" id="sub_mnu_id_'.$i.'" value="'.$rec[$i]['sub_mnu_id'].'" />
                                            <input type="hidden" name="min_mnu_id_fk" id="min_mnu_id_fk_'.$i.'" value="'.$rec[$i]['min_mnu_id_fk'].'" />
                                            <input type="hidden" name="sub_mnu_name" id="sub_mnu_name_'.$i.'" value="'.$rec[$i]['sub_mnu_name'].'" />
                                            <input type="hidden" name="sub_mnu_desc" id="sub_mnu_desc_'.$i.'" value="'.$rec[$i]['sub_mnu_desc'].'" />
                                            <input type="hidden" name="sub_mnu_preference" id="sub_mnu_preference_'.$i.'" value="'.$rec[$i]['sub_mnu_preference'].'" />
                                            <input type="hidden" name="status" id="status_'.$i.'" value="'.$rec[$i]['status'].'" />
                                        </td>
                                        <td>'.$rec[$i]['sub_mnu_name'].'</td>
                                        <td>'.$rec[$i]['sub_mnu_desc'].'</td>
                                    </tr>';
                            }
                        ?>
                    </tbody>
                    <thead>
                        <tr>
                            <th style="display: none;"><input type="text" name="search_engine" value="Search Main Menu" class="search_init" /></th>
                            <th><input type="text" name="search_engine" value="Search Main Menu" class="search_init" /></th>
                            <th><input type="text" name="search_browser" value="Search Sub Menu Name" class="search_init" /></th>
                            <th><input type="text" name="search_browser" value="Search Sub Menu Title" class="search_init" /></th>
                        </tr>
                    </thead>
                </table>
            </form>
        </div>
        <?php
	break;
}
?>