<?php
 /**
 *      [XCECP] (C) COLNET Inc.
 *      This is NOT a freeware, use is subject to license terms
 */
if(!defined("IN_QKWEB")){exit("Access Denied");}
class OrderAdmin{
	function index(){
		load_class("order");
		$om = new OrderModel();
		$act= getgpc("act","P");
		$id = getgpc("id","P");
		$inajax = getgpc("inajax","P");
		if($inajax==1){
			$ret = array('success'=>false,'message'=>'参数错误');
			if($act=="addGoods"){
				echo $om->addGoods($_POST);exit;
			}else if($act=="editGoods"){
				echo $om->editGoods($_POST);exit;
			}else if($act=="addOrder"){
				echo $om->addOrder($_POST);exit;
			}else if($act=="del" && $id && settype($id,"integer")){
				if($om->del($id)){
					$ret = array('success'=>true);
					echo json_encode($ret);exit;
				}
			}else if($act=="ajaxEdit"){
				if($om->ajaxEdit($_POST)){
					exit('{"success":true}');
				}
			}else if($act=="ship" && $id && settype($id,"integer")){
				$res = $om->ship($_POST);
				if($inajax==1){
					if($res){
						exit('{"success":true}');
					}else{
						$ret = array('success'=>false,'message'=>$om->msg);
					}
				}
			}
			echo json_encode($ret);exit;
		}
		if($act=="edit" && $id && settype($id,"integer")){
			$res = $om->edit($_POST);
				if($res){
					exit('{"success":true}');
				}else{
					exit('{"success":false}');
				}
		}
		$act = getgpc("act");
		$id = getgpc("id");
			load_class("delivery");
			$dm = new DeliveryModel();
			$deliveryType = $dm->getAllType(); 
			assign("deliveryType",$deliveryType);
		
		if($act=="edit" && $id && settype($id,"integer") ){
			$orderInfo = $om->getInfo($id);
			assign("orderInfo",$orderInfo);
		}
		$status = $om->getAllStatus();
		assign("status",$status);
		display("order");
	}
	function service(){
		load_class("order");
		$om = new OrderModel();
		$act= getgpc("act","P");
		$id = getgpc("id","P");
		$inajax = getgpc("inajax","P");
		if($inajax==1){
			$ret = array('success'=>false,'message'=>'参数错误');
			if($act=="ajaxEdit"){
				$ret['success'] = $om->ajaxEditService($_POST);
			}else if($act=="del" && $id && settype($id,"integer")){
				$ret['success'] = $om->delService($id);
			}
			echo json_encode($ret);exit;
		}
		display("order/service");
	}
}
?>