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

payment/classes/class.ilPaymentPurchaseGUI.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 
00024 
00035 require_once "./classes/class.ilObjectGUI.php";
00036 
00037 class ilPaymentPurchaseGUI extends ilObjectGUI
00038 {
00039         var $ctrl;
00040         var $ilias;
00041         var $lng;
00042         var $tpl;
00043 
00044         var $object = null;
00045 
00046         function ilPaymentPurchaseGUI($a_ref_id)
00047         {
00048                 global $ilCtrl,$lng,$ilErr,$ilias,$tpl,$tree;
00049 
00050                 $this->ctrl =& $ilCtrl;
00051                 $this->ctrl->saveParameter($this,array("ref_id"));
00052 
00053                 $this->ilErr =& $ilErr;
00054                 $this->ilias =& $ilias;
00055 
00056                 $this->lng =& $lng;
00057                 $this->lng->loadLanguageModule('payment');
00058 
00059                 $this->tpl =& $tpl;
00060 
00061                 $this->ref_id = $a_ref_id;
00062 
00063                 $this->object =& ilObjectFactory::getInstanceByRefId($this->ref_id);
00064         }
00065 
00069         function &executeCommand()
00070         {
00071                 $cmd = $this->ctrl->getCmd();
00072 
00073                 if (!$cmd = $this->ctrl->getCmd())
00074                 {
00075                         $cmd = "showDetails";
00076                 }
00077                 
00078                 // build header if called from start_purchase.php
00079                 if($this->ctrl->getTargetScript() == 'start_purchase.php')
00080                 {
00081                         $this->__buildHeader();
00082                 }
00083                 $this->$cmd();
00084         }
00085 
00086         function showDetails()
00087         {
00088                 $this->__initPaymentObject();
00089                 $this->__initPricesObject();
00090                 $this->__initShoppingCartObject();
00091 
00092                 $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.pay_purchase_details.html','payment');
00093 
00094                 if($this->pobject->getStatus() == $this->pobject->STATUS_EXPIRES)
00095                 {
00096                         sendInfo($this->lng->txt('pay_expires_info'));
00097 
00098                         return false;
00099                 }
00100 
00101                 $prices = $this->price_obj->getPrices();
00102                 $buyedObject = "";
00103                 if($this->sc_obj->isInShoppingCart($this->pobject->getPobjectId()))
00104                 {
00105                         $buyedObject = $this->sc_obj->getEntry($this->pobject->getPobjectId());
00106                         if (is_array($prices) &&
00107                                 count($prices) > 1)
00108                         {
00109                                 sendInfo($this->lng->txt('pay_item_already_in_sc_choose_another'));
00110                         }
00111                         else
00112                         {
00113                                 sendInfo($this->lng->txt('pay_item_already_in_sc'));
00114                         }
00115 
00116                         $this->tpl->setCurrentBlock("shopping_cart");
00117                         $this->tpl->setVariable("LINK_GOTO_SHOPPING_CART", ILIAS_HTTP_PATH . "/payment/payment.php");
00118                         $this->tpl->setVariable("LINK_BUY", ILIAS_HTTP_PATH . "/payment/start_bmf.php");
00119                         $this->tpl->setVariable("TXT_GOTO_SHOPPING_CART", $this->lng->txt('pay_goto_shopping_cart'));
00120                         $this->tpl->setVariable("TXT_BUY", $this->lng->txt('pay_click_to_buy'));
00121                         $this->tpl->parseCurrentBlock("shopping_cart");
00122                 }
00123 
00124                 $this->ctrl->setParameter($this, "ref_id", $this->pobject->getRefId());
00125 
00126                 if (!is_array($buyedObject) ||
00127                         (is_array($buyedObject) && is_array($prices) && count($prices) > 1))
00128                 {
00129                         $this->tpl->setVariable("DETAILS_FORMACTION",$this->ctrl->getFormAction($this));
00130                         $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_'.$this->object->getType().'_b.gif'));
00131                         $this->tpl->setVariable("ALT_IMG",$this->lng->txt('obj_'.$this->object->getType()));
00132                         $this->tpl->setVariable("TITLE",$this->object->getTitle());
00133 
00134                         // payment infos
00135                         $this->tpl->setVariable("TXT_INFO",$this->lng->txt('info'));
00136                         switch($this->pobject->getPayMethod())
00137                         {
00138                                 case $this->pobject->PAY_METHOD_BILL:
00139                                         $this->tpl->setVariable("INFO_PAY",$this->lng->txt('pay_bill'));
00140                                         $this->tpl->setVariable("INPUT_CMD",'getBill');
00141                                         $this->tpl->setVariable("INPUT_VALUE",$this->lng->txt('pay_get_bill'));
00142                                         break;
00143 
00144                                 case $this->pobject->PAY_METHOD_BMF:
00145                                         $this->tpl->setVariable("INFO_PAY",$this->lng->txt('pay_bmf_info'));
00146                                         $this->tpl->setVariable("INPUT_CMD",'addToShoppingCart');
00147                                         $this->tpl->setVariable("INPUT_VALUE",$this->lng->txt('pay_add_to_shopping_cart'));
00148                                         break;
00149                         }
00150 
00151                         $this->tpl->setVariable("ROWSPAN",count($prices));
00152                         $this->tpl->setVariable("TXT_PRICES",$this->lng->txt('prices'));
00153                 }
00154 
00155                 if (is_array($prices))
00156                 {
00157                         if (count($prices) > 1)
00158                         {
00159                                 $counter = 0;
00160                                 foreach($prices as $price)
00161                                 {
00162                                         if ($counter == 0)
00163                                         {
00164                                                 $placeholderCheckbox = "CHECKBOX";
00165                                                 $placeholderDuration = "DURATION";
00166                                                 $placeholderPrice = "PRICE";
00167                                         }
00168                                         else
00169                                         {
00170                                                 $placeholderCheckbox = "ROW_CHECKBOX";
00171                                                 $placeholderDuration = "ROW_DURATION";
00172                                                 $placeholderPrice = "ROW_PRICE";
00173                                         }
00174                                         $this->tpl->setCurrentBlock("price_row");
00175                                         if ($buyedObject["price_id"] == $price['price_id'])
00176                                         {
00177                                                 $this->tpl->setVariable($placeholderCheckbox,ilUtil::formRadioButton(1,'price_id',$price['price_id']));
00178                                         }
00179                                         else
00180                                         {
00181                                                 $this->tpl->setVariable($placeholderCheckbox,ilUtil::formRadioButton(0,'price_id',$price['price_id']));
00182                                         }
00183                                         $this->tpl->setVariable($placeholderDuration,$price['duration'].' '.$this->lng->txt('paya_months'));
00184                                         $this->tpl->setVariable($placeholderPrice,ilPaymentPrices::_getPriceString($price['price_id']));
00185                                         $this->tpl->parseCurrentBlock();
00186                                         $counter++;
00187                                 }
00188                         }
00189                         else if (!is_array($buyedObject))
00190                         {
00191                                 foreach($prices as $price)
00192                                 {
00193                                         $this->tpl->setVariable("CHECKBOX",ilUtil::formRadioButton(0,'price_id',$price['price_id']));
00194                                         $this->tpl->setVariable("DURATION",$price['duration'].' '.$this->lng->txt('paya_months'));
00195                                         $this->tpl->setVariable("PRICE",ilPaymentPrices::_getPriceString($price['price_id']));
00196                                 }
00197                         }
00198                 }
00199 
00200         }
00201 
00202         function addToShoppingCart()
00203         {
00204                 if(!isset($_POST['price_id']))
00205                 {
00206                         sendInfo($this->lng->txt('pay_select_price'));
00207                         $this->showDetails();
00208 
00209                         return true;
00210                 }
00211                 else
00212                 {
00213                         $this->__initPaymentObject();
00214                         $this->__initShoppingCartObject();
00215                         
00216 
00217                         $this->sc_obj->setPriceId((int) $_POST['price_id']);
00218                         $this->sc_obj->setPobjectId($this->pobject->getPobjectId());
00219                         $this->sc_obj->add();
00220 
00221 #                       $tmp_obj =& ilObjectFactory::getInstanceByRefId($this->pobject->getRefId());
00222 
00223                         $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.pay_purchase_details.html','payment');
00224                         $this->tpl->setCurrentBlock("shopping_cart");
00225                         $this->tpl->setVariable("LINK_GOTO_SHOPPING_CART", ILIAS_HTTP_PATH . "/payment/payment.php");
00226                         $this->tpl->setVariable("LINK_BUY", ILIAS_HTTP_PATH . "/payment/start_bmf.php");
00227                         $this->tpl->setVariable("TXT_GOTO_SHOPPING_CART", $this->lng->txt('pay_goto_shopping_cart'));
00228                         $this->tpl->setVariable("TXT_BUY", $this->lng->txt('pay_click_to_buy'));
00229                         $this->tpl->parseCurrentBlock("shopping_cart");
00230 
00231                         sendInfo($this->lng->txt('pay_added_to_shopping_cart'));
00232 
00233                         return true;
00234                 }
00235         }
00236 
00237         // PRIVATE
00238         function __initShoppingCartObject()
00239         {
00240                 include_once './payment/classes/class.ilPaymentShoppingCart.php';
00241 
00242                 $this->sc_obj =& new ilPaymentShoppingCart($this->ilias->account);
00243 
00244                 return true;
00245         }
00246 
00247         function __initPaymentObject()
00248         {
00249                 include_once './payment/classes/class.ilPaymentObject.php';
00250 
00251                 $this->pobject =& new ilPaymentObject($this->ilias->account,ilPaymentObject::_lookupPobjectId($this->ref_id));
00252 
00253                 return true;
00254         }
00255         function __initPricesObject()
00256         {
00257                 include_once './payment/classes/class.ilPaymentPrices.php';
00258                 
00259                 $this->price_obj =& new ilPaymentPrices($this->pobject->getPobjectId());
00260 
00261                 return true;
00262         }
00263 
00264         function __buildHeader()
00265         {
00266                 $this->tpl->addBlockFile("CONTENT", "content", "tpl.payb_content.html");
00267                 
00268                 $this->tpl->setVariable("HEADER",$this->object->getTitle());
00269                 $this->tpl->setVariable("DESCRIPTION",$this->object->getDescription());
00270 
00271                 $this->__buildStylesheet();
00272                 $this->__buildStatusline();
00273         }
00274 
00275         function  __buildStatusline()
00276         {
00277                 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00278                 $this->__buildLocator();
00279         }       
00280 
00281         function __buildLocator()
00282         {
00283                 $this->tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html");
00284                 $this->tpl->setVariable("TXT_LOCATOR",$this->lng->txt("locator"));
00285 
00286                 $this->tpl->setCurrentBlock("locator_item");
00287                 $this->tpl->setVariable("ITEM", $this->lng->txt("repository"));
00288                 $this->tpl->setVariable("LINK_ITEM", "../repository.php?getlast=true");
00289                 $this->tpl->parseCurrentBlock();
00290 
00291                 // CHECK for new mail and info
00292                 sendInfo();
00293 
00294                 return true;
00295         }
00296 
00297         function __buildStylesheet()
00298         {
00299                 $this->tpl->setVariable("LOCATION_STYLESHEET",ilUtil::getStyleSheetLocation());
00300                 $this->tpl->setVariable("LOCATION_JAVASCRIPT",ilUtil::getJSPath('functions.js'));
00301         }
00302 
00303         
00304 
00305 }
00306 ?>

Generated on Fri Dec 13 2013 09:06:37 for ILIAS Release_3_4_x_branch .rev 46804 by  doxygen 1.7.1