ILIAS  release_4-4 Revision
ilERPDebtor_eco Class Reference
+ Inheritance diagram for ilERPDebtor_eco:
+ Collaboration diagram for ilERPDebtor_eco:

Public Member Functions

 __construct ()
 Retrive or create Debtor. More...
 
 getDebtorByNumber ($number)
 Return true if debtor found in e-conomic and set handle to that debtor. More...
 
 setDebtorGroup ($number=1)
 
 createDebtor ($number)
 Create a new debtor in e-conomic and set handle to that debtor. More...
 
 getDebtorGroup ()
 
 setEAN ($ean)
 Set EAN number on debtor. More...
 
 createInvoice ()
 Create invoice. More...
 
 createInvoiceLine ( $product, $desc, $quantity, $unetprice)
 Create a line on a invoice Don't care about product currently. More...
 
 bookInvoice ()
 Finish the invoice. More...
 
 getInvoicePDF ($v)
 handle More...
 
- Public Member Functions inherited from ilERPDebtor
 getInvoiceNumber ()
 
 getName ()
 
 getEmail ()
 
 getAll ()
 Get all information about a Debtor. More...
 
 setAll ($values)
 Set information about a Debtor. More...
 
 saveInvoice ($contens, $preview=true)
 
 sendInvoice ($subject, $message, $to=null, $bytes, $fname="faktura")
 
 setTestValues ()
 Generate random values to test integration with ERP. More...
 

Private Member Functions

 getProduct ($product=null)
 

Private Attributes

 $set
 
 $erp
 
 $invH
 

Additional Inherited Members

- Data Fields inherited from ilERPDebtor
const website = "http://www.ilias.dk"
 
const senderEmail = "noreply@ilias.dk"
 
const senderName = "ILIAS ERP"
 
- Protected Member Functions inherited from ilERPDebtor
 __construct ()
 
- Protected Attributes inherited from ilERPDebtor
 $number
 
 $name = ''
 
 $email = ''
 
 $address = ''
 
 $postalcode = ''
 
 $city = ''
 
 $country = ''
 
 $phone = ''
 
 $ean
 
 $website
 
 $invoice_booked = false
 
 $invoice_number = 0
 
 $handle
 
 $dgh
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilERPDebtor_eco::__construct ( )

Retrive or create Debtor.

Definition at line 45 of file class.ilERPDebtor_eco.php.

References ilERP_eco\_getInstance().

46  {
47 
48  $this->erp = ilERP_eco::_getInstance();
49  $this->set = $this->erp->getSettings();
50 
51  parent::__construct();
52 
53  }
static _getInstance()
Static method to get the singleton instance.
+ Here is the call graph for this function:

Member Function Documentation

◆ bookInvoice()

ilERPDebtor_eco::bookInvoice ( )

Finish the invoice.

Return a handle to it.

Definition at line 210 of file class.ilERPDebtor_eco.php.

211  {
212  if (!$this->erp->connection_ok) $this->erp->connect();
213  try
214  {
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;
221  return $v;
222  }
223  catch (Exception $e)
224  {
225  throw new ilERPException(__FILE__ . ":" . __LINE__ . " " . $e->getMessage());
226  }
227  }
Class for ERP related exception handling in ILIAS.

◆ createDebtor()

ilERPDebtor_eco::createDebtor (   $number)

Create a new debtor in e-conomic and set handle to that debtor.

Returns
bool if creation was successfull

Definition at line 88 of file class.ilERPDebtor_eco.php.

References ilERPDebtor\$dgh, ilERPDebtor\$number, ilERPDebtor\getAll(), and setDebtorGroup().

89  {
90  $cust = $this->getAll();
91  $deb = new stdClass();
92  $deb->Number = $number;
93 
94 
95  $this->setDebtorGroup(); // cheating
96 
97  $deb->DebtorGroupHandle = $this->dgh;
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'];
106 
107  $deb->VatZone = "HomeCountry";
108  $deb->IsAccessible = true;
109 
110  $deb->CurrencyHandle = new stdClass();
111  $deb->CurrencyHandle->Code = $this->set['code'];
112 
113  $deb->TermOfPaymentHandle = new stdClass();
114  $deb->TermOfPaymentHandle->Id = $this->set['terms'];
115 
116  $deb->LayoutHandle = new stdClass();
117  $deb->LayoutHandle->Id = $this->set['layout'];
118 
119  //if (!$this->erp->connection_ok) $this->erp->connect();
120  try
121  {
122  $this->handle = $this->erp->client->Debtor_CreateFromData(array('data' => $deb))->Debtor_CreateFromDataResult;
123  }
124  catch (Exception $e)
125  {
126  throw new ilERPException(__FILE__ . ":" . __LINE__ . " " . $e->getMessage() . " " . print_r($deb,true));
127  }
128  }
getAll()
Get all information about a Debtor.
Class for ERP related exception handling in ILIAS.
+ Here is the call graph for this function:

◆ createInvoice()

ilERPDebtor_eco::createInvoice ( )

Create invoice.

Definition at line 160 of file class.ilERPDebtor_eco.php.

161  {
162  if (!$this->erp->connection_ok) $this->erp->connect();
163  try
164  {
165  $this->invH = $this->erp->client->CurrentInvoice_Create(array('debtorHandle' => $this->handle))->CurrentInvoice_CreateResult;
166  }
167  catch (Exception $e)
168  {
169  throw new ilERPException(__FILE__ . ":" . __LINE__ . " " . $e->getMessage());
170  }
171  }
Class for ERP related exception handling in ILIAS.

◆ createInvoiceLine()

ilERPDebtor_eco::createInvoiceLine (   $product,
  $desc,
  $quantity,
  $unetprice 
)

Create a line on a invoice Don't care about product currently.

Definition at line 178 of file class.ilERPDebtor_eco.php.

References getProduct().

179  {
180  if (!isset($this->invH)) throw new ilERPException(__FILE__ . ":" . __LINE__ . " No Invoice Handle set.");
181  else
182  {
183  if (!$this->erp->connection_ok) $this->erp->connect();
184  try
185  {
186  $productH = $this->getProduct( $this->set['product'] );
187  $lineH = $this->erp->client->CurrentInvoiceLine_Create(
188  array('invoiceHandle' => $this->invH ))->CurrentInvoiceLine_CreateResult;
189 
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 ));
198  }
199  catch (Exception $e)
200  {
201  throw new ilERPException(__FILE__ . ":" . __LINE__ . " " . $e->getMessage());
202  }
203  }
204  }
Class for ERP related exception handling in ILIAS.
getProduct($product=null)
+ Here is the call graph for this function:

◆ getDebtorByNumber()

ilERPDebtor_eco::getDebtorByNumber (   $number)

Return true if debtor found in e-conomic and set handle to that debtor.

Returns
bool

Definition at line 60 of file class.ilERPDebtor_eco.php.

References ilERPDebtor\$number.

61  {
62  unset($this->handle);
63  if (!$this->erp->connection_ok) $this->erp->connect();
64  try
65  {
66  $this->handle = $this->erp->client->Debtor_FindByNumber(array('number' => $number))->Debtor_FindByNumberResult;
67  }
68  catch (Exception $e)
69  {
70  throw new ilERPException(__FILE__ . ":" . __LINE__ . " " . $e->getMessage());
71  }
72  if (isset($this->handle)) return true; else return false;
73  }
Class for ERP related exception handling in ILIAS.

◆ getDebtorGroup()

ilERPDebtor_eco::getDebtorGroup ( )

Definition at line 130 of file class.ilERPDebtor_eco.php.

131  {
132  $this->dgh = $this->erp->client->debtorGroup_FindByNumber(array('number' => 1))->DebtorGroup_FindByNumberResult;
133  }

◆ getInvoicePDF()

ilERPDebtor_eco::getInvoicePDF (   $v)

handle

Definition at line 248 of file class.ilERPDebtor_eco.php.

249  {
250  if (!($this->invoice_booked)) throw new ilERPException("(getInvoicePDF) Cannot generate PDF of unbooked invoice.");
251  if (!$this->erp->connection_ok) $this->erp->connect();
252  try
253  {
254  $bytes = $this->erp->client->Invoice_GetPdf( array('invoiceHandle' => $v))->Invoice_GetPdfResult;
255  }
256  catch (Exception $e)
257  {
258  throw new ilERPException(__FILE__ . ":" . __LINE__ . " " . $e->getMessage());
259  }
260  return $bytes;
261  }
Class for ERP related exception handling in ILIAS.

◆ getProduct()

ilERPDebtor_eco::getProduct (   $product = null)
private

Definition at line 229 of file class.ilERPDebtor_eco.php.

Referenced by createInvoiceLine().

230  {
231  $product = $this->set['product'];
232  if (!$this->erp->connection_ok) $this->erp->connect();
233  try
234  {
235  return $this->erp->client->Product_FindByNumber(array('number' => $product))->Product_FindByNumberResult;
236  }
237  catch (Exception $e)
238  {
239  throw new ilERPException(__FILE__ . ":" . __LINE__ . " " . $e->getMessage());
240 
241  }
242  }
Class for ERP related exception handling in ILIAS.
+ Here is the caller graph for this function:

◆ setDebtorGroup()

ilERPDebtor_eco::setDebtorGroup (   $number = 1)

Definition at line 76 of file class.ilERPDebtor_eco.php.

References ilERPDebtor\$number.

Referenced by createDebtor().

77  {
78  $this->dgh = $this->erp->client->debtorGroup_FindByNumber(
79  array('number' => $number))->DebtorGroup_FindByNumberResult;
80  }
+ Here is the caller graph for this function:

◆ setEAN()

ilERPDebtor_eco::setEAN (   $ean)

Set EAN number on debtor.

Return true if success

Definition at line 140 of file class.ilERPDebtor_eco.php.

References ilERPDebtor\$ean.

141  {
142  if (!strlen($ean)==13)
143  $this->setError("(cannot set EAN number. Must be 13 digits not '" . $ean .".");
144  else
145  try
146  {
147  $this->erp->client->Debtor_SetEan(array('debtorHandle' => $this->handle, 'value' => $ean));
148  return true;
149  }
150  catch (Exception $e)
151  {
152  throw new ilERPException("(setEan " . $ean . ") " . $e->getMessage());
153  }
154  return false;
155  }
Class for ERP related exception handling in ILIAS.

Field Documentation

◆ $erp

ilERPDebtor_eco::$erp
private

Definition at line 39 of file class.ilERPDebtor_eco.php.

◆ $invH

ilERPDebtor_eco::$invH
private

Definition at line 40 of file class.ilERPDebtor_eco.php.

◆ $set

ilERPDebtor_eco::$set
private

Definition at line 38 of file class.ilERPDebtor_eco.php.


The documentation for this class was generated from the following file: