function pageindex($inPath) { $url = $this->getUrlParams($inPath); $page = $url['page'] ? (int) $url['page'] : 1; $categoryObj = new m_category(); $purchaseObj = new m_purchase(); $condition = "isdel = 0"; if ($_POST) { $key = base_Utils::getStr($_POST['key']); $cat_id = (int) $_POST['cat_id']; $condition .= " and goods_name like '%{$key}%' or goods_sn like '%{$key}%'"; if ($cat_id) { $condition .= " and cat_id = {$cat_id}"; } $this->params['key'] = $key; } $purchaseObj->setCount(true); $purchaseObj->setPage($page); $purchaseObj->setLimit(base_Constant::PAGE_SIZE); $purchase = $purchaseObj->select($condition, "", "", "order by id desc"); $this->params['purchase'] = $purchase->items; $this->params['pagebar'] = $this->PageBar($purchase->totalSize, base_Constant::PAGE_SIZE, $page, $inPath); $this->params['catelist'] = $categoryObj->getOrderCate(' '); return $this->render('purchase/index.html', $this->params); }
function pagecategory($inPath) { $url = $this->getUrlParams($inPath); $catid = (int) $url['catid'] > 0 ? (int) $url['catid'] : (int) $_POST['cat_id']; $categoryObj = new m_category($catid); $this->params['categorylist'] = $categoryObj->getOrderCate(' '); if ($_POST) { $post = base_Utils::shtmlspecialchars($_POST); if ($catid) { if ($categoryObj->isErrorPid($post['pid'], $post['cat_id']) === false) { $this->ShowMsg("不能将父分类修改为它的子分类"); } if ($categoryObj->create($post)) { $this->ShowMsg("修改成功!", $this->createUrl("/category/index"), '', 1); } $this->ShowMsg("修改失败" . $categoryObj->getError()); } else { if ($categoryObj->isHasPid($post['pid']) === false) { $this->ShowMsg("你选择的上级分类不存在"); } if ($categoryObj->create($post)) { $this->ShowMsg("添加成功!", $this->createUrl("/category/index"), '', 1); } $this->ShowMsg("添加失败,原因:" . $categoryObj->getError()); } } else { if ($catid) { $this->params['category'] = $categoryObj->get(); } return $this->render('category/category.html', $this->params); } }
function pageaddgoods($inPath) { $url = $this->getUrlParams($inPath); $goods_id = (int) $url['gid'] > 0 ? (int) $url['gid'] : (int) $_POST['goods_id']; $goodsObj = new m_goods($goods_id); if ($_POST) { $post = base_Utils::shtmlspecialchars($_POST); if ($goodsObj->create($post)) { base_Utils::ssetcookie(array('cat_id' => $post['cat_id'])); $this->ShowMsg("操作成功!", $this->createUrl("/goods/addgoods"), 2, 1); } $this->ShowMsg("操作失败" . $goodsObj->getError()); } $categoryObj = new m_category(); $this->params['cat_id'] = (int) $_COOKIE['cat_id']; $this->params['catelist'] = $categoryObj->getOrderCate(' '); $this->params['goods'] = $goodsObj->selectOne("goods_id={$goods_id}"); return $this->render('goods/addgoods.html', $this->params); }