Prechádzať zdrojové kódy

Реализована возможность печатать отчёты

Вадим Королёв 1 rok pred
rodič
commit
6611c90845

+ 5 - 3
src/controllers/RegenController.php

@@ -8,11 +8,13 @@ class RegenController extends Controller {
 		$parts = explode("/", $this->request_uri);
 		$report_id = end($parts);
 		$report = ReportModel::getById($report_id);
+		$subject = SubjectModel::getById($report['subject_id']);
 
 		$view = new RegenEditView([
 			"page_title" => "Regen: редактирование отчёта",
-			"crumbs" => ["Главная"=>"/", "Regen" => "/"],
-			"markup" => $report['markup']
+			"crumbs" => ["Главная"=>"/", "Regen: редактирование отчёта" => "/"],
+			"markup" => $report['markup'],
+			"filename" => $subject['name']." #".$report['work_number']." - Королёв"
 		]);
 		$view->view();
 	}
@@ -63,7 +65,7 @@ class RegenController extends Controller {
 			'subjects' => $subjects,
 			'worktypes' => $worktypes,
 			'error_text' => $error_text,
-			"crumbs" => ["Главная"=>"/", "Regen" => "/"]
+			"crumbs" => ["Главная"=>"/", "Regen: создание отчёта" => "/"]
 		]);
 		$view->view();
 	}

+ 22 - 9
src/css/pockit.css

@@ -21,15 +21,14 @@
 	--accent: #396690;
 }
 
-@font-face {
-	font-family: 'Finlandica';
-	src: url('/fonts/Finlandica-Regular.otf')
-} 
+@font-face{font-family:'lato'; src: url('/fonts/Lato-Bold.ttf') format('truetype'); font-weight: bold; font-style: normal;}
+@font-face{font-family:'lato'; src: url('/fonts/Lato-BoldItalic.ttf') format('truetype'); font-weight:bold; font-style: italic;}
+@font-face{font-family:'lato'; src: url('/fonts/Lato-Regular.ttf') format('truetype'); font-weight:normal; font-style: normal;}
 
 body {
 	background-color: var(--gray-1);
 	color: var(--gray-8);
-	font-family: 'Finlandica';
+	font-family: 'lato';
 	font-size: 18px;
 	margin: 0;
 }
@@ -74,18 +73,26 @@ nav {
 
 /* End Forms */
 
-
 /* Buttons */
 button,
 input {
 	background-color: var(--gray-4);
 	border: 1px solid var(--gray-5);
-	padding: 0.25em;
-	color: var(--gray-6);
+	padding: 0.5em;
+	color: var(--gray-9);
 	font-size: 1rem;
 	border-radius: 5px;
 }
 
+button:hover {
+	background-color: var(--gray-6);
+}
+
+button:active,
+button:focus {
+	background-color: var(--gray-3);
+}
+
 .createbutton {
 	background-color: var(--success);
 	border-color: var(--successborder);
@@ -209,4 +216,10 @@ a:hover {
 	border-color: red;
 	color: #f9fbf8;
 }
-/* End Cards */
+/* End Cards */
+
+.filename {
+	user-select: all;
+	font-weight: bold;
+	text-decoration: underline;
+}

+ 22 - 3
src/css/regen-report.css

@@ -1,10 +1,12 @@
 #controls > textarea {
 	width: -moz-available;
 	resize: vertical;
-	background-color: #404040;
+	background-color: var(--gray-4);
 	outline: none;
 	border: 1px solid var(--card-border);
-	color: var(--fg);
+	color: var(--gray-8);
+	border-radius: 5px;
+	font-size: 1rem;
 }
 
 #control-buttons {
@@ -161,9 +163,26 @@ th {text-align:center !important;font-weight:normal}
 	nav,
 	#markuparea,
 	button,
-	#preview hr {
+	#preview hr,
+	#control-buttons,
+	.no-print {
 		display: none;
 	}
+	
+	#controls {
+		visibility: hidden;
+		width: auto;
+		margin: 0;
+		padding: 0;
+		max-width: unset;
+		border: none;
+		border-radius: 0px;
+	}
+
+	#preview {
+		display: block !important;
+		visibility: visible;
+	}
 
 	#preview .page-container {
 		padding: 0;

BIN
src/fonts/Finlandica-Black.otf


BIN
src/fonts/Finlandica-BlackItalic.otf


BIN
src/fonts/Finlandica-Bold.otf


BIN
src/fonts/Finlandica-BoldItalic.otf


BIN
src/fonts/Finlandica-ExtraBold.otf


BIN
src/fonts/Finlandica-ExtraBoldItalic.otf


BIN
src/fonts/Finlandica-ExtraLight.otf


BIN
src/fonts/Finlandica-ExtraLightItalic.otf


BIN
src/fonts/Finlandica-Italic.otf


BIN
src/fonts/Finlandica-Light.otf


BIN
src/fonts/Finlandica-LightItalic.otf


BIN
src/fonts/Finlandica-Medium.otf


BIN
src/fonts/Finlandica-MediumItalic.otf


BIN
src/fonts/Finlandica-Regular.otf


BIN
src/fonts/Finlandica-SemiBold.otf


BIN
src/fonts/Finlandica-SemiBoldItalic.otf


BIN
src/fonts/Finlandica-Thin.otf


BIN
src/fonts/Finlandica-ThinItalic.otf


BIN
src/fonts/Lato-Bold.ttf


BIN
src/fonts/Lato-BoldItalic.ttf


BIN
src/fonts/Lato-Regular.ttf


+ 94 - 0
src/fonts/OFL.txt

@@ -0,0 +1,94 @@
+Copyright (c) 2010-2015, Łukasz Dziedzic (dziedzic@typoland.com),
+with Reserved Font Name Lato.
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded, 
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.

+ 23 - 8
src/js/regenpreview.js

@@ -2,35 +2,50 @@
 // 0 - режим редактирования
 // 1 - режим просмотра превью
 var current_state = 0;
+var markup_area = $('#markuparea');
+var preview_area = $('#preview');
 
 $(document).ready(function() {
 	textAreaAdjust(document.getElementById("markuparea"));
 });
 
+$("#switchPreview").click(function() {
+	markup_area.hide();
+	preview_area.show();
+	updatePreview();
+});
+
+$("#switchMarkup").click(function() {
+	markup_area.show();
+	preview_area.hide();
+});
+
+$("#printReport").click(function() {
+
+	updatePreview(true);
+})
+
 // При печати текста заставляет textbox расширяться
 function textAreaAdjust(element) {
 	element.style.height = "1px";
 	element.style.height = (25+element.scrollHeight)+"px";
 }
 
-function updatePreview() {
-	let new_text = $("#markuparea").val();
-	if (new_text == old_text) {
-		return;
-	}
-	old_text = new_text;
-
+function updatePreview(then_print=false) {
 	const str = document.location.toString();
 	const slash_idx = str.lastIndexOf('/');
 	const report_id = str.substring(slash_idx + 1);
 	$.post(
 		"/regen/gethtml",
 		{
-			markup: new_text,
+			markup: markup_area.val(),
 			report_id: report_id
 		},
 		function (data, textStatus, xhr) {
 			$("#preview").html(data);
+			if (then_print) {
+				window.print();
+			}
 		}
 	);
 }

+ 7 - 2
src/views/RegenEditView.php

@@ -3,6 +3,7 @@
 
 class RegenEditView extends LayoutView {
 	protected $markup;
+	protected $filename;
 
 	public function customHead():void { ?>
 <link rel="stylesheet" href="/css/regen-report.css">
@@ -14,11 +15,15 @@ class RegenEditView extends LayoutView {
 	<div id='control-buttons'>
 		<button id='switchMarkup'>Разметка</button>
 		<button id='switchPreview'>Превью</button>
-		<button id='printReportButton' onclick="printReport()">Печать</button>
+		<button id="printReport">Печать</button>
 	</div>
 
 	<textarea onkeyup="textAreaAdjust(this)" id="markuparea" autocomplete="off"><?= $this->markup ?></textarea>
-	<div id="preview"></div>
+	<div style='display: none;' id="preview"></div>
+</div>
+
+<div class='card no-print'>
+	<p>Название файла: <span class='filename'><?= $this->filename ?></span></p>
 </div>
 
  

+ 1 - 1
src/views/RegenNewReportView.php

@@ -17,7 +17,7 @@ class RegenNewReportView extends LayoutView {
 <?php } ?>
 
 <form action="/regen/new" method="POST">
-	<div class="card" style='border-color: var(--accent)'>
+	<div class="card">
 		<div class="form-control-container">
 			<label for="sel-subject_id">Предмет</label>
 			<select class="form-control" id="sel-subject_id" name="subject_id">

+ 1 - 1
start.sh

@@ -1 +1 @@
-php -S localhost:9000 -t ./src ./src/index.php
+php -S 127.0.0.1:9000 -t ./src ./src/index.php