• Main Page
  • Related Pages
  • Modules
  • 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                 $this->__buildHeader();
00079 
00080                 $this->$cmd();
00081         }
00082 
00083         function showDetails()
00084         {
00085                 if($this->object->getType() == 'crs' && $this->object->getSubscriptionMaxMembers() > 0)
00086                 {
00087                         $this->object->initCourseMemberObject();
00088                         
00089                         if($this->object->getSubscriptionMaxMembers() <= $this->object->members_obj->getCountMembers())
00090                         {                         
00091                                 ilUtil::sendInfo($this->lng->txt('pay_crs_max_members_exceeded'));
00092                                 return false;
00093                         }
00094                 }
00095                 
00096                 $this->__initPaymentObject();
00097                 $this->__initPricesObject();
00098                 $this->__initShoppingCartObject();      
00099                 
00100                 $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.pay_purchase_details.html','payment');
00101 
00102                 if($this->pobject->getStatus() == $this->pobject->STATUS_EXPIRES)
00103                 {
00104                         ilUtil::sendInfo($this->lng->txt('pay_expires_info'));
00105 
00106                         return false;
00107                 }
00108 
00109                 $prices = $this->price_obj->getPrices();
00110                 $buyedObject = "";
00111                 if($this->sc_obj->isInShoppingCart($this->pobject->getPobjectId()))
00112                 {
00113                         $buyedObject = $this->sc_obj->getEntry($this->pobject->getPobjectId());
00114                         if (is_array($prices) &&
00115                                 count($prices) > 1)
00116                         {
00117                                 ilUtil::sendInfo($this->lng->txt('pay_item_already_in_sc_choose_another'));
00118                         }
00119                         else
00120                         {
00121                                 ilUtil::sendInfo($this->lng->txt('pay_item_already_in_sc'));
00122                         }
00123 
00124                         $this->tpl->setCurrentBlock("shopping_cart");
00125                         $this->tpl->setVariable("LINK_GOTO_SHOPPING_CART", "ilias.php?cmdClass=ilpaymentgui&baseClass=ilPersonalDesktopGUI&cmd=showShoppingCart");
00126                         $this->tpl->setVariable("TXT_GOTO_SHOPPING_CART", $this->lng->txt('pay_goto_shopping_cart'));
00127 #                       $this->tpl->setVariable("TXT_BUY", $this->lng->txt('pay_click_to_buy'));
00128                         $this->tpl->parseCurrentBlock("shopping_cart");
00129                 }
00130 
00131                 $this->ctrl->setParameter($this, "ref_id", $this->pobject->getRefId());
00132 
00133 #               if (!is_array($buyedObject) ||
00134 #                       (is_array($buyedObject) && is_array($prices) && count($prices) > 1))
00135 #               {
00136                         $this->tpl->setVariable("DETAILS_FORMACTION",$this->ctrl->getFormAction($this));
00137                         $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_'.$this->object->getType().'_b.gif'));
00138                         $this->tpl->setVariable("ALT_IMG",$this->lng->txt('obj_'.$this->object->getType()));
00139                         $this->tpl->setVariable("TITLE",$this->object->getTitle());
00140 
00141                         // payment infos
00142                         $this->tpl->setVariable("TXT_INFO",$this->lng->txt('info'));
00143                         switch($this->pobject->getPayMethod())
00144                         {
00145                                 case $this->pobject->PAY_METHOD_BILL:
00146                                         $this->tpl->setVariable("INFO_PAY",$this->lng->txt('pay_bill'));
00147                                         $this->tpl->setVariable("INPUT_CMD",'getBill');
00148                                         $this->tpl->setVariable("INPUT_VALUE",$this->lng->txt('pay_get_bill'));
00149                                         break;
00150 
00151                                 case $this->pobject->PAY_METHOD_BMF:
00152                                         $this->tpl->setVariable("INFO_PAY",$this->lng->txt('pay_info'));
00153                                         if (is_array($buyedObject))
00154                                         {
00155                                                 if (is_array($prices) && count($prices) > 1)
00156                                                 {
00157                                                         $this->tpl->setVariable("INPUT_CMD",'addToShoppingCart');
00158                                                         $this->tpl->setVariable("INPUT_VALUE",$this->lng->txt('pay_change_price'));
00159                                                 }
00160                                         }
00161                                         else
00162                                         {
00163                                                 $this->tpl->setVariable("INPUT_CMD",'addToShoppingCart');
00164                                                 $this->tpl->setVariable("INPUT_VALUE",$this->lng->txt('pay_add_to_shopping_cart'));
00165                                         }
00166                                         break;
00167 
00168                                 case $this->pobject->PAY_METHOD_PAYPAL:
00169                                         $this->tpl->setVariable("INFO_PAY",$this->lng->txt('pay_info'));
00170                                         if (is_array($buyedObject))
00171                                         {
00172                                                 if (is_array($prices) && count($prices) > 1)
00173                                                 {
00174                                                         $this->tpl->setVariable("INPUT_CMD",'addToShoppingCart');
00175                                                         $this->tpl->setVariable("INPUT_VALUE",$this->lng->txt('pay_change_price'));
00176                                                 }
00177                                         }
00178                                         else
00179                                         {
00180                                                 $this->tpl->setVariable("INPUT_CMD",'addToShoppingCart');
00181                                                 $this->tpl->setVariable("INPUT_VALUE",$this->lng->txt('pay_add_to_shopping_cart'));
00182                                         }
00183                                         break;
00184                         }
00185 
00186                         $this->tpl->setVariable("ROWSPAN",count($prices));
00187                         $this->tpl->setVariable("TXT_PRICES",$this->lng->txt('prices'));
00188 #               }
00189 
00190                 if (is_array($prices))
00191                 {
00192 #                       if (count($prices) > 1)
00193 #                       {
00194                                 $counter = 0;
00195                                 foreach($prices as $price)
00196                                 {
00197                                         if ($counter == 0)
00198                                         {
00199                                                 $placeholderCheckbox = "CHECKBOX";
00200                                                 $placeholderDuration = "DURATION";
00201                                                 $placeholderPrice = "PRICE";
00202                                         }
00203                                         else
00204                                         {
00205                                                 $placeholderCheckbox = "ROW_CHECKBOX";
00206                                                 $placeholderDuration = "ROW_DURATION";
00207                                                 $placeholderPrice = "ROW_PRICE";
00208                                         }
00209                                         $this->tpl->setCurrentBlock("price_row");
00210                                         if ($buyedObject["price_id"] == $price['price_id'])
00211                                         {
00212                                                 $this->tpl->setVariable($placeholderCheckbox,ilUtil::formRadioButton(1,'price_id',$price['price_id']));
00213                                         }
00214                                         else
00215                                         {
00216                                                 $this->tpl->setVariable($placeholderCheckbox,ilUtil::formRadioButton(0,'price_id',$price['price_id']));
00217                                         }
00218                                         $this->tpl->setVariable($placeholderDuration,$price['duration'].' '.$this->lng->txt('paya_months'));
00219                                         $this->tpl->setVariable($placeholderPrice,ilPaymentPrices::_getPriceString($price['price_id']));
00220                                         $this->tpl->parseCurrentBlock();
00221                                         $counter++;
00222                                 }
00223 #                       }
00224 #                       else if (!is_array($buyedObject))
00225 #                       {
00226 #                               foreach($prices as $price)
00227 #                               {
00228 #                                       $this->tpl->setVariable("CHECKBOX",ilUtil::formRadioButton(0,'price_id',$price['price_id']));
00229 #                                       $this->tpl->setVariable("DURATION",$price['duration'].' '.$this->lng->txt('paya_months'));
00230 #                                       $this->tpl->setVariable("PRICE",ilPaymentPrices::_getPriceString($price['price_id']));
00231 #                               }
00232 #                       }
00233                 }
00234 
00235         }
00236 
00237         function addToShoppingCart()
00238         {
00239                 if($this->object->getType() == 'crs' && $this->object->getSubscriptionMaxMembers() > 0)
00240                 {
00241                         $this->object->initCourseMemberObject();
00242                         
00243                         if($this->object->getSubscriptionMaxMembers() <= $this->object->members_obj->getCountMembers())
00244                         {                         
00245                                 ilUtil::sendInfo($this->lng->txt('pay_crs_max_members_exceeded'));
00246                                 return false;
00247                         }
00248                 }
00249                 
00250                 if(!isset($_POST['price_id']))
00251                 {
00252                         ilUtil::sendInfo($this->lng->txt('pay_select_price'));
00253                         $this->showDetails();
00254 
00255                         return true;
00256                 }
00257                 else
00258                 {
00259                         $this->__initPaymentObject();
00260                         $this->__initShoppingCartObject();
00261                         
00262 
00263                         $this->sc_obj->setPriceId((int) $_POST['price_id']);
00264                         $this->sc_obj->setPobjectId($this->pobject->getPobjectId());
00265                         $this->sc_obj->add();
00266 
00267 #                       $tmp_obj =& ilObjectFactory::getInstanceByRefId($this->pobject->getRefId());
00268 
00269                         $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.pay_purchase_details.html','payment');
00270                         $this->tpl->setCurrentBlock("shopping_cart");
00271                         $this->tpl->setVariable("LINK_GOTO_SHOPPING_CART", "ilias.php?cmdClass=ilpaymentgui&baseClass=ilPersonalDesktopGUI&cmd=showShoppingCart");
00272                         $this->tpl->setVariable("TXT_GOTO_SHOPPING_CART", $this->lng->txt('pay_goto_shopping_cart'));
00273 #                       $this->tpl->setVariable("TXT_BUY", $this->lng->txt('pay_click_to_buy'));
00274                         $this->tpl->parseCurrentBlock("shopping_cart");
00275 
00276                         ilUtil::sendInfo($this->lng->txt('pay_added_to_shopping_cart'));
00277 
00278                         return true;
00279                 }
00280         }
00281 
00282         // PRIVATE
00283         function __initShoppingCartObject()
00284         {
00285                 include_once './payment/classes/class.ilPaymentShoppingCart.php';
00286 
00287                 $this->sc_obj =& new ilPaymentShoppingCart($this->ilias->account);
00288 
00289                 return true;
00290         }
00291 
00292         function __initPaymentObject()
00293         {
00294                 include_once './payment/classes/class.ilPaymentObject.php';
00295 
00296                 $this->pobject =& new ilPaymentObject($this->ilias->account,ilPaymentObject::_lookupPobjectId($this->ref_id));
00297 
00298                 return true;
00299         }
00300         function __initPricesObject()
00301         {
00302                 include_once './payment/classes/class.ilPaymentPrices.php';
00303                 
00304                 $this->price_obj =& new ilPaymentPrices($this->pobject->getPobjectId());
00305 
00306                 return true;
00307         }
00308 
00309         function __buildHeader()
00310         {
00311                 $this->tpl->addBlockFile("CONTENT", "content", "tpl.payb_content.html");
00312                 
00313                 $this->tpl->setVariable("HEADER",$this->object->getTitle());
00314                 $this->tpl->setVariable("DESCRIPTION",$this->object->getDescription());
00315 
00316 #               $this->__buildStylesheet();
00317 #               $this->__buildStatusline();
00318         }
00319 
00320         function  __buildStatusline()
00321         {
00322                 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00323                 $this->__buildLocator();
00324         }       
00325 
00326         function __buildLocator()
00327         {
00328                 $this->tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html");
00329                 $this->tpl->setVariable("TXT_LOCATOR",$this->lng->txt("locator"));
00330 
00331                 $this->tpl->setCurrentBlock("locator_item");
00332                 $this->tpl->setVariable("ITEM", $this->lng->txt("repository"));
00333                 $this->tpl->setVariable("LINK_ITEM", "../repository.php?getlast=true");
00334                 $this->tpl->parseCurrentBlock();
00335 
00336                 // CHECK for new mail and info
00337                 ilUtil::sendInfo();
00338 
00339                 return true;
00340         }
00341 
00342         function __buildStylesheet()
00343         {
00344                 $this->tpl->setVariable("LOCATION_STYLESHEET",ilUtil::getStyleSheetLocation());
00345         }
00346 
00347         
00348 
00349 }
00350 ?>

Generated on Fri Dec 13 2013 17:56:54 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1