<?php 
$form_name = "MSM Introduction";
$table_name = "custom_msm_introduction";
$primary_key = "mem_intr_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_location ON (custom_location.loc_code = ".$table_name.".mem_intr_location) 
			INNER JOIN custom_survey_master ON (custom_survey_master.sur_code = ".$table_name.".mem_intr_survey) 
		WHERE ".$table_name.".del_status = 'N'";
		
		if(SURVYFXD == 'Y')
			$query .= " AND ".$table_name.".mem_intr_survey = '".SURVY."'";
		
		$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();
					
					j = row;
					mem_intr_id = '#mem_intr_id_'+j;
					
					frmval["mem_intr_id"] = $(mem_intr_id).val();
					parent.frm_edit_val(frmval["mem_intr_id"]);
				});

				// frm_val(this.form)
			} );
		</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>Interviewer Initial</th>
                            <!-- <th>Survey Title</th> -->
                            <!--  <th>Location</th> -->
                            <th>Date of Recruit</th>
                            <th>Participant ID</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]['mem_intr_initial'].'
                                            <input type="hidden" name="mem_intr_id" id="mem_intr_id_'.$i.'" value="'.$rec[$i]['mem_intr_id'].'" />
                                        </td>
										<td>'.date('d-m-Y',strtotime($rec[$i]['mem_intr_doi'])).'</td>
                                        <td>'.$rec[$i]['mem_intr_part_id'].'</td>
                                    </tr>';
                                //Commented - Vidhya 31-10-2017 -<td>'.$rec[$i]['sur_title'].'</td>
                                //<td>'.$rec[$i]['loc_name'].'</td>
                            }
                        ?>
                    </tbody>
                    <thead>
                        <tr>
                            <th style="display: none;"><input type="text" name="search_engine" value="Search Particiapnt ID" class="search_init" /></th>
                            <th><input type="text" name="search_engine" value="Search Interviewer Initial" class="search_init" /></th>
                          <!--    <th><input type="text" name="search_engine" value="Search Survey Title" class="search_init" /></th>
                            <th><input type="text" name="search_engine" value="Search Location" class="search_init" /></th>-->
                            <th><input type="text" name="search_browser" value="Search Date" class="search_init" /></th>
                            <th><input type="text" name="search_browser" value="Search Participant ID" class="search_init" /></th>
                        </tr>
                    </thead>
                </table>
            </form>
        </div>
        <?php
	break;
}
?>