ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
ilShopVats Class Reference

Class ilShopVats. More...

+ Collaboration diagram for ilShopVats:

Public Member Functions

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

Static Public Member Functions

static _readAllVats ()
 

Private Member Functions

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

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

◆ __construct()

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 $ilDB, $lng, and read().

30  {
31  global $ilDB, $lng;
32 
33  $this->db = $ilDB;
34  $this->lng = $lng;
35 
36  if((int)$a_vat_id && $a_vat_id > 0)
37  {
38  $this->id = $a_vat_id;
39  $this->read();
40  }
41  }
read()
Fetches the data of a vat dataset from database.
global $lng
Definition: privfeed.php:40
global $ilDB
+ Here is the call graph for this function:

Member Function Documentation

◆ _readAllVats()

static ilShopVats::_readAllVats ( )
static

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

References $ilDB, $res, and $row.

Referenced by ilObjPaymentSettingsGUI\checkShopActivationObject().

239  {
240  global $ilDB;
241 
242  $vats = array();
243  $res = $ilDB->query('SELECT * FROM payment_vats');
244  while($row = $ilDB->fetchAssoc($res))
245  {
246  $vats[] = $row;
247  }
248  return $vats;
249  }
global $ilDB
+ Here is the caller graph for this function:

◆ delete()

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().

158  {
159  if((int)$this->id)
160  {
161  $result = $this->db->queryF('
162  SELECT * FROM payment_objects
163  WHERE vat_id = %s',
164  array('integer'),
165  array($this->getId())
166  );
167 
168  while($row = $this->db->fetchObject($result))
169  {
170  throw new ilShopException(sprintf($this->lng->txt('paya_vat_not_deleted'), $this->title));
171  }
172 
173  $this->db->manipulateF('
174  DELETE FROM payment_vats
175  WHERE vat_id = %s',
176  array('integer'),
177  array($this->getId())
178 
179  );
180  return true;
181  }
182 
183  throw new ilShopException($this->lng->txt('payment_cannot_delete_nonexisting_vat'));
184  }
$result
Class for shop related exception handling in ILIAS.
+ Here is the call graph for this function:

◆ getId()

ilShopVats::getId ( )

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

References $id.

Referenced by delete(), and update().

217  {
218  return $this->id;
219  }
+ Here is the caller graph for this function:

◆ getRate()

ilShopVats::getRate ( )

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

References $rate.

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

234  {
235  return $this->rate;
236  }
+ Here is the caller graph for this function:

◆ getTitle()

ilShopVats::getTitle ( )

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

References $title.

Referenced by save(), and update().

200  {
201  return $this->title;
202  }
+ Here is the caller graph for this function:

◆ read()

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().

50  {
51  if((int)$this->id)
52  {
53 
54  $res = $this->db->queryf('SELECT * FROM payment_vats
55  WHERE vat_id = %s',
56  array('integer'), array($this->id) );
57 
58  while($row = $this->db->fetchObject($res))
59  {
60  $this->setTitle($row->vat_title);
61  $this->setRate($row->vat_rate);
62 
63  return true;
64  }
65 
66  throw new ilShopException($this->lng->txt('payment_cannot_find_vat'));
67  }
68 
69  throw new ilShopException($this->lng->txt('payment_cannot_read_nonexisting_vat'));
70  }
setTitle($a_title)
Setter for the title.
Class for shop related exception handling in ILIAS.
setRate($a_rate)
Setter for the vat rate.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reloadFromDatabase()

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().

81  {
82  $this->read();
83 
84  return $this;
85  }
read()
Fetches the data of a vat dataset from database.
+ Here is the call graph for this function:

◆ save()

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().

127  {
128  if(!(int)$this->id)
129  {
130  if(ilShopVatsList::_isVATAlreadyCreated($this->rate))
131  {
132  throw new ilShopException($this->lng->txt('payment_vat_already_created'));
133  }
134 
135  $next_id = $this->db->nextId('payment_vats');
136 
137  $this->db->manipulateF('
138  INSERT INTO payment_vats
139  (vat_id, vat_title, vat_rate)
140  VALUES (%s,%s,%s)',
141  array('integer', 'text', 'float'),
142  array($next_id, $this->getTitle(), $this->getRate())
143  );
144  return true;
145  }
146 
147  throw new ilShopException($this->lng->txt('payment_cannot_save_existing_vat'));
148  }
static _isVATAlreadyCreated($a_vat_rate, $a_vat_id=null)
Checks if the passed vat rate already exists in database.
Class for shop related exception handling in ILIAS.
+ Here is the call graph for this function:

◆ setId()

ilShopVats::setId (   $a_id)

Setter for the id.

public

Parameters
int$a_id
Returns
ilShopVats

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

211  {
212  $this->id = $a_id;
213 
214  return $this;
215  }

◆ setRate()

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().

228  {
229  $this->rate = $a_rate;
230 
231  return $this;
232  }
+ Here is the caller graph for this function:

◆ setTitle()

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().

194  {
195  $this->title = $a_title;
196 
197  return $this;
198  }
+ Here is the caller graph for this function:

◆ update()

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().

95  {
96  if((int)$this->id)
97  {
98  if(ilShopVatsList::_isVATAlreadyCreated($this->rate, $this->id))
99  {
100  throw new ilShopException($this->lng->txt('payment_vat_already_created'));
101  }
102 
103 
104  $this->db->manipulatef('
105  UPDATE payment_vats
106  SET vat_title = %s,
107  vat_rate = %s
108  WHERE vat_id = %s',
109  array('text', 'float', 'integer'),
110  array($this->getTitle(),$this->getRate(),$this->getId())
111  );
112 
113  return true;
114  }
115 
116  throw new ilShopException($this->lng->txt('payment_cannot_update_nonexisting_vat'));
117  }
static _isVATAlreadyCreated($a_vat_rate, $a_vat_id=null)
Checks if the passed vat rate already exists in database.
Class for shop related exception handling in ILIAS.
+ Here is the call graph for this function:

Field Documentation

◆ $id

ilShopVats::$id = 0
private

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

Referenced by delete(), and getId().

◆ $rate

ilShopVats::$rate = 0
private

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

Referenced by getRate().

◆ $title

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: