27 if(!isset(self::$_instance))
55 return isset($this->vendors[$a_usr_id]);
58 public function add($a_usr_id)
60 if(isset($this->vendors[$a_usr_id]))
62 die(
"class.ilPaymentVendors::add() Vendor already exists");
65 $this->db->insert(
'payment_vendors',
67 'vendor_id' => array(
'integer', $a_usr_id),
68 'cost_center' => array(
'text',
'IL_INST_ID_' . $a_usr_id)
76 public function update($a_usr_id, $a_cost_center)
78 $this->db->update(
'payment_vendors',
79 array(
'cost_center' => array(
'text', $a_cost_center)),
80 array(
'vendor_id' => array(
'integer', $a_usr_id)));
87 public function delete($a_usr_id)
89 if(!isset($this->vendors[$a_usr_id]))
91 die(
"class.ilPaymentVendors::delete() Vendor does not exist");
94 $this->db->manipulateF(
'
95 DELETE FROM payment_vendors WHERE vendor_id = %s',
109 $this->vendors = array();
111 $res = $this->db->query(
'SELECT * FROM payment_vendors');
114 while(
$row = $this->db->fetchObject(
$res))
116 $this->vendors[
$row->vendor_id][
'vendor_id'] =
$row->vendor_id;
117 $this->vendors[
$row->vendor_id][
'cost_center'] =
$row->cost_center;
123 public static function _isVendor($a_usr_id)
130 $res = $ilDB->queryf(
'
131 SELECT * FROM payment_vendors WHERE vendor_id = %s',
132 array(
'integer'), array($a_usr_id));
134 return $ilDB->numRows(
$res) ?
true :
false;
137 public static function _getCostCenter($a_usr_id)
144 $res = $ilDB->queryf(
'
145 SELECT * FROM payment_vendors WHERE vendor_id = %s',
146 array(
'integer'), array($a_usr_id));
148 while(
$row = $ilDB->fetchObject(
$res))
150 return $row->cost_center;