2.2 - added new Template and Template selection

environments/production/deployments/9
Theenoro 2019-05-03 21:20:24 +02:00
parent c7271e3c22
commit 251b33fb53
9 changed files with 1174 additions and 36 deletions

View File

@ -23,6 +23,6 @@
"build": "react-scripts build", "build": "react-scripts build",
"test": "react-scripts test --env=jsdom", "test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject", "eject": "react-scripts eject",
"less": "less-watch-compiler ./src_less ./public/ main.less" "less": "npx less-watch-compiler ./src_less ./public/ main.less"
} }
} }

View File

@ -1,3 +1,8 @@
select {
padding: 5px;
height: 34px;
box-sizing: border-box;
}
@font-face { @font-face {
font-family: 'Exo'; font-family: 'Exo';
font-style: normal; font-style: normal;

File diff suppressed because it is too large Load Diff

View File

@ -5,50 +5,63 @@ export class Templates{
static template = { static template = {
header:"", header:"",
wochenbericht:"", wochenbericht:"",
wochenbericht_2:"",
monatsbericht:"", monatsbericht:"",
arbeitszeiten:"", arbeitszeiten:"",
footer:"" footer:""
}; };
static getTemplates(){ static getTemplates(){
axios.get('/templates/header.ptt') axios.get('/templates/header.ptt')
.then ((result) => { .then ((result) => {
Templates.template.header = result.data; Templates.template.header = result.data;
}) })
.catch ((error) => { .catch ((error) => {
console.log(error); console.log(error);
}) })
axios.get('/templates/wochenbericht.ptt') axios.get('/templates/wochenbericht.ptt')
.then ((result) => { .then ((result) => {
Templates.template.wochenbericht = result.data;
})
.catch ((error) => {
console.log(error);
})
axios.get('/templates/wochenbericht_2.ptt')
.then ((result) => {
Templates.template.wochenbericht_2 = result.data;
})
.catch ((error) => {
console.log(error);
})
Templates.template.wochenbericht = result.data;
})
.catch ((error) => {
console.log(error);
})
axios.get('/templates/monatsbericht.ptt') axios.get('/templates/monatsbericht.ptt')
.then ((result) => { .then ((result) => {
Templates.template.monatsbericht = result.data; Templates.template.monatsbericht = result.data;
}) })
.catch ((error) => { .catch ((error) => {
console.log(error); console.log(error);
}) })
axios.get('/templates/arbeitszeiten.ptt') axios.get('/templates/arbeitszeiten.ptt')
.then ((result) => { .then ((result) => {
Templates.template.arbeitszeiten = result.data; Templates.template.arbeitszeiten = result.data;
}) })
.catch ((error) => { .catch ((error) => {
console.log(error); console.log(error);
}) })
axios.get('/templates/footer.ptt') axios.get('/templates/footer.ptt')
.then ((result) => { .then ((result) => {
Templates.template.footer = result.data; Templates.template.footer = result.data;
}) })
.catch ((error) => { .catch ((error) => {
console.log(error); console.log(error);
}) })
} }
printTimes(){ printTimes(){
return `` return ``

View File

@ -18,12 +18,14 @@ export class Print extends React.Component {
startWeek:0, startWeek:0,
endWeek:0, endWeek:0,
diff:0, diff:0,
html:"" html:"",
choosenTemplate:"wochenbericht"
} }
this.preview = this.preview.bind(this); this.preview = this.preview.bind(this);
this.print = this.print.bind(this); this.print = this.print.bind(this);
this.handleChangeStart = this.handleChangeStart.bind(this); this.handleChangeStart = this.handleChangeStart.bind(this);
this.handleChangeEnd = this.handleChangeEnd.bind(this); this.handleChangeEnd = this.handleChangeEnd.bind(this);
this.handleChangeTemplate = this.handleChangeTemplate.bind(this);
Templates.getTemplates() Templates.getTemplates()
} }
preview(){ preview(){
@ -33,7 +35,7 @@ export class Print extends React.Component {
var start = moment(this.state.start); var start = moment(this.state.start);
var end = moment(this.state.end); var end = moment(this.state.end);
var me = this; var me = this;
Modi_Week.preview(name,anfang,start,end,me) Modi_Week.preview(name,anfang,start,end,me,this.state.choosenTemplate)
} }
print(){ print(){
@ -65,6 +67,9 @@ export class Print extends React.Component {
this.setState({diff:diff}); this.setState({diff:diff});
console.log(diff); console.log(diff);
} }
handleChangeTemplate(e){
this.setState({choosenTemplate: e.target.value});
}
render(){ render(){
return ( return (
@ -75,6 +80,11 @@ export class Print extends React.Component {
</div> </div>
<div>Start: <input type="date" value={this.state.start} onChange={this.handleChangeStart}/></div> <div>Start: <input type="date" value={this.state.start} onChange={this.handleChangeStart}/></div>
<div>Ende: <input type="date" value={this.state.end} onChange={this.handleChangeEnd}/></div> <div>Ende: <input type="date" value={this.state.end} onChange={this.handleChangeEnd}/></div>
<div>Vorlage: <select value={this.state.choosenTemplate} onChange={this.handleChangeTemplate}>
<option selected value="wochenbericht">Wochenbericht 1</option>
<option value="wochenbericht_2">Wochenbericht 2</option>
</select>
</div>
<div><button onClick={this.preview}>Vorschau</button><button onClick={this.print}>Drucken</button></div> <div><button onClick={this.preview}>Vorschau</button><button onClick={this.print}>Drucken</button></div>
</div> </div>
<iframe id="pdf" title="PDF OUTPUT"> <iframe id="pdf" title="PDF OUTPUT">

View File

@ -5,7 +5,16 @@ const moment = require('moment');
const nunjucks = require('nunjucks'); const nunjucks = require('nunjucks');
export class Modi_Week{ export class Modi_Week{
static preview(name,anfang,start,end,me){ /**
*
* @param {*} name
* @param {*} anfang
* @param {*} start
* @param {*} end
* @param {*} me
* @param {*} choosenTemplate
*/
static preview(name,anfang,start,end,me,choosenTemplate){
var sql = 'SELECT * FROM days WHERE date BETWEEN '+(moment(me.state.start).unix()*1000)+' AND '+(moment(me.state.end).unix()*1000); var sql = 'SELECT * FROM days WHERE date BETWEEN '+(moment(me.state.start).unix()*1000)+' AND '+(moment(me.state.end).unix()*1000);
var days = DB.cdb.exec(sql); var days = DB.cdb.exec(sql);
//for(var result = []; days.step();) result.push(days.getAsObject({':start':me.state.start,':end':me.state.end})); //for(var result = []; days.step();) result.push(days.getAsObject({':start':me.state.start,':end':me.state.end}));
@ -91,7 +100,13 @@ export class Modi_Week{
} }
} }
} }
var build = Templates.template.header+Templates.template.wochenbericht+Templates.template.footer;
/**
* @INFO
* Putting all Templates together for the print
*/
var build = Templates.template.header+Templates.template[choosenTemplate]+Templates.template.footer;
var html = nunjucks.renderString(build, {name:name,weeks:weeks}); var html = nunjucks.renderString(build, {name:name,weeks:weeks});

View File

@ -0,0 +1,5 @@
select{
padding: 5px;
height: 34px;
box-sizing: border-box;
}

View File

@ -3,6 +3,8 @@
@color:#ffffff; @color:#ffffff;
@import './form_elements.less';
@font-face { @font-face {
font-family: 'Exo'; font-family: 'Exo';
font-style: normal; font-style: normal;
@ -18,6 +20,8 @@ html,body{
*{ *{
} }
#container{ #container{
display: flex; display: flex;
} }

View File

@ -1,5 +1,5 @@
#print-frame{ #print-frame{
.header{ .header{
height:98px; height:98px;
background-color: @background; background-color: @background;