Esempio n. 1
0
 public function checkInventory($item, $size)
 {
     $checkInventory = \App\Inventory::where('product_id', $item)->pluck($size) - $this->cartInventory($item, $size);
     if ($checkInventory > 0) {
         return 1;
     }
 }
Esempio n. 2
0
 public function dispense($ic, $name)
 {
     $getID = Patient::where('pt_ic', $ic)->first();
     //whole row
     $deID = $getID->id;
     //get the id from the ic
     $getcaseID = Record::where('pt_id', $deID)->first();
     $caseID = $getcaseID->id;
     $disData = Dispensary::where('case_ref', $caseID)->first();
     //xpe pakai first() sbb setiap case unik, case lain xpakai id ni
     $arrQty = explode("#", $disData->dispensed_quantity);
     $arrDrug = explode("#", $disData->dispensed_drug_code);
     //need declare $prices array x?
     $prices = array();
     for ($x = 0; $x < count($arrDrug) - 1; $x++) {
         //get price of each drug into an array
         $hehe = Inventory::where('drug_name', $arrDrug[$x])->first();
         $prices[$x] = $hehe->spu;
     }
     // $arrOne = count($arrDrug);
     // arr1 = druglist , arr2= respective qty of drug, arr3= respective price of drug
     $panel = Panel::all();
     return view('staff.dispensary')->with('name', $name)->with('arr2', $arrQty)->with('arr1', $arrDrug)->with('arr3', $prices)->with('panel', $panel)->with('ptid', $deID);
 }
Esempio n. 3
0
 public function deleteItem($conferenceId, $itemId)
 {
     $item = Inventory::where('conferenceID', $conferenceId)->where('id', $itemId);
     if ($item->delete()) {
         return response()->json(['message' => 'item_deleted'], 200);
     } else {
         return response()->json(['message' => 'item_could_not_be_deleted'], 500);
     }
 }
Esempio n. 4
0
 private function modifyQuantity(Request $request, $modifier)
 {
     $inventory = new Inventory();
     $item = $inventory->where("product_id", "=", $request->product_id)->first();
     $item->quantity = $item->quantity + $modifier;
     if ($item->quantity < 0) {
         $item->quantity = 0;
         return false;
     }
     $item->save();
     return json_encode($item);
 }
 /**
  * A movie can be returned to any Kiosk so update kiosk and make movie available
  *
  * @param $id
  * @param $kiosk
  */
 private function markReturned($id, $kiosk)
 {
     Inventory::where('id', $id)->update(['isRented' => 0, 'kiosk_id' => $kiosk]);
 }
 public function completePayment(Request $request, SlackHandler $slacker)
 {
     // Set your secret key: remember to change this to your live secret key in production
     // See your keys here https://dashboard.stripe.com/account/apikeys
     Stripe::setApiKey(env('STRIPE_SK'));
     // Get the credit card details submitted by the form
     $token = $request->input('stripeToken');
     // dd(\Session::get('cart_id'));
     if (!\Session::get('cart_id')) {
         return redirect()->route('alreadyPaid');
     }
     if (\App\Shipping::where('cart_id', \Session::get('cart_id'))->pluck('payment_status') == 'Paid') {
         return redirect()->route('alreadyPaid');
     }
     // $charge = 0;
     // $cart->checkoutPrice()
     // Create the charge on Stripe's servers - this will charge the user's card
     try {
         $charge = Charge::create(array("amount" => round($this->getCheckoutPrice()), "currency" => "usd", "source" => $token, "description" => \Session::get('cart_id')));
     } catch (\Stripe\Error\Card $e) {
         // The card has been declined
     }
     $cart_id = \Session::get('cart_id');
     $markPaid = \App\Shipping::where('cart_id', \Session::get('cart_id'))->first();
     $markPaid->payment_status = 'Paid';
     $markPaid->shipped_status = 'Not Shipped';
     $markPaid->save();
     $slacker->sendSaleMessage();
     \App\Sale::create(array('customer_id' => $markPaid->email, 'cart_id' => \Session::get('cart_id')));
     $purge = [];
     foreach (\App\Cart::where('customer_id', $cart_id)->get() as $purgeCarts) {
         $purge[] = $purgeCarts;
         $inventory = \App\Inventory::where('product_id', $purgeCarts->product_id)->pluck($purgeCarts->size);
         $newsize = $inventory - $purgeCarts->quantity;
         \DB::table('inventories')->where('product_id', $purgeCarts->product_id)->update(array($purgeCarts->size => $newsize));
     }
     if (env('APP_ENV') == 'local') {
         \Mail::send('emails.productshipped', array('cart' => \App\Cart::where('customer_id', $cart_id)->get(), 'customer' => \App\Shipping::where('cart_id', $cart_id)->first()), function ($message) {
             $message->to(\App\Shipping::where('cart_id', \Session::get('cart_id'))->pluck('email'))->subject("Your Eternally Nocturnal Order");
         });
     } else {
         \Mail::send('emails.productshipped', array('cart' => \App\Cart::where('customer_id', $cart_id)->get(), 'customer' => \App\Shipping::where('cart_id', $cart_id)->first()), function ($message) {
             $message->to(\App\Shipping::where('cart_id', \Session::get('cart_id'))->pluck('email'))->subject("Your Eternally Nocturnal Order");
         });
     }
     \Session::forget('cart_id');
     \Session::forget('checkoutAmt');
     return redirect()->route('transSuccess');
 }