-
Notifications
You must be signed in to change notification settings - Fork 0
/
invoice.php
executable file
·180 lines (180 loc) · 6.52 KB
/
invoice.php
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<?php
session_start();
if(!isset($_POST['unox']) || $_POST['unox']!=$_SESSION['unox']) {sleep(2);exit;} // appel depuis uno.php
?>
<?php
include('../../config.php');
include('lang/lang.php');
if(!file_exists('../../data/invoice.json')) file_put_contents('../../data/invoice.json', '{}');
if(!file_exists('../../../files/invoice')) mkdir('../../../files/invoice');
// ********************* actions *************************************************************************
if(isset($_POST['action'])) {
switch ($_POST['action']) {
// ********************************************************************************************
case 'plugin': ?>
<div class="blocForm">
<h2>Invoice</h2>
<p><?php echo T_("Allows you to create an invoice with one or more predefined formats. PDF output."); ?></p>
<h3><?php echo T_("Setting"); ?></h3>
<table class="hForm">
<tr>
<td><label><?php echo T_("Invoice Header Image");?></label></td>
<td>
<input type="text" class="input" name="invoiceLogo" id="invoiceLogo" value="" />
<div class="bouton finder" style="margin-left:30px;" id="bFMarkdown" onClick="f_finder_select('invoiceLogo')" title="<?php echo T_("File manager");?>"><img src="<?php echo $_POST['udep']; ?>includes/img/finder.png" /></div>
</td>
<td><em><?php echo T_("Recommended size between 100px and 200px.");?></em></td>
</tr>
<tr>
<td style="vertical-align:middle"><label><?php echo T_("Business address");?></label></td>
<td>
<textarea class="input" style="width:350px" name="invoiceAddr" id="invoiceAddr" rows="7"></textarea>
</td>
<td><em><?php echo T_("Company information, right of the logo.");?></em></td>
</tr>
<tr>
<td><label><?php echo T_("Invoicing details");?></label></td>
<td>
<input type="text" class="input" name="invoiceComp" id="invoiceComp" value="" />
</td>
<td><em><?php echo T_("Invoicing supplement, displayed in italics below the table.");?></em></td>
</tr>
<tr>
<td style="vertical-align:middle"><label><?php echo T_("Invoice Footer");?></label></td>
<td>
<textarea class="input" style="width:350px" name="invoiceFoot" id="invoiceFoot" rows="7"></textarea>
</td>
<td></td>
</tr>
</table>
<div class="bouton fr" onClick="f_save_invoice();" title="<?php echo T_("Save settings");?>"><?php echo T_("Save");?></div>
<div class="clear"></div>
<hr />
<h3><?php echo T_("Test invoice"); ?></h3>
<table class="hForm">
<tr>
<td><label><?php echo T_("First name");?></label></td>
<td>
<input type="text" class="input" name="invoiceFname" id="invoiceFname" value="" />
</td>
<td></td>
</tr>
<tr>
<td><label><?php echo T_("Last name");?>*</label></td>
<td>
<input type="text" class="input" name="invoiceLname" id="invoiceLname" value="" />
</td>
<td></td>
</tr>
<tr>
<td><label><?php echo T_("Email");?></label></td>
<td>
<input type="text" class="input" name="invoiceEmail" id="invoiceEmail" value="" />
</td>
<td></td>
</tr>
<tr>
<td><label><?php echo T_("Address");?></label></td>
<td>
<input type="text" class="input" name="invoiceAdres" id="invoiceAdres" value="" />
</td>
<td></td>
</tr>
<tr>
<td><label><?php echo T_("Product");?>*</label></td>
<td>
<input type="text" class="input" name="invoiceProdu" id="invoiceProdu" value="" />
</td>
<td></td>
</tr>
<tr>
<td><label><?php echo T_("Product REF");?></label></td>
<td>
<input type="text" class="input" name="invoiceRef" id="invoiceRef" value="" />
</td>
<td></td>
</tr>
<tr>
<td><label><?php echo T_("Date");?></label></td>
<td>
<input type="text" class="input" name="invoiceDate" id="invoiceDate" value="" />
</td>
<td></td>
</tr>
<tr>
<td><label><?php echo T_("Price");?>*</label></td>
<td>
<input type="text" class="input" name="invoicePrice" id="invoicePrice" value="" />
</td>
<td></td>
</tr>
<tr>
<td><label><?php echo T_("Shipping price");?></label></td>
<td>
<input type="text" class="input" name="invoiceShip" id="invoiceShip" value="" />
</td>
<td></td>
</tr>
<tr>
<td><label><?php echo T_("Tax % (0 to 1)");?></label></td>
<td>
<input type="text" class="input" name="invoiceTax" id="invoiceTax" value="" />
</td>
<td><?php echo T_("Example for 20% : 0.2");?></td>
</tr>
<tr>
<td><label><?php echo T_("Currency");?></label></td>
<td>
<input type="text" class="input" name="invoiceCurr" id="invoiceCurr" value="" />
</td>
<td><?php echo T_("Default is EURO");?></td>
</tr>
<tr>
<td><label><?php echo T_("Payment method");?></label></td>
<td>
<input type="text" class="input" name="invoiceMetho" id="invoiceMetho" value="" />
</td>
<td></td>
</tr>
<tr>
<td><label><?php echo T_("File name");?></label></td>
<td>
<input type="text" class="input" name="invoiceFile" id="invoiceFile" value="" />
</td>
<td></td>
</tr>
</table>
<div class="bouton fr" onClick="f_test_invoice();" title="<?php echo T_("Test invoice");?>"><?php echo T_("Create PDF");?></div>
<div class="clear"></div>
</div>
<?php break;
// ********************************************************************************************
case 'save':
$a = array();
if(isset($_POST['logo'])) {
if(substr($_POST['logo'],0,5)=='/file') $a['logo'] = stripslashes(realpath(__DIR__ . '/../../..'.$_POST['logo']));
else $a['logo'] = $_POST['logo'];
}
if(isset($_POST['addr'])) $a['addr'] = strip_tags($_POST['addr']);
if(isset($_POST['comp'])) $a['comp'] = strip_tags($_POST['comp']);
if(isset($_POST['foot'])) $a['foot'] = strip_tags($_POST['foot']);
$out = json_encode($a);
if(file_put_contents('../../data/invoice.json', $out)) echo T_('Backup performed');
else echo '!'.T_('Impossible backup');
break;
// ********************************************************************************************
case 'test':
$invoice = array();
foreach($_POST as $k=>$v) if($k!='action' && $k!='unox') $invoice[$k] = strip_tags(preg_replace("/\s+/", " ",$v));
if(!empty($invoice['lname']) && !empty($invoice['produ']) && !empty($invoice['price'])) {
$invoice['output'] = 'S';
include('invoiceCreatePdf.php');
}
else echo '!'.T_('Error');
break;
// ********************************************************************************************
}
clearstatcache();
exit;
}
?>