/** * 服务删除 */ public function actionDelService($id) { $commodity_model = Commodity::model(); $commodity_info = $commodity_model->findByPk($id); $commodity_service_model = Commodity_Service::model(); $commodity_service_info = $commodity_service_model->findByPk($id); //如果有单独服务信息的话,先删除单独的服务信息,再删除主表信息 if (isset($commodity_service_info)) { if ($commodity_service_info->delete() && $commodity_info->delete()) { $this->redirect('./index.php?r=commodity/showService'); } else { echo "<script>alert('" . $commodity_info->comm_name . " 删除失败');</script>"; } } else { if ($commodity_info->delete()) { $this->redirect('./index.php?r=commodity/showService'); } else { echo "<script>alert('" . $commodity_info->comm_name . " 删除失败');</script>"; } } }
$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 echo $form->label($aptm_info, 'pk_aptm_id'); ?> </td> <td> <?php
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; }