Exemplo n.º 1
0
 public static function addData($hd, $tenbang, $id, $ten_thanhphan, $input = null)
 {
     date_default_timezone_set("Asia/Bangkok");
     $date = new DateTime();
     if ($input == null) {
         $f = new Logfileadmin();
         $f->hoatdong = $hd;
         $f->tenbang = $tenbang;
         $f->id_thanhphan = $id;
         $f->ten_thanhphan = $ten_thanhphan;
         $f->datetime = $date->format("Y-m-d H:i:s");
         $f->save();
     } else {
         $thongtincu = "";
         $datas = $input[0];
         foreach ($datas as $key => $value) {
             if ($key != "created_at" and $key != "updated_at") {
                 $thongtincu .= "{$key}:{$value} \n";
             }
         }
         $f = new Logfileadmin();
         $f->hoatdong = $hd;
         $f->tenbang = $tenbang;
         $f->id_thanhphan = $id;
         $f->ten_thanhphan = $ten_thanhphan;
         $f->thongtin_cu = $thongtincu;
         $f->datetime = $date->format("Y-m-d H:i:s");
         $f->save();
     }
 }
Exemplo n.º 2
0
 public function getXoaGia($id_gia, $id_sanpham)
 {
     $model = Gia::find($id_gia);
     Logfileadmin::addData("Xóa", "Giá", $id_gia, "ID Sản Phẩm: {$id_sanpham}\n Giá:{$model->gia}");
     Gia::where('id', '=', $id_gia)->where('id_sanpham', '=', $id_sanpham)->delete();
     return Redirect::to('gia/xem-gia')->with('success', 'Xóa thành công');
 }
Exemplo n.º 3
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $sanpham = Sanpham::where('id_loai', '=', $id)->count();
     if ($sanpham > 0) {
         return Redirect::to('loais')->with('errorDelete', "Thất bại.Loại này đang tồn tại sản phẩm");
     }
     $model = $this->loai->find($id);
     Logfileadmin::addData("Xóa", "Loại", $model->id, $model->tenloai);
     $this->loai->find($id)->delete();
     return Redirect::route('loais.index');
 }
 public function postSuaSanpham($id)
 {
     $input = Input::all();
     $validation = Validator::make($input, Sanpham::$rulesUpdate);
     if ($validation->passes()) {
         $image = Input::file('hinhanh');
         if (!is_null($image)) {
             // nếu có thay doi hinh anh
             $imageName = $image->getClientOriginalName();
             $nameArray = explode('.', $imageName);
             $imageType = end($nameArray);
             $imageRules = array("jpg", "jpeg", "png");
             if (in_array($imageType, $imageRules)) {
                 //neu dung thi tien hanh insert vao csdl
                 $imageNewName = uniqid(rand(), true);
                 $imageNewName = md5($imageNewName);
                 $imageNewName = substr($imageNewName, 0, 6);
                 $imageNewName .= "." . $imageType;
                 Input::file('hinhanh')->move('uploads', $imageNewName);
                 // upload hinh anh
                 //sau khi upload thi insert vao csdl
                 $sp = Sanpham::find($id);
                 $sp->tensp = Input::get('tensp');
                 $sp->donvitinh = Input::get('donvitinh');
                 $sp->hinhanh = $imageNewName;
                 $sp->chitietsp = Input::get('chitietsp');
                 $sp->khuyenmai = Input::get('khuyenmai');
                 $sp->id_loai = Input::get('id_loai');
                 //luu logfile
                 $info = Sanpham::where('id', '=', $id)->get()->toArray();
                 Logfileadmin::addData("Sửa", "Sản Phẩm", $sp->id, $sp->tensp, $info);
                 //hoan tat update
                 $sp->save();
                 return Redirect::to("sanpham/chitiet-sanpham/{$sp->id}");
             } else {
                 return Redirect::to("sanpham/sua-sanpham/{$id}")->with('errorImage', "Không đúng định dạng hình ảnh");
             }
         } else {
             //nếu không thay doi hinh anh
             $sp = Sanpham::find($id);
             $sp->tensp = Input::get('tensp');
             $sp->donvitinh = Input::get('donvitinh');
             $sp->chitietsp = Input::get('chitietsp');
             $sp->khuyenmai = Input::get('khuyenmai');
             $sp->id_loai = Input::get('id_loai');
             //luu logfile
             $info = Sanpham::where('id', '=', $id)->get()->toArray();
             Logfileadmin::addData("Sửa", "Sản Phẩm", $sp->id, $sp->tensp, $info);
             //hoan tat update
             $sp->save();
             return Redirect::to("sanpham/chitiet-sanpham/{$sp->id}");
         }
     } else {
         return Redirect::to("sanpham/sua-sanpham/{$id}")->withInput()->withErrors($validation)->with('message', 'There were validation errors.');
     }
 }
Exemplo n.º 5
0
 public function getXoaHoadon($id)
 {
     Logfileadmin::addData("Xóa", "Hóa đơn nhập", $id, "Hóa đơn nhập");
     $ctns = Chitietnhap::where('id_phieunhap', '=', $id)->get();
     foreach ($ctns as $ctn) {
         $value = "";
         $value = "ID Hóa Đơn Nhập:{$ctn->id_phieunhap}\n" . "ID Sản phẩm:{$ctn->id_sanpham}\n" . "Đơn Giá:{$ctn->dongia}\n" . "Số Lượng:{$ctn->soluong}";
         Logfileadmin::addData("Xóa", "Chi tiết hóa đơn nhập", $ctn->id, $value);
     }
     Chitietnhap::where('id_phieunhap', '=', $id)->delete();
     Phieunhap::where('id', '=', $id)->delete();
     return Redirect::to('nhap/xem-hoadon');
 }
Exemplo n.º 6
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $model = $this->hang->find($id);
     Logfileadmin::addData("Xóa", "Hãng", $model->id, $model->tenhang);
     $this->hang->find($id)->delete();
     return Redirect::route('hangs.index');
 }
Exemplo n.º 7
0
|
*/
//***************************ADMIN**********************************
Route::filter("checkUser", function () {
    if (Session::get('quyen') != 1) {
        return Redirect::to("/");
    }
});
Route::group(array("prefix" => "admin", "before" => "checkUser"), function () {
    Route::get("/", function () {
        $logs = Logfileadmin::orderBy("created_at", "desc")->paginate(15);
        $tonkho = DB::table("ton_kho")->where("soluong", "<=", 0)->paginate(15);
        return View::make('admin.home')->with('logs', $logs)->with("tonkho", $tonkho);
    });
    Route::get("logfile", function () {
        $logs = Logfileadmin::orderBy("created_at", "desc")->paginate(15);
        return View::make('logfile.logfile')->with('logs', $logs);
    });
});
Route::group(array("before" => "checkUser"), function () {
    Route::controller('dat_hang', 'DondathangController');
    Route::controller('nhap', 'NhapController');
    Route::controller('sanpham', 'SanphamController');
    Route::controller('gia', 'GiaController');
    Route::resource('hangs', 'HangsController');
    Route::resource('chung_loais', 'Chung_loaisController');
    Route::resource('nguoi_dungs', 'Nguoi_dungsController');
    Route::resource('loais', 'LoaisController');
    Route::resource('trangthais', 'TrangthaisController');
    Route::resource('vanchuyens', 'VanchuyensController');
});
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $model = $this->nguoi_dung->find($id);
     Logfileadmin::addData("Xóa", "Thành Viên", $model->id, "Tên: " . $model->tennd . "\n Tài khoản:" . $model->taikhoan);
     $this->nguoi_dung->find($id)->delete();
     return Redirect::route('nguoi_dungs.index');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $model = $this->chung_loai->find($id);
     Logfileadmin::addData("Xóa", "Chủng Loại", $model->id, $model->tenchungloai);
     $this->chung_loai->find($id)->delete();
     return Redirect::route('chung_loais.index');
 }