public function queryAction() { list($page, $sidx, $limit, $sord, $start) = getRequestParams(); $condition = array("a.club_id" => get_club_id()); $filters = I("filters", '', ''); $filters = json_decode($filters); if ($filters->groupOp == 'AND') { $rules = $filters->rules; foreach ($rules as $key => $value) { if ($value->field == "name" && !empty($value->data)) { $condition["a.name"] = array("like", "%{$value->data}%"); } if ($value->field == "phone" && !empty($value->data)) { $condition["a.phone"] = $value->data; } } } $model = M("YaaGift"); $ret = $model->table(array("yoga_yaa_gift" => "b", "yoga_member_basic" => "a"))->where($condition)->where("b.member_id=a.id")->field("a.name,a.sex,b.*")->order("{$sidx} {$sord}")->limit("{$start},{$limit}")->select(); foreach ($ret as $key => $value) { $record_id = $value['record_id']; if ($record_id != 0) { $ret[$key]['recorder'] = M("UserExtension")->find($record_id); } } $count = $model->table(array("yoga_yaa_gift" => "a", "yoga_member_basic" => "a", "yoga_user_extension" => "c"))->where($condition)->where("a.member_id=b.id")->order(" {$sidx} {$sord}")->limit("{$start},{$limit}")->count(); if ($count > 0 && $limit > 0) { $total_pages = ceil($count / $limit); } else { $total_pages = 0; } $response = array("page" => $page, "total" => $total_pages, "records" => $count, "rows" => $ret); $this->ajaxReturn($response); }
public function queryAction() { if (is_user_brand()) { $response = array("page" => 0, "total" => 0, "records" => 0, "rows" => null); $this->ajaxReturn($response); } list($page, $sidx, $limit, $sord, $start) = getRequestParams(); $sidx = preg_replace("/classify.*,/", "", $sidx); $sidx = trim($sidx); $mcs = D("User")->getMc(); $arr = array(); foreach ($mcs as $key => $value) { $ret = $this->getOne($value['id']); if ($value['group_id'] == 0) { $ret['classify'] = "未分组"; } else { $group = D("McGroup")->find($value['group_id']); $ret['classify'] = $group['name']; } $mcs[$key] = array_merge($value, $ret); } if (empty($sidx) || $sidx == "id") { $sidx = "cardsale_all"; $sord = "desc"; } $function = $sidx . "_" . $sord; $f2 = "f2_" . $sidx . "_" . $sord; $mcs = $this->sortarr($mcs, $function, $f2); $response = array("page" => 0, "total" => 0, "records" => 0, "rows" => $mcs); $this->ajaxReturn($response); }
public function queryAction() { $club_id = get_club_id(); list($page, $sidx, $limit, $sord, $start) = getRequestParams(); $model = D("PtClassPublic"); $condition = array("club_id" => $club_id); $filters = I("filters", '', ''); $filters = json_decode($filters); if ($filters->groupOp == 'AND') { $rules = $filters->rules; foreach ($rules as $key => $value) { if ($value->field == "name") { $condition = array_merge($condition, array("name" => array("like", "%{$value->data}%"))); } else { if ($value->field == "pt_id" && $value->data != 0) { $condition = array_merge($condition, array("pt_id" => $value->data)); } } } } $ret = $model->where($condition)->order("{$sidx} {$sord}")->limit("{$start},{$limit}")->select(); foreach ($ret as $key => $value) { $ret[$key]['image'] = "/Public/uploads/ptclass/" . $value['image']; } $count = $model->where($condition)->count(); if ($count > 0 && $limit > 0) { $total_pages = ceil($count / $limit); } else { $total_pages = 0; } $response = array("page" => $page, "total" => $total_pages, "records" => $count, "rows" => $ret); $this->ajaxReturn($response); }
public function queryAction() { list($page, $sidx, $limit, $sord, $start) = getRequestParams(); $model = M("McFollowUp"); $condition = array("a.club_id" => get_club_id(), "a.ret" => array("gt", 0)); $filters = I("filters", '', ''); $filters = json_decode($filters); if ($filters->groupOp == 'AND') { $rules = $filters->rules; foreach ($rules as $key => $value) { if ($value->field == "mc_id" && $value->data != -1) { $condition["b.mc_id"] = $value->data; } if ($value->field == "name" && !empty($value->data)) { $condition["b.name"] = array("like", "%{$value->data}%"); } if ($value->field == "phone" && !empty($value->data)) { $condition["b.phone"] = $value->data; } } } $ret = $model->table(array("yoga_mc_follow_up" => "a", "yoga_member_basic" => "b", "yoga_user_extension" => "c"))->where($condition)->where("a.member_id=b.id and b.mc_id=c.id")->field("c.name_cn as mc,b.name,b.sex,b.type,a.is_come,a.come_time,a.appoint_time,a.appoint_time,a.is_come,a.come_time,a.ret,a.id")->order("a.{$sidx} {$sord}")->limit("{$start},{$limit}")->select(); $count = $model->table(array("yoga_mc_follow_up" => "a", "yoga_member_basic" => "b", "yoga_user_extension" => "c"))->where($condition)->where("a.member_id=b.id and b.mc_id=c.id")->count(); if ($count > 0 && $limit > 0) { $total_pages = ceil($count / $limit); } else { $total_pages = 0; } $response = array("page" => $page, "total" => $total_pages, "records" => $count, "rows" => $ret); $this->ajaxReturn($response); }
public function queryfollowupAction() { list($page, $sidx, $limit, $sord, $start) = getRequestParams(); $condition = array("club_id" => get_club_id()); $filters = I("filters", '', ''); $filters = json_decode($filters); $sql = ""; $setcreate_time = false; if ($filters->groupOp == 'AND') { $rules = $filters->rules; foreach ($rules as $key => $value) { if ($value->field == "mc_id" && $value->data != 0) { $condition["mc_id"] = $value->data; } else { if ($value->field == "ret" && $value->data != -1) { $condition["ret"] = $value->data; } else { if ($value->field == "create_time" && $value->data != 0 && $value->data != -1) { $setcreate_time = true; $day = $value->data - 1; $time = date('Y-m-d', strtotime("{$day} days ago")); $condition["create_time"] = array("gt", $time); } else { if ($value->field == "start_time" && $value->data != 0) { if (isset($condition['create_time'])) { if (!$setcreate_time) { $condition["create_time"] = array("between", $value->data . "," . $condition["create_time"]); } } else { $condition["create_time"] = array("gt", $value->data); } } else { if ($value->field == "end_time" && $value->data != 0) { if (isset($condition['create_time'])) { if (!$setcreate_time) { $condition["create_time"] = array("between", $condition["create_time"][1] . "," . $value->data . " 23:59:59"); } } else { $condition["create_time"] = array("lt", $value->data . " 23:59:59"); } } } } } } } } $model = D("McFollowUp"); $ret = $model->relation(true)->where($condition)->order("{$sidx} {$sord}")->limit("{$start},{$limit}")->select(); // echo $model->getLastSql();die(); $count = $model->where($condition)->count(); if ($count > 0 && $limit > 0) { $total_pages = ceil($count / $limit); } else { $total_pages = 0; } $response = array("page" => $page, "total" => $total_pages, "records" => $count, "rows" => $ret); $this->ajaxReturn($response); }
public function getEmployeesAction() { list($page, $sidx, $limit, $sord, $start) = getRequestParams(); $model = M("User"); $brand_id = get_brand_id(); $condition = array("brand_id" => $brand_id, "is_brand" => 0); $valuesql = "select * from yoga_user a,yoga_user_extension b where a.brand_id={$brand_id} and a.is_brand=0 and a.id=b.id and a.invalid=1 and a.club_id=" . get_club_id() . " "; $countsql = "select count(*) as count from yoga_user a,yoga_user_extension b where a.brand_id={$brand_id} and a.is_brand=0 and a.id=b.id and a.invalid=1 and a.club_id=" . get_club_id() . " "; $filters = I("filters", '', ''); $filters = json_decode($filters); $sql = ""; if ($filters->groupOp == 'AND') { $rules = $filters->rules; foreach ($rules as $key => $value) { // if($value->field=="club" && $value->data!=0 ) // { // $sql.=" and a.club_id ".getOPerationMysql($value->op)." '{$value->data}'"; // } if ($value->field == "work_status" && $value->data != -1) { $sql .= " and b.work_status " . getOPerationMysql($value->op) . " '{$value->data}'"; } if ($value->field == "name_cn") { $sql .= " and b.name_cn like '%{$value->data}%'"; } if ($value->field == "name_en") { $sql .= " and b.name_en like '%{$value->data}%'"; } if ($value->field == "role" && $value->data != -1) { $ids = M("AuthGroupAccess")->where("group_id=" . $value->data)->select(); $id = array(); foreach ($ids as $key => $value) { $id[] = $value['uid']; } $ids = implode(",", $id); $sql .= " and b.id in({$ids})"; } } } $model = new \Think\Model(); $countsql = $countsql . " " . $sql; $count = $model->query($countsql); $count = $count[0]["count"]; $valuesql = $valuesql . " " . $sql . $tail . " order by a.{$sidx} {$sord} limit {$start},{$limit}"; $ret = $model->query($valuesql); foreach ($ret as $key => $value) { $ret[$key]['role'] = D("User")->getRole($value['id']); } if ($count > 0 && $limit > 0) { $total_pages = ceil($count / $limit); } else { $total_pages = 0; } $response = array("page" => $page, "total" => $total_pages, "records" => $count, "rows" => $ret); $this->ajaxReturn($response); }
public function queryAction() { list($page, $sidx, $limit, $sord, $start) = getRequestParams(); $filters = I("filters", '', ''); $brand_id = get_brand_id(); $club_id = get_club_id(); $condition = array("club_id" => $club_id); $filters = json_decode($filters); if ($filters->groupOp == 'AND') { $rules = $filters->rules; foreach ($rules as $key => $value) { if ($value->field == "contract_number") { $condition["contract_number"] = $value->data; } if ($value->field == "card_number") { $member_ids = M("Card")->where(array("card_number" => $value->data))->field("group_concat( distinct member_id) as ids")->find(); if (!empty($member_ids)) { $condition["member_id"] = array("in", $member_ids['ids']); } else { $response = array("page" => 0, "total" => 0, "records" => 0, "rows" => ""); $this->ajaxReturn($response); } } if ($value->field == "name") { $member_ids = M("MemberBasic")->where(array("name" => $value->data))->field("group_concat( distinct id) as ids")->find(); if (!empty($member_ids)) { $condition["member_id"] = array("in", $member_ids['ids']); } else { $response = array("page" => 0, "total" => 0, "records" => 0, "rows" => ""); $this->ajaxReturn($response); } } if ($value->field == "phone") { $member_ids = M("MemberBasic")->where(array("phone" => $value->data))->field("group_concat( distinct id) as ids")->find(); if (!empty($member_ids)) { $condition["member_id"] = array("in", $member_ids['ids']); } else { $response = array("page" => 0, "total" => 0, "records" => 0, "rows" => ""); $this->ajaxReturn($response); } } } } $model = D("PtContract"); $count = $model->where($condition)->count(); $ret = $model->relation(true)->where($condition)->order("{$sidx} {$sord}")->limit("{$start},{$limit}")->select(); if ($count > 0 && $limit > 0) { $total_pages = ceil($count / $limit); } else { $total_pages = 0; } $response = array("page" => $page, "total" => $total_pages, "records" => $count, "rows" => $ret); $this->ajaxReturn($response); }
private function getPayHistory($type, $st, $et, $clubs, $sidx, $limit, $sord, $start) { list($page, $sidx, $limit, $sord, $start) = getRequestParams(); $payHistoryModel = M("PayHistory"); $sql = "select b.* from yoga_bill_project a,yoga_pay_history b where a.`sale_club_id` in ({$clubs}) and b.`create_time` between \"{$st}\" and \"{$et}\" and a.`type`={$type} and a.id=b.`bill_project_id` order by {$sidx} {$sord} limit {$start} , {$limit}"; $list = $payHistoryModel->query($sql); $sql = "select count(*) as count from yoga_bill_project a,yoga_pay_history b where a.`sale_club_id` in ({$clubs}) and b.`create_time` between \"{$st}\" and \"{$et}\" and a.`type`={$type} and a.id=b.`bill_project_id` "; $count = $payHistoryModel->query($sql); $count = $count[0]['count']; return array($count, $list); }
public function queryPayBackAction() { $clubs = implode(",", I("club_ids")); list($page, $sidx, $limit, $sord, $start) = getRequestParams(); $service = \Service\CService::factory("Member"); list($count, $objs) = $service->queryPayBack($clubs, I("start_time"), I("end_time"), $sidx, $limit, $sord, $start); if ($count > 0 && $limit > 0) { $total_pages = ceil($count / $limit); } else { $total_pages = 0; } $response = array("page" => $page, "total" => $total_pages, "records" => $count, "rows" => $objs); $this->ajaxReturn($response); }
public function getNotice() { list($page, $sidx, $limit, $sord, $start) = getRequestParams(); $brand_id = get_brand_id(); $condition = array("brand_id" => $brand_id); $notice = $this->where($condition)->order("{$sidx} {$sord}")->limit("{$start},{$limit}")->select(); $count = $this->where($condition)->count(); if ($count > 0 && $limit > 0) { $total_pages = ceil($count / $limit); } else { $total_pages = 0; } $response = array("page" => $page, "total" => $total_pages, "records" => $count, "rows" => $notice); return $response; }
public function getCardtypeAction() { list($page, $sidx, $limit, $sord, $start) = getRequestParams(); $brand_id = get_brand_id(); $can_sale_id = D("CardSaleclub")->getCanSaleCards(); $model = D("CardType"); $ids = array(); foreach ($can_sale_id as $key => $value) { $ids[] = $value["id"]; } $useclub = I("useclub"); if (!empty($useclub) && $useclub != -1) { $can_use_id = D("CardUseclub")->getCanUseCards($useclub); $model = D("CardType"); $uids = array(); foreach ($can_use_id as $key => $value) { $uids[] = $value["id"]; } $ids = array_intersect($ids, $uids); } $ids = implode(',', $ids); $condition = array("brand_id" => $brand_id, "id" => array("in", $ids)); $category = I("category"); if ($category != -1 && $category !== '') { $condition["category"] = $category; } $type = I("type"); if ($type != -1 && $type !== '') { $condition["type"] = $type; } $name = I("name"); if ($name != -1 && $name !== '') { $condition["name"] = array("like", "%{$name}%"); } $ret = $model->relation(true)->where($condition)->order("{$sidx} {$sord}")->limit("{$start},{$limit}")->select(); $count = $model->where($condition)->count(); if ($count > 0 && $limit > 0) { $total_pages = ceil($count / $limit); } else { $total_pages = 0; } $clubs = M("Club")->where(array("brand_id" => get_brand_id()))->field('id,club_name')->select(); $peaktimes = M("PeakTime")->where(array("brand_id" => get_brand_id()))->field('id,peak_name')->select(); $response = array("page" => $page, "total" => $total_pages, "records" => $count, "rows" => $ret, "userdata" => array("clubs" => $clubs, "peaktimes" => $peaktimes)); $this->ajaxReturn($response); }
public function queryAction() { $club_id = get_club_id(); $pts = D("User")->getPt(); $arr = array(); foreach ($pts as $key => $value) { $arr[] = $value['id']; } list($page, $sidx, $limit, $sord, $start) = getRequestParams(); $model = D("PtClassPublic"); if (!empty($arr)) { $condition = array("pt_id" => array("in", $arr)); } $condition[] = array("club_id" => $club_id); $condition['_logic'] = 'or'; $map['_complex'] = $condition; $filters = I("filters", '', ''); $filters = json_decode($filters); if ($filters->groupOp == 'AND') { $rules = $filters->rules; foreach ($rules as $key => $value) { if ($value->field == "name") { $v = $value->data; $map = array_merge($map, array("_string" => "name like '%{$v}%' or teacher_name like '%{$v}%'")); // $map = array_merge($map,array("name"=>array("like","%{$value->data}%")) ); } } } $ret = $model->where($map)->order("{$sidx} {$sord}")->limit("{$start},{$limit}")->select(); foreach ($ret as $key => $value) { if (!empty($value['teacher_name'])) { $ret[$key]['teacher'] = $value['teacher_name']; } else { $teacher = M("UserExtension")->find($value['pt_id']); $ret[$key]['teacher'] = $teacher['name_cn']; } } $count = $model->where($map)->count(); if ($count > 0 && $limit > 0) { $total_pages = ceil($count / $limit); } else { $total_pages = 0; } $response = array("page" => $page, "total" => $total_pages, "records" => $count, "rows" => $ret); $this->ajaxReturn($response); }
public function getMcs() { list($page, $sidx, $limit, $sord, $start) = getRequestParams(); $club_id = empty($club_id) ? get_club_id() : $club_id; $where = "a.id=b.id and a.id=c.uid and b.club_id={$club_id} and c.group_id=6"; $filters = I("filters", '', ''); $filters = json_decode($filters); $sql = ""; if ($filters->groupOp == 'AND') { $rules = $filters->rules; foreach ($rules as $key => $value) { if ($value->field == "name" && !empty($value->data)) { $name = $value->data; $where .= " and (a.name_cn like '%{$name}%' or a.name_en like '%{$name}%')"; } } } $mcs = M()->where($where)->table(array("yoga_user_extension" => "a", "yoga_user" => "b", "yoga_auth_group_access" => "c"))->field("a.id,a.name_cn,a.group_id,a.work_status")->order("a.group_id")->limit("{$offset},{$num}")->select(); foreach ($mcs as $key => $value) { if ($value['work_status'] == 1) { $group = array("name" => "离职"); $mcs[$key]['group'] = $group; } else { if ($value['group_id'] != 0) { $group = $this->find($value['group_id']); $mcs[$key]['group'] = $group; } else { $mcs[$key]['group'] = null; } } } $count = D("User")->getMcCount(); if ($count > 0 && $limit > 0) { $total_pages = ceil($count / $limit); } else { $total_pages = 0; } $response = array("page" => $page, "total" => $total_pages, "records" => $count, "rows" => $mcs); return $response; }
public function queryAction() { list($page, $sidx, $limit, $sord, $start) = getRequestParams(); $model = D("Channel"); $club_id = get_club_id(); if ($club_id != 0) { $condition = array("club_id" => $club_id); } else { $condition = array("brand_id" => get_brand_id()); } $search = I("_search"); if (!empty($search)) { $condition = array_merge($condition, getOneSearchParams()); } $ret = $model->relation(true)->where($condition)->order("{$sidx} {$sord}")->limit("{$start},{$limit}")->select(); $count = $model->where($condition)->count(); if ($count > 0 && $limit > 0) { $total_pages = ceil($count / $limit); } else { $total_pages = 0; } $response = array("page" => $page, "total" => $total_pages, "records" => $count, "rows" => $ret); $this->ajaxReturn($response); }
public function queryConsumeAction() { $service = \Service\CService::factory("Member"); list($page, $sidx, $limit, $sord, $start) = getRequestParams(); $condition = array("brand_id" => get_brand_id()); $filters = I("filters", '', ''); $filters = json_decode($filters); if ($filters->groupOp == 'AND') { $rules = $filters->rules; $name = ""; $phone = ""; foreach ($rules as $key => $value) { if ($value->field == "club_id" && $value->data != -1) { $condition["club_id"] = $value->data; } else { if ($value->field == "name") { $name = $value->data; } else { if ($value->field == "phone") { $phone = $value->data; } else { if ($value->field == "contract_number") { $contract = M("Contract")->where(array("contract_number" => $value->data))->find(); if (empty($contract)) { $response = array("page" => 0, "total" => 0, "records" => 0, "rows" => null); $this->ajaxReturn($response); } $condition["contract_id"] = $contract['id']; } else { if ($value->field == "card_number") { $card = M("Card")->where(array("card_number" => $value->data))->find(); if (empty($card)) { $response = array("page" => 0, "total" => 0, "records" => 0, "rows" => null); $this->ajaxReturn($response); } $condition["card_id"] = $card['id']; } } } } } } if (!empty($name) || !empty($phone)) { $members = $service->getMemberByBrand(get_brand_id(), $name, $phone); if (empty($members)) { $response = array("page" => 0, "total" => 0, "records" => 0, "rows" => null); $this->ajaxReturn($response); } $ids = ""; foreach ($members as $k => $v) { if ($k != 0) { $ids .= ","; } $ids .= $v['id']; } $condition["member_id"] = array("in", $ids); } } $model = D("CheckHistory"); $ret = $model->relation(true)->where($condition)->order("{$sidx} {$sord}")->limit("{$start},{$limit}")->select(); $count = $model->where($condition)->count(); if ($count > 0 && $limit > 0) { $total_pages = ceil($count / $limit); } else { $total_pages = 0; } $response = array("page" => $page, "total" => $total_pages, "records" => $count, "rows" => $ret); $this->ajaxReturn($response); }
public function queryReportAction() { list($page, $sidx, $limit, $sord, $start) = getRequestParams(); $filters = I("filters", '', ''); $filters = json_decode($filters); $rules = $filters->rules; foreach ($rules as $key => $value) { if ($value->field == "club_ids") { $clubs = $value->data; } else { if ($value->field == "pay_id") { $pay_id = $value->data; } else { if ($value->field == "type") { $type = $value->data; } else { if ($value->field == "start_time") { $start_time = $value->data; } else { if ($value->field == "end_time") { $end_time = $value->data; } } } } } } switch ($type) { case '1': //day if (empty($start_time)) { $this->error("请输入开始时间!"); } $st = $start_time . " 00:00:00"; $et = $start_time . " 23:59:59"; break; case '2': //month if (empty($start_time)) { $this->error("请输入开始时间!"); } $st = $start_time . "-01 00:00:00"; $et = $start_time . "-31 23:59:59"; break; case '3': //year if (empty($start_time)) { $this->error("请输入开始时间!"); } $st = $start_time . "-01-01 00:00:00"; $et = $start_time . "-12-31 23:59:59"; break; case '4': //other if (empty($start_time)) { $this->error("请输入开始时间!"); } if (empty($end_time)) { $this->error("请输入结束时间!"); } $st = $start_time; $et = $end_time; break; default: # code... break; } $condition = array("club_id" => array("in", $clubs), "create_time" => array("between", "{$st},{$et}")); if (!empty($pay_id)) { $condition = array("id" => $pay_id); } $model = D("PayHistory"); $bill_project = $model->relation(true)->where($condition)->order("{$sidx} {$sord}")->limit("{$start},{$limit}")->select(); foreach ($bill_project as $key => $value) { $bill_project[$key]['member'] = M("MemberBasic")->find($value['bill']['member_id']); } $count = $model->where($condition)->count(); if ($count > 0 && $limit > 0) { $total_pages = ceil($count / $limit); } else { $total_pages = 0; } $response = array("page" => $page, "total" => $total_pages, "records" => $count, "rows" => $bill_project); $this->ajaxReturn($response); }
$postfix = ""; $isFirst = true; foreach ($mpds as $index => $response) { $adaptationSetStartPos = strpos($response, AdaptationSetStartTag); $adaptationSetEndPos = strpos($response, AdaptationSetEndTag); if ($isFirst) { $prefix = substr($response, 0, $adaptationSetStartPos); $postfix = substr($response, $adaptationSetEndPos + strlen(AdaptationSetEndTag)); $isFirst = false; } $output = $output . substr($response, $adaptationSetStartPos, $adaptationSetEndPos - $adaptationSetStartPos + strlen(AdaptationSetEndTag)); } $output = $prefix . $output . $postfix; return $output; } $params = getRequestParams(); $fileName = $params['file']; $arr = array(); if ($fileName == 'strip') { $content = getContent("http://lbd.kaltura.com:8001/mapped/strip.json/manifest.mpd"); $content = str_replace('id="1"', 'group="1"', $content); $arr[] = $content; for ($i = 0; $i < 5; $i++) { $content = getContent("http://lbd.kaltura.com:8001/mapped/aud-{$i}.json/manifest.mpd"); $adaptAttrs = 'group="' . ($i + 2) . '"' . "\n"; $adaptAttrs .= ' lang="en_vid' . $i . '"'; $content = str_replace('id="2"', $adaptAttrs, $content); $arr[] = $content; } } else { $arr[] = getContent("http://lbd.kaltura.com:8001/mapped/vid-{$fileName}.json/manifest.mpd");
/** * Verifying required params posted or not */ function verifyRequiredParams($required_fields) { $error = false; $error_fields = ""; $request_params = getRequestParams(); foreach ($required_fields as $field) { if (!isset($request_params[$field]) || strlen(trim($request_params[$field])) <= 0) { $error = true; $error_fields .= $field . ', '; } } if ($error) { // Required field(s) are missing or empty // echo error json and stop the app $message = 'Required field(s) ' . substr($error_fields, 0, -2) . ' is missing'; exitApp(BAD_REQUEST, $message); } }
public function queryAction() { list($page, $sidx, $limit, $sord, $start) = getRequestParams(); $filters = I("filters", '', ''); $brand_id = get_brand_id(); $club_id = get_club_id(); $valuesql = "select b.*,a.name,a.sex,a.phone ,c.card_number ,d.name as card_name,d.type as card_type ,d.price as card_type_price from yoga_contract b left join yoga_member_basic a on b.member_id=a.id left join yoga_card c on b.card_id=c.id left join yoga_card_type d on b.card_type_id=d.id where b.brand_id= {$brand_id} "; $countsql = "select count(*) as count from yoga_contract b left join yoga_member_basic a on b.member_id=a.id left join yoga_card c on b.card_id=c.id left join yoga_card_type d on b.card_type_id=d.id where b.brand_id= {$brand_id} "; $filters = json_decode($filters); $sql = ""; if ($filters->groupOp == 'AND') { $rules = $filters->rules; foreach ($rules as $key => $value) { if ($value->field == "mc_id" && !empty($value->data)) { $sql .= " and b.mc_id " . getOPerationMysql($value->op) . " '{$value->data}'"; } if ($value->field == "sale_club_id" && !empty($value->data)) { $sql .= " and b.sale_club_id " . getOPerationMysql($value->op) . " '{$value->data}'"; } if ($value->field == "start_time" && !empty($value->data)) { $sql .= " and b.create_time " . getOPerationMysql($value->op) . " '{$value->data}'"; } if ($value->field == "end_time" && !empty($value->data)) { $sql .= " and b.create_time " . getOPerationMysql($value->op) . " '{$value->data}'"; } if ($value->field == "card_type_id" && !empty($value->data)) { $sql .= " and b.card_type_id " . getOPerationMysql($value->op) . " '{$value->data}'"; } if ($value->field == "contract_number") { $sql .= " and b.contract_number " . getOPerationMysql($value->op) . " '{$value->data}'"; } if ($value->field == "card_number") { $sql .= " and c.card_number " . getOPerationMysql($value->op) . " '{$value->data}'"; } if ($value->field == "name") { $sql .= " and a.name " . getOPerationMysql($value->op) . " '{$value->data}'"; } if ($value->field == "phone") { $sql .= " and a.phone " . getOPerationMysql($value->op) . " '{$value->data}'"; } } } // $tail=" and a.id=b.member_id and b.brand_id=$brand_id and b.contract_type=0 and b.card_id=c.id and b.card_type_id=d.id"; $tail = ""; $model = new \Think\Model(); $countsql = $countsql . " " . $sql . $tail; $count = $model->query($countsql); $count = $count[0]["count"]; $valuesql = $valuesql . " " . $sql . $tail . " order by {$sidx} {$sord} limit {$start},{$limit}"; $ret = $model->query($valuesql); foreach ($ret as $key => $value) { $mc = M("UserExtension")->find($value['mc_id']); $recorder = M("UserExtension")->find($value['record_id']); $ret[$key]['mc_name'] = !empty($mc) ? $mc['name_cn'] : "NO MC!"; $ret[$key]['recorder_name'] = !empty($recorder) ? $recorder['name_cn'] : "品牌帐号"; } if ($count > 0 && $limit > 0) { $total_pages = ceil($count / $limit); } else { $total_pages = 0; } $response = array("page" => $page, "total" => $total_pages, "records" => $count, "rows" => $ret); $this->ajaxReturn($response); }
public function querycardophistoryAction($id) { list($page, $sidx, $limit, $sord, $start) = getRequestParams(); $ret = D("CardOpHistory")->where("card_id={$id}")->relation(true)->order("{$sidx} {$sord}")->limit("{$start},{$limit}")->select(); $count = M("CardOpHistory")->where("card_id={$id}")->count(); if ($count > 0 && $limit > 0) { $total_pages = ceil($count / $limit); } else { $total_pages = 0; } $response = array("page" => $page, "total" => $total_pages, "records" => $count, "rows" => $ret); $this->ajaxReturn($response); }
public function queryAction() { list($page, $sidx, $limit, $sord, $start) = getRequestParams(); $brand_id = get_brand_id(); $condition = array("brand_id" => $brand_id); $category = I("category"); if ($category != -1 && $category !== '') { $condition["category"] = $category; } $type = I("type"); if ($type != -1 && $type !== '') { $condition["type"] = $type; } $name = I("name"); if ($name != -1 && $name !== '') { $condition["name"] = array("like", "%{$name}%"); } $model = D("CardType"); $ret = $model->relation(true)->where($condition)->order("{$sidx} {$sord}")->limit("{$start},{$limit}")->select(); $count = $model->where($condition)->count(); $saleclub = I("saleclub"); $useclub = I("useclub"); $result = array(); if ($saleclub != -1 && $saleclub !== '') { foreach ($ret as $key => $value) { if (!empty($value['saleclub'])) { foreach ($value['saleclub'] as $clubobj) { if ($clubobj['club_id'] == $saleclub) { $result[] = $value; break; } } } } } else { $result = $ret; } $ret = $result; $result = array(); if ($useclub != -1 && $useclub !== '') { foreach ($ret as $key => $value) { if (!empty($value['useclub'])) { foreach ($value['useclub'] as $clubobj) { if ($clubobj['club_id'] == $useclub) { $result[] = $value; break; } } } } } else { $result = $ret; } $clubs = M("Club")->where(array("brand_id" => get_brand_id()))->field('id,club_name')->select(); if ($count > 0 && $limit > 0) { $total_pages = ceil($count / $limit); } else { $total_pages = 0; } $peaktimes = M("PeakTime")->where(array("brand_id" => get_brand_id()))->field('id,peak_name')->select(); $response = array("page" => $page, "total" => $total_pages, "records" => $count, "rows" => $result, "userdata" => array("clubs" => $clubs, "peaktimes" => $peaktimes)); $this->ajaxReturn($response); }
if (!empty($slept)) { echo "<h2>slept</h2>\n"; echo buildTable($slept); } ?> <?php if (!empty($pad)) { echo "<h2>pad</h2>\n"; echo buildTable($pad); } ?> <h2>request</h2> <?php echo buildTable(getRequestParams()); ?> <h2>http (headers)</h2> <?php echo buildTable(getHttpParams()); ?> <?php if (!empty($_COOKIE)) { echo "<h2>cookies</h2>\n"; echo buildTable($_COOKIE); } ?> <?php
public function queryAction() { list($page, $sidx, $limit, $sord, $start) = getRequestParams(); $condition = array("club_id" => get_club_id(), "is_member" => 1, "recharge" => array("gt", 0)); $filters = I("filters", '', ''); $filters = json_decode($filters); $sql = ""; $setcreate_time = false; if ($filters->groupOp == 'AND') { unset($condition['recharge']); $rules = $filters->rules; foreach ($rules as $key => $value) { if ($value->field == "name" && !empty($value->data)) { $condition["name"] = array("like", "%{$value->data}%"); } else { if ($value->field == "phone" && !empty($value->data)) { $condition["phone"] = $value->data; } else { if ($value->field == "card_number") { $card_number = $value->data; $tmodel = new \Think\Model(); $ids = $tmodel->query("select group_concat( distinct member_id) as ids from yoga_card where card_number='{$card_number}'"); $ids = $ids[0]['ids']; $condition["id"] = array("in", $ids); } } } } } $model = D("MemberBasic"); $ret = $model->relation("mc")->relation(true)->where($condition)->order("{$sidx} {$sord}")->limit("{$start},{$limit}")->select(); $count = $model->where($condition)->count(); if ($count > 0 && $limit > 0) { $total_pages = ceil($count / $limit); } else { $total_pages = 0; } $response = array("page" => $page, "total" => $total_pages, "records" => $count, "rows" => $ret); $this->ajaxReturn($response); }
public function querycontractAction($id) { list($page, $sidx, $limit, $sord, $start) = getRequestParams(); $model = M("Contract"); $ret = $model->where(array("card_id" => $id))->order("{$sidx} {$sord}")->limit("{$start},{$limit}")->select(); foreach ($ret as $key => $value) { $card_type = M("CardType")->find($value['card_type_id']); $ret[$key]['card_type'] = $card_type; } $count = $model->where(array("card_id" => $id))->count(); $count = $model->where($condition)->count(); if ($count > 0 && $limit > 0) { $total_pages = ceil($count / $limit); } else { $total_pages = 0; } $response = array("page" => $page, "total" => $total_pages, "records" => $count, "rows" => $ret); $this->ajaxReturn($response); }
} else { return htmlspecialcharsbx($_REQUEST[$param]); } } /*Очищаем переменные сессии, чтобы сортировка восстанавливалась с учетом $table_id */ /** @global CMain $APPLICATION */ global $APPLICATION; $uniq = md5($APPLICATION->GetCurPage()); if (isset($_SESSION["SESS_SORT_BY"][$uniq])) { unset($_SESSION["SESS_SORT_BY"][$uniq]); } if (isset($_SESSION["SESS_SORT_ORDER"][$uniq])) { unset($_SESSION["SESS_SORT_ORDER"][$uniq]); } $module = getRequestParams('module'); $view = getRequestParams('view'); if (!$module or !$view or !Loader::IncludeModule($module)) { include $_SERVER['DOCUMENT_ROOT'] . BX_ROOT . '/admin/404.php'; } list($helper, $interface) = AdminBaseHelper::getGlobalInterfaceSettings($module, $view); if (!$helper or !$interface) { include $_SERVER['DOCUMENT_ROOT'] . BX_ROOT . '/admin/404.php'; } $isPopup = isset($_REQUEST['popup']) and $_REQUEST['popup'] == 'Y'; $fields = isset($interface['FIELDS']) ? $interface['FIELDS'] : array(); $tabs = isset($interface['TABS']) ? $interface['TABS'] : array(); $helperType = false; if (is_subclass_of($helper, 'DigitalWand\\AdminHelper\\Helper\\AdminEditHelper')) { $helperType = 'edit'; /** @var AdminEditHelper $adminHelper */ $adminHelper = new $helper($fields, $tabs);
public function getMembersAction() { list($page, $sidx, $limit, $sord, $start) = getRequestParams(); $condition = array("record_id" => is_user_login()); $channel_id = I("channel_id"); if ($channel_id != 0 && $channel_id !== '') { $condition["channel_id"] = $channel_id; } $type = I("type"); if ($type != 0 && $type !== '') { $condition["type"] = $type; } $name = I("name"); if ($name !== '') { $condition["name"] = array("like", "%{$name}%"); } $phone = I("phone"); if ($phone !== '') { $condition["phone"] = $phone; } $model = M("MemberBasic"); $ret = $model->where($condition)->order("{$sidx} {$sord}")->limit("{$start},{$limit}")->select(); $count = $model->where($condition)->count(); if ($count > 0 && $limit > 0) { $total_pages = ceil($count / $limit); } else { $total_pages = 0; } $response = array("page" => $page, "total" => $total_pages, "records" => $count, "rows" => $ret); $this->ajaxReturn($response); }
public function queryAction() { list($page, $sidx, $limit, $sord, $start) = getRequestParams(); $condition = array("a.club_id" => get_club_id()); $filters = I("filters", '', ''); $filters = json_decode($filters); if ($filters->groupOp == 'AND') { $rules = $filters->rules; foreach ($rules as $key => $value) { if ($value->field == "name" && !empty($value->data)) { $condition["a.name"] = array("like", "%{$value->data}%"); } if ($value->field == "phone" && !empty($value->data)) { $condition["a.phone"] = $value->data; } } } $model = M("AppointBlackList"); $ret = $model->table(array("yoga_appoint_black_list" => "b", "yoga_member_basic" => "a", "yoga_card" => "c"))->where($condition)->where("b.member_id=a.id and a.id=c.member_id and b.status=1")->field("a.name,a.sex,b.*,c.card_number")->order("{$sidx} {$sord}")->limit("{$start},{$limit}")->select(); $count = $model->table(array("yoga_appoint_black_list" => "b", "yoga_member_basic" => "a", "yoga_card" => "c"))->where($condition)->where("b.member_id=a.id and a.id=c.member_id and b.status=1")->field("a.name,a.sex,b.*,c.card_number")->count(); if ($count > 0 && $limit > 0) { $total_pages = ceil($count / $limit); } else { $total_pages = 0; } $response = array("page" => $page, "total" => $total_pages, "records" => $count, "rows" => $ret); $this->ajaxReturn($response); }
public function getMembers() { list($page, $sidx, $limit, $sord, $start) = getRequestParams(); $condition = array("club_id" => get_club_id()); $pt_id = $mc_id = is_user_login(); $request_id = I("mc_id"); $request_pt_id = I("pt_id"); if (MODULE_NAME == 'Mc') { if ($request_id != -1) { $condition['mc_id'] = $mc_id; } else { $mcs = D("McGroup")->getMyGroupMc($mc_id); $arr_mcids = array(); foreach ($mcs as $key => $value) { $arr_mcids[] = $value['id']; } $condition['mc_id'] = array("in", $arr_mcids); } } if (MODULE_NAME == 'Pt') { if ($request_pt_id != -1) { $condition['pt_id'] = $pt_id; } } if (MODULE_NAME == 'Teamleader') { $mcs = D("McGroup")->getMyGroupMc($mc_id); $arr_mcids = array(); foreach ($mcs as $key => $value) { $arr_mcids[] = $value['id']; } $condition['mc_id'] = array("in", $arr_mcids); } if (MODULE_NAME == 'Channel') { $tmodel = new \Think\Model(); $uid = is_user_login(); $ids = $tmodel->query("select group_concat( distinct id) as ids from yoga_channel where user_id='{$uid}'"); $ids = $ids[0]['ids']; $condition['channel_id'] = array("in", $ids); } $is_member = I("is_member"); if ($is_member != -1) { $condition["is_member"] = $is_member; } $filters = I("filters", '', ''); $filters = json_decode($filters); $sql = ""; $setcreate_time = false; $hasinfo = false; if ($filters->groupOp == 'AND') { $rules = $filters->rules; foreach ($rules as $key => $value) { if ($value->field == "follow_time" && $value->data != 0) { $v = $value->data; if ($v == 1) { $condition['follow_up_time'] = '0000-00-00 00:00:00'; } else { if ($v == 2) { $day = date('Y-m-d'); $condition['follow_up_time'] = array("like", "{$day}%"); } else { if ($v == 3) { $day = date('Y-m-d', strtotime('-3 day')); $condition['follow_up_time'] = array("lt", "{$day}"); } else { if ($v == 4) { $day = date('Y-m-d', strtotime('-7 day')); $condition['follow_up_time'] = array("lt", "{$day}"); } } } } } if ($value->field == "channel_id" && $value->data != 0) { $condition["channel_id"] = $value->data; } if ($value->field == "contract_end" && $value->data != 0) { $day = $value->data; $time = date('Y-m-d H:i:s', strtotime("-{$day} days ago")); $now = date('Y-m-d H:i:s'); $club_id = get_club_id(); $tmodel = new \Think\Model(); $ids = $tmodel->query("select group_concat( distinct c.id) as ids from (select * from (select * from yoga_contract where sale_club_id={$club_id} and end_time>'{$now}' order by end_time) a group by member_id ) b ,yoga_member_basic c where b.end_time<'{$time}' and b.end_time>'{$now}' and b.sale_club_id={$club_id} and c.id=b.member_id"); // echo $tmodel->_sql();die(); $ids = $ids[0]['ids']; $condition["id"] = array("in", $ids); } if ($value->field == "pt_id" && $value->data != -1) { $condition["pt_id"] = $value->data; } else { if ($value->field == "mc_id") { if ($value->data != -1) { $condition["mc_id"] = $value->data; } else { if (MODULE_NAME == 'Mc') { $mcs = D("McGroup")->getMyGroupMc($mc_id); $arr_mcids = array(); foreach ($mcs as $key => $value) { $arr_mcids[] = $value['id']; } $condition['mc_id'] = array("in", $arr_mcids); } else { unset($condition["mc_id"]); } } } else { if ($value->field == "create_time" && $value->data != 0 && $value->data != -1) { $setcreate_time = true; $day = $value->data - 1; $time = date('Y-m-d', strtotime("{$day} days ago")); $condition["create_time"] = array("gt", $time); } else { if ($value->field == "start_time" && $value->data != 0) { if (isset($condition['create_time'])) { if (!$setcreate_time) { $condition["create_time"] = array("between", $value->data . "," . $condition["create_time"]); } } else { $condition["create_time"] = array("gt", $value->data); } } else { if ($value->field == "end_time" && $value->data != 0) { if (isset($condition['create_time'])) { if (!$setcreate_time) { $condition["create_time"] = array("between", $condition["create_time"][1] . "," . $value->data . " 23:59:59"); } } else { $condition["create_time"] = array("lt", $value->data . " 23:59:59"); } } else { if ($value->field == "is_member" && $value->data != -1) { $condition["is_member"] = $value->data; } else { if ($value->field == "type" && $value->data != 0) { $condition["type"] = $value->data; } else { if ($value->field == "name" && !empty($value->data)) { $hasinfo = true; $condition["name"] = array("like", "%{$value->data}%"); } else { if ($value->field == "phone" && !empty($value->data)) { $hasinfo = true; $condition["phone"] = $value->data; } else { if ($value->field == "card_number" && !empty($value->data)) { $hasinfo = true; $card_number = $value->data; $tmodel = new \Think\Model(); $ids = $tmodel->query("select group_concat( distinct member_id) as ids from yoga_card where card_number='{$card_number}'"); $ids = $ids[0]['ids']; $condition["id"] = array("in", $ids); } else { if ($value->field == "st_type") { $st_type = $value->data->type; $day = $value->data->day; $time = date('Y-m-d H:i:s', strtotime("{$day} days ago")); $now = date('Y-m-d H:i:s'); if ($st_type == 4) { $condition["assign_time"] = array("gt", $time); } else { if ($st_type == 2) { $condition["create_time"] = array("gt", $time); } else { if ($st_type == 3) { $condition["follow_up_time"] = array("lt", $time); } else { if ($st_type == 1) { $time = date('Y-m-d H:i:s', strtotime("-{$day} days ago")); $tmodel = new \Think\Model(); $ids = $tmodel->query("select group_concat( distinct member_id) as ids from yoga_mc_follow_up where mc_id={$mc_id} and ret=2 and appoint_time>'{$now}' and appoint_time<'{$time}'"); $ids = $ids[0]['ids']; $condition["id"] = array("in", $ids); } else { if ($st_type == 5) { $time = date('Y-m-d H:i:s', strtotime("-{$day} days ago")); $tmodel = new \Think\Model(); $ids = $tmodel->query("select group_concat( distinct member_id) as ids from yoga_mc_follow_up where mc_id={$mc_id} and ret=1 and appoint_time>'{$now}' and appoint_time<'{$time}'"); $ids = $ids[0]['ids']; $condition["id"] = array("in", $ids); } else { if ($st_type == 6) { $condition["join_time"] = array("gt", $time); } else { if ($st_type == 7) { $condition["mc_service_time"] = array("lt", $time); } else { if ($st_type == 8) { $condition["pt_follow_up_time"] = array("lt", $time); } else { if ($st_type == 9) { $condition["pt_assign_time"] = array("gt", $time); } else { if ($st_type == 11) { $time = date('Y-m-d H:i:s', strtotime("-{$day} days")); $club_id = get_club_id(); $_string = "id in (select member_id from yoga_mc_follow_up where club_id={$club_id} and ret=0 and failed_reason='未接通' and create_time>'{$time}' ) and id not in(select member_id from yoga_mc_follow_up where club_id={$club_id} and create_time>'{$time}' and (ret!=0 or failed_reason!='未接通'))"; $condition['_string'] = $_string; } else { if ($st_type == 10) { $time = date('Y-m-d H:i:s', strtotime("-{$day} days ago")); $tmodel = new \Think\Model(); $ids = $tmodel->query("select group_concat( distinct member_id) as ids from yoga_pt_follow_up where pt_id={$mc_id} and ret!=0 and appoint_time>'{$now}' and appoint_time<'{$time}'"); $ids = $ids[0]['ids']; $condition["id"] = array("in", $ids); } } } } } } } } } } } } } } } } } } } } } } } } $model = D("MemberBasic"); $brand_id = get_brand_id(); if ($brand_id == 35 && !$hasinfo) { $response = array("page" => 0, "total" => 0, "records" => 0, "rows" => null); return $response; } $ret = $model->relation(true)->where($condition)->order("{$sidx} {$sord}")->limit("{$start},{$limit}")->select(); $count = $model->where($condition)->count(); if ($count > 0 && $limit > 0) { $total_pages = ceil($count / $limit); } else { $total_pages = 0; } $response = array("page" => $page, "total" => $total_pages, "records" => $count, "rows" => $ret); return $response; }
public function queryAction() { list($page, $sidx, $limit, $sord, $start) = getRequestParams(); //query member card $valuesql = "select a.* ,b.name,b.phone from yoga_card a,yoga_member_basic b where a.member_id=b.id "; $countsql = "select count(*) as count from yoga_card a,yoga_member_basic b where a.member_id=b.id "; $filters = I("filters", '', ''); $filters = json_decode($filters); $sql = ""; if ($filters->groupOp == 'AND') { $rules = $filters->rules; foreach ($rules as $key => $value) { if ($value->field == "card_number") { $sql .= " and a.card_number " . getOPerationMysql($value->op) . " '{$value->data}'"; } if ($value->field == "name") { $sql .= " and b.name " . getOPerationMysql($value->op) . " '{$value->data}'"; } if ($value->field == "phone") { $sql .= " and b.phone " . getOPerationMysql($value->op) . " '{$value->data}'"; } } } $model = new \Think\Model(); $countsql = $countsql . " " . $sql; $count = $model->query($countsql); $count = $count[0]["count"]; $valuesql = $valuesql . " " . $sql . $tail . " order by {$sidx} {$sord} limit {$start},{$limit}"; $ret = $model->query($valuesql); if ($count > 0 && $limit > 0) { $total_pages = ceil($count / $limit); } else { $total_pages = 0; } $response = array("page" => $page, "total" => $total_pages, "records" => $count, "rows" => $ret); $this->ajaxReturn($response); }
public function getAppointsAction() { list($page, $sidx, $limit, $sord, $start) = getRequestParams(); $start = $start / 2; $limit = $limit / 2; $mc_id = is_user_login(); $condition = array("mc_id" => $mc_id, "ret" => array("neq", 0)); $filters = I("filters", '', ''); $filters = json_decode($filters); $valuesql = "select b.*,a.name,a.sex,a.phone from yoga_member_basic a,yoga_mc_follow_up b where b.mc_id={$mc_id} and ret!=0 and a.id=b.member_id "; $countsql = "select count(*) as count from yoga_member_basic a,yoga_mc_follow_up b where b.mc_id={$mc_id} and ret!=0 and a.id=b.member_id "; $sql = ""; if (empty($filters)) { $now = date('Y-m-d H:i:s'); $day = $value->data; $time = date('Y-m-d', strtotime("-1 days ago")); $sql .= " and b.appoint_time >='{$now}' and b.appoint_time <='{$time}' "; } else { if ($filters->groupOp == 'AND') { $rules = $filters->rules; foreach ($rules as $key => $value) { if ($value->field == "time" && $value->data != 0) { $now = date('Y-m-d'); $day = $value->data; $time = date('Y-m-d', strtotime("-{$day} days ago")); $sql .= " and b.appoint_time >='{$now}' and b.appoint_time <='{$time}' "; } if ($value->field == "name") { $sql .= " and a.name like '%{$value->data}%'"; } if ($value->field == "phone") { $sql .= " and a.phone='{$value->data}'"; } if ($value->field == "day" && $value->data != 0) { $now = date('Y-m-d'); $day = $value->data; $time = date('Y-m-d', strtotime("-{$day} days ago")); $sql .= " and b.appoint_time >='{$now}' and b.appoint_time <'{$time}' "; } } } } $model = new \Think\Model(); $countsql = $countsql . " " . $sql; $count = $model->query($countsql); $count = $count[0]["count"] * 2; $valuesql = $valuesql . " " . $sql . $tail . " order by {$sidx} {$sord} limit {$start},{$limit}"; $ret = $model->query($valuesql); $newret = array(); foreach ($ret as $key => $value) { $newret[] = $value; $newvalue = $value; $newvalue['desc'] = "备注:" . $newvalue['desc']; $newvalue['name'] = ""; $newret[] = $newvalue; } if ($count > 0 && $limit > 0) { $total_pages = ceil($count / $limit); } else { $total_pages = 0; } $response = array("page" => $page, "total" => $total_pages, "records" => $count, "rows" => $newret); $this->ajaxReturn($response); }