public function action_spot() { $action = $this->params['action']; if (empty($action)) { $this->assign('kindmenu', Common::getConfig('menu_sub.spotkind')); //分类设置项 $this->display('stourtravel/spot/list'); } else { if ($action == 'read') { $start = Arr::get($_GET, 'start'); $limit = Arr::get($_GET, 'limit'); $keyword = Arr::get($_GET, 'keyword'); $kindid = Arr::get($_GET, 'kindid'); $attrid = Arr::get($_GET, 'attrid'); $webid = Arr::get($_GET, 'webid'); $sort = json_decode(Arr::get($_GET, 'sort'), true); $order = 'order by a.modtime desc'; $webid = empty($webid) ? -1 : $webid; $keyword = Common::getKeyword($keyword); $specOrders = array('attrid', 'kindlist', 'iconlist', 'themelist'); if ($sort[0]['property']) { if ($sort[0]['property'] == 'displayorder') { $prefix = ''; } else { if ($sort[0]['property'] == 'ishidden') { $prefix = 'a.'; } else { if (in_array($sort[0]['property'], $specOrders)) { $prefix = 'order_'; } } } $order = 'order by ' . $prefix . $sort[0]['property'] . ' ' . $sort[0]['direction'] . ',a.modtime desc'; } $w = "a.id is not null"; $w .= empty($keyword) ? '' : " and (a.title like '%{$keyword}%' or a.id like '%{$keyword}%')"; $w .= empty($kindid) ? '' : " and find_in_set({$kindid},a.kindlist)"; $w .= empty($attrid) ? '' : " and find_in_set({$attrid},a.attrid)"; $w .= $webid == '-1' ? '' : " and a.webid={$webid}"; if (empty($kindid)) { $sql = "select a.aid,a.id,a.title,a.price,a.tagword,a.kindlist,a.attrid,a.litpic,if(length(ifnull(a.attrid,''))=0,0,1) as order_attrid,if(length(ifnull(a.kindlist,''))=0,0,1) as order_kindlist,if(length(ifnull(a.iconlist,''))=0,0,1) as order_iconlist,if(length(ifnull(a.themelist,''))=0,0,1) as order_themelist,\na.webid,a.piclist,a.themelist,a.iconlist,a.supplierlist,a.ishidden,b.isjian,ifnull(b.displayorder,9999) as displayorder,b.isding from sline_spot as a left join sline_allorderlist b on (a.id=b.aid and b.typeid=5) where {$w} {$order} limit {$start},{$limit} "; } else { $sql = "select a.aid,a.id,a.title,a.price,if(length(ifnull(a.attrid,''))=0,0,1) as order_attrid,if(length(ifnull(a.kindlist,''))=0,0,1) as order_kindlist,if(length(ifnull(a.iconlist,''))=0,0,1) as order_iconlist,if(length(ifnull(a.themelist,''))=0,0,1) as order_themelist,\na.tagword,a.kindlist,a.attrid,a.litpic,a.webid,a.piclist,a.themelist,a.iconlist,a.supplierlist,a.ishidden,b.isjian,ifnull(b.displayorder,9999) as displayorder,b.isding from sline_spot as a left join sline_kindorderlist as b on (b.classid={$kindid} and a.id=b.aid and b.typeid=5) where {$w} {$order} limit {$start},{$limit}"; } $totalcount_arr = DB::query(Database::SELECT, "select count(*) as num from sline_spot a where {$w}")->execute()->as_array(); $list = DB::query(Database::SELECT, $sql)->execute()->as_array(); $new_list = array(); foreach ($list as $k => $v) { $v['kindname'] = Model_Destinations::getKindnameList($v['kindlist']); $v['attrname'] = Model_Spot_Attr::getAttrnameList($v['attrid']); $v['url'] = Common::getBaseUrl($v['webid']) . '/spots/show_' . $v['aid'] . '.html'; $iconname = Model_Icon::getIconName($v['iconlist']); $name = ''; foreach ($iconname as $icon) { if (!empty($icon)) { $name .= '<span style="color:red">[' . $icon . ']</span>'; } } $v['iconname'] = $name; $v['series'] = Common::getSeries($v['id'], '05'); //编号 //供应商信息 $supplier = ORM::factory('supplier')->where("id='{$v['supplierlist']}'")->find()->as_array(); $v['suppliername'] = $supplier['suppliername']; $v['linkman'] = $supplier['linkman']; $v['mobile'] = $supplier['mobile']; $v['address'] = $supplier['address']; $v['qq'] = $supplier['qq']; $suits = DB::query(Database::SELECT, "select a.*,b.kindname as tickettypename from sline_spot_ticket a left join sline_spot_ticket_type b on a.tickettypeid=b.id where a.spotid={$v['id']} order by a.displayorder asc")->execute()->as_array(); if (!empty($suits)) { $v['tr_class'] = 'parent-product-tr'; } $new_list[] = $v; foreach ($suits as $key => $val) { $val['title'] = $val['title']; $val['ticketid'] = $val['id']; //门票id $val['spotid'] = $v['id']; //景点id $val['id'] = 'suit_' . $val['id']; if ($key != count($suits) - 1) { $val['tr_class'] = 'suit-tr'; } $new_list[] = $val; } } $result['total'] = $totalcount_arr[0]['num']; $result['lists'] = $new_list; $result['success'] = true; echo json_encode($result); } else { if ($action == 'save') { } else { if ($action == 'delete') { $rawdata = file_get_contents('php://input'); $data = json_decode($rawdata); $id = $data->id; if (is_numeric($id)) { $model = ORM::factory('spot', $id); $model->deleteClear(); } else { if (strpos($id, 'suit') !== FALSE) { $suitid = substr($id, strpos($id, '_') + 1); $suit = ORM::factory('spot_ticket', $suitid); $suit->deleteClear(); } } } else { if ($action == 'update') { $id = Arr::get($_POST, 'id'); $field = Arr::get($_POST, 'field'); $val = Arr::get($_POST, 'val'); $kindid = Arr::get($_POST, 'kindid'); if ($field == 'displayorder') { $displayorder = empty($val) ? 9999 : $val; if (is_numeric($id)) { if (empty($kindid)) { $order = ORM::factory('allorderlist'); $order_mod = $order->where("aid='{$id}' and typeid=5 and webid=0")->find(); if ($order_mod->id) { $order_mod->displayorder = $displayorder; } else { $order_mod->displayorder = $displayorder; $order_mod->aid = $id; $order_mod->webid = 0; $order_mod->typeid = 5; } $order_mod->save(); if ($order_mod->saved()) { echo 'ok'; } else { echo 'no'; } } else { $kindorder = ORM::factory('kindorderlist'); $kindorder_mod = $kindorder->where("aid='{$id}' and typeid=5 and classid={$kindid}")->find(); if ($kindorder_mod->id) { $kindorder_mod->displayorder = $displayorder; } else { $kindorder_mod->displayorder = $displayorder; $kindorder_mod->aid = $id; $kindorder_mod->classid = $kindid; $kindorder_mod->typeid = 5; } $kindorder_mod->save(); if ($kindorder->saved()) { echo 'ok'; } else { echo 'no'; } } } else { if (strpos($id, 'suit') !== FALSE) { $suitid = substr($id, strpos($id, '_') + 1); $suit = ORM::factory('spot_ticket', $suitid); $suit->displayorder = $displayorder; if ($suit->id) { $suit->save(); if ($suit->saved()) { echo 'ok'; } else { echo 'no'; } } } } } else { if (is_numeric($id)) { $model = ORM::factory('spot', $id); } else { if (strpos($id, 'suit') !== FALSE) { $suitid = substr($id, strpos($id, '_') + 1); $model = ORM::factory('spot_ticket', $suitid); } } if ($model->id) { $model->{$field} = $val; if ($field == 'kindlist') { $model->{$field} = implode(',', Model_Destinations::getParentsStr($val)); } else { if ($field == 'attrid') { $model->{$field} = implode(',', Model_Attrlist::getParentsStr($val, 5)); } } $model->save(); if ($model->saved()) { echo 'ok'; } else { echo 'no'; } } } } } } } } }
public function action_show() { $id = $this->params['id']; //详细信息 $row = ORM::factory('car')->where("id={$id}")->find()->as_array(); if (empty($row['litpic'])) { $row['litpic'] = Common::getDefaultImage(); } //车辆类型 if (!empty($row['carkindid'])) { $cartype = ORM::factory('car_kind')->where("id=" . $row['carkindid'])->find()->as_array(); $row['counkindname'] = $cartype['kindname']; } //车辆品牌 //$carbrand=ORM::factory('car_brand')->where("id=".$row['carbrandid'])->find()->as_array(); //$row['carbrand'] = $carbrand['kindname']; $row['attrname'] = Model_Car_Attr::getAttrnameList($row['attrid']); $row['lineseries'] = Common::getSeries($row['id'], '03'); //线路编号 //产品图片 if (!empty($row['piclist'])) { $temarr = explode(",", $row['piclist']); foreach ($temarr as $key => $value) { $row['pic_arr'][$key] = explode("||", $value); } } $sql = "SELECT min(b.adultprice) as carprice FROM sline_car a LEFT JOIN sline_car_suit_price b ON (b.carid = {$id} and b.adultprice!=0) WHERE a.ishidden=0 GROUP BY a.id ORDER BY a.displayorder ASC LIMIT 1"; $query = DB::query(Database::SELECT, $sql); $list = $query->execute()->as_array(); $this->assign('list', $list); $this->assign('row', $row); $this->display('cars/show'); }
public function action_car() { $action = $this->params['action']; if (empty($action)) { $this->assign('kindmenu', Common::getConfig('menu_sub.carkind')); //分类设置项 $this->display('stourtravel/car/list'); } else { if ($action == 'read') { $start = Arr::get($_GET, 'start'); $limit = Arr::get($_GET, 'limit'); $keyword = Arr::get($_GET, 'keyword'); $kindid = Arr::get($_GET, 'kindid'); $attrid = Arr::get($_GET, 'attrid'); $carkindid = Arr::get($_GET, 'carkindid'); $webid = Arr::get($_GET, 'webid'); $sort = json_decode(Arr::get($_GET, 'sort'), true); $order = 'order by a.modtime desc'; $webid = empty($webid) ? -1 : $webid; $keyword = Common::getKeyword($keyword); $specOrders = array('attrid', 'kindlist', 'iconlist', 'themelist'); if ($sort[0]['property']) { $prefix = ''; if ($sort[0]['property'] == 'displayorder') { $prefix = ''; } else { if ($sort[0]['property'] == 'ishidden') { $prefix = 'a.'; } else { if ($sort[0]['property'] == 'suitday') { $prefix = 'e.'; } else { if ($sort[0]['property'] == 'seatnum') { $prefix = 'a.'; } else { if (in_array($sort[0]['property'], $specOrders)) { $prefix = 'order_'; } } } } } $order = 'order by ' . $prefix . $sort[0]['property'] . ' ' . $sort[0]['direction'] . ',a.modtime desc'; } $w = "a.id is not null"; $w .= empty($keyword) ? '' : " and (a.title like '%{$keyword}%' or a.id like '%{$keyword}%')"; $w .= empty($kindid) ? '' : " and find_in_set({$kindid},a.kindlist)"; $w .= empty($attrid) ? '' : " and find_in_set({$attrid},a.attrid)"; $w .= empty($brandid) ? '' : " and a.carbrandid='{$brandid}'"; $w .= empty($carkindid) ? '' : " and a.carkindid='{$carkindid}'"; $w .= $webid == '-1' ? '' : " and a.webid={$webid}"; if (empty($kindid)) { $sql = "select a.id,a.webid,a.aid,a.title,a.supplierlist,a.seatnum,a.carkindid,a.kindlist,a.attrid,a.iconlist,a.themelist,if(length(ifnull(a.attrid,''))=0,0,1) as order_attrid,if(length(ifnull(a.kindlist,''))=0,0,1) as order_kindlist,if(length(ifnull(a.iconlist,''))=0,0,1) as order_iconlist,if(length(ifnull(a.themelist,''))=0,0,1) as order_themelist\n,a.ishidden,d.kindname as carkindname,IFNULL(b.displayorder,9999) as displayorder,ifnull(e.suitday,0) as suitday from sline_car as a left join sline_allorderlist b on (a.id=b.aid and b.typeid=3) left join sline_car_kind d on (a.carkindid=d.id) left join (select c.carid,c.id,min(c.suitday) as suitday from(select a.carid,a.id,max(b.day) as suitday\n from sline_car_suit a left join sline_car_suit_price b on a.id=b.suitid group by a.id) c group by c.carid) e on a.id=e.carid where {$w} {$order} limit {$start},{$limit}"; } else { $sql = "select a.id,a.webid,a.aid,a.title,a.supplierlist,a.seatnum,a.carkindid,a.kindlist,a.attrid,a.iconlist,a.themelist,if(length(ifnull(a.attrid,''))=0,0,1) as order_attrid,if(length(ifnull(a.kindlist,''))=0,0,1) as order_kindlist,if(length(ifnull(a.iconlist,''))=0,0,1) as order_iconlist,if(length(ifnull(a.themelist,''))=0,0,1) as order_themelist\n,a.ishidden,b.isjian,b.isding,b.istejia,ifnull(b.displayorder,9999) as displayorder ,d.kindname as carkindname,ifnull(e.suitday,0) as suitday from sline_car as a left join sline_kindorderlist as b on (a.id=b.id and b.classid={$kindid} and b.typeid=3) left join sline_car_kind d on (a.carkindid=d.id) left join (select c.carid,c.id,min(c.suitday) as suitday from(select a.carid,a.id,max(b.day) as suitday\n from sline_car_suit a left join sline_car_suit_price b on a.id=b.suitid group by a.id) c group by c.carid) e on a.id=e.carid where FIND_IN_SET({$kindid},a.kindlist) order by a.modtime desc"; } $totalcount_arr = DB::query(Database::SELECT, "select count(*) as num from sline_car a where {$w}")->execute()->as_array(); $list = DB::query(Database::SELECT, $sql)->execute()->as_array(); $new_list = array(); foreach ($list as $k => $v) { $v['kindname'] = Model_Destinations::getKindnameList($v['kindlist']); $v['attrname'] = Model_Car_Attr::getAttrnameList($v['attrid']); $v['series'] = Common::getSeries($v['id'], '03'); //编号 $v['url'] = Common::getBaseUrl($v['webid']) . '/cars/show_' . $v['aid'] . '.html'; //供应商信息 $supplier = ORM::factory('supplier')->where("id='{$v['supplierlist']}'")->find()->as_array(); $v['suppliername'] = $supplier['suppliername']; $v['linkman'] = $supplier['linkman']; $v['mobile'] = $supplier['mobile']; $v['address'] = $supplier['address']; $v['qq'] = $supplier['qq']; $suits = ORM::factory('car_suit')->where("carid={$v['id']}")->get_all(); $suittypes = ORM::factory('car_suit_type')->where("carid={$v['id']}")->get_all(); $suitOrder = $sort[0]['property'] == 'suitday' ? 'order by suitday ' . $sort[0]['direction'] : ''; $suitSql = "select a.*,ifnull(max(b.day),0) as suitday from sline_car_suit a left join sline_car_suit_price b on a.id=b.suitid where a.carid={$v['id']} group by a.id {$suitOrder}"; $suits = DB::query(Database::SELECT, $suitSql)->execute()->as_array(); if (!empty($suits)) { $v['tr_class'] = 'parent-product-tr'; } $new_list[] = $v; foreach ($suits as $key => $val) { $val['title'] = $val['suitname']; $val['id'] = 'suit_' . $val['id']; $val['suittypes'] = $suittypes; if ($key != count($suits) - 1) { $val['tr_class'] = 'suit-tr'; } $new_list[] = $val; } } $result['total'] = $totalcount_arr[0]['num']; $result['lists'] = $new_list; $result['success'] = true; echo json_encode($result); } else { if ($action == 'save') { } else { if ($action == 'delete') { $rawdata = file_get_contents('php://input'); $data = json_decode($rawdata); $id = $data->id; if (is_numeric($id)) { $model = ORM::factory('car', $id); $model->deleteClear(); } else { if (strpos($id, 'suit') !== FALSE) { $suitid = substr($id, strpos($id, '_') + 1); $suit = ORM::factory('car_suit', $suitid); $carid = $suit->carid; $suit->deleteClear(); Model_Car::updateMinPrice($carid); } } } else { if ($action == 'update') { $id = Arr::get($_POST, 'id'); $field = Arr::get($_POST, 'field'); $val = Arr::get($_POST, 'val'); $kindid = Arr::get($_POST, 'kindid'); if ($field == 'displayorder') { $displayorder = empty($val) ? 9999 : $val; if (is_numeric($id)) { if (empty($kindid)) { $order = ORM::factory('allorderlist'); $order_mod = $order->where("aid='{$id}' and typeid=3 and webid=0")->find(); if ($order_mod->id) { $order_mod->displayorder = $displayorder; } else { $order_mod->displayorder = $displayorder; $order_mod->aid = $id; $order_mod->webid = 0; $order_mod->typeid = 3; } $order_mod->save(); if ($order_mod->saved()) { echo 'ok'; } else { echo 'no'; } } else { $kindorder = ORM::factory('kindorderlist'); $kindorder_mod = $kindorder->where("aid='{$id}' and typeid=3 and classid={$kindid}")->find(); if ($kindorder_mod->id) { $kindorder_mod->displayorder = $displayorder; } else { $kindorder_mod->displayorder = $displayorder; $kindorder_mod->aid = $id; $kindorder_mod->classid = $kindid; $kindorder_mod->typeid = 3; } $kindorder_mod->save(); if ($kindorder->saved()) { echo 'ok'; } else { echo 'no'; } } } else { if (strpos($id, 'suit') !== FALSE) { $suitid = substr($id, strpos($id, '_') + 1); $suit = ORM::factory('car_suit', $suitid); $suit->displayorder = $displayorder; if ($suit->id) { $suit->save(); if ($suit->saved()) { echo 'ok'; } else { echo 'no'; } } } } } else { if (is_numeric($id)) { $model = ORM::factory('car', $id); } else { if (strpos($id, 'suit') !== FALSE) { $suitid = substr($id, strpos($id, '_') + 1); $model = ORM::factory('car_suit', $suitid); } } if ($model->id) { $model->{$field} = $val; if ($field == 'kindlist') { $model->{$field} = implode(',', Model_Destinations::getParentsStr($val)); } else { if ($field == 'attrid') { $model->{$field} = implode(',', Model_Attrlist::getParentsStr($val, 3)); } } $model->save(); if ($model->saved()) { echo 'ok'; } else { echo 'no'; } } } } } } } } }
public function action_show() { $id = $this->params['id']; //详细信息 $row = ORM::factory('hotel')->where("id={$id}")->find()->as_array(); if (empty($row['litpic'])) { $row['litpic'] = Common::getDefaultImage(); } //酒店星级 $hoteltype = ORM::factory('hotel_rank')->where("aid=" . intval($row['hotelrankid']))->find()->as_array(); $row['randname'] = $hoteltype['hotelrank']; //酒店属性 $row['attrname'] = Model_Hotel_Attr::getAttrnameList($row['attrid']); $row['series'] = Common::getSeries($row['id'], '02'); //编号 //产品图片 if (!empty($row['piclist'])) { $temarr = explode(",", $row['piclist']); foreach ($temarr as $key => $value) { $row['pic_arr'][$key] = explode("||", $value); } } $this->assign('row', $row); $this->display('hotels/show'); }
public function action_visa() { $action = $this->params['action']; if (empty($action)) { $this->assign('kindmenu', Common::getConfig('menu_sub.visakind')); //分类设置项 $this->display('stourtravel/visa/list'); } else { if ($action == 'read') { $start = Arr::get($_GET, 'start'); $limit = Arr::get($_GET, 'limit'); $visatype = Arr::get($_GET, 'visatype'); $cityid = Arr::get($_GET, 'cityid'); $keyword = Arr::get($_GET, 'keyword'); $keyword = Common::getKeyword($keyword); //echo $keyword; $specOrders = array('attrid', 'kindlist', 'iconlist', 'themelist'); $sort = json_decode(Arr::get($_GET, 'sort'), true); $order = 'order by a.modtime desc'; if ($sort[0]['property']) { if ($sort[0]['property'] == 'displayorder') { $prefix = ''; } else { if ($sort[0]['property'] == 'ishidden') { $prefix = 'a.'; } else { if (in_array($sort[0]['property'], $specOrders)) { $prefix = 'order_'; } } } $order = 'order by ' . $prefix . $sort[0]['property'] . ' ' . $sort[0]['direction'] . ',a.modtime desc'; } $w = "a.id is not null"; $w .= empty($keyword) ? '' : " and (a.title like '%{$keyword}%' or a.id like '%{$keyword}%')"; $w .= empty($visatype) ? '' : " and a.visatype={$visatype}"; $w .= empty($cityid) ? '' : " and a.cityid={$cityid}"; $sql = "select a.*,if(length(ifnull(a.iconlist,''))=0,0,1) as order_iconlist,if(length(ifnull(a.themelist,''))=0,0,1) as order_themelist,ifnull(b.displayorder,9999) as displayorder from sline_visa as a left join sline_allorderlist b on (a.id=b.aid and b.typeid=8) where {$w} {$order} limit {$start},{$limit}"; //echo $sql; $totalcount_arr = DB::query(Database::SELECT, "select count(*) as num from sline_visa a where {$w}")->execute()->as_array(); $list = DB::query(Database::SELECT, $sql)->execute()->as_array(); $new_list = array(); foreach ($list as $k => $v) { $v['visakind'] = ORM::factory('visa_kind')->where('id', '=', $v['visatype'])->find()->get('kindname'); $v['visacity'] = ORM::factory('visa_city')->where('id', '=', $v['cityid'])->find()->get('kindname'); $iconname = Model_Icon::getIconName($v['iconlist']); $name = ''; foreach ($iconname as $icon) { if (!empty($icon)) { $name .= '<span style="color:red">[' . $icon . ']</span>'; } } $v['iconname'] = $name; $v['series'] = Common::getSeries($v['id'], '08'); //编号 //供应商信息 $supplier = ORM::factory('supplier')->where("id='{$v['supplierlist']}'")->find()->as_array(); $v['suppliername'] = $supplier['suppliername']; $v['linkman'] = $supplier['linkman']; $v['mobile'] = $supplier['mobile']; $v['address'] = $supplier['address']; $v['qq'] = $supplier['qq']; $new_list[] = $v; } $result['total'] = $totalcount_arr[0]['num']; $result['lists'] = $new_list; $result['success'] = true; echo json_encode($result); } else { if ($action == 'save') { } else { if ($action == 'delete') { $rawdata = file_get_contents('php://input'); $data = json_decode($rawdata); $id = $data->id; if (is_numeric($id)) { $model = ORM::factory('visa', $id); $model->deleteClear(); } } else { if ($action == 'update') { $id = Arr::get($_POST, 'id'); $field = Arr::get($_POST, 'field'); $val = Arr::get($_POST, 'val'); $kindid = Arr::get($_POST, 'kindid'); if ($field == 'displayorder') { $displayorder = empty($val) ? 9999 : $val; if (is_numeric($id)) { $order = ORM::factory('allorderlist'); $order_mod = $order->where("aid", '=', $id)->and_where('typeid', '=', '8')->and_where('webid', '=', '0')->find(); if ($order_mod->id) { $order_mod->displayorder = $displayorder; } else { $order_mod->displayorder = $displayorder; $order_mod->aid = $id; $order_mod->webid = 0; $order_mod->typeid = 8; } $order_mod->save(); if ($order_mod->saved()) { echo 'ok'; } else { echo 'no'; } } } else { if (is_numeric($id)) { $model = ORM::factory('visa', $id); } if ($model->id) { $model->{$field} = $val; $model->save(); if ($model->saved()) { echo 'ok'; } else { echo 'no'; } } } } } } } } }
public function action_line() { $action = $this->params['action']; if (empty($action)) { $this->assign('kindmenu', Common::getConfig('menu_sub.linekind')); //分类设置项 $this->display('stourtravel/line/list'); } else { if ($action == 'read') { $start = Arr::get($_GET, 'start'); $limit = Arr::get($_GET, 'limit'); $keyword = Arr::get($_GET, 'keyword'); $kindid = Arr::get($_GET, 'kindid'); $attrid = Arr::get($_GET, 'attrid'); $startcity = Arr::get($_GET, 'startcity'); $sort = json_decode(Arr::get($_GET, 'sort'), true); $webid = Arr::get($_GET, 'webid'); $webid = empty($webid) ? '-1' : $webid; $keyword = Common::getKeyword($keyword); $specOrders = array('attrid', 'kindlist', 'iconlist', 'themelist'); $order = 'order by a.modtime desc'; if ($sort[0]['property']) { if ($sort[0]['property'] == 'displayorder') { $prefix = ''; } else { if ($sort[0]['property'] == 'ishidden') { $prefix = 'a.'; } else { if ($sort[0]['property'] == 'suitday') { $prefix = 'd.'; } else { if (in_array($sort[0]['property'], $specOrders)) { $prefix = 'order_'; } } } } $order = 'order by ' . $prefix . $sort[0]['property'] . ' ' . $sort[0]['direction'] . ',a.modtime desc'; } $w = "a.id is not null"; $w .= empty($keyword) ? '' : " and (a.title like '%{$keyword}%' or a.id like '%{$keyword}%')"; $w .= empty($kindid) ? '' : " and find_in_set({$kindid},a.kindlist)"; $w .= empty($attrid) ? '' : " and find_in_set({$attrid},a.attrid)"; $w .= empty($startcity) ? '' : " and a.startcity='{$startcity}'"; $w .= $webid == '-1' ? '' : " and a.webid={$webid}"; if ($kindid != 0) { $sql = "select a.id,a.aid,a.title,a.iconlist,a.price,a.startcity,if(length(ifnull(a.attrid,''))=0,0,1) as order_attrid,if(length(ifnull(a.kindlist,''))=0,0,1) as order_kindlist,if(length(ifnull(a.iconlist,''))=0,0,1) as order_iconlist,if(length(ifnull(a.themelist,''))=0,0,1) as order_themelist,\na.attrid,a.webid,a.kindlist,a.ishidden,a.piclist,a.themelist,a.supplierlist,b.isjian,IFNULL(b.displayorder,9999) as displayorder,b.isding,b.istejia,ifnull(d.suitday,0) as suitday from sline_line as a left join sline_kindorderlist b on (a.id=b.aid and b.typeid=1 and b.classid={$kindid}) left join (select\nc.lineid,c.id,min(c.suitday) as suitday from(select a.lineid,a.id,max(ifnull(b.day,0)) as suitday from sline_line_suit a left join sline_line_suit_price b on a.id=b.suitid group by a.id) c group by c.lineid) d on a.id=d.lineid where {$w} {$order} limit {$start},{$limit}"; } else { $sql = "select a.id,a.aid,a.title,a.supplierlist,a.iconlist,a.price,a.startcity,a.attrid,if(length(ifnull(a.attrid,''))=0,0,1) as order_attrid,if(length(ifnull(a.kindlist,''))=0,0,1) as order_kindlist,if(length(ifnull(a.iconlist,''))=0,0,1) as order_iconlist,if(length(ifnull(a.themelist,''))=0,0,1) as order_themelist,a.webid,a.kindlist,a.ishidden,a.piclist,a.themelist,b.isjian,IFNULL(b.displayorder,9999) as displayorder,b.isding,b.istejia,ifnull(d.suitday,0) as suitday from sline_line as a left join sline_allorderlist b on (a.id=b.aid and b.typeid=1) left join (select\nc.lineid,c.id,min(c.suitday) as suitday from(select a.lineid,a.id,max(ifnull(b.day,0)) as suitday from sline_line_suit a left join sline_line_suit_price b on a.id=b.suitid group by a.id) c group by c.lineid) d on a.id=d.lineid where {$w} {$order} limit {$start},{$limit}"; } $totalcount_arr = DB::query(Database::SELECT, "select count(*) as num from sline_line a where {$w}")->execute()->as_array(); $list = DB::query(Database::SELECT, $sql)->execute()->as_array(); $new_list = array(); foreach ($list as $k => $v) { $v['kindname'] = Model_Destinations::getKindnameList($v['kindlist']); $v['attrname'] = Model_Line_Attr::getAttrnameList($v['attrid']); $v['url'] = Common::getBaseUrl($v['webid']) . '/lines/show_' . $v['aid'] . '.html'; $iconname = Model_Icon::getIconName($v['iconlist']); $name = ''; foreach ($iconname as $icon) { if (!empty($icon)) { $name .= '<span style="color:red">[' . $icon . ']</span>'; } } $v['iconname'] = $name; $v['lineseries'] = Common::getSeries($v['id'], '01'); //线路编号 //供应商信息 $supplier = ORM::factory('supplier')->where("id='{$v['supplierlist']}'")->find()->as_array(); $v['suppliername'] = $supplier['suppliername']; $v['linkman'] = $supplier['linkman']; $v['mobile'] = $supplier['mobile']; $v['address'] = $supplier['address']; $v['qq'] = $supplier['qq']; /*foreach($supplier as $key=>$v) { $v[$key] = $v; }*/ //$suit=ORM::factory('line_suit')->where("lineid={$v['id']}")->get_all(); $suitOrder = $sort[0]['property'] == 'suitday' ? 'order by suitday ' . $sort[0]['direction'] : ''; $suitSql = "select a.*,max(b.day) as suitday from sline_line_suit a left join sline_line_suit_price b on a.id=b.suitid where a.lineid={$v['id']} group by a.id {$suitOrder}"; $suit = DB::query(Database::SELECT, $suitSql)->execute()->as_array(); if (!empty($suit)) { $v['tr_class'] = 'parent-line-tr'; } $new_list[] = $v; foreach ($suit as $key => $val) { $val['title'] = $val['suitname']; $val['minprice'] = Model_Line_Suit_Price::getMinPrice($val['id']); $val['minprofit'] = Model_Line_Suit_Price::getMinPrice($val['id'], 'adultprofit'); $val['id'] = 'suit_' . $val['id']; if ($key != count($suit) - 1) { $val['tr_class'] = 'suit-tr'; } $new_list[] = $val; } } $result['total'] = $totalcount_arr[0]['num']; $result['lines'] = $new_list; $result['success'] = true; echo json_encode($result); } else { if ($action == 'save') { $rawdata = file_get_contents('php://input'); $data = json_decode($rawdata); $field = Arr::get($_GET, 'field'); $kindid = Arr::get($_GET, 'kindid'); $id = $data->id; if (is_numeric($id)) { if ($field == 'displayorder') { $displayorder = $data->displayorder; if (empty($kindid)) { $order = ORM::factory('allorderlist'); $order_mod = $order->where("aid='{$id}' and typeid=1 and webid=0")->find(); $displayorder = empty($displayorder) ? 9999 : $displayorder; if ($order_mod->id) { $order_mod->displayorder = $displayorder; } else { $order_mod->displayorder = $displayorder; $order_mod->aid = $id; $order_mod->webid = 0; $order_mod->typeid = 1; } $order_mod->save(); } else { $kindorder = ORM::factory('kindorderlist'); $kindorder_mod = $kindorder->where("aid='{$id}' and typeid=1 and classid={$kindid}")->find(); $displayorder = empty($displayorder) ? 9999 : $displayorder; if ($kindorder_mod->id) { $kindorder_mod->displayorder = $displayorder; } else { $kindorder_mod->displayorder = $displayorder; $kindorder_mod->aid = $id; $kindorder_mod->classid = $kindid; $kindorder_mod->typeid = 1; } $kindorder_mod->save(); } } } else { if (strpos($id, 'suit') !== FALSE) { $suitid = substr($id, strpos($id, '_') + 1); $suit = ORM::factory('line_suit', $suitid); if ($field == 'displayorder') { $displayorder = $data->displayorder; $displayorder = empty($displayorder) ? 999999 : $displayorder; $suit->displayorder = $displayorder; $suit->save(); } else { $suit->{$field} = $data->{$field}; $suit->save(); } } } } else { if ($action == 'delete') { $rawdata = file_get_contents('php://input'); $data = json_decode($rawdata); $id = $data->id; if (is_numeric($id)) { $line = ORM::factory('line', $id); $line->deleteClear(); $jieshao_model = new Model_Line_Jieshao(); $jieshao_model->deleteByLineId($id); } else { if (strpos($id, 'suit') !== FALSE) { $suitid = substr($id, strpos($id, '_') + 1); $suit = ORM::factory('line_suit', $suitid); $lineid = $suit->lineid; $suit->deleteClear(); Model_Line::updateMinPrice($lineid); } } } else { if ($action == 'update') { $id = Arr::get($_POST, 'id'); $field = Arr::get($_POST, 'field'); $val = Arr::get($_POST, 'val'); $kindid = Arr::get($_POST, 'kindid'); if ($field == 'displayorder') { if (is_numeric($id)) { $displayorder = $val; if (empty($kindid)) { $order = ORM::factory('allorderlist'); $order_mod = $order->where("aid='{$id}' and typeid=1 and webid=0")->find(); $displayorder = empty($displayorder) ? 9999 : $displayorder; if ($order_mod->id) { $order_mod->displayorder = $displayorder; } else { $order_mod->displayorder = $displayorder; $order_mod->aid = $id; $order_mod->webid = 0; $order_mod->typeid = 1; } $order_mod->save(); if ($order_mod->saved()) { echo 'ok'; } else { echo 'no'; } } else { $kindorder = ORM::factory('kindorderlist'); $kindorder_mod = $kindorder->where("aid='{$id}' and typeid=1 and classid={$kindid}")->find(); $displayorder = empty($displayorder) ? 9999 : $displayorder; if ($kindorder_mod->id) { $kindorder_mod->displayorder = $displayorder; } else { $kindorder_mod->displayorder = $displayorder; $kindorder_mod->aid = $id; $kindorder_mod->classid = $kindid; $kindorder_mod->typeid = 1; } $kindorder_mod->save(); if ($kindorder->saved()) { echo 'ok'; } else { echo 'no'; } } } else { if (strpos($id, 'suit') !== FALSE) { $suitid = substr($id, strpos($id, '_') + 1); $suit = ORM::factory('line_suit', $suitid); $displayorder = $val; $displayorder = empty($displayorder) ? 999999 : $displayorder; if ($suit->id) { $suit->displayorder = $displayorder; $suit->save(); if ($suit->saved()) { echo 'ok'; } else { echo 'no'; } } } } } else { if (is_numeric($id)) { $model = ORM::factory('line', $id); } else { if (strpos($id, 'suit') !== FALSE) { $suitid = substr($id, strpos($id, '_') + 1); $model = ORM::factory('line_suit', $suitid); } } if ($model->id) { $model->{$field} = $val; if ($field == 'kindlist') { $model->{$field} = implode(',', Model_Destinations::getParentsStr($val)); } else { if ($field == 'attrid') { $model->{$field} = implode(',', Model_Attrlist::getParentsStr($val, 1)); } } $model->save(); if ($model->saved()) { echo 'ok'; } else { echo 'no'; } } } } } } } } }
public function action_show() { $lineid = $this->params['id']; if (empty($lineid)) { echo "产品信息错误!"; exit; } //产品信息 $row = ORM::factory('spot')->where("id={$lineid}")->find()->as_array(); $row['kindname'] = Model_Destinations::getKindnameList($row['kindlist']); $row['attrname'] = Model_Spot_Attr::getAttrnameList($row['attrid']); $row['lineseries'] = Common::getSeries($row['id'], '05'); //线路编号 //产品图片 if (!empty($row['piclist'])) { $temarr = explode(",", $row['piclist']); foreach ($temarr as $key => $value) { $row['pic_arr'][$key] = explode("||", $value); } } //相关产品 if (empty($row['kindlist'])) { $otherarr = array(); } else { $temarr = explode(",", trim($row['kindlist'], ',')); $endnum = count($temarr) - 1; $kindlistid = $temarr[$endnum]; $sql = "select a.id,a.title,a.price,a.attrid,a.litpic,a.satisfyscore,ifnull(b.displayorder,9999) as displayorder from sline_spot as a left join sline_kindorderlist as b on (b.classid={$kindlistid} and a.id=b.aid and b.typeid=5) order by displayorder asc limit 0,4"; $otherarr = DB::query(Database::SELECT, $sql)->execute()->as_array(); foreach ($otherarr as $key => $value) { $otherarr[$key]['attrname'] = Model_Spot_Attr::getAttrnameList($value['attrid']); } } $this->assign('row', $row); $this->assign('other', $otherarr); $this->display('spot/show'); }
public function action_show() { $tel = Common::getSysPara('cfg_phone'); $lineid = $this->params['id']; if (empty($lineid)) { echo "产品信息错误!"; exit; } //产品信息 $row = ORM::factory('line')->where("id={$lineid}")->find()->as_array(); $row['lineprice'] = Model_Line::getMinPrice($lineid); if (empty($row['litpic'])) { $row['litpic'] = Common::getDefaultImage(); } $row['lineseries'] = Common::getSeries($row['id'], '01'); //线路编号 $row['satisfyscore'] = empty($row['satisfyscore']) ? $row['satisfyscore'] : $row['satisfyscore'] . '%'; //如果行程类型为2 if ($row['isstyle'] == '2') { $temjeishao = ORM::factory('line_jieshao')->where("lineid=" . $row['id'])->order_by("day", 'asc')->limit($row['lineday'])->get_all(); /*foreach ($temjeishao as $key => $value) { //$value['jieshao'] = strip_tags($value['jieshao']); //$value['jieshao'] = Common::clearHtml($value['jieshao']); $temjeishao[$key]['jieshao'] = $value['jieshao']; }*/ $row['linejieshao_arr'] = $temjeishao; } else { } //产品图片 if (!empty($row['piclist'])) { $temarr = explode(",", $row['piclist']); foreach ($temarr as $key => $value) { $row['pic_arr'][$key] = explode("||", $value); } } $this->assign('linedisc', ORM::factory('line_content')->where("webid=0 and isopen=1 and isline=0 and columnname<>'linespot'")->order_by("displayorder", 'asc')->get_all()); $this->assign('row', $row); $this->assign('phone', $tel); $this->display('lines/show'); }
public function action_index() { $action = $this->params['action']; $typeid = $this->typeid; if (empty($action)) { $this->assign('kindmenu', self::$kind); //分类设置项 $this->display('stourtravel/tongyong/list'); } else { if ($action == 'read') { $start = Arr::get($_GET, 'start'); $limit = Arr::get($_GET, 'limit'); $keyword = Arr::get($_GET, 'keyword'); $kindid = Arr::get($_GET, 'kindid'); $attrid = Arr::get($_GET, 'attrid'); $webid = Arr::get($_GET, 'webid'); $webid = empty($webid) ? 0 : $webid; $keyword = Common::getKeyword($keyword); $sort = json_decode(Arr::get($_GET, 'sort'), true); $order = 'order by a.modtime desc'; $specOrders = array('attrid', 'kindlist', 'iconlist', 'themelist'); if ($sort[0]['property']) { if ($sort[0]['property'] == 'displayorder') { $prefix = 'b.'; } else { if ($sort[0]['property'] == 'ishidden') { $prefix = 'a.'; } else { if ($sort[0]['property'] == 'addtime') { $prefix = 'a.'; } else { if (in_array($sort[0]['property'], $specOrders)) { $prefix = 'order_'; } } } } $order = 'order by ' . $prefix . $sort[0]['property'] . ' ' . $sort[0]['direction'] . ',a.modtime desc'; } $w = "a.typeid='{$typeid}'"; $w .= empty($keyword) ? '' : " and a.title like '%{$keyword}%'"; $w .= empty($kindid) ? '' : " and find_in_set({$kindid},a.kindlist)"; $w .= empty($attrid) ? '' : " and find_in_set({$attrid},a.attrid)"; $w .= $webid == '-1' ? '' : " and a.webid={$webid}"; if (empty($kindid)) { $sql = "select a.*,b.displayorder,if(length(ifnull(a.attrid,''))=0,0,1) as order_attrid,if(length(ifnull(a.kindlist,''))=0,0,1) as order_kindlist,if(length(ifnull(a.iconlist,''))=0,0,1) as order_iconlist,if(length(ifnull(a.themelist,''))=0,0,1) as order_themelist from sline_model_archive as a left join sline_allorderlist b on (a.id=b.aid and b.typeid='{$typeid}') where {$w} {$order}"; } else { $sql = "select a.*,b.displayorder,if(length(ifnull(a.attrid,''))=0,0,1) as order_attrid,if(length(ifnull(a.kindlist,''))=0,0,1) as order_kindlist,if(length(ifnull(a.iconlist,''))=0,0,1) as order_iconlist,if(length(ifnull(a.themelist,''))=0,0,1) as order_themelist from sline_model_archive as a left join sline_kindorderlist as b on (b.classid={$kindid} and a.id=b.aid and b.typeid='{$typeid}') where {$w} {$order} "; } $total = DB::query(1, $sql)->execute(); $sql .= " limit {$start},{$limit}"; $list = DB::query(1, $sql)->execute()->as_array(); $new_list = array(); $moduleinfo = Model_Model::getModuleInfo($typeid); foreach ($list as $k => $v) { $v['kindname'] = Model_Destinations::getKindnameList($v['kindlist']); $v['attrname'] = Model_Article_Attr::getAttrnameList($v['attrid']); $v['modtime'] = Common::myDate('Y-m-d', $v['modtime']); $v['modulepinyin'] = $moduleinfo['pinyin']; $iconname = Model_Icon::getIconName($v['iconlist']); $name = ''; foreach ($iconname as $icon) { if (!empty($icon)) { $name .= '<span style="color:red">[' . $icon . ']</span>'; } } $v['iconname'] = $name; $v['series'] = Common::getSeries($v['id'], $typeid); //编号 //供应商信息 $supplier = ORM::factory('supplier')->where("id='{$v['supplierlist']}'")->find()->as_array(); $v['suppliername'] = $supplier['suppliername']; $v['linkman'] = $supplier['linkman']; $v['mobile'] = $supplier['mobile']; $v['address'] = $supplier['address']; $v['qq'] = $supplier['qq']; //套餐信息 $homes = ORM::factory('model_suit')->where("productid", '=', $v['id'])->get_all(); //读取套餐 if (!empty($homes)) { $v['tr_class'] = 'parent-product-tr'; } $new_list[] = $v; foreach ($homes as $key => $val) { $val['title'] = $val['suitname']; $val['suitid'] = $val['id']; $val['id'] = 'suit_' . $val['id']; $val['productid'] = $val['productid']; $val['sellprice'] = $val['sellprice']; $val['ourprice'] = $val['ourprice']; if ($key != count($homes) - 1) { $val['tr_class'] = 'suit-tr'; } $new_list[] = $val; } } $result['total'] = $total->count(); $result['lists'] = $new_list; $result['success'] = true; echo json_encode($result); } else { if ($action == 'save') { } else { if ($action == 'delete') { $rawdata = file_get_contents('php://input'); $data = json_decode($rawdata); $id = $data->id; if (is_numeric($id)) { $model = ORM::factory('model_archive', $id); $model->delete(); } else { if (strpos($id, 'suit') !== FALSE) { $suitid = substr($id, strpos($id, '_') + 1); $suit = ORM::factory('model_suit', $suitid); $suit->delete(); } } } else { if ($action == 'update') { $id = Arr::get($_POST, 'id'); $field = Arr::get($_POST, 'field'); $val = Arr::get($_POST, 'val'); $kindid = Arr::get($_POST, 'kindid'); if ($field == 'displayorder') { $displayorder = empty($val) ? 9999 : $val; if (is_numeric($id)) { if (empty($kindid)) { $order = ORM::factory('allorderlist'); $order_mod = $order->where("aid='{$id}' and typeid='{$typeid}' and webid=0")->find(); if ($order_mod->id) { $order_mod->displayorder = $displayorder; } else { $order_mod->displayorder = $displayorder; $order_mod->aid = $id; $order_mod->webid = 0; $order_mod->typeid = $typeid; } $order_mod->save(); if ($order_mod->saved()) { echo 'ok'; } else { echo 'no'; } } else { $kindorder = ORM::factory('kindorderlist'); $kindorder_mod = $kindorder->where("aid='{$id}' and typeid={$typeid} and classid={$kindid}")->find(); if ($kindorder_mod->id) { $kindorder_mod->displayorder = $displayorder; } else { $kindorder_mod->displayorder = $displayorder; $kindorder_mod->aid = $id; $kindorder_mod->classid = $kindid; $kindorder_mod->typeid = $typeid; } $kindorder_mod->save(); if ($kindorder->saved()) { echo 'ok'; } else { echo 'no'; } } } else { if (strpos($id, 'suit') !== FALSE) { $suitid = substr($id, strpos($id, '_') + 1); $suit = ORM::factory('model_suit', $suitid); $suit->displayorder = $displayorder; if ($suit->id) { $suit->save(); if ($suit->saved()) { echo 'ok'; } else { echo 'no'; } } } } } else { if (is_numeric($id)) { $model = ORM::factory('model_archive', $id); } else { if (strpos($id, 'suit') !== FALSE) { $suitid = substr($id, strpos($id, '_') + 1); $model = ORM::factory('model_suit', $suitid); } } if ($model->id) { $model->{$field} = $val; if ($field == 'kindlist') { $model->{$field} = implode(',', Model_Destinations::getParentsStr($val)); } else { if ($field == 'attrid') { $model->{$field} = implode(',', Model_Attrlist::getParentsStr($val, $typeid)); } } $model->save(); if ($model->saved()) { echo 'ok'; } else { echo 'no'; } } } } } } } } }
public function action_tuan() { $action = $this->params['action']; if (empty($action)) { $this->assign('kindmenu', Common::getConfig('menu_sub.tuankind')); //分类设置项 $this->display('stourtravel/tuan/list'); } else { if ($action == 'read') { $start = Arr::get($_GET, 'start'); $limit = Arr::get($_GET, 'limit'); $keyword = Arr::get($_GET, 'keyword'); $kindid = Arr::get($_GET, 'kindid'); $attrid = Arr::get($_GET, 'attrid'); $webid = Arr::get($_GET, 'webid'); $webid = empty($webid) ? 0 : $webid; $keyword = Common::getKeyword($keyword); $sort = json_decode(Arr::get($_GET, 'sort'), true); $specOrders = array('attrid', 'kindlist', 'iconlist', 'themelist'); $order = 'order by a.modtime desc'; if ($sort[0]['property']) { if ($sort[0]['property'] == 'displayorder') { $prefix = ''; } else { if ($sort[0]['property'] == 'ishidden') { $prefix = 'a.'; } else { if ($sort[0]['property'] == 'endtime') { $prefix = 'a.'; } else { if (in_array($sort[0]['property'], $specOrders)) { $prefix = 'order_'; } } } } $order = 'order by ' . $prefix . $sort[0]['property'] . ' ' . $sort[0]['direction'] . ',a.modtime desc'; } $w = "a.id is not null"; $w .= empty($keyword) ? '' : " and (a.title like '%{$keyword}%' or a.id like '%{$keyword}%')"; $w .= empty($kindid) ? '' : " and find_in_set({$kindid},a.kindlist)"; $w .= empty($attrid) ? '' : " and find_in_set({$attrid},a.attrid)"; $w .= $webid == '-1' ? '' : " and a.webid={$webid}"; if (empty($kindid)) { $sql = "select a.id,a.webid,a.aid,a.title,a.endtime,a.shownum,a.bookcount,a.totalnum,a.virtualnum,a.validdate,a.attrid,a.kindlist,a.jifenbook,a.jifentprice,a.jifencomment,a.iconlist,a.themelist,b.isjian,b.isding,if(length(ifnull(a.attrid,''))=0,0,1) as order_attrid,if(length(ifnull(a.kindlist,''))=0,0,1) as order_kindlist,if(length(ifnull(a.iconlist,''))=0,0,1) as order_iconlist,if(length(ifnull(a.themelist,''))=0,0,1) as order_themelist,\nifnull(b.displayorder,9999) as displayorder,ishidden from sline_tuan as a left join sline_allorderlist b on (a.id=b.aid and b.typeid=13) where {$w} {$order} limit {$start},{$limit}"; } else { $sql = "select a.id,a.webid,a.aid,a.title,a.endtime,a.shownum,a.bookcount,a.totalnum,a.virtualnum,a.validdate,a.attrid,a.kindlist,a.jifenbook,a.jifentprice,a.jifencomment,a.iconlist,a.themelist,if(length(ifnull(a.attrid,''))=0,0,1) as order_attrid,if(length(ifnull(a.kindlist,''))=0,0,1) as order_kindlist,if(length(ifnull(a.iconlist,''))=0,0,1) as order_iconlist,if(length(ifnull(a.themelist,''))=0,0,1) as order_themelist,\nb.isjian,b.isding,ifnull(b.displayorder,9999) as displayorder,ishidden from sline_tuan as a left join sline_kindorderlist as b on (b.classid={$kindid} and a.id=b.aid and b.typeid=13) where {$w} {$order} limit {$start},{$limit}"; } $totalcount_arr = DB::query(Database::SELECT, "select count(*) as num from sline_tuan a where {$w}")->execute()->as_array(); $list = DB::query(Database::SELECT, $sql)->execute()->as_array(); $new_list = array(); foreach ($list as $k => $v) { $v['kindname'] = Model_Destinations::getKindnameList($v['kindlist']); $v['attrname'] = Model_Spot_Attr::getAttrnameList($v['attrid']); $iconname = Model_Icon::getIconName($v['iconlist']); $name = ''; foreach ($iconname as $icon) { if (!empty($icon)) { $name .= '<span style="color:red">[' . $icon . ']</span>'; } } $v['iconname'] = $name; $v['series'] = Common::getSeries($v['id'], '13'); //编号 $new_list[] = $v; } $result['total'] = $totalcount_arr[0]['num']; $result['lists'] = $new_list; $result['success'] = true; echo json_encode($result); } else { if ($action == 'save') { } else { if ($action == 'delete') { $rawdata = file_get_contents('php://input'); $data = json_decode($rawdata); $id = $data->id; if (is_numeric($id)) { $model = ORM::factory('tuan', $id); $model->deleteClear(); } } else { if ($action == 'update') { $id = Arr::get($_POST, 'id'); $field = Arr::get($_POST, 'field'); $val = Arr::get($_POST, 'val'); $kindid = Arr::get($_POST, 'kindid'); if ($field == 'displayorder') { $displayorder = empty($val) ? 9999 : $val; if (is_numeric($id)) { if (empty($kindid)) { $order = ORM::factory('allorderlist'); $order_mod = $order->where("aid='{$id}' and typeid=13 and webid=0")->find(); if ($order_mod->id) { $order_mod->displayorder = $displayorder; } else { $order_mod->displayorder = $displayorder; $order_mod->aid = $id; $order_mod->webid = 0; $order_mod->typeid = 13; } $order_mod->save(); if ($order_mod->saved()) { echo 'ok'; } else { echo 'no'; } } else { $kindorder = ORM::factory('kindorderlist'); $kindorder_mod = $kindorder->where("aid='{$id}' and typeid=13 and classid={$kindid}")->find(); if ($kindorder_mod->id) { $kindorder_mod->displayorder = $displayorder; } else { $kindorder_mod->displayorder = $displayorder; $kindorder_mod->aid = $id; $kindorder_mod->classid = $kindid; $kindorder_mod->typeid = 13; } $kindorder_mod->save(); if ($kindorder->saved()) { echo 'ok'; } else { echo 'no'; } } } } else { if (is_numeric($id)) { $model = ORM::factory('tuan', $id); } if ($model->id) { $model->{$field} = $val; if ($field == 'kindlist') { $model->{$field} = implode(',', Model_Destinations::getParentsStr($val)); } else { if ($field == 'attrid') { $model->{$field} = implode(',', Model_Attrlist::getParentsStr($val, 13)); } } $model->save(); if ($model->saved()) { echo 'ok'; } else { echo 'no'; } } } } } } } } }
public function action_index() { $action = $this->params['action']; $typeid = 11; if (empty($action)) { $this->assign('kindmenu', Common::getConfig('menu_sub.jiebankind')); //分类设置项 $this->display('stourtravel/jieban/list'); } else { if ($action == 'read') { $start = Arr::get($_GET, 'start'); $limit = Arr::get($_GET, 'limit'); $kindid = Arr::get($_GET, 'kindid'); $attrid = Arr::get($_GET, 'attrid'); $sort = json_decode(Arr::get($_GET, 'sort'), true); $order = 'order by a.addtime desc'; $specOrders = array('attrid', 'kindlist', 'iconlist', 'themelist'); if ($sort[0]['property']) { if ($sort[0]['property'] == 'displayorder') { $prefix = ''; } else { if ($sort[0]['property'] == 'ishidden') { $prefix = 'a.'; } else { if (in_array($sort[0]['property'], $specOrders)) { $prefix = 'order_'; } } } $order = 'order by ' . $prefix . $sort[0]['property'] . ' ' . $sort[0]['direction'] . ',a.addtime desc'; } $w = "a.id is not null"; $w .= empty($kindid) ? '' : " and find_in_set({$kindid},a.kindlist)"; $w .= empty($attrid) ? '' : " and find_in_set({$attrid},a.attrid)"; $sql = "select a.*,if(length(ifnull(a.attrid,''))=0,0,1) as order_attrid,if(length(ifnull(a.kindlist,''))=0,0,1) as order_kindlist,if(length(ifnull(a.iconlist,''))=0,0,1) as order_iconlist,ifnull(b.displayorder,9999) as displayorder from sline_jieban as a left join sline_allorderlist b on (a.id=b.aid and b.typeid={$typeid}) where {$w} {$order} limit {$start},{$limit}"; $totalcount_arr = DB::query(Database::SELECT, "select count(*) as num from sline_jieban a where {$w}")->execute()->as_array(); $list = DB::query(Database::SELECT, $sql)->execute()->as_array(); $new_list = array(); foreach ($list as $k => $v) { $v['kindname'] = Model_Destinations::getKindnameList($v['kindlist']); $v['attrname'] = Model_Jieban_Attr::getAttrnameList($v['attrid']); $v['title'] = Model_Jieban::genTitle($v, $v['day']); $memberinfo = ORM::factory('member', $v['memberid'])->as_array(); $v['membername'] = $memberinfo['nickname']; $v['membermobile'] = $memberinfo['mobile']; $v['joinnum'] = Model_Jieban::getJoinNum($v['id']); $iconname = Model_Icon::getIconName($v['iconlist']); $name = ''; foreach ($iconname as $icon) { if (!empty($icon)) { $name .= '<span style="color:red">[' . $icon . ']</span>'; } } $v['iconname'] = $name; $v['series'] = Common::getSeries($v['id'], $typeid); //编号 $v['addtime'] = Common::myDate('Y-m-d', $v['addtime']); $new_list[] = $v; } $result['total'] = $totalcount_arr[0]['num']; $result['lists'] = $new_list; $result['success'] = true; echo json_encode($result); } else { if ($action == 'save') { } else { if ($action == 'delete') { $rawdata = file_get_contents('php://input'); $data = json_decode($rawdata); $id = $data->id; if (is_numeric($id)) { $model = ORM::factory('jieban', $id); $model->delete(); } } else { if ($action == 'update') { $id = Arr::get($_POST, 'id'); $field = Arr::get($_POST, 'field'); $val = Arr::get($_POST, 'val'); $kindid = Arr::get($_POST, 'kindid'); if ($field == 'displayorder') { $displayorder = empty($val) ? 9999 : $val; if (is_numeric($id)) { if (empty($kindid)) { $order = ORM::factory('allorderlist'); $order_mod = $order->where("aid='{$id}' and typeid={$typeid} and webid=0")->find(); if ($order_mod->id) { $order_mod->displayorder = $displayorder; } else { $order_mod->displayorder = $displayorder; $order_mod->aid = $id; $order_mod->webid = 0; $order_mod->typeid = 11; } $order_mod->save(); if ($order_mod->saved()) { echo 'ok'; } else { echo 'no'; } } else { } } } else { if (is_numeric($id)) { $model = ORM::factory('jieban', $id); } if ($model->id) { $model->{$field} = $val; if ($field == 'kindlist') { $model->{$field} = implode(',', Model_Destinations::getParentsStr($val)); } else { if ($field == 'attrid') { $model->{$field} = implode(',', Model_Attrlist::getParentsStr($val, 11)); } } $model->save(); if ($model->saved()) { echo 'ok'; } else { echo 'no'; } } } } } } } } }