ILIAS  Release_3_10_x_branch Revision 61812
 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());
87 
88  $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_'.$tmp_obj->getType().'.gif'));
89  $this->tpl->setVariable("ALT_IMG",$this->lng->txt('obj_'.$tmp_obj->getType()));
90  $this->tpl->setVariable("TITLE",$tmp_obj->getTitle());
91  $this->tpl->setVariable("DESCRIPTION",$this->lng->txt('paya_bill_data'));
92 
93  // set plain text variables
94  $this->tpl->setVariable("TXT_CONTACT",$this->lng->txt('contact_data'));
95  $this->tpl->setVariable("TXT_GENDER",$this->lng->txt('gender'));
96  $this->tpl->setVariable("TXT_GENDER_F",$this->lng->txt("gender_f"));
97  $this->tpl->setVariable("TXT_GENDER_M",$this->lng->txt("gender_m"));
98  $this->tpl->setVariable("TXT_FIRSTNAME",$this->lng->txt('firstname'));
99  $this->tpl->setVariable("TXT_LASTNAME",$this->lng->txt('lastname'));
100  $this->tpl->setVariable("TXT_TITLE",$this->lng->txt('person_title'));
101  $this->tpl->setVariable("TXT_INSTITUTION",$this->lng->txt('institution'));
102  $this->tpl->setVariable("TXT_DEPARTMENT",$this->lng->txt('department'));
103  $this->tpl->setVariable("TXT_STREET",$this->lng->txt('street'));
104  $this->tpl->setVariable("TXT_ZIPCODE",$this->lng->txt('zipcode'));
105  $this->tpl->setVariable("TXT_CITY",$this->lng->txt('city'));
106  $this->tpl->setVariable("TXT_COUNTRY",$this->lng->txt('country'));
107  $this->tpl->setVariable("TXT_PHONE",$this->lng->txt('phone'));
108  $this->tpl->setVariable("TXT_FAX",$this->lng->txt('fax'));
109  $this->tpl->setVariable("TXT_EMAIL",$this->lng->txt('email'));
110  $this->tpl->setVariable("TXT_ACCOUNT_DATA",$this->lng->txt('account_data'));
111  $this->tpl->setVariable("TXT_ACCOUNT_NUMBER",$this->lng->txt('account_number'));
112  $this->tpl->setVariable("TXT_BANKCODE",$this->lng->txt('bankcode'));
113  $this->tpl->setVariable("TXT_IBAN",$this->lng->txt('iban'));
114  $this->tpl->setVariable("TXT_BIC",$this->lng->txt('bic'));
115  $this->tpl->setVariable("TXT_BANKNAME",$this->lng->txt('bankname'));
116 
117 
118  $this->tpl->setVariable("INPUT_VALUE",$this->lng->txt('save'));
119 
120  // set radios
121 
122  $gender = isset($_POST['gender']) ? $_POST['gender'] : $this->bvd_obj->getGender();
123 
124  $this->tpl->setVariable("GENDER_CHECK_M",ilUtil::formRadioButton($gender == 1 ? 1 : 0,'gender',1));
125  $this->tpl->setVariable("GENDER_CHECK_F",ilUtil::formRadioButton($gender == 2 ? 1 : 0,'gender',2));
126 
127  // fill defaults
128 
129  $this->tpl->setVariable("FIRSTNAME",
130  isset($_POST['firstname'])
131  ? ilUtil::prepareFormOutput($_POST['firstname'],true)
132  : ilUtil::prepareFormOutput($this->bvd_obj->getFirstname()));
133  $this->tpl->setVariable("LASTNAME",
134  isset($_POST['lastname'])
135  ? ilUtil::prepareFormOutput($_POST['lastname'],true)
136  : ilUtil::prepareFormOutput($this->bvd_obj->getLastname()));
137  $this->tpl->setVariable("INSTITUTION",
138  isset($_POST['institution'])
139  ? ilUtil::prepareFormOutput($_POST['institution'],true)
140  : ilUtil::prepareFormOutput($this->bvd_obj->getInstitution()));
141  $this->tpl->setVariable("DEPARTMENT",
142  isset($_POST['department'])
143  ? ilUtil::prepareFormOutput($_POST['department'],true)
144  : ilUtil::prepareFormOutput($this->bvd_obj->getDepartment()));
145  $this->tpl->setVariable("STREET",
146  isset($_POST['street'])
147  ? ilUtil::prepareFormOutput($_POST['street'],true)
148  : ilUtil::prepareFormOutput($this->bvd_obj->getStreet()));
149  $this->tpl->setVariable("ZIPCODE",
150  isset($_POST['zipcode'])
151  ? ilUtil::prepareFormOutput($_POST['zipcode'],true)
152  : ilUtil::prepareFormOutput($this->bvd_obj->getZipcode()));
153  $this->tpl->setVariable("CITY",
154  isset($_POST['city'])
155  ? ilUtil::prepareFormOutput($_POST['city'],true)
156  : ilUtil::prepareFormOutput($this->bvd_obj->getCity()));
157  $this->tpl->setVariable("COUNTRY",
158  isset($_POST['country'])
159  ? ilUtil::prepareFormOutput($_POST['country'],true)
160  : ilUtil::prepareFormOutput($this->bvd_obj->getCountry()));
161  $this->tpl->setVariable("PHONE",
162  isset($_POST['phone'])
163  ? ilUtil::prepareFormOutput($_POST['phone'],true)
164  : ilUtil::prepareFormOutput($this->bvd_obj->getPhone()));
165  $this->tpl->setVariable("FAX",
166  isset($_POST['fax'])
167  ? ilUtil::prepareFormOutput($_POST['fax'],true)
168  : ilUtil::prepareFormOutput($this->bvd_obj->getFax()));
169  $this->tpl->setVariable("EMAIL",
170  isset($_POST['email'])
171  ? ilUtil::prepareFormOutput($_POST['email'],true)
172  : ilUtil::prepareFormOutput($this->bvd_obj->getEmail()));
173  $this->tpl->setVariable("ACCOUNT_NUMBER",
174  isset($_POST['account_number'])
175  ? ilUtil::prepareFormOutput($_POST['account_number'],true)
176  : ilUtil::prepareFormOutput($this->bvd_obj->getAccountNumber()));
177  $this->tpl->setVariable("BANKCODE",
178  isset($_POST['bankcode'])
179  ? ilUtil::prepareFormOutput($_POST['bankcode'],true)
180  : ilUtil::prepareFormOutput($this->bvd_obj->getBankcode()));
181  $this->tpl->setVariable("IBAN",
182  isset($_POST['iban'])
183  ? ilUtil::prepareFormOutput($_POST['iban'],true)
184  : ilUtil::prepareFormOutput($this->bvd_obj->getIban()));
185  $this->tpl->setVariable("BIC",
186  isset($_POST['bic'])
187  ? ilUtil::prepareFormOutput($_POST['bic'],true)
188  : ilUtil::prepareFormOutput($this->bvd_obj->getBic()));
189  $this->tpl->setVariable("BANKNAME",
190  isset($_POST['bankname'])
191  ? ilUtil::prepareFormOutput($_POST['bankname'],true)
192  : ilUtil::prepareFormOutput($this->bvd_obj->getBankname()));
193  }
194 
195  function update()
196  {
197  include_once './payment/classes/class.ilPaymentBillVendor.php';
198 
199  $this->bvd_obj =& new ilPaymentBillVendor($this->pobject_id);
200 
201  $this->bvd_obj->setGender($_POST['gender']);
202  $this->bvd_obj->setFirstname(ilUtil::stripSlashes($_POST['firstname']));
203  $this->bvd_obj->setLastname(ilUtil::stripSlashes($_POST['lastname']));
204  $this->bvd_obj->setTitle(ilUtil::stripSlashes($_POST['title']));
205  $this->bvd_obj->setInstitution(ilUtil::stripSlashes($_POST['institution']));
206  $this->bvd_obj->setDepartment(ilUtil::stripSlashes($_POST['department']));
207  $this->bvd_obj->setStreet(ilUtil::stripSlashes($_POST['street']));
208  $this->bvd_obj->setZipcode(ilUtil::stripSlashes($_POST['zipcode']));
209  $this->bvd_obj->setCity(ilUtil::stripSlashes($_POST['city']));
210  $this->bvd_obj->setCountry(ilUtil::stripSlashes($_POST['country']));
211  $this->bvd_obj->setPhone(ilUtil::stripSlashes($_POST['phone']));
212  $this->bvd_obj->setFax(ilUtil::stripSlashes($_POST['fax']));
213  $this->bvd_obj->setEmail(ilUtil::stripSlashes($_POST['email']));
214  $this->bvd_obj->setAccountNumber(ilUtil::stripSlashes($_POST['account_number']));
215  $this->bvd_obj->setBankcode(ilUtil::stripSlashes($_POST['bankcode']));
216  $this->bvd_obj->setIban(ilUtil::stripSlashes($_POST['iban']));
217  $this->bvd_obj->setBic(ilUtil::stripSlashes($_POST['bic']));
218  $this->bvd_obj->setBankname(ilUtil::stripSlashes($_POST['bankname']));
219 
220  if($this->bvd_obj->validate())
221  {
222  $this->bvd_obj->update();
223  ilUtil::sendInfo($this->lng->txt('paya_bill_data_updated'));
224  }
225  else
226  {
227  ilUtil::sendInfo($this->lng->txt('paya_pay_method_fill_out_required').$this->bvd_obj->getMessage());
228  }
229  $this->showBillData();
230 
231  return true;
232  }
233 
234 
235  // PRIVATE
236  function __showButtons()
237  {
238  // DETAILS LINK
239  $this->ctrl->setParameterByClass('ilpaymentobjectgui','pobject_id',$this->pobject_id);
240 
241  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
242  $this->tpl->setCurrentBlock("btn_cell");
243  $this->tpl->setVariable("BTN_LINK",$this->ctrl->getLinkTargetByClass('ilpaymentobjectgui','editDetails'));
244  $this->tpl->setVariable("BTN_TXT",$this->lng->txt('paya_edit_details'));
245  $this->tpl->parseCurrentBlock();
246 
247  // PRICES LINK
248  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
249  $this->tpl->setCurrentBlock("btn_cell");
250  $this->tpl->setVariable("BTN_LINK",$this->ctrl->getLinkTargetByClass('ilpaymentobjectgui','editPrices'));
251  $this->tpl->setVariable("BTN_TXT",$this->lng->txt('paya_edit_prices'));
252  $this->tpl->parseCurrentBlock();
253 
254  $this->showButton('showBillData',$this->lng->txt('paya_edit_pay_method'));
255  }
256 
258  {
259  include_once './payment/classes/class.ilPaymentBillVendor.php';
260 
261  $this->bvd_obj =& new ilPaymentBillVendor($this->pobject_id);
262 
263  if(!$this->bvd_obj->hasData())
264  {
265  ilUtil::sendInfo($this->lng->txt('paya_read_from_personal_profile'));
266 
267  $tmp_user =& ilObjectFactory::getInstanceByObjId($this->pobject->getVendorId());
268 
269  switch($tmp_user->getGender())
270  {
271  case 'm':
272  $this->bvd_obj->setGender(1);
273  break;
274  case 'f':
275  $this->bvd_obj->setGender(2);
276  break;
277  }
278  $this->bvd_obj->setFirstname($tmp_user->getFirstname());
279  $this->bvd_obj->setLastname($tmp_user->getLastname());
280  $this->bvd_obj->setTitle($tmp_user->getTitle());
281  $this->bvd_obj->setInstitution($tmp_user->getInstitution());
282  $this->bvd_obj->setDepartment($tmp_user->getDepartment());
283  $this->bvd_obj->setStreet($tmp_user->getStreet());
284  $this->bvd_obj->setZipcode($tmp_user->getZipcode());
285  $this->bvd_obj->setCity($tmp_user->getCity());
286  $this->bvd_obj->setCountry($tmp_user->getCountry());
287  $this->bvd_obj->setPhone($tmp_user->getPhoneOffice());
288  $this->bvd_obj->setFax($tmp_user->getFax());
289  $this->bvd_obj->setEmail($tmp_user->getEmail());
290  }
291  }
292 }
293 ?>