/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update(Request $request) { $product = products::whereid($request->get('id'))->first(); $product->fill($request->all()); if ($product->save()) { return Redirect::back()->withFlash_message(['msg' => ' Product successfully edited', 'type' => 'success']); } return Redirect::back()->withFlash_message(['msg' => ' Edit Failed', 'type' => 'warning']); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $products = products::all(); $materials = materials::all(); $replenishments = materialreplenishment::join('products', 'products.id', '=', 'materialreplenishment.product_id_fk')->join('materials', 'materials.id', '=', 'materialreplenishment.material_id_fk')->get(array('materialreplenishment.id', 'products.name as productname', 'materials.name as materialname', 'materialreplenishment.material_count', 'materialreplenishment.material_id_fk', 'materialreplenishment.product_id_fk', 'materialreplenishment.created_at')); $inventories = DB::select("select p.id,p.name, COALESCE(SUM(CASE WHEN x.MATERIAL_ID_FK = 1 THEN x.MATERIAL_COUNT END),0) Sample, COALESCE(SUM(CASE WHEN x.MATERIAL_ID_FK = 2 THEN x.MATERIAL_COUNT END),0) Literatures, COALESCE(SUM(CASE WHEN x.MATERIAL_ID_FK = 3 THEN x.MATERIAL_COUNT END),0) Promomaterials from ( select id,'0' as map_id, product_id_fk,material_id_fk,material_count from materialreplenishment union select id,material_map_fk, product_id_fk,material_id_fk,material_count*-1 from materialallocations) as x right join products p on p.id=x.product_id_fk GROUP BY p.id,p.name"); $allocations = materialallocations::join('products', 'products.id', '=', 'materialallocations.product_id_fk')->join('materials', 'materials.id', '=', 'materialallocations.material_id_fk')->join('calls', 'calls.id', '=', 'materialallocations.material_map_fk')->join('institutiondoctorsmaps', 'institutiondoctorsmaps.id', '=', 'calls.INST_DOC_ID_FK')->join('doctors', 'doctors.doc_id', '=', 'institutiondoctorsmaps.doctor_id_fk')->join('institution', 'institution.id', '=', 'institutiondoctorsmaps.institution_id_fk')->join('users', 'users.id', '=', 'calls.user_id_fk')->get(array('materialallocations.id', 'products.name as productname', 'materials.name as materialname', 'materialallocations.material_count', 'materialallocations.material_id_fk', 'materialallocations.product_id_fk', 'materialallocations.created_at', 'doctors.doc_name as doctorname', 'institution.name as institutionname', 'users.fname as userfname', 'users.lname as userlname')); return view('materialinventory', compact('products', 'materials', 'replenishments', 'inventories', 'allocations')); }
public function edit($id) { $product = \App\products::find($id); if ($product != null) { return view('backend.updateProduct', ['product' => $product]); } else { return view('backend.createProduct'); } }
public function run() { DB::table('products')->delete(); products::create(['name' => 'CLOPATE 75MG FC TAB']); products::create(['name' => 'ODASYL 5MG TAB']); products::create(['name' => 'ODASYL 10MG TAB']); products::create(['name' => 'SARTAN 50MG TAB']); products::create(['name' => 'SARTAN 100MG TAB']); products::create(['name' => 'SARTAN-H 50MG/12.5MG FC TAB']); products::create(['name' => 'EXCIT 1080MG (10MEQ) TABLET']); products::create(['name' => 'FINARID 5MG TAB']); products::create(['name' => 'PIMAX 200MCG TAB']); products::create(['name' => 'PIMAX 400MCG TAB']); products::create(['name' => 'ENERAPLUS DROPS 15ML']); products::create(['name' => 'ENERAPLUS DROPS 30ML']); products::create(['name' => 'ENERAPLUS SYRUP 60ML']); products::create(['name' => 'ENERAPLUS SYRUP 120ML']); products::create(['name' => 'ENERAPLUS SYRUP 240ML']); products::create(['name' => 'ENERAPLUS FOR TEENS']); products::create(['name' => 'NAPRAN 100MG/ML ORAL DROPS']); products::create(['name' => 'NAPRAN 125MG/5ML SUSP']); products::create(['name' => 'NAPRAN 250MG/5ML SUSP']); products::create(['name' => 'L-ZET 5MG TAB']); products::create(['name' => 'L-ZET 2.5MG/5ML SYRUP']); products::create(['name' => 'ANTAL 10MG TAB']); products::create(['name' => 'BEFIDAN 500MG CAP']); products::create(['name' => 'FLEXICOF 50MG/ML DROPS 15ML']); products::create(['name' => 'FLEXICOF 100MG/5ML SYRUP 60ML']); products::create(['name' => 'FLEXICOF 100MG/5L SYRUP 120ML']); products::create(['name' => 'PROTEC PILL 150MCG/30MCG/60MG']); products::create(['name' => 'SMARTEE SYRUP 60ML']); products::create(['name' => 'SMARTEE SYRUP 120ML']); products::create(['name' => 'ZEDROXYN 100MG/ML ORALL DROPS 10ML']); products::create(['name' => 'ZEDROXYN 125MG/5ML SUSP 60ML']); products::create(['name' => 'ZEDROXYN 250MG/5ML SUSP 60ML']); products::create(['name' => 'ZEDROXYN 250MG CAP']); products::create(['name' => 'ZEDROXYN 500MG CAP']); products::create(['name' => 'ZEXANTA 500MG CAP']); products::create(['name' => 'ZIRCAM 7.5MG DROPS 15ML']); products::create(['name' => 'ZIRCAM 15MG SYRUP 60ML']); products::create(['name' => 'ZIRCAM 30MG SYRUP 60ML']); products::create(['name' => 'NATALIE PRE-NATAL CAP']); products::create(['name' => 'GENERICS']); }
public function postOrder(Request $request) { //update here $purchaseorder = purchaseorder::find($request->purchaseorders_id); if (isset($_POST['saveStatus'])) { // if(isset($_POST['btnProcessDelivery'])){ // $purchaseorder->status = "on-delivery-process"; // $purchaseorder->save(); // } // if(isset($_POST['btnClose'])){ // $purchaseorder->status = "closed"; // $purchaseorder->save(); // } $trail = new audittrail(); $trailmessage = ""; if ($purchaseorder->status != $request->newstatus) { $trailmessage .= "Admin updated order status to : " . $request->newstatus . ";"; } if ($purchaseorder->remarks != $request->remarks) { $trailmessage .= " remarked: '" . $request->remarks . "'"; } if ($purchaseorder->status != $request->newstatus || $purchaseorder->remarks != $request->remarks) { $trail->purchaseorder_id = $purchaseorder->id; $trail->trail = $trailmessage; $trail->save(); } if ($request->newstatus == "closed") { $orders = orders::where('purchaseorders_id', $purchaseorder->id)->get(); foreach ($orders as $order) { $product = products::where('productName', $order->productName)->first(); if ($product) { $inventoryCount = new inventorycount(); $inventoryCount->type = "withdraw"; $inventoryCount->product_id = $product->id; $inventoryCount->amount = $order->quantity; $inventoryCount->save(); } } } $purchaseorder->status = $request->newstatus; $purchaseorder->remarks = $request->remarks; $purchaseorder->save(); return redirect('/order/' . $request->purchaseorders_id)->with('affirm', 'Status updated successfully'); } if (isset($_POST['saveCustomerDetails'])) { if ($purchaseorder->customer_name != $request->customer_name || $purchaseorder->customer_mobile != $request->mobilenumber || $purchaseorder->customer_email != $request->email || $purchaseorder->customer_address != $request->address || $purchaseorder->userverified != $request->customerStatus) { $trail = new audittrail(); if ($purchaseorder->customer_name != $request->customer_name) { $trail->trail .= " updated customer name to " . $request->customer_name . ";"; } if ($purchaseorder->customer_mobile != $request->mobilenumber) { $trail->trail .= " updated customer number to " . $request->mobilenumber . ";"; } if ($purchaseorder->customer_email != $request->email) { $trail->trail .= " updated customer email to " . $request->email . ";"; } if ($purchaseorder->customer_address != $request->address) { $trail->trail .= " updated customer email to " . $request->email . ";"; } if ($purchaseorder->userverified == "" || $purchaseorder->userverified == "unverified") { if ($purchaseorder->userverified != $request->customerStatus) { $trail->trail .= " updated user status to : " . $request->customerStatus; } } else { if ($purchaseorder->userverified != $request->customerStatus) { $trail->trail .= " updated user status to : " . $request->customerStatus . ";"; } } $trail->purchaseorder_id = $purchaseorder->id; $trail->save(); } $purchaseorder->customer_name = $request->customer_name; $purchaseorder->customer_mobile = $request->mobilenumber; $purchaseorder->customer_email = $request->email; $purchaseorder->customer_address = $request->address; $purchaseorder->userverified = $request->customerStatus; $purchaseorder->save(); return redirect('/order/' . $request->purchaseorders_id)->with('affirm', 'Customer details for this order updated successfully'); } }
public function postCheckoutFinal(Request $request, AppMailer $mailer) { if (isset($_POST['LoginAndCheckout'])) { if (Auth::attempt(['email' => $request->email, 'password' => $request->password])) { // Authentication passed... //return redirect()->intended('review'); } else { return redirect("/checkout")->with("error", "authentication failed"); } } if (isset($_POST['RegisterAccountcheckout'])) { if (Auth::attempt(['email' => $request->email, 'password' => $request->password])) { // Authentication passed... //return redirect()->intended('review'); } else { if (User::where('name', $request->username)->count() > 0) { return redirect('/checkout')->with('error', 'User name already exist'); } if (User::where('email', $request->email)->count() > 0) { return redirect('/checkout')->with('error', 'Email already exist'); } $user = new User(); $user->lastname = $request->lastname; $user->firstname = $request->firstname; $user->middleName = $request->middlename; $user->email = $request->email; $user->customer_address = $request->address; $user->name = $request->username; $user->password = bcrypt($request->password); $user->mobileNumber = $request->mobile; $confirmation_code = str_random(30); $user->token = $confirmation_code; $user->save(); //return redirect("/checkout")->with("authentication failed"); $mailer->sendEmailConfirmationTo($user); if (Auth::attempt(['email' => $user->email, 'password' => $request->password])) { } else { return "error"; } } } $data['name'] = Auth::check() ? Auth::user()->firstname . " " . Auth::user()->lastname : $request->name; $data['address'] = Auth::check() ? Auth::user()->customer_address : $request->address; $data['mobile'] = Auth::check() ? Auth::user()->mobileNumber : $request->mobile; $data['email'] = Auth::check() ? Auth::user()->email : $request->email; $orders = []; $items = Cart::getContent(); if (isset($_POST['placeorder'])) { $purchaseOrder = new purchaseorder(); $purchaseOrder->customer_name = $data['name']; $purchaseOrder->customer_mobile = $data['mobile']; $purchaseOrder->customer_address = $data['address']; $purchaseOrder->customer_email = $data['email']; $purchaseOrder->status = "pending"; $deadline = strtotime("+7 day"); $purchaseOrder->deadline = date('Y-m-d', $deadline); if (Auth::check()) { $purchaseOrder->user_id = Auth::user()->id; } $purchaseOrder->save(); $items = Cart::getContent(); foreach ($items as $item) { $order = new orders(); $product = products::find($item->id); $sellingprice = $product->sellingprice; $amount = $item->quantity * $sellingprice; $order->purchaseorders_id = $purchaseOrder->id; $order->productName = $item->name; $order->quantity = $item->quantity; $order->amount = $amount; $order->save(); } Cart::clear(); if (Auth::check()) { if (Auth::user()->active) { return redirect("/myorders")->with('affirm', "Your order has been processed."); } else { return redirect("/myorders")->with('affirm', "Your order has been processed. Please keep your lines up, we will contact you."); } } return redirect("/")->with('affirm', "Your order has been processed. Please keep your lines up, we will contact you."); } $data['orders'] = $items; return view('checkoutreview', $data); }