Esempio n. 1
0
 public function add($id)
 {
     //add the item to the transaction log
     $userid = Auth::id();
     $purchasedItem = Item::where('user', $userid)->findOrFail($id);
     //get max transaction id
     $maxTransactionId = Transaction::where('user_id', '=', $userid)->max('transaction_id');
     //check if open
     $maxTransactionIdStatus = Transaction::where('user_id', $userid)->where('transaction_id', $maxTransactionId)->first()->status;
     if ($maxTransactionIdStatus == 'open') {
         //check if item already in list
         $currentTransaction = Transaction::where('user_id', '=', $userid)->where('transaction_id', '=', $maxTransactionId)->where('sku', '=', $purchasedItem->sku)->first();
         if ($currentTransaction) {
             $updateQuantity = $currentTransaction->quantity;
             $updateQuantity++;
             $currentTransaction->update(array('quantity' => $updateQuantity));
         } else {
             Transaction::create(array('transaction_id' => $maxTransactionId, 'user_id' => $userid, 'item_name' => $purchasedItem->item_name, 'price' => $purchasedItem->price, 'quantity' => 1, 'sku' => $purchasedItem->sku, 'status' => 'open'));
         }
     } else {
         if ($maxTransactionIdStatus = 'closed') {
             $newTransactionId = $maxTransactionId + 1;
             Transaction::create(array('transaction_id' => $newTransactionId, 'user_id' => $userid, 'item_name' => $purchasedItem->item_name, 'price' => $purchasedItem->price, 'quantity' => 1, 'sku' => $purchasedItem->sku, 'status' => 'open'));
         }
     }
     //reduce inventory
     $inventoryItemQuantity = $purchasedItem->quantity;
     $inventoryItemQuantity--;
     $purchasedItem->update(array('quantity' => $inventoryItemQuantity));
     return redirect('home');
 }
 /**
  * agreed to buy
  * @param  Request
  * @return [type]
  */
 public function postBuy(Request $request)
 {
     //MENU
     $mainMenu = Category::getParentMenu();
     $allMenu = Category::getAllMenu($mainMenu);
     //HOT PRODUCTS.
     $hotProduct = Product::hotProduct();
     //DISCOUNT PRODUCTS.
     $discountProduct = Product::discountProduct();
     if (\Session::has('giohang')) {
         $data = \Session::get('giohang');
         if ($request->get('account_number') != null) {
             $account_number = $request->get('account_number');
         } else {
             $account_number = null;
         }
         $transaction = ['customer_id' => \Auth::id(), 'ship_id' => \Session::get('ship'), 'pay_id' => \Session::get('pay'), 'amount' => \Session::get('total'), 'message' => $request->get('message'), 'security' => time(), 'account_number' => $request->get('account_number')];
         //dd($transaction);
         $transactions = Transaction::create($transaction);
         //dd($transactions->toArray());
         foreach ($data as $key => $value) {
             $order = ['transaction_id' => $transactions->id, 'product_id' => $value['id'], 'qty' => $value['qty'], 'price_order' => $value['price'], 'discount_order' => $value['discount']];
             $orders = Order::create($order);
         }
         $this->getCancel();
         return view('fornindex.shopping_succeed', compact('allMenu', 'hotProduct', 'discountProduct'));
     }
 }
Esempio n. 3
0
 public function testRemoveInUseTag()
 {
     $tags = $this->createTags();
     $t = Transaction::create(['date' => '01/01/2016', 'name' => 'Rent', 'value' => 625]);
     $tags[0]->transactions()->save($t);
     $this->visitTagsPage()->press('Delete')->seePageIsTags()->seeInElement('ul.tags li', $tags[0]->name)->seeInElement('.alert-danger', 'Tag cannot be removed while in use');
 }
 public function saveTransaction(SaveTransactionPostRequest $request)
 {
     DB::transaction(function () use($request) {
         $transaction = Transaction::create(['transactionDate' => Carbon::parse($request->input('transactionDate'))->toDateString(), 'amount' => $request->input('amount'), 'transaction_type_id' => $request->input('transaction_type_id'), 'investor_id' => $request->input('id'), 'notes' => $request->input('notes') === '' ? null : $request->input('notes')]);
         $investor = Investor::find($request->input('id'));
         $investor->balance = $this->computeBalance($investor->id);
         $investor->save();
         return response()->json(['status' => 'success']);
     });
 }
 /**
  *
  * 	Description: Save Transaction
  *	Component: AddTransactionFormModal
  *
  */
 public function saveTransaction(SaveTransactionPostRequest $request)
 {
     $account = Account::find($request->input('id'));
     $transactionType = TransactionType::where('code', $request->input('transactionType'))->first();
     if ($transactionType->account_type === 'DR') {
         $this->validate($request, ['amount' => 'max:' . $account->balance]);
     }
     $transaction = Transaction::create(['transactionDate' => Carbon::parse($request->input('transactionDate'))->toDateString(), 'amount' => $request->input('amount'), 'transaction_type_id' => $transactionType->id, 'account_id' => $request->input('id'), 'notes' => $request->input('notes') === '' ? null : $request->input('notes')]);
     $account->balance = $this->recomputeRunningBalance($account->id);
     $account->save();
     return response()->json(['message' => 'New Transaction Posted.']);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     //Status
     if ($request->get('status') == false) {
         $status = 0;
     } else {
         $status = 1;
     }
     $data = ['customer_id' => $request->get('customer_id'), 'pay_id' => $request->get('pay_id'), 'ship_id' => $request->get('ship_id'), 'account_number' => $request->get('account_number'), 'message' => $request->get('message'), 'security' => time(), 'status' => $status];
     Transaction::create($data);
     return redirect()->route('transaction.index');
     //dd($data);
 }
Esempio n. 7
0
 public function placeOrder($request)
 {
     $shoppingCart = $request->session()->get('cart');
     $shoppingCartItems = $request->session()->get('items');
     $user = Auth::user();
     $code = $request->input('coupon');
     $coupon = Coupon::ofCode($code);
     $transaction = Transaction::create(array('id' => md5(uniqid()), 'coupon' => is_object($coupon) ? $coupon->id : '', 'user_id' => $user->id, 'order_data' => json_encode($shoppingCartItems), 'real_charges' => $request->input('realCharges'), 'amount_off' => $request->input('amountOff')));
     ShoppingCartItem::where('shopping_cart_id', $shoppingCart->id)->delete();
     if (is_object($coupon)) {
         Coupon::where('id', $coupon->id)->update(['times_redeemed' => $coupon->times_redeemed + 1]);
     }
     $request->session()->forget('items');
     $request->session()->put('itemsCtr', 0);
 }
Esempio n. 8
0
 /**
  * заполнение таблицы пранзакций
  */
 private function transactionsTable()
 {
     Transaction::truncate();
     $u = User::count();
     $c = Card::count();
     $i = 0;
     while ($i < 10) {
         ++$i;
         Transaction::create(['user_id' => rand(1, $u), 'card_id' => rand(1, $c), 'money' => rand(0, 1000)]);
     }
     $crd = Card::all();
     foreach ($crd as $v) {
         $v->balance = Transaction::where('card_id', $v->id)->sum('money');
         $v->save();
     }
 }
 public function store(PeminjamanRequest $request)
 {
     $input = $request->all();
     $book_id = $input['book_id'];
     $student_id = $input['student_id'];
     $input['borrowed_at'] = time();
     $transaction = Transaction::create($input);
     $book = Book::findOrFail($book_id);
     $stock = $book['stock'] - 1;
     $book->update(['stock' => $stock]);
     $student = Student::findOrFail($student_id);
     $borrow = $student['borrow'] + 1;
     $student->update(['borrow' => $borrow]);
     session()->flash('flash_message', 'You have been added 1 transaction!');
     return redirect()->route('peminjaman.laporan');
 }
Esempio n. 10
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     //
     $this->validate($request, ['transaction_id' => 'required|unique:transactions', 'type' => 'required', 'client' => 'required', 'password' => 'required', 'date_submitted' => 'required']);
     //$input = $request->all();
     //$transaction->fill($input)->save();
     //$transaction->save();
     $user = Auth::user();
     $date = new DateTime($request['date_submitted']);
     Transaction::create(['transaction_id' => $request['transaction_id'], 'type' => $request['type'], 'client' => $request['client'], 'password' => $request['password'], 'status' => 'New', 'date_submitted' => $date]);
     $date = new DateTime();
     Log::create(['transaction_id' => $request['transaction_id'], 'processor_name' => $user->firstname . ' ' . $user->lastname, 'status' => 'New', 'remarks' => $request['remarks'], 'date_received' => $date, 'date_released' => '', 'next_processor' => '-']);
     if ($user->user_type = "Processor") {
         return redirect('processor/process_transactions')->withMessage('success create');
     } else {
         return redirect('superadmin/process_transactions')->withMessage('success create');
     }
 }
Esempio n. 11
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!');
     }
 }
 public function create(Request $request)
 {
     $order = $request->input('order');
     $transaction = Transaction::create(['status' => 'unpaid', 'order_id' => array_get($order, 'id'), 'price_incl' => array_get($order, 'price_incl'), 'price_excl' => array_get($order, 'price_excl'), 'redirect_url' => Input::get('redirect_url')]);
     return response()->json(['payment_url' => url('pay/' . $transaction->id)]);
 }
 public function postCheckoutbaru(Requests\CheckoutPaymentRequest $request)
 {
     $input = Session::get('values');
     $customer = Customer::create($input);
     $tos = Cart::tos();
     $total = Cart::total();
     $od = array('order_date' => Carbon::now('Asia/Kuala_Lumpur'), 'total_tax' => $tos, 'total_purchase' => $total, 'order_status' => 0, 'customer_id' => $customer->id);
     $order = Order::create($od);
     $pp = array('order_id' => $order->id, 'time' => Input::get('time'), 'date' => Input::get('date'), 'ref_no' => Input::get('ref_no'), 'amount' => Input::get('amount'), 'pref_bank' => Input::get('pref_bank'), 'method' => Input::get('method'));
     $ppr = PaymentProof::create($pp);
     $formid = str_random();
     $cart_content = Cart::content();
     foreach ($cart_content as $cart) {
         $tr = array('product_id' => $cart->id, 'form_id' => $formid, 'qty' => $cart->qty, 'total_price' => $cart->subtotal, 'order_id' => $order->id, 'gambar_id' => $cart->options->img_id, 'color' => $cart->options->color, 'size' => $cart->options->size, 'category_id' => $cart->options->cat, 'month' => Carbon::now('Asia/Kuala_Lumpur'));
         Transaction::create($tr);
     }
     $data = array('name' => $customer->name, 'email' => $customer->email, 'no_tel' => $customer->no_tel, 'date' => Carbon::now('Asia/Kuala_Lumpur'));
     Mail::send('emails.invoice', $data, function ($message) {
         $input = Session::get('values');
         $message->from('*****@*****.**', 'Sales');
         $message->to($input['email'], $input['name'])->subject('Your Order Has Been Received');
     });
     Session::forget('values');
     Cart::destroy();
     return redirect('store/thankyou/');
 }
 protected function createTransaction(array $data)
 {
     return Transaction::create($data);
 }
Esempio n. 15
0
 /**
  * User is returned successfully from Paypal after paying their fees. 
  */
 public function postPaypalComplete(Request $request, $event_id)
 {
     //Complete the transaction
     $complete = $this->gateway->completePurchase(array('transactionReference' => $request->paymentId, 'payerId' => $request->PayerID));
     $response = $complete->send();
     $data = $response->getData();
     //dd($data);
     //payment approved
     $user = Auth::user();
     $event = Event::findOrFail($event_id);
     if ($data['state'] === 'approved') {
         $transaction = array('event_id' => $event_id, 'user_id' => $user->id, 'transaction_type' => 'competitor_payment', 'paypal_sale_id' => $data['transactions'][0]['related_resources'][0]['sale']['id'], 'payment_method' => $data['payer']['payment_method'], 'status' => $data['state'], 'total' => $data['transactions'][0]['amount']['total'], 'currency' => $data['transactions'][0]['amount']['currency'], 'transaction_fee' => $data['transactions'][0]['related_resources'][0]['sale']['transaction_fee']['value']);
         $savedTransaction = Transaction::create($transaction);
         //Change all the entries to paid
         $entries = $user->eventEntries($event_id);
         foreach ($entries as $entry) {
             $entry->paymentStatus = 'paid';
             $entry->transaction_id = $savedTransaction->id;
             $entry->save();
         }
         \Flash::success('Thank you, your payment was successful and your current entries below.');
         return redirect(action('PagesController@userEntries'));
     } elseif ($data['state'] === 'failed') {
         //Delete the user entry and leave message
         $entries_to_delete = $user->eventEntries($event_id);
         foreach ($entries_to_delete as $entry) {
             $entry->delete();
         }
         \Flash::error('Unfortunately your payment failed. Your entry to this event has *not* been completed. If you still want to proceed, please enter again.');
         return redirect(action('EventsController@show', $event->slug));
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker\Factory::create();
     for ($i = 0; $i < 10; ++$i) {
         Transaction::create(['customer_id' => $faker->numberBetween($min = 1, $max = 10), 'ship_id' => $faker->numberBetween($min = 1, $max = 10), 'pay_id' => $faker->numberBetween($min = 1, $max = 10), 'status' => $faker->numberBetween($min = 0, $max = 1), 'amount' => $faker->randomFloat($nbMaxDecimals = NULL, $min = 0, $max = NULL), 'message' => $faker->text($maxNbChars = 200), 'security' => $faker->postcode]);
     }
 }