%PDF- %PDF-
| Direktori : /home/riacommer/public_html/admin/ |
| Current File : /home/riacommer/public_html/admin/so_ce2.php |
<?php
$msg="";
$action="create";
$id="";
$sonumber="";
$dis_sonumber="";
$sodate="";
$terms="";
$dis_terms="";
$status="";
$dis_status="";
$email="";
$remarks="";
//shipping address
$s_name="";
$s_contact="";
$s_address="";
$s_address2="";
$s_city="";
$s_postcode="";
$s_state="";
$s_country="";
if(isset($_GET["id"])){
$action="edit";
$id=$_GET["id"];
$sql = "SELECT so.*, (select email from csb_customer where id = so.customerid) as email FROM csb_so so WHERE so.id = '" . $id . "'";
$mysql_result = mysql_query($sql, $connection);
$num_rows = mysql_num_rows($mysql_result);
if($num_rows>=1){
while($row = mysql_fetch_array($mysql_result)){
$sonumber = $row["sonumber"];
$dis_sonumber = sprintf("SO-%08s", $row["sonumber"]);
$sodate = $row["sodate"];
$terms = $row["terms"];
if($terms=="2"){
$dis_terms = "Credit Card";
} else if($terms=="48"){
$dis_terms = "PayPal (MYR)";
} else if($terms=="0"){
$dis_terms = "Cash/Cheque Deposit";
}
$status = $row["status"];
if($status=="1"){
$dis_status = "Pending Payment";
}
$remarks = $row["remarks"];
$email = $row["email"];
$s_name=$row["sname"];
$s_contact=$row["scontact"];
$s_address=$row["saddress"];
$s_address2=$row["saddress2"];
$s_city=$row["scity"];
$s_postcode=$row["spostcode"];
$s_state=$row["sstate"];
$s_country="Malaysia";
}
}
}
if(isset($_POST["action"])){ //capture for create and edit only
/*$userId=SQLEncode($_POST["userId"]);
$userPwd=SQLEncode($_POST["confirmpwd"]);
$active = "0";
if(isset($_POST["active"])){
$active = "1";
}*/
$status = SQLEncode($_POST["cmbStatus"]);
$remarks = SQLEncode($_POST["remarks"]);
}
if(isset($_POST["action"]) && $_POST["action"]=="edit"){
$id=SQLEncode($_POST["id"]); //for id only
//business logic code here
$sql = "UPDATE csb_so SET status = '".$status."', remarks = '" . $remarks . "' WHERE id = '" . $id . "'";
$isSuccess = mysql_query($sql);
if($isSuccess==1){
$msg = "Record is updated successfully.";
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Administrator - Control Panel</title>
<link href="../css/form.css" rel="stylesheet" type="text/css" />
<link href="../css/table.css" rel="stylesheet" type="text/css" />
<link href="../css/admin.css" rel="stylesheet" type="text/css" />
<script language="javascript">
function doCancel(){
document.location.href="orders.php";
}
function checkAll(){
var eMsg="";
var isOK=true;
if(document.frm.userId.value==""){
eMsg += "User ID is required.<br />";
}
if(eMsg !=""){
eMsg = "The following field information is required:<br>" + eMsg;
//goto top
isOK = false;
if(document.getElementById('abox')!=null){
document.getElementById('ibox').removeChild(document.getElementById('abox'));
}
var newdiv = document.createElement('div');
var divIdName = 'abox';
newdiv.setAttribute('id','abox');
newdiv.setAttribute('name','abox');
newdiv.setAttribute('class','alert');
newdiv.setAttribute('className','alert');
newdiv.innerHTML = eMsg;
document.getElementById('ibox').appendChild(newdiv);
document.location.href="#top";
if (window.parent && window.parent.autoIframe) {window.parent.autoIframe('tabIframe2');}
} else {
isOK=true;
if(document.getElementById('abox')!=null){
document.getElementById('ibox').removeChild(document.getElementById('abox'));
}
}
return isOK;
}
</script>
</head>
<body>
<p>
<?php include_once ("header.php");?>
</p>
<p class="header">Order Details</p>
<div class="main" style="width:95%">
<div id="ibox" name="ibox">
<?php
if($msg!=""){
echo "<div id='abox' name='abox' class='alert'>" . $msg . "</div>";
}
?>
<br/>
<a href="email_so.php?id=<?php echo $id; ?>" target="_blank">Email Sales Order []</a><br /><br />
</div>
<div class="box">
<form action="orders_ce.php?id=<?php echo $id; ?>" method="post" id="frm" name="frm" onSubmit="return checkAll();">
<input type="hidden" id="action" name="action" value="<?php echo $action; ?>"/>
<input type="hidden" id="id" name="id" value="<?php echo $id; ?>"/>
<h3>Order Details</h3>
<label>
<span>Sales Order:</span>
<?php echo $dis_sonumber; ?>
</label>
<label>
<span>S.O. Date:</span>
<?php echo $sodate; ?>
</label>
<label>
<span>Payment Method:</span>
<?php echo $dis_terms; ?>
</label>
<label>
<span>Status:</span>
<?php //echo $dis_status; ?>
<select id="cmbStatus" name="cmbStatus">
<option value="1" <?php echo ($status=="1")?"selected":""; ?>>Pending Payment</option>
<option value="2" <?php echo ($status=="2")?"selected":""; ?>>Paid</option>
<option value="3" <?php echo ($status=="3")?"selected":""; ?>>Cancel</option>
</select>
</label>
<label>
<span>Remarks:</span>
<textarea cols="40" rows="5" id="remarks" name="remarks"><?php echo XMLEncode($remarks); ?></textarea>
</label>
<label>
<span> </span>
</label>
<label>
<span></span>
<div class="info">
<input type="submit" value="Save"/>
<input type="button" value="Cancel" onclick="doCancel();"/>
</div>
</label>
<h3>Order Items</h3>
<table width="520" border="1" cellpadding="2" cellspacing="0">
<tr>
<td>#</td><td><b>类别</b></td><td><b>项目</b></td><td align="right"><b>价钱</b></td>
</tr>
<?php
$cnt=0;
$ttlAmt=0;
$sql = "SELECT prod.id, prod.productid, prod.unitprice, prod.remarks as 'from_issue' FROM `csb_so_product` prod where prod.soid=" . $sonumber . " and prod.prodtype='subscribe' order by prod.createddate DESC";
//echo $sql;
$mysql_result = mysql_query($sql, $connection);
$num_rows = mysql_num_rows($mysql_result);
if($num_rows>=1){
while($row = mysql_fetch_array($mysql_result)){
$cnt++;
$id = $row["id"];
$productid = $row["productid"];
$issueNo = '从第'.$row["from_issue"] . '期 至 第' . ($row["from_issue"]+11) . '期';
$maintitle = ""; //$row["maintitle"];
$unitprice = $row["unitprice"];
if($productid=="-5"){
$maintitle = '一年/十二期在线下载版, ' . $issueNo;
}
//if($productid=="postal_yearly"){
if($productid=="-10"){
$maintitle = '一年/十二期邮寄杂志, ' . $issueNo;
}
echo '<tr><td>'.$cnt.'</td>';
//echo '<td>杂志</td>';
if($productid=="-5"){
echo '<td>杂志 (十二期下载)</td>';
} else if($productid=="-10"){
echo '<td>杂志 (十二期邮寄)</td>';
} else {
echo '<td>杂志 (单期下载)</td>';
}
echo '<td>' . $maintitle . '</td>';
echo '<td align="right">RM '.number_format($unitprice, 2).'</td>';
echo '</tr>';
$ttlAmt += $unitprice;
}
}
$sql = "SELECT prod.id, prod.productid, prod.unitprice, mag.issue, mag.year, mag.maintitle, mag.cover FROM `csb_so_product` prod, csb_magazine mag where prod.productid = mag.id and prod.soid=" . $sonumber . " and prod.prodtype='magazine' order by prod.createddate DESC";
$mysql_result = mysql_query($sql, $connection);
$num_rows = mysql_num_rows($mysql_result);
if($num_rows>=1){
while($row = mysql_fetch_array($mysql_result)){
$cnt++;
$id = $row["id"];
$productid = $row["productid"];
$issueNo = '第'.$row["issue"] . '期,' . $row["year"];
$maintitle = $row["maintitle"];
$unitprice = $row["unitprice"];
echo '<tr><td>'.$cnt.'</td>';
//echo '<td>杂志</td>';
if($productid=="-5"){
echo '<td>杂志 (十二期下载)</td>';
} else if($productid=="-10"){
echo '<td>杂志 (十二期邮寄)</td>';
} else {
echo '<td>杂志 (单期下载)</td>';
}
echo '<td>' . $issueNo . ' ' . $maintitle . '</td>';
echo '<td align="right">RM '.number_format($unitprice, 2).'</td>';
echo '</tr>';
$ttlAmt += $unitprice;
}
}
//$sql = "SELECT prod.id, prod.productid, mag.issue, mag.year, mag.maintitle, mag.cover FROM `csb_so_product` prod, csb_magazine mag where prod.productid = mag.id and prod.soid=" . $sonumber . " and prodtype='article' order by prod.createddate DESC";
$sql = "SELECT prod.id, prod.productid, prod.unitprice, article.title, mag.issue, mag.year FROM `csb_so_product` prod, csb_articles article, csb_magazine mag
where prod.productid = article.id and prod.soid = '" . $sonumber . "' and prod.prodtype = 'article' and article.magazineid = mag.id
order by prod.createddate desc";
//echo '<br />' . $sql;
$mysql_result = mysql_query($sql, $connection);
$num_rows = mysql_num_rows($mysql_result);
if($num_rows>=1){
while($row = mysql_fetch_array($mysql_result)){
$cnt++;
$id = $row["id"];
$productid = $row["productid"];
$issueNo = '第' . $row["issue"] . '期,' . $row["year"];
$maintitle = $row["title"];
$unitprice = $row["unitprice"];
echo '<tr><td>'.$cnt.'</td>';
echo '<td>文章 (下载)</td>';
echo '<td>' . $issueNo . ' ' . $maintitle . '</td>';
echo '<td align="right">RM '.number_format($unitprice,2).'</td>';
echo '</tr>';
$ttlAmt += $unitprice;
}
}
echo '<tr><td colspan="3" align="right"><b>总价:</b></td><td align="right"><b>RM ' . number_format($ttlAmt, 2, '.', ',') . '</b></td></tr>';
?>
</table>
<br />
<h3>Billing Address <a href="#" style="font-size:10px;font-weight:normal;">[Edit]</a></h3>
<?php
$member = new Member($connection);
$member->doSelect($email);
?>
<label>
<span>Customer Name:</span>
<?php echo $member->name; ?>
</label>
<label>
<span>Email:</span>
<?php echo $member->email; ?>
</label>
<label>
<span>Contact:</span>
<?php echo $member->tel; ?>
</label>
<label>
<span>Address 1:</span>
<?php echo $member->address1; ?>
</label>
<label>
<span>Address 2:</span>
<?php echo $member->address2; ?>
</label>
<label>
<span>City:</span>
<?php echo $member->city; ?>
</label>
<label>
<span>State:</span>
<?php echo $member->state; ?>
</label>
<label>
<span>Country:</span>
<?php echo "Malaysia"; ?>
</label>
<br /><br />
<h3>Shipping Address <a href="#" style="font-size:10px;font-weight:normal;">[Edit]</a></h3>
<label>
<span>Customer Name:</span>
<?php echo $s_name; ?>
</label>
<label>
<span>Contact:</span>
<?php echo $s_contact; ?>
</label>
<label>
<span>Address 1:</span>
<?php echo $s_address; ?>
</label>
<label>
<span>Address 2:</span>
<?php echo $s_address2; ?>
</label>
<label>
<span>City:</span>
<?php echo $s_city; ?>
</label>
<label>
<span>State:</span>
<?php echo $s_state; ?>
</label>
<label>
<span>Country:</span>
<?php echo "Malaysia"; ?>
</label>
</form>
</div>
<?php include_once("footer.php"); ?>
</body>
</html>