예제 #1
0
 public static function genTitle($arr, $day)
 {
     $title = $arr['title'];
     $dest = Model_Destinations::getKindnameList($arr['kindlist']);
     $dest = explode(',', $dest);
     $dest = implode('--', $dest);
     return $title ? $title : $dest . $day . '日游行程';
 }
예제 #2
0
파일: site.php 프로젝트: lz1988/stourwebcms
 public function action_ajax_save()
 {
     $model = new Model_Destinations();
     $model->save_web($_POST);
     echo json_encode(array('status' => true));
 }
예제 #3
0
파일: spot.php 프로젝트: lz1988/stourwebcms
 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';
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
예제 #4
0
 public function action_modelattr()
 {
     $action = $this->params['action'];
     $typeid = $this->params['typeid'];
     //栏目id.
     $attrtable = 'model_attr';
     if (empty($action)) {
         $channelname = Model_Model::getModuleName($typeid);
         //产品名
         //$menu = self::$product_arr[$typeid].'kind';
         $this->assign('typeid', $typeid);
         $this->assign('menu', '');
         $this->assign('channelname', $channelname);
         $this->display('stourtravel/attr/modelattr');
     } else {
         if ($action == 'read') {
             $node = Arr::get($_GET, 'node');
             $list = array();
             if ($node == 'root') {
                 $list = ORM::factory($attrtable)->where("pid=0 and typeid={$typeid}")->get_all();
                 foreach ($list as $k => $v) {
                     $list[$k]['kindname'] = Model_Destinations::getKindnameList($v['destid']);
                     $list[$k]['allowDrag'] = false;
                 }
                 $list[] = array('leaf' => true, 'id' => '0add', 'attrname' => '<button class="dest-add-btn df-add-btn" onclick="addSub(0)">添加</button>', 'allowDrag' => false, 'allowDrop' => false, 'displayorder' => 'add');
             } else {
                 $list = ORM::factory($attrtable)->where('pid', '=', $node)->get_all();
                 foreach ($list as $k => $v) {
                     $list[$k]['kindname'] = Model_Destinations::getKindnameList($v['destid']);
                     $list[$k]['leaf'] = true;
                 }
                 $list[] = array('leaf' => true, 'id' => $node . 'add', 'attrname' => '<button class="dest-add-btn df-add-btn" onclick="addSub(\'' . $node . '\')">添加</button>', 'allowDrag' => false, 'allowDrop' => false, 'displayorder' => 'add');
             }
             echo json_encode(array('success' => true, 'text' => '', 'children' => $list));
         } else {
             if ($action == 'addsub') {
                 $pid = Arr::get($_POST, 'pid');
                 $model = ORM::factory($attrtable);
                 $model->pid = $pid;
                 $model->attrname = "未命名";
                 $model->webid = 0;
                 $model->typeid = $typeid;
                 $model->save();
                 if ($model->saved()) {
                     $model->reload();
                     echo json_encode($model->as_array());
                 }
             } else {
                 if ($action == 'save') {
                     $rawdata = file_get_contents('php://input');
                     $field = Arr::get($_GET, 'field');
                     $data = json_decode($rawdata);
                     $id = $data->id;
                     if ($field) {
                         $model = ORM::factory($attrtable, $id);
                         if ($model->id) {
                             $model->{$field} = $data->{$field};
                             $model->save();
                             if ($model->saved()) {
                                 echo 'ok';
                             } else {
                                 echo 'no';
                             }
                         }
                     }
                 } else {
                     if ($action == 'drag') {
                         $moveid = Arr::get($_POST, 'moveid');
                         $overid = Arr::get($_POST, 'overid');
                         $position = Arr::get($_POST, 'position');
                         $movemodel = ORM::factory($attrtable, $moveid);
                         $overmodel = ORM::factory($attrtable, $overid);
                         if ($position == 'append') {
                             $movemodel->pid = $overid;
                         } else {
                             $movemodel->pid = $overmodel->pid;
                         }
                         $movemodel->save();
                         if ($movemodel->saved()) {
                             echo 'ok';
                         } else {
                             echo 'no';
                         }
                     } else {
                         if ($action == 'delete') {
                             $rawdata = file_get_contents('php://input');
                             $data = json_decode($rawdata);
                             $id = $data->id;
                             if (!is_numeric($id)) {
                                 echo json_encode(array('success' => false));
                                 exit;
                             }
                             $model = ORM::factory($attrtable, $id);
                             $model->delete();
                         } else {
                             if ($action == 'update') {
                                 $id = Arr::get($_POST, 'id');
                                 $field = Arr::get($_POST, 'field');
                                 $val = Arr::get($_POST, 'val');
                                 $model = ORM::factory($attrtable, $id);
                                 if ($model->id) {
                                     $model->{$field} = $val;
                                     $model->save();
                                     if ($model->saved()) {
                                         echo 'ok';
                                     } else {
                                         echo 'no';
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
예제 #5
0
 public function action_article()
 {
     $action = $this->params['action'];
     if (empty($action)) {
         $this->assign('kindmenu', Common::getConfig('menu_sub.articlekind'));
         //分类设置项
         $this->display('stourtravel/article/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 = $webid == "" ? -1 : $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 = '';
                 } else {
                     if ($sort[0]['property'] == 'ishidden') {
                         $prefix = 'a.';
                     } else {
                         if ($sort[0]['property'] == 'templet') {
                             $prefix = 'a.';
                         } else {
                             if ($sort[0]['property'] == 'modtime') {
                                 $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}%'";
             $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.aid,a.title,a.attrid,a.kindlist,a.webid,a.addtime,a.ishidden,a.themelist,a.iconlist,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,ifnull(b.displayorder,999999) as displayorder,b.isding,a.modtime,a.templet from sline_article as a left join sline_allorderlist b on (a.id=b.aid and b.typeid=4) where {$w} {$order} limit {$start},{$limit}";
             } else {
                 $sql = "select a.id,a.aid,a.title,a.attrid,a.kindlist,a.webid,a.addtime,a.ishidden,a.themelist,a.iconlist,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,b.isjian,b.displayorder,b.isding,a.modtime,a.templet from sline_article as a left join sline_kindorderlist as b on (b.classid={$kindid} and a.id=b.aid and b.typeid=4)  where {$w} {$order} limit {$start},{$limit}";
             }
             $totalcount_arr = DB::query(Database::SELECT, "select count(*) as num from sline_article 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_Article_Attr::getAttrnameList($v['attrid']);
                 $v['modtime'] = Common::myDate('Y-m-d', $v['modtime']);
                 $v['url'] = Common::getBaseUrl($v['webid']) . '/raiders/show_' . $v['aid'] . '.html';
                 $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('article', $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=4 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 = 4;
                                     }
                                     $order_mod->save();
                                     if ($order_mod->saved()) {
                                         echo 'ok';
                                     } else {
                                         echo 'no';
                                     }
                                 } else {
                                     Common::debug('here');
                                     $kindorder = ORM::factory('kindorderlist');
                                     $kindorder_mod = $kindorder->where("aid='{$id}' and typeid=4 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 = 4;
                                     }
                                     $kindorder_mod->save();
                                     if ($kindorder->saved()) {
                                         echo 'ok';
                                     } else {
                                         echo 'no';
                                     }
                                 }
                             }
                         } else {
                             if (is_numeric($id)) {
                                 $model = ORM::factory('article', $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, 4));
                                     }
                                 }
                                 $model->save();
                                 if ($model->saved()) {
                                     echo 'ok';
                                 } else {
                                     echo 'no';
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
예제 #6
0
 public function action_edit()
 {
     $weblist = ORM::factory('weblist')->get_all();
     $photoid = $this->params['photoid'];
     $info = ORM::factory('photo', $photoid)->as_array();
     $info['kindlist_arr'] = Model_Destinations::getKindlistArr($info['kindlist']);
     $info['attrlist_arr'] = Common::getSelectedAttr(6, $info['attrid']);
     $info['piclist_arr'] = json_encode(Model_Photo_Picture::getPicturesByPid($info['id']));
     //图片数组
     $extendinfo = Common::getExtendInfo(6, $info['id']);
     $this->assign('extendinfo', $extendinfo);
     //扩展信息
     $this->assign('weblist', $weblist);
     $this->assign('action', 'edit');
     $this->assign('info', $info);
     $this->assign('position', '修改相册' . $info['title']);
     $this->display('stourtravel/photo/edit');
 }
예제 #7
0
파일: car.php 프로젝트: lz1988/stourwebcms
 public function action_edit()
 {
     $carid = $this->params['carid'];
     $info = ORM::factory('car', $carid)->as_array();
     $info['kindlist_arr'] = Model_Destinations::getKindlistArr($info['kindlist']);
     $info['attrlist_arr'] = Common::getSelectedAttr(3, $info['attrid']);
     $info['iconlist_arr'] = Common::getSelectedIcon($info['iconlist']);
     $info['supplier_arr'] = ORM::factory('supplier', $info['supplierlist'])->as_array();
     $info['piclist_arr'] = json_encode(Common::getUploadPicture($info['piclist']));
     //图片数组
     $columns = ORM::factory('car_content')->where("(webid=0 and isopen=1) or columnname='tupian'")->order_by('displayorder', 'asc')->get_all();
     $extendinfo = Common::getExtendInfo(3, $info['id']);
     $this->assign('columns', $columns);
     $this->assign('extendinfo', $extendinfo);
     //扩展信息
     $this->assign('action', 'edit');
     $this->assign('info', $info);
     $this->display('stourtravel/car/edit');
 }
예제 #8
0
파일: line.php 프로젝트: lz1988/stourwebcms
 public function action_attr()
 {
     $action = $this->params['action'];
     if (empty($action)) {
         $this->display('stourtravel/line/attr');
     } else {
         if ($action == 'read') {
             $node = Arr::get($_GET, 'node');
             $list = array();
             if ($node == 'root') {
                 $list = ORM::factory('line_attr')->where('pid=0')->get_all();
                 foreach ($list as $k => $v) {
                     $list[$k]['kindname'] = Model_Destinations::getKindnameList($v['destid']);
                     $list[$k]['allowDrag'] = false;
                 }
                 $list[] = array('leaf' => true, 'id' => '0add', 'attrname' => '<button class="dest-add-btn" onclick="addSub(0)">添加</button>', 'allowDrag' => false, 'allowDrop' => false, 'displayorder' => 'add');
             } else {
                 $list = ORM::factory('line_attr')->where('pid=' . $node)->get_all();
                 foreach ($list as $k => $v) {
                     $list[$k]['kindname'] = Model_Destinations::getKindnameList($v['destid']);
                     $list[$k]['leaf'] = true;
                 }
                 $list[] = array('leaf' => true, 'id' => $node . 'add', 'attrname' => '<button class="dest-add-btn" onclick="addSub(\'' . $node . '\')">添加</button>', 'allowDrag' => false, 'allowDrop' => false, 'displayorder' => 'add');
             }
             echo json_encode(array('success' => true, 'text' => '', 'children' => $list));
         } else {
             if ($action == 'addsub') {
                 $pid = Arr::get($_POST, 'pid');
                 $model = ORM::factory('line_attr');
                 $model->pid = $pid;
                 $model->attrname = "未命名";
                 $model->save();
                 if ($model->saved()) {
                     $model->reload();
                     //  $dest->updateSibling('add');
                     echo json_encode($model->as_array());
                 }
             } else {
                 if ($action == 'save') {
                     $rawdata = file_get_contents('php://input');
                     $field = Arr::get($_GET, 'field');
                     $data = json_decode($rawdata);
                     $id = $data->id;
                     if ($field) {
                         $model = ORM::factory('line_attr', $id);
                         if ($model->id) {
                             $model->{$field} = $data->{$field};
                             $model->save();
                             if ($model->saved()) {
                                 echo 'ok';
                             } else {
                                 echo 'no';
                             }
                         }
                     }
                 } else {
                     if ($action == 'drag') {
                         $moveid = Arr::get($_POST, 'moveid');
                         $overid = Arr::get($_POST, 'overid');
                         $position = Arr::get($_POST, 'position');
                         $movemodel = ORM::factory('line_attr', $moveid);
                         $overmodel = ORM::factory('line_attr', $overid);
                         if ($position == 'append') {
                             $movemodel->pid = $overid;
                         } else {
                             $movemodel->pid = $overmodel->pid;
                         }
                         $movemodel->save();
                         if ($movemodel->saved()) {
                             echo 'ok';
                         } else {
                             echo 'no';
                         }
                     } else {
                         if ($action == 'delete') {
                             $rawdata = file_get_contents('php://input');
                             $data = json_decode($rawdata);
                             $id = $data->id;
                             if (!is_numeric($id)) {
                                 echo json_encode(array('success' => false));
                                 exit;
                             }
                             $model = ORM::factory('line_attr', $id);
                             $model->deleteClear();
                         } else {
                             if ($action == 'update') {
                                 $id = Arr::get($_POST, 'id');
                                 $field = Arr::get($_POST, 'field');
                                 $val = Arr::get($_POST, 'val');
                                 $model = ORM::factory('line_attr', $id);
                                 if ($model->id) {
                                     $model->{$field} = $val;
                                     $model->save();
                                     if ($model->saved()) {
                                         echo 'ok';
                                     } else {
                                         echo 'no';
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
예제 #9
0
파일: spot.php 프로젝트: lz1988/stourwebcms
 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');
 }
예제 #10
0
 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';
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
예제 #11
0
파일: tuan.php 프로젝트: lz1988/stourwebcms
 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';
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
예제 #12
0
 public function getProductDests($id, $typeid)
 {
     if (empty($id) || empty($typeid)) {
         return null;
     }
     $model = ORM::factory('model', $typeid);
     if (!$model->loaded()) {
         return null;
     }
     $table = $model->maintable;
     $info = ORM::factory($table, $id);
     if (!$info->loaded()) {
         return null;
     }
     $destList = Model_Destinations::getKindlistArr($info->kindlist);
     return $destList;
 }
예제 #13
0
 public function action_view()
 {
     $jiebanid = $this->params['id'];
     $info = ORM::factory('jieban', $jiebanid)->as_array();
     $info['destlist'] = Model_Destinations::getKindnameList($info['kindlist']);
     $info['attrname'] = Model_Spot_Attr::getAttrnameList($info['attrid']);
     $info['title'] = Model_Jieban::genTitle($info, $info['day']);
     $memberinfo = ORM::factory('member', $info['memberid'])->as_array();
     $info['membername'] = $memberinfo['nickname'];
     $info['membermobile'] = $memberinfo['mobile'];
     $info['joinnum'] = Model_Jieban::getJoinNum($jiebanid);
     $info['joinlist'] = ORM::factory('jieban_join')->where("jiebanid=" . $info['id'])->get_all();
     $line = ORM::factory('line', $info['lineid'])->as_array();
     $info['lineinfo'] = "<a href='/lines/show_{$line['aid']}.html' target='_blank'>{$line['title']}</a>";
     $this->assign('info', $info);
     $this->display('stourtravel/jieban/view');
 }