Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00034 class ilPaymentVendors
00035 {
00036 var $db = null;
00037
00038 var $vendors = array();
00039
00044 function ilPaymentVendors()
00045 {
00046 global $ilDB;
00047
00048 $this->db =& $ilDB;
00049
00050 $this->__read();
00051 }
00052
00053 function getVendors()
00054 {
00055 return $this->vendors;
00056 }
00057
00058 function isAssigned($a_usr_id)
00059 {
00060 return isset($this->vendors[$a_usr_id]);
00061 }
00062
00063 function add($a_usr_id)
00064 {
00065 if(isset($this->vendors[$a_usr_id]))
00066 {
00067 die("class.ilPaymentVendors::add() Vendor already exists");
00068 }
00069 $query = "INSERT INTO payment_vendors ".
00070 "SET vendor_id = '".$a_usr_id."', ".
00071 "cost_center = '".IL_INST_ID."_".$a_usr_id."'";
00072
00073 $this->db->query($query);
00074 $this->__read();
00075
00076 return true;
00077 }
00078 function update($a_usr_id, $a_cost_center)
00079 {
00080 $query = "UPDATE payment_vendors ".
00081 "SET cost_center = '".$a_cost_center."' ".
00082 "WHERE vendor_id = '".$a_usr_id."'";
00083
00084 $this->db->query($query);
00085 $this->__read();
00086
00087 return true;
00088 }
00089 function delete($a_usr_id)
00090 {
00091 if(!isset($this->vendors[$a_usr_id]))
00092 {
00093 die("class.ilPaymentVendors::delete() Vendor does not exist");
00094 }
00095 $query = "DELETE FROM payment_vendors ".
00096 "WHERE vendor_id = '".$a_usr_id."'";
00097
00098 $this->db->query($query);
00099 $this->__read();
00100
00101 return true;
00102 }
00103
00104
00105 function __read()
00106 {
00107 $this->vendors = array();
00108
00109 $query = "SELECT * FROM payment_vendors ";
00110 $res = $this->db->query($query);
00111
00112 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00113 {
00114 $this->vendors[$row->vendor_id]['vendor_id'] = $row->vendor_id;
00115 $this->vendors[$row->vendor_id]['cost_center'] = $row->cost_center;
00116 }
00117 return true;
00118 }
00119
00120
00121 function _isVendor($a_usr_id)
00122 {
00123 global $ilDB;
00124
00125 $query = "SELECT cost_center FROM payment_vendors ".
00126 "WHERE vendor_id = '".$a_usr_id."'";
00127
00128 $res = $ilDB->query($query);
00129
00130 return $res->numRows() ? true : false;
00131 }
00132
00133 function _getCostCenter($a_usr_id)
00134 {
00135 global $ilDB;
00136
00137 $query = "SELECT * FROM payment_vendors ".
00138 "WHERE vendor_id = '".$a_usr_id."'";
00139
00140 $res = $ilDB->query($query);
00141 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00142 {
00143 return $row->cost_center;
00144 }
00145 return -1;
00146 }
00147
00148 }
00149 ?>