<?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();
$pagename = basename($_SERVER['PHP_SELF']);
$msg = NULL;

$creator = $obj->getUserAuthority($_SESSION['uid'], 'SOA_CHK_CRETR');
$approver1 = $obj->getUserAuthority($_SESSION['uid'], 'SOA_CHK_APP_1');
$approver2 = $obj->getUserAuthority($_SESSION['uid'], 'SOA_CHK_APP_2');
?>
<!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" />
<!-- 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-dollar"></i>&nbsp;Risk Calculator&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">Risk Calculator</li>
                    </ol>
                </section>

                <!-- Main content -->
                <section class="content">
				<?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> RM 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 RM.
				</div>
				<?php }?>


				<?php if($msg == 3){?>
				<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>Sent</b>To Decision Chart.
				</div>
				<?php }?>


				<?php if($msg == 2){?>
				<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> RM delete successfully.
				</div>
				<?php }}?>
				
				<!--   content put here..................-->
				<div class="box box-primary">
				<h3 style=" text-align:center;">Risk Calculator</h3>
				<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-12">
						 <?php if($creator==1){?>
                            <div style="float:right;"><a href="calculateriskvessel.php" title="Add New"><button type="button" class="btn btn-info btn-flat">Add New</button></a></div>
						 <?php }?>
                         </div>
                     </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" >RM ID</th>
                                    <th align="left" valign="middle" width="25%">RM Date</th>
									
                                    <th align="center" valign="middle" width="10%">Details</th>
                                </tr>
                            </thead>

							<?php 

								$sQuery = "SELECT * FROM period_rm_master where RM_STATUS=1 order by RM_ID desc";
							
								$rResult = mysql_query($sQuery) or die($sQuery);

								
							
							?>
							<tbody>

							<?php
							$i=0;
							while ( $aRow = mysql_fetch_array( $rResult ) )
								{$i++;
									

									

									$details = '<a href="updateriskcalculatorvessel.php?id='.$aRow['RM_ID'].'" title="Edit Details" ><i class="fa fa-edit "></i></a>';
									
								
									?>

							<!-- updateriskcalculator.php?id='.$aRow['RM_ID'].' -->

							<tr>
							<td><?= $i?></td>
							<td><?= $aRow['RM_NO']?></td>
							<td><?= date('d-m-Y H:i:s',strtotime($aRow['RM_DATE']))?></td>
							
							<td><?= $details?></td>
								</tr>
							<?php } ?>
							</tbody>
                        </table>
                    </div>
				</form>
				</div>
				<!--   content ends here..................-->
                </section><!-- /.content -->
            </aside><!-- /.right-side -->
			
        </div><!-- ./wrapper -->
<?php $display->footer(); ?>
<?php $display->js(); ?>
<link href="../../css/datatables/jquery.dataTables.min.css" rel="stylesheet" type="text/css" />
<script src='../../js/plugins/datatables/jquery.dataTables.min.js'></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/bootstrap-datepicker.js" type="text/javascript"></script>
<script language="JavaScript" type="text/javascript" src="../../js/jquery.alerts.js"></script>
<script type="text/javascript">
	
// $.noConflict();
$(document).ready(function(){
// getDefaultData();
// $('#coa_list').dataTables();

// var table = $('#coa_list').DataTable();

$('#coa_list').DataTable({
                        dom: 'Bfrtip',
                        buttons: [
                            'copy', 'csv', 'excel', 'pdf', 'print'
                        ]
                    });
});
function getDefaultData()
{
		var table = $('#coa_list').dataTable();
		if(table != null)table.fnDestroy();
	  
		table = $("#coa_list").DataTable( {
			"processing": true,
			"serverSide": true,
			"stateSave": true,
			"order": [[2, 'desc']],
			"ajax": {
				"url": "options.php?id=112",
				"type": "POST",
				"dataSrc": function ( d ) {
					return d.records;
				},
				"data": function ( d ) {},
			},
			"columns": [
				{ "data": "col1" },
				{ "data": "col2" },
				{ "data": "col3" },
				{ "data": "col4" },
				{ "data": "col5" },
				{ "data": "col6" },
				{ "data": "col7" },
				{ "data": "col8" },
				
			],
			"language": {
				  "zeroRecords": "SORRY CURRENTLY THERE ARE ZERO(0) RECORDS"
				},
			 "fnDrawCallback": function(oSettings, json) {
				  $('[data-toggle="tooltip"]').tooltip();	
				},	
			"columnDefs": [ 
			        
					{
						"targets": 7,
						"orderable": false
					}
				]
					
		});
}
</script>
		
</body>
</html>