Advertisement
ruberval

virtuemat

Sep 24th, 2013
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.57 KB | None | 0 0
  1. <?php
  2. /**
  3.  *
  4.  * Calc View
  5.  *
  6.  * @package VirtueMart
  7.  * @subpackage Payment Method
  8.  * @author Max Milbers
  9.  * @author valérie isaksen
  10.  * @link http://www.virtuemart.net
  11.  * @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved.
  12.  * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
  13.  * VirtueMart is free software. This version may have been modified pursuant
  14.  * to the GNU General Public License, and as distributed it includes or
  15.  * is derivative of works licensed under the GNU General Public License or
  16.  * other free or open source software licenses.
  17.  * @version $Id: view.html.php 5601 2012-03-04 18:22:24Z Milbo $
  18.  */
  19.  
  20. // Check to ensure this file is included in Joomla!
  21. defined('_JEXEC') or die('Restricted access');
  22.  
  23. // Load the view framework
  24. if(!class_exists('VmView'))require(JPATH_VM_ADMINISTRATOR.DS.'helpers'.DS.'vmview.php');
  25.  
  26. /**
  27.  * Description
  28.  *
  29.  * @package     VirtueMart
  30.  * @author valérie isaksen
  31.  */
  32. if (!class_exists('VirtueMartModelCurrency'))
  33. require(JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'currency.php');
  34.  
  35. class VirtuemartViewPaymentMethod extends VmView {
  36.  
  37.     function display($tpl = null) {
  38.  
  39.         // Load the helper(s)
  40.         $this->addHelperPath(JPATH_VM_ADMINISTRATOR.DS.'helpers');
  41.  
  42.         if(!class_exists('Permissions')) require(JPATH_VM_ADMINISTRATOR.DS.'helpers'.DS.'permissions.php');
  43.  
  44.         if (!class_exists('VmHTML'))
  45.             require(JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'html.php');
  46.  
  47.         if (!class_exists ('vmPlugin')) {
  48.             require(JPATH_VM_PLUGINS . DS . 'vmplugin.php');
  49.         }
  50.  
  51.  
  52.         $this->assignRef('perms', Permissions::getInstance());
  53.  
  54.         $model = VmModel::getModel('paymentmethod');
  55.  
  56.         //@todo should be depended by loggedVendor
  57.         //      $vendorId=1;
  58.         //      $this->assignRef('vendorId', $vendorId);
  59.         // TODO logo
  60.         $this->SetViewTitle();
  61.  
  62.         $layoutName = JRequest::getWord('layout', 'default');
  63.  
  64.         $vendorModel = VmModel::getModel('vendor');
  65.  
  66.         $vendorModel->setId(1);
  67.         $vendor = $vendorModel->getVendor();
  68.         $currencyModel = VmModel::getModel('currency');
  69.         $currencyModel = $currencyModel->getCurrency($vendor->vendor_currency);
  70.         $this->assignRef('vendor_currency', $currencyModel->currency_symbol);
  71.  
  72.         if ($layoutName == 'edit') {
  73.  
  74.             // Load the helper(s)
  75.             if (!class_exists('VmImage'))
  76.                 require(JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'image.php');
  77.  
  78.             if (!class_exists('vmParameters'))
  79.                 require(JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'parameterparser.php');
  80.  
  81.             $payment = $model->getPayment();
  82.             $this->assignRef('payment', $payment);
  83.             $this->assignRef('vmPPaymentList', self::renderInstalledPaymentPlugins($payment->payment_jplugin_id));
  84.             //          $this->assignRef('PaymentTypeList',self::renderPaymentRadioList($paym->payment_type));
  85.  
  86.             //          $this->assignRef('creditCardList',self::renderCreditCardRadioList($paym->payment_creditcards));
  87.             //          echo 'humpf <pre>'.print_r($paym).'</pre>' ;
  88.             //$this->assignRef('creditCardList',ShopFunctions::renderCreditCardList($paym->payment_creditcards,true));
  89.             $this->assignRef('shopperGroupList', ShopFunctions::renderShopperGroupList($payment->virtuemart_shoppergroup_ids, true));
  90.  
  91.             if(Vmconfig::get('multix','none')!=='none'){
  92.                 $vendorList= ShopFunctions::renderVendorList($payment->virtuemart_vendor_id);
  93.                 $this->assignRef('vendorList', $vendorList);
  94.             }
  95.  
  96.             $this->addStandardEditViewCommands( $payment->virtuemart_paymentmethod_id);
  97.         } else {
  98.             $this->addStandardDefaultViewCommands();
  99.             $this->addStandardDefaultViewLists($model);
  100.  
  101.             $payments = $model->getPayments();
  102.             $this->assignRef('payments',    $payments);
  103.  
  104.             $pagination = $model->getPagination();
  105.             $this->assignRef('pagination', $pagination);
  106.  
  107.         }
  108.  
  109.         parent::display($tpl);
  110.     }
  111.  
  112.  
  113.     /**
  114.      * Builds a list to choose the Payment type
  115.      *
  116.      * @copyright   Copyright (c) 2009 VirtueMart Team. All rights reserved.
  117.      * @author      Max Milbers
  118.      * @param   $selected   the selected values, may be single data or array
  119.      * @return  $list       list of the Entrypoints
  120.      * @deprecated
  121.      */
  122.  
  123.     function renderPaymentTypesList($selected){
  124.  
  125.         $list = array(
  126.         '0' => array('payment_type' => 'C', 'payment_type_name' => JText::_('COM_VIRTUEMART_PAYMENT_FORM_CREDIT')),
  127.         '1' => array('payment_type' => 'Y', 'payment_type_name' => JText::_('COM_VIRTUEMART_PAYMENT_FORM_USE_PP')),
  128.         '2' => array('payment_type' => 'B', 'payment_type_name' => JText::_('COM_VIRTUEMART_PAYMENT_FORM_BANK_DEBIT')),
  129.         '3' => array('payment_type' => 'N', 'payment_type_name' => JText::_('COM_VIRTUEMART_PAYMENT_FORM_AO')),
  130.         '4' => array('payment_type' => 'P', 'payment_type_name' => JText::_('COM_VIRTUEMART_PAYMENT_FORM_FORMBASED'))
  131.         );
  132.  
  133.         $listHTML = JHTML::_('Select.genericlist', $list, 'payment_type', '', 'payment_type', 'payment_type_name', $selected );
  134.         return $listHTML;
  135.     }
  136.     /*
  137.      *
  138.     * @deprecated
  139.     */
  140.     function renderPaymentRadioList($selected){
  141.  
  142.         $list = array(
  143.         '0' => array('payment_type' => 'C', 'payment_type_name' => JText::_('COM_VIRTUEMART_PAYMENT_FORM_CREDIT')),
  144.         '1' => array('payment_type' => 'Y', 'payment_type_name' => JText::_('COM_VIRTUEMART_PAYMENT_FORM_USE_PP')),
  145.         '2' => array('payment_type' => 'B', 'payment_type_name' => JText::_('COM_VIRTUEMART_PAYMENT_FORM_BANK_DEBIT')),
  146.         '3' => array('payment_type' => 'N', 'payment_type_name' => JText::_('COM_VIRTUEMART_PAYMENT_FORM_AO')),
  147.         '4' => array('payment_type' => 'P', 'payment_type_name' => JText::_('COM_VIRTUEMART_PAYMENT_FORM_FORMBASED'))
  148.         );
  149.  
  150.         $listHTML='';
  151.         foreach($list as $item){
  152.             if($item['payment_type']==$selected) $checked='checked="checked"'; else $checked='';
  153.             if($item['payment_type']=='Y' || $item['payment_type']=='C') $id = 'pam_type_CC_on'; else $id='pam_type_CC_off';
  154.             $listHTML .= '<input id="'.$id.'" type="radio" name="payment_type" value="'.$item['payment_type'].'" '.$checked.'>'.$item['payment_type_name'].' <br />';
  155.         }
  156.  
  157.         return $listHTML;
  158.     }
  159.  
  160.     function renderInstalledPaymentPlugins($selected){
  161.  
  162.         if ( JVM_VERSION===1) {
  163.             $table = '#__plugins';
  164.             $ext_id = 'id';
  165.             $enable = 'published';
  166.         } else {
  167.             $table = '#__extensions';
  168.             $ext_id = 'extension_id';
  169.             $enable = 'enabled';
  170.         }
  171.  
  172.         $db = JFactory::getDBO();
  173.         //Todo speed optimize that, on the other hand this function is NOT often used and then only by the vendors
  174.         //      $q = 'SELECT * FROM #__plugins as pl JOIN `#__virtuemart_payment_method` AS pm ON `pl`.`id`=`pm`.`payment_jplugin_id` WHERE `folder` = "vmpayment" AND `published`="1" ';
  175.         //      $q = 'SELECT * FROM #__plugins as pl,#__virtuemart_payment_method as pm  WHERE `folder` = "vmpayment" AND `published`="1" AND pl.id=pm.payment_jplugin_id';
  176.         $q = 'SELECT * FROM `'.$table.'` WHERE `folder` = "vmpayment" AND `'.$enable.'`="1" ';
  177.         $db->setQuery($q);
  178.         $result = $db->loadAssocList($ext_id);
  179.         if(empty($result)){
  180.             $app = JFactory::getApplication();
  181.             $app -> enqueueMessage(JText::_('COM_VIRTUEMART_NO_PAYMENT_PLUGINS_INSTALLED'));
  182.         }
  183.         $listHTML='<select id="payment_jplugin_id" name="payment_jplugin_id">';
  184.         if(!class_exists('JParameter')) require(JPATH_VM_LIBRARIES.DS.'joomla'.DS.'html'.DS.'parameter.php' );
  185.         foreach($result as $paym){
  186.             $params = new JParameter($paym['params']);
  187.             if($paym[$ext_id]==$selected) $checked='selected="selected"'; else $checked='';
  188.             // Get plugin info
  189.             $pType = $params->getValue('pType');
  190.             if($pType=='Y' || $pType=='C') $id = 'pam_type_CC_on'; else $id='pam_type_CC_off';
  191.             $listHTML .= '<option id="'.$id.'" '.$checked.' value="'.$paym[$ext_id].'">'.JText::_($paym['name']).'</option>';
  192.  
  193.         }
  194.         $listHTML .= '</select>';
  195.  
  196.         return $listHTML;
  197.     }
  198.  
  199. }
  200. // pure php not tag
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement