Ejemplo n.º 1
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Ban();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Ban'])) {
         $model->attributes = $_POST['Ban'];
         if ($model->save()) {
             $this->redirect(array('admin', 'status' => 0, 'id' => 0));
         }
     }
     $this->render('create', array('model' => $model));
 }
Ejemplo n.º 2
0
 public function addTags($tags)
 {
     $criteria = new CDbCriteria();
     $criteria->addInCondition('title', $tags);
     $this->updateCounters(array('frequency' => 1), $criteria);
     foreach ($tags as $name) {
         if (!$this->exists('title=:name', array(':name' => $name))) {
             $tag = new Ban();
             $tag->title = $name;
             $tag->frequency = 1;
             $tag->save();
         }
     }
 }
Ejemplo n.º 3
0
 public function actionCreate()
 {
     $model = new Ban();
     if (isset($_POST['Ban'])) {
         $model->setAttributes($_POST['Ban']);
         if ($model->save()) {
             if (Yii::app()->getRequest()->getIsAjaxRequest()) {
                 Yii::app()->end();
             } else {
                 $this->redirect(array('admin'));
             }
         }
     }
     $this->render('create', array('model' => $model));
 }
Ejemplo n.º 4
0
        BootstrapSkin::displayAlertBox("This target is already banned!", "alert-error", "", false, false);
        BootstrapSkin::displayInternalFooter();
        die;
    }
    $database = gGetDb();
    $ban = new Ban();
    $currentUsername = User::getCurrent()->getUsername();
    $database->transactionally(function () use($database, $ban, $duration, $currentUsername) {
        $ban->setDatabase($database);
        $ban->setActive(1);
        $ban->setType($_POST['type']);
        $ban->setTarget($_POST['target']);
        $ban->setUser($currentUsername);
        $ban->setReason($_POST['banreason']);
        $ban->setDuration($duration);
        $ban->save();
        Logger::banned($database, $ban, $_POST['banreason']);
    });
    $smarty->assign("ban", $ban);
    BootstrapSkin::displayAlertBox($smarty->fetch("bans/bancomplete.tpl"), "alert-info", "", false, false);
    Notification::banned($ban);
    BootstrapSkin::displayInternalFooter();
    die;
} elseif ($action == "unban") {
    global $smarty;
    if (!isset($_GET['id']) || $_GET['id'] == "") {
        BootstrapSkin::displayAlertBox("The ID parameter appears to be missing! This is probably a bug.", "alert-error", "Ahoy There! Something's not right...", true, false);
        BootstrapSkin::displayInternalFooter();
        die;
    }
    if (!User::getCurrent()->isAdmin() && !User::getCurrent()->isCheckuser()) {
Ejemplo n.º 5
0
 public function postDatHang()
 {
     $data = Input::all();
     $giohang = Session::get('giohang');
     $rules = array();
     //kiem tra hang ton kho
     $error = array();
     foreach ($giohang as $v) {
         $kho = DB::table('ton_kho')->where("id", '=', $v['id_sp'])->where("soluong", ">=", $v['quantity'])->count();
         if ($kho == 0) {
             $error[$v['id_sp']] = "Sản phẩm {$v['tensp']} đã hết hàng.";
         }
     }
     if (empty($error)) {
         foreach ($data as $key => $value) {
             if ($key != "id_hinhthuc" && $key != "ghichu") {
                 $rules[$key] = "required|numeric";
             }
         }
         $rules['id_hinhthuc'] = "required|numeric";
         $valdator = Validator::make($data, $rules);
         if (!$valdator->fails() && !empty($data)) {
             // dung thi them hoa don
             // lay tong gia
             $giavanchuyen = Vanchuyen::find(Input::get('id_hinhthuc'));
             $total = 0;
             foreach ($giohang as $sp) {
                 $total += $sp['gia'] * $sp['quantity'];
             }
             $total += $giavanchuyen->gia;
             date_default_timezone_set("Asia/Bangkok");
             $date = new DateTime();
             $donhang = new Donhang();
             $donhang->ngaymua = $date;
             $donhang->noigiaohang = Session::get('diachi');
             $donhang->ghichu = Input::get('ghichu');
             $donhang->id_hinhthuc = Input::get('id_hinhthuc');
             $donhang->tonggia = $total;
             $donhang->id_user = Session::get('id_taikhoan');
             $donhang->save();
             //them chi tiet don hang
             foreach ($giohang as $v) {
                 $sp = new Ban();
                 $sp->id_sp = $v['id_sp'];
                 $sp->id_dh = $donhang->id;
                 $sp->soluong = $v['quantity'];
                 $sp->gia = $v['gia'];
                 $sp->save();
             }
             Session::forget('giohang');
             return Redirect::to("/")->with("successcart", "Đặt hàng thành công");
         } else {
             return Redirect::to("/")->with("errorcart", "Đặt hàng thất bại. Xin bạn vui lòng thử lại sau");
         }
     } else {
         //khi trong kho khong co hàng
         return Redirect::to("users/xem-giohang")->with("error", $error);
         // print_r($error);
     }
 }