33 require_once
'./Services/Payment/classes/class.ilERPDebtor.php';
34 require_once
'./Services/Payment/classes/class.ilERP_eco.php';
49 $this->
set = $this->erp->getSettings();
63 if (!$this->erp->connection_ok) $this->erp->connect();
66 $this->handle = $this->erp->client->Debtor_FindByNumber(array(
'number' =>
$number))->Debtor_FindByNumberResult;
70 throw new ilERPException(__FILE__ .
":" . __LINE__ .
" " . $e->getMessage());
72 if (isset($this->handle))
return true;
else return false;
78 $this->dgh = $this->erp->client->debtorGroup_FindByNumber(
79 array(
'number' =>
$number))->DebtorGroup_FindByNumberResult;
91 $deb =
new stdClass();
98 $deb->Name = $cust[
'name'];
99 $deb->Email = $cust[
'email'];
100 $deb->Address = $cust[
'address'];
101 $deb->PostalCode = $cust[
'postalcode'];
102 $deb->City = $cust[
'city'];
103 $deb->Country = $cust[
'country'];
104 $deb->TelephoneAndFaxNumber = $cust[
'phone'];
105 $deb->Website = $cust[
'website'];
107 $deb->VatZone =
"HomeCountry";
108 $deb->IsAccessible =
true;
110 $deb->CurrencyHandle =
new stdClass();
111 $deb->CurrencyHandle->Code = $this->
set[
'code'];
113 $deb->TermOfPaymentHandle =
new stdClass();
114 $deb->TermOfPaymentHandle->Id = $this->
set[
'terms'];
116 $deb->LayoutHandle =
new stdClass();
117 $deb->LayoutHandle->Id = $this->
set[
'layout'];
122 $this->handle = $this->erp->client->Debtor_CreateFromData(array(
'data' => $deb))->Debtor_CreateFromDataResult;
126 throw new ilERPException(__FILE__ .
":" . __LINE__ .
" " . $e->getMessage() .
" " . print_r($deb,
true));
132 $this->dgh = $this->erp->client->debtorGroup_FindByNumber(array(
'number' => 1))->DebtorGroup_FindByNumberResult;
142 if (!strlen(
$ean)==13)
143 $this->setError(
"(cannot set EAN number. Must be 13 digits not '" .
$ean .
".");
147 $this->erp->client->Debtor_SetEan(array(
'debtorHandle' => $this->handle,
'value' =>
$ean));
162 if (!$this->erp->connection_ok) $this->erp->connect();
165 $this->invH = $this->erp->client->CurrentInvoice_Create(array(
'debtorHandle' => $this->handle))->CurrentInvoice_CreateResult;
169 throw new ilERPException(__FILE__ .
":" . __LINE__ .
" " . $e->getMessage());
180 if (!isset($this->invH))
throw new ilERPException(__FILE__ .
":" . __LINE__ .
" No Invoice Handle set.");
183 if (!$this->erp->connection_ok) $this->erp->connect();
186 $productH = $this->
getProduct( $this->
set[
'product'] );
187 $lineH = $this->erp->client->CurrentInvoiceLine_Create(
188 array(
'invoiceHandle' => $this->invH ))->CurrentInvoiceLine_CreateResult;
190 $this->erp->client->CurrentInvoiceLine_SetProduct(
191 array(
'currentInvoiceLineHandle' => $lineH,
'valueHandle' => $productH ));
192 $this->erp->client->CurrentInvoiceLine_SetDescription(
193 array(
'currentInvoiceLineHandle' => $lineH,
'value' => $desc ));
194 $this->erp->client->CurrentInvoiceLine_SetQuantity(
195 array(
'currentInvoiceLineHandle' => $lineH,
'value' => (
float) $quantity ));
196 $this->erp->client->CurrentInvoiceLine_SetUnitNetPrice(
197 array(
'currentInvoiceLineHandle' => $lineH,
'value' => $unetprice ));
201 throw new ilERPException(__FILE__ .
":" . __LINE__ .
" " . $e->getMessage());
212 if (!$this->erp->connection_ok) $this->erp->connect();
215 $this->erp->client->CurrentInvoice_SetIsVatIncluded(
216 array(
'currentInvoiceHandle' => $this->invH,
'value' => 0));
217 $v = $this->erp->client->CurrentInvoice_Book(
218 array(
'currentInvoiceHandle' => $this->invH))->CurrentInvoice_BookResult;
219 $this->invoice_booked =
true;
220 $this->invoice_number = $v->Number;
225 throw new ilERPException(__FILE__ .
":" . __LINE__ .
" " . $e->getMessage());
231 $product = $this->
set[
'product'];
232 if (!$this->erp->connection_ok) $this->erp->connect();
235 return $this->erp->client->Product_FindByNumber(array(
'number' => $product))->Product_FindByNumberResult;
239 throw new ilERPException(__FILE__ .
":" . __LINE__ .
" " . $e->getMessage());
250 if (!($this->invoice_booked))
throw new ilERPException(
"(getInvoicePDF) Cannot generate PDF of unbooked invoice.");
251 if (!$this->erp->connection_ok) $this->erp->connect();
254 $bytes = $this->erp->client->Invoice_GetPdf( array(
'invoiceHandle' => $v))->Invoice_GetPdfResult;
258 throw new ilERPException(__FILE__ .
":" . __LINE__ .
" " . $e->getMessage());