%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/riacommer/domains/gasworld.com.my/private_html/admin/
Upload File :
Create Path :
Current File : /home/riacommer/domains/gasworld.com.my/private_html/admin/so_ce.php

<?php 
include_once("api/security.php");
include_once("api/db.php");
include_once("api/util.php");
include_once("constants.php");

$act='create';
$id='';

$customerid='';

//billing
$firstname = '';
$lastname = '';
$contactno = '';
$company = '';
$address1 = '';
$address2 = '';
$address3 = '';
$city = '';
$postcode = '';
$country = '';
$state = '';
//shipping
$ship_firstname = '';
$ship_lastname = '';
$ship_contactno = '';
$ship_company = '';
$ship_address1 = '';
$ship_address2 = '';
$ship_address3 = '';
$ship_city = '';
$ship_postcode = '';
$ship_country = '';
$ship_state = '';

//validation
$isImageRequired=' required="required"';

$status='';
$remarks='';

if(isset($_GET["id"])){

	$id = $_GET["id"];
	$sql = "SELECT s.*, m.name, m.lname, m.mobile, m.company, m.address1, m.address2, m.address3, m.city, m.postcode, m.country, m.state FROM sa_so s, sa_member m where s.customerid = m.id AND s.id='$id'";
	$mysql_result = mysql_query($sql, $connection);
	$num_rows = mysql_num_rows($mysql_result);
	if($num_rows>=1){
		$act='update';
		while($row = mysql_fetch_array($mysql_result)){
		
			$customerid = $row["customerid"];
		
			$ship_firstname = $row["sname"];
			$ship_lastname = $row["slname"];
			$ship_contactno = $row["scontact"];
			$ship_company = $row["scompany"];
			$ship_address1 = $row["saddress"];
			$ship_address2 = $row["saddress2"];
			$ship_address3 = $row["saddress3"];
			$ship_city = $row["scity"];
			$ship_postcode = $row["spostcode"];
			$ship_country = $row["scountry"];
			$ship_state = $row["sstate"];
			
			$firstname = $row["name"];
			$lastname = $row["lname"];
			$contactno = $row["mobile"];
			$company = $row["company"];
			$address1 = $row["address1"];
			$address2 = $row["address2"];
			$address3 = $row["address3"];
			$city = $row["city"];
			$postcode = $row["postcode"];
			$country = $row["country"];
			$state = $row["state"];			
			
			$status = $row["status"];
			if($status==''){
				$status = 'open';
			}
			
			$remarks = $row["remarks"];
		}
	} else {
		header("Location: http://" .$_SERVER['HTTP_HOST'] . str_replace("\\", "", dirname($_SERVER['PHP_SELF'])) ."/400.php");
	}	
}

if(isset($_POST["act"])){
	$act = $_POST["act"];
	$cartitemid = $_POST["cartitemid"];
	if($act=="delete"){
		$sql = "DELETE FROM sa_so_product WHERE id=$cartitemid";
		mysql_query($sql);
	} else {
		$qty = $_POST["qty"];
		$sql = "UPDATE sa_so_product SET qty=$qty WHERE id=$cartitemid";
		mysql_query($sql);
	}
}
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Sales Order - <?php echo $app_title; ?></title>
    <link href="css/application.min.css" rel="stylesheet">
    <!-- as of IE9 cannot parse css files with more that 4K classes separating in two files -->
    <!--[if IE 9]>
        <link href="css/application-ie9-part2.css" rel="stylesheet">
    <![endif]-->
    <link rel="shortcut icon" href="favicon.ico">
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta name="description" content="">
    <meta name="author" content="">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">	
    <script>
    </script>
</head>
<body>
<?php include_once("sidebar.php"); ?>
<?php include_once("topbar.php");?>
<!--CONTENT START HERE-->
<div class="content-wrap">
    <!-- main page content. the place to put widgets in. usually consists of .row > .col-md-* > .widget.  -->
    <main id="content" class="content" role="main">
		<h1 class="page-title">Sales Order</span></h1>
		
		<section class="widget">
            <!--<header>
				<h4>Sales Order</h4>
            </header>-->
			
			<div class="widget-body">
			
<form id="frm" name="frm" method="POST" action="so_ce.php?id=<?php echo $id;?>#cart">
	<input type="hidden" value="" id="act" name="act" />
	<input type="hidden" value="" id="qty" name="qty" />
	<input type="hidden" value="" id="cartitemid" name="cartitemid" />
</form>				
			
				<form class="form-horizontal" role="form" method="post" action="api/so.php"
					id="validation-form"
					data-parsley-priority-enabled="false"
                    novalidate="novalidate">
					<input type="hidden" value="<?php echo $act; ?>" id="act" name="act" />
					<input type="hidden" value="<?php echo $id; ?>" id="id" name="id" />
					
					<input type="hidden" value="<?php echo $customerid; ?>" id="customerid" name="customerid" />
					
					<fieldset>
						<legend><strong>Billing Address</strong></legend>
						
						<div class="form-group">
							<label class="col-sm-4 control-label"><span class="red">*</span> First Name:</label>
                  <div class="col-sm-7">
                    <input type="text" id="firstname" class="form-control" name="firstname" autocomplete="off" value="<?php echo $firstname; ?>">
					<span class="errMsg" id="efirstname" name="efirstname"></span>
                  </div>
						</div>
				<div class="form-group">
				<label class="col-sm-4 control-label"><span class="red">*</span> Last Name:</label>
                  <div class="col-sm-7">
                    <input type="text" id="lastname" class="form-control" name="lastname" autocomplete="off" value="<?php echo $lastname; ?>">
					<span class="errMsg" id="elastname" name="elastname"></span>
                  </div>
				</div>
				
				<div class="form-group">
				<label class="col-sm-4 control-label"><span class="red">*</span> Contact No.:</label>
                  <div class="col-sm-7">
                    <input type="text" id="contactno" class="form-control" name="contactno" autocomplete="off" value="<?php echo $contactno; ?>">
					<span class="errMsg" id="econtactno" name="econtactno"></span>
                  </div>
				</div>
				
				<div class="form-group">
				<label class="col-sm-4 control-label">Company:</label>
                  <div class="col-sm-7">
                    <input type="text" id="company" class="form-control" name="company" autocomplete="off" value="<?php echo $company; ?>">
					<span class="errMsg" id="ecompany" name="ecompany"></span>
                  </div>
				</div>	
				
				<div class="form-group">
				<label class="col-sm-4 control-label"><span class="red">*</span> Address Line 1:</label>
                  <div class="col-sm-7">
                    <input type="text" id="address1" class="form-control" name="address1" autocomplete="off" value="<?php echo $address1; ?>">
					<span class="errMsg" id="eaddress1" name="eaddress1"></span>
                  </div>
				</div>
				
				<div class="form-group">
				<label class="col-sm-4 control-label">Address Line 2:</label>
                  <div class="col-sm-7">
                    <input type="text" id="address2" class="form-control" name="address2" autocomplete="off" value="<?php echo $address2; ?>">
					<span class="errMsg" id="eaddress2" name="eaddress2"></span>
                  </div>
				</div>

				<div class="form-group">
				<label class="col-sm-4 control-label">Address Line 3:</label>
                  <div class="col-sm-7">
                    <input type="text" id="address3" class="form-control" name="address3" autocomplete="off" value="<?php echo $address3; ?>">
					<span class="errMsg" id="eaddress3" name="eaddress3"></span>
                  </div>
				</div>

				<div class="form-group">
				<label class="col-sm-4 control-label"><span class="red">*</span> City:</label>
                  <div class="col-sm-7">
                    <input type="text" id="city" class="form-control" name="city" autocomplete="off" value="<?php echo $city; ?>">
					<span class="errMsg" id="ecity" name="ecity"></span>
                  </div>
				</div>
				
				<div class="form-group">
				<label class="col-sm-4 control-label"><span class="red">*</span> Zip/Postal Code:</label>
                  <div class="col-sm-7">
                    <input type="text" id="postcode" class="form-control" name="postcode" autocomplete="off" value="<?php echo $postcode; ?>">
					<span class="errMsg" id="epostcode" name="epostcode"></span>
                  </div>
				</div>

				<div class="form-group">
				<label class="col-sm-4 control-label"><span class="red">*</span> Country:</label>
                  <div class="col-sm-7">
                    <input type="text" id="country" class="form-control" name="country" autocomplete="off" value="<?php echo $country; ?>">
					<span class="errMsg" id="ecountry" name="ecountry"></span>
                  </div>
				</div>			

				<div class="form-group">
				<label class="col-sm-4 control-label"><span class="red">*</span> State:</label>
                  <div class="col-sm-7">
                    <input type="text" id="state" class="form-control" name="state" autocomplete="off" value="<?php echo $state; ?>">
					<span class="errMsg" id="estate" name="estate"></span>
                  </div>
				</div>
				
			</fieldset>
					
			<fieldset>
				<legend><strong>Shipping Address</strong></legend>

				<div class="form-group">
				<label class="col-sm-4 control-label"><span class="red">*</span> First Name:</label>
                  <div class="col-sm-7">
                    <input type="text" id="ship_firstname" class="form-control" name="ship_firstname" autocomplete="off" value="<?php echo $ship_firstname; ?>">
					<span class="errMsg" id="eship_firstname" name="eship_firstname"></span>
                  </div>
				</div>
				
				<div class="form-group">
				<label class="col-sm-4 control-label"><span class="red">*</span> Last Name:</label>
                  <div class="col-sm-7">
                    <input type="text" id="ship_lastname" class="form-control" name="ship_lastname" autocomplete="off" value="<?php echo $ship_lastname; ?>">
					<span class="errMsg" id="eship_lastname" name="eship_lastname"></span>
                  </div>
				</div>
				
				<div class="form-group">
				<label class="col-sm-4 control-label">Contact No.:</label>
                  <div class="col-sm-7">
                    <input type="text" id="ship_contactno" class="form-control" name="ship_contactno" autocomplete="off" value="<?php echo $ship_contactno; ?>">
					<span class="errMsg" id="eship_contactno" name="eship_contactno"></span>
                  </div>
				</div>
				
				<div class="form-group">
				<label class="col-sm-4 control-label">Company:</label>
                  <div class="col-sm-7">
                    <input type="text" id="ship_company" class="form-control" name="ship_company" autocomplete="off" value="<?php echo $ship_company; ?>">
					<span class="errMsg" id="eship_company" name="eship_company"></span>
                  </div>
				</div>	
				
				<div class="form-group">
				<label class="col-sm-4 control-label"><span class="red">*</span> Address Line 1:</label>
                  <div class="col-sm-7">
                    <input type="text" id="ship_address1" class="form-control" name="ship_address1" autocomplete="off" value="<?php echo $ship_address1; ?>">
					<span class="errMsg" id="eship_address1" name="eship_address1"></span>
                  </div>
				</div>
				
				<div class="form-group">
				<label class="col-sm-4 control-label">Address Line 2:</label>
                  <div class="col-sm-7">
                    <input type="text" id="ship_address2" class="form-control" name="ship_address2" autocomplete="off" value="<?php echo $ship_address2; ?>">
					<span class="errMsg" id="eship_address2" name="eship_address2"></span>
                  </div>
				</div>

				<div class="form-group">
				<label class="col-sm-4 control-label">Address Line 3:</label>
                  <div class="col-sm-7">
                    <input type="text" id="ship_address3" class="form-control" name="ship_address3" autocomplete="off" value="<?php echo $ship_address3; ?>">
					<span class="errMsg" id="eship_address3" name="eship_address3"></span>
                  </div>
				</div>

				<div class="form-group">
				<label class="col-sm-4 control-label"><span class="red">*</span> City:</label>
                  <div class="col-sm-7">
                    <input type="text" id="ship_city" class="form-control" name="ship_city" autocomplete="off" value="<?php echo $ship_city; ?>">
					<span class="errMsg" id="eship_city" name="eship_city"></span>
                  </div>
				</div>
				
				<div class="form-group">
				<label class="col-sm-4 control-label"><span class="red">*</span> Zip/Postal Code:</label>
                  <div class="col-sm-7">
                    <input type="text" id="ship_postcode" class="form-control" name="ship_postcode" autocomplete="off" value="<?php echo $ship_postcode; ?>">
					<span class="errMsg" id="eship_postcode" name="eship_postcode"></span>
                  </div>
				</div>

				<div class="form-group">
				<label class="col-sm-4 control-label"><span class="red">*</span> Country:</label>
                  <div class="col-sm-7">
                    <input type="text" id="ship_country" class="form-control" name="ship_country" autocomplete="off" value="<?php echo $ship_country; ?>">
					<span class="errMsg" id="eship_country" name="eship_country"></span>
                  </div>
				</div>			

				<div class="form-group">
				<label class="col-sm-4 control-label"><span class="red">*</span> State:</label>
                  <div class="col-sm-7">
                    <input type="text" id="ship_state" class="form-control" name="ship_state" autocomplete="off" value="<?php echo $ship_state; ?>">
					<span class="errMsg" id="eship_state" name="eship_state"></span>
                  </div>
				</div>				
				
			</fieldset>

<script language="javascript">
function doUpdate(cid, qty){
	document.frm.act.value="update";
	document.frm.cartitemid.value = cid;
	document.frm.qty.value = qty;
	document.frm.submit();
}
function doDelete(cid){
	if(confirm("Are you sure want to remove this item?")){
		document.frm.act.value="delete";
		document.frm.cartitemid.value = cid;
		document.frm.submit();
	}
}
</script>		
					<fieldset>
						<legend><strong>Sales Order Details</strong></legend>
						
						<a name="cart"></a><table border="1" width="100%">
							<tr>
								<td>#</td><td>Image</td><td>Product Name</td><td>Product Code</td><td align="center">Quantity</td><td align="right">Unit Price</td><td align="right">Sub-Total</td><td align="center">Action</td>
<?php
$shipping_fee=0.00;
if($ship_country!="Malaysia"){
	$shipping_fee = 20.00;
}

$total=0.00;
$subtotal=0.00;
$weighttotal=0;

		$sql = "select p.*, prod.id as cartitemid, prod.qty, (prod.qty * p.selling_price) as total from sa_so_product prod, sa_product p where prod.soid='$id' and prod.productid=p.id order by prod.createddate desc";
		$mysql_result = mysql_query($sql, $connection);
		$num_rows = mysql_num_rows($mysql_result);
		$nItem=0;
		if($num_rows>=1){
			while($row = mysql_fetch_array($mysql_result)){
				$nItem++;
				//$urlProduct = 'product.php?uuid='.$row["id"];
				$urlImage = '../contents/products/thumb_'.urlencode($row["product_image"]);
				
				$subtotal += $row["total"];
				$weighttotal += ($row["qty"]*$row["weight"]);
				
				$qtyDrop = '<select class="selectqty" id="qty_'.$nItem.'" name="qty_'.$nItem.'">';
                  
					for($i=1;$i<=20;$i++){
						if($row["qty"]==$i){
							$qtyDrop .= '<option value="'.$i.'" selected>'.$i.'</option>';
						} else {
							$qtyDrop .= '<option value="'.$i.'">'.$i.'</option>';
						}
					}
				  
                $qtyDrop .= '</select>';
				
				//<input type="text" size="1" value="'.$row["qty"].'" id="qty_'.$nItem.'" name="qty_'.$nItem.'" class="span1">
				
				echo '<tr><td style="text-align:right;">'.$nItem.'.</td>
					<td class="image"><img title="product" alt="product" src="'.$urlImage.'" height="100" width="100"></td>
					<td  class="name">'.$row["product_name"].'</td>
					<td class="model">'.$row["product_code"].'</td>
					<td class="quantity" align="center">'.$qtyDrop.'</td>
					<td class="price" align="right">MYR '.$row["selling_price"].'</td>
					<td class="total" align="right">MYR '.$row["total"].'</td>
					
					<td align="center">
					<a href="javascript:;" onClick="javascript:doUpdate('.$row["cartitemid"].', document.getElementById(\'qty_'.$nItem.'\').value);"><img class="tooltip-test" data-original-title="Update" src="../assets/img/update.png" alt=""></a>
					<a href="javascript:;" onClick="javascript:doDelete('.$row["cartitemid"].');"><img class="tooltip-test" data-original-title="Remove"  src="../assets/img/remove.png" alt=""></a></td>
					</td>
					
				  </tr>';
			}
		} else {
			echo '<tr><td colspan="8" align="center">No record(s) found.</td></td>';
		}
?>			
						</table>
						
						
<table class="table table-striped table-bordered">
              <tr>
                <td style="text-align:right;"><span class="extra bold">Sub-Total :</span></td>
                <td style="text-align:right;"><span class="bold">MYR <?php echo number_format($subtotal,2);?></span></td>
              </tr>
              <tr>
                <td style="text-align:right;"><span class="extra bold">Weight (kg) :</span></td>
                <td style="text-align:right;"><span class="bold"><?php echo number_format(($weighttotal/1000), 2); ?></span></td>
              </tr>
			  <tr>
                <td style="text-align:right;"><span class="extra bold">Shipping Fees :</span></td>
				<td style="text-align:right;"><span class="bold">MYR <?php echo number_format($shipping_fee, 2); ?></span></td>
              </tr>
              <tr>
                <td style="text-align:right;"><span class="extra bold totalamout">Total :</span></td>
                <td style="text-align:right;"><span class="bold totalamout">MYR <?php echo number_format(($subtotal+$shipping_fee),2); ?></span></td>
              </tr>
</table>						
						
					</fieldset>
					
		<fieldset>
			<legend><strong>Sales Order Status</strong></legend>
				<div class="form-group">
				<label class="col-sm-4 control-label"><span class="red">*</span> Status:</label>
                  <div class="col-sm-7">
                    <select id="status" name="status" class="form-control">
						<option value="open"<?php echo ($status=="open")?" selected":"";?>>Open</option>
						<option value="paid"<?php echo ($status=="paid")?" selected":"";?>>Paid</option>
						<option value="cancelled"<?php echo ($status=="cancelled")?" selected":"";?>>Cancelled</option>
					</select>
                  </div>
				</div>			

				<div class="form-group">
				<label class="col-sm-4 control-label">Remarks:</label>
                  <div class="col-sm-7">
					<textarea rows="3" id="remarks" name="remarks" class="autogrow form-control transition-height" id="elastic-textarea"><?php echo $remarks; ?></textarea>
                  </div>
				</div>				
			</fieldset>		
					
					<div class="form-actions">
						<div class="row">
							<div class="col-sm-offset-4 col-sm-7">
								<button type="submit" class="btn btn-primary">Save Changes</button>
                                <button type="button" class="btn btn-inverse" onClick="javascript:document.location.href='so.php';">Cancel</button>
                            </div>
                        </div>
                    </div>
				</form>
			</div>
        </section>
		
    </main>
</div>
<!--CONTENT END HERE-->

<!-- The Loader. Is shown when pjax happens -->
<div class="loader-wrap hiding hide">
    <i class="fa fa-circle-o-notch fa-spin-fast"></i>
</div>

<!-- common libraries. required for every page-->
<script src="vendor/jquery/dist/jquery.min.js"></script>
<script src="vendor/jquery-pjax/jquery.pjax.js"></script>
<script src="vendor/bootstrap-sass/vendor/assets/javascripts/bootstrap/transition.js"></script>
<script src="vendor/bootstrap-sass/vendor/assets/javascripts/bootstrap/collapse.js"></script>
<script src="vendor/bootstrap-sass/vendor/assets/javascripts/bootstrap/dropdown.js"></script>
<script src="vendor/bootstrap-sass/vendor/assets/javascripts/bootstrap/button.js"></script>
<script src="vendor/bootstrap-sass/vendor/assets/javascripts/bootstrap/tooltip.js"></script>
<script src="vendor/bootstrap-sass/vendor/assets/javascripts/bootstrap/alert.js"></script>
<script src="vendor/jQuery-slimScroll/jquery.slimscroll.min.js"></script>
<script src="vendor/widgster/widgster.js"></script>
<script src="vendor/pace.js/pace.min.js"></script>
<script src="vendor/jquery-touchswipe/jquery.touchSwipe.js"></script>
<script src="vendor/jquery-touchswipe/jquery.touchSwipe.js"></script>

<!-- common app js -->
<script src="js/settings.js"></script>
<script src="js/app.js"></script>

<!-- page specific libs -->
<script src="vendor/bootstrap-sass/vendor/assets/javascripts/bootstrap/tooltip.js"></script>
<script src="vendor/bootstrap-sass/vendor/assets/javascripts/bootstrap/modal.js"></script>
<script src="vendor/bootstrap-select/bootstrap-select.min.js"></script>
<script src="vendor/jquery-autosize/jquery.autosize.min.js"></script>
<script src="vendor/bootstrap3-wysihtml5/lib/js/wysihtml5-0.3.0.min.js"></script>
<script src="vendor/bootstrap3-wysihtml5/src/bootstrap3-wysihtml5.js"></script>
<script src="vendor/select2/select2.min.js"></script>
<script src="vendor/switchery/dist/switchery.min.js"></script>
<script src="vendor/moment/min/moment.min.js"></script>
<script src="vendor/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js"></script>
<script src="vendor/mjolnic-bootstrap-colorpicker/dist/js/bootstrap-colorpicker.min.js"></script>
<script src="vendor/jasny-bootstrap/js/inputmask.js"></script>
<script src="vendor/jasny-bootstrap/js/fileinput.js"></script>
<script src="vendor/holderjs/holder.js"></script>
<script src="vendor/dropzone/downloads/dropzone.min.js"></script>
<script src="vendor/markdown/lib/markdown.js"></script>
<script src="vendor/bootstrap-markdown/js/bootstrap-markdown.js"></script>
<script src="vendor/seiyria-bootstrap-slider/dist/bootstrap-slider.min.js"></script>
<script src="vendor/parsleyjs/dist/parsley.min.js"></script>
<!-- page specific js -->
<script type="text/javascript">
//var elem = document.querySelector('.js-switch');
//var init = new Switchery(elem);
var elems = Array.prototype.slice.call(document.querySelectorAll('.js-switch'));
elems.forEach(function(html) {
  var switchery = new Switchery(html);
});
</script>
<script src="js/form-validation.js"></script>
<script type="text/javascript">
function validChars(e, goods) {
	var key, keychar;
	key = (window.event) ? window.event.keyCode : ((e) ? e.which : null);
	if (key == null) return true;

	keychar = String.fromCharCode(key);
	keychar = keychar.toLowerCase();
	goods = goods.toLowerCase();

	if (goods.indexOf(keychar) != -1)
		return true;

	if (key==null || key==0 || key==8 || key==9 || key==13 || key==27)
		return true;

	return false;
}
</script>
</body>
</html>

Zerion Mini Shell 1.0