function pageindex($inPath) { $url = $this->getUrlParams($inPath); $page = $url['page'] ? (int) $url['page'] : 1; $categoryObj = new m_category(); $this->params['catelist'] = $categoryObj->getOrderCate(' '); $condi = ''; $goodsObj = new m_goods(); if ($_POST) { $key = base_Utils::getStr($_POST['key'], 'html'); $cat_id = (int) $_POST['cat_id']; $this->params['key'] = $key; $this->params['cat_id'] = $cat_id; $tableName = $goodsObj->tableName(); if ($key) { $condi .= "{$tableName}.goods_name like '%{$key}%' or {$tableName}.goods_sn like '%{$key}%'"; } if ($cat_id) { $condi = $condi ? $condi . " and {$tableName}.cat_id = {$cat_id}" : "{$tableName}.cat_id = {$cat_id}"; } } $rs = $goodsObj->getGoodsList($condi, $page); $this->params['goods'] = $rs->items; $this->params['pagebar'] = $this->PageBar($rs->totalSize, base_Constant::PAGE_SIZE, $page, $inPath); return $this->render('goods/index.html', $this->params); }
function pagepurchase($inPath) { $url = $this->getUrlParams($inPath); $goods_id = $url['gid'] ? (int) $url['gid'] : (int) $_POST['goods_id']; $url['ac'] = $url['ac'] ? $url['ac'] : "add"; $purchaseObj = new m_purchase((int) $url['id']); switch ($url['ac']) { case "add": $goodsObj = base_mAPI::get("m_goods", $goods_id); if ($_POST) { $goods_sn = base_Utils::getStr($_POST['goods_sn']); $rs = $goodsObj->get("goods_sn = '{$goods_sn}'"); if (!$rs) { $this->ShowMsg("没有该商品信息"); } $data['goods_id'] = $rs['goods_id']; $data['goods_sn'] = $rs['goods_sn']; $data['in_num'] = (double) $_POST['in_num']; $data['in_price'] = (double) $_POST['in_price']; if (!$data['in_num'] or !$data['in_price']) { $this->showMsg("数量和单价不能够为空!"); } $data['content'] = base_Utils::getStr($_POST['content']); if ($purchaseObj->create($data)) { $this->ShowMsg("入库成功!", $this->createUrl("/purchase/index"), 2, 1); } $this->ShowMsg("入库出错!原因:" . $purchaseObj->getError()); } if ($url['id']) { $this->params['goods'] = $purchaseObj->get(); } else { $this->params['goods'] = $goodsObj->get(); } break; case "del": if ($url['gid']) { if ($purchaseObj->deleteOne($url['gid'])) { $this->ShowMsg("删除成功!", $this->createUrl("/purchase/index"), 2, 1); } $this->ShowMsg("删除出错!原因:" . $purchaseObj->getError()); } break; } $this->params['ac'] = $url['ac']; return $this->render('purchase/purchase.html', $this->params); }
/** * 日志 * @param int $goods_id * @param string $content * @param int $type 0添加商品 1入库 2出库 */ function create($goods_id, $content, $type = 0) { if (!goods_id or !$content) { $this->setError(0, "缺少必要参数"); return false; } $this->set("goods_id", $goods_id); $this->set("type", $type); $this->set("content", base_Utils::getStr($content)); $this->set("user_id", $_COOKIE['admin_id']); $this->set("username", $_COOKIE['admin_name']); $this->set("dateymd", date("Y-m-d", $this->_time)); $this->set("dateline", $this->_time); $res = $this->save(); if ($res) { return $res; } $this->setError(0, "保存数据失败:" . $this->getError()); return false; }
function pagesales($inPath) { $ymd = date('Y-m-d', time()); if ($_POST) { $purchaseObj = new m_purchase(); $condi = ''; $start = base_Utils::getStr($_POST['start']); $end = base_Utils::getStr($_POST['end']); if ($start) { $condi = "dateymd>={$start}"; $condi .= $end ? " and dateymd<={$end}" : " and dateymd<={$ymd}"; } $this->params['title'] = "进货统计"; $rs = $purchaseObj->select($condi, "dateymd,sum(in_num*in_price) as money", "group by dateymd")->items; $this->params['start'] = $start; $this->params['end'] = $end; $this->params['line'] = $this->linedata($rs); } return $this->render('statistics/sales.html', $this->params); }
function pagelog($inPath) { $url = $this->getUrlParams($inPath); $page = $url['page'] ? (int) $url['page'] : 1; $type = (int) $url['type']; $ymd = date("Y-m-d", time()); $condi = "type={$type}"; if ($_POST) { $stime = base_Utils::getStr($_POST['stime']); $etime = base_Utils::getStr($_POST['etime']); if ($stime) { $etime = $etime ? $etime : $ymd; $condi .= " and dateymd between '{$stime}' and '{$etime}'"; } } $logObj = new m_log(); $logObj->setCount(true); $logObj->setPage($page); $logObj->setLimit(base_Constant::PAGE_SIZE); $rs = $logObj->select($condi, "", "", "order by log_id desc"); $this->params['log'] = $rs->items; $this->params['stime'] = $stime; $this->params['etime'] = $etime; $this->params['type'] = $type; $this->params['pagebar'] = $this->PageBar($rs->totalSize, base_Constant::PAGE_SIZE, $page, $inPath); return $this->render('system/log.html', $this->params); }
/** * 打印小票 * @param array $inPath */ function pageprint($inPath) { $url = $this->getUrlParams($inPath); $page = $url['page'] ? (int) $url['page'] : 1; $ymd = date("Y-m-d", time()); $condi = ''; if ($_POST) { $key = base_Utils::getStr($_POST['key']); $stime = base_Utils::getStr($_POST['stime']); $etime = base_Utils::getStr($_POST['etime']); if ($key) { $condi = "order_id ='{$key}' or goods_name like '%{$key}%' or realname like '%{$key}%' or membercardid ='{$key}'"; } if ($stime) { $etime = $etime ? $etime : $ymd; $condi = $condi ? $condi . " and" : ""; $condi .= " dateymd between '{$stime}' and '{$etime}'"; } } $saleObj = new m_sales(); $saleObj->setCount(true); $saleObj->setPage($page); $saleObj->setLimit(base_Constant::PAGE_SIZE); $rs = $saleObj->select($condi, "order_id,sum(price*num) as allprice,dateymd,sum(p_discount+m_discount) as discount,sum(refund_amount) as refund", "group by order_id", "order by sid desc"); $this->params['sales'] = $rs->items; $this->params['key'] = $key; $this->params['stime'] = $stime; $this->params['etime'] = $etime; $this->params['pagebar'] = $this->PageBar($rs->totalSize, base_Constant::PAGE_SIZE, $page, $inPath); return $this->render('sales/print.html', $this->params); }
function pageecshop($inPath) { //define(DEBUG,1); $url = $this->getUrlParams($inPath); $lastid = (int) $url['lastid'] ? (int) $url['lastid'] : 0; if ($_POST or $lastid > 0) { $pre = base_Utils::getStr($_REQUEST['pre']) ? base_Utils::getStr($_REQUEST['pre']) : $url['pre']; $num = (int) $_POST['num'] ? (int) $_POST['num'] : $url['num']; $ecshop = new m_plugins("ecshop"); $ecshop->_db->setLimit($num); $categoryObj = new m_category(); $goodsObj = new m_goods(); $type = $_POST['type'] ? $_POST['type'] : $url['type']; if ($type == 1) { $table = $pre . "category"; if ($lastid == 0) { $categoryObj->clearTable(array("category")); } $rs = $ecshop->_db->select($table, "cat_id>{$lastid}", "cat_id,cat_name,parent_id,sort_order,is_show", "order by cat_id asc")->items; if (is_array($rs[0])) { foreach ($rs as $k) { $itmes['cat_id'] = $k['cat_id']; $itmes['cat_name'] = $k['cat_name']; $itmes['pid'] = $k['parent_id']; $itmes['sort'] = $k['sort_order']; $itmes['is_show'] = $k['is_show']; if (!$categoryObj->insert($itmes)) { $this->showMsg('写入数据错误' . $categoryObj->getError()); } $lastid = $k['cat_id']; } $this->showMsg("转换{$num}条完成!", $this->createUrl("/plugins/ecshop", array("lastid" => $lastid, "num" => $num, "type" => 1)) . "?pre={$pre}", 2, 1); } else { $this->showMsg("转换完成", $this->createUrl("/plugins/ecshop"), 5, 1); } } else { $table = $pre . "goods"; if ($lastid == 0) { $goodsObj->clearTable(array("goods", "member", "purchase", "sales", "log")); } $rs = $ecshop->_db->select($table, "goods_id>{$lastid}", "", "order by goods_id asc")->items; if (is_array($rs[0])) { $i = 0; $j = 0; foreach ($rs as $k) { $itmes['cat_id'] = $k['cat_id']; $itmes['goods_sn'] = $k['goods_sn']; $itmes['goods_name'] = $k['goods_name']; $itmes['market_price'] = $k['market_price']; $itmes['out_price'] = $k['shop_price']; $itmes['promote_price'] = $k['promote_price']; $itmes['ispromote'] = $k['is_promote']; $itmes['weight'] = $k['goods_weight']; $itmes['unit'] = ''; $itmes['in_price'] = 0; $itmes['ismemberprice'] = 1; $itmes['promote_start_date'] = date("Y-m-d", $k['promote_start_date']); $itmes['promote_end_date'] = date("Y-m-d", $k['promote_end_date']); $itmes['warn_stock'] = $k['warn_number']; $itmes['goods_desc'] = $k['goods_brief']; if (!$goodsObj->create($itmes)) { $j++; //$this->showMsg('写入数据错误'.$goodsObj->getError()); } $i++; $lastid = $k['goods_id']; } $this->showMsg("共转换{$i}条数据,失败或者重复商品{$j}条!", $this->createUrl("/plugins/ecshop", array("lastid" => $lastid, "num" => $num, "type" => 2)) . "?pre={$pre}", 2, 1); } else { $this->showMsg("转换商品完成", $this->createUrl("/plugins/ecshop"), 5, 1); } } } $this->params['head_title'] = "Ecshop转换插件-" . $this->params['head_title']; return $this->render('plugins/ecshop/index.html', $this->params); }