<?php 
session_start();
require_once("../../includes/display_internal_user_dryout.inc.php");
require_once("../../includes/functions_internal_user_dryout.inc.php");
$obj = new data();
$connect = $obj->funConnect();
$display = new display();
$display->logout_iu();


if (@$_REQUEST['action'] == 'submit')
 {
	$msg = $obj->fixfinalisedfixturesheet();
	header('Location:./finalisedvoyagefixtures.php?msg='.$msg);
 }
if(isset($_REQUEST['selBType']) && $_REQUEST['selBType']!="")
{
	$_SESSION['selBType'] = $_REQUEST['selBType'];
	$estimatetype = $selBType = $_SESSION['selBType'];
}
else if(isset($_SESSION['selBType']))
{
	$estimatetype = $selBType = $_SESSION['selBType'];
}
else
{
	unset($_SESSION['selBType']);
	$selBType = '';
	$estimatetype = 1;
}
$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="../../css/datatables/dataTables.bootstrap.css" rel="stylesheet" type="text/css" />
<?php $display->js(); ?>
<!-- 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(5); ?>
			<aside class="right-side">                
                <!-- Content Header (Page header) -->
                <section class="content-header">
                    <h1>
                        <i class="fa fa-book"></i>&nbsp;Ops VC&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">Finalised Voyage Fixtures</li>
                    </ol>
                </section>

                <!-- Main content -->
                <section class="content">
				<!--   content put here..................-->
				<?php if(isset($_REQUEST['msg'])){
						$msg = $_REQUEST['msg'];
					if($msg == 1){?>
                    <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> Fixtures Finalised successfully.
                    </div>
				<?php }}?>
				<div class="box box-primary">
				<h3 style=" text-align:center;">Finalised Voyage Fixtures List</h3>
				<form role="form" name="frm1" id="frm1" enctype="multipart/form-data" action="<?php echo $pagename;?>" method="post">
				<div align="right"><div class="col-xs-6">&nbsp;
                     </div>
                     <div class="col-xs-4">
                        <a href="#" onClick="SubmitToFix();"><button type="button" class="btn btn-info btn-flat">Finalise Fixture</button></a>
                     </div>
                     <div class="col-xs-2" >
                         <select name="selBType" id="selBType" class="form-control" onChange="getSubmit();">
                         
                         <?php echo $obj->getBusinessTypeList1($selBType);?>
                         </select> 
                         <select name="selusers" id="selusers"  style="display:none;">
                         
                         <?php echo $obj->getUserList();?>
                         </select>                  
                     </div><!-- /.col -->
                </div>
				
                    
					<div style="height:10px; clear:both;">
						<input type="hidden" name="action" value="submit" />
					</div>				
					<?php $obj->displayFinalisedVoyageFixturesList($selBType);?>
                    <input type="hidden" id="hddnFCA1" name="hddnFCA1" value=""/><input type="hidden" name="selOP" id="selOP" value=""/><input type="hidden" name="hddnCOMID" id="hddnCOMID" value=""/>
                    <div style="clear:both;"></div>
				</form>
				</div>
                
              <div class="modal fade" id="compose-modal" tabindex="-1" role="dialog" aria-hidden="true">
				<div class="modal-dialog" style="width:95%">
					 <div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
							<h4 class="modal-title"><i class="fa fa-file-text-o"></i>Decision Chart</h4>
						</div>
						
						<div class="modal-body" id="div_3" style="overflow:auto;">
						</div>
					 </div>
				</div>
				</div>
				<!--   content ends here..................-->
                </section><!-- /.content -->
            </aside><!-- /.right-side -->
			
        </div><!-- ./wrapper -->
<?php $display->footer(); ?>
<script src="../../js/plugins/datatables/jquery.dataTables.js" type="text/javascript"></script>
<script src="../../js/plugins/datatables/dataTables.bootstrap.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" />
<link href="../../css/datepicker/datepicker.css" rel="stylesheet" type="text/css" />
<script src="../../js/plugins/datepicker/bootstrap-datepicker.js" type="text/javascript"></script>
<script language="JavaScript" type="text/javascript" src="../../js/jquery.alerts.js"></script>
<script type="text/javascript">
 
$(function() {
	$("#fce_list").dataTable();
    $('[id^=selUser_]').html($("#selusers").html());
});

function getListToCompare(val)
{
	$("#div_3").html('<b style="font-size:25px;">Please wait . . .</b><br><br><img src="../../img/loading.gif"  />');
	$.post("options.php?id=37",{val:""+val+""}, function(html) {
	$("#div_3").html("");
	$("#div_3").html(html);
	     $("input[type='radio']").iCheck({
				checkboxClass: 'icheckbox_minimal',
				radioClass: 'iradio_minimal'
			    });
	});
}


function SubmitToFix()
{
	var anyBoxesChecked = false;
	var chkArr = Array();
	var j = 0;
    $('[id^=rdoFCA_]').each(function() {
		var rowid = this.id;
		var ids = rowid.split('_');
        if ($(this).is(":checked") && $("#selUser_"+ids[1]).val()!='') {
			chkArr[j] = $(this).val();
			$('#hddnFCA1').val($(this).val());
			$('#selOP').val($("#selUser_"+ids[1]).val());
			$("#hddnCOMID").val($("#txtComId_"+ids[1]).val());
            anyBoxesChecked = true;
			j = j + 1;
        }
    });
 
    if (anyBoxesChecked == false) {
      jAlert('Please select one fixture and assign an operator.', 'alert');
      return false;
    } 
	else
	{  
		jConfirm('Are you sure to finalise this Fixture ?', 'Confirmation', function(r) {
		if(r){ 
		   document.frm1.submit();
		   }
		else{return false;}
		});
	}
}


function getSubmit()
{ 
    $("#action").val("ss");
	document.frm1.submit();
}

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