Printing data on numpad key press, first version. Settings page for mapping key to actions.

This commit is contained in:
kplaczek
2018-05-06 21:03:42 +02:00
parent 283c5b905e
commit e5f44b92e4
12 changed files with 535 additions and 61 deletions

View File

@@ -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);