예제 #1
0
 public function indexAction()
 {
     $cid = intval($this->param('cid', 0));
     if (!$cid) {
         $url = ComTool::url("index");
         ComTool::redirect($url);
     }
     $category = CategoryData::getById($cid);
     if (!$category) {
         $url = ComTool::url("index");
         ComTool::redirect($url);
     }
     $curTime = time();
     $category['start_time'] = '09:00:00';
     $category['end_time'] = '24:00:00';
     $startTime = strtotime($category['start_time']);
     $endTime = strtotime($category['end_time']);
     $notStart = $curTime < $startTime ? true : false;
     //true为尚未开始
     $isOver = $curTime > $endTime ? true : false;
     //true为已结束
     $isOn = !$notStart && !$isOver;
     //过程中
     $this->assign('notStart', $notStart);
     $this->assign('isOver', $isOver);
     $this->assign('isOn', $isOn);
     $group = GroupData::getById($category['group_id']);
     $store = StoreData::getById($category['store_id']);
     $goods = GoodsData::getsByCid($cid);
     $cart = array();
     $cart = $this->getCart($cid);
     $this->assign('category', $category);
     $this->assign('group', $group);
     $this->assign('store', $store);
     $this->assign('goods', $goods);
     $this->assign('products', $cart['products']);
     $this->assign('totalPrice', $cart['totalPrice']);
     $this->display();
 }
예제 #2
0
<?php

date_default_timezone_set("America/Hermosillo");
$user = UserData::getById(Session::getUID());
$operations = null;
$category = null;
if (!isset($_GET["cat_id"])) {
    $operations = OperationData::getAllByDate(date("Y-m-d", time()));
    $spents = SpentData::getAllByDate(date("Y-m-d", time()));
} else {
    $operations = OperationData::getAllByDateAndCategoryId(date("Y-m-d", time()), $_GET["cat_id"]);
    $spents = SpentData::getAllByDateAndCategoryId(date("Y-m-d", time()), $_GET["cat_id"]);
    $category = CategoryData::getById($_GET["cat_id"]);
}
$sell = 0;
$spent = 0;
$money = 0;
foreach ($operations as $career) {
    $sell += $career->q * $career->price;
}
foreach ($spents as $career) {
    $spent += $career->price;
}
$money = $sell - $spent;
?>
<section class="content-header">
	<h1>Resumen</h1>
<ol class="breadcrumb">
                        <li> Categoria</li>
                        <li class="active"><?php 
if ($category == null) {
예제 #3
0
 public function getCategory()
 {
     return CategoryData::getById($this->category_id);
 }
예제 #4
0
<?php

$user = CategoryData::getById($_GET["id"]);
?>
<div class="row">
	<div class="col-md-12">
	<h1>Editar Categoria</h1>
	<br>
		<form class="form-horizontal" method="post" id="addproduct" action="index.php?action=updatecategory" role="form">


  <div class="form-group">
    <label for="inputEmail1" class="col-lg-2 control-label">Nombre*</label>
    <div class="col-md-6">
      <input type="text" name="name" value="<?php 
echo $user->name;
?>
" class="form-control" id="name" placeholder="Nombre">
    </div>
  </div>

  <div class="form-group">
    <div class="col-lg-offset-2 col-lg-10">
    <input type="hidden" name="user_id" value="<?php 
echo $user->id;
?>
">
      <button type="submit" class="btn btn-success">Actualizar Categoria</button>
    </div>
  </div>
</form>
예제 #5
0
<?php

if (count($_SESSION["cart"]) == 1) {
    unset($_SESSION["cart"]);
} else {
    $products = $_SESSION["cart"];
    $news = array();
    foreach ($products as $product) {
        if ($product["product_id"] != $_GET["product_id"]) {
            array_push($news, $product);
        }
    }
    $_SESSION["cart"] = $news;
}
//print_r($products);
if ($_GET["href"] == "cart") {
    Core::redir("index.php?view=mycart");
} else {
    if ($_GET["href"] == "product") {
        $p = ProductData::getById($_GET["product_id"]);
        $cat = CategoryData::getById($p->category_id);
        Core::redir("index.php?view=productos&cat=" . $cat->short_name);
    }
}
예제 #6
0
 public function getCategory()
 {
     return $this->category_id != null ? CategoryData::getById($this->category_id) : null;
 }
예제 #7
0
 /**
  * 提交订单
  */
 public function goAction()
 {
     if (ComTool::isAjax()) {
         if (!$this->isLogin()) {
             ComTool::ajax(Cola::getConfig('_error.mustlogin'), '请先登录,即将跳转至登录页面');
         }
         $mobile = trim($this->post('mobile'));
         ComTool::checkEmpty($mobile, '请填写常用手机号');
         if (!ComTool::isMobile($mobile)) {
             ComTool::ajax(100001, '请填写正确的手机号');
         }
         $receiver = $this->post('receiver', '');
         ComTool::checkMaxLen($receiver, 16, "收货人姓名最多16位");
         $addrDesc = $this->post('addr_desc', '');
         ComTool::checkMaxLen($addrDesc, 32, "详细位置最多32位");
         $message = trim($this->post('message', ''));
         ComTool::checkMaxLen($message, 100, "留言最多100字");
         $curCategory = $this->post('cate', 0);
         $curCategory = intval(base64_decode($curCategory));
         if (!isset($_SESSION['cart'][$curCategory])) {
             ComTool::ajax(100001, '购物车为空');
         }
         $cart = $this->getCart($curCategory);
         if (!$cart) {
             ComTool::ajax(100001, '购物车为空');
         }
         $groupName = $this->post('group', '');
         if (!$groupName) {
             $category = CategoryData::getById($curCategory);
             $group = GroupData::getById($category['group_id']);
             $groupName = $group['name'];
         } else {
             $groupName = base64_decode($groupName);
         }
         $currUser = $this->getCurrentUser();
         $data = array();
         $orderId = ComTool::getOrderId();
         $data['id'] = $orderId;
         $data['user_id'] = $currUser['id'];
         $data['category_id'] = $curCategory;
         $data['user_name'] = $receiver;
         $data['user_tel'] = $mobile;
         $data['user_addr'] = "{$groupName} {$addrDesc}";
         $data['message'] = $message;
         $data['create_time'] = $data['update_time'] = time();
         $data['create_date'] = date("Y-m-d");
         $data['total_cost'] = $cart['totalPrice'];
         $data['status'] = '1';
         $res = OrderData::add($data);
         if ($res === false) {
             ComTool::ajax(100001, '服务器忙,请重试');
         }
         $sql = "insert into order_detail(order_id,good_id,good_name,amount,`price`,price_desc,`status`) values";
         foreach ($cart['products'] as $product) {
             $sql .= "('{$orderId}','{$product['id']}','{$product['name']}','{$product['quantity']}','{$product['price']}','{$product['price']}({$product['price_num']}{$product['price_unit']})','1'),";
         }
         $sql = trim($sql, ',');
         $res = OrderData::sql($sql);
         if ($res === false) {
             ComTool::ajax(100001, '服务器忙,请重试');
         }
         //TODO 清除此分类购物车的session
         ComTool::ajax(100000, 'ok');
     }
 }
예제 #8
0
<?php

$grade = CategoryData::getById($_GET["id"]);
$name = $grade->name;
$grade->del();
setcookie("gradedeleted", $name);
header("Location: index.php?view=categories");
예제 #9
0
<?php

$cat = CategoryData::getById($_POST["category_id"]);
$cat->name = $_POST["name"];
$cat->short_name = $_POST["short_name"];
if (isset($_POST["is_active"])) {
    $cat->is_active = 1;
} else {
    $cat->is_active = 0;
}
$cat->update();
Core::redir("index.php?view=categories");
예제 #10
0
<?php

$cat = CategoryData::getById($_GET["id"]);
$cat->active();
Core::redir("index.php?view=categories");
예제 #11
0
<?php

if (count($_POST) > 0) {
    $user = CategoryData::getById($_POST["user_id"]);
    $user->name = $_POST["name"];
    $user->update();
    print "<script>window.location='index.php?view=categories';</script>";
}