diff --git a/app/Http/Controllers/AirlyController.php b/app/Http/Controllers/AirlyController.php new file mode 100644 index 0000000..9509557 --- /dev/null +++ b/app/Http/Controllers/AirlyController.php @@ -0,0 +1,93 @@ +paper = new Paper(); + } + + /** + * get:/airly_all + * @return \Illuminate\Http\RedirectResponse + */ + public function airly_all() + { + $airly = new Airly(); + $this->paper->sendImagePrint($airly->icon); + $this->paper->sendHeaderPrint('Jakość powietrza:' . PHP_EOL . date('H:i d-m-Y')); + $airly->setStations(config('paper.airly.stations')); + + foreach ($airly->getStations() as $stationId) { + $stationInfo = $airly->getStationInfo($stationId); + $this->paper->sendHeaderPrint($stationInfo['address']['locality'] . ' ' . $stationInfo['address']['route']); + $dataText = $airly->getInformationText($stationId); + $this->paper->sendPrint('', $dataText); + } + return back(); + } + + public function airly_rzeczypospolitej() + { + $airly = new Airly(); + $this->paper->sendImagePrint($airly->icon); + $this->paper->sendHeaderPrint('Jakość powietrza:' . PHP_EOL . date('H:i d-m-Y')); + $airly->setStations([config('paper.airly.rzeczypospolitej')]); + + foreach ($airly->getStations() as $stationId) { + $stationInfo = $airly->getStationInfo($stationId); + $this->paper->sendHeaderPrint($stationInfo['address']['locality'] . ' ' . $stationInfo['address']['route']); + $dataText = $airly->getInformationText($stationId); + $this->paper->sendPrint('', $dataText); + } + return back(); + } + + public function airly_grunwaldzka() + { + $airly = new Airly(); + $this->paper->sendImagePrint($airly->icon); + $this->paper->sendHeaderPrint('Jakość powietrza:' . PHP_EOL . date('H:i d-m-Y')); + $airly->setStations([config('paper.airly.grunwaldzka')]); + + foreach ($airly->getStations() as $stationId) { + $stationInfo = $airly->getStationInfo($stationId); + $this->paper->sendHeaderPrint($stationInfo['address']['locality'] . ' ' . $stationInfo['address']['route']); + $dataText = $airly->getInformationText($stationId); + $this->paper->sendPrint('', $dataText); + } + return back(); + } + + public function airly_sowinskiego() + { + $airly = new Airly(); + $this->paper->sendImagePrint($airly->icon); + $this->paper->sendHeaderPrint('Jakość powietrza:' . PHP_EOL . date('H:i d-m-Y')); + $airly->setStations([config('paper.airly.sowinskiego')]); + + foreach ($airly->getStations() as $stationId) { + $stationInfo = $airly->getStationInfo($stationId); + $this->paper->sendHeaderPrint($stationInfo['address']['locality'] . ' ' . $stationInfo['address']['route']); + $dataText = $airly->getInformationText($stationId); + $this->paper->sendPrint('', $dataText); + } + return back(); + } +} \ No newline at end of file diff --git a/app/Http/Controllers/Keyboard.php b/app/Http/Controllers/Keyboard.php index 03bd82c..dde4ef1 100644 --- a/app/Http/Controllers/Keyboard.php +++ b/app/Http/Controllers/Keyboard.php @@ -2,25 +2,127 @@ namespace App\Http\Controllers; -use App\Paper\CinemaMultikino; -use DiDom\Query; -use Illuminate\Http\Request; -use DiDom\Document; use App\Paper\Paper; +use Illuminate\Http\Request; +use Illuminate\Support\Facades\DB; class Keyboard extends Controller { - - private $paper; - - public function __construct() + public function press(Request $request, $key) { - $this->paper = new Paper(); - } - public function press($key) - { - $this->paper->sendPrint($key); + $keyboardData = DB::table('keyboard')->where('key', $key)->first(); + + if (isset($keyboardData) && isset($keyboardData->action)) { + + + $keyboardAction = explode('_', $keyboardData->action); + + switch ($keyboardAction[0]) { + case 'settings': + $settings = new Settings(); + $settings->printMappedKeys(); + + break; + case 'airly': + $airly = new AirlyController(); + switch ($keyboardAction[1]) { + case 'all': + $airly->airly_all(); + break; + case 'rzeczypospolitej': + $airly->airly_rzeczypospolitej(); + break; + case 'grunwaldzka': + $airly->airly_grunwaldzka(); + break; + case 'sowinskiego': + $airly->airly_sowinskiego(); + break; + } + break; + case 'note': + switch ($keyboardAction[1]) { + case 'last': + $main = new Main(); + $main->noteLast(); + + break; + case $keyboardAction[1] > 0: + echo 'test'; + $main = new Main(); + $main->printNote((int)$keyboardAction[1]); + break; + } + break; + case 'repertoire': + switch ($keyboardAction[1]) { + case 'all': + switch ($keyboardAction[2]) { + case 'today': + $repertoire = new Repertoire(); + $repertoire->today_repertoire($request); + break; + case 'tomorrow': + $repertoire = new Repertoire(); + $repertoire->tomorrow_repertoire($request); + break; + } + break; + case 'helios': + switch ($keyboardAction[2]) { + case 'today': + $repertoire = new Repertoire(); + $repertoire->today_helios($request); + break; + case 'tomorrow': + $repertoire = new Repertoire(); + $repertoire->tomorrow_helios($request); + break; + } + break; + case 'multikino': + switch ($keyboardAction[2]) { + case 'today': + $repertoire = new Repertoire(); + $repertoire->today_multikino($request); + break; + case 'tomorrow': + $repertoire = new Repertoire(); + $repertoire->tomorrow_multikino($request); + break; + } + break; + case 'cinemacity': + switch ($keyboardAction[2]) { + case 'today': + $repertoire = new Repertoire(); + $repertoire->today_cinemacity($request); + break; + case 'tomorrow': + $repertoire = new Repertoire(); + $repertoire->tomorrow_cinemacity($request); + break; + } + break; + case 'gdynskiecentrumfilmowe': + switch ($keyboardAction[2]) { + case 'today': + $repertoire = new Repertoire(); + $repertoire->today_gdynskiecentrumfilmowe($request); + break; + case 'tomorrow': + $repertoire = new Repertoire(); + $repertoire->tomorrow_gdynskiecentrumfilmowe($request); + break; + } + break; + } + break; + } + } + + } } diff --git a/app/Http/Controllers/Main.php b/app/Http/Controllers/Main.php index ef8d840..7d998af 100755 --- a/app/Http/Controllers/Main.php +++ b/app/Http/Controllers/Main.php @@ -34,6 +34,7 @@ class Main extends Controller * post::/printImage * @param Request $request * @return \Illuminate\Http\RedirectResponse + * @throws \Exception */ public function imagePrint(Request $request) { @@ -138,28 +139,6 @@ class Main extends Controller ]); } - /** - * get:/airly - * @param Request $request - * @return \Illuminate\Http\RedirectResponse - */ - public function airly(Request $request) - { - $airly = new Airly(); - $this->paper->sendImagePrint($airly->icon); - $this->paper->sendHeaderPrint('Jakość powietrza:' . PHP_EOL . date('H:i d-m-Y')); - $airly->setStations(config('paper.airly.stations')); - - foreach ($airly->getStations() as $stationId) { - $stationInfo = $airly->getStationInfo($stationId); - $this->paper->sendHeaderPrint($stationInfo['address']['locality'] . ' ' . $stationInfo['address']['route']); - $dataText = $airly->getInformationText($stationId); - $this->paper->sendPrint('', $dataText); - } - return back(); - - } - /** * post::/print/{id} * @param Request $request @@ -168,15 +147,24 @@ class Main extends Controller */ public function printText(Request $request, $id) { - $note = DB::table('note')->where('id', $id)->first(); - $this->paper->sendPrint($note->topic, $note->text, $note->icon); + $note = $this->printNote($id); $request->session()->flash('print_status', 'Wydrukowano notatkę: ' . $note->topic . '!'); return back(); } + public function printNote($noteId){ + $note = DB::table('note')->where('id', $noteId)->first(); + $this->paper->sendPrint($note->topic, $note->text, $note->icon); + return $note; + } + + public function noteLast(){ + $note = DB::table('note')->orderBy('id', 'desc')->first(); + $this->printNote($note->id); + } + private function templateReplace($input) { - return str_replace(['[d]', '[m]', '[y]', '[h]', '[i]', '[s]'], [date('d'), date('m'), date('Y'), date('H'), date('i'), date('s')], $input); diff --git a/app/Http/Controllers/Settings.php b/app/Http/Controllers/Settings.php new file mode 100644 index 0000000..1e519d3 --- /dev/null +++ b/app/Http/Controllers/Settings.php @@ -0,0 +1,119 @@ +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; + } + +} \ No newline at end of file diff --git a/app/Paper/Airly.php b/app/Paper/Airly.php index aa30ed4..0b15828 100644 --- a/app/Paper/Airly.php +++ b/app/Paper/Airly.php @@ -24,7 +24,7 @@ class Airly return $this->stations; } - public function setStations($stations){ + public function setStations(array $stations){ $this->stations = $stations; } diff --git a/app/Paper/CinemaCinemaCity.php b/app/Paper/CinemaCinemaCity.php index 4e23d9c..10e9276 100644 --- a/app/Paper/CinemaCinemaCity.php +++ b/app/Paper/CinemaCinemaCity.php @@ -26,9 +26,6 @@ class CinemaCinemaCity implements Cinema if (is_null($this->cinemaId) || is_null($this->day)) throw new \Exception('Day or cinemaid not set.'); -// if (!is_array($this->cinemaId)) { -// $this->cinemaId = (array)$this->cinemaId; -// } $url = 'https://www.cinema-city.pl/pgm-list-byfeat?si=' . $this->cinemaId . '&sort=cin&bd=' . $this->day; return file_get_contents($url); @@ -41,9 +38,6 @@ class CinemaCinemaCity implements Cinema $document = json_decode($document); -// $cinemaData = []; -// $text = "Repertuar Cinema-City\n"; -// $text .= str_replace('/', '-', $this->day) . "\n\n"; $movies = []; $date = date('d/m/Y', strtotime($this->day)); @@ -55,9 +49,6 @@ class CinemaCinemaCity implements Cinema foreach ($movieData->BD as $projections) { if ($projections->date == $date) { foreach ($projections->P as $projection) { - -// var_dump($projection); -// die(); $movie['hours'][] = $projection->time; } } diff --git a/config/paper.php b/config/paper.php index 5b22075..d7def05 100644 --- a/config/paper.php +++ b/config/paper.php @@ -11,5 +11,8 @@ return ['airly' => [ 'api_key' => '8b6d77b2950e4e018b0684912bf7b9ed', 'stations' => ['2210', '2256', '2180'], + 'rzeczypospolitej' => 2210, + 'grunwaldzka' => 2256, + 'sowinskiego' => 2180, ] ]; diff --git a/public/css/app.css b/public/css/app.css index 9117651..0917f74 100755 --- a/public/css/app.css +++ b/public/css/app.css @@ -28,6 +28,21 @@ form { display: none; } +.flex { + display: flex; + align-items: center; +} +.flex.space-between { + justify-content: space-between; +} +.flex.header { + margin-bottom: 1rem; +} + +.flex .header { + margin-bottom: 0; +} + .icon { cursor: pointer; height: 25px; @@ -55,342 +70,455 @@ form { height: 29px; margin: 0; } + .icon.address-card-o { background-position-x: -0px; } + .icon.anchor { background-position-x: -25px; } + .icon.archive-3 { background-position-x: -50px; } + .icon.at { background-position-x: -75px; } + .icon.balance-scale { background-position-x: -100px; } + .icon.ban { background-position-x: -125px; } + .icon.bar-chart-o { background-position-x: -150px; } + .icon.barcode { background-position-x: -175px; } + .icon.battery-empty { background-position-x: -200px; } + .icon.battery-full { background-position-x: -225px; } + .icon.battery-half { background-position-x: -250px; } + .icon.battery-quarter { background-position-x: -275px; } + .icon.battery-three-quarters { background-position-x: -300px; } + .icon.bed { background-position-x: -325px; } + .icon.beer { background-position-x: -350px; } + .icon.bell-o { background-position-x: -375px; } + .icon.bell-slash-o { background-position-x: -400px; } + .icon.bicycle { background-position-x: -425px; } + .icon.birthday-cake { background-position-x: -450px; } + .icon.bolt { background-position-x: -475px; } + .icon.bomb { background-position-x: -500px; } + .icon.book { background-position-x: -525px; } + .icon.bug { background-position-x: -550px; } + .icon.building-o { background-position-x: -575px; } + .icon.bullhorn { background-position-x: -600px; } + .icon.bus { background-position-x: -625px; } + .icon.camera { background-position-x: -650px; } + .icon.car { background-position-x: -675px; } + .icon.chain { background-position-x: -700px; } + .icon.chat-2 { background-position-x: -725px; } + .icon.check { background-position-x: -750px; } + .icon.cloud { background-position-x: -775px; } + .icon.code { background-position-x: -800px; } + .icon.coffee { background-position-x: -825px; } + .icon.cog { background-position-x: -850px; } + .icon.cutlery { background-position-x: -875px; } + .icon.dashboard { background-position-x: -900px; } + .icon.database { background-position-x: -925px; } + .icon.diamond { background-position-x: -950px; } + .icon.dollar { background-position-x: -975px; } + .icon.dribbble { background-position-x: -1000px; } + .icon.envelope-o { background-position-x: -1025px; } + .icon.envira { background-position-x: -1050px; } + .icon.exclamation-triangle { background-position-x: -1075px; } + .icon.female { background-position-x: -1100px; } + .icon.file-text-o { background-position-x: -1125px; } + .icon.film { background-position-x: -1150px; } + .icon.fingerprint { background-position-x: -1175px; } + .icon.fire-extinguisher { background-position-x: -1200px; } + .icon.fire { background-position-x: -1225px; } + .icon.flag-o { background-position-x: -1250px; } + .icon.flask { background-position-x: -1275px; } + .icon.floppy-o { background-position-x: -1300px; } + .icon.folder-o { background-position-x: -1325px; } + .icon.folder-open-o { background-position-x: -1350px; } + .icon.frown-o { background-position-x: -1375px; } + .icon.gamepad { background-position-x: -1400px; } + .icon.gift { background-position-x: -1425px; } + .icon.git { background-position-x: -1450px; } + .icon.glass { background-position-x: -1475px; } + .icon.graduation-cap { background-position-x: -1500px; } + .icon.grav { background-position-x: -1525px; } + .icon.group { background-position-x: -1550px; } + .icon.hand-o-left { background-position-x: -1575px; } + .icon.heart-o { background-position-x: -1600px; } + .icon.home { background-position-x: -1625px; } + .icon.lemon-o { background-position-x: -1650px; } + .icon.lightbulb-o { background-position-x: -1675px; } + .icon.list-alt { background-position-x: -1700px; } + .icon.location-arrow { background-position-x: -1725px; } + .icon.lock { background-position-x: -1750px; } + .icon.male { background-position-x: -1775px; } + .icon.map-1 { background-position-x: -1800px; } + .icon.map-marker { background-position-x: -1825px; } + .icon.microchip { background-position-x: -1850px; } + .icon.money { background-position-x: -1875px; } + .icon.moon-o { background-position-x: -1900px; } + .icon.music { background-position-x: -1925px; } + .icon.paper-plane { background-position-x: -1950px; } + .icon.paperclip { background-position-x: -1975px; } + .icon.paw { background-position-x: -2000px; } + .icon.pencil { background-position-x: -2025px; } + .icon.phone { background-position-x: -2050px; } + .icon.pie-chart { background-position-x: -2075px; } + .icon.piggy-bank { background-position-x: -2100px; } + .icon.plane { background-position-x: -2125px; } + .icon.question-circle-o { background-position-x: -2150px; } + .icon.rocket { background-position-x: -2175px; } + .icon.search { background-position-x: -2200px; } + .icon.ship { background-position-x: -2225px; } + .icon.shopping-cart { background-position-x: -2250px; } + .icon.smile-o { background-position-x: -2275px; } + .icon.snowflake-o { background-position-x: -2300px; } + .icon.steam { background-position-x: -2325px; } + .icon.subway { background-position-x: -2350px; } + .icon.success { background-position-x: -2375px; } + .icon.support { background-position-x: -2400px; } + .icon.thermometer-2 { background-position-x: -2425px; } + .icon.thumbs-o-down { background-position-x: -2450px; } + .icon.thumbs-o-up { background-position-x: -2475px; } + .icon.ticket { background-position-x: -2500px; } + .icon.times { background-position-x: -2525px; } + .icon.trash-o { background-position-x: -2550px; } + .icon.tree { background-position-x: -2575px; } + .icon.trophy { background-position-x: -2600px; } + .icon.truck { background-position-x: -2625px; } + .icon.umbrella { background-position-x: -2650px; } + .icon.usd { background-position-x: -2675px; } + .icon.warning { background-position-x: -2700px; } + .icon.wifi { background-position-x: -2725px; } + .icon.wpexplorer { background-position-x: -2750px; } + .icon.wrench { background-position-x: -2775px; } + .icon.youtube-play { background-position-x: -2800px; } \ No newline at end of file diff --git a/resources/views/form/create.blade.php b/resources/views/form/create.blade.php index 9cd0015..304dd3f 100644 --- a/resources/views/form/create.blade.php +++ b/resources/views/form/create.blade.php @@ -12,17 +12,11 @@ name="text">{{ $text }}