ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilShopVats Class Reference

Class ilShopVats. More...

+ Collaboration diagram for ilShopVats:

Public Member Functions

 __construct ($a_vat_id=0)
 Constructor.
 reloadFromDatabase ()
 Public interface to reload the capsuled data of a vat from database.
 update ()
 Updates an existing vat dataset.
 save ()
 Saves a new vat dataset.
 delete ()
 Deletes an existing vat dataset.
 setTitle ($a_title)
 Setter for the title.
 getTitle ()
 setId ($a_id)
 Setter for the id.
 getId ()
 setRate ($a_rate)
 Setter for the vat rate.
 getRate ()

Static Public Member Functions

static _readAllVats ()

Private Member Functions

 read ()
 Fetches the data of a vat dataset from database.

Private Attributes

 $id = 0
 $title = ''
 $rate = 0

Detailed Description

Class ilShopVats.

Author
Nadia Ahmad nahma.nosp@m.d@da.nosp@m.tabay.nosp@m..de
Version
$Id$

Definition at line 16 of file class.ilShopVats.php.

Constructor & Destructor Documentation

ilShopVats::__construct (   $a_vat_id = 0)

Constructor.

Parameters
$a_vat_idThe primary key of a vat dataset. public

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

References $lng, and read().

{
global $ilDB, $lng;
$this->db = $ilDB;
$this->lng = $lng;
if((int)$a_vat_id && $a_vat_id > 0)
{
$this->id = $a_vat_id;
$this->read();
}
}

+ Here is the call graph for this function:

Member Function Documentation

static ilShopVats::_readAllVats ( )
static

Definition at line 238 of file class.ilShopVats.php.

References $res, and $row.

Referenced by ilObjPaymentSettingsGUI\checkShopActivationObject().

{
global $ilDB;
$vats = array();
$res = $ilDB->query('SELECT * FROM payment_vats');
while($row = $ilDB->fetchAssoc($res))
{
$vats[] = $row;
}
return $vats;
}

+ Here is the caller graph for this function:

ilShopVats::delete ( )

Deletes an existing vat dataset.

public

Returns
bool Returns true if no error occured.
Exceptions
ilShopException

Definition at line 157 of file class.ilShopVats.php.

References $id, $result, $row, $title, and getId().

{
if((int)$this->id)
{
$result = $this->db->queryF('
SELECT * FROM payment_objects
WHERE vat_id = %s',
array('integer'),
array($this->getId())
);
while($row = $this->db->fetchObject($result))
{
throw new ilShopException(sprintf($this->lng->txt('paya_vat_not_deleted'), $this->title));
}
$this->db->manipulateF('
DELETE FROM payment_vats
WHERE vat_id = %s',
array('integer'),
array($this->getId())
);
return true;
}
throw new ilShopException($this->lng->txt('payment_cannot_delete_nonexisting_vat'));
}

+ Here is the call graph for this function:

ilShopVats::getId ( )

Definition at line 216 of file class.ilShopVats.php.

References $id.

Referenced by delete(), and update().

{
return $this->id;
}

+ Here is the caller graph for this function:

ilShopVats::getRate ( )

Definition at line 233 of file class.ilShopVats.php.

References $rate.

Referenced by ilShopShoppingCartGUI\addBookings(), ilPaymentShoppingCart\getShoppingCart(), save(), ilObjPaymentSettingsGUI\saveCustomerObject(), and update().

{
return $this->rate;
}

+ Here is the caller graph for this function:

ilShopVats::getTitle ( )

Definition at line 199 of file class.ilShopVats.php.

References $title.

Referenced by save(), and update().

{
return $this->title;
}

+ Here is the caller graph for this function:

ilShopVats::read ( )
private

Fetches the data of a vat dataset from database.

private

Exceptions
ilShopException

Definition at line 49 of file class.ilShopVats.php.

References $res, $row, setRate(), and setTitle().

Referenced by __construct(), and reloadFromDatabase().

{
if((int)$this->id)
{
$res = $this->db->queryf('SELECT * FROM payment_vats
WHERE vat_id = %s',
array('integer'), array($this->id) );
while($row = $this->db->fetchObject($res))
{
$this->setTitle($row->vat_title);
$this->setRate($row->vat_rate);
return true;
}
throw new ilShopException($this->lng->txt('payment_cannot_find_vat'));
}
throw new ilShopException($this->lng->txt('payment_cannot_read_nonexisting_vat'));
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilShopVats::reloadFromDatabase ( )

Public interface to reload the capsuled data of a vat from database.

Throws a ilShopException if the object property $this->id has no valid value (because $this->read() is called).

public

Returns
ilShopVats

Definition at line 80 of file class.ilShopVats.php.

References read().

{
$this->read();
return $this;
}

+ Here is the call graph for this function:

ilShopVats::save ( )

Saves a new vat dataset.

public

Returns
bool Returns true if no error occured.
Exceptions
ilShopException

Definition at line 126 of file class.ilShopVats.php.

References ilShopVatsList\_isVATAlreadyCreated(), getRate(), and getTitle().

{
if(!(int)$this->id)
{
{
throw new ilShopException($this->lng->txt('payment_vat_already_created'));
}
$next_id = $this->db->nextId('payment_vats');
$this->db->manipulateF('
INSERT INTO payment_vats
(vat_id, vat_title, vat_rate)
VALUES (%s,%s,%s)',
array('integer', 'text', 'float'),
array($next_id, $this->getTitle(), $this->getRate())
);
return true;
}
throw new ilShopException($this->lng->txt('payment_cannot_save_existing_vat'));
}

+ Here is the call graph for this function:

ilShopVats::setId (   $a_id)

Setter for the id.

public

Parameters
int$a_id
Returns
ilShopVats

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

{
$this->id = $a_id;
return $this;
}
ilShopVats::setRate (   $a_rate)

Setter for the vat rate.

public

Parameters
float$a_rate
Returns
ilShopVats

Definition at line 227 of file class.ilShopVats.php.

Referenced by read().

{
$this->rate = $a_rate;
return $this;
}

+ Here is the caller graph for this function:

ilShopVats::setTitle (   $a_title)

Setter for the title.

public string $a_title

Returns
ilShopVats

Definition at line 193 of file class.ilShopVats.php.

Referenced by read().

{
$this->title = $a_title;
return $this;
}

+ Here is the caller graph for this function:

ilShopVats::update ( )

Updates an existing vat dataset.

public

Returns
bool Returns true if no error occured.
Exceptions
ilShopException

Definition at line 94 of file class.ilShopVats.php.

References ilShopVatsList\_isVATAlreadyCreated(), getId(), getRate(), and getTitle().

{
if((int)$this->id)
{
if(ilShopVatsList::_isVATAlreadyCreated($this->rate, $this->id))
{
throw new ilShopException($this->lng->txt('payment_vat_already_created'));
}
$this->db->manipulatef('
UPDATE payment_vats
SET vat_title = %s,
vat_rate = %s
WHERE vat_id = %s',
array('text', 'float', 'integer'),
array($this->getTitle(),$this->getRate(),$this->getId())
);
return true;
}
throw new ilShopException($this->lng->txt('payment_cannot_update_nonexisting_vat'));
}

+ Here is the call graph for this function:

Field Documentation

ilShopVats::$id = 0
private

Definition at line 18 of file class.ilShopVats.php.

Referenced by delete(), and getId().

ilShopVats::$rate = 0
private

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

Referenced by getRate().

ilShopVats::$title = ''
private

Definition at line 19 of file class.ilShopVats.php.

Referenced by delete(), and getTitle().


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