Esempio n. 1
0
 public function store()
 {
     try {
         $createOrder = Input::json()->all();
         $addOrder = new Order();
         $addOrder->status = 1;
         $addOrder->save();
         $addOrderId = $addOrder->id;
         $numberOfItems = 0;
         foreach ($createOrder['items'] as $OrderItem) {
             $newOrderItem = new Order_Item();
             $newOrderItem->order_id = $addOrderId;
             $newOrderItem->item_id = $OrderItem['item_id'];
             $newOrderItem->order_qty = $OrderItem['order_qty'];
             $newOrderItem->save();
             $numberOfItems = $numberOfItems + 1;
         }
         $addOrder->items = $createOrder['items'];
         $addOrder->open = 'yes';
         $vendorId = $createOrder['vendor_id'];
         $addOrder->vendor_id = $vendorId;
         $vendorName = Vendor::find($vendorId);
         $addOrder->vendor_name = $vendorName->name;
         $addOrder->item_count = $numberOfItems;
         $this->addOrderToEmail($addOrder);
         return $addOrder->toJson();
     } catch (Exception $e) {
         return '{"error":{"text":' . $e->getMessage() . '}}';
     }
 }
Esempio n. 2
0
 /**
  * Auto generated seed file
  *
  * @return void
  */
 public function run()
 {
     \DB::table('order_item')->delete();
     $oids = DB::table('orders')->lists('id');
     $iids = DB::table('item')->lists('id');
     $faker = Faker\Factory::create();
     foreach (range(1, 30) as $id) {
         Order_Item::create(['order_qty' => $faker->numberBetween(1, 20), 'order_id' => $faker->randomElement($oids), 'item_id' => $faker->randomElement($iids)]);
     }
 }
Esempio n. 3
0
		public static function getByOrder($id)
		{
			global $db;
			//get order items from database
			$order_itemSQL = "SELECT * FROM order_items WHERE orderid=?";
			$values = array($id);
			$order_items = $db->qwv($order_itemSQL, $values);
			
			return Order_Item::wrap($order_items);
		}
Esempio n. 4
0
		public function __get($var)
		{
			if( $var == 'order_item' )
			{
				return Order_Item::getByID($this->order_itemid);
			}
			elseif( $var == 'modifier' )
			{
				return Modifier::getByID($this->modifierid);
			}
			elseif( $var == 'ingredient' )
			{
				return Ingredient::getByID($this->ingredientid);
			}
			else
			{
				return $this->$var;
			}
		}
Esempio n. 5
0
<div style="font-size: 13px;margin: 10px 5px">
	<?php 
//理疗师姓名查找用数据准备
$beau_model = Beautician::model();
$query = "select * from tbl_beautician";
$beau_info = $beau_model->findAllBySql($query);
//构建dropDownList的option用的数组
$beau_options = array();
foreach ($beau_info as $_beau_v) {
    if ($_beau_v->beau_valid != 1) {
        continue;
    }
    $beau_options["{$_beau_v->pk_beau_id}"] = "{$_beau_v->beau_realname}";
}
//商品名称及时间数据准备
$ord_item_model = Order_Item::model();
$ord_item_info = $ord_item_model->findByPk($aptm_info->aptm_ord_item_id);
if (isset($ord_item_info)) {
    $comm_model = Commodity::model();
    $comm_info = $comm_model->findByPk($ord_item_info->ord_item_comm_id);
    $comm_serv_model = Commodity_Service::model();
    $comm_serv_info = $comm_serv_model->findByPk($ord_item_info->ord_item_comm_id);
}
?>
	<?php 
$form = $this->beginWidget('CActiveForm');
?>
	<table border="1" width="100%" class="table_a">
		<tr bgcolor="#add8e6">
			<td>
				<?php 
Esempio n. 6
0
</div>
<div style="font-size: 13px; margin: 10px 5px;">
	<table class="table_a" border="1" width="100%">
		<tbody><tr bgcolor="#4169e1" style="font-weight: bold;">
<!--			<td align="center">操作</td>-->
			<td align="center">订单编号</td>
<!--			<td>顾客编号</td>-->
			<td>订单状态</td>
			<td>顾客姓名</td>
			<td>支付方法</td>
            <td>订单金额</td>
            <td>更新时间</td>
		</tr>
		<?php 
$i = 0;
$order_model = Order_Item::model();
foreach (array_reverse($order_info) as $_v) {
    $price = 0;
    ?>
			<tr <?php 
    if ($i % 2 != 0) {
        echo 'bgcolor="#add8e6"';
    } else {
        echo 'bgcolor="#ffffff"';
    }
    ?>
 id="user1">
<!--				<td><a href="./index.php?r=order/detail&id=--><?php 
    //echo $_v->pk_ord_id
    ?>
<!--">详细</a></td>-->
Esempio n. 7
0
	$active_items = array();
	
	//get all active orders
	if(Order::getAllActive())
	{
			//get all active orders
			//This is the only line needed for the waiter screen to function
			$active_order_objects = Order::getAllActive();
			
			//multiple orders
			if(is_array($active_order_objects))
			{
				foreach($active_order_objects as $active_order_object)
				{
					//for each order, get all items on that order
					$active_order_items = Order_Item::getByOrder($active_order_object->orderid);
					
					//multiple items on order
					if(is_array($active_order_items))
					{
						foreach($active_order_items as $active_order_item)
						{
							$thisitem = array(	'orderid' => $active_order_item->orderid,
											'name' => Item::getByID($active_order_item->itemid)->name,
											'specialComment' => Order::getByID($active_order_item->orderid)->specialComment,
											'tablenumber' => Order::getByID($active_order_item->orderid)->tableid,
											'time' => date("g:i (A) m/d/y", Order::getByID($active_order_item->orderid)->time),
											'status' => Order::getByID($active_order_item->orderid)->statusid,
											'user' => Order::getByID($active_order_item->orderid)->userid,
											'itemid' => $active_order_item->itemid,
											'catid' => Item::getByID($active_order_item->itemid)->categoryid
Esempio n. 8
0
	$tmpl->breadcrumb = $bc->path;
	$tmpl->report_type = $report_type;
	$page->run();
	

	//get all items
	$items = array();
	$items = Item::getAll();
	$tmpl->items = $items;
	
	$item_counts = array();
	
	//get all item counts
	foreach($items as $item)
	{
		$item_counts[$item->itemid] = Order_Item::getOrderCount($item->itemid);
	}
	
	$tmpl->item_counts = $item_counts;

	$order_times = array();
	
	//push active orders
	$active_orders = Order::getAllActive();
	if(is_array($active_orders))
	{
		foreach($active_orders as $active_order)
		{
			$order_times[date("G", $active_order->time)]++;
		}
	}
Esempio n. 9
0
		public function __get($var)
		{
			if( $var == 'table' )
			{
				return Table::getByID($this->tableid);
			}
			elseif( $var == 'user' )
			{
				return User::getByID($this->userid);
			}
			elseif( $var == 'status' )
			{
				return Status::getByID($this->statusid);
			}
			elseif( $var == 'items' )
			{
				return Order_Item::getByOrder($this->orderid);
			}
			else
			{
				return $this->$var;
			}
		}
Esempio n. 10
0
function aptm_infomation($appointment)
{
    $order_item_model = Order_Item::model();
    $comm_service_model = Commodity_Service::model();
    $order_model = Order::model();
    $commodity_model = Commodity::model();
    $view_order_count_model = View_Order_Count::model();
    $aptm_infomation = array();
    //开始时间
    $start_time = date("H:i", strtotime($appointment->aptm_time));
    $aptm_infomation[0] = $start_time;
    //终了时间
    $query = 'select * from tbl_order_item where pk_ord_itm_id=' . $appointment->aptm_ord_item_id;
    $order_item_info = $order_item_model->findBySql($query);
    $duration = 30;
    if (isset($order_item_info)) {
        $query = 'select * from tbl_commodity_service where pk_serv_id=' . $order_item_info->ord_item_comm_id;
        $comm_service_info = $comm_service_model->findBySql($query);
        if (isset($comm_service_info)) {
            $duration += $comm_service_info->serv_duration;
        }
    }
    $end_time = date("H:i", strtotime("{$start_time} + {$duration} minute"));
    $aptm_infomation[1] = $end_time;
    //预约单号
    //		$aptm_infomation[2] = $appointment->pk_aptm_id;
    //订单号
    if (isset($order_item_info)) {
        $aptm_infomation[2] = $order_item_info->pk_ord_itm_ord_id;
    }
    //客户姓名
    $aptm_infomation[3] = $appointment->aptm_cust_name;
    //客户编号
    $cust_id = 0;
    if (isset($order_item_info)) {
        $query = 'select * from tbl_order where pk_ord_id=' . $order_item_info->pk_ord_itm_ord_id;
        $order_info = $order_model->findBySql($query);
        if (isset($order_info)) {
            $cust_id = $order_info->ord_cust_id;
        }
    }
    $aptm_infomation[4] = $cust_id;
    //预约项目
    $aptm_name = '未知';
    if (isset($comm_service_info)) {
        $query = 'select * from tbl_commodity where pk_comm_id=' . $comm_service_info->pk_serv_id;
        $commodity_info = $commodity_model->findBySql($query);
        if (isset($commodity_info)) {
            $aptm_name = $commodity_info->comm_name;
        }
    }
    $aptm_infomation[5] = $aptm_name;
    //地址
    $aptm_infomation[6] = $appointment->aptm_cust_addr;
    //联系方式
    $aptm_infomation[7] = $appointment->aptm_cust_tel;
    //刷卡金额
    $price = 0;
    if (isset($order_info)) {
        $query = 'select * from view_order_count where pk_ord_id = ' . $order_info->pk_ord_id;
        $view_order_count_info = $view_order_count_model->findBySql($query);
        //			echo '<pre>';
        //			print_r($view_order_count_info);
        //			echo '</pre>';
        if (isset($view_order_count_info)) {
            $price = $view_order_count_info->total;
        }
        $price -= $order_info->ord_paid_money;
    }
    $aptm_infomation[8] = $price;
    return $aptm_infomation;
}
Esempio n. 11
0
 /**
  * 按照选定的日期和美疗师来显示预约(包括普通预约和1元预约),用以计算金额
  * @throws CException
  */
 public function actionSelectAptmByDay()
 {
     define('APTM_ID', 0);
     define('COMM_NAME', 1);
     define('CUST_NAME', 2);
     define('PRICE', 3);
     if (isset($_POST['beau_id']) && $_POST['beau_id'] != 0 && isset($_POST['from_date_year']) && isset($_POST['from_date_month']) && isset($_POST['from_date_day']) && isset($_POST['to_date_year']) && isset($_POST['to_date_month']) && isset($_POST['to_date_day'])) {
         //整理日期
         $from_date = $_POST['from_date_year'] . '-' . $_POST['from_date_month'] . '-' . $_POST['from_date_day'];
         $to_date = $_POST['to_date_year'] . '-' . $_POST['to_date_month'] . '-' . $_POST['to_date_day'];
         $from_date = date("Y-m-d H:i:s", strtotime("{$from_date}"));
         $to_date = date('Y-m-d H:i:s', strtotime("{$to_date} +1 day"));
         if ($from_date > $to_date) {
             echo "<script>alert('起始日期应该早于或等于终了日期!');</script>";
         }
         //TODO:金额信息较复杂,应该需要再建一张表来计算,需要讨论
         //传递形式:
         /*
         xxxx-xx-xx
         ------------------------------------------
         |aptmid|aaaa                             |
         |项目名 |aaaa                             |
         |客户名 |bbbb                             |
         |金额: |111                              |
         ------------------------------------------
         xxxx-xx-xx
         ------------------------------------------
         |aptmid|aaaa                             |
         |项目名 |aaaa                             |
         |客户名 |bbbb                             |
         |金额: |111                              |
         ------------------------------------------
         |aptmid|aaaa                             |
         |项目名 |aaaa                             |
         |客户名 |bbbb                             |
         |金额: |111                              |
         ------------------------------------------
         */
         //定义数组
         $day_count = $this->countDays($from_date, $to_date);
         $aptm_info_by_day = array($day_count);
         //查询普通预约
         //(从tbl_appointment的预约日期入手,包括关联的tbl_order_item,tbl_commodity以获取客户名,项目名等信息)
         $aptm_model = Aptm::model();
         $query = 'select * from tbl_appointment where aptm_beau_id = ' . $_POST['beau_id'] . ' and aptm_time >= "' . $from_date . '"' . ' and aptm_time < "' . $to_date . '"';
         $aptm_info = $aptm_model->findAllBySql($query);
         if (isset($aptm_info)) {
             for ($cnt_day = 0; $cnt_day < $day_count; $cnt_day++) {
                 $counter_by_day = 0;
                 foreach ($aptm_info as $_v_aptm_info) {
                     $day_selected = date('Y-m-d', strtotime("{$from_date}" . ' +' . $cnt_day . ' day'));
                     $day_compare = date('Y-m-d', strtotime($_v_aptm_info->aptm_time));
                     if ($day_selected == $day_compare) {
                         //                            $info_by_day[APTM_ID] = $_v_aptm_info->pk_aptm_id;
                         //                            $info_by_day[CUST_NAME] = $_v_aptm_info->aptm_cust_name;
                         //                            $info_by_day[COMM_NAME] = '未取得';
                         //                            $info_by_day[PRICE] = 0;
                         $info_by_day = new InfoByDay();
                         $info_by_day->aptm_id = $_v_aptm_info->pk_aptm_id;
                         $info_by_day->cust_name = $_v_aptm_info->aptm_cust_name;
                         //查询tbl_order_item表以取得commodity_id
                         $order_item_model = Order_Item::model();
                         $order_item_info = $order_item_model->findByPk($_v_aptm_info->aptm_ord_item_id);
                         if (isset($order_item_info)) {
                             $comm_model = Commodity::model();
                             $comm_info = $comm_model->findByPk($order_item_info->ord_item_comm_id);
                             if (isset($comm_info)) {
                                 //                                    $info_by_day[COMM_NAME] = $comm_info->comm_name;
                                 $info_by_day->comm_name = $comm_info->comm_name;
                             }
                             //TODO:此处为暂定处理,在修改金额的时候需要修改!
                             //                                $info_by_day[PRICE] = $order_item_info->ord_item_price;
                             $info_by_day->price = $order_item_info->ord_item_price;
                         }
                         $aptm_info_by_day[$cnt_day][$counter_by_day] = $info_by_day;
                         $counter_by_day++;
                     }
                 }
             }
         }
         //查询1元特殊预约
         $contact_model = Contact::model();
         $query = 'select * from tbl_contact where con_beau_id = ' . $_POST['beau_id'] . ' and con_time >="' . $from_date . '"' . ' and con_time <"' . $to_date . '"';
         $contact_info = $contact_model->findAllBySql($query);
         $contact_info_by_day = array($day_count);
         if (isset($contact_info)) {
             for ($cnt_day = 0; $cnt_day < $day_count; $cnt_day++) {
                 $counter_by_day = 0;
                 foreach ($contact_info as $_v_contact_info) {
                     //                        $info_by_day[APTM_ID] = $_v_contact_info->pk_contact_id;
                     //                        $info_by_day[CUST_NAME] = $_v_contact_info->con_name;
                     //                        $info_by_day[COMM_NAME] = '未取得';
                     //                        //TODO:此处为暂定处理,在修改金额的时候需要修改!
                     //                        $info_by_day[PRICE] = 0;
                     $info_by_day = new InfoByDay();
                     $info_by_day->aptm_id = $_v_contact_info->pk_contact_id;
                     $info_by_day->cust_name = $_v_contact_info->con_name;
                     //查询tbl_code表以获取COMM_NAME
                     $code_model = Code::model();
                     $query = 'select * from tbl_code where code_tbl_name="tbl_contact" and code_name="con_prefer" and code_value=' . $_v_contact_info->con_prefer;
                     $code_info = $code_model->findBySql($query);
                     if (isset($code_info)) {
                         //                            $info_by_day[COMM_NAME] = $code_info->code_meaning;
                         $info_by_day->comm_name = $code_info->code_meaning;
                     }
                     $contact_info_by_day[$cnt_day][$counter_by_day] = $info_by_day;
                     //TODO:此处的三维数组改为自定义类试试看
                     $counter_by_day++;
                 }
             }
         }
         //获取美疗师姓名
         $beau_model = Beautician::model();
         $beau_info = $beau_model->findByPk($_POST['beau_id']);
         $beau_name = '没名字';
         if (isset($beau_info)) {
             $beau_name = $beau_info->beau_realname;
         }
         //            //转向列表显示页面
         //            $this->redirect('./index.php?r=aptm/showAptmByDay&beau_name='.$beau_name.
         //                            'from_date='.$from_date.
         //                            'to_date='.$to_date.
         //                            'day_count='.$day_count.
         //                            'aptm_info_by_day='.$aptm_info_by_day.
         //                            'contact_info_by_day='.$contact_info_by_day);
         $this->actionShowAptmByDay($beau_name, $from_date, $to_date, $day_count, $aptm_info_by_day, $contact_info_by_day);
         return;
     }
     //有东西没有选择的话,依旧描绘当前的选择视图
     //TODO:需要将已经选择的内容回传给视图以便修改
     $this->renderPartial('selectAptmByDay');
 }
Esempio n. 12
0
 /**
  * 订单详细信息修改
  */
 public function actionUpdate($id, $ordItmID)
 {
     $order_model = Order::model();
     $order_info = $order_model->findByPk($id);
     //查找出本订单相关的所有订单商品
     $query = 'select * from tbl_order_item where pk_ord_itm_ord_id = ' . $order_info->pk_ord_id;
     $order_model = Order_Item::model();
     $order_item_info = $order_model->findAllBySql($query);
     if (isset($order_info)) {
         if ($ordItmID != 'FFFFFFFF') {
             //订单内商品删除用处理
             $order_item = $order_model->findByPk($ordItmID);
             if (isset($order_item)) {
                 $aptm_model = Aptm::model();
                 $query_aptm = 'select * from tbl_appointment where aptm_ord_item_id = ' . $ordItmID;
                 $aptm_info = $aptm_model->findAllBySql($query_aptm);
                 foreach ($aptm_info as $_v) {
                     $_v->delete();
                 }
                 $order_item->delete();
             }
         } else {
             if (isset($_POST["Order"])) {
                 //保存变更之前的订单状态
                 $ord_status_org = $order_info->ord_status;
                 $order_info->attributes = $_POST["Order"];
                 //订单更新时间更新
                 $order_info->ord_upt_time = date("Y-m-d H:i:s", time());
                 //订单收货信息更新
                 //如果用户没有设置订单收货信息(姓名地址邮编电话),则从customer表中查询信息
                 //                $cust_model = Customer::model();
                 //                $cust_info = $cust_model->findByPk($order_model->ord_cust_id);
                 //                if(isset($cust_info)) {
                 //                    if($order_info->ord_cust_name == '') {
                 //                        $order_info->ord_cust_name = $cust_info->cust_realname;
                 //                    }
                 //                    if($order_info->ord_cust_tel == '') {
                 //                        $order_info->ord_cust_tel = $cust_info->cust_mobile1;
                 //                    }
                 //                }
                 if ($order_info->save()) {
                     //保存变更之后的订单状态
                     $ord_status_mod = $order_info->ord_status;
                     /*
                      * 如果是从 非完成 变为 完成
                      *  则向该用户账户余额里增加金额相应积分
                      * 如果是从 完成 变为 非完成
                      *  则从该用户账户余额里扣除金额相应积分,不足以抵扣的,将积分归0
                      * 但是订单金额里面,需要去除用户用积分抵扣的部分
                      */
                     //计算金额(扣除积分抵扣的部分)
                     $total_price = 0;
                     foreach ($order_item_info as $_v) {
                         $total_price += $_v->ord_item_price;
                     }
                     $total_price -= $order_info->ord_deductible;
                     if ($total_price < 0) {
                         $total_price = 0;
                     }
                     //查找用户
                     $query = 'select * from tbl_customer where pk_cust_id=' . $order_info->ord_cust_id;
                     $cust_info = Customer::model()->findBySql($query);
                     //积分处理
                     if (isset($cust_info)) {
                         if ($ord_status_org != 600) {
                             if ($ord_status_mod == 600) {
                                 //从 非完成 变为 完成,订单金额进入用户积分(1元1分)
                                 $cust_info->cust_point += $total_price;
                             }
                         } else {
                             if ($ord_status_mod != 600) {
                                 //从 完成 变为 非完成,从用户积分扣除订单金额(1元1分)
                                 $cust_info->cust_point -= $total_price;
                                 //如果积分为负数,则变为0
                                 if ($cust_info->cust_point < 0) {
                                     $cust_info->cust_point = 0;
                                 }
                             }
                         }
                     }
                     $cust_info->save();
                     //画面转向
                     $this->redirect("./index.php?r=order/detail&id={$id}");
                 } else {
                     //var_dump($user_info->getErrors());
                     //var_dump($customer_info->getErrors());
                     echo "<script>alert('订单信息修改失败!');</script>";
                 }
             }
         }
         $this->renderPartial('update', array("order_info" => $order_info, 'order_item_info' => $order_item_info));
     } else {
         echo "<script>alert('未找到该订单!');</script>";
     }
 }