ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPaymentBillAdminGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
31 include_once './payment/classes/class.ilPaymentObject.php';
32 
34 {
35  var $ctrl;
36 
37  var $lng;
38  var $user_obj = null;
39  var $pobject = null;
40  var $pobject_id = null;
41 
42  function ilPaymentBillAdminGUI(&$user_obj,$a_pobject_id)
43  {
44  global $ilCtrl;
45 
46  $this->ctrl =& $ilCtrl;
47  $this->ctrl->setParameter($this,'pobject_id',$a_pobject_id);
48 
49  $this->ilPaymentBaseGUI();
50 
51  $this->pobject =& new ilPaymentObject($user_obj,$a_pobject_id);
52  $this->user_obj =& $user_obj;
53  $this->pobject_id = $a_pobject_id;
54  }
58  function &executeCommand()
59  {
60  global $tree;
61 
62  $cmd = $this->ctrl->getCmd();
63  switch ($this->ctrl->getNextClass($this))
64  {
65 
66  default:
67  if(!$cmd = $this->ctrl->getCmd())
68  {
69  $cmd = 'showBillData';
70  }
71  $this->$cmd();
72  break;
73  }
74  }
75 
76  function showBillData()
77  {
78  $this->__initBillVendorData();
79 
80  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.paya_bill_admin.html',true);
81  $this->__showButtons();
82 
83  $this->tpl->setVariable("BILL_FORMACTION",$this->ctrl->getFormAction($this));
84 
85  // set table header
86  $tmp_obj =& ilObjectFactory::getInstanceByRefId($this->pobject->getRefId(), false);
87  if($tmp_obj)
88  {
89  $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_'.$tmp_obj->getType().'.gif'));
90  $this->tpl->setVariable("ALT_IMG",$this->lng->txt('obj_'.$tmp_obj->getType()));
91  $this->tpl->setVariable("TITLE",$tmp_obj->getTitle());
92  $this->tpl->setVariable("DESCRIPTION",$this->lng->txt('paya_bill_data'));
93  }
94  else
95  {
96  $this->tpl->setVariable("TITLE", $this->lng->txt('object_not_found'));
97  }
98  // set plain text variables
99  $this->tpl->setVariable("TXT_CONTACT",$this->lng->txt('contact_data'));
100  $this->tpl->setVariable("TXT_GENDER",$this->lng->txt('gender'));
101  $this->tpl->setVariable("TXT_GENDER_F",$this->lng->txt("gender_f"));
102  $this->tpl->setVariable("TXT_GENDER_M",$this->lng->txt("gender_m"));
103  $this->tpl->setVariable("TXT_FIRSTNAME",$this->lng->txt('firstname'));
104  $this->tpl->setVariable("TXT_LASTNAME",$this->lng->txt('lastname'));
105  $this->tpl->setVariable("TXT_TITLE",$this->lng->txt('person_title'));
106  $this->tpl->setVariable("TXT_INSTITUTION",$this->lng->txt('institution'));
107  $this->tpl->setVariable("TXT_DEPARTMENT",$this->lng->txt('department'));
108  $this->tpl->setVariable("TXT_STREET",$this->lng->txt('street'));
109  $this->tpl->setVariable("TXT_ZIPCODE",$this->lng->txt('zipcode'));
110  $this->tpl->setVariable("TXT_CITY",$this->lng->txt('city'));
111  $this->tpl->setVariable("TXT_COUNTRY",$this->lng->txt('country'));
112  $this->tpl->setVariable("TXT_PHONE",$this->lng->txt('phone'));
113  $this->tpl->setVariable("TXT_FAX",$this->lng->txt('fax'));
114  $this->tpl->setVariable("TXT_EMAIL",$this->lng->txt('email'));
115  $this->tpl->setVariable("TXT_ACCOUNT_DATA",$this->lng->txt('account_data'));
116  $this->tpl->setVariable("TXT_ACCOUNT_NUMBER",$this->lng->txt('account_number'));
117  $this->tpl->setVariable("TXT_BANKCODE",$this->lng->txt('bankcode'));
118  $this->tpl->setVariable("TXT_IBAN",$this->lng->txt('iban'));
119  $this->tpl->setVariable("TXT_BIC",$this->lng->txt('bic'));
120  $this->tpl->setVariable("TXT_BANKNAME",$this->lng->txt('bankname'));
121 
122 
123  $this->tpl->setVariable("INPUT_VALUE",$this->lng->txt('save'));
124 
125  // set radios
126 
127  $gender = isset($_POST['gender']) ? $_POST['gender'] : $this->bvd_obj->getGender();
128 
129  $this->tpl->setVariable("GENDER_CHECK_M",ilUtil::formRadioButton($gender == 1 ? 1 : 0,'gender',1));
130  $this->tpl->setVariable("GENDER_CHECK_F",ilUtil::formRadioButton($gender == 2 ? 1 : 0,'gender',2));
131 
132  // fill defaults
133 
134  $this->tpl->setVariable("FIRSTNAME",
135  isset($_POST['firstname'])
136  ? ilUtil::prepareFormOutput($_POST['firstname'],true)
137  : ilUtil::prepareFormOutput($this->bvd_obj->getFirstname()));
138  $this->tpl->setVariable("LASTNAME",
139  isset($_POST['lastname'])
140  ? ilUtil::prepareFormOutput($_POST['lastname'],true)
141  : ilUtil::prepareFormOutput($this->bvd_obj->getLastname()));
142  $this->tpl->setVariable("INSTITUTION",
143  isset($_POST['institution'])
144  ? ilUtil::prepareFormOutput($_POST['institution'],true)
145  : ilUtil::prepareFormOutput($this->bvd_obj->getInstitution()));
146  $this->tpl->setVariable("DEPARTMENT",
147  isset($_POST['department'])
148  ? ilUtil::prepareFormOutput($_POST['department'],true)
149  : ilUtil::prepareFormOutput($this->bvd_obj->getDepartment()));
150  $this->tpl->setVariable("STREET",
151  isset($_POST['street'])
152  ? ilUtil::prepareFormOutput($_POST['street'],true)
153  : ilUtil::prepareFormOutput($this->bvd_obj->getStreet()));
154  $this->tpl->setVariable("ZIPCODE",
155  isset($_POST['zipcode'])
156  ? ilUtil::prepareFormOutput($_POST['zipcode'],true)
157  : ilUtil::prepareFormOutput($this->bvd_obj->getZipcode()));
158  $this->tpl->setVariable("CITY",
159  isset($_POST['city'])
160  ? ilUtil::prepareFormOutput($_POST['city'],true)
161  : ilUtil::prepareFormOutput($this->bvd_obj->getCity()));
162  $this->tpl->setVariable("COUNTRY",
163  isset($_POST['country'])
164  ? ilUtil::prepareFormOutput($_POST['country'],true)
165  : ilUtil::prepareFormOutput($this->bvd_obj->getCountry()));
166  $this->tpl->setVariable("PHONE",
167  isset($_POST['phone'])
168  ? ilUtil::prepareFormOutput($_POST['phone'],true)
169  : ilUtil::prepareFormOutput($this->bvd_obj->getPhone()));
170  $this->tpl->setVariable("FAX",
171  isset($_POST['fax'])
172  ? ilUtil::prepareFormOutput($_POST['fax'],true)
173  : ilUtil::prepareFormOutput($this->bvd_obj->getFax()));
174  $this->tpl->setVariable("EMAIL",
175  isset($_POST['email'])
176  ? ilUtil::prepareFormOutput($_POST['email'],true)
177  : ilUtil::prepareFormOutput($this->bvd_obj->getEmail()));
178  $this->tpl->setVariable("ACCOUNT_NUMBER",
179  isset($_POST['account_number'])
180  ? ilUtil::prepareFormOutput($_POST['account_number'],true)
181  : ilUtil::prepareFormOutput($this->bvd_obj->getAccountNumber()));
182  $this->tpl->setVariable("BANKCODE",
183  isset($_POST['bankcode'])
184  ? ilUtil::prepareFormOutput($_POST['bankcode'],true)
185  : ilUtil::prepareFormOutput($this->bvd_obj->getBankcode()));
186  $this->tpl->setVariable("IBAN",
187  isset($_POST['iban'])
188  ? ilUtil::prepareFormOutput($_POST['iban'],true)
189  : ilUtil::prepareFormOutput($this->bvd_obj->getIban()));
190  $this->tpl->setVariable("BIC",
191  isset($_POST['bic'])
192  ? ilUtil::prepareFormOutput($_POST['bic'],true)
193  : ilUtil::prepareFormOutput($this->bvd_obj->getBic()));
194  $this->tpl->setVariable("BANKNAME",
195  isset($_POST['bankname'])
196  ? ilUtil::prepareFormOutput($_POST['bankname'],true)
197  : ilUtil::prepareFormOutput($this->bvd_obj->getBankname()));
198  }
199 
200  function update()
201  {
202  include_once './payment/classes/class.ilPaymentBillVendor.php';
203 
204  $this->bvd_obj =& new ilPaymentBillVendor($this->pobject_id);
205 
206  $this->bvd_obj->setGender($_POST['gender']);
207  $this->bvd_obj->setFirstname(ilUtil::stripSlashes($_POST['firstname']));
208  $this->bvd_obj->setLastname(ilUtil::stripSlashes($_POST['lastname']));
209  $this->bvd_obj->setTitle(ilUtil::stripSlashes($_POST['title']));
210  $this->bvd_obj->setInstitution(ilUtil::stripSlashes($_POST['institution']));
211  $this->bvd_obj->setDepartment(ilUtil::stripSlashes($_POST['department']));
212  $this->bvd_obj->setStreet(ilUtil::stripSlashes($_POST['street']));
213  $this->bvd_obj->setZipcode(ilUtil::stripSlashes($_POST['zipcode']));
214  $this->bvd_obj->setCity(ilUtil::stripSlashes($_POST['city']));
215  $this->bvd_obj->setCountry(ilUtil::stripSlashes($_POST['country']));
216  $this->bvd_obj->setPhone(ilUtil::stripSlashes($_POST['phone']));
217  $this->bvd_obj->setFax(ilUtil::stripSlashes($_POST['fax']));
218  $this->bvd_obj->setEmail(ilUtil::stripSlashes($_POST['email']));
219  $this->bvd_obj->setAccountNumber(ilUtil::stripSlashes($_POST['account_number']));
220  $this->bvd_obj->setBankcode(ilUtil::stripSlashes($_POST['bankcode']));
221  $this->bvd_obj->setIban(ilUtil::stripSlashes($_POST['iban']));
222  $this->bvd_obj->setBic(ilUtil::stripSlashes($_POST['bic']));
223  $this->bvd_obj->setBankname(ilUtil::stripSlashes($_POST['bankname']));
224 
225  if($this->bvd_obj->validate())
226  {
227  $this->bvd_obj->update();
228  ilUtil::sendInfo($this->lng->txt('paya_bill_data_updated'));
229  }
230  else
231  {
232  ilUtil::sendInfo($this->lng->txt('paya_pay_method_fill_out_required').$this->bvd_obj->getMessage());
233  }
234  $this->showBillData();
235 
236  return true;
237  }
238 
239 
240  // PRIVATE
241  function __showButtons()
242  {
243  // DETAILS LINK
244  $this->ctrl->setParameterByClass('ilpaymentobjectgui','pobject_id',$this->pobject_id);
245 
246  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
247  $this->tpl->setCurrentBlock("btn_cell");
248  $this->tpl->setVariable("BTN_LINK",$this->ctrl->getLinkTargetByClass('ilpaymentobjectgui','editDetails'));
249  $this->tpl->setVariable("BTN_TXT",$this->lng->txt('paya_edit_details'));
250  $this->tpl->parseCurrentBlock();
251 
252  // PRICES LINK
253  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
254  $this->tpl->setCurrentBlock("btn_cell");
255  $this->tpl->setVariable("BTN_LINK",$this->ctrl->getLinkTargetByClass('ilpaymentobjectgui','editPrices'));
256  $this->tpl->setVariable("BTN_TXT",$this->lng->txt('paya_edit_prices'));
257  $this->tpl->parseCurrentBlock();
258 
259  $this->showButton('showBillData',$this->lng->txt('paya_edit_pay_method'));
260  }
261 
263  {
264  include_once './payment/classes/class.ilPaymentBillVendor.php';
265 
266  $this->bvd_obj =& new ilPaymentBillVendor($this->pobject_id);
267 
268  if(!$this->bvd_obj->hasData())
269  {
270  ilUtil::sendInfo($this->lng->txt('paya_read_from_personal_profile'));
271 
272  $tmp_user =& ilObjectFactory::getInstanceByObjId($this->pobject->getVendorId());
273 
274  switch($tmp_user->getGender())
275  {
276  case 'm':
277  $this->bvd_obj->setGender(1);
278  break;
279  case 'f':
280  $this->bvd_obj->setGender(2);
281  break;
282  }
283  $this->bvd_obj->setFirstname($tmp_user->getFirstname());
284  $this->bvd_obj->setLastname($tmp_user->getLastname());
285  $this->bvd_obj->setTitle($tmp_user->getTitle());
286  $this->bvd_obj->setInstitution($tmp_user->getInstitution());
287  $this->bvd_obj->setDepartment($tmp_user->getDepartment());
288  $this->bvd_obj->setStreet($tmp_user->getStreet());
289  $this->bvd_obj->setZipcode($tmp_user->getZipcode());
290  $this->bvd_obj->setCity($tmp_user->getCity());
291  $this->bvd_obj->setCountry($tmp_user->getCountry());
292  $this->bvd_obj->setPhone($tmp_user->getPhoneOffice());
293  $this->bvd_obj->setFax($tmp_user->getFax());
294  $this->bvd_obj->setEmail($tmp_user->getEmail());
295  }
296  }
297 }
298 ?>