<?php 

session_start();
require_once("../../includes/display_internal_user_risk.inc.php");
require_once("../../includes/functions_internal_user_riskmangement.inc.php");
$obj = new data();
$connect = $obj->funConnect();
$display = new display();
$display->logout_iu();
if (@$_REQUEST['action'] == 'submit')
 {
	$msg = $obj->deleteFfaOption();
	header('Location:./ffaoption.php?msg='.$msg);
 }
$pagename = basename($_SERVER['PHP_SELF']);
$msg = NULL;
?>
<!DOCTYPE html>
<html>

<style>
    /* Define table dimensions and overflow property */
    .table-container {
      /* width: 400px; */
      /* height: 200px/; */
      overflow: auto;
    }
  </style>

<style>
.dataTables_scrollBody {
    transform:rotateX(180deg);
}
.dataTables_scrollBody table {
    transform:rotateX(180deg);
}
	</style>





  
<head>
<meta charset="UTF-8">
<title><?php $display->title(); ?></title>
<?php $display->favicon(); ?>
<link href="https://cdn.datatables.net/1.11.5/css/jquery.dataTables.min.css" rel="stylesheet" type="text/css" />
<link href="https://cdn.datatables.net/buttons/2.2.2/css/buttons.dataTables.min.css" rel="stylesheet" type="text/css" />


<meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
<?php $display->css(); ?>
<link href="../../css/datatables/dataTables.bootstrap.css" rel="stylesheet" type="text/css" />
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
  <script src="../js/html5shiv.js"></script>
  <script src="../js/respond.min.js"></script>
<![endif]-->
</head>
    <body class="skin-blue fixed">
        <!-- header logo: style can be found in header.less -->
        <?php $display->header_tag(); ?>
		<div class="wrapper row-offcanvas row-offcanvas-left">
            <?php $display->leftmenu(6); ?>
			<aside class="right-side">                
                <!-- Content Header (Page header) -->
                <section class="content-header">
                    <h1>
                        <i class="fa fa-folder-open"></i>&nbsp;Option&nbsp;&nbsp;&nbsp;&nbsp;<small><div class="headline text-center" id="time" style="color:#000; font-weight:bold; font-size:12px;"></div></small>
                    </h1>
                    <ol class="breadcrumb">
                        <li><a href="../"><i class="fa fa-home"></i> Home</a></li>
                        <li class="active">FFA &nbsp;&nbsp;&nbsp;>&nbsp;&nbsp;&nbsp;Option</li>
                    </ol>
                </section>

                <!-- Main content -->
                <section class="content">
				<!--   content put here..................-->
				<?php if(isset($_REQUEST['msg'])){
						$msg = $_REQUEST['msg'];
						if($msg == 0){?>
				<div class="alert alert-success alert-dismissable">
					<i class="fa fa-check"></i>
					<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
					<b>Congratulations!</b> FFA Option added/updated successfully.
				</div>
				<?php }?>
				<?php if($msg == 1){?>
				<div class="alert alert-danger alert-dismissable">
					<i class="fa fa-ban"></i>
					<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
					<b>Sorry!</b> there was an error while adding/updating FFA 					<b>Congratulations!</b> FFA Option added/updated successfully.
.
				</div>
				<?php }?>
				<?php if($msg == 4){?>
				<div class="alert alert-success alert-dismissable">
					<i class="fa fa-check"></i>
					<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
					<b>Congratulations!</b> FFA Option deleted successfully.
				</div>
				<?php }}?>
				<div class="box box-primary">
				<h3 style=" text-align:center;">Option List</h3>
				<div align="right"><a href="addffaoption.php" title="Add New"><button class="btn btn-info btn-flat">Add New</button></a>&nbsp;&nbsp;&nbsp;&nbsp;</div>
				<form name="frm1" id="frm1" enctype="multipart/form-data" action="<?php echo $pagename;?>"/>
				<div style="height:10px;">
				<input name="txttblid" id="txttblid" class="input" size="5" type="hidden" value="" />
				<input name="txttblstatus" id="txttblstatus" type="hidden" value="" />
				<input type="hidden" name="action" value="submit" />

				<input type="hidden" name="txtDEL_ID" id="txtDEL_ID" value="0"/>

				
				</div>				
				<?php $obj->displayOptionListFfaHedge();?>
				</form>
				</div>
				<!--   content ends here..................-->
                </section><!-- /.content -->
            </aside><!-- /.right-side -->
			
        </div><!-- ./wrapper -->
<?php $display->footer(); ?>
<?php $display->js(); ?>
<script src="https://cdn.datatables.net/1.11.5/js/jquery.dataTables.min.js" type="text/javascript"></script>




	
	<!-- new scripts -->
	<script src="https://cdn.datatables.net/buttons/2.2.2/js/dataTables.buttons.min.js" type="text/javascript"></script>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js" type="text/javascript"></script>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js" type="text/javascript"></script>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js" type="text/javascript"></script>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js" type="text/javascript"></script>
	<script src="https://cdn.datatables.net/buttons/2.2.2/js/buttons.html5.min.js" type="text/javascript"></script>
	<script src="https://cdn.datatables.net/buttons/2.2.2/js/buttons.print.min.js" type="text/javascript"></script>

	<link href="../../css/jquery.alerts.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" type="text/javascript" src="../../js/jquery.alerts.js"></script>

<script>
    window.onload = function() {
      // Get the table container element
      var tableContainer = document.getElementById('table-container');

      // Set the scroll behavior to auto-scroll to the bottom
      tableContainer.scrollTop = tableContainer.scrollHeight;
    };
  </script>



 <script type="text/javascript">

$(function() {

	var new_row = $("<tr class='search-header'/>");
				// <-----------------DPk------------------------>
				$('#terminal_list thead th').each(function(i) {
				var title = $(this).text();

			
				var new_th = $('<th style="' + $(this).attr('style') + '" />');

			if (title == "#") {
		
			    $(new_th).append('<input type="text" name="' + title + '" id="' + title + '" style="width:30px;" placeholder="' + title + '" data-index="'+i+'"/>');
			} else if (title == "DATE") {
			
				$(new_th).append('<input type="text" name="' + title + '" id="DATE""  style="width:80px;" placeholder="' + title + '" data-index="'+i+'"/>');
			} else if (title == "CLOSING REF") {
				
				$(new_th).append('<input type="search" name="' + title + '" id="CLOSING_REF"  style="width:85px;" placeholder="' + title + '" data-index="'+i+'" value=""/>' );
			}else if (title == "TRADE REF NO") {
			
				$(new_th).append('<input type="text" name="' + title + '"  id="TRADE_REF"   style="width:90px;" placeholder="' + title + '" data-index="'+i+'"/>');

			}else if (title == "CLEARING REF NO") {
			
				$(new_th).append('<input type="text" name="' + title + '"  id="CLEARING_REF"  style="width:85px;" placeholder="' + title + '" data-index="'+i+'"/>');

			}else if (title == "CLEARING FEE FACTOR") {
			
				$(new_th).append('<input type="text"  id="CLEARING_FEE"  style="width:50px;" placeholder="' + title + '" data-index="'+i+'"/>');

			}else if (title == "CONTRACT") {
				
			$(new_th).append('<input type="text"  id="CONTRACT" style="width:50px;" placeholder="' + title + '" data-index="'+i+'"/>');

			}else if (title == "PERIOD") {
			
				$(new_th).append('<input type="text" id="PERIOD" style="width:70px;" placeholder="' + title + '" data-index="'+i+'"/>');

			}else if (title == "SIZE DPM") {
			
				$(new_th).append('<input type="text"  id="SIZE_DPM" style="width:30px;" placeholder="' + title + '" data-index="'+i+'"/>');

			}else if (title == "SIZE TOTAL") {
			
				$(new_th).append('<input type="text" id="SIZE_TOTAL" style="width:30px;" placeholder="' + title + '" data-index="'+i+'"/>');

			}else if (title == "BUY") {
			
			$(new_th).append('<input type="text" id="BUY" style="width:50px;" placeholder="' + title + '" data-index="'+i+'"/>');

			}else if (title == "SELL") {
			
			$(new_th).append('<input type="text" id="SELL" style="width:50px;" placeholder="' + title + '" data-index="'+i+'"/>');

			}else if (title == "CLEARING FEES") {

		
			
			$(new_th).append('<input type="text" id="CLEARING_FEES" style="width:40px;" placeholder="' + title + '" data-index="'+i+'"/>');

			}else if (title == "CLEARING GST") {
			
			$(new_th).append('<input type="text" id="CLEARING_GST" style="width:40px;" placeholder="' + title + '" data-index="'+i+'"/>');
			
			}else if (title == "BROKERAGE") {
			
			$(new_th).append('<input type="text" id="BROKERAGE" style="width:40px;" placeholder="' + title + '" data-index="'+i+'"/>');

			}else if (title == "GROSS PL") {
			
			$(new_th).append('<input type="text" id="GROSS" style="width:70px;" placeholder="' + title + '" data-index="'+i+'"/>');

			}else if (title == "NET PL") {
			
			$(new_th).append('<input type="text" id="NET" style="width:70px;" placeholder="' + title + '" data-index="'+i+'"/>');

			}else if (title == "EXECUTED FOR") {
			 
			$(new_th).append('<input type="text" id="EXECUTED" style="width:70px;" placeholder="' + title + '" data-index="'+i+'"/>');

			}else if (title == "BROKERAGE(%)") {
				
			$(new_th).append('<input type="text" id="BROKERAGE_PER" style="width:60px;" placeholder="' + title + '" data-index="'+i+'"/>');

			}else if (title == "ENTITY") {
			
			$(new_th).append('<input type="text" id="ENTITY" BROKERAGE style="width:50px;"  placeholder="' + title + '" data-index="'+i+'"/>');

			}else if (title == "EXCHANGE") {
			
			$(new_th).append('<input type="text"  id="EXCHANGE" style="width:40px;" placeholder="' + title + '" data-index="'+i+'"/>');

			}else if (title == "VESSEL CARGO HEDGE") {
				
			$(new_th).append('<input type="text" id="VESSEL"  style="width:70px;" placeholder="' + title + '" data-index="'+i+'"/>');

			}else if (title == "REMARKS") {
			
			$(new_th).append('<input type="text" id="REMARKS"  style="width:70px;" placeholder="' + title + '" data-index="'+i+'"/>');

			}else if (title == "FIXTURE NO.") {
			
			$(new_th).append('<input type="text" id="FIXTURE"  style="width:70px;" placeholder="' + title + '" data-index="'+i+'"/>');

			}else if (title == "TYPE") {
			
			$(new_th).append('<input type="text" id="TYPE"  style="width:50px;" placeholder="' + title + '" data-index="'+i+'"/>');

			}else if (title == "DETAILS") {
			
			$(new_th).append('<input type="text" style="width:30px;" placeholder="' + title + '" data-index="'+i+'"/>');

			} else if (title == "SELECT") {
			
			$(new_th).append('<input type="text" style="width:30px;" placeholder="' + title + '" data-index="'+i+'"/>');

			}   else if (title == "DELETE") {
			
			$(new_th).append('<input type="text" style="width:30px;" placeholder="' + title + '" data-index="'+i+'"/>');

			}        
			
			else {
			   $(new_th).append('<input type="text" style="width:150px;" placeholder="' + title + '" data-index="'+i+'"/>');
			}
			
			
			
			
			
			

				
			$(new_row).append(new_th);
			
			// <--------------------DPk------------------------>
				});
				$('#terminal_list thead').prepend(new_row);


			var table = $('#terminal_list').DataTable({

		


							"scrollX": true,
							"searching": true,
							"iDisplayLength": 200,
   							 "aLengthMenu": [[5, 10, 25, 50, 200], [5, 10, 25, 50, 200]],
							paging: true, 
							stateSave: true,
							retrieve: true,
							stateSaveParams: function( settings, data ) {
							data.searchName = $('#CLOSING_REF').val()
							data.DATE = $('#DATE').val()
							data.TRADE_REF = $('#TRADE_REF').val()
							data.CLEARING_REF = $('#CLEARING_REF').val()
							data.CONTRACT = $('#CONTRACT').val()
							data.PERIOD = $('#PERIOD').val()
							data.SIZE_DPM = $('#SIZE_DPM').val()
							data.SIZE_TOTAL = $('#SIZE_TOTAL').val()

							data.BUY = $('#BUY').val()
							data.SELL = $('#SELL').val()
						
							data.CLEARING_FEES = $('#CLEARING_FEES').val()

							data.CLEARING_GST = $('#CLEARING_GST').val()

							data.BROKERAGE = $('#BROKERAGE').val()
							data.GROSS = $('#GROSS').val()
							data.NET = $('#NET').val()
							data.EXECUTED = $('#EXECUTED').val()
							data.BROKERAGE_PER = $('#BROKERAGE_PER').val()
							data.ENTITY = $('#ENTITY').val()
							data.EXCHANGE = $('#EXCHANGE').val()
							data.VESSEL = $('#VESSEL').val()
							data.REMARKS = $('#REMARKS').val()
							data.FIXTURE = $('#FIXTURE').val()
							data.TYPE = $('#TYPE').val()
							  
							     
						
							},
							stateLoadParams: function( settings, data ) {
							$('#CLOSING_REF').val(data.searchName)
							$('#DATE').val(data.DATE)
							$('#TRADE_REF').val(data.TRADE_REF)
							$('#CLEARING_REF').val(data.CLEARING_REF)
							$('#CONTRACT').val(data.CONTRACT)
							$('#PERIOD').val(data.PERIOD)
							$('#SIZE_DPM').val(data.SIZE_DPM)
							$('#SIZE_TOTAL').val(data.SIZE_TOTAL)
							$('#BUY').val(data.BUY)
							$('#SELL').val(data.SELL)
						
							$('#CLEARING_FEES').val(data.CLEARING_FEES)
							
							$('#CLEARING_GST').val(data.CLEARING_GST)

							$('#BROKERAGE').val(data.BROKERAGE)
							$('#GROSS').val(data.GROSS)
							$('#NET').val(data.NET)
							$('#EXECUTED').val(data.EXECUTED)
							$('#BROKERAGE_PER').val(data.BROKERAGE_PER)
							$('#ENTITY').val(data.ENTITY)
							$('#EXCHANGE').val(data.EXCHANGE)
							$('#VESSEL').val(data.VESSEL)
							$('#REMARKS').val(data.REMARKS)
							$('#FIXTURE').val(data.FIXTURE)
							$('#TYPE').val(data.TYPE)
							}

					
						});
			// $("#terminal_list").dataTable();

			// Filter event handler

			$(table.table().container()).each(function (i) {
         
        });
		
$( table.table().container() ).on( 'keyup', 'thead input', function () {



  table
    .column( $(this).data('index') )
    .search( this.value )
    .draw();
	console.log(this.value);
	
});


	

});


 $(document).ready(function(){
 var i=1;
 $("[id^=myonoffswitch_]").each(function () {
        document.getElementById("myonoffswitch_"+i).setAttribute("type", "checkbox");
		i++;
    });
 
});

function getChangeStatus(var1,var2,rowid)
{

	$("#txttblid").val(var1);
		$("#txttblstatus").val(var2);

		
	jConfirm('Do you want to change status?', 'Confirmation', function(r) {



	if(r){ 
	
		document.frm1.submit();
	}
	else{
			if(var2 == 1)
			{
				$("#myonoffswitch_"+rowid).attr("checked","checked");
			}
			else
			{
				$("#myonoffswitch_"+rowid).attr("checked","");
			}
		return false;
		}
	});
}

function deleteInv(var1)
{

	$('#txtDEL_ID').val(var1);


	jConfirm('Are you sure you want to delete this entry?', 'Confirmation', function(r) {
	if(r)
	{


		document.frm1.submit();
	}
	else
	{
		return false;
	}
	});
}
</script>
		
</body>
</html>