<?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')
{
 	$id = $obj->createCombinedSOA();
	header('Location:./updatecombinedsoa.php?id='.$id);
}

$pagename = basename($_SERVER['PHP_SELF']);
?>
<!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(24); ?>
			<aside class="right-side">                
                <!-- Content Header (Page header) -->
                <section class="content-header">
                    <h1>
                        <i class="fa fa-dollar"></i>&nbsp;Combined SOA&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">Combined SOA</li>
                    </ol>
                </section>
                <!-- Main content -->
                <section class="content">
				    <div align="right"><a href="combined_soa.php"><button class="btn btn-info btn-flat">Back</button></a></div>
				    <div style="height:10px;">&nbsp;</div>
					<!--   content put here..................-->
					<div class="box box-primary">
						<h3 style=" text-align:center;">Combined SOA</h3>
                        <form name="frm1" id="frm1" enctype="multipart/form-data" action="<?php echo $pagename;?>" method="post"/>
						<div class="row invoice-info" style="margin-left:7px;margin-right:7px;">
						    
                            <div class="col-xs-3">
							     Vendor
								 <address>
                                 <select name="selVendor" id="selVendor" class="form-control" onChange="getData();">
								   <?php echo $obj->getVendorListNewUpdate();?>
                                  </select>  
								  </address>                
							</div><!-- /.col -->
							<div class="col-xs-6">&nbsp;
							</div>
							<div class="col-sm-3">
								&nbsp;<address>
								
								</address>
							</div>
						</div>
						
						<div style="overflow:auto;">
							<div class="box-body table-responsive" style="overflow:auto;">
								<table id="vessel_list" class="table">
									<thead>
									<tr>
										<th align="left" valign="top" width="4%">#</th>
										<th align="left" valign="top" width="8%">Vessel Name</th>
										<th align="left" valign="top" width="8%">Voyage No.</th>	
										<th align="left" valign="top" width="8%">CP date</th>	
										<th align="left" valign="top" width="8%">Payment Type</th>
										<th align="left" valign="top" width="8%">Invoice/Advice No.</th>
										<th align="left" valign="top" width="8%">Invoice/Advice Date</th>
										<th align="left" valign="top" width="10%">Vendor</th>
										<th align="left" valign="top" width="8%">Amount Due</th>
										<th align="left" valign="top" width="14%">Amount Being Paid.</th>
										<th align="left" valign="top" width="14%">Remarks</th>
									</tr>
									</thead>
									<tbody id="tbody1">
										
									</tbody>
									<tfoot>
										<tr>
										   <td colspan="7"></td>
										   <td><strong>Total</strong></td>
										   <td><input type="text" name="txtTotalAmount" readonly="true" id="txtTotalAmount" class="form-control numeric" placeholder="0.00" autocomplete="off" value=""/></td>
										   <td></td>
										   <td></td>
										</tr>
									</tfoot>
								</table>
							</div>
						</div>
						
						<div class="row" style="padding-right:10px; padding-left:10px; margin-bottom:50px;">
							 <div class="col-xs-4" margin-bottom:30px;>
								 Attachment<br>
								<div class="btn btn-success btn-file btn-flat" data-toggle="tooltip">
								<i class="fa fa-paperclip"></i> Attachment
								<input type="file" class="form-control" multiple name="attach_file[]" id="attach_file" title="" data-widget="Attachment" data-toggle="tooltip" data-original-title="Attachment"/>
								</div>
							 
							 </div>
							 <div class="col-xs-4" margin-bottom:30px;>
								 Remarks<br/>
								<textarea name="txtRemarks" id="txtRemarks" class="form-control autosize" rows="3" placeholder="Remarks"></textarea>
							 
							 </div>
							 <div class="col-xs-4" style="margin-bottom:30px; text-align:center;">
								<button type="button" data-toggle="modal" data-target="#compose-modal" class="btn btn-warning" onClick="getSelect();" >Select</button>
								<input type="hidden" name="action" id="action" value="submit" />
							 </div>
						 </div>
						 <div class="row" style="padding-right:10px; padding-left:10px; margin-bottom:50px;">
						 <div class="col-xs-4" margin-bottom:30px;></div>
						 </div>
						</form>
					</div>
					<!--   content ends here..................-->
                </section><!-- /.content -->
            </aside><!-- /.right-side -->
        </div><!-- ./wrapper -->
<?php $display->footer(); ?>
<?php $display->js(); ?>
<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" />
<script language="JavaScript" type="text/javascript" src="../../js/jquery.numeric.js"></script>
<script language="JavaScript" type="text/javascript" src="../../js/jquery.alerts.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	getData();
});

function getString(var1)
{
  var var2 = var1.split('-');  
  return var2[2]+'/'+var2[1]+'/'+var2[0];
}

function getData()
{
	$('#tbody1').html("");
	$('#tbody1').html('<tr><td align="center" colspan="7"><img src="../../img/loading.gif" /></span></td></tr>');
	$.post("options.php?id=90",{selVendor:""+$("#selVendor").val()+""}, function(html) {
		$('#tbody1').html("");
		$('#tbody1').html(html);
		$('[id^=chkSelect_]').iCheck({
			checkboxClass: 'icheckbox_minimal',
			radioClass: 'iradio_minimal'
		});
		
		$("[id^=chkSelect_]").on('ifChecked', function () { 
		   $(this).attr('checked', true);
		   getTotal();
		});
		
		$("[id^=chkSelect_]").on('ifUnchecked', function () {
		   $(this).attr('checked', false); 
		   getTotal();
		});
		getTotal();
		$(".numeric").numeric();
	});
}

function getTotal()
{
    var total = 0;
    $('[id^=chkSelect_]').each(function() {
		if($(this).is(":checked")) {
			var chkvalue = $(this).val();
			var balanceamt = parseFloat($("#txtBalance_"+chkvalue).val());
			if(isNaN(balanceamt)){balanceamt = 0;}
			total = parseFloat(total) + parseFloat(balanceamt);
		}
	});
	$("#txtTotalAmount").val(total.toFixed(2));
}

function getSelect()
{
	var anyBoxesChecked = false;
	var chkArr = Array();
	var j = 0;
    $('[id^=chkSelect_]').each(function() {
        if ($(this).is(":checked")) {
			chkArr[j] = $(this).val();
            anyBoxesChecked = true;
			j = j + 1;
        }
    });
 
    if (anyBoxesChecked == false) {
       jAlert('Please select at least one checkbox', 'alert');
      return false;
    } 
	else
	{  
	    jConfirm('Are you sure you want to create Combined SOA?', 'Confirmation', function(r) {
		if(r){ 
			document.frm1.submit();
		}
		else{return false;}
		});
	}
}
 
</script>
		
</body>
</html>