Пример #1
0
 public function doList()
 {
     //list
     $listPageHelper = new ListPageHelper();
     $listPageHelper->pageSize = 10;
     $pageNum = intval(Request::get("page"));
     $listPageHelper->pageNum = $pageNum ? $pageNum : 1;
     //Condition
     $ordersCondition = new OrdersValue();
     //派单显示的模式
     $orderListModel = '所有派单';
     switch (Request::get('type')) {
         case 'today':
             $ordersCondition->addAddtimeCondition(date("Y-m-d H:i:s", mktime(23, 59, 59, date('m'), date('d') - 1)), Value::GREATER_THAN);
             $orderListModel = '今日派单';
             break;
         case 'week':
             //设置星期
             if (date('w') == 0) {
                 $w = 6;
             } else {
                 $w = date('w') - 1;
             }
             $ordersCondition->addAddtimeCondition(date("Y-m-d H:i:s", mktime(0, 0, 0, date('m'), date('d') - $w)), Value::GREATER_EQUAL);
             $orderListModel = '本周派单';
             break;
         case 'month':
             $ordersCondition->addAddtimeCondition(date("Y-m-d H:i:s", mktime(0, 0, 0, date('m'), 1)), Value::GREATER_EQUAL);
             $orderListModel = '本月派单';
             break;
         case 'year':
             $ordersCondition->addAddtimeCondition(date("Y-m-d H:i:s", mktime(0, 0, 0, 1, 1, date('y'))), Value::GREATER_EQUAL);
             $orderListModel = '今年派单';
             break;
             //成交状态
         //成交状态
         case 'isop':
             $ordersCondition->addOperateStatusCondition(Value::OPERATE_STATUS_OPERATED, Value::EQUAL);
             $orderListModel = '已经成交的派单';
             break;
         case 'notop':
             $ordersCondition->addOperateStatusCondition(Value::OPERATE_STATUS_NOT_OPERATE, Value::EQUAL);
             $orderListModel = '未成交的派单';
             break;
             //是否查看
         //是否查看
         case 'isview':
             $orderListModel = '已经查看过的派单';
             $ordersCondition->addStatusCondition(Value::STATUS_SEEM, Value::EQUAL);
             break;
         case 'notview':
             $orderListModel = '未查看过的派单';
             $ordersCondition->addStatusCondition(Value::STATUS_NOT_SEE, Value::EQUAL);
             break;
             //联系状态
         //联系状态
         case 'c' . Value::CONTACT_STATUS_CANNOT_CONTACT:
             $ordersCondition->addContactStatusCondition(Value::CONTACT_STATUS_CANNOT_CONTACT, Value::EQUAL);
             $orderListModel = '无法联系的派单';
             break;
         case 'c' . Value::CONTACT_STATUS_CONTACTED:
             $ordersCondition->addContactStatusCondition(Value::CONTACT_STATUS_CONTACTED, Value::EQUAL);
             $orderListModel = '已经联系的派单';
             break;
         case 'c' . Value::CONTACT_STATUS_NOT_CONTACT:
             $ordersCondition->addContactStatusCondition(Value::CONTACT_STATUS_NOT_CONTACT, Value::EQUAL);
             $orderListModel = '未联系的派单';
             break;
             // page from search//
         // page from search//
         case 'time':
             //按时间范围搜索
             $start = Request::get('start');
             $end = Request::get('end');
             if ($start == '' or $end == '') {
                 Zee::redirect(Zee::url('orders', 'search'));
             } else {
                 $ordersCondition->addAddtimeCondition($start, Value::GREATER_EQUAL);
                 $ordersCondition->addAddtimeCondition($end, Value::LESS_EQUAL);
                 $orderListModel = '时间段 ' . $start . ' 到 ' . $end . '的派单';
             }
             break;
         case 'mobile':
             $mobile = Request::get('num');
             if ($mobile == '') {
                 Zee::redirect(Zee::url('orders', 'search'));
             } else {
                 $ordersCondition->addMobileCondition($mobile, Value::LIKE);
                 $ordersCondition->addCondition('1=1 or `orders`.telephone ' . Value::LIKE . ' \'' . $mobile . ' \'');
                 //也查找一下固定电话
             }
             $orderListModel = '手机号(或者固定电话)为 ' . $mobile . ' 的派单';
             break;
         case 'his':
             $his = Request::get('his');
             if ($his == '') {
                 Zee::redirect(Zee::url('orders', 'search'));
             } else {
                 $ordersCondition->addHISCondition($his, Value::LIKE);
             }
             $orderListModel = 'HIS为 ' . $his . ' 的派单';
             break;
         case 'orderid':
             $orderid = Request::get('num');
             if ($orderid == '') {
                 Zee::redirect(Zee::url('orders', 'search'));
             } else {
                 $ordersCondition->addOrderIdCondition($orderid, Value::LIKE);
             }
             $orderListModel = '派单ID为 ' . $orderid . ' 的派单';
             break;
         case 'project':
             //按项目名称
             $project = Request::get('project');
             if ($project == '') {
                 Zee::redirect(Zee::url('orders', 'search'));
             } else {
                 $ordersCondition->addProjectIdCondition($project, Value::EQUAL);
             }
             $projectService = new ProjectService();
             $projectInfo = $projectService->getByPrimary($project);
             $orderListModel = '项目为 ' . $projectInfo->project_name . ' 的派单';
             break;
         case 'name':
             //按客户名称
             $name = Request::get('name');
             if ($name == '') {
                 Zee::redirect(Zee::url('orders', 'search'));
             } else {
                 $ordersCondition->addCustomerNameCondition($name, Value::LIKE);
             }
             $orderListModel = '顾客用户姓名为 ' . $name . ' 的派单';
             break;
         case 'newtime':
             //按最新留言时间
             $time = Request::get('time');
             if ($time == '') {
                 Zee::redirect(Zee::url('orders', 'search'));
             } else {
                 $messageCondition = new MessageValue();
                 $messageCondition->addTimeCondition($time . ' 00:00:00', Value::GREATER_EQUAL);
                 $messageCondition->addTimeCondition($time . ' 23:59:59', Value::LESS_EQUAL);
                 //var_dump($messageCondition->conditions);
                 //get data
                 $messageService = new MessageService();
                 $messageList = $messageService->getList($messageCondition);
                 $ConditionStr = '';
                 if (count($messageList) > 0) {
                     foreach ($messageList as $messageKey => $messageValue) {
                         if ($messageKey == count($messageList) - 1) {
                             $ConditionStr .= $messageValue->order_id;
                         } else {
                             $ConditionStr .= $messageValue->order_id . ",";
                         }
                     }
                 }
                 if ($ConditionStr != '') {
                     //$ConditionStr='('.$ConditionStr.')';
                     //echo $ConditionStr;
                     $ordersCondition->addOrderIdCondition($ConditionStr, 'in');
                     //print_r($ordersCondition->conditions);
                     $orderListModel = '留言时间 为 ' . $time . ' 的派单';
                 } else {
                     //如果没有查找到 该日期的留言
                     $ordersCondition->addOrderIdCondition(0, Value::LESS_THAN);
                 }
             }
             break;
         case 'comment':
             //按 留言时间段
             $start = Request::get('start');
             $end = Request::get('end');
             if ($start == '' or $start == '') {
                 Zee::redirect(Zee::url('orders', 'search'));
             } else {
                 $messageCondition = new MessageValue();
                 $messageCondition->addTimeCondition($start . ' 00:00:00', Value::GREATER_EQUAL);
                 $messageCondition->addTimeCondition($end . ' 23:59:59', Value::LESS_EQUAL);
                 //var_dump($messageCondition->conditions);
                 //get data
                 $messageService = new MessageService();
                 $messageList = $messageService->getList($messageCondition);
                 $ConditionStr = '';
                 if (count($messageList) > 0) {
                     foreach ($messageList as $messageKey => $messageValue) {
                         if ($messageKey == count($messageList) - 1) {
                             $ConditionStr .= $messageValue->order_id;
                         } else {
                             $ConditionStr .= $messageValue->order_id . ",";
                         }
                     }
                 }
                 if ($ConditionStr != '') {
                     //$ConditionStr='('.$ConditionStr.')';
                     //echo $ConditionStr;
                     $ordersCondition->addOrderIdCondition($ConditionStr, 'in');
                     //print_r($ordersCondition->conditions);
                     $orderListModel = '留言时间 为 ' . $start . ' 到 ' . $end . ' 的派单';
                 } else {
                     //如果没有查找到 该日期的留言
                     $ordersCondition->addOrderIdCondition(0, Value::LESS_THAN);
                 }
             }
             break;
         case 'timearea':
             //联系时间
             $start = Request::get('start');
             $end = Request::get('end');
             if ($start == '' or $start == '') {
                 Zee::redirect(Zee::url('orders', 'search'));
             } else {
                 $ordersCondition->addContactTimeCondition($start, Value::GREATER_EQUAL);
                 $ordersCondition->addContactTimeCondition($end, Value::LESS_EQUAL);
                 $orderListModel = '联系时间 为 ' . $start . ' 到 ' . $end . ' 的派单';
             }
             break;
     }
     //get data
     $ordersService = new OrdersService();
     $userCondition = new UserValue();
     $userService = new UserService();
     $userlist = $userService->getlist($userCondition);
     //get project
     $projectCondition = new ProjectValue();
     $projectService = new ProjectService();
     $projectlist = $projectService->getList($projectCondition);
     $ordersCondition->addCondition('1=1 ORDER BY `order_id` DESC');
     $ordersList = $ordersService->getList($ordersCondition, $listPageHelper);
     $areaService = new AreaService();
     $arealist = $areaService->getList(new AreaValue());
     //var_dump($messageVo);
     // print_r($arealist);
     View::set('Area', $arealist);
     //view
     View::set("orderListModel", $orderListModel);
     View::set("UserViewValue", $userlist);
     View::set("OrdersList", $ordersList);
     View::set("Projectlist", $projectlist);
     View::set("ListPageHelper", $listPageHelper);
     View::display("List");
 }