public function postUpdate($id) { $settingupdate = Request::all(); $setting = Setting::find($id); $setting->update($settingupdate); return redirect('admin/settings/')->with('flash_message', 'Settings Save'); }
public function store(Request $request) { foreach (Input::except('_token') as $id => $value) { $setting = Setting::find($id); $setting->value = $value; $setting->save(); } return redirect()->route("settings.all")->with('setting-saved', 'Successful saved!'); }
public function update(Request $request) { $settings = $request->except('_method', '_token'); foreach ($settings as $key => $value) { $set = Setting::find($key); $set->fill(['value' => $value])->save(); } return redirect('/setting')->with('success', 'Sukses memperbarui pengaturan'); }
public function update($data) { $setting = null; if (isset($data['id'])) { $setting = Setting::find($data['id']); $setting->update($data); } return $setting; }
public function store(SettingRequest $request) { //remove from cache old data to update global website settings Cache::forget('settings'); $settings = Setting::find(1); //update database using json format $settings->data = ['website_title' => $request->get('website_title'), 'admin_title' => $request->get('admin_title'), 'website_description' => $request->get('website_description'), 'admin_email' => $request->get('admin_email'), 'code_header' => $request->get('code_header'), 'code_footer' => $request->get('code_footer')]; $settings->update(); flash('Settings updated with success'); return redirect()->back(); }
public function ajax_variable() { $data = Request::all(); $s = Setting::find($data['pk']); // change name and value variable if ($data['name'] == 'name') { $s->name = $data['value']; } elseif ($data['name'] == 'value') { $s->value = $data['value']; } else { $s->lang_code = $data['lang_code']; } $s->save(); }
public function getRefresh(Request $req) { $Set1 = Setting::find(1); $Set2 = Setting::find(2); $Set1->sitename = $Set2->sitename; $Set1->description = $Set2->description; $Set1->email = $Set2->email; $Set1->tag = $Set2->tag; $Set1->fb = $Set2->fb; $Set1->twitter = $Set2->twitter; $Set1->gambar_utama = $Set2->gambar_utama; $Set1->save(); $req->session()->flash('success', 'Berhasil mengembalikan pengaturan'); return redirect(route('setting')); }
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()); }
public function store(Request $request) { $this->validate($request, ['app_name' => 'required|max:100']); \DB::beginTransaction(); try { $settings = Setting::find(1); if (!empty($settings)) { $settings->app_name = $request->app_name; $settings->update(); } else { $settings = new Setting(); $settings->app_name = $request->app_name; $settings->save(); } \DB::commit(); Session::flash('flash_message', 'Settings successfully updated!'); return redirect()->back(); } catch (Exception $e) { DB::rollBack(); return redirect()->back(); } }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $settings = Setting::find(1); $settings->uploader_email = $request->uploader_email; $settings->enable_ig_edit = $request->has('enable_ig_edit') ? 1 : 0; $settings->validate_posting_mkl = $request->has('validate_posting_mkl') ? 1 : 0; $settings->validate_printing_mkl = $request->has('validate_printing_mkl') ? 1 : 0; $settings->validate_posting_ass = $request->has('validate_posting_ass') ? 1 : 0; $settings->validate_printing_ass = $request->has('validate_printing_ass') ? 1 : 0; $settings->validate_reposting_mkl = $request->has('validate_reposting_mkl') ? 1 : 0; $settings->validate_reposting_ass = $request->has('validate_reposting_ass') ? 1 : 0; $settings->device_password = $request->device_password; $settings->update(); $hash = UpdateHash::find(1); if (empty($hash)) { UpdateHash::create(['hash' => \Hash::make(date('Y-m-d H:i:s'))]); } else { $hash->hash = md5(date('Y-m-d H:i:s')); $hash->update(); } Session::flash('flash_message', 'Settings successfully updated.'); Session::flash('flash_class', 'alert-success'); return redirect()->route("settings.index"); }
public function contact() { $data['setting'] = Setting::find(1); return view('front.contact.index', $data); }
public function saveSettings(Request $request) { $settings = Setting::find(1); $settings->voteInterval = $request->input('voteInterval'); $settings->save(); return redirect('admin/settings')->with('status', 'Settings updated!'); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { // $setting = Setting::find($id); $setting->delete(); return redirect()->route('setting.index'); }
public function addVote(Request $request) { $this->validate($request, ['g-recaptcha-response' => 'required|recaptcha']); $id = $request->input('server_id'); $settings = Setting::find(1); $interval = $settings->voteInterval; $ip = getHostByName(php_uname('n')); //Check if user alredy voted in 24h $vote = Vote::where('ip', $ip)->first(); if ($vote != null) { if ($vote->updated_at->addHours($interval) > Carbon::now()) { //already voted return redirect('server/' . $id)->withErrors('You have already voted. Now you can vote after ' . $interval . ' hours from your voting time'); } } //Deletes old record Vote::where('ip', $ip)->delete(); $server = serverModel::where('id', $id)->first(); $votes = $server->votes; $server->votes = $votes + 1; $server->save(); $vote = new Vote(); $vote->ip = $ip; $vote->save(); return redirect('server/' . $id)->with('status', 'You have successfully voted!'); }
public function utime(Request $request) { // $id = 1; $setting = Setting::find($id); $setting->refresh_interval = $request->refresh_interval; if (intval($setting->refresh_interval) < 1) { $setting->refresh_interval = 1; } $setting->warn_timeout = $request->warn_timeout; $setting->save(); echo 1; }
public function updateSettings(Request $request) { $settings = Setting::find(1); $settings->fill($request->input())->save(); return redirect(route('admin.dashboard')); }
public function uploadpcount(Request $request) { $destinationPath = storage_path() . '/uploads/pcount/'; $fileName = $request->file('data')->getClientOriginalName(); $request->file('data')->move($destinationPath, $fileName); $filePath = storage_path() . '/uploads/pcount/' . $fileName; $filename_data = explode("-", $fileName); if (count($filename_data) == 6 && $filename_data[5] == '5.csv') { $storeid = $filename_data[0]; $userid = $filename_data[1]; $year = explode(".", $filename_data[4]); $transdate = date('Y-m-d', strtotime($year[0] . '-' . $filename_data[2] . '-' . $filename_data[3])); $imgname = explode(".", $fileName); $signature = 'IM_' . $imgname[0] . '.jpg'; $store = Store::with('area')->with('enrollment')->with('distributor')->with('client')->with('channel')->with('customer')->with('region')->with('agency')->find($storeid); $user = User::find($userid); DB::beginTransaction(); try { $settings = Setting::find(1); $store_inventory = StoreInventories::where('store_pri_id', $store->id)->where('transaction_date', $transdate)->first(); if (!empty($store_inventory)) { ItemInventories::where('store_inventory_id', $store_inventory->id)->delete(); $store_inventory->delete(); } $store_inventory = StoreInventories::create(['area' => $store->area->area, 'enrollment_type' => $store->enrollment->enrollment, 'distributor_code' => $store->distributor->distributor_code, 'distributor' => $store->distributor->distributor, 'store_id' => $store->storeid, 'store_pri_id' => $store->id, 'store_code' => $store->store_code, 'store_code_psup' => $store->store_code_psup, 'store_name' => $store->store_name, 'client_code' => $store->client->client_code, 'client_name' => $store->client->client_name, 'channel_code' => $store->channel->channel_code, 'channel_name' => $store->channel->channel_desc, 'customer_code' => $store->customer->customer_code, 'customer_name' => $store->customer->customer_name, 'region_short_name' => $store->region->region_short, 'region_name' => $store->region->region, 'region_code' => $store->region->region_code, 'agency_code' => $store->agency->agency_code, 'agency' => $store->agency->agency_name, 'username' => $user->name, 'signature' => $signature, 'transaction_date' => $transdate]); $reader = ReaderFactory::create(Type::CSV); // for XLSX files $reader->setFieldDelimiter(';'); $reader->open($filePath); $areas = ['MDC', 'ROSE PHARMACY', '360 PHARMACY', '360 DRUG', 'ST. JOSEPH DRUG', 'SOUTH STAR DRUG']; foreach ($reader->getSheetIterator() as $sheet) { foreach ($sheet->getRowIterator() as $row) { $item = Item::with('division')->with('category')->with('subcategory')->with('brand')->where('sku_code', trim($row[0]))->first(); if (!empty($item)) { $osa = 0; $oos = 0; $min_stock = 2; if (in_array($store->area->area, $areas)) { $min_stock = 3; } // dd($min_stock); $store_item = StoreItem::where('store_id', $store->id)->where('item_id', $item->id)->first(); if (!isset($row[13])) { if (!empty($store_item)) { $min_stock = $store_item->min_stock; } } else { $min_stock = $row[13]; } if ($row[1] > $min_stock) { $osa = 1; } else { $oos = 1; } ItemInventories::insert(['store_inventory_id' => $store_inventory->id, 'division' => $item->division->division, 'category' => $item->category->category, 'category_long' => $item->category->category_long, 'sub_category' => $item->subcategory->sub_category, 'brand' => $item->brand->brand, 'sku_code' => $item->sku_code, 'other_barcode' => $row[7], 'description' => $item->description, 'description_long' => $item->description_long, 'lpbt' => $item->lpbt, 'conversion' => $row[10], 'min_stock' => $min_stock, 'ig' => $row[9], 'fso_multiplier' => $row[8], 'sapc' => $row[1], 'whpc' => $row[2], 'whcs' => $row[3], 'so' => $row[4], 'fso' => $row[5], 'fso_val' => $row[6], 'osa' => $osa, 'oos' => $oos, 'osa_tagged' => $row[11], 'npi_tagged' => $row[12]]); if ($settings->enable_ig_edit) { if (!empty($store_item)) { if ($store_item->ig != $row[9]) { $updated_ig = UpdatedIg::where('store_id', $store->id)->where('sku_code', $item->sku_code)->first(); $other_code = OtherBarcode::where('item_id', $item->id)->where('area_id', $store->area->id)->first(); $othercode = ''; if (!empty($other_code)) { $othercode = $other_code->other_barcode; } if (!empty($updated_ig)) { $updated_ig->area = $store->area->area; $updated_ig->region_code = $store->region->region_code; $updated_ig->region = $store->region->region; $updated_ig->distributor_code = $store->distributor->distributor_code; $updated_ig->distributor = $store->distributor->distributor; $updated_ig->agency_code = $store->agency->agency_code; $updated_ig->agency = $store->agency->agency_name; $updated_ig->storeid = $store->storeid; $updated_ig->channel_code = $store->channel->channel_code; $updated_ig->channel = $store->channel->channel_desc; $updated_ig->other_code = $othercode; $updated_ig->division = $item->division->division; $updated_ig->category = $item->category->category; $updated_ig->sub_category = $item->subcategory->sub_category; $updated_ig->brand = $item->brand->brand; $updated_ig->conversion = $item->conversion; $updated_ig->fso_multiplier = $row[8]; $updated_ig->min_stock = $min_stock; $updated_ig->lpbt = $item->lpbt; $updated_ig->ig = $row[9]; $updated_ig->updated_at = date('Y-m-d H:i:s'); $updated_ig->save(); } else { UpdatedIg::create(['area' => $store->area->area, 'region_code' => $store->region->region_code, 'region' => $store->region->region, 'distributor_code' => $store->distributor->distributor_code, 'distributor' => $store->distributor->distributor, 'agency_code' => $store->agency->agency_code, 'agency' => $store->agency->agency_name, 'storeid' => $store->storeid, 'store_id' => $store->id, 'store_code' => $store->store_code, 'store_name' => $store->store_name, 'channel_code' => $store->channel->channel_code, 'channel' => $store->channel->channel_desc, 'other_code' => $othercode, 'sku_code' => $item->sku_code, 'description' => $item->description, 'division' => $item->division->division, 'category' => $item->category->category, 'sub_category' => $item->subcategory->sub_category, 'brand' => $item->brand->brand, 'conversion' => $item->conversion, 'fso_multiplier' => $row[8], 'min_stock' => $min_stock, 'lpbt' => $item->lpbt, 'ig' => $row[9]]); } } } } } } } $reader->close(); DB::commit(); return response()->json(array('msg' => 'file uploaded', 'status' => 0)); } catch (Exception $e) { DB::rollback(); return response()->json(array('msg' => 'file uploaded error', 'status' => 1)); } } else { return response()->json(array('msg' => 'Cannot upload file, invalid version', 'status' => 1)); } }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { // $ticket = Ticket::find($id); $setting = Setting::find(1); return view('ticket.show', array('ticket' => $ticket, 'setting' => $setting)); }
public function index(Request $request) { $user = $request->id; $type = $request->type; $ext = $request->ext; $storelist = DB::table('store_users')->select('stores.id', 'stores.store_code', 'stores.store_name', 'stores.channel_id', 'channels.channel_desc', 'areas.area', 'enrollments.enrollment', 'distributors.distributor_code', 'distributors.distributor', 'stores.storeid', 'stores.store_code_psup', 'clients.client_code', 'clients.client_name', 'channels.channel_code', 'customers.customer_code', 'customers.customer_name', 'regions.region_code', 'regions.region', 'regions.region_short', 'agencies.agency_code', 'agencies.agency_name')->join('stores', 'stores.id', '=', 'store_users.store_id')->join('channels', 'channels.id', '=', 'stores.channel_id')->join('areas', 'areas.id', '=', 'stores.area_id')->join('enrollments', 'enrollments.id', '=', 'stores.enrollment_id')->join('distributors', 'distributors.id', '=', 'stores.distributor_id')->join('clients', 'clients.id', '=', 'stores.client_id')->join('customers', 'customers.id', '=', 'stores.customer_id')->join('regions', 'regions.id', '=', 'stores.region_id')->join('agencies', 'agencies.id', '=', 'stores.agency_id')->where('store_users.user_id', $user)->where('stores.active', 1)->get(); if ($type == 1) { $settings = Setting::find(1); if ($ext == 'json') { return response()->json($settings); } else { $writer = WriterFactory::create(Type::CSV); $writer->openToBrowser('settings.txt'); $data[0] = $settings->enable_ig_edit; $data[1] = $settings->validate_posting_mkl; $data[2] = $settings->validate_printing_mkl; $data[3] = $settings->validate_posting_ass; $data[4] = $settings->validate_printing_ass; $data[5] = $settings->device_password; $data[6] = $settings->validate_reposting_mkl; $data[7] = $settings->validate_reposting_ass; $writer->addRow($data); $writer->close(); } } // get store list if ($type == 2) { if ($ext == 'json') { $json_data = new \stdClass(); $json_data->total_count = count($storelist); foreach ($storelist as $store) { $data = new \stdClass(); $data->id = $store->id; $data->store_code = $store->store_code; $data->store_name = $store->store_name; $data->channel_id = $store->channel_id; $data->channel_desc = $store->channel_desc; $data->area = $store->area; $json_data->stores[] = $data; } return response()->json($json_data); } else { $writer = WriterFactory::create(Type::CSV); $writer->openToBrowser('stores.txt'); // $writer->addRow(array('ID', 'Store Code', 'Store Name' , 'Channel Id', 'Channel', 'Area')); $writer->addRow(array(count($storelist))); foreach ($storelist as $store) { $data[0] = $store->id; $data[1] = $store->store_code; $data[2] = $store->store_name; $data[3] = $store->channel_id; $data[4] = $store->channel_desc; $data[5] = $store->area; $writer->addRow($data); } $writer->close(); } } //get store sku list if ($type == 3) { $ids = array(); foreach ($storelist as $store) { $ids[] = $store->id; } $skus = DB::table('store_items')->select('store_items.id', 'store_items.store_id', 'items.description', 'items.description_long', 'items.conversion', 'store_items.ig', 'store_items.fso_multiplier', 'items.lpbt', 'categories.category', 'categories.category_long', 'sub_categories.sub_category', 'brands.brand', 'divisions.division', 'other_barcodes.other_barcode', 'items.sku_code', 'items.barcode', 'store_items.min_stock', 'store_items.osa_tagged', 'store_items.npi_tagged')->join('stores', 'stores.id', '=', 'store_items.store_id')->join('items', 'items.id', '=', 'store_items.item_id')->join('other_barcodes', 'other_barcodes.item_id', '=', 'items.id')->join('categories', 'categories.id', '=', 'items.category_id')->join('sub_categories', 'sub_categories.id', '=', 'items.sub_category_id')->join('brands', 'brands.id', '=', 'items.brand_id')->join('divisions', 'divisions.id', '=', 'items.division_id')->where('item_type_id', 1)->whereRaw('other_barcodes.area_id = stores.area_id')->whereIn('store_items.store_id', $ids)->orderBy('store_items.id', 'asc')->get(); $updated_igs = DB::table('updated_igs')->whereIn('store_id', $ids)->get(); $updated_ig_list = []; if (!empty($updated_igs)) { foreach ($updated_igs as $updated_ig) { if (!isset($updated_ig_list[$updated_ig->store_id][$updated_ig->sku_code])) { $updated_ig_list[$updated_ig->store_id][$updated_ig->sku_code] = 0; } $updated_ig_list[$updated_ig->store_id][$updated_ig->sku_code] = $updated_ig->ig; } } if ($ext == 'json') { $json_data = new \stdClass(); $json_data->total_count = count($skus); foreach ($skus as $sku) { $data = new \stdClass(); $data->conversion = $sku->conversion; $data->lpbt = $sku->lpbt; $data->category_long = $sku->category_long; $data->sub_category = $sku->sub_category; $data->brand = $sku->brand; $data->division = $sku->division; $data->store_id = $sku->store_id; $data->sku_code = $sku->sku_code; $data->fso_multiplier = $sku->fso_multiplier; $data->barcode = $sku->barcode; $data->min_stock = $sku->min_stock; $data->category = $sku->category; $data->description_long = $sku->description_long; $data->osa_tagged = $sku->osa_tagged; $data->npi_tagged = $sku->npi_tagged; $json_data->skus[] = $data; } return response()->json($json_data); } else { $writer = WriterFactory::create(Type::CSV); $writer->openToBrowser('mkl.txt'); // $writer->addRow(array('Other Barcode', 'Item Description', 'Inventory Goal', // 'Conversion', 'LPBT', 'Category Long', 'Sub-Category', 'Brand', 'Division', 'Store ID', 'Web ID', 'FSO Multiplier', 'Item Barcode', 'Min Stock', // 'Category', 'Long Desc', 'OSA Tagged', 'NPI Tagged')); $writer->addRow(array(count($skus))); foreach ($skus as $sku) { $data[0] = $sku->other_barcode; $data[1] = $sku->description; if (isset($updated_ig_list[$sku->store_id][$sku->sku_code])) { $data[2] = $updated_ig_list[$sku->store_id][$sku->sku_code]; } else { $data[2] = $sku->ig; } $data[3] = $sku->conversion; $data[4] = $sku->lpbt; $data[5] = $sku->category_long; $data[6] = $sku->sub_category; $data[7] = $sku->brand; $data[8] = $sku->division; $data[9] = $sku->store_id; $data[10] = $sku->sku_code; $data[11] = $sku->fso_multiplier; $data[12] = $sku->barcode; $data[13] = $sku->min_stock; $data[14] = $sku->category; $data[15] = $sku->description_long; $data[16] = $sku->osa_tagged; $data[17] = $sku->npi_tagged; $writer->addRow($data); } $writer->close(); } } if ($type == 4) { $ids = array(); foreach ($storelist as $store) { $ids[] = $store->id; } $skus = DB::table('store_items')->select('store_items.id', 'store_items.store_id', 'items.description', 'items.description_long', 'items.conversion', 'store_items.ig', 'store_items.fso_multiplier', 'items.lpbt', 'categories.category', 'categories.category_long', 'sub_categories.sub_category', 'brands.brand', 'divisions.division', 'other_barcodes.other_barcode', 'items.sku_code', 'items.barcode', 'store_items.min_stock')->join('stores', 'stores.id', '=', 'store_items.store_id')->join('items', 'items.id', '=', 'store_items.item_id')->join('other_barcodes', 'other_barcodes.item_id', '=', 'items.id')->join('categories', 'categories.id', '=', 'items.category_id')->join('sub_categories', 'sub_categories.id', '=', 'items.sub_category_id')->join('brands', 'brands.id', '=', 'items.brand_id')->join('divisions', 'divisions.id', '=', 'items.division_id')->where('store_items.item_type_id', 2)->whereRaw('other_barcodes.area_id = stores.area_id')->whereIn('store_items.store_id', $ids)->orderBy('store_items.id', 'asc')->get(); if ($ext == 'json') { $json_data = new \stdClass(); $json_data->total_count = count($skus); foreach ($skus as $sku) { $data = new \stdClass(); $data->conversion = $sku->conversion; $data->lpbt = $sku->lpbt; $data->category_long = $sku->category_long; $data->sub_category = $sku->sub_category; $data->brand = $sku->brand; $data->division = $sku->division; $data->store_id = $sku->store_id; $data->sku_code = $sku->sku_code; $data->fso_multiplier = $sku->fso_multiplier; $data->barcode = $sku->barcode; $data->min_stock = $sku->min_stock; $data->category = $sku->category; $data->description_long = $sku->description_long; $json_data->skus[] = $data; } return response()->json($json_data); } else { $writer = WriterFactory::create(Type::CSV); $writer->openToBrowser('assortment.txt'); // $writer->addRow(array('Other Barcode', 'Item Description', 'Inventory Goal', // 'Conversion', 'LPBT', 'Category', 'Sub-Category', 'Brand', 'Division', 'Store ID', 'Web ID', 'FSO Multiplier', 'Item Barcode', 'Min Stock')); $writer->addRow(array(count($skus))); foreach ($skus as $sku) { $data[0] = $sku->other_barcode; $data[1] = $sku->description; $data[2] = $sku->ig; $data[3] = $sku->conversion; $data[4] = $sku->lpbt; $data[5] = $sku->category_long; $data[6] = $sku->sub_category; $data[7] = $sku->brand; $data[8] = $sku->division; $data[9] = $sku->store_id; $data[10] = $sku->sku_code; $data[11] = $sku->fso_multiplier; $data[12] = $sku->barcode; $data[13] = $sku->min_stock; $data[14] = $sku->category; $data[15] = $sku->description_long; $writer->addRow($data); } $writer->close(); } } if ($type == 5) { $ids = array(); foreach ($storelist as $store) { $ids[] = $store->id; } $updated_igs = DB::table('updated_igs', 'sku_code', 'ig')->select('store_id', 'sku_code', 'ig')->whereIn('store_id', $ids)->get(); if ($ext == 'json') { $json_data = new \stdClass(); $json_data->total_count = count($updated_igs); foreach ($updated_igs as $ig) { $data = new \stdClass(); $data->store_id = $ig->store_id; $data->sku_code = $ig->sku_code; $data->ig = $ig->ig; $json_data->updated_igs[] = $data; } return response()->json($json_data); } else { $writer = WriterFactory::create(Type::CSV); $writer->openToBrowser('updatedig.txt'); // $writer->addRow(array('Store Id', 'SKU Code', 'IG')); $writer->addRow(array(count($updated_igs))); foreach ($updated_igs as $ig) { $data[0] = $ig->store_id; $data[1] = $ig->sku_code; $data[2] = $ig->ig; $writer->addRow($data); } $writer->close(); } } }