119 lines
3.6 KiB
PHP
119 lines
3.6 KiB
PHP
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: k
|
|
* Date: 10.02.2017
|
|
* Time: 20:10
|
|
*/
|
|
|
|
namespace App\Http\Controllers;
|
|
set_time_limit(-1);
|
|
|
|
use App\Paper\Paper;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Http\Request;
|
|
|
|
class Settings extends Controller
|
|
{
|
|
|
|
private $paper = null;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->paper = new Paper();
|
|
}
|
|
|
|
/**
|
|
* get:/
|
|
* @param Request $request
|
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
|
*/
|
|
public function mainView(Request $request)
|
|
{
|
|
|
|
$keyboard = DB::select('SELECT * FROM keyboard');
|
|
return view('settings', [
|
|
'keyboard' => $keyboard,
|
|
'actions' => $this->getActions()
|
|
]);
|
|
}
|
|
|
|
public function getMappedKeys()
|
|
{
|
|
$keys = DB::table('keyboard')->get();
|
|
$text = '';
|
|
$actions = $this->getActions('');
|
|
foreach ($keys as $key) {
|
|
$text .= '[' . $key->key . '] ' . $actions[$key->action] . "\n";
|
|
}
|
|
return $text;
|
|
}
|
|
|
|
public function printMappedKeys()
|
|
{
|
|
$this->paper->sendPrint('Zmapowane klawisze', $this->getMappedKeys());
|
|
}
|
|
|
|
public function save(Request $request)
|
|
{
|
|
foreach ($request->input('key') as $keyid => $keyValue) {
|
|
DB::table('keyboard')
|
|
->where('id', $keyid)
|
|
->update([
|
|
'action' => $keyValue,
|
|
]);
|
|
}
|
|
return redirect()->route('settingsList');
|
|
}
|
|
|
|
private function getActions($noActionText = 'Bez akcji')
|
|
{
|
|
$actions = [];
|
|
$actions[''] = $noActionText;
|
|
|
|
$actions['separator0'] = 'separator';
|
|
|
|
$actions['settings_list'] = 'Lista zmapowanych klawiszy';
|
|
|
|
$actions['separator1'] = 'separator';
|
|
|
|
$actions['repertoire_all_today'] = 'Repertuar wszystkie kina dzisiaj';
|
|
$actions['repertoire_all_tomorrow'] = 'Repertuar wszystkie kina jutro';
|
|
|
|
$actions['repertoire_helios_today'] = 'Repertuar Helios dzisiaj';
|
|
$actions['repertoire_helios_tomorrow'] = 'Repertuar Helios jutro';
|
|
|
|
$actions['repertoire_multikino_today'] = 'Repertuar Multikino dzisiaj';
|
|
$actions['repertoire_multikino_tomorrow'] = 'Repertuar Multikino jutro';
|
|
|
|
$actions['repertoire_cinemacity_today'] = 'Repertuar Cinema-City dzisiaj';
|
|
$actions['repertoire_cinemacity_tomorrow'] = 'Repertuar Cinema-City jutro';
|
|
|
|
$actions['repertoire_gdynskiecentrumfilmowe_today'] = 'Repertuar Gdyńskie Centrum filmowe dzisiaj';
|
|
$actions['repertoire_gdynskiecentrumfilmowe_tomorrow'] = 'Repertuar Gdyńskie Centrum filmowe jutro';
|
|
|
|
$actions['separator2'] = 'separator';
|
|
$actions['airly_all'] = 'Airly wszystkie stacje';
|
|
$actions['airly_rzeczypospolitej'] = 'Airly (Rzeczypospolitej)';
|
|
$actions['airly_grunwaldzka'] = 'Airly (Grunwaldzka)';
|
|
$actions['airly_sowinskiego'] = 'Airly (Sowińskiego)';
|
|
|
|
// $actions['separator3'] = 'separator';
|
|
// $actions['spacex_next_flight'] = 'Najbliższy lot SpaceX';
|
|
// $actions['spacex_prev_flight'] = 'Poprzedni lot SpaceX';
|
|
// $actions['spacex_all_next_summary'] = 'Wszystkie zaplanowane loty SpaceX (skrót)';
|
|
|
|
$actions['separator4'] = 'separator';
|
|
$actions['note_last'] = 'Ostatnia zapisana notatka';
|
|
|
|
|
|
$actions['separator5'] = 'separator';
|
|
|
|
$notes = DB::select('SELECT * FROM note WHERE type = "note" ORDER BY updated_at DESC');
|
|
foreach ($notes as $note) {
|
|
$actions['note_' . $note->id] = 'Notatka: ' . $note->topic;
|
|
}
|
|
return $actions;
|
|
}
|
|
|
|
} |