<?php
/**
 * [UQcms System] Copyright uqcms.com
 * QQ: 2200631718
 * Author: gj.name
 * This is NOT a freeware
*/
defined('IN_UQ') or exit('Access Denied'); class area_uqcms extends control { function __construct(){ $this->aid = $_SESSION['admin']['aid']; parent::__construct(); } function index(){ $pid = @$_GET['pid']?$_GET['pid']:'0'; $prov = isset($_GET['prov'])?$_GET['prov']:''; $city = isset($_GET['city'])?$_GET['city']:''; $data = $this->db->get_all("select * from ".table('area')." where pid = ".$pid); $this->assign('data',@$data); $provinceData = $this->db->get_all("select * from ".table('area')." where pid = 0"); $this->assign('provinceData',@$provinceData); if(!empty($prov)){ $cityData = $this->db->get_all("select * from ".table('area')." where level = 2 and pid = ".$prov); $this->assign('cityData',$cityData); } $this->display(); } function edit(){ $id = intval($_GET['id'])?$_GET['id']:false; if($id){ $row = $this->db->get_one("select * from ".table('area')." where id = ".$id); $this->assign('row',$row); } $this->display('area/edit'); } public function edit_save(){ $id = $_POST['id']; if($id){ $setsql['name'] = $_POST['name']; $setsql['letter'] = $_POST['letter']; $setsql['status'] = $_POST['status']; $query = $this->db->update(table('area'),$setsql,'id = '.$id); if($query){ echo '1'; }else{ echo '失败'; } }else{ return false; } } function get_all(){ $result = $this->module('area')->get_list(); echo json_encode($result); } function ajax_district(){ $pid = $_POST['pid']; $data = ''; $query = $this->db->query("select * from ".table('area')." where pid = ".$pid); while($row = $this->db->fetch_array($query)){ $data .= $row['id']; } $data = $data; } function district_del(){ $cid = isset($_POST['cid'])?$_POST['cid']:exit('cid is not null'); $query = $this->db->delete(table('area'),'cid = '.$cid); if($query){ echo '1'; } } }