ILIAS  Release_4_0_x_branch Revision 61816
 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 ()

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 Krzywon nkrzy.nosp@m.won@.nosp@m.datab.nosp@m.ay.d.nosp@m.e
Version
$Id$

Definition at line 38 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 51 of file class.ilShopVats.php.

References $ilDB, $lng, and read().

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

+ Here is the call graph for this function:

Member Function Documentation

ilShopVats::delete ( )

Deletes an existing vat dataset.

public

Returns
bool Returns true if no error occured.
Exceptions
ilShopException

Definition at line 179 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 238 of file class.ilShopVats.php.

References $id.

Referenced by delete(), and update().

{
return $this->id;
}

+ Here is the caller graph for this function:

ilShopVats::getTitle ( )

Definition at line 221 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 71 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 102 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 148 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 232 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 249 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 215 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 116 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 40 of file class.ilShopVats.php.

Referenced by delete(), and getId().

ilShopVats::$rate = 0
private

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

Referenced by getRate().

ilShopVats::$title = ''
private

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

Referenced by delete(), and getTitle().


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