ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilERPDebtor.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
34 {
35 
36  protected $number;
37  protected $name = '';
38  protected $email = '';
39  protected $address = '';
40  protected $postalcode = '';
41  protected $city = '';
42  protected $country = '';
43  protected $phone = '';
44  protected $ean;
45  protected $website;
46  protected $invoice_booked = false;
47  protected $invoice_number = 0;
48 
49  protected $handle; // debtor
50  protected $dgh;
51 
52  const website = "http://www.ilias.dk";
53 
54  const senderEmail = "noreply@ilias.dk";
55  const senderName = "ILIAS ERP";
56 
57 
58 
59  protected function __construct()
60  {
61  }
62 
63  public function getInvoiceNumber()
64  {
65  return $this->invoice_number;
66  }
67 
68  public function getName()
69  {
70  return $this->name;
71  }
72 
73  public function getEmail()
74  {
75  return $this->email;
76  }
77 
83  public function getAll()
84  {
85  $a['number'] = $this->number;
86  $a['name'] = $this->name;
87  $a['email'] = $this->email;
88  $a['address'] = $this->address;
89  $a['postalcode'] = $this->postalcode;
90  $a['city'] = $this->city;
91  $a['country'] = $this->country;
92  $a['ean'] = $this->ean;
93  $a['website'] = $this->website;
94  $a['dgh'] = $this->dgh;
95  $a['phone'] = $this->phone;
96  return $a;
97  }
98 
99 
103  public function setAll($values)
104  {
105  foreach ($values as $key => $value)
106  $this->$key = $value;
107  }
108 
109 
110 
111 
112 
113  public function saveInvoice($contens, $preview=true)
114  {
116  $fp = @fopen( $file, 'w+' );
117  if (!$fp)
118  {
119  throw new ilERPException("Cannot write " . $file);
120  }
121  fwrite($fp, $contens);
122  fclose($fp);
123  }
124 
125 
126  public function sendInvoice($subject, $message, $to = null, $bytes, $fname = "faktura")
127  {
128 
129  $content = chunk_split(base64_encode($bytes));
130 
131  if (!isset($to)) $to = $this->email;
132  $filename = $fname . ".pdf";
133 
134  $uid = md5(uniqid(time()));
135 
136  $header = "From: " . ilERPDebtor::senderName . " <". ilERPDebtor::senderEmail.">\r\n";
137  $header .= "Reply-To: " . ilERPDebtor::senderEmail . "\r\n";
138  $header .= "MIME-Version: 1.0\r\n";
139  $header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n";
140  $header .= "This is a multi-part message in MIME format.\r\n";
141  $header .= "--".$uid."\r\n";
142  $header .= "Content-type:text/plain; charset=utf-8\r\n";
143  $header .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
144  $header .= $message."\r\n\r\n";
145  $header .= "--".$uid."\r\n";
146  $header .= "Content-Type: application/octet-stream; name=\"".$filename."\"\r\n"; // use diff. tyoes here
147  $header .= "Content-Transfer-Encoding: base64\r\n";
148  $header .= "Content-Disposition: attachment; filename=\"".$filename."\"\r\n\r\n";
149  $header .= $content."\r\n\r\n";
150  $header .= "--".$uid."--";
151 
152  /*
153  include_once './Services/Mail/classes/classes/class.ilMimeMail.php';
154  $mail = new ilMimeMail;
155  $mail->autoCheck(true);
156  $mail->Subject($subject);
157  $mail->From(ilERPDebtor::senderName . " <". ilERPDebtor::senderEmail.">");
158  $mail->ReplyTo(ilERPDebtor::senderEmail);
159  $mail->To($to);
160  $mail->Body("Mail body");
161  $mail->Attach(
162 
163  $mail->Send();*/
164 
165  $restore_me = ini_get('display_errors');
166  ini_set('display_errors', 0);
167  mail($to, $subject, "", $header);
168  ini_set('display_errors', $restore_me);
169 
170  }
171 
175  public function setTestValues()
176  {
177  $fname = array("Jesper", "Nicolai", "Alex", "Stefan", "Helmut", "Elvis");
178  $lname = array("Gødvad", "Lundgaard", "Killing", "Meyer", "Schottmüller", "Presly");
179  $city = array("Copenhagen", "Århus", "Collonge", "Bremen", "SecretPlace" );
180  $country = array("Denmark", "Germany", "France", "Ümlaudia", "Graceland");
181  $road = array(" Straße", " Road", "vej", " Boulevard");
182 
183  $this->number = rand(1000,1010);
184  $this->name = $fname[rand(0,5)] . " " . $lname[rand(0,5)];
185  $this->email = "noreply@ilias.dk";
186  $this->address= "Ilias" . $road[rand(0,3)] ." " . rand(1,100);
187  $this->postalcode = rand(2000,7000);
188  $this->city = $city[rand(0,3)];
189  $this->country = $country[rand(0,4)];
190  $this->phone = "+" . rand(1,45) . " " . rand(100,999) . " " . rand(1000, 9999);
191  $this->ean = 0;
192  $this->website = ilERPDebtor::website;
193  }
194 
195 }
196 
197 
198 ?>