Ejemplo n.º 1
0
 public function getDashboard()
 {
     $reports = new Report();
     $totalProducts = $reports->getTotalProducts();
     $totalImports = $reports->getTotalImports();
     $totalSales = $reports->getTotalSalesToday();
     $totalPurchase = $reports->getTotalPurchaseToday();
     $accountsBalance = $reports->getAccountBalances();
     $accountBalanceTransfers = $reports->getBalanceTransferFullReport();
     $stocksBranch = $reports->getStocksBranch();
     $stockRequisitions = StockRequisition::orderBy('id', 'desc')->take(3)->get();
     $latestTransactions = Transaction::orderBy('id', 'desc')->take(5)->get();
     $register = Transaction::where('payment_method', '=', 'check')->where('type', '=', 'Receive')->where('cheque_status', '=', 0)->orderBy('id', 'desc')->get();
     $purchaseregister = Transaction::where('payment_method', '=', 'check')->where('type', '=', 'Payment')->where('cheque_status', '=', 0)->orwhere('type', '=', 'Expense')->where('cheque_status', '=', 0)->orderBy('id', 'desc')->get();
     //var_dump($stockRequisitions);
     return view('Users.dashboard')->with('latestTransactions', $latestTransactions)->with('totalProducts', $totalProducts)->with('totalSales', $totalSales)->with('stockRequisitions', $stockRequisitions)->with('stocksBranch', $stocksBranch)->with('accountsBalance', $accountsBalance)->with('accountBalanceTransfers', $accountBalanceTransfers)->with('totalPurchase', $totalPurchase)->with('totalImports', $totalImports)->with('register', $register)->with('purchaseregister', $purchaseregister);
 }
Ejemplo n.º 2
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request, Transaction $transactions)
 {
     // Setup query
     $query = $transactions->orderBy('timestamp', 'ASC')->with('category', 'vendor');
     $activeFilters = [];
     // Account filter
     if ($accountFilter = $request->input('account')) {
         $query->whereHas('account', function ($q) use($accountFilter) {
             $q->where('slug', '=', $accountFilter);
         });
         $activeFilters['account'] = ['name' => Account::where('slug', '=', $accountFilter)->first()->name, 'removedUri' => http_build_query($request->except('account'))];
     }
     // Vendor filter
     if ($vendorFilter = $request->input('vendor')) {
         $query->whereHas('vendor', function ($q) use($vendorFilter) {
             $q->where('slug', '=', $vendorFilter);
         });
         $activeFilters['vendor'] = ['name' => Vendor::where('slug', '=', $vendorFilter)->first()->name, 'removedUri' => http_build_query($request->except('vendor'))];
     }
     // Category filter
     if ($categoryFilter = $request->input('category')) {
         $query->whereHas('category', function ($q) use($categoryFilter) {
             $q->where('slug', '=', $categoryFilter);
         });
         $activeFilters['category'] = ['name' => Category::where('slug', '=', $categoryFilter)->first()->name, 'removedUri' => http_build_query($request->except('category'))];
     }
     // Business filter
     if (($businessFilter = $request->input('business')) === "") {
         $query->where('business_expense', '=', '1');
         $activeFilters['business expense'] = ['name' => '', 'removedUri' => http_build_query($request->except('business'))];
     }
     // Charity filter
     if (($charityFilter = $request->input('charity')) === "") {
         $query->where('charitable_deduction', '=', '1');
         $activeFilters['charitable deduction'] = ['name' => '', 'removedUri' => http_build_query($request->except('charity'))];
     }
     // Execute query
     $this->transactions = $query->get();
     $this->calculateRowBalances();
     $rows = $this->transactions->reverse();
     return view('transactions.index', ['rows' => $rows, 'balance' => money_format('%(!i', @$rows[0]->balance), 'filters' => $activeFilters])->withInput($request->all());
 }
Ejemplo n.º 3
0
 public function __construct()
 {
     View::share('pros', Product::take(8)->Where('status', 1)->orderBy('created_at', 'DESC')->get());
     View::share('customs', Product::take(8)->Where('type', 0)->orderBy('created_at', 'DESC')->get());
     View::share('products', Product::take(8)->Where('status', 1)->orderBy('created_at', 'DESC')->get());
     View::share('cus', Product::take(8)->Where('status', 1)->orderBy('created_at', 'ASC')->get());
     View::share('categories', Category::all());
     View::share('cart_content', Cart::content());
     View::share('count', Cart::count());
     View::share('total', Cart::total());
     View::share('set', Setting::find(1));
     View::share('tos', Cart::tos());
     View::share('transactions', Transaction::orderBy('created_at', 'desc')->paginate(10));
     View::share('settings', Setting::find(1));
     View::share('caty', Category::take(5)->orderBy('created_at', 'DESC')->get());
     View::share('payments', Payment::Where('status', 1)->get());
     View::share('customers', Customer::all());
     View::share('orders', Order::all());
     View::share('cat', Category::all());
     View::share('db', Product::take(6)->Where('status', 1)->orderBy('created_at', 'ASC')->get());
 }
Ejemplo n.º 4
0
 public function getIndex()
 {
     $now = Carbon::now('Asia/Kuala_Lumpur');
     $monthStart = $now->startOfMonth();
     $monthEnd = $now->endOfMonth();
     $tempahan = Order::orderBy('created_at', $monthStart);
     // where('created_at', '>=', Carbon::now()->startOfMonth())->get()
     $kato = Category::whereHas('transaction', function ($query) {
         $query->where('qty', '>', 0);
         $query->where('created_at', '>=', Carbon::now('Asia/Kuala_Lumpur')->startOfYear());
     })->get();
     $katoo = Category::whereHas('transaction', function ($query) {
         $query->where('qty', '>', 0);
         $query->where('created_at', '>=', Carbon::now('Asia/Kuala_Lumpur')->startOfMonth());
     })->get();
     $overall = Transaction::select('id', 'created_at', 'month', DB::raw('sum(qty) as total'))->groupBy(DB::raw('MONTH(month)'))->orderBy('created_at', 'asc')->where('created_at', '>=', Carbon::now('Asia/Kuala_Lumpur')->startOfYear())->get();
     $testo = Transaction::select('id', 'month')->groupBy(DB::raw('MONTH(month)'))->orderBy('month', 'asc');
     $tahun = Carbon::now('Asia/Kuala_Lumpur')->startOfYear();
     $tran = Transaction::all();
     $tops = Transaction::orderBy('qty', 'desc')->groupBy('product_id')->limit(5)->where('created_at', '>=', Carbon::now('Asia/Kuala_Lumpur')->startOfWeek())->get();
     return view('a.index', compact('kato', 'katoo', 'tops', 'overall', 'tahun', 'testo'))->with('tempahan', $tempahan)->with('trans', $tran)->with('args', Order::all())->with('ris', Order::sum('total_purchase'))->with('name', $kato->lists('name'))->with('namo', $katoo->lists('name'));
 }
Ejemplo n.º 5
0
 public function store(Request $request)
 {
     try {
         $counter = $request->input('counter');
         $transactionDate = $request->input('date');
         Transaction::create($request->all());
         $data = Transaction::orderBy('created_at', 'desc')->first();
         ItemOut::create(['date' => $transactionDate, 'description' => 'kode transaksi ' . $data->id]);
         $dataOut = ItemOut::orderBy('created_at', 'desc')->first();
         $total = 0;
         for ($i = 0; $i < $counter; $i++) {
             echo "counter: " . $counter . "/";
             $qty = $request->input('qty' . strval($i));
             $priceId = $request->input('price_id' . strval($i));
             $subtotal = $request->input('subtotal' . strval($i));
             $total = $total + $subtotal;
             $price = Price::where('id', '=', $priceId)->first();
             $isItemAvailable = Item::where('id', '=', $price->item_id)->first();
             if (is_null($isItemAvailable)) {
                 Transaction::destroy($data->id);
                 return redirect('transaction')->with('message', 'Data dengan kode barang: ' . $price->item_id . ', tidak ada');
             } else {
                 DetailTransaction::create(['qty' => $qty, 'price_id' => $priceId, 'transaction_id' => $data->id, 'subtotal' => $subtotal]);
                 DetailItemOut::create(['qty' => $qty, 'item_id' => $price->item_id, 'item_out_id' => $dataOut->id]);
                 Item::decreaseStock($price->item_id, $qty);
             }
         }
         $updateTransaction = Transaction::where('id', '=', $data->id)->first();
         $updateTransaction->total_price = $total;
         $updateTransaction->save();
         return redirect('transaction')->with('message', 'Data berhasil dibuat!');
     } catch (\Illuminate\Database\QueryException $e) {
         return redirect('transaction')->with('message', 'Data dengan transaksi tersebut sudah digunakan!');
     } catch (\PDOException $e) {
         return redirect('transaction')->with('message', 'Data dengan transaksi tersebut sudah digunakan!');
     }
 }
Ejemplo n.º 6
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $transactions = Transaction::orderBy('id', 'desc')->paginate(10);
     return view('transactions.index', compact('transactions'));
 }
Ejemplo n.º 7
0
 /**
  * [getTransaction description]
  * @return [type] [description]
  */
 protected function getTransaction()
 {
     return Transaction::orderBy('status', 'asc')->paginate(5);
 }
Ejemplo n.º 8
0
 public function transactions()
 {
     $subtitle = "Showing All Transactions";
     $transactions = Transaction::orderBy('created_at', 'desc')->get();
     return view('transactions.admin', compact('transactions', 'subtitle'));
 }