-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenpdf.sh
executable file
·48 lines (39 loc) · 1.16 KB
/
genpdf.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
#
# (c)2016 by Tim Rühsen
# quit on error
set -e
DBHOST=oms-4
custid=2
DATE1=$(date --date='1 month ago' +'01%m%y')
DATE2=$(date --date="$(date +'%d') days ago" +'%d%m%y')
XDATE1="20"${DATE1:4:2}${DATE1:2:2}${DATE1:0:2}
XDATE2="20"${DATE2:4:2}${DATE2:2:2}${DATE2:0:2}
echo $DATE1-$DATE2 $XDATE1-$XDATE2
# for testing
DATE1=010416
DATE2=300416
(
echo '<?php'
echo
echo '$orderId='\"RE/test/1\"\;
echo '$orderDate='\"$DATE1-$DATE2\"\;
echo
# generate receiver data (e.g. via mysql from a database)
echo '$receiver_company='\"Empfänger GmbH\"\;
echo '$receiver_name='\"- Buchhaltung -\"\;
echo '$receiver_street='\"Foo Straße 55b\"\;
echo '$receiver_postal='\"12345 Bar Stadt\"\;
echo '$receiver_country='\"\"\;
echo '$receiver_custid='777\;
echo
# generate invoice records here, as PHP array (Name, Description, Units, Price/Unit)
echo '$items = array('
echo ' new item(array("Admin", "DB Einrichtung, Aufwand in h", 6.5, 63.00)),'
echo ' new item(array("Beratung", "telefonische Beratung in h", 3.0, 50.00)),'
echo ');'
echo
echo '?>'
) >receiver.php
php5 -f invoice_a4.php >out.html
wkhtmltopdf -s A4 out.html out.pdf