9086c9ad77db90633e0629e9e86a88366265ded0
Bernd Wurst Neues Modul zum Abschließen...

Bernd Wurst authored 6 years ago

1) <?php
2) /*
3) This file belongs to the Webinterface of schokokeks.org Hosting
4) 
5) Written 2008-2018 by schokokeks.org Hosting, namely
6)   Bernd Wurst <bernd@schokokeks.org>
7)   Hanno Böck <hanno@schokokeks.org>
8) 
9) To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
10) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

11) You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see
Bernd Wurst Neues Modul zum Abschließen...

Bernd Wurst authored 6 years ago

12) http://creativecommons.org/publicdomain/zero/1.0/
13) 
14) Nevertheless, in case you use a significant part of this code, we ask (but not require, see the license) that you keep the authors' names in place and return your changes to the public. We would be especially happy if you tell us what you're going to do with this code.
15) */
16) 
17) require_role(ROLE_CUSTOMER);
18) 
19) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

20) function get_orderprocessing_contract()
21) {
Bernd Wurst Neues Modul zum Abschließen...

Bernd Wurst authored 6 years ago

22)     $args = array(
23)         "cid" => (int) $_SESSION['customerinfo']['customerno']);
24)     $result = db_query("SELECT id, signed, type, startdate, enddate FROM kundendaten.contract WHERE customer=:cid AND type='orderprocessing' AND (enddate IS NULL OR enddate < CURDATE())", $args);
25)     if ($result->rowCount() == 0) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

26)         return null;
Bernd Wurst Neues Modul zum Abschließen...

Bernd Wurst authored 6 years ago

27)     }
28)     $line = $result->fetch();
29)     return $line;
30) }
31) 
32) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

33) function contract_html()
34) {
Bernd Wurst Neues Modul zum Abschließen...

Bernd Wurst authored 6 years ago

35)     use_module('contacts');
36)     require_once('contacts.php');
Hanno remove whitespace in empty...

Hanno authored 6 years ago

37) 
Bernd Wurst Neues Modul zum Abschließen...

Bernd Wurst authored 6 years ago

38)     $kundenkontakte = get_kundenkontakte();
39)     $kunde = get_contact($kundenkontakte['kunde']);
40)     $adresse = nl2br("\n".filter_input_general($kunde['address'])."\n".filter_input_general($kunde['country']).'-'.filter_input_general($kunde['zip']).' '.filter_input_general($kunde['city']));
41)     $name = filter_input_general($kunde['name']);
42)     if ($kunde['company']) {
43)         $name = filter_input_general($kunde['company'])."<br />".filter_input_general($kunde['name']);
44)     }
45)     $email = filter_input_general($kunde['email']);
46)     $address = "<strong>$name</strong>$adresse</p><p>E-Mail-Adresse: $email";
Hanno remove whitespace in empty...

Hanno authored 6 years ago

47) 
Bernd Wurst Neues Modul zum Abschließen...

Bernd Wurst authored 6 years ago

48)     $date = date('d.m.Y');
49) 
50)     $DIR=realpath(dirname(__FILE__).'/..');
51) 
52)     $vertrag = file_get_contents($DIR.'/vertrag.html');
53)     $vertrag = str_replace('((ADRESSE))', $address, $vertrag);
54)     $vertrag = str_replace('((DATUM))', $date, $vertrag);
55) 
56)     $vertrag = str_replace('</body>', '', $vertrag);
57)     $vertrag = str_replace('</html>', '', $vertrag);
58) 
59)     return $vertrag."<br><br><pagebreak>\n".file_get_contents($DIR.'/anlage1.html')."<br><br><pagebreak>\n".file_get_contents($DIR.'/anlage2.html')."</body></html>";
60) }
61) 
62) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

63) function save_op_contract($pdfdata)
64) {
Bernd Wurst Neues Modul zum Abschließen...

Bernd Wurst authored 6 years ago

65)     $args = array("cid" => $_SESSION['customerinfo']['customerno'],
66)             "pdfdata" => $pdfdata);
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

67)     db_query(
68)         "INSERT INTO kundendaten.contract (customer, signed, type, startdate, pdfdata) VALUES (:cid, NOW(), 'orderprocessing', CURDATE(), :pdfdata)",
69)         $args
70)     );
Bernd Wurst Neues Modul zum Abschließen...

Bernd Wurst authored 6 years ago

71) }
72) 
73) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

74) function get_contract_pdf($id)
75) {