public function edit() { $tid = intval($_GET['tid']); if ($this->checkFormSubmit()) { $tasknew = $_GET['tasknew']; if ($tasknew['title'] && $tasknew['contact'] && $tasknew['catid']) { $location = getLocation($tasknew['city'], $tasknew['address']); $tasknew['longitude'] = $location['longitude']; $tasknew['latitude'] = $location['latitude']; $this->t('task')->where(array('uid' => $this->uid, 'tid' => $tid))->update($tasknew); $pics = $_GET['pic']; if ($pics && is_array($pics)) { $this->t('task')->where(array('tid' => $tid))->update(array('pic' => $pics[0])); $this->t('image')->where(array('dataid' => $tid, 'datatype' => 'task'))->delete(); foreach ($pics as $pic) { $this->t('image')->insert(array('dataid' => $tid, 'datatype' => 'task', 'image' => $pic)); } } $this->showSuccess('save_succeed'); } else { $this->showError('undefined_action'); } } else { global $G, $lang; $task = $this->t('task')->where(array('uid' => $this->uid, 'tid' => $tid))->selectOne(); if (!$task) { $this->showError('page_notfound'); } $pics = $this->t('image')->where(array('dataid' => $tid, 'datatype' => 'task'))->select(); if ($pics) { $newlist = array(); foreach ($pics as $plist) { $plist['url'] = image($plist['image']); $newlist[] = $plist; } $pics = $newlist; unset($newlist); } $categorylist = $this->getCategoryList(); $category = new \Core\Category(); $category->dataList = $categorylist; $categoryoptions = $category->getOptions(0, $task['catid']); include template('task_form'); } }
public function category() { if ($this->checkFormSubmit()) { $delete = $_GET['delete']; if ($delete && is_array($delete)) { $deleteids = $delete; $category = new \Core\Category(); $category->dataList = $this->getCategoryList(); foreach ($delete as $catid) { $deleteids = array_merge($deleteids, $category->getAllChildids($catid)); } $deleteids = implode(',', $deleteids); $this->t('service_category')->where("catid IN({$deleteids})")->delete(); } $categorylist = $_GET['categorylist']; if ($categorylist && is_array($categorylist)) { foreach ($categorylist as $catid => $category) { $this->t('service_category')->where(array('catid' => $catid))->update($category); } } $newcategory = $_GET['newcategory']; if ($newcategory && is_array($newcategory)) { foreach ($newcategory['cname'] as $key => $cname) { if ($cname) { $data = array('fid' => $newcategory['fid'][$key], 'cname' => $cname, 'displayorder' => intval($newcategory['displayorder'][$key]), 'template' => $newcategory['template']['key']); $this->t('service_category')->insert($data); } } } $this->showSuccess('save_succeed'); } else { global $G, $lang; $fid = isset($_GET['fid']) ? intval($_GET['fid']) : 0; $categorylist = $this->getCategoryList(); include template('service_category'); } }
public function edit() { $id = intval($_GET['id']); if ($this->checkFormSubmit()) { $goodsnew = $_GET['goodsnew']; $goodsnew['price'] = floatval($goodsnew['price']); $goodsnew['stock'] = intval($goodsnew['stock']); if ($goodsnew['name']) { $this->t('goods')->where(array('uid' => $this->uid, 'id' => $id))->update($goodsnew); $pics = $_GET['pic']; if ($pics && is_array($pics)) { $this->t('goods')->where(array('id' => $id))->update(array('pic' => $pics[0])); $this->t('image')->where(array('dataid' => $id, 'datatype' => 'goods'))->delete(); foreach ($pics as $image) { $this->t('image')->insert(array('dataid' => $id, 'datatype' => 'goods', 'image' => $image)); } } $description = htmlspecialchars($_GET['description']); $this->t('goods_description')->where(array('goods_id' => $id))->update(array('description' => $description)); $this->showSuccess('save_succeed'); } else { $this->showError('undefined_action'); } } else { global $G, $lang; $goods = $this->t('goods')->where(array('uid' => $this->uid, 'id' => $id))->selectOne(); if ($goods) { $pics = $this->t('image')->where(array('dataid' => $id, 'datatype' => 'goods'))->select(); if ($pics) { $newlist = array(); foreach ($pics as $list) { $list['url'] = image($list['image']); $newlist[] = $list; } $pics = $newlist; unset($newlist); } $description = $this->t('goods_description')->where(array('goods_id' => $id))->selectOne(); $goods['description'] = $description['description']; $categorylist = $this->getCategoryList(); $category = new \Core\Category(); $category->dataList = $categorylist; $categoryoptions = $category->getOptions(0, $goods['catid']); include template('goods_form'); } else { $this->notFound(); } } }