ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilPurchase Class Reference

Class ilPurchase. More...

+ Collaboration diagram for ilPurchase:

Public Member Functions

 __construct ($usr_id, $pay_type)
 purchase ($tid)

Private Member Functions

 getDebtor ()

Private Attributes

 $deb
 $ilUser
 $active_erp
 $cart
 $sc
 $pay_type

Detailed Description

Class ilPurchase.

Author
Jesper G�dvad jespe.nosp@m.r@il.nosp@m.ias.d.nosp@m.k
Version
$Id: class.ilPurchase.php

Definition at line 20 of file class.ilPurchase.php.

Constructor & Destructor Documentation

ilPurchase::__construct (   $usr_id,
  $pay_type 
)

Definition at line 29 of file class.ilPurchase.php.

References $pay_type, $usr_id, and ilERP\getActive().

{
$this->ilUser = new ilObjUser($usr_id);
$this->pay_type = $pay_type;
$this->active_erp = ilERP::getActive();
$this->erp_cls = "ilERPDebtor_" . $this->active_erp['erp_short'];
require_once './Services/Payment/classes/class.' . $this->erp_cls. '.php';
$this->deb = new $this->erp_cls();
$this->cart = new ilPaymentShoppingCart( $this->ilUser );
$this->sc = $this->cart->getShoppingCart( $pay_type );
if (! $this->sc) throw new ilERPException("EmptyCart");
}

+ Here is the call graph for this function:

Member Function Documentation

ilPurchase::getDebtor ( )
private

Definition at line 46 of file class.ilPurchase.php.

Referenced by purchase().

{
if (!$this->deb->getDebtorByNumber($this->ilUser->getId()))
{
$this->deb->setAll( array(
'number' => $this->ilUser->getId(),
'name' => $this->ilUser->getFullName(),
'email' => $this->ilUser->email,
'address' => $this->ilUser->street,
'postalcode' => $this->ilUser->zipcode,
'city' => $this->ilUser->city,
'country' => $this->ilUser->country,
'phone' => $this->ilUser->phone_mobile)
);
$this->deb->createDebtor($this->ilUser->getId());
}
}

+ Here is the caller graph for this function:

ilPurchase::purchase (   $tid)

Definition at line 64 of file class.ilPurchase.php.

References $lng, ilCourseParticipants\_getInstanceByObjId(), ilPaymentObject\_getObjectData(), ilObject\_lookupObjId(), getDebtor(), IL_CRS_MEMBER, and ilPaymentBookings\setTransaction().

{
global $lng;
$this->getDebtor();
$this->deb->createInvoice();
$products = array();
foreach ($this->sc as $i)
{
$pod = ilPaymentObject::_getObjectData($i['pobject_id']);
$bo = new ilPaymentBookings( $this->ilUser->getId());
$ilias_tid = $this->ilUser->getId() . "_" . $tid;
// psc_id, pobject_id, obj_id, typ, betrag_string
$bo->setTransaction($ilias_tid);
$bo->setPobjectId( isset($i['pobject_id']) ? $i['pobject_id'] : 0 );
$bo->setCustomerId( $this->ilUser->getId() );
$bo->setVendorId( $pod['vendor_id'] );
$bo->setPayMethod($this->paytype);
$bo->setOrderDate(time());
// $bo->setDuration($i['dauer']); // duration
// $bo->setPrice( $i['betrag'] ); // amount
//$bo->setPrice( ilPaymentPrices::_getPriceString( $i['price_id'] ));
$bo->setDuration($i['duration']);
$bo->setPrice($i['price_string']);
$bo->setDiscount(0);
$bo->setVoucher('');
$bo->setVatRate( $i['vat_rate'] );
$bo->setVatUnit( $i['vat_unit'] );
$bo->setTransactionExtern($tid);
// $product_name = $i['buchungstext'];
//$duration = $i['dauer'];
//$amount = $i['betrag'];
$product_name = $i['object_title'];
$duration = $i['duration'];
$amount = $i['price']; // -> ? $i['price_string']
include_once './Services/Payment/classes/class.ilPayMethods.php';
$save_adr = (int) ilPaymethods::_EnabledSaveUserAddress($this->paytype) ? 1 : 0;
//if($save_adr == 1)
//{
$bo->setStreet($this->ilUser->getStreet(), '');
$bo->setPoBox('');//$this->ilUser->);
$bo->setZipcode($this->ilUser->getZipcode());
$bo->setCity($this->ilUser->getCity());
$bo->setCountry($this->ilUser->getCountry());
//}
$bo->setPayed(1);
$bo->setAccess(1);
$bo->setAccessExtension($this->sc['extension']);
$boid = $bo->add();
//$bo->update();
if ( $i['typ'] == 'crs')
{
include_once './Modules/Course/classes/class.ilCourseParticipants.php';
$this->deb->createInvoiceLine( 0, $product_name . " (" . $duration. ")", 1, $amount );
$products[] = $product_name;
$obj_id = ilObject::_lookupObjId($pod["ref_id"]);
$cp->add($this->ilUser->getId(), IL_CRS_MEMBER);
$cp->sendNotification($cp->NOTIFY_ACCEPT_SUBSCRIBER, $this->ilUser->getId());
}
}
$inv = $this->deb->bookInvoice();
$invoice_number = $this->deb->getInvoiceNumber();
$attach = $this->deb->getInvoicePDF($inv);
$this->deb->saveInvoice($attach, false);
$lng->loadLanguageModule('payment');
$this->deb->sendInvoice($lng->txt('pay_order_paid_subject'),
$this->ilUser->getFullName() . ",\n" .
str_replace( '%products%', implode(", ", $products), $lng->txt('pay_order_paid_body')) ,
$this->ilUser->getEmail(),
$attach, $lng->txt('pays_invoice') ."-" . $invoice_number
);
$this->cart->emptyShoppingCart();
}

+ Here is the call graph for this function:

Field Documentation

ilPurchase::$active_erp
private

Definition at line 24 of file class.ilPurchase.php.

ilPurchase::$cart
private

Definition at line 25 of file class.ilPurchase.php.

ilPurchase::$deb
private

Definition at line 22 of file class.ilPurchase.php.

ilPurchase::$ilUser
private

Definition at line 23 of file class.ilPurchase.php.

ilPurchase::$pay_type
private

Definition at line 27 of file class.ilPurchase.php.

Referenced by __construct().

ilPurchase::$sc
private

Definition at line 26 of file class.ilPurchase.php.


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