Пример #1
0
 function opc()
 {
     if (!class_exists('VmConfig')) {
         require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php';
     }
     VmConfig::loadConfig();
     require_once JPATH_OPC . DS . 'helpers' . DS . 'loader.php';
     OPCloader::$debugMsg = '';
     //mobile handling:
     if (!defined('OPC_DETECTED_DEVICE')) {
         if (class_exists('OPCplugin')) {
             OPCplugin::detectMobile();
         }
     }
     if (!class_exists('OPCLang')) {
         require JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_onepage' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'language.php';
     }
     OPCLang::loadLang();
     require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'mini.php';
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'shoppergroups.php';
     //$this->setShopperGroups();
     $userModel = OPCmini::getModel('user');
     $cmd = JRequest::getVar('cmd', '');
     if ($cmd === 'checkbitvat') {
         $checkvat = $this->checkBitVat();
     }
     if ($cmd === 'checkvatopc') {
         $checkvat = $this->checkOPCVat();
     }
     OPCShopperGroups::setShopperGroupsController();
     if (method_exists($userModel, 'getCurrentUser')) {
         $user = $userModel->getCurrentUser();
         self::$shopper_groups = $user->shopper_groups;
         if (!empty($user->virtuemart_shipmentmethod_id)) {
             $user->virtuemart_shipmentmethod_id = 0;
             $user->virtuemart_paymentmethod_id = 0;
         }
     }
     $session = JFactory::getSession();
     $b = $session->set('eurobnk', null, 'vm');
     if (empty($euvat_shopper_group)) {
         jimport('joomla.html.parameter');
         if (class_exists('plgSystemBit_vm_change_shoppergroup')) {
             $session = JFactory::getSession();
             $sg = $session->get('vm_shoppergroups_add', array(), 'vm');
             $dispatcher = JDispatcher::getInstance();
             JPluginHelper::importPlugin('system', 'plgSystemBit_vm_change_shoppergroup', true, $dispatcher);
             // very important
             $document = JFactory::getDocument();
             JRequest::setVar('format_override', 'html');
             $_REQUEST['view'] = 'cart';
             $_REQUEST['option'] = 'com_virtuemart';
             $doctype = $document->getType();
             $dispatcher->trigger('onAfterRender');
             JRequest::setVar('format_override', 'raw');
             $sg = $session->get('vm_shoppergroups_add', array(), 'vm');
         }
     }
     JResponse::setBody('');
     // security:
     JRequest::setVar('virtuemart_shoppergroup_id', null, 'post');
     if (!class_exists('VmConfig')) {
         require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php';
     }
     VmConfig::loadConfig(true);
     // since vm2.0.21a we need to load the language files here
     if (method_exists('VmConfig', 'loadJLang')) {
         $lang = JFactory::getLanguage();
         $extension = 'com_virtuemart';
         $lang->load($extension);
         //  when AJAX it needs to be loaded manually here >> in case you are outside virtuemart !!!
         VmConfig::loadJLang('com_virtuemart_orders', true);
         VmConfig::loadJLang('com_virtuemart_shoppers', true);
     }
     /// load shipping here
     $vars = JRequest::get('post');
     // custom tag test
     $cmd = JRequest::getVar('cmd', 'get_shipping');
     $doc = JFactory::getDocument();
     $type = get_class($doc);
     if ($type == 'JDocumentRAW') {
         //C:\Documents and Settings\Rupos\Local Settings\Temp\scp02371\srv\www\clients\client1\web90\web\vm2\components\com_onepage\overrides\
         //require_once(JPATH_SITE.DS.'components'.DS.'com_onepage'.DS.'overrides'.DS.'opchtml.php');
         //JFactory::$instance = new JDocumentOpchtml();
         //JFactory::$document = new JDocumentOpchtml();
     }
     /*
     	$doc->addCustomTag = create_function('$string', 'return;');  
     	$doc->addCustomTag( '<!-- This is a comment. -->' );
     */
     $c = JRequest::getVar('virtuemart_currency_id', 0);
     JRequest::setVar('virtuemart_currency_id', (int) JRequest::getVar('virtuemart_currency_id'));
     /* to test the currency: */
     $mainframe = Jfactory::getApplication();
     $virtuemart_currency_id = $mainframe->getUserStateFromRequest("virtuemart_currency_id", 'virtuemart_currency_id', JRequest::getInt('virtuemart_currency_id'));
     // end custom tag test
     $view = $this->getView('cart', 'html');
     $cmd = JRequest::getCmd('cmd', 'get_shipping');
     $return = array();
     $return['cmd'] = $cmd;
     if (!empty($checkvat)) {
         $return['checkvat'] = $checkvat;
     }
     $db = JFactory::getDBO();
     $username = JRequest::getVar('username', '');
     $user = JFactory::getUser();
     $un = $user->get('username');
     if ($un == $username) {
         // do not complain if entering the same username of already registered
         $return['username_exists'] = false;
     } else {
         if (!empty($username)) {
             $q = "select username from #__users where username = '******' limit 0,1";
             $db->setQuery($q);
             $r = $db->loadResult();
             if (!empty($r)) {
                 $return['username_exists'] = true;
             } else {
                 $return['username_exists'] = false;
             }
         }
     }
     if ($cmd === 'checkemail') {
         $email = JRequest::getVar('email', '');
         $return['email'] = $email;
         $user = JFactory::getUser();
         $ue = $user->get('email');
         if ($email == $ue) {
             // do not complain if user is logged in and enters the same email address
             $return['email_exists'] = false;
         } else {
             if (!empty($email)) {
                 $q = "select email from #__users where username = '******' or email = '" . $db->getEscaped($email) . "' limit 0,1";
                 $db->setQuery($q);
                 $r = $db->loadResult();
                 if (!empty($r)) {
                     $return['email_exists'] = true;
                 } else {
                     $return['email_exists'] = false;
                 }
             }
         }
     }
     if ($cmd === 'get_klarna_address') {
         if (file_exists(JPATH_SITE . DS . 'plugins' . DS . 'vmpayment' . DS . 'klarna' . DS . 'klarna' . DS . 'api' . DS . 'klarna.php')) {
             $klarnaaddress = $this->getKlarnaAddress();
             if (!empty($klarnaaddress)) {
                 echo json_encode(array('cmd' => 'getKlarna', 'shipping' => 'opc_do_not_update', 'klarna' => $klarnaaddress, 'totals_html' => '', 'payment' => ''));
                 $mainframe = JFactory::getApplication();
                 // do not allow further processing
                 $mainframe->close();
             }
         }
     }
     if (!defined('JPATH_OPC')) {
         define('JPATH_OPC', JPATH_SITE . DS . 'components' . DS . 'com_onepage');
     }
     require_once JPATH_OPC . DS . 'helpers' . DS . 'loader.php';
     require_once JPATH_OPC . DS . 'helpers' . DS . 'ajaxhelper.php';
     include JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php';
     $OPCloader = new OPCloader();
     $cart = VirtueMartCart::getCart(false);
     $opcsavedST = $cart->ST;
     $opcsavedBT = $cart->BT;
     $stopen = JRequest::getVar('shiptoopen', 0);
     if ($stopen === 'false') {
         $stopen = 0;
     }
     if (empty($stopen)) {
         $sa = JRequest::getVar('sa', '');
         if ($sa == 'adresaina') {
             $stopen = 1;
         }
     }
     if ($stopen) {
         $restoreST = false;
         $restoreBT = true;
     } else {
         $cart->ST = 0;
         $restoreST = true;
         $restoreBT = false;
     }
     //$virtuemart_currency_id;  = $mainframe->getUserStateFromRequest( "virtuemart_currency_id", 'virtuemart_currency_id',JRequest::getInt('virtuemart_currency_id') );
     $cart->paymentCurrency = $virtuemart_currency_id;
     if (defined('VM_VERSION') && VM_VERSION >= 3) {
         if (method_exists($cart, 'prepareCartProducts')) {
             $cart->prepareCartProducts();
         }
     }
     if ($cmd === 'getST') {
         require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'loggedshopper.php';
         $return['sthtml'] = OPCLoggedShopper::getSTHtml($cart);
     }
     if (!isset($cart->vendorId)) {
         $cart->vendorId = 1;
     }
     if ($cmd == 'updateattributes') {
         $arr = $this->updateattributes($cart);
         if (!empty($arr)) {
             foreach ($arr as $key => $val) {
                 $return[$key] = $val;
             }
         }
     }
     if ($cmd == 'update_product') {
         if (defined('VM_VERSION') && VM_VERSION >= 3) {
             $quantity = JRequest::getVar('quantity');
             if (!is_array($quantity)) {
                 $cart_virtuemart_product_id = JRequest::getVar('cart_virtuemart_product_id');
                 $arr = array($cart_virtuemart_product_id => (int) $quantity);
                 JRequest::setVar('quantity', $arr);
                 $x = JRequest::getVar('quantity');
             }
         }
         $cart->updateProductCart();
     }
     if ($cmd == 'delete_product') {
         $cart->updateProductCart();
     }
     if ($cmd == 'removecoupon') {
         JRequest::setVar('coupon_code', '');
         $_REQUEST['coupon_code'] = $_POST['coupon_code'] = $_GET['coupon_code'] = '';
         $cart->couponCode = '';
         //$this->setCoupon($cart);
         $deletecouponmsg = true;
     }
     $cp = 0;
     if (method_exists($cart, 'prepareCartProducts')) {
         $cart->prepareCartProducts();
     }
     $cart->setCartIntoSession();
     $stopen = JRequest::getVar('shiptoopen', false);
     //if (!empty($stopen))
     if ($stopen === 'true' || $stopen === '1') {
         $stopen = true;
         $sa = JRequest::setVar('sa', 'adresaina');
     } else {
         $stopen = false;
     }
     //$this->setAddress($cart, true, $stopen);
     $this->setAddress($cart);
     $BT = $cart->BT;
     if ($stopen) {
         $this->setAddress($cart, true, $stopen);
         $cart->BT = $BT;
     } else {
         $cart->ST = 0;
     }
     //die('h');
     $this->setExtAddress($cart, false, $stopen);
     $zip = JRequest::getVar('shipto_zip');
     // IMPORTANT: this function calls shipping if Vm's automatic enabled
     if (method_exists($cart, 'prepareCartData')) {
         $cart->prepareCartData(false);
     }
     // US and Canada fix, show no tax for no state selected
     if (!isset($cart->BT['virtuemart_state_id'])) {
         $cart->BT['virtuemart_state_id'] = '';
     }
     if (!empty($cart->ST)) {
         // if the VM uses BT address instead of ST address in calculation, uncomment the following line:
         // $cart->BT = $cart->ST;   // this only applies to the display of the checkout, not actual saving of the data
         if (!isset($cart->ST['virtuemart_state_id'])) {
             $cart->ST['virtuemart_state_id'] = '';
         }
     }
     @header('Content-Type: text/html; charset=utf-8');
     @header("Cache-Control: no-cache, must-revalidate");
     // HTTP/1.1
     @header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
     // Date in the past
     // run vm main controlle due to compatibilty
     JPluginHelper::importPlugin('vmextended');
     JPluginHelper::importPlugin('vmuserfield');
     $dispatcher = JDispatcher::getInstance();
     $_controller = 'cart';
     $trigger = 'onVmSiteController';
     $trigger = 'plgVmOnMainController';
     $dispatcher->trigger($trigger, array($_controller));
     // this function will reload the taxes on products per country
     // this calls api methods as well, let's disable it for now:
     $cart->virtuemart_shipmentmethod_id = 0;
     if (method_exists($cart, 'prepareCartViewData')) {
         $cart->prepareCartViewData();
     }
     if (!empty($virtuemart_currency_id)) {
         $cart->paymentCurrency = $virtuemart_currency_id;
     }
     if ($cmd == 'process_coupon') {
         $cart->couponCode = JRequest::getVar('coupon_code', '');
         $this->setCoupon($cart);
         // set coupon
     }
     $view->cart = $cart;
     $view->assignRef('cart', $cart);
     //if (($cmd != 'runpay') && ($cmd != 'refreshPayment'))
     // this influences the recalculation of the basket:
     $cmds = array('process_coupon', 'refresh-totals', 'refresh_totals', 'removecoupon', 'delete_product', 'update_product', 'checkvatopc', 'delete_product', 'update_product', 'updateattributes', 'get_shipping');
     if (empty($cmd) || in_array($cmd, $cmds) || stripos($cmd, 'shipping') !== false) {
         $shipping = $OPCloader->getShipping($view, $cart, true);
         $saved_totals = OPCloader::$totals_html;
     } else {
         $shipping = 'opc_do_not_update';
         OPCloader::$totals_html = '';
     }
     $return['shipping'] = $shipping;
     if (empty(OPCloader::$inform_html)) {
         OPCloader::$inform_html = array();
     }
     $return['inform_html'] = implode('', OPCloader::$inform_html);
     if (!empty($cart->couponCode)) {
         $db = JFactory::getDBO();
         $q = "select * from #__virtuemart_coupons where coupon_code = '" . $db->getEscaped($cart->couponCode) . "' limit 0,1";
         $db->setQuery($q);
         $res = $db->loadAssoc();
         if (!empty($res)) {
             if ($res['percent_or_total'] == 'percent') {
                 $cp = $res['coupon_value'];
             }
         }
         if (empty($cp)) {
             if (OPCloader::tableExists('awocoupon')) {
                 $db = JFactory::getDBO();
                 $q = "select * from #__awocoupon where coupon_code = '" . $db->getEscaped($cart->couponCode) . "' and coupon_value_type = 'percent' limit 0,1";
                 $db->setQuery($q);
                 $res = $db->loadAssoc();
                 if (!empty($res)) {
                     $cp = $res['coupon_value'];
                 }
             }
         }
     }
     if (!empty($cp)) {
         $cp = (double) $cp;
         if (round($cp) == $cp) {
             $cp = (int) $cp . ' %';
         } else {
             $cp = number_format($cp, 2, '.', ' ') . ' %';
         }
     }
     $return['couponpercent'] = $cp;
     // get payment html
     $num = 0;
     if ($cmd == 'runpay') {
         $view->cart->virtuemart_shipmentmethod_id = JRequest::getVar('shipping_rate_id', '');
     }
     $isexpress = OPCloader::isExpress($cart);
     $ph2_a = $OPCloader->getPayment($view, $num, false, $isexpress);
     $ph2 = $ph2_a['html'];
     $return['payment_extra'] = $ph2_a['extra'];
     /*
     if (!empty($ph_a['extra']))
     {
       foreach ($ph_a['extra'] as $key=>$val)
     		  {
     		    $return['payment_extra'].$val; 
     		  }
     }
     */
     if ($cmd == 'runpay') {
         $cart->virtuemart_shipmentmethod_id = null;
     }
     if (!empty(OPCloader::$totalIsZero)) {
         $hide_payment_if_one = true;
         $num = 1;
         $ph2 = '<input type="hidden" value="0" name="virtuemart_paymentmethod_id" id="virtuemart_paymentmethod_id_0" />';
     }
     if (!empty($hide_payment_if_one) && $num === 1 || $isexpress) {
         $ph = '<div class="payment_inner_html" rel="force_hide_payments">' . $ph2;
     } else {
         $ph = '<div class="payment_inner_html" rel="force_show_payments">' . $ph2;
     }
     $ph .= '</div>';
     $return['payment'] = $ph;
     if (isset($saved_totals)) {
         $return['totals_html'] = $saved_totals;
     } else {
         $return['totals_html'] = OPCloader::$totals_html;
     }
     $return['min_pov'] = OPCloader::checkPurchaseValue($cart);
     if (!empty($return['totals_html'])) {
         $session = JFactory::getSession();
         /*
         $r = $session->get('opcuniq'); 
         if (empty($r))
         {
         $rand = uniqid('', true); 
                $session->set('opcuniq', $rand);
                $session->set($rand, '0');
         }
         */
         $rand = uniqid('', true);
         $return['totals_html'] .= '<input type="hidden" name="opcuniq" value="' . $rand . '" />';
     }
     $t = $return['shipping'] . ' ' . $return['payment'];
     $t = str_replace('//<![CDATA[', '', $t);
     $t = str_replace('//]]> ', '', $t);
     $t = str_replace('<![CDATA[', '', $t);
     $t = str_replace(']]> ', '', $t);
     $t = str_replace('#paymentForm', '#adminForm', $t);
     //$t = str_replace('jQuery(document).ready(', ' jQuery( ', $t);
     $js = array();
     if (strpos($t, '<script') !== false) {
         $xa = basketHelper::strposall($t, '<script');
         foreach ($xa as $st) {
             // end of <script tag
             $x1 = strpos($t, '>', $st + 1);
             // end of </scrip tag
             $x2 = strpos($t, '</scrip', $st + 1);
             $js1 = substr($t, $x1 + 1, $x2 - $x1 - 1);
             $js[] = $js1;
         }
     }
     $return['shipping'] .= JHtml::_('form.token');
     $return['payment'] .= JHtml::_('form.token');
     if (isset(VmPlugin::$ccount)) {
         if (!empty($opc_debug)) {
             $js[] = "\n" . 'op_log("Positive cache match: ' . VmPlugin::$ccount . '");';
         }
     }
     if (!empty($opc_debug)) {
         if (defined('OPCMEMSTART')) {
             $mem = memory_get_usage(true);
             $memd = $mem - OPCMEMSTART;
             $memd = (double) ($memd / 1024);
             $memd = number_format($memd, 0, '.', ' ');
             if (!defined('debugmem')) {
                 $debugmem = $mem - OPCMEMSTART;
                 $debugmem = (double) ($debugmem / 1024);
             } else {
                 $debugmem = (double) (debugmem / 1024);
             }
             $debugmem = number_format($debugmem, 0, '.', ' ');
             $mem = (double) ($mem / 1024);
             $mem = number_format($mem, 0, '.', ' ');
             $js[] = "\n" . 'op_log("Memory usage: ' . $memd . 'kb of ' . $mem . 'kb, debug mem: ' . $debugmem . 'kb ");';
         }
     }
     $return['javascript'] = $js;
     $return['opcplugins'] = OPCloader::getPluginData($cart);
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'removemsgs.php';
     OPCremoveMsgs::removeMsgs($cart);
     $x = JFactory::getApplication()->getMessageQueue();
     $arr = array();
     $disablarray = array('Unrecognised mathop', JText::_('COM_VIRTUEMART_CART_PLEASE_ACCEPT_TOS'));
     include JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'third_party' . DS . 'third_party_disable_msgs.php';
     $euvat_text = array('VMUSERFIELD_ISTRAXX_EUVATCHECKER_INVALID', 'VMUSERFIELD_ISTRAXX_EUVATCHECKER_VALID', 'VMUSERFIELD_ISTRAXX_EUVATCHECKER_INVALID_COUNTRYCODE', 'VMUSERFIELD_ISTRAXX_EUVATCHECKER_INVALID_FORMAT_REASON', 'VMUSERFIELD_ISTRAXX_EUVATCHECKER_INVALID_FORMAT', 'VMUSERFIELD_ISTRAXX_EUVATCHECKER_SERVICE_UNAVAILABLE', 'VMUSERFIELD_ISTRAXX_EUVATCHECKER_COMPANYNAME_REQUIRED');
     foreach ($euvat_text as $k => $t) {
         $tt = JText::_($t);
         $euvat_text[$k] = substr($tt, 0, 20);
     }
     $euvatinfo = '';
     $remove = array();
     foreach ($x as $key => $val) {
         foreach ($euvat_text as $kx => $eutext) {
             // echo 'comparing '.$eutext.' with '.$val['message']."<br />\n";
             if (stripos($val['message'], $eutext) !== false) {
                 $euvatinfo .= $val['message'];
                 $remove[] = $key;
                 break;
             }
         }
         foreach ($disablarray as $msg) {
             if (stripos($val['message'], $msg) !== false) {
                 $remove[] = $key;
             }
             if (stripos($val['message'], JText::_('COM_VIRTUEMART_COUPON_CODE_INVALID')) !== false) {
                 $cart->couponCode = '';
                 $cart->setCartIntoSession();
             }
         }
     }
     if (!empty($euvatinfo)) {
         $return['checkvat'] = $euvatinfo;
     }
     foreach ($x as $key => $val) {
         if (!in_array($key, $remove)) {
             $arr[] = $val['message'];
         }
     }
     $return['msgs'] = $arr;
     if (!empty($opc_debug)) {
         if (!empty(OPCloader::$debugMsg)) {
             $return['debug_msgs'] = OPCloader::$debugMsg;
         }
     }
     if (!empty($cart->couponCode)) {
         $return['couponcode'] = $cart->couponCode;
     } else {
         $return['couponcode'] = '';
     }
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'shoppergroups.php';
     OPCShopperGroups::setShopperGroupsController($cart);
     $upd = array('update_product', 'delete_product', 'process_coupon', 'removecoupon', 'updateattribute', 'refreshall', 'updateattributes', 'checkvatopc', 'checkvat', 'vat_info');
     if (in_array($cmd, $upd) || stripos($cmd, 'shipping') !== false || !empty($ajaxify_cart)) {
         if ($shipping == 'opc_do_not_update') {
             $shipping = '';
         }
         if (!empty($ph2_a['html'])) {
             $payment_html = $op_payment = '<div id="payment_html">' . $ph2_a['html'] . '</div>';
         } else {
             $payment_html = $op_payment = '<div id="payment_html">&nbsp;</div>';
         }
         $html = $this->getCartHtml($cart, $OPCloader, $shipping, $payment_html);
         $return['basket'] = $html;
     }
     $cart->virtuemart_shipmentmethod_id = 0;
     $cart->virtuemart_paymentmethod_id = 0;
     $cart->setCartIntoSession();
     $x = @ob_get_clean();
     $x = @ob_get_clean();
     $x = @ob_get_clean();
     $x = @ob_get_clean();
     //echo json_encode('');
     echo json_encode($return);
     //echo $shipping;
     $dispatcher = JDispatcher::getInstance();
     $returnValues = $dispatcher->trigger('updateAbaData', array());
     if ($restoreBT) {
         $cart->BT = $opcsavedBT;
     }
     if ($restoreST) {
         $cart->ST = $opcsavedST;
     }
     $cart->setCartIntoSession();
     $mainframe = JFactory::getApplication();
     // do not allow further processing
     $mainframe->close();
     die;
 }
 /**
  * Displays the view, collects needed data for the different layouts
  *
  * Okey I try now a completly new idea.
  * We make a function for every tab and the display is getting the right tabs by an own function
  * putting that in an array and after that we call the preparedataforlayoutBlub
  *
  * @author Oscar van Eijk
  * @author Max Milbers
  *
  *  Original code from: \components\com_virtuemart\views\user\view.html.php
  *
  */
 function display($tpl = null)
 {
     $useSSL = VmConfig::get('useSSL', 0);
     $useXHTML = true;
     $this->assignRef('useSSL', $useSSL);
     $this->assignRef('useXHTML', $useXHTML);
     $mainframe = JFactory::getApplication();
     $pathway = $mainframe->getPathway();
     $layoutName = $this->getLayout();
     if (!defined('OPC_IN_REGISTRATION_MODE')) {
         define('OPC_IN_REGISTRATION_MODE', 1);
     }
     require_once JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_onepage' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'language.php';
     OPCLang::loadLang();
     $this->loadOPC();
     // 	vmdebug('layout by view '.$layoutName);
     if (empty($layoutName) or $layoutName == 'default') {
         $layoutName = JRequest::getWord('layout', 'edit');
         if ($layoutName == 'default') {
             $layoutName = 'edit';
         }
         $this->setLayout($layoutName);
     }
     if (empty($this->fTask)) {
         $ftask = 'saveUser';
         $this->assignRef('fTask', $ftask);
     }
     if (!class_exists('ShopFunctions')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'shopfunctions.php';
     }
     // 	vmdebug('my layoutname',$layoutName);
     if ($layoutName == 'login') {
         parent::display($tpl);
         return;
     }
     if (!class_exists('VirtuemartModelUser')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'user.php';
     }
     $this->_model = new VirtuemartModelUser();
     //		$this->_model->setCurrent(); //without this, the administrator can edit users in the FE, permission is handled in the usermodel, but maybe unsecure?
     $editor = JFactory::getEditor();
     //the cuid is the id of the current user
     $this->_currentUser = JFactory::getUser();
     $this->_cuid = $this->_lists['current_id'] = $this->_currentUser->get('id');
     $this->assignRef('userId', $this->_cuid);
     $this->_userDetails = $this->_model->getUser();
     $this->assignRef('userDetails', $this->_userDetails);
     $address_type = JRequest::getWord('addrtype', 'BT');
     $this->assignRef('address_type', $address_type);
     //New Address is filled here with the data of the cart (we are in the cart)
     if (!class_exists('VirtueMartCart')) {
         require JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php';
     }
     $cart = VirtueMartCart::getCart();
     $new = false;
     if (JRequest::getInt('new', '0') == 1) {
         $new = true;
     }
     if ($new) {
         $virtuemart_userinfo_id = 0;
     } else {
         $virtuemart_userinfo_id = JRequest::getString('virtuemart_userinfo_id', '0', '');
         if (empty($virtuemart_userinfo_id)) {
             require_once JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_onepage' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'mini.php';
             $umodel = OPCmini::getModel('user');
             //new VirtuemartModelUser();
             $uid = JFactory::getUser()->id;
             $userDetails = $umodel->getUser();
             $virtuemart_userinfo_id = $umodel->getBTuserinfo_id();
         }
     }
     $this->assignRef('virtuemart_userinfo_id', $virtuemart_userinfo_id);
     $userFields = null;
     if ((strpos($this->fTask, 'cart') || strpos($this->fTask, 'checkout')) && empty($virtuemart_userinfo_id)) {
         $fieldtype = $address_type . 'address';
         if (method_exists($cart, 'prepareAddressDataInCart')) {
             $cart->prepareAddressDataInCart($address_type, $new);
         }
         if (method_exists($cart, 'prepareAddressFieldsInCart')) {
             $cart->prepareAddressFieldsInCart();
         }
         $userFields = $cart->{$fieldtype};
         $task = JRequest::getWord('task', '');
     } else {
         $userFields = $this->_model->getUserInfoInUserFields($layoutName, $address_type, $virtuemart_userinfo_id);
         if (!$new && empty($userFields[$virtuemart_userinfo_id])) {
             $virtuemart_userinfo_id = $this->_model->getBTuserinfo_id();
             // 			vmdebug('Try to get $virtuemart_userinfo_id by type BT', $virtuemart_userinfo_id);
         }
         $userFields = $userFields[$virtuemart_userinfo_id];
         $task = 'editaddressST';
     }
     require_once JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_onepage' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'loader.php';
     /*
     if (!class_exists('VirtueMartCart'))
     	require(JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php');
     $this->cart = VirtueMartCart::getCart(); 
     */
     $OPCloader = new OPCloader();
     OPCloader::setRegType();
     $action_url = JURI::root(true) . '/index.php?option=com_onepage&amp;view=opc&amp;controller=opc&amp;task=opcregister&amp;nosef=1';
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'javascript.php';
     OPCJavascript::getJavascript($this, $OPCloader, false, $action_url, 'com_onepage', 'opcregister');
     $OPCloader->customizeFieldsPerOPCConfig($userFields);
     OPCloader::loadJavascriptFiles($this);
     $op_formvars = OPCloader::getFormVars($this);
     /*
     	foreach ($userFields['fields'] as $key=>$val)
     {
        if (isset($val['formcode']))
     		{
     		
     		  $val['formcode'] .= $html; 
     		  break; 
     		  
     		}
     }
     */
     $this->assignRef('userFields', $userFields);
     if ($layoutName == 'edit') {
         if ($this->_model->getId() == 0 && $this->_cuid == 0) {
             $button_lbl = JText::_('COM_VIRTUEMART_REGISTER');
         } else {
             $button_lbl = JText::_('COM_VIRTUEMART_SAVE');
         }
         $this->assignRef('button_lbl', $button_lbl);
         $this->lUser();
         if (JVM_VERSION <= 2) {
             $this->shopper($userFields);
         } else {
             $this->shopper3($userFields);
         }
         $this->payment();
         $this->lOrderlist();
         $this->lVendor();
     }
     $this->_lists['shipTo'] = $this->generateStAddressList($this, $this->_model, $task, $cart);
     if ($this->_openTab < 0) {
         $_paneOffset = array();
     } else {
         if (defined('__VM_USER_USE_SLIDERS')) {
             $_paneOffset = array('startOffset' => $this->_openTab, 'startTransition' => 1, 'allowAllClose' => true);
         } else {
             $_paneOffset = array('startOffset' => $this->_openTab);
         }
     }
     // Implement the Joomla panels. If we need a ShipTo tab, make it the active one.
     // In tmpl/edit.php, this is the 4th tab (0-based, so set to 3 above)
     jimport('joomla.html.pane');
     $pane = OPCPane::getInstance(defined('__VM_USER_USE_SLIDERS') ? 'Sliders' : 'Tabs', $_paneOffset);
     $this->assignRef('lists', $this->_lists);
     $this->assignRef('editor', $editor);
     $this->assignRef('pane', $pane);
     if ($layoutName == 'mailregisteruser') {
         $vendorModel = VmModel::getModel('vendor');
         //			$vendorModel->setId($this->_userDetails->virtuemart_vendor_id);
         $vendor = $vendorModel->getVendor();
         $this->assignRef('vendor', $vendor);
     }
     if ($layoutName == 'editaddress') {
         $layoutName = 'edit_address';
         $this->setLayout($layoutName);
     }
     if (!$this->userDetails->JUser->get('id')) {
         $corefield_title = JText::_('COM_VIRTUEMART_USER_CART_INFO_CREATE_ACCOUNT');
     } else {
         $corefield_title = JText::_('COM_VIRTUEMART_YOUR_ACCOUNT_DETAILS');
     }
     if (strpos($this->fTask, 'cart') || strpos($this->fTask, 'checkout')) {
         $pathway->addItem(JText::_('COM_VIRTUEMART_CART_OVERVIEW'), JRoute::_('index.php?option=com_virtuemart&view=cart', FALSE));
     } else {
         //$pathway->addItem(JText::_('COM_VIRTUEMART_YOUR_ACCOUNT_DETAILS'), JRoute::_('index.php?option=com_virtuemart&view=user&&layout=edit'));
     }
     $pathway_text = JText::_('COM_VIRTUEMART_YOUR_ACCOUNT_DETAILS');
     if (!$this->userDetails->JUser->get('id')) {
         if (strpos($this->fTask, 'cart') || strpos($this->fTask, 'checkout')) {
             if ($address_type == 'BT') {
                 $vmfield_title = JText::_('COM_VIRTUEMART_USER_FORM_EDIT_BILLTO_LBL');
             } else {
                 $vmfield_title = JText::_('COM_VIRTUEMART_USER_FORM_ADD_SHIPTO_LBL');
             }
         } else {
             if ($address_type == 'BT') {
                 $vmfield_title = JText::_('COM_VIRTUEMART_USER_FORM_EDIT_BILLTO_LBL');
                 $title = JText::_('COM_VIRTUEMART_REGISTER');
             } else {
                 $vmfield_title = JText::_('COM_VIRTUEMART_USER_FORM_ADD_SHIPTO_LBL');
             }
         }
     } else {
         if ($address_type == 'BT') {
             $vmfield_title = JText::_('COM_VIRTUEMART_USER_FORM_BILLTO_LBL');
         } else {
             $vmfield_title = JText::_('COM_VIRTUEMART_USER_FORM_ADD_SHIPTO_LBL');
         }
     }
     $add_product_link = "";
     require_once JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_onepage' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'mini.php';
     if (OPCmini::isSuperVendor()) {
         $add_product_link = JRoute::_('/index.php?option=com_virtuemart&tmpl=component&view=product&view=product&task=edit&virtuemart_product_id=0');
         $add_product_link = $this->linkIcon($add_product_link, 'COM_VIRTUEMART_PRODUCT_ADD_PRODUCT', 'new', false, false, true, true);
     }
     $this->assignRef('add_product_link', $add_product_link);
     $document = JFactory::getDocument();
     $document->setTitle($pathway_text);
     $pathway->additem($pathway_text);
     $document->setMetaData('robots', 'NOINDEX, NOFOLLOW, NOARCHIVE, NOSNIPPET');
     $this->assignRef('page_title', $pathway_text);
     $this->assignRef('corefield_title', $corefield_title);
     $this->assignRef('vmfield_title', $vmfield_title);
     //   if ($onlyindex) return JURI::root(true).'/index.php';
     shopFunctionsF::setVmTemplate($this, 0, 0, $layoutName);
     require_once JPATH_SITE . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_onepage' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'removemsgs.php';
     OPCremoveMsgs::removeMsgs($cart);
     $jsvalidator = $OPCloader->getJSValidatorScript($this);
     $op_userfields = $OPCloader->getBTfields($this);
     $registration_html = $OPCloader->getRegistrationHhtml($this);
     require_once JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_onepage' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'commonhtml.php';
     $reg_html = OPCCommonHtml::getFormVarsRegistration($OPCloader);
     $op_formvars = $reg_html . $jsvalidator;
     $op_userfields .= $op_formvars;
     $onsubmit = $op_onclick = $OPCloader->getJSValidator($this);
     $op_onclick = ' onclick="' . $op_onclick . '" ';
     ob_start();
     //parent::display($tpl);
     include_once JPATH_OPC . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'registration_templates.php';
     $html = ob_get_clean();
     //$html = str_replace('"com_virtuemart"', '"com_onepage"', $html);
     //$html = str_replace('=com_virtuemart', '=com_onepage', $html);
     $this->getActions($html);
     $html = $OPCloader->addListeners($html);
     echo $html;
     $extras = $OPCloader->getExtras($this);
     echo $extras;
 }