<?php echo '
<link rel="stylesheet" href="includes/media/css/TableTools_JUI.css" type="text/css" />
<script type="text/javascript" language="javascript" src="includes/media/js/ZeroClipboard.js"></script>
<script type="text/javascript" language="javascript" src="includes/media/js/TableTools.js"></script>';
date_default_timezone_set('Asia/Calcutta');
?>
<script language="javascript">
	var asInitVals = new Array();
	
	$(document).ready(function() {
		$("#tabs").tabs( {
			"show": function(event, ui) {
				var oTable = $('div.dataTables_scrollBody>table.display', ui.panel).dataTable();
				var tab3 = $("#tabs-3").is(":visible");
				
				if(tab3)
					$("#tab_id").val("3");
				
				if ( oTable.length > 0 ) {
					oTable.fnAdjustColumnSizing();
				}
			}
		} );
	} );
    function specimen_data()
	{
		prd_frm = $("#prd_frm").val();
		prd_to = $("#prd_to").val();
		sur_id = $("#sur_id").val();
		trns_typ = $("#trns_typ").val();
		reimb_typ = $("#reimb_typ").val();
		
		if(prd_frm == "")
		{
			alert("Please Provide Period From");
			$('#prd_frm').focus();
			$('#dataTable').html('');
			return false;
		}
		if(prd_to == "")
		{
			alert("Please Provide Period To");
			$('#prd_to').focus();
			$('#dataTable').html('');
			return false;
		}
		// if(!Date_Compare(prd_to, prd_frm, $("#dt_fmt").val()))
		if(!Date_Compare(prd_to, prd_frm, $("#dt_fmt").val()))
		{
			alert("To Date Must be Greater than From Date");
			$('#prd_to').focus();
			return false;
		}
		if(sur_id == "")
		{
			alert("Please Select Protocol");
			$('#sur_id').focus();
			$('#dataTable').html('');
			return false;
		}
		if(trns_typ == "")
		{
			alert("Please Select Transcation Type");
			$('#trns_typ').focus();
			$('#dataTable').html('');
			return false;
		}
		//$('#recuirtment').submit();
		
		var url = "";
		var loc = window.location;
		var pathName = loc.pathname.substring(0, loc.pathname.lastIndexOf('/') + 1);
		url = loc.href.substring(0, loc.href.length - ((loc.pathname + loc.search + loc.hash).length - pathName.length));
		
		$.ajax({
			type: "POST",
			data: "page="+getUrlVars()["page"]+"&mode=edit&attr=print&sur_id="+sur_id+"&prd_frm="+prd_frm+"&prd_to="+prd_to+"&trns_typ="+trns_typ+"&reimb_typ="+reimb_typ,
			url: url+"index.php",
			error: function(msg){
				alert( msg.status );
			},
			success: function(msg){
				// alert(msg);
				$('#dataTable').show();
				$('#dataTable').html(msg);
				$('#dataTable').css("border", 0);
				n = msg.indexOf("No menu items to display");
				if(msg != '' && n < 1)
					$("#submit_div").show();
				else
					$("#submit_div").hide();
			}
		});
	}
	
	function enb_option(val)
	{
		if(val == 1)
		{
			$('#reimb_opt').show();
		}
		else
		{
			$('#reimb_opt').hide();
		}
		div_clear();
	}
	
	function div_clear()
	{
		$("#dataTable").hide();
		$("#submit_div").hide();
	}
</script>
<?php
	$dt_fmt = str_replace("mm", "m", DT_FMT);
	$dt_fmt = str_replace("dd", "d", $dt_fmt);
	$dt_fmt = str_replace("yyyy", "Y", $dt_fmt);
	
	$dt = date($dt_fmt);
?>
<style>
	#dataTable {
		line-height: 15px !important
	}
</style>
<div style="width: 95%; margin: 0 auto; padding: 10px;">
	<div id="frm_display">
        <div id="tabs">
            <ul>
                <li class="active"><a href="#tabs-3">&nbsp;Reimbursement / Incentive Report&nbsp;</a></li>
            </ul>
            
            <form class="form" name="recuirtment" id="recuirtment" method="post" action="<?php echo $action; ?>" onsubmit="return frm_validation();" style="width: 85%;">
                <div id="tabs-3">
                    <div class="questionrow" style="width: 50%; margin: 0 auto;">
                        <div class="question"><strong>Period From</strong></div>
                        <div class="answer">
                        	<input type="text" name="prd_frm" id="prd_frm" value="<?php echo $dt; ?>" readonly="readonly" />
							<input type="hidden" name="prd_frm_old" id="prd_frm_old" value="" />
                            <input type="hidden" name="dt_fmt" id="dt_fmt" value="<?php echo DT_FMT; ?>" />
                            <script>
                                $(function() {
                                    $('#prd_frm').datepick({pickerClass: 'datepick-jumps', 
										renderer: $.extend({}, $.datepick.defaultRenderer, 
										{picker: $.datepick.defaultRenderer.picker. 
											replace(/\{link:prev\}/, '{link:prevJump}{link:prev}'). 
											replace(/\{link:next\}/, '{link:nextJump}{link:next}')
										}), 
										dateFormat: '<?php echo DT_FMT; ?>', 
										yearRange: '1900:<?php echo date('Y'); ?>',
										showTrigger: '#calImg',
										onClose: showDatefrm
                                    });
                                });
								function showDatefrm(date) {
									prd_frm_old = $("#prd_frm_old").val();
									
									if(prd_frm_old != "" && prd_frm_old != $("#prd_frm").val())
									{
										$("#dataTable").hide();
										$("#submit_div").hide();
										$("#prd_frm_old").val($("#prd_frm").val());
									}
									else
										$("#prd_frm_old").val($("#prd_frm").val());
								}
                            </script>
                        </div>
                        <div class="question"><strong>Period To</strong></div>
                        <div class="answer">
                        	<input type="text" name="prd_to" id="prd_to" value="<?php echo $dt; ?>" readonly="readonly" />
							<input type="hidden" name="prd_to_old" id="prd_to_old" value="" />
                            <script>
                                $(function() {
                                    $('#prd_to').datepick({pickerClass: 'datepick-jumps', 
                                            renderer: $.extend({}, $.datepick.defaultRenderer, 
                                            {picker: $.datepick.defaultRenderer.picker. 
                                                replace(/\{link:prev\}/, '{link:prevJump}{link:prev}'). 
                                                replace(/\{link:next\}/, '{link:nextJump}{link:next}')
                                            }), 
                                            dateFormat: '<?php echo DT_FMT; ?>', 
                                            yearRange: '1900:<?php echo date('Y'); ?>',
                                            showTrigger: '#calImg',
											onClose: showDateto
                                    });
                                });
								function showDateto(date) {
									prd_to_old = $("#prd_to_old").val();
									
									if(prd_to_old != "" && prd_to_old != $("#prd_to").val())
									{
										$("#dataTable").hide();
										$("#submit_div").hide();
										$("#prd_to_old").val($("#prd_to").val());
									}
									else
										$("#prd_to_old").val($("#prd_to").val());
								}
                            </script>
                        </div>
                        <div class="question"><strong>Protocol&nbsp; &nbsp; </strong></div>
                        <div class="answer">
                        	<?php echo $common->dropdown('sur_code', 'sur_title', 'custom_survey_master', '', 'sur_title', 'sur_id', $sur_id, 'onchange="return div_clear();"'); ?>
							<script>
								// $("#partcpnt_id option[value='']").text('All');
								// specimen_data();
							</script>
                        </div>
                        <div class="question"><strong>Transaction Type&nbsp; &nbsp; </strong></div>
                        <div class="answer">
							<select id="trns_typ" name="trns_typ" onchange="return enb_option(this.value);">
								<option value="">Select</option>
								<option value="1">Reimbursement</option>
								<option value="2">Incentives</option>
							</select>
                        </div>
						<div id="reimb_opt" style="display: none;">
							<div class="question"><strong>Option&nbsp; &nbsp; </strong></div>
							<div class="answer">
								<select id="reimb_typ" name="reimb_typ" onchange="return div_clear();">
									<option value="1">Headwise</option>
									<option value="2">Voucherwise</option>
								</select>
							</div>
						</div>
                        <!--<div class="question"><strong>Heads&nbsp; &nbsp; </strong></div>
                        <div class="answer">
                        	<?php //$common->dropdown('reimbrsmnt_head_id', 'reimbrsmnt_head_name', 'custom_reimbursement_heads_master', 'reimbrsmnt_head_id IN (SELECT reimbrsmnt_head_mstr_id FROM custom_reimbursement_mapping)', 'reimbrsmnt_head_name', 'sur_id', $sur_id, ''); ?>
                        </div>-->
                    </div>
                    <div class="clear_form">
                    </div>
                    <div class="questionrow" align="center">
						<br/><input type="button" name="print" value="Go" onclick="return specimen_data();" /><br/><br/>
                    </div>
					<div class="questionrow" id="dataTable" style="display: none; overflow: auto; width: 100%; max-height: 350px;">
					</div>
					<div class="clear_form">
					</div>
                    <div class="questionrow">
                        <div style="padding: 5px; display: none;" align="center" id="submit_div">
                            <input type="submit" name="excel" value="Excel" />
                            <input type="submit" name="pdf" value="Pdf" />
                        </div>
                    </div>
                </div>
            </form>
		</div>
	</div>
</div>