• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

payment/classes/class.ilPaymentVendors.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
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         // PRIVATE
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         // STATIC
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 } // END class.ilPaymentVendors
00149 ?>

Generated on Fri Dec 13 2013 13:52:11 for ILIAS Release_3_7_x_branch .rev 46817 by  doxygen 1.7.1