<?php session_start();
include ('../inc/dbcon.php');
include ('../inc/functions.php');
if(isset($_SESSION["axeslogin"]) && $_SESSION["axeslogin"] == true){
get_pagesecurity('20','creates','R');    
$_SESSION['cuPages']='mas_shipcreate.php';   
$cuPage='mas_shipcreate.php';    
$aid=$_SESSION['uid'];    
}else{
header('Location:../index.php');
exit;    
}
$mhead='master';
$menuh='Master Process';
$phead='shipcre';
$page='Add Shipping Line';
$dtnow = date("Y-m-d h:i:s", time());
?>
<?php
include('../layout/head.php');
include('../layout/header.php');
include('../layout/side_nav.php');
?>
<?php 
if(isset($_POST['save_ship'])){
    $sort = strtoupper(remove_junk(escape($_POST['sort'])));
    $contact = remove_junk(escape($_POST['contact']));
	$name = ucwords(remove_junk(escape($_POST['name'])));
    $address = remove_junk(escape($_POST['address']));
	
	if(isset($_POST['name'])){
	$ducode = mysqli_query($con,"SELECT * FROM tbl_shipline WHERE name = '$name'");
	}
	
	if($ducode->num_rows > 0) {
		save_msg('i','Shipping Line name alrady used! Plz try another');
		echo "<script>window.location='mas_shipcreate.php'</script>";
	}else{
    $sql="INSERT INTO tbl_shipline(sortn,name,contact,address,uid,date) VALUES ('$sort','$name','$contact','$address','$aid','$dtnow')";    
	$result = mysqli_query($con,$sql) or die(mysqli_error($con));
    $efid=mysqli_affected_rows($con);    
    if($efid>0){
    $act =remove_junk(escape('Shipping Line name: '.$sort));    
    write_activity($aid,'SHI','New shipping line has been Added',$act);
    save_msg('s','Data Successfully Saved!');    
    }else{
    save_msg('w','Data Fail to Saved!');    
    }
    echo "<script>window.location='mas_shipcreate.php'</script>";  
	}  
}
?>
<div class="content-wrapper">
<?php include('../layout/page_head.php'); ?>
<!-- Main content -->
<section class="content">
    
<div class="row">
<div class="col-md-8">
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">Add Shipping Line</h3>
</div>
<div class="box-body">
<?php echo display_msg();?>  
<form action="mas_shipcreate.php" onsubmit="return validate()" enctype="multipart/form-data" method="post" accept-charset="utf-8">
<div class="col-md-12 popup_details_div">

<div class="row">
<div class="col-md-12">
<div class="col-md-2"></div>
<div class="col-md-8">
<div class="col-md-12">
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label>Sort Name</label>
<input type="text" name="sort" maxlength="8" value="" id="sort" class="form-control" placeholder="e.g. OOCL"  />
</div>    
</div>    
<div class="col-md-8">    
<div class="form-group">
<label>Name</label>
<input type="text" name="name" maxlength="35" value="" id="name" class="form-control" placeholder="e.g. Orient Overseas Container Line"  />
</div>
</div>     
</div>
<div class="row">
<div class="col-md-12">    
<div class="form-group">
<label>Contact No</label>
<input type="text" name="contact" maxlength="18" value="" id="contact" class="form-control" placeholder="e.g. +880161xxxxxxx"  />
</div>
</div>    
</div>    
<div class="row">
<div class="col-md-12">    
<div class="form-group">
<label>Address</label>
<textarea class="form-control" maxlength="150" rows="6" name="address" placeholder="Address"></textarea>
</div>
</div>    
</div>    
</div>    
</div>    
<div class="col-md-2"></div>    
</div>    
</div>    

</div>
<div class="clearfix" ></div>
<div class="col-md-12 nopadding widgets_area"></div>    
<div class="row"style="margin-top: 15px" >
<div class="col-md-8"></div>
<div class="col-md-4 text-right" >
<input type="submit" name="save_ship" id="submit" class="btn btn-flat bg-purple btn-sm " value="Save"/> <a href="mas_shiplist.php" class="btn btn-flat bg-gray  ">Close</a>
</div> 
</div>     
</form>    
</div>
</div>
</div>
<div class="col-md-4">
<div class="row">
<div class="col-md-12">
<div class="box box-solid">
<div class="box-header">
<h3 class="box-title">History </h3>
</div>
<!-- /.box-header -->
<div class="box-body" >
<?php if($_SESSION['access']=='1'){echo read_activity($aid,'SHI','A');}else{echo read_activity($aid,'SHI','U');}?>
</div>
</div>
</div>
</div>
</div>
</div>

<?php include('../layout/quick.php');?>     
</section>
<!-- /.main content -->    
</div>

<?php 
include('../layout/footer.php');
?>
<!-- page script -->
<script type="text/javascript">
$(document).ready(function () {  
var sort = new LiveValidation('sort');
sort.add(Validate.Presence);
var name = new LiveValidation('name');
name.add(Validate.Presence);
});    
</script>    
<!-- /page script -->
</html>    