<?php 



// echo '<h1 style="color:red">';



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['action2'] == 'submit1')
 {

	
 	// $msg = $obj->insertNominationDetails();
	header('Location:./riskvessel.php?msg='.$msg);
 }


 if(isset($_SESSION['selBType']))
{
	$selBType = $_SESSION['selBType'];
}
else
{
	$_SESSION['selBType'] = 3;
	$selBType = 3;
}



 
$pagename = basename($_SERVER['PHP_SELF']);
$msg = NULL;
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title><?php $display->title(); ?></title>
<?php $display->favicon(); ?>
<meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
<?php $display->css(); ?>
<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" />
<!-- 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]-->


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



</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(5); ?>
			<aside class="right-side">                
                <!-- Content Header (Page header) -->
                <section class="content-header">
                    <h1>
                        <i class="fa fa-folder-open"></i>&nbsp;Vessels' Open days - Details&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">Vessel &nbsp;&nbsp;&nbsp;>&nbsp;&nbsp;&nbsp;Vessels' Open days - Details</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> Risk Vessel 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 Risk Vessel.
				</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> Status changed successfully.
				</div>
				<?php }}?>
				<div class="box box-primary">
				<h3 style=" text-align:center;">Vessels' Open days - Details</h3>
				<!-- <div align="right"><a href="addriskvessel.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 class="row" style="padding-right:10px; padding-left:10px;">

   <div class="col-md-3">
		<select name="selBType_2" id="selBType_2" class="form-control" onChange="getDefaultDataFor2();">
		<option value="">---Select Business Type---</option>
		  <?php echo $obj->getBusinessTypeList1($selBType);?>
		 </select>                  
   </div><!-- /.col -->
	<div class="col-md-3">
	<?php if(in_array(2, $rigts)){?>
	   <!-- <div style="float:right;"><a href="addperiod_contract.php" title="Add New"><button type="button" class="btn btn-info btn-flat">Add New</button></a></div> -->
	<?php }?>
	</div>
</div>

<div >
   <input name="txttblid" id="txttblid" type="hidden" value="" />
   <input name="txttblstatus" id="txttblstatus" type="hidden" value="" />
   <input name="delId" id="delId" type="hidden" value="" />
   <input type="hidden" name="action" id="action" value="submit" />
</div>				
<div class="box-body table-responsive" style="overflow:auto;">
   <table id="coa_list" class="table table-bordered table-striped">
	   <thead>
		   <tr>
	
			   <th>#</th>
								   <th align="left" valign="middle" width="10%">Contract ID</th>
								   
								   <th align="left" valign="middle" width="10%">Contract Date</th>
								   <th align="left" valign="middle" width="10%">Vessel Name</th>
								   <th align="left" valign="middle" width="10%">Vessel Type</th>
								  
								   
								   <th align="center" valign="middle" width="12%">Own Business Account</th>
								   <th align="left" valign="middle" width="10%">Initial hire</th>

								   <th align="left" valign="middle" width="10%">Delivery Date 
								   </th>


								


								   
								   <th align="center" valign="middle" width="8%">Time Period Min (Days)
								   </th>
								   <th align="center" valign="middle" width="10%">Time Period Max (Days)
								   </th>

								   
								   <th align="center" valign="middle" width="8%">About days Min
								   </th>
								   <th align="center" valign="middle" width="10%">About days Max 
								   </th>
								   <th align="center" valign="middle" width="8%">Re-Del Date (Min)
								   </th>
								   <th align="center" valign="middle" width="10%">Re-Del Date (Max)

								   </th>

								   <!-- <th align="left" valign="middle" width="10%">Estimated voyage days 
								   </th>



								   <th align="center" valign="middle" width="8%">Performed Days

								   </th> -->

								   <th align="center" valign="middle" width="8%">Voyage days performed/fixed till

</th>


								



								   <th align="center" valign="middle" width="10%">Min Balance Days
								   </th>
								   <th align="center" valign="middle" width="10%">Max Balance days
								   </th>

								   <th align="center" valign="middle" width="10%">Details
								   </th>


								   
		   </tr>
	   </thead>
   </table>
</div>

</form>
				</div>


				<div class="modal fade" id="compose-modal" tabindex="-1" role="dialog" 		aria-hidden="true">
						<div class="modal-dialog">
							<div class="modal-content">
								<div class="modal-header">
									<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
								</div>
								<div class="modal-body">
									<form name="frm2" id="frm2" enctype="multipart/form-data" action="<?php echo $pagename;?>" method="post"/>
                                        <div id="divPayment">
                                            
                                        </div>
                                        <div class="box-footer" align="right">
                                            <button type="submit" id="btnhide" class="btn btn-primary btn-flat" onClick="return getValid();" >Submit</button>
                                            <input type="hidden" id="action2" name="action2" value="submit1" />
                                            <input type="hidden" name="txtCRMFILE1" id="txtCRMFILE1" value="" />
                                            <input type="hidden" name="txtCRMNAME1" id="txtCRMNAME1" value="" />
                                            <input type="hidden" id="tblid" name="tblid" value=""/>
                                        </div>
									</form>
								</div>
							</div><!-- /.modal-content -->
						</div><!-- /.modal-dialog -->
					</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>
<script src="../../js/timer.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">



 $(document).ready(function(){

	getDefaultDataFor2();

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

	
	$("#terminal_list").dataTable({
		"iDisplayLength": 100,

    });




});

function openWin(var1)
{
	$("#divPayment").empty();
	$("#divPayment").html('<div><img src="../../img/ajax-loader.gif" /><br><b>Loading...</b></div>'); 
	$.post("options.php?id=45",{idForNom:""+var1+""}, function(html) {

		console.log(html)
		$("#divPayment").empty();
		$("#divPayment").append(html);
		// if($("#txtP_PR").val() > 0)
		// {
			// $("#btnhide").hide();	
		// }
		// $("#txtP_Date").numeric();
        // $('#txtP_Remarks').autosize({append: "\n"});
		// $('#txtP_Date').datepicker({
			// format: 'dd-mm-yyyy',
			// autoclose:true
		// });
	});
}



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 getDefaultDataFor2()
{

	

	event.preventDefault();

	console.log('check',$("#selBType_2").val());
		var table = $('#coa_list').dataTable();
		if(table != null)table.fnDestroy();
	  
		table = $("#coa_list").DataTable( {
			"processing": true,
			"serverSide": true,
			"stateSave": true,
			"order": [[1, 'desc']],
			"ajax": {
				"url": "options.php?id=158",
				"type": "POST",
				"dataSrc": function ( d ) {
					return d.records;
				},
				"data": function ( d ) {d.businesstype=$("#selBType_2").val()},
			},
			"columns": [
				{ "data": "col1" },
				{ "data": "col2" },
				{ "data": "col3" },
				{ "data": "col4" },
				{ "data": "col20" },
			
			
				{ "data": "col7" },
				{ "data": "col6" },
				{ "data": "col5" },
				
				{ "data": "col8" },
				{ "data": "col9" },

				{ "data": "col10" },
				{ "data": "col11" },
				{ "data": "col16" },
				{ "data": "col17" },

				{ "data": "col19" },
				
				{ "data": "col14" },
			
				{ "data": "col15" },
				{ "data": "col21" },
			
				
			],
			"language": {
				  "zeroRecords": "SORRY CURRENTLY THERE ARE ZERO(0) RECORDS"
				},
			 "fnDrawCallback": function(oSettings, json) {
				  $('[data-toggle="tooltip"]').tooltip();	
				},	
			"columnDefs": [ 
			        
					{
						"targets": 7,
						"orderable": false
					},
					{
						"targets": 9,
						"orderable": false
					},
					{
						"targets": 10,
						"orderable": false
					},
					{
						"targets": 11,
						"orderable": false
					},
					{
						"targets": 12,
						"orderable": false
					}
				],
				dom: 'Bfrtip',
					buttons: [
						{
							extend: 'excel',
						
							title:"Risk Vessel",
							sFileName: "Risk Vessel"


						},
						
							]


					
		});





}





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;
	}
	});
}



function getValid()
{
	if($('#txtNoOfDate').val() == ''  || $('#txtP_Remarks').val()=='')
	{
		jAlert('Please fill No. of Days & Remarks', 'Alert');
		return false;
	}
	else
	{
		
	   
		document.frm2.submit();
		return true;
	}
}






</script>
		
</body>
</html>