/** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { $allcustomers = \App\Customers::orderBy('first_name')->get(); $customers = $allcustomers->lists('CustomerFullName', 'id'); $allproducts = \App\Products::orderBy('product_name')->get(); $products = $allproducts->lists('ProductShowInfo', 'id'); //\App\Products::lists('product_name','id'); return view('orders.create', compact('customers', 'products')); }
public function editCustomer(Request $request) { $session = $request->get('session'); $id = $request->get('id'); $companyname = $request->get("companyname"); $regno = $request->get("regno"); $address = $request->get("address"); $website = $request->get("website"); $customer = Customers::find(intval($id)); $customer->companyName = $companyname; $customer->regNo = $regno; $customer->address = $address; $customer->website = $website; $customer->save(); return redirect()->action('CRMController@homeView', ["session" => $session]); }
/** * Store a newly created resource in storage. * * @return Response */ public function store(PurchasesRequest $request) { $today = $request->odenish_tarixi; $odenilecekMebleg = $request->Purchase; $customers = \App\Customers::get(); foreach ($customers as $cusId) { $ifnotinsertprucase = DB::insert(DB::raw("INSERT INTO purchases (CustomerName,CustomerId,Borc,Purchase,odenish_tarixi,info,created_at,updated_at)\nSELECT * FROM (SELECT '{$cusId->name}' as namee, '{$cusId->id}' as cusid, 0 as borc, 0 as purc , 0 as oden,0 as info ,'{$today}' as crea ,'{$today}' as updates ) AS tmps\nWHERE NOT EXISTS (\n SELECT * FROM purchases WHERE CustomerId = '{$cusId->id}' AND created_at = '{$today}') LIMIT 1")); } $datePurchase = DB::select('select * from purchases where cast(created_at as DATE) = ? and CustomerId = ?', array($today, $request['CustomerId'])); $odenilecekMebleg = $request->Purchase + $datePurchase[0]->Purchase; DB::table('purchases')->where('id', $datePurchase[0]->id)->update(array('purchase' => $odenilecekMebleg)); // $cusName = Customers::find($request->CustomerId); // $request['CustomerName']= $cusName->name; // //$this->validate($request, ['name' => 'required']); // Uncomment and modify if needed. // Purchases::create($request->all()); return redirect('purchase/create'); }
/** * Store a newly created resource in storage. * * @return Response */ public function store(Request $request) { $dateCusId = DB::select('select * from orders where cast(created_at as DATE) = ? and CustomerId = ?', array($request['Date'], $request['CustomerId'])); $customers = Customers::where('id', '=', $request->CustomerId)->get(); foreach ($request['quantity'] as $key => $tee) { $products = Products::where('id', '=', $key)->get(); $count = DB::select('select count(*) as a from orders where cast(created_at As Date) = ? and CustomerId = ? and ProductId = ?', array($request['Date'], $request['CustomerId'], $key)); if ($count[0]->a == 0) { $InsertDb = DB::table('orders')->insert(array('ProductName' => $products[0]->Name, 'ProductId' => $key, 'CustomerId' => $request->CustomerId, 'CustomerName' => $customers[0]->name, 'quantity' => $tee, 'Alish' => $products[0]->Alish, 'AlishCem' => $tee * $products[0]->Alish, 'Satish' => $products[0]->Satish, 'SatishCem' => $tee * $products[0]->Satish, 'Income' => $products[0]->Income, 'IncomeCem' => $tee * ($products[0]->Satish - $products[0]->Alish), 'created_at' => $request['Date'], 'updated_at' => $request['Date'])); } else { $selectOld = Orders::where('ProductId', $key)->where('CustomerId', $request->CustomerId)->where('created_at', $request['Date'])->get(); DB::table('orders')->where('ProductId', $key)->where('CustomerId', $request->CustomerId)->where('created_at', $request['Date'])->update(array('quantity' => $tee, 'AlishCem' => $tee * $selectOld[0]->Alish, 'SatishCem' => $tee * $selectOld[0]->Satish, 'IncomeCem' => $tee * $selectOld[0]->Income)); } } //////////////////////////buna bax asahi // $datePurchase = DB::select('select * from purchases where cast(created_at as DATE) = ? and CustomerId = ?', array($request['Date'], $request['CustomerId'])); // DB::table('purchases') // ->where('id', $datePurchase[0]->id) // ->update(array('Borc' => $borc)); //////////////////////////////////// // DB::table('users') // ->where('id', 1) // ->update(array('votes' => 1)); // $test = Products::where('CustomerId', '=', $request['CustomerId'])->get(); // foreach ($test as $key => $t2) { // DB::table('orders')->insert( // ['ProductName' => $t2->Name, // 'CustomerId' => $request['CustomerName'], // 'CustomerName' => $request['CustomerName'], // 'quantity' => Input::get("quantity.$key"), // 'Alish' => $t2->Alish, // 'Satish' => $t2->Satish, // 'Income' => Input::get("quantity.$key") * ($t2->Satish - $t2->Alish), // 'created_at' => Carbon::now(), // 'updated_at' => Carbon::now()] // ); // } // Orders::create($request->all()); return redirect('orders/create'); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function view() { $customers = Customers::paginate(15); return view('customers.view', compact('customers')); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function inquiry_storeatas() { $tour = Input::all(); $tourname = Input::get('tourname'); $tourdate = Input::get('tourdate'); $tourdateto = Input::get('tourdateto'); $news2 = DB::table('news')->leftJoin('users', 'news.publisher', '=', 'users.id')->leftJoin('news_categories', 'news.category', '=', 'news_categories.id')->select('news.title', 'news.slug', 'news_categories.name as category', 'news.s_content', 'users.name as publisher', 'news.image', 'news.created_at', 'users.image as image2')->get(); $customers = new Customers(array($cust_name = Input::get('name'), $email = Input::get('email'), $phone = Input::get('phone'), $country = Input::get('country'))); $bookings = new Booking(array($cust_name = Input::get('name'), $message = Input::get('message'))); $bookings->cust_name = $cust_name; $bookings->tour_name = $tourname; $customers->cust_name = $cust_name; $customers->email = $email; $customers->phone = $phone; $customers->country = $country; $bookings->tour_date = $tourdateto; //$bookings->price = $tourprice->price; //$bookings->status = $status; $bookings->save(); $customers->save(); return \Redirect::back()->with('message', 'Your inquiry has been successfully send to us.', $tourname); }
/** * Remove the specified resource from storage. * * @param $user * @return Response */ public function postDelete(DeleteRequest $request, $id) { $customers = Customers::find($id); $customers->delete(); }
private function customer($method, $params, $from, $con) { $results = []; // list of all method that can be called in current module $registeredMethod = array('create', 'destroy', 'listSales', 'loadFormEdit', 'read', 'update', 'viewDetail'); // if called method is not registered then deny access if (!in_array($method, $registeredMethod)) { throw new Exception('Wrong turn buddy'); } // get Current User $currentUser = $from->Session->get('pos/current_user'); // route to requested module and method $results = Customers::$method($params, $currentUser, $con); // followup action if ($method == 'viewDetail') { // send transaction chart's data on picked month $data = Customers::last7MonthsTransactions($params, $currentUser, $con); $transaction['event'] = 'customer/last7MonthsTransactions'; $transaction['data'] = $data; $from->send(json_encode($transaction)); } return $results; }
/** * Show the form for creating a new resource. * * @return Response */ public function create() { $CategoryName = Categories::lists('name', 'id'); $CustomerName = Customers::lists('name', 'id'); return view('products.create', compact('CustomerName', $CustomerName), compact('CategoryName')); }
public static function viewDetail($params, $currentUser, $con) { // check role's permission $permission = RolePermissionQuery::create()->select('read_second_party')->findOneById($currentUser->role_id, $con); if (!$permission || $permission != 1) { throw new \Exception('Akses ditolak. Anda tidak mempunyai izin untuk melakukan operasi ini.'); } $customer = Customers::seeker($params, $currentUser, $con); $stats = Customers::getStats($params, $currentUser, $con); $results['success'] = true; $results['detail'] = $customer['data']; $results['stats'] = $stats['data']; return $results; }
/** * Reorder items * * @param items list * @return items from @param */ public function getReorder(ReorderRequest $request) { $list = $request->list; $items = explode(",", $list); $order = 1; foreach ($items as $value) { if ($value != '') { Customers::where('id', '=', $value)->update(array('position' => $order)); $order++; } } return $list; }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { Customers::destroy($id); return redirect('customers'); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $customer = Customers::find($id); $customer->delete(); return redirect('customer'); }