예제 #1
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function __construct()
 {
     $setting = Models\Setting::first();
     $this->data['menu'] = Models\Menu::with('child')->where('level', 0)->get();
     $this->data['berita'] = Models\Berita::orderBy('id_berita', 'desc')->limit(6)->get();
     $this->data['pengumuman'] = Models\Pengumuman::orderBy('tanggal', 'desc')->limit(10)->get();
     $this->data['agenda'] = Models\Agenda::orderBy('tgl_posting', 'desc')->limit(5)->get();
     $this->data['polling'] = Models\Polling::with('jawaban')->where('status', 'Y')->limit(1)->first();
     $this->data['title'] = $setting->title_web;
     $this->data['desc'] = $setting->desc_web;
     $this->data['key'] = $setting->key_web;
     $this->data['logo'] = $setting->logo;
     $this->data['header_img'] = $setting->bg_header;
     $this->data['icon'] = $setting->favicon;
     $this->data['facebook'] = $setting->facebook;
     $this->data['peta_latitude'] = $setting->peta_latitude;
     $this->data['peta_longitude'] = $setting->peta_longitude;
     $this->data['twitter'] = $setting->twitter;
     $this->data['gplus'] = $setting->gplus;
     $this->data['slider_home'] = Models\Berita::orderBy('tanggal', 'desc')->limit(5)->get();
     $this->data['galeri_home'] = Models\Foto::OrderBy('id_foto', 'desc')->paginate(9);
     $this->data['opini_home'] = Models\Berita::where('kategori_berita', 5)->orderBy('id_berita', 'desc')->limit(6)->get();
     $this->data['banner'] = Models\Banner::where('id', 1)->first();
     $this->data['link'] = Models\Link::orderBy('id', 'desc')->limit(5)->get();
     $this->data['publikasi'] = Models\Publikasi::orderBy('id', 'desc')->limit(3)->get();
     $this->data['setting'] = $setting;
 }
예제 #2
0
 public static function getSettings()
 {
     static $static_cache = null;
     if (!$static_cache) {
         $static_cache = Setting::first();
     }
     return $static_cache;
 }
 /**
  * Handle the command.
  *
  * @param  UpdateSettingCommand  $command
  * @return void
  */
 public function handle(UpdateSettingCommand $command)
 {
     $setting = Setting::first();
     $setting->salary = $command->salary;
     $setting->save = $command->save;
     if ($setting->save()) {
         return true;
     } else {
         return false;
     }
 }
예제 #4
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store()
 {
     //Check if exists
     $cost = Cost::exists($this->month, $this->year);
     if (!empty($cost)) {
         return $this->saveResponse(false);
     }
     $setting = Setting::first();
     $spend = Item::total($this->month, $this->year);
     $cost = Bus::dispatch(new CreateCostCommand($setting->salary, $setting->save, $spend));
     return $this->saveResponse($cost);
 }
예제 #5
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     if ($this->confirm("\n****************************************************\nThis will disable LDAP support. You will not be able \nto login with an account that does not exist \nlocally in the Snipe-IT local database. \n****************************************************\n\nDo you wish to continue? [y|N]")) {
         $setting = Setting::first();
         $setting->ldap_enabled = 0;
         if ($setting->save()) {
             $this->info('LDAP has been set to disabled.');
         } else {
             $this->info('Unable to disable LDAP.');
         }
     } else {
         $this->info('Canceled. No actions taken.');
     }
 }
 /**
  * Migration to pull in LDAP settings from ldap.config into database.
  *
  * @return void
  */
 public function up()
 {
     $settings = \App\Models\Setting::first();
     // Only update the settings record if there IS an LDAP Config
     // AND the Settings table doesn't already have LDAP settings in it
     if (config('ldap.url') && $settings && $settings->ldap_server) {
         $settings->ldap_enabled = 1;
         $settings->ldap_server = config('ldap.url');
         $settings->ldap_uname = config('ldap.username');
         $settings->ldap_pword = Crypt::encrypt(config('ldap.password'));
         $settings->ldap_basedn = config('ldap.basedn');
         $settings->ldap_filter = config('ldap.filter');
         $settings->ldap_username_field = config('ldap.result.username');
         $settings->ldap_lname_field = config('ldap.result.last.name');
         $settings->ldap_fname_field = config('ldap.result.first.name');
         $settings->ldap_auth_filter_query = config('ldap.authentication.filter.query');
         $settings->ldap_version = config('ldap.version');
         $settings->ldap_active_flag = config('ldap.result.active.flag');
         $settings->ldap_emp_num = config('ldap.result.emp.num');
         $settings->ldap_email = config('ldap.result.email');
         // Save the imported settings
         if ($settings->save()) {
             echo 'LDAP settings imported into database' . "\n";
             // Copy the old LDAP config file to prevent any future confusion
             if (@copy(app_path() . '/config/' . app()->environment() . '/ldap.php', app_path() . '/config/' . app()->environment() . '/deprecated.ldap.php')) {
                 if (@unlink(app_path() . '/config/' . app()->environment() . '/ldap.php')) {
                     echo 'Original LDAP file archived to ' . app_path() . '/config/' . app()->environment() . '/deprecated.ldap.php' . "\n";
                 } else {
                     echo 'Could not archive LDAP config file' . "\n";
                 }
             } else {
                 echo 'Could not archive LDAP config file' . "\n";
             }
         }
     }
 }
예제 #7
0
 /**
  * Returns a view that presents information about an asset for detail view.
  *
  * @author [A. Gianotto] [<*****@*****.**>]
  * @param int $assetId
  * @since [v1.0]
  * @return View
  */
 public function getView($assetId = null)
 {
     $asset = Asset::withTrashed()->find($assetId);
     $settings = Setting::getSettings();
     if (!Company::isCurrentUserHasAccess($asset)) {
         return redirect()->to('hardware')->with('error', trans('general.insufficient_permissions'));
     } elseif ($asset->userloc) {
         $use_currency = $asset->userloc->currency;
     } elseif ($asset->assetloc) {
         $use_currency = $asset->assetloc->currency;
     } else {
         $default_currency = Setting::first()->default_currency;
         if ($settings->default_currency != '') {
             $use_currency = $settings->default_currency;
         } else {
             $use_currency = trans('general.currency');
         }
     }
     if (isset($asset->id)) {
         $qr_code = (object) array('display' => $settings->qr_code == '1', 'url' => route('qr_code/hardware', $asset->id));
         return View::make('hardware/view', compact('asset', 'qr_code', 'settings'))->with('use_currency', $use_currency);
     } else {
         // Prepare the error message
         $error = trans('admin/hardware/message.does_not_exist', compact('id'));
         // Redirect to the user management page
         return redirect()->route('hardware')->with('error', $error);
     }
 }
예제 #8
0
 /**
  * Validate and process settings edit form.
  *
  * @author [A. Gianotto] [<*****@*****.**>]
  * @since [v1.0]
  * @return Redirect
  */
 public function postEdit()
 {
     // Check if the asset exists
     if (is_null($setting = Setting::first())) {
         // Redirect to the asset management page with error
         return redirect()->to('admin')->with('error', trans('admin/settings/message.update.error'));
     }
     if (Input::get('clear_logo') == '1') {
         $setting->logo = null;
     } elseif (Input::file('logo_img')) {
         if (!config('app.lock_passwords')) {
             $image = Input::file('logo_img');
             $file_name = "logo." . $image->getClientOriginalExtension();
             $path = public_path('uploads/' . $file_name);
             Image::make($image->getRealPath())->resize(null, 40, function ($constraint) {
                 $constraint->aspectRatio();
                 $constraint->upsize();
             })->save($path);
             $setting->logo = $file_name;
         }
     }
     if (config('app.lock_passwords') == false) {
         $setting->site_name = e(Input::get('site_name'));
         $setting->brand = e(Input::get('brand'));
         $setting->custom_css = e(Input::get('custom_css'));
     }
     if (Input::get('per_page') != '') {
         $setting->per_page = e(Input::get('per_page'));
     } else {
         $setting->per_page = 200;
     }
     $setting->locale = e(Input::get('locale', 'en'));
     $setting->qr_code = e(Input::get('qr_code', '0'));
     $setting->full_multiple_companies_support = e(Input::get('full_multiple_companies_support', '0'));
     $setting->alt_barcode = e(Input::get('alt_barcode'));
     $setting->alt_barcode_enabled = e(Input::get('alt_barcode_enabled', '0'));
     $setting->barcode_type = e(Input::get('barcode_type'));
     $setting->load_remote = e(Input::get('load_remote', '0'));
     $setting->default_currency = e(Input::get('default_currency', '$'));
     $setting->qr_text = e(Input::get('qr_text'));
     $setting->auto_increment_prefix = e(Input::get('auto_increment_prefix'));
     $setting->auto_increment_assets = e(Input::get('auto_increment_assets', '0'));
     $setting->zerofill_count = e(Input::get('zerofill_count'));
     $setting->alert_interval = e(Input::get('alert_interval'));
     $setting->alert_threshold = e(Input::get('alert_threshold'));
     $setting->email_domain = e(Input::get('email_domain'));
     $setting->email_format = e(Input::get('email_format'));
     $setting->username_format = e(Input::get('username_format'));
     $setting->labels_per_page = e(Input::get('labels_per_page'));
     $setting->labels_width = e(Input::get('labels_width'));
     $setting->labels_height = e(Input::get('labels_height'));
     $setting->labels_pmargin_left = e(Input::get('labels_pmargin_left'));
     $setting->labels_pmargin_right = e(Input::get('labels_pmargin_right'));
     $setting->labels_pmargin_top = e(Input::get('labels_pmargin_top'));
     $setting->labels_pmargin_bottom = e(Input::get('labels_pmargin_bottom'));
     $setting->labels_display_bgutter = e(Input::get('labels_display_bgutter'));
     $setting->labels_display_sgutter = e(Input::get('labels_display_sgutter'));
     $setting->labels_fontsize = e(Input::get('labels_fontsize'));
     $setting->labels_pagewidth = e(Input::get('labels_pagewidth'));
     $setting->labels_pageheight = e(Input::get('labels_pageheight'));
     if (Input::has('labels_display_name')) {
         $setting->labels_display_name = 1;
     } else {
         $setting->labels_display_name = 0;
     }
     if (Input::has('labels_display_serial')) {
         $setting->labels_display_serial = 1;
     } else {
         $setting->labels_display_serial = 0;
     }
     if (Input::has('labels_display_tag')) {
         $setting->labels_display_tag = 1;
     } else {
         $setting->labels_display_tag = 0;
     }
     $alert_email = rtrim(Input::get('alert_email'), ',');
     $alert_email = trim(Input::get('alert_email'));
     $setting->alert_email = e($alert_email);
     $setting->alerts_enabled = e(Input::get('alerts_enabled', '0'));
     $setting->header_color = e(Input::get('header_color'));
     $setting->default_eula_text = e(Input::get('default_eula_text'));
     $setting->slack_endpoint = e(Input::get('slack_endpoint'));
     $setting->slack_channel = e(Input::get('slack_channel'));
     $setting->slack_botname = e(Input::get('slack_botname'));
     $setting->ldap_enabled = e(Input::get('ldap_enabled', '0'));
     $setting->ldap_server = e(Input::get('ldap_server'));
     $setting->ldap_server_cert_ignore = e(Input::get('ldap_server_cert_ignore', false));
     $setting->ldap_uname = e(Input::get('ldap_uname'));
     if (Input::has('ldap_pword')) {
         $setting->ldap_pword = Crypt::encrypt(Input::get('ldap_pword'));
     }
     $setting->ldap_basedn = e(Input::get('ldap_basedn'));
     $setting->ldap_filter = Input::get('ldap_filter');
     $setting->ldap_username_field = Input::get('ldap_username_field');
     $setting->ldap_lname_field = e(Input::get('ldap_lname_field'));
     $setting->ldap_fname_field = e(Input::get('ldap_fname_field'));
     $setting->ldap_auth_filter_query = Input::get('ldap_auth_filter_query');
     $setting->ldap_version = e(Input::get('ldap_version'));
     $setting->ldap_active_flag = e(Input::get('ldap_active_flag'));
     $setting->ldap_emp_num = e(Input::get('ldap_emp_num'));
     $setting->ldap_email = e(Input::get('ldap_email'));
     $setting->ad_domain = e(Input::get('ad_domain'));
     $setting->is_ad = e(Input::get('is_ad', '0'));
     $setting->ldap_tls = e(Input::get('ldap_tls', '0'));
     $setting->ldap_pw_sync = e(Input::get('ldap_pw_sync', '0'));
     // If validation fails, we'll exit the operation now.
     if ($setting->save()) {
         return redirect()->to("admin/settings/app")->with('success', trans('admin/settings/message.update.success'));
     } else {
         return redirect()->back()->withInput()->withErrors($setting->getErrors());
     }
     // Redirect to the setting management page
     return redirect()->to("admin/settings/app/edit")->with('error', trans('admin/settings/message.update.error'));
 }
예제 #9
0
 /**
  * Exports the depreciations to CSV
  *
  * @deprecated Server-side exports have been replaced by datatables export since v2.
  * @author [A. Gianotto] [<*****@*****.**>]
  * @since [v1.0]
  * @return \Illuminate\Http\Response
  */
 public function exportDeprecationReport()
 {
     // Grab all the assets
     $assets = Asset::with('model', 'assigneduser', 'assetstatus', 'defaultLoc', 'assetlog')->orderBy('created_at', 'DESC')->get();
     $csv = \League\Csv\Writer::createFromFileObject(new \SplTempFileObject());
     $csv->setOutputBOM(Reader::BOM_UTF16_BE);
     $rows = [];
     // Create the header row
     $header = [trans('admin/hardware/table.asset_tag'), trans('admin/hardware/table.title'), trans('admin/hardware/table.serial'), trans('admin/hardware/table.checkoutto'), trans('admin/hardware/table.location'), trans('admin/hardware/table.purchase_date'), trans('admin/hardware/table.purchase_cost'), trans('admin/hardware/table.book_value'), trans('admin/hardware/table.diff')];
     //we insert the CSV header
     $csv->insertOne($header);
     // Create a row per asset
     foreach ($assets as $asset) {
         $row = [];
         $row[] = e($asset->asset_tag);
         $row[] = e($asset->name);
         $row[] = e($asset->serial);
         if ($asset->assigned_to > 0) {
             $user = User::find($asset->assigned_to);
             $row[] = e($user->fullName());
         } else {
             $row[] = '';
             // Empty string if unassigned
         }
         if ($asset->assigned_to > 0 && $asset->assigneduser->location_id > 0) {
             $location = Location::find($asset->assigneduser->location_id);
             if ($location->city) {
                 $row[] = e($location->city) . ', ' . e($location->state);
             } elseif ($location->name) {
                 $row[] = e($location->name);
             } else {
                 $row[] = '';
             }
         } else {
             $row[] = '';
             // Empty string if location is not set
         }
         if ($asset->assetloc) {
             $currency = e($asset->assetloc->currency);
         } else {
             $currency = e(Setting::first()->default_currency);
         }
         $row[] = $asset->purchase_date;
         $row[] = $currency . Helper::formatCurrencyOutput($asset->purchase_cost);
         $row[] = $currency . Helper::formatCurrencyOutput($asset->getDepreciatedValue());
         $row[] = $currency . Helper::formatCurrencyOutput($asset->purchase_cost - $asset->getDepreciatedValue());
         $csv->insertOne($row);
     }
     $csv->output('depreciation-report-' . date('Y-m-d') . '.csv');
     die;
 }
예제 #10
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     return Setting::first();
 }
예제 #11
0
 /**
  * Validates and stores a new location created via the Create Asset form modal.
  *
  * @todo Check if a Form Request would work better here.
  * @author [A. Gianotto] [<*****@*****.**>]
  * @see AssetsController::getCreate() method that makes the form
  * @since [v1.0]
  * @return String JSON
  */
 public function store()
 {
     $new['currency'] = Setting::first()->default_currency;
     // create a new location instance
     $location = new Location();
     // Save the location data
     $location->name = e(Input::get('name'));
     $location->currency = Setting::first()->default_currency;
     //e(Input::get('currency'));
     $location->address = '';
     //e(Input::get('address'));
     // $location->address2			= e(Input::get('address2'));
     $location->city = e(Input::get('city'));
     $location->state = '';
     //e(Input::get('state'));
     $location->country = e(Input::get('country'));
     // $location->zip    			= e(Input::get('zip'));
     $location->user_id = Auth::user()->id;
     // Was the location created?
     if ($location->save()) {
         return JsonResponse::create($location);
     }
     // failure
     $errors = $location->errors();
     return JsonResponse::create(["error" => "Failed validation: " . print_r($location->getErrors(), true)], 500);
 }