/**
	 * Send the Recommend to a friend email.
	 *
	 * @author Kohl Patrick,
	 */
	public function mailRecommend () {

		JRequest::checkToken () or jexit ('Invalid Token');
		// Display it all
		$view = $this->getView ('recommend', 'html');

		if(!VmConfig::get('show_emailfriend',false)){
			$view->display ();
		}
		if (!class_exists ('shopFunctionsF')) {
			require(JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php');
		}
		if(!class_exists('ShopFunctions')) require(JPATH_VM_ADMINISTRATOR.DS.'helpers'.DS.'shopfunctions.php');

		$mainframe = JFactory::getApplication ();
		$vars = array();

		$virtuemart_product_idArray = JRequest::getInt ('virtuemart_product_id', 0);
		if (is_array ($virtuemart_product_idArray)) {
			$virtuemart_product_id = (int)$virtuemart_product_idArray[0];
		} else {
			$virtuemart_product_id = (int)$virtuemart_product_idArray;
		}
		$productModel = VmModel::getModel ('product');

		$vars['product'] = $productModel->getProduct ($virtuemart_product_id);

		$user = JFactory::getUser ();
		$vars['user'] = array('name' => $user->name, 'email' =>  $user->email);

		$vars['vendorEmail'] = $user->email;
		$vendorModel = VmModel::getModel ('vendor');
		$vendor = $vendorModel->getVendor ($vars['product']->virtuemart_vendor_id);
		$vendorModel->addImages ($vars['vendor']);
		$vendor->vendorFields = $vendorModel->getVendorAddressFields();
		$vars['vendor'] = $vendor;
		$vars['vendorAddress']= shopFunctions::renderVendorAddress($vars['product']->virtuemart_vendor_id);

		$vars['vendorEmail']=  $user->email;
		$vars['vendor']->vendor_name =$user->name;


		$toMail = JRequest::getVar ('email'); //is sanitized then
		$toMail = str_replace (array('\'', '"', ',', '%', '*', '/', '\\', '?', '^', '`', '{', '}', '|', '~'), array(''), $toMail);

		if (shopFunctionsF::renderMail ('recommend', $toMail, $vars, 'productdetails', TRUE)) {
			$string = 'COM_VIRTUEMART_MAIL_SEND_SUCCESSFULLY';
		} else {
			$string = 'COM_VIRTUEMART_MAIL_NOT_SEND_SUCCESSFULLY';
		}
		$mainframe->enqueueMessage (JText::_ ($string));

// 		vmdebug('my email vars ',$vars,$TOMail);


		$view->setLayout ('mail_confirmed');
		$view->display ();
	}
Exemple #2
0
 /**
  *
  *
  * @author Valérie Isaksen
  */
 function plgVmConfirmedOrder($cart, $order)
 {
     if (!($method = $this->getVmPluginMethod($order['details']['BT']->virtuemart_paymentmethod_id))) {
         return NULL;
         // Another method was selected, do nothing
     }
     if (!$this->selectedThisElement($method->payment_element)) {
         return FALSE;
     }
     VmConfig::loadJLang('com_virtuemart', true);
     if (!class_exists('VirtueMartModelOrders')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php';
     }
     $this->getPaymentCurrency($method);
     $currency_code_3 = shopFunctions::getCurrencyByID($method->payment_currency, 'currency_code_3');
     $email_currency = $this->getEmailCurrency($method);
     $totalInPaymentCurrency = vmPSPlugin::getAmountInCurrency($order['details']['BT']->order_total, $method->payment_currency);
     $dbValues['payment_name'] = $this->renderPluginName($method) . '<br />' . $method->payment_info;
     $dbValues['order_number'] = $order['details']['BT']->order_number;
     $dbValues['virtuemart_paymentmethod_id'] = $order['details']['BT']->virtuemart_paymentmethod_id;
     $dbValues['cost_per_transaction'] = $method->cost_per_transaction;
     $dbValues['cost_percent_total'] = $method->cost_percent_total;
     $dbValues['payment_currency'] = $currency_code_3;
     $dbValues['email_currency'] = $email_currency;
     $dbValues['payment_order_total'] = $totalInPaymentCurrency['value'];
     $dbValues['tax_id'] = $method->tax_id;
     $this->storePSPluginInternalData($dbValues);
     $html = '<table class="vmorder-done">' . "\n";
     $html .= $this->getHtmlRow('STANDARD_PAYMENT_INFO', $dbValues['payment_name'], 'class="vmorder-done-payinfo"');
     if (!empty($payment_info)) {
         $lang = JFactory::getLanguage();
         if ($lang->hasKey($method->payment_info)) {
             $payment_info = vmText::_($method->payment_info);
         } else {
             $payment_info = $method->payment_info;
         }
         $html .= $this->getHtmlRow('STANDARD_PAYMENTINFO', $payment_info, 'class="vmorder-done-payinfo"');
     }
     if (!class_exists('VirtueMartModelCurrency')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'currency.php';
     }
     $currency = CurrencyDisplay::getInstance('', $order['details']['BT']->virtuemart_vendor_id);
     $html .= $this->getHtmlRow('STANDARD_ORDER_NUMBER', $order['details']['BT']->order_number, 'class="vmorder-done-nr"');
     $html .= $this->getHtmlRow('STANDARD_AMOUNT', $currency->priceDisplay($order['details']['BT']->order_total), 'class="vmorder-done-amount"');
     if ($method->payment_currency != $order['details']['BT']->order_currency) {
         $html .= $this->getHtmlRow('COM_VIRTUEMART_CART_TOTAL_PAYMENT', $totalInPaymentCurrency['display'], 'class="vmorder-done-amount"');
     }
     //$html .= $this->getHtmlRow('STANDARD_INFO', $method->payment_info);
     //$html .= $this->getHtmlRow('STANDARD_AMOUNT', $totalInPaymentCurrency.' '.$currency_code_3);
     $html .= '</table>' . "\n";
     $modelOrder = VmModel::getModel('orders');
     $order['order_status'] = $this->getNewStatus($method);
     $order['customer_notified'] = 1;
     $order['comments'] = '';
     $modelOrder->updateStatusForOneOrder($order['details']['BT']->virtuemart_order_id, $order, TRUE);
     //We delete the old stuff
     $cart->emptyCart();
     vRequest::setVar('html', $html);
     return TRUE;
 }
Exemple #3
0
 /**
  *
  * тут выводится форма для перехода на сайт оплаты
  * @author Alexius
  */
 function plgVmConfirmedOrder($cart, $order)
 {
     //echo'<pre>salt = ';print_r($this);echo'</pre>';
     if (!($method = $this->getVmPluginMethod($order['details']['BT']->virtuemart_paymentmethod_id))) {
         return NULL;
         // Another method was selected, do nothing
     }
     if (!$this->selectedThisElement($method->payment_element)) {
         return FALSE;
     }
     VmConfig::loadJLang('com_virtuemart', true);
     if (!class_exists('VirtueMartModelOrders')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php';
     }
     $this->getPaymentCurrency($method);
     $currency_code_3 = shopFunctions::getCurrencyByID($method->payment_currency, 'currency_code_3');
     $email_currency = $this->getEmailCurrency($method);
     $new_status = $method->status_pending;
     $totalInPaymentCurrency = vmPSPlugin::getAmountInCurrency($order['details']['BT']->order_total, $method->payment_currency);
     $dbValues['payment_name'] = $this->renderPluginName($method) . '<br />' . $method->payment_info;
     $dbValues['order_number'] = $order['details']['BT']->order_number;
     $dbValues['virtuemart_paymentmethod_id'] = $order['details']['BT']->virtuemart_paymentmethod_id;
     $dbValues['cost_per_transaction'] = $method->cost_per_transaction;
     $dbValues['cost_percent_total'] = $method->cost_percent_total;
     $dbValues['payment_currency'] = $currency_code_3;
     $dbValues['email_currency'] = $email_currency;
     $dbValues['payment_order_total'] = $totalInPaymentCurrency['value'];
     $dbValues['tax_id'] = $method->tax_id;
     $this->storePSPluginInternalData($dbValues);
     /*
     $order1 = $this->getDataByOrderNumber('1419045');
     $orderModel = VmModel::getModel('orders');
     $order = $orderModel->getOrder($order1->virtuemart_order_id);
     echo'<pre>';var_dump($order1);echo'</pre>';//die;
     //echo'<pre>';var_dump($order);echo'</pre>';
     die;
     */
     //echo'<pre>';print_r($order['items']);echo'</pre>';
     //die;
     $session = JFactory::getSession();
     $session->set('virtuemart_order_number', $order['details']['BT']->order_number);
     //Формирование POST заголовка для отправки на Ipay
     $post_variables = array('srv_no' => $method->srv_no, 'pers_acc' => $order['details']['BT']->order_number, 'amount' => (int) $order['details']['BT']->order_total, 'amount_editable' => 'N', 'provider_url' => $method->provider_url);
     $url = $method->server;
     //$url = 'https://stand.besmart.by:4443/pls/ipay/!iSOU.Login';
     $html = '';
     $html = '<div class="erip-ipay-frm">';
     $html .= '<p>Номер вашего заказа: ' . $order['details']['BT']->order_number . '.</p>';
     $html .= '<p>Для оплаты через систему ЕРИП запишите данный номер заказа.</p><br><br>';
     $html .= '<p>Для оплаты через систему iPay - нажмите на кнопку ниже.</p>';
     $html .= '<form action="' . $url . '" method="post" name="ipay-frm">';
     foreach ($post_variables as $name => $value) {
         $html .= '<input type="hidden" name="' . $name . '" value="' . htmlspecialchars($value) . '" />';
     }
     $html .= '<button type="submit" class="button">Оплатить через iPay</button>';
     $html .= '</form>';
     $html .= '</div>';
     //return $html;
     return $this->processConfirmedOrderPaymentResponse(2, $cart, $order, $html, $method->payment_name, $new_status);
 }
 /**
  *
  *
  * @author Valérie Isaksen
  */
 function plgVmConfirmedOrder($cart, $order)
 {
     if (!($method = $this->getVmPluginMethod($order['details']['BT']->virtuemart_paymentmethod_id))) {
         return NULL;
         // Another method was selected, do nothing
     }
     if (!$this->selectedThisElement($method->payment_element)) {
         return FALSE;
     }
     VmConfig::loadJLang('com_virtuemart', true);
     VmConfig::loadJLang('com_virtuemart_orders', TRUE);
     if (!class_exists('VirtueMartModelOrders')) {
         require VMPATH_ADMIN . DS . 'models' . DS . 'orders.php';
     }
     $this->getPaymentCurrency($method);
     $currency_code_3 = shopFunctions::getCurrencyByID($method->payment_currency, 'currency_code_3');
     $email_currency = $this->getEmailCurrency($method);
     $totalInPaymentCurrency = vmPSPlugin::getAmountInCurrency($order['details']['BT']->order_total, $method->payment_currency);
     $dbValues['payment_name'] = $this->renderPluginName($method) . '<br />' . $method->payment_info;
     $dbValues['order_number'] = $order['details']['BT']->order_number;
     $dbValues['virtuemart_paymentmethod_id'] = $order['details']['BT']->virtuemart_paymentmethod_id;
     $dbValues['cost_per_transaction'] = $method->cost_per_transaction;
     $dbValues['cost_min_transaction'] = $method->cost_min_transaction;
     $dbValues['cost_percent_total'] = $method->cost_percent_total;
     $dbValues['payment_currency'] = $currency_code_3;
     $dbValues['email_currency'] = $email_currency;
     $dbValues['payment_order_total'] = $totalInPaymentCurrency['value'];
     $dbValues['tax_id'] = $method->tax_id;
     $this->storePSPluginInternalData($dbValues);
     $payment_info = '';
     if (!empty($method->payment_info)) {
         $lang = JFactory::getLanguage();
         if ($lang->hasKey($method->payment_info)) {
             $payment_info = vmText::_($method->payment_info);
         } else {
             $payment_info = $method->payment_info;
         }
     }
     if (!class_exists('VirtueMartModelCurrency')) {
         require VMPATH_ADMIN . DS . 'models' . DS . 'currency.php';
     }
     $currency = CurrencyDisplay::getInstance('', $order['details']['BT']->virtuemart_vendor_id);
     $html = $this->renderByLayout('post_payment', array('order_number' => $order['details']['BT']->order_number, 'order_pass' => $order['details']['BT']->order_pass, 'payment_name' => $dbValues['payment_name'], 'displayTotalInPaymentCurrency' => $totalInPaymentCurrency['display']));
     $modelOrder = VmModel::getModel('orders');
     $order['order_status'] = $this->getNewStatus($method);
     $order['customer_notified'] = 1;
     $order['comments'] = '';
     $modelOrder->updateStatusForOneOrder($order['details']['BT']->virtuemart_order_id, $order, TRUE);
     //We delete the old stuff
     $cart->emptyCart();
     vRequest::setVar('html', $html);
     return TRUE;
 }
 function display($tpl = null)
 {
     $this->loadHelper('image');
     $this->loadHelper('html');
     $model = VmModel::getModel();
     $usermodel = VmModel::getModel('user');
     JToolBarHelper::title(JText::_('COM_VIRTUEMART_CONFIG'), 'head vm_config_48');
     $this->addStandardEditViewCommands();
     $config = VmConfig::loadConfig();
     if (!empty($config->_params)) {
         unset($config->_params['pdf_invoice']);
         // parameter remove and replaced by inv_os
     }
     $this->config = $config;
     $this->userparams = JComponentHelper::getParams('com_users');
     $this->jTemplateList = ShopFunctions::renderTemplateList(JText::_('COM_VIRTUEMART_ADMIN_CFG_JOOMLA_TEMPLATE_DEFAULT'));
     $this->vmLayoutList = $model->getLayoutList('virtuemart', VmConfig::get('vmlayout', 0), 'vmlayout');
     $this->categoryLayoutList = $model->getLayoutList('category', VmConfig::get('categorylayout', 0), 'categorylayout');
     $this->productLayoutList = $model->getLayoutList('productdetails', VmConfig::get('productlayout', 0), 'productlayout');
     $this->noimagelist = $model->getNoImageList();
     $this->orderStatusModel = VmModel::getModel('orderstatus');
     $this->currConverterList = $model->getCurrencyConverterList();
     $this->moduleList = $model->getModuleList();
     $this->activeLanguages = $model->getActiveLanguages(VmConfig::get('active_languages'));
     $this->orderByFields = $model->getProductFilterFields('browse_orderby_fields');
     $this->searchFields = $model->getProductFilterFields('browse_search_fields');
     $this->aclGroups = $usermodel->getAclGroupIndentedTree();
     if (is_Dir(VmConfig::get('vmtemplate') . DS . 'images' . DS . 'availability' . DS)) {
         $imagePath = VmConfig::get('vmtemplate') . '/images/availability/';
     } else {
         $imagePath = '/components/com_virtuemart/assets/images/availability/';
     }
     $this->imagePath = $imagePath;
     shopFunctions::checkSafePath();
     $this->checkVmUserVendor();
     parent::display($tpl);
 }
 /**
  * Display stored payment data for an order
  * @param  int $virtuemart_order_id
  * @param  int $payment_method_id
  * @see components/com_virtuemart/helpers/vmPSPlugin::plgVmOnShowOrderBEPayment()
  */
 function plgVmOnShowOrderBEPayment($virtuemart_order_id, $payment_method_id)
 {
     if (!$this->selectedThisByMethodId($payment_method_id)) {
         return NULL;
         // Another method was selected, do nothing
     }
     if (!($payments = $this->getDatasByOrderId($virtuemart_order_id))) {
         // JError::raiseWarning(500, $db->getErrorMsg());
         return '';
     }
     $html = '<table class="adminlist table">' . "\n";
     $html .= $this->getHtmlHeaderBE();
     $code = "sofort_response_";
     $first = TRUE;
     foreach ($payments as $payment) {
         $html .= '<tr class="row1"><th>' . vmText::_('COM_VIRTUEMART_DATE') . '</th><th align="left">' . $payment->created_on . '</th></tr>';
         // Now only the first entry has this data when creating the order
         if ($first) {
             $html .= $this->getHtmlRowBE('SOFORT_PAYMENT_NAME', $payment->payment_name);
             // keep that test to have it backwards compatible. Old version was deleting that column  when receiving an IPN notification
             if ($payment->payment_order_total and $payment->payment_order_total != 0.0) {
                 $html .= $this->getHtmlRowBE('SOFORT_PAYMENT_ORDER_TOTAL', $payment->payment_order_total . " " . shopFunctions::getCurrencyByID($payment->payment_currency, 'currency_code_3'));
             }
             if ($payment->email_currency and $payment->email_currency != 0) {
                 $html .= $this->getHtmlRowBE('SOFORT_PAYMENT_EMAIL_CURRENCY', shopFunctions::getCurrencyByID($payment->email_currency, 'currency_code_3'));
             }
             if ($payment->email_currency and $payment->email_currency != 0) {
                 $html .= $this->getHtmlRowBE('SOFORT_RESPONSE_TRANSACTION', $payment->sofort_response_transaction);
             }
             $first = FALSE;
         } else {
             foreach ($payment as $key => $value) {
                 // only displays if there is a value or the value is different from 0.00 and the value
                 if ($value) {
                     if (substr($key, 0, strlen($code)) == $code) {
                         $html .= $this->getHtmlRowBE($key, $value);
                     }
                 }
             }
         }
     }
     $html .= '</table>' . "\n";
     return $html;
 }
Exemple #7
0
 static function checkSafePath($safePath = 0)
 {
     if ($safePath == 0) {
         $safePath = VmConfig::get('forSale_path', 0);
         if (self::$tested) {
             return $safePath;
         }
     }
     $warn = FALSE;
     $uri = JFactory::getURI();
     $configlink = $uri->root() . 'administrator/index.php?option=com_virtuemart&view=config';
     VmConfig::loadJLang('com_virtuemart');
     if (empty($safePath)) {
         $warn = 'COM_VIRTUEMART_WARN_NO_SAFE_PATH_SET';
     } else {
         //jimport('joomla.filesystem.folder');
         if (!class_exists('JFolder')) {
             require_once JPATH_VM_LIBRARIES . DS . 'joomla' . DS . 'filesystem' . DS . 'folder.php';
         }
         $exists = JFolder::exists($safePath);
         if (!$exists) {
             $warn = 'COM_VIRTUEMART_WARN_SAFE_PATH_WRONG';
         } else {
             if (!is_writable($safePath)) {
                 VmConfig::loadJLang('com_virtuemart_config');
                 VmError('COM_VIRTUEMART_WARN_SAFE_PATH_NOT_WRITEABLE', vmText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'), $safePath, $configlink);
             } else {
                 if (!is_writable(self::getInvoicePath($safePath))) {
                     VmConfig::loadJLang('com_virtuemart_config');
                     VmError('COM_VIRTUEMART_WARN_SAFE_PATH_INV_NOT_WRITEABLE', vmText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'), $safePath, $configlink);
                 }
             }
         }
     }
     if ($warn) {
         $suggestedPath = shopFunctions::getSuggestedSafePath();
         VmConfig::loadJLang('com_virtuemart_config');
         VmWarn($warn, vmText::_('COM_VIRTUEMART_ADMIN_CFG_MEDIA_FORSALE_PATH'), $suggestedPath, $configlink);
         return FALSE;
     }
     return $safePath;
 }
Exemple #8
0
    ?>
		<div class="vendor-image">
		<?php 
    echo $this->vendor->images[0]->displayMediaThumb('', false);
    ?>
		</div>
	<?php 
}
?>
	</h1>

<?php 
if (!class_exists('ShopFunctions')) {
    require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'shopfunctions.php';
}
echo shopFunctions::renderVendorAddress($this->vendor->virtuemart_vendor_id);
/*	foreach($this->userFields as $userfields){

		foreach($userfields['fields'] as $item){
			if(!empty($item['value'])){
				if($item['name']==='agreed'){
					$item['value'] =  ($item['value']===0) ? vmText::_('COM_VIRTUEMART_USER_FORM_BILLTO_TOS_NO'):vmText::_('COM_VIRTUEMART_USER_FORM_BILLTO_TOS_YES');
				}
			?><!-- span class="titles"><?php echo $item['title'] ?></span -->
						<span class="values vm2<?php echo '-'.$item['name'] ?>" ><?php echo $this->escape($item['value']) ?></span>
					<?php if ($item['name'] != 'title' and $item['name'] != 'first_name' and $item['name'] != 'middle_name' and $item['name'] != 'zip') { ?>
						<br class="clear" />
					<?php
				}
			}
		}
 /**
  * Sets the file information and paths/urls and so on.
  *
  * @author Max Milbers
  * @param unknown_type $filename
  * @param unknown_type $url
  * @param unknown_type $path
  */
 function setFileInfo($type = 0)
 {
     $this->file_url_folder = '';
     $this->file_path_folder = '';
     $this->file_url_folder_thumb = '';
     if ($this->file_is_forSale == 0 and $type != 'forSale') {
         $this->file_url_folder = $this->getMediaUrlByView($type);
         $this->file_url_folder_thumb = $this->file_url_folder . 'resized/';
         $this->file_path_folder = str_replace('/', DS, $this->file_url_folder);
     } else {
         if (!class_exists('shopFunctions')) {
             require VMPATH_SITE . DS . 'helpers' . DS . 'shopfunctions.php';
         }
         $safePath = shopFunctions::checkSafePath();
         if (!$safePath) {
             return FALSE;
         }
         $this->file_path_folder = $safePath;
         $this->file_url_folder = $this->file_path_folder;
         //str_replace(DS,'/',$this->file_path_folder);
         $this->file_url_folder_thumb = VmConfig::get('forSale_path_thumb');
     }
     //Clean from possible injection
     while (strpos($this->file_path_folder, '..') !== false) {
         $this->file_path_folder = str_replace('..', '', $this->file_path_folder);
     }
     $this->file_path_folder = preg_replace('#[/\\\\]+#', DS, $this->file_path_folder);
     if (empty($this->file_url)) {
         $this->file_url = $this->file_url_folder;
         $this->file_name = '';
         $this->file_extension = '';
     } else {
         if (!class_exists('JFile')) {
             require VMPATH_LIBS . DS . 'joomla' . DS . 'filesystem' . DS . 'file.php';
         }
         if ($this->file_is_forSale == 1) {
             $rdspos = strrpos($this->file_url, DS);
             if ($rdspos !== false) {
                 $name = substr($this->file_url, $rdspos + 1);
             } else {
                 vmdebug('$name', $this->file_url, $rdspos);
             }
         } else {
             //This construction is only valid for the images, it is for own structuring using folders
             $name = str_replace($this->file_url_folder, '', $this->file_url);
         }
         if (!empty($name) && $name !== '/') {
             $this->file_name = JFile::stripExt($name);
             //$this->file_extension = strtolower(JFile::getExt($name));
             $this->file_extension = strtolower(JFile::getExt($name));
             //Ensure using right directory
             $file_url = $this->getMediaUrlByView($type) . $name;
             if ($this->file_is_forSale == 1) {
                 if (JFile::exists($file_url)) {
                     $this->file_url = $file_url;
                 } else {
                     //	vmdebug('MediaHandler, file does not exist in safepath '.$file_url);
                 }
             } else {
                 $pathToTest = VMPATH_ROOT . DS . str_replace('/', DS, $file_url);
                 if (JFile::exists($pathToTest)) {
                     $this->file_url = $file_url;
                 } else {
                     //	vmdebug('MediaHandler, file does not exist in '.$pathToTest);
                 }
             }
         }
     }
     if ($this->file_is_downloadable) {
         $this->media_role = 'file_is_downloadable';
     }
     if ($this->file_is_forSale) {
         $this->media_role = 'file_is_forSale';
     }
     if (empty($this->media_role)) {
         $this->media_role = 'file_is_displayable';
     }
     // 		vmdebug('$this->media_role',$this->media_role);
     $this->determineFoldersToTest();
     if (!empty($this->file_url) && empty($this->file_url_thumb)) {
         $this->displayMediaThumb('', true, '', false);
     }
 }
Exemple #10
0
	/**
	 * Display stored payment data for an order
	 *
	 * @see components/com_virtuemart/helpers/vmPSPlugin::plgVmOnShowOrderBEPayment()
	 */
	function plgVmOnShowOrderBEPayment($virtuemart_order_id, $payment_method_id) {

		if (!$this->selectedThisByMethodId($payment_method_id)) {
			return NULL; // Another method was selected, do nothing
		}
		if (!($this->_currentMethod = $this->getVmPluginMethod($payment_method_id))) {
			return FALSE;
		}
		if (!($payments = $this->_getPaypalInternalData($virtuemart_order_id))) {
			// JError::raiseWarning(500, $db->getErrorMsg());
			return '';
		}

		//$html = $this->renderByLayout('orderbepayment', array($payments, $this->_psType));
		$html = '<table class="adminlist" width="50%">' . "\n";
		$html .= $this->getHtmlHeaderBE();
		$code = "paypal_response_";
		$first = TRUE;
		foreach ($payments as $payment) {
			$html .= '<tr class="row1"><td>' . JText::_('VMPAYMENT_PAYPAL_DATE') . '</td><td align="left">' . $payment->created_on . '</td></tr>';
			// Now only the first entry has this data when creating the order
			if ($first) {
				$html .= $this->getHtmlRowBE('COM_VIRTUEMART_PAYMENT_NAME', $payment->payment_name);
				// keep that test to have it backwards compatible. Old version was deleting that column  when receiving an IPN notification
				if ($payment->payment_order_total and  $payment->payment_order_total != 0.00) {
					$html .= $this->getHtmlRowBE('COM_VIRTUEMART_TOTAL', $payment->payment_order_total . " " . shopFunctions::getCurrencyByID($payment->payment_currency, 'currency_code_3'));
				}

				$first = FALSE;
			} else {
				$paypalInterface = $this->_loadPayPalInterface();

				if (isset($payment->paypal_fullresponse) and !empty($payment->paypal_fullresponse)) {
					$paypal_data = json_decode($payment->paypal_fullresponse);
					$paypalInterface = $this->_loadPayPalInterface();
					$html .= $paypalInterface->onShowOrderBEPayment($paypal_data);

					$html .= '<tr><td></td><td>
    <a href="#" class="PayPalLogOpener" rel="' . $payment->id . '" >
        <div style="background-color: white; z-index: 100; right:0; display: none; border:solid 2px; padding:10px;" class="vm-absolute" id="PayPalLog_' . $payment->id . '">';

					foreach ($paypal_data as $key => $value) {
						$html .= ' <b>' . $key . '</b>:&nbsp;' . $value . '<br />';
					}

					$html .= ' </div>
        <span class="icon-nofloat vmicon vmicon-16-xml"></span>&nbsp;';
					$html .= JText::_('VMPAYMENT_PAYPAL_VIEW_TRANSACTION_LOG');
					$html .= '  </a>';
					$html .= ' </td></tr>';
				} else {
					$html .= $paypalInterface->onShowOrderBEPaymentByFields($payment);
				}
			}



		}
		$html .= '</table>' . "\n";

		$doc = JFactory::getDocument();
		$js = "
	jQuery().ready(function($) {
		$('.PayPalLogOpener').click(function() {
			var logId = $(this).attr('rel');
			$('#PayPalLog_'+logId).toggle();
			return false;
		});
	});";
		$doc->addScriptDeclaration($js);
		return $html;

	}
 function getInvoicePDF($orderDetails = 0, $viewName = 'invoice', $layout = 'invoice', $format = 'html', $force = false)
 {
     // 		$force = true;
     $path = VmConfig::get('forSale_path', 0);
     if (empty($path)) {
         vmError('No path set to store invoices');
         return false;
     } else {
         $path .= shopFunctions::getInvoiceFolderName() . DS;
         if (!file_exists($path)) {
             vmError('Path wrong to store invoices, folder invoices does not exist ' . $path);
             return false;
         } else {
             if (!is_writable($path)) {
                 vmError('Cannot store pdf, directory not writeable ' . $path);
                 return false;
             }
         }
     }
     $orderModel = VmModel::getModel('orders');
     $invoiceNumberDate = array();
     if (!$orderModel->createInvoiceNumber($orderDetails['details']['BT'], $invoiceNumberDate)) {
         return 0;
     }
     if (!empty($invoiceNumberDate[0])) {
         $invoiceNumber = $invoiceNumberDate[0];
     } else {
         $invoiceNumber = FALSE;
     }
     if (!$invoiceNumber or empty($invoiceNumber)) {
         vmError('Cant create pdf, createInvoiceNumber failed');
         return 0;
     }
     if (shopFunctions::InvoiceNumberReserved($invoiceNumber)) {
         return 0;
     }
     $path .= preg_replace('/[^A-Za-z0-9_\\-\\.]/', '_', 'vm' . $layout . '_' . $invoiceNumber . '.pdf');
     if (file_exists($path) and !$force) {
         return $path;
     }
     //We come from the be, so we need to load the FE langauge
     VmConfig::loadJLang('com_virtuemart', true);
     $this->addViewPath(JPATH_VM_SITE . DS . 'views');
     $view = $this->getView($viewName, $format);
     $this->writeJs = false;
     $view->addTemplatePath(JPATH_VM_SITE . DS . 'views' . DS . $viewName . DS . 'tmpl');
     $vmtemplate = VmConfig::get('vmtemplate', 0);
     if (!empty($vmtemplate) and $vmtemplate == 'default') {
         if (JVM_VERSION == 2) {
             $q = 'SELECT `template` FROM `#__template_styles` WHERE `client_id`="0" AND `home`="1"';
         } else {
             $q = 'SELECT `template` FROM `#__templates_menu` WHERE `client_id`="0" AND `menuid`="0"';
         }
         $db = JFactory::getDbo();
         $db->setQuery($q);
         $templateName = $db->loadResult();
     } else {
         $templateName = shopFunctionsF::setTemplate($vmtemplate);
     }
     if (!empty($templateName)) {
         $TemplateOverrideFolder = JPATH_SITE . DS . "templates" . DS . $templateName . DS . "html" . DS . "com_virtuemart" . DS . "invoice";
         if (file_exists($TemplateOverrideFolder)) {
             $view->addTemplatePath($TemplateOverrideFolder);
         }
     }
     $view->invoiceNumber = $invoiceNumberDate[0];
     $view->invoiceDate = $invoiceNumberDate[1];
     $view->orderDetails = $orderDetails;
     $view->uselayout = $layout;
     $view->showHeaderFooter = false;
     $vendorModel = VmModel::getModel('vendor');
     $virtuemart_vendor_id = 1;
     //We could set this automatically by the vendorId stored in the order.
     $vendor = $vendorModel->getVendor($virtuemart_vendor_id);
     $metadata = array('title' => JText::sprintf('COM_VIRTUEMART_INVOICE_TITLE', $vendor->vendor_store_name, $view->invoiceNumber, $orderDetails['details']['BT']->order_number), 'keywords' => JText::_('COM_VIRTUEMART_INVOICE_CREATOR'));
     return VmPdf::createVmPdf($view, $path, 'F', $metadata);
 }
Exemple #12
0
 function displayKlarnaLogos($method, $virtuemart_country_id, $shipTo, $total)
 {
     $session = JFactory::getSession();
     $sessionKlarna = $session->get('Klarna', 0, 'vm');
     if (empty($sessionKlarna)) {
         return '';
     }
     $sessionKlarnaData = unserialize($sessionKlarna);
     $address['virtuemart_country_id'] = $virtuemart_country_id;
     $cData = KlarnaHandler::getcData($method, $address);
     $country2 = strtolower(shopFunctions::getCountryByID($virtuemart_country_id, 'country_2_code'));
     switch ($sessionKlarnaData->klarna_option) {
         case 'invoice':
             $image = '/klarna_invoice_' . $country2 . '.png';
             $klarna_invoice_fee = KlarnaHandler::getInvoiceFeeInclTax($method, $cData['country_code_3']);
             $currency = CurrencyDisplay::getInstance();
             $display_fee = $currency->priceDisplay($klarna_invoice_fee);
             $text = JText::sprintf('VMPAYMENT_KLARNA_INVOICE_TITLE_NO_PRICE', $display_fee);
             break;
         case 'partpayment':
         case 'part':
             $image = '/klarna_part_' . $country2 . '.png';
             $address['virtuemart_country_id'] = $virtuemart_country_id;
             $pclasses = KlarnaHandler::getPClasses(NULL, $country2, KlarnaHandler::getKlarnaMode($method), $cData);
             if (!class_exists('Klarna_payments')) {
                 require JPATH_VMKLARNAPLUGIN . DS . 'klarna' . DS . 'helpers' . DS . 'klarna_payments.php';
             }
             if (!class_exists('KlarnaVm2API')) {
                 require JPATH_VMKLARNAPLUGIN . DS . 'klarna' . DS . 'helpers' . DS . 'klarna_vm2api.php';
             }
             $payments = new klarna_payments($cData, $shipTo);
             //vmdebug('displaylogos',$cart_prices);
             $totalInPaymentCurrency = KlarnaHandler::convertPrice($total, $cData['currency_code']);
             $text = $payments->displayPclass($sessionKlarnaData->KLARNA_DATA['pclass'], $totalInPaymentCurrency);
             // .' '.$total;
             break;
         case 'speccamp':
             $image = 'klarna_logo.png';
             $text = JText::_('VMPAYMENT_KLARNA_SPEC_TITLE');
             break;
         default:
             $image = '';
             $text = '';
             break;
     }
     $html = $this->renderByLayout('payment_cart', array('logo' => $image, 'description' => $text));
     return $html;
 }
Exemple #13
0
 function display($tpl = null)
 {
     //Load helpers
     if (!class_exists('CurrencyDisplay')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php';
     }
     if (!class_exists('VmHTML')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php';
     }
     if (!class_exists('vmPSPlugin')) {
         require VMPATH_PLUGINLIBS . DS . 'vmpsplugin.php';
     }
     $orderStatusModel = tmsModel::getModel('orderstatus');
     $orderStates = $orderStatusModel->getOrderStatusList(true);
     $this->SetViewTitle('ORDER');
     $orderModel = tmsModel::getModel();
     $curTask = vRequest::getCmd('task');
     if ($curTask == 'edit') {
         tsmConfig::loadJLang('com_tsmart_shoppers', TRUE);
         tsmConfig::loadJLang('com_tsmart_orders', true);
         //For getOrderStatusName
         if (!class_exists('ShopFunctions')) {
             require VMPATH_ADMIN . DS . 'helpers' . DS . 'shopfunctions.php';
         }
         // Load addl models
         $userFieldsModel = tmsModel::getModel('userfields');
         // Get the data
         $tsmart_order_id = vRequest::getInt('tsmart_order_id');
         $order = $orderModel->getOrder($tsmart_order_id);
         if (empty($order['details'])) {
             JFactory::getApplication()->redirect('index.php?option=com_tsmart&view=orders', tsmText::_('com_tsmart_ORDER_NOTFOUND'));
         }
         $_orderID = $order['details']['BT']->tsmart_order_id;
         $orderbt = $order['details']['BT'];
         $orderst = array_key_exists('ST', $order['details']) ? $order['details']['ST'] : $orderbt;
         $orderbt->invoiceNumber = $orderModel->getInvoiceNumber($orderbt->tsmart_order_id);
         $currency = CurrencyDisplay::getInstance('', $order['details']['BT']->tsmart_vendor_id);
         $this->assignRef('currency', $currency);
         $_userFields = $userFieldsModel->getUserFields('account', array('captcha' => true, 'delimiters' => true), array('delimiter_userinfo', 'user_is_vendor', 'username', 'name', 'password', 'password2', 'agreed', 'address_type'));
         $userFieldsCart = $userFieldsModel->getUserFields('cart', array('captcha' => true, 'delimiters' => true), array('delimiter_userinfo', 'user_is_vendor', 'username', 'password', 'password2', 'agreed', 'address_type'));
         $_userFields = array_merge($userFieldsCart, $_userFields);
         //Fallback for customer_note
         if (empty($orderbt->customer_note) and !empty($orderbt->oc_note)) {
             $orderbt->customer_note = $orderbt->oc_note;
         }
         $userfields = $userFieldsModel->getUserFieldsFilled($_userFields, $orderbt, 'BT_');
         $_userFields = $userFieldsModel->getUserFields('shipment', array(), array('delimiter_userinfo', 'username', 'email', 'password', 'password2', 'agreed', 'address_type'));
         $shipmentfields = $userFieldsModel->getUserFieldsFilled($_userFields, $orderst, 'ST_');
         // Create an array to allow orderlinestatuses to be translated
         // We'll probably want to put this somewhere in ShopFunctions...
         $_orderStatusList = array();
         foreach ($orderStates as $orderState) {
             //$_orderStatusList[$orderState->tsmart_orderstate_id] = $orderState->order_status_name;
             //When I use update, I have to use this?
             $_orderStatusList[$orderState->order_status_code] = tsmText::_($orderState->order_status_name);
         }
         $_itemStatusUpdateFields = array();
         $_itemAttributesUpdateFields = array();
         foreach ($order['items'] as $_item) {
             $_itemStatusUpdateFields[$_item->tsmart_order_item_id] = JHtml::_('select.genericlist', $orderStates, "item_id[" . $_item->tsmart_order_item_id . "][order_status]", 'class="selectItemStatusCode"', 'order_status_code', 'order_status_name', $_item->order_status, 'order_item_status' . $_item->tsmart_order_item_id, true);
         }
         if (!isset($_orderStatusList[$orderbt->order_status])) {
             if (empty($orderbt->order_status)) {
                 $orderbt->order_status = 'unknown';
             }
             $_orderStatusList[$orderbt->order_status] = tsmText::_('com_tsmart_UNKNOWN_ORDER_STATUS');
         }
         $this->lists['search'] = '';
         /* Assign the data */
         $this->assignRef('orderdetails', $order);
         $this->assignRef('orderID', $_orderID);
         $this->assignRef('userfields', $userfields);
         $this->assignRef('shipmentfields', $shipmentfields);
         $this->assignRef('orderstatuslist', $_orderStatusList);
         $this->assignRef('itemstatusupdatefields', $_itemStatusUpdateFields);
         $this->assignRef('itemattributesupdatefields', $_itemAttributesUpdateFields);
         $this->assignRef('orderbt', $orderbt);
         $this->assignRef('orderst', $orderst);
         $this->assignRef('tsmart_shipmentmethod_id', $orderbt->tsmart_shipmentmethod_id);
         /* Data for the Edit Status form popup */
         $_currentOrderStat = $order['details']['BT']->order_status;
         // used to update all item status in one time
         $_orderStatusSelect = JHtml::_('select.genericlist', $orderStates, 'order_status', 'style="width:100px;"', 'order_status_code', 'order_status_name', $_currentOrderStat, 'order_items_status', true);
         $this->assignRef('orderStatSelect', $_orderStatusSelect);
         $this->assignRef('currentOrderStat', $_currentOrderStat);
         /* Toolbar */
         if (JVM_VERSION < 3) {
             $backward = "back";
             $list = 'back';
         } else {
             $backward = 'backward';
             $list = 'list';
         }
         JToolBarHelper::custom('prevItem', $backward, '', 'com_tsmart_ITEM_PREVIOUS', false);
         JToolBarHelper::custom('nextItem', 'forward', '', 'com_tsmart_ITEM_NEXT', false);
         JToolBarHelper::divider();
         JToolBarHelper::custom('cancel', $list, '', 'com_tsmart_ORDER_LIST_LBL', false, false);
     } else {
         if ($curTask == 'editOrderItem') {
             if (!class_exists('calculationHelper')) {
                 require VMPATH_ADMIN . DS . 'helpers' . DS . 'calculationh.php';
             }
             $this->assignRef('orderstatuses', $orderStates);
             $model = tmsModel::getModel();
             $orderId = vRequest::getString('orderId', '');
             $orderLineItem = vRequest::getVar('orderLineId', '');
             $this->assignRef('tsmart_order_id', $orderId);
             $this->assignRef('tsmart_order_item_id', $orderLineItem);
             $orderItem = $model->getOrderLineDetails($orderId, $orderLineItem);
             $this->assignRef('orderitem', $orderItem);
         } else {
             $this->setLayout('orders');
             $model = tmsModel::getModel();
             $this->addStandardDefaultViewLists($model, 'created_on');
             $orderStatusModel = tmsModel::getModel('orderstatus');
             $orderstates = vRequest::getCmd('order_status_code', '');
             $this->lists['state_list'] = $orderStatusModel->renderOSList($orderstates, 'order_status_code', FALSE, ' onchange="this.form.submit();" ');
             $orderslist = $model->getOrdersList();
             $this->assignRef('orderstatuses', $orderStates);
             if (!class_exists('CurrencyDisplay')) {
                 require VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php';
             }
             /* Apply currency This must be done per order since it's vendor specific */
             $_currencies = array();
             // Save the currency data during this loop for performance reasons
             if ($orderslist) {
                 foreach ($orderslist as $tsmart_order_id => $order) {
                     if (!empty($order->order_currency)) {
                         $currency = $order->order_currency;
                     } else {
                         if ($order->tsmart_vendor_id) {
                             if (!class_exists('tsmartModelVendor')) {
                                 require VMPATH_ADMIN . DS . 'models' . DS . 'vendor.php';
                             }
                             $currObj = tsmartModelVendor::getVendorCurrency($order->tsmart_vendor_id);
                             $currency = $currObj->tsmart_currency_id;
                         }
                     }
                     //This is really interesting for multi-X, but I avoid to support it now already, lets stay it in the code
                     if (!array_key_exists('curr' . $currency, $_currencies)) {
                         $_currencies['curr' . $currency] = CurrencyDisplay::getInstance($currency, $order->tsmart_vendor_id);
                     }
                     $order->order_total = $_currencies['curr' . $currency]->priceDisplay($order->order_total);
                     $order->invoiceNumber = $model->getInvoiceNumber($order->tsmart_order_id);
                 }
             }
             //update order items button
             /*$q = 'SELECT * FROM #__tsmart_order_items WHERE `product_discountedPriceWithoutTax` IS NULL ';
             		$db = JFactory::getDBO();
             		$db->setQuery($q);
             		//$res = $db->loadRow();
             		if(true) {
             			JToolBarHelper::custom('updateCustomsOrderItems', 'new', 'new', vmText::_('com_tsmart_REPORT_UPDATEORDERITEMS'),false);
             			vmError('com_tsmart_UPDATEORDERITEMS_WARN');
             		}*/
             /*
              * UpdateStatus removed from the toolbar; don't understand how this was intented to work but
              * the order ID's aren't properly passed. Might be readded later; the controller needs to handle
              * the arguments.
              */
             /* Toolbar */
             //JToolBarHelper::customX( 'CreateOrderHead', 'new','new','New',false);
             JToolBarHelper::save('updatestatus', tsmText::_('com_tsmart_UPDATE_STATUS'));
             if (vmAccess::manager('orders.delete')) {
                 JToolBarHelper::spacer('80');
                 JToolBarHelper::deleteList();
             }
             /* Assign the data */
             $this->assignRef('orderslist', $orderslist);
             $this->pagination = $model->getPagination();
         }
     }
     if (JFactory::getApplication()->isSite()) {
         $bar = JToolBar::getInstance('toolbar');
         $bar->appendButton('Link', 'back', 'com_tsmart_LEAVE', 'index.php?option=com_tsmart&manage=0');
     }
     shopFunctions::checkSafePath();
     parent::display($tpl);
 }
Exemple #14
0
	<?php 
echo shopFunctionsF::getLoginForm($this->cart, FALSE);
// This displays the form to change the current shopper
$adminID = JFactory::getSession()->get('vmAdminID');
if ((JFactory::getUser()->authorise('core.admin', 'com_virtuemart') || JFactory::getUser($adminID)->authorise('core.admin', 'com_virtuemart')) && VmConfig::get('oncheckout_change_shopper', 0)) {
    echo $this->loadTemplate('shopperform');
}
$taskRoute = '';
?>
<form method="post" id="checkoutForm" name="checkoutForm" action="<?php 
echo JRoute::_('index.php?option=com_virtuemart&view=cart' . $taskRoute, $this->useXHTML, $this->useSSL);
?>
">
		<?php 
if (VmConfig::get('multixcart') == 'byselection') {
    echo shopFunctions::renderVendorFullVendorList($this->cart->vendorId);
}
echo $this->loadTemplate('address');
// This displays the pricelist MUST be done with tables, because it is also used for the emails
echo $this->loadTemplate('pricelist');
if (!empty($this->checkoutAdvertise)) {
    ?>
 <div id="checkout-advertise-box"> <?php 
    foreach ($this->checkoutAdvertise as $checkoutAdvertise) {
        ?>
				<div class="checkout-advertise">
					<?php 
        echo $checkoutAdvertise;
        ?>
				</div>
				<?php 
Exemple #15
0
 function display($tpl = null)
 {
     // Get the task
     $task = vRequest::getCmd('task', $this->getLayout());
     $this->assignRef('task', $task);
     // Load helpers
     if (!class_exists('CurrencyDisplay')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php';
     }
     if (!class_exists('VmHTML')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php';
     }
     if (!class_exists('VmImage')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'image.php';
     }
     $model = tmsModel::getModel();
     // Handle any publish/unpublish
     switch ($task) {
         case 'add':
         case 'edit':
             //this was in the controller for the edit tasks, we need this for the access by FE
             //$this->addTemplatePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'views'.DS.'product'.DS.'tmpl');
             tsmConfig::loadJLang('com_tsmart_orders', TRUE);
             tsmConfig::loadJLang('com_tsmart_shoppers', TRUE);
             $model_country = tmsModel::getModel('country');
             $this->countries = $model_country->getItemList();
             $tsmart_product_id = vRequest::getInt('tsmart_product_id');
             if (is_array($tsmart_product_id) && count($tsmart_product_id) > 0) {
                 $tsmart_product_id = (int) $tsmart_product_id[0];
             } else {
                 $tsmart_product_id = (int) $tsmart_product_id;
             }
             $product = $model->getItem($tsmart_product_id);
             require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmserviceclass.php';
             $product->tsmart_service_class_ids = tsmserviceclass::get_list_service_class_ids_by_tour_id($tsmart_product_id);
             require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmgroupsize.php';
             $product->tsmart_group_size_ids = tsmGroupSize::get_list_group_size_ids_by_tour_id($tsmart_product_id);
             //$user = JFactory::getUser();
             $superVendor = vmAccess::isSuperVendor();
             if ($superVendor != 1 and $superVendor != $product->tsmart_vendor_id) {
                 vmdebug('Product view.html.php ' . $superVendor, $product->tsmart_vendor_id);
                 JFactory::getApplication()->redirect('index.php?option=com_tsmart&view=tsmart', tsmText::_('com_tsmart_ALERTNOTAUTHOR'), 'error');
             }
             if (!empty($product->product_parent_id)) {
                 $product_parent = $model->getProductSingle($product->product_parent_id, false);
             }
             require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmserviceclass.php';
             $this->tour_service_class = tsmserviceclass::get_list_tour_service_class();
             $customfields = tmsModel::getModel('Customfields');
             $product->allIds[] = $product->tsmart_product_id;
             if (!empty($product->product_parent_id)) {
                 $product->allIds[] = $product->product_parent_id;
             }
             $product->customfields = $customfields->getCustomEmbeddedProductCustomFields($product->allIds);
             // Get the category tree
             if (isset($product->categories)) {
                 $this->category_tree = ShopFunctions::categoryListTree($product->categories);
             } else {
                 $this->category_tree = ShopFunctions::categoryListTree();
             }
             //Fallback for categories inherited by parent to correctly calculate the prices
             if (empty($product->categories) and !empty($product_parent->categories)) {
                 $product->categories = $product_parent->categories;
             }
             //Get the shoppergoup list - Cleanshooter Custom Shopper Visibility
             if (!isset($product->shoppergroups)) {
                 $product->shoppergroups = 0;
             }
             $this->shoppergroupList = ShopFunctions::renderShopperGroupList($product->shoppergroups);
             // Load the product price
             if (!class_exists('calculationHelper')) {
                 require VMPATH_ADMIN . DS . 'helpers' . DS . 'calculationh.php';
             }
             //Do we need the children? If there is a C customfield, we dont want them
             $isCustomVariant = false;
             foreach ($product->customfields as $custom) {
                 if ($custom->field_type == 'C' and $custom->tsmart_product_id == $tsmart_product_id) {
                     $isCustomVariant = true;
                     break;
                 }
             }
             if (!class_exists('tsmartModelConfig')) {
                 require VMPATH_ADMIN . '/models/config.php';
             }
             $productLayouts = tsmartModelConfig::getLayoutList('productdetails');
             $this->productLayouts = $productLayouts;
             // Load Images
             $model->addImages($product);
             if (!class_exists('VmTemplate')) {
                 require VMPATH_SITE . DS . 'helpers' . DS . 'vmtemplate.php';
             }
             $vmtemplate = VmTemplate::loadVmTemplateStyle();
             $this->imagePath = shopFunctions::getAvailabilityIconUrl($vmtemplate);
             // Load the vendors
             $vendor_model = tmsModel::getModel('vendor');
             $lists['vendors'] = '';
             if ($this->showVendors()) {
                 $lists['vendors'] = Shopfunctions::renderVendorList($product->tsmart_vendor_id);
             }
             // Load the currencies
             $currency_model = tmsModel::getModel('currency');
             $vendor_model->setId(vmAccess::isSuperVendor());
             $this->vendor = $vendor_model->getVendor();
             $currency = $currency_model->getItemList();
             $this->vendor_currency_symb = $currency->currency_symbol;
             $lists['manufacturers'] = shopFunctions::renderManufacturerList($product->tsmart_manufacturer_id, true);
             if (!empty($product->product_weight_uom)) {
                 $product_weight_uom = $product->product_weight_uom;
             } else {
                 if (!empty($product_parent)) {
                     $product_weight_uom = $product_parent->product_weight_uom;
                 } else {
                     $product_weight_uom = tsmConfig::get('weight_unit_default');
                 }
             }
             if (!empty($product->product_lwh_uom)) {
                 $product_lwh_uom = $product->product_lwh_uom;
             } else {
                 if (!empty($product_parent)) {
                     $product_lwh_uom = $product_parent->product_lwh_uom;
                 } else {
                     $product_lwh_uom = tsmConfig::get('lwh_unit_default');
                 }
             }
             if (!empty($product->product_unit)) {
                 $product_unit = $product->product_unit;
             } else {
                 if (!empty($product_parent)) {
                     $product_unit = $product_parent->product_unit;
                 } else {
                     $product_unit = tsmConfig::get('product_unit_default', 'KG');
                 }
             }
             $lists['product_weight_uom'] = ShopFunctions::renderWeightUnitList('product_weight_uom', $product_weight_uom);
             $lists['product_iso_uom'] = ShopFunctions::renderUnitIsoList('product_unit', $product_unit);
             $lists['product_lwh_uom'] = ShopFunctions::renderLWHUnitList('product_lwh_uom', $product_lwh_uom);
             if (empty($product->product_available_date)) {
                 $product->product_available_date = date("Y-m-d");
             }
             $waitinglistmodel = tmsModel::getModel('waitinglist');
             /* Load waiting list */
             if ($product->tsmart_product_id) {
                 //$waitinglist = $this->get('waitingusers', 'waitinglist');
                 $waitinglist = $waitinglistmodel->getWaitingusers($product->tsmart_product_id);
                 $this->assignRef('waitinglist', $waitinglist);
             }
             $orderstatusModel = tmsModel::getModel('orderstatus');
             $lists['OrderStatus'] = $orderstatusModel->renderOSList(array(), 'order_status', TRUE);
             // Add the tsmart_shoppergroup_ids
             $cid = JFactory::getUser()->id;
             $this->activeShoppergroups = shopfunctions::renderGuiList($cid, 'shoppergroups', 'shopper_group_name', 'category', 'vmuser_shoppergroups', 'tsmart_user_id');
             if (!empty($this->activeShoppergroups)) {
                 $shoppergroupModel = tmsModel::getModel('shoppergroup');
                 $this->activeShoppergroups = tsmText::_($shoppergroupModel->getDefault(0)->shopper_group_name);
             }
             // Load protocustom lists
             $customModel = tmsModel::getModel('custom');
             $this->fieldTypes = tsmartModelCustom::getCustomTypes();
             $customsList = $customModel->getCustomsList();
             $attribs = 'style= "width: 300px;"';
             $customlist = JHtml::_('select.genericlist', $customsList, 'customlist', $attribs, 'value', 'text', null, false, true);
             $this->assignRef('customsList', $customlist);
             if ($product->product_parent_id > 0) {
                 // Set up labels
                 $info_label = tsmText::_('com_tsmart_PRODUCT_FORM_ITEM_INFO_LBL');
                 $status_label = tsmText::_('com_tsmart_PRODUCT_FORM_ITEM_STATUS_LBL');
                 $dim_weight_label = tsmText::_('com_tsmart_PRODUCT_FORM_ITEM_DIM_WEIGHT_LBL');
                 $images_label = tsmText::_('com_tsmart_PRODUCT_FORM_ITEM_IMAGES_LBL');
                 $delete_message = tsmText::_('com_tsmart_PRODUCT_FORM_DELETE_ITEM_MSG');
             } else {
                 if ($task == 'add') {
                     $action = tsmText::_('com_tsmart_PRODUCT_FORM_NEW_PRODUCT_LBL');
                 } else {
                     $action = tsmText::_('com_tsmart_PRODUCT_FORM_UPDATE_ITEM_LBL');
                 }
                 $info_label = tsmText::_('com_tsmart_PRODUCT_FORM_PRODUCT_INFO_LBL');
                 $status_label = tsmText::_('com_tsmart_PRODUCT_FORM_PRODUCT_STATUS_LBL');
                 $dim_weight_label = tsmText::_('com_tsmart_PRODUCT_FORM_PRODUCT_DIM_WEIGHT_LBL');
                 $images_label = tsmText::_('com_tsmart_PRODUCT_FORM_PRODUCT_IMAGES_LBL');
                 $delete_message = tsmText::_('com_tsmart_PRODUCT_FORM_DELETE_PRODUCT_MSG');
             }
             //get countries
             require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmcountries.php';
             $countries = tsmcountries::get_countries();
             $this->assignRef('countries', $countries);
             //end get countries
             //get cities
             require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/vmcities.php';
             $cities = tsmcities::get_cities();
             $this->assignRef('cities', $cities);
             //end get cities
             //get tour style
             require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmtourstyle.php';
             $list_tour_style = tsmtourstyle::get_list_tour_style();
             $this->assignRef('list_tour_style', $list_tour_style);
             //end get toursyle
             //get tour section
             require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmtoursection.php';
             $list_tour_section = tsmtoursection::get_list_tour_section();
             $this->assignRef('list_tour_section', $list_tour_section);
             //end get toursyle
             //get tour physicalgrade
             require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmphysicalgrade.php';
             $list_physical_grade = vmphysicalgrade::get_physical_grade();
             $this->assignRef('list_physical_grade', $list_physical_grade);
             //end get physicalgrade
             //get tour_type
             require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmtourtype.php';
             $list_tour_type = tsmtourtype::get_list_tour_type();
             $this->assignRef('list_tour_type', $list_tour_type);
             //end get tour_type
             //get tour_type
             require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmserviceclass.php';
             $list_tour_service_class = tsmserviceclass::get_list_tour_service_class();
             $product->list_tour_service_class_id = tsmserviceclass::get_list_service_class_ids_by_tour_id($product->tsmart_product_id);
             $this->assignRef('list_tour_service_class', $list_tour_service_class);
             //end get tour_type
             //get activities
             require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/vmactivities.php';
             $product->list_activity_id = tsmactivities::get_list_activity_id_by_tour_id($product->tsmart_product_id);
             $activities = tsmactivities::get_activities();
             $this->assignRef('activities', $activities);
             //end get activities
             //get list group size
             require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmgroupsize.php';
             $list_group_size = tsmGroupSize::get_list_group_size();
             $product->list_group_size_id = tsmGroupSize::get_list_group_size_ids_by_tour_id($product->tsmart_product_id);
             $this->assignRef('list_group_size', $list_group_size);
             //end get list group size
             //get list country
             require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmcountries.php';
             $product->list_tsmart_country_id = tsmcountries::get_list_tsmart_country_id_by_tour_id($product->tsmart_product_id);
             //end get list group size
             require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmprice.php';
             $this->list_price_type = vmprice::get_list_price_type();
             require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmproduct.php';
             $this->list_tour_method = vmproduct::get_list_tour_method();
             $this->assignRef('product', $product);
             $this->assignRef('product_parent', $product_parent);
             /* Assign label values */
             $this->assignRef('action', $action);
             $this->assignRef('info_label', $info_label);
             $this->assignRef('status_label', $status_label);
             $this->assignRef('dim_weight_label', $dim_weight_label);
             $this->assignRef('images_label', $images_label);
             $this->assignRef('delete_message', $delete_message);
             $this->assignRef('lists', $lists);
             // Toolbar
             if ($product->product_sku) {
                 $sku = ' (' . $product->product_sku . ')';
             } else {
                 $sku = "";
             }
             //if (!empty($product->canonCatLink)) $canonLink = '&tsmart_category_id=' . $product->canonCatLink; else $canonLink = '';
             if (!empty($product->tsmart_product_id)) {
                 if (!class_exists('shopFunctionsF')) {
                     require VMPATH_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
                 }
                 $menuItemID = shopFunctionsF::getMenuItemId(JFactory::getLanguage()->getTag());
                 $canonLink = '';
                 if ($product->canonCatId) {
                     $canonLink = '&tsmart_category_id=' . $product->canonCatId;
                 }
                 $text = '<a href="' . juri::root() . 'index.php?option=com_tsmart&view=productdetails&tsmart_product_id=' . $product->tsmart_product_id . $canonLink . '&Itemid=' . $menuItemID . '" target="_blank" >' . $product->product_name . $sku . '<span class="vm2-modallink"></span></a>';
                 if (JFactory::getApplication()->isSite()) {
                     $bar = JToolBar::getInstance('toolbar');
                     $bar->appendButton('Link', 'back', 'com_tsmart_LEAVE_TO_PRODUCT', juri::root() . 'index.php?option=com_tsmart&view=productdetails&tsmart_product_id=' . $product->tsmart_product_id . $canonLink . '&Itemid=' . $menuItemID);
                 }
             } else {
                 $text = $product->product_name . $sku;
             }
             $this->SetViewTitle('PRODUCT', $text);
             $this->addStandardEditViewCommandsNoValidate($product->tsmart_product_id);
             break;
         case 'massxref_cats':
         case 'massxref_cats_exe':
             $this->SetViewTitle('PRODUCT_MASSXREF');
             $showVendors = $this->showVendors();
             $this->assignRef('showVendors', $showVendors);
             $keyWord = '';
             $catmodel = tmsModel::getModel('category');
             $this->assignRef('catmodel', $catmodel);
             $this->addStandardDefaultViewCommandsNoValidate();
             $this->addStandardDefaultViewLists($catmodel, 'category_name');
             $session = JFactory::getSession();
             $reset = $session->get('reset_pag', false, 'vm');
             $limit = '';
             if ($reset) {
                 $limit = 0;
                 $session->set('reset_pag', false, 'vm');
             }
             $this->categories = $catmodel->getCategoryTree(0, 0, false, $this->lists['search'], $limit);
             $catpagination = $catmodel->getPagination();
             $this->assignRef('catpagination', $catpagination);
             $this->setLayout('massxref');
             JToolBarHelper::custom('massxref_cats_exe', 'new', 'new', tsmText::_('com_tsmart_PRODUCT_XREF_CAT_EXE'), false);
             break;
         case 'massxref_sgrps':
         case 'massxref_sgrps_exe':
             $sgrpmodel = tmsModel::getModel('shoppergroup');
             $this->addStandardDefaultViewLists($sgrpmodel);
             $shoppergroups = $sgrpmodel->getShopperGroups(false, true);
             $this->assignRef('shoppergroups', $shoppergroups);
             $sgrppagination = $sgrpmodel->getPagination();
             $this->assignRef('sgrppagination', $sgrppagination);
             $this->setLayout('massxref');
             JToolBarHelper::custom('massxref_sgrps_exe', 'new', 'new', tsmText::_('com_tsmart_PRODUCT_XREF_SGRPS_EXE'), false);
             break;
         default:
             if ($product_parent_id = vRequest::getInt('product_parent_id', false)) {
                 $product_parent = $model->getProductSingle($product_parent_id, false);
                 if ($product_parent) {
                     $title = 'PRODUCT_CHILDREN_LIST';
                     $link_to_parent = JHtml::_('link', JRoute::_('index.php?view=product&task=edit&tsmart_product_id=' . $product_parent->tsmart_product_id . '&option=com_tsmart'), $product_parent->product_name, array('title' => tsmText::_('com_tsmart_EDIT_PARENT') . ' ' . $product_parent->product_name));
                     $msg = tsmText::_('com_tsmart_PRODUCT_OF') . " " . $link_to_parent;
                 } else {
                     $title = 'PRODUCT_CHILDREN_LIST';
                     $msg = 'Parent with product_parent_id ' . $product_parent_id . ' not found';
                 }
             } else {
                 $title = 'PRODUCT';
                 $msg = "";
             }
             $this->SetViewTitle($title, $msg);
             $this->addStandardDefaultViewLists($model, 'created_on');
             if ($cI = vRequest::getInt('tsmart_category_id', false)) {
                 $app = JFactory::getApplication();
                 //$old_state = $app->getUserState('tsmart_category_id');
                 $old_state = $app->getUserState('tsmart_category_id');
                 if (empty($old_state) or $old_state != $cI) {
                     vRequest::setVar('com_tsmart.product.filter_order', 'pc.ordering');
                     $model->filter_order = 'pc.ordering';
                     $old_state = $app->setUserState('tsmart_category_id', $cI);
                 }
             }
             //Get the list of products
             $productlist = $model->getItemList();
             //The pagination must now always set AFTER the model load the listing
             $this->pagination = $model->getPagination();
             //Get the category tree
             $categoryId = $model->tsmart_category_id;
             //OSP switched to filter in model, was vRequest::getInt('tsmart_category_id');
             $category_tree = ShopFunctions::categoryListTree(array($categoryId));
             $this->assignRef('category_tree', $category_tree);
             //load service class
             //Load the product price
             if (!class_exists('calculationHelper')) {
                 require VMPATH_ADMIN . DS . 'helpers' . DS . 'calculationh.php';
             }
             $vendor_model = tmsModel::getModel('vendor');
             $productreviews = tmsModel::getModel('ratings');
             $this->mfTable = $model->getTable('manufacturers');
             $this->catTable = $model->getTable('categories');
             $this->lists['vendors'] = '';
             if ($this->showVendors()) {
                 $this->lists['vendors'] = Shopfunctions::renderVendorList(vmAccess::getVendorId());
             }
             foreach ($productlist as $tsmart_product_id => $product) {
                 $product->mediaitems = count($product->tsmart_media_id);
                 $product->reviews = $productreviews->countReviewsForProduct($product->tsmart_product_id);
                 $vendor_model->setId($product->tsmart_vendor_id);
                 $vendor = $vendor_model->getVendor();
                 $currencyDisplay = CurrencyDisplay::getInstance($vendor->vendor_currency, $vendor->tsmart_vendor_id);
                 if (!empty($product->allPrices[$product->selectedPrice]['product_price']) && !empty($product->allPrices[$product->selectedPrice]['product_currency'])) {
                     $product->product_price_display = $currencyDisplay->priceDisplay($product->allPrices[$product->selectedPrice]['product_price'], (int) $product->allPrices[$product->selectedPrice]['product_currency'], 1, true);
                 } else {
                     if (!empty($product->allPrices) and count($product->allPrices) > 1) {
                         $product->product_price_display = tsmText::_('com_tsmart_MULTIPLE_PRICES');
                     } else {
                         $product->product_price_display = tsmText::_('com_tsmart_NO_PRICE_SET');
                     }
                 }
                 // Write the first 5 categories in the list
                 $product->categoriesList = '';
                 if (!empty($product->categories[0])) {
                     $product->categoriesList = shopfunctions::renderGuiList($product->categories, 'categories', 'category_name', 'category');
                 }
                 // Write the first 5 manufacturers in the list
                 $product->manuList = '';
                 if (!empty($product->tsmart_manufacturer_id[0])) {
                     $product->manuList = shopfunctions::renderGuiList($product->tsmart_manufacturer_id, 'manufacturers', 'mf_name', 'manufacturer');
                 }
             }
             $mf_model = tmsModel::getModel('manufacturer');
             $manufacturers = $mf_model->getManufacturerDropdown();
             $this->assignRef('manufacturers', $manufacturers);
             /* add Search filter in lists*/
             /* Search type */
             $options = array('' => tsmText::_('com_tsmart_LIST_EMPTY_OPTION'), 'parent' => tsmText::_('com_tsmart_PRODUCT_LIST_SEARCH_BY_PARENT_PRODUCT'), 'product' => tsmText::_('com_tsmart_PRODUCT_LIST_SEARCH_BY_DATE_TYPE_PRODUCT'), 'price' => tsmText::_('com_tsmart_PRODUCT_LIST_SEARCH_BY_DATE_TYPE_PRICE'), 'withoutprice' => tsmText::_('com_tsmart_PRODUCT_LIST_SEARCH_BY_DATE_TYPE_WITHOUTPRICE'));
             $this->lists['search_type'] = VmHTML::selectList('search_type', vRequest::getVar('search_type'), $options);
             /* Search order */
             $options = array('bf' => tsmText::_('com_tsmart_PRODUCT_LIST_SEARCH_BY_DATE_BEFORE'), 'af' => tsmText::_('com_tsmart_PRODUCT_LIST_SEARCH_BY_DATE_AFTER'));
             $this->lists['search_order'] = VmHTML::selectList('search_order', vRequest::getVar('search_order'), $options);
             // Toolbar
             /*if (vmAccess::manager('product.edit')) {
                   JToolBarHelper::custom('massxref_cats', 'new', 'new', vmText::_('com_tsmart_PRODUCT_XREF_CAT'), true);
                   JToolBarHelper::custom('massxref_sgrps', 'new', 'new', vmText::_('com_tsmart_PRODUCT_XREF_SGRPS'), true);
               }
               if (vmAccess::manager('product.create')) {
                   JToolBarHelper::custom('createchild', 'new', 'new', vmText::_('com_tsmart_PRODUCT_CHILD'), true);
                   JToolBarHelper::custom('cloneproduct', 'copy', 'copy', vmText::_('com_tsmart_PRODUCT_CLONE'), true);
               }*/
             // JToolBarHelper::custom('addrating', 'default', '', vmText::_('com_tsmart_ADD_RATING'), true);
             $view = vRequest::getCmd('view', vRequest::getCmd('controller', 'tsmart'));
             JToolBarHelper::divider();
             if (vmAccess::manager($view . '.edit.state')) {
                 JToolBarHelper::publishList();
                 JToolBarHelper::unpublishList();
             }
             if (vmAccess::manager($view . '.delete')) {
                 JToolBarHelper::spacer('10');
                 JToolBarHelper::deleteList();
             }
             $this->assignRef('productlist', $productlist);
             $this->assignRef('tsmart_category_id', $categoryId);
             $this->assignRef('model', $model);
             break;
     }
     parent::display($tpl);
 }
Exemple #16
0
 function checkStoreInvoice($orderDetails = 0)
 {
     JRequest::setVar('task', 'checkStoreInvoice');
     $force = true;
     //	@ini_set( 'max_execution_time', 5 );
     $path = VmConfig::get('forSale_path', 0);
     if ($path === 0) {
         vmError('No path set to store invoices');
         return false;
     } else {
         $path .= 'invoices' . DS;
         if (!file_exists($path)) {
             vmError('Path wrong to store invoices, folder invoices does not exist ' . $path);
             return false;
         } else {
             if (!is_writable($path)) {
                 vmError('Cannot store pdf, directory not writeable ' . $path);
                 return false;
             }
         }
     }
     $orderModel = VmModel::getModel('orders');
     $invoiceNumberDate = array();
     if (!$orderModel->createInvoiceNumber($orderDetails['details']['BT'], $invoiceNumberDate)) {
         return 0;
     }
     if (!empty($invoiceNumberDate[0])) {
         $invoiceNumber = $invoiceNumberDate[0];
     } else {
         $invoiceNumber = FALSE;
     }
     if (!$invoiceNumber or empty($invoiceNumber)) {
         vmError('Cant create pdf, createInvoiceNumber failed');
         return 0;
     }
     if (shopFunctions::InvoiceNumberReserved($invoiceNumber)) {
         return 0;
     }
     $path .= 'vminvoice_' . $invoiceNumber . '.pdf';
     if (file_exists($path) and !$force) {
         return $path;
     }
     // 			$app = JFactory::getApplication('site');
     //We come from the be, so we need to load the FE langauge
     $jlang = JFactory::getLanguage();
     $jlang->load('com_virtuemart', JPATH_SITE, 'en-GB', true);
     $jlang->load('com_virtuemart', JPATH_SITE, $jlang->getDefault(), true);
     $jlang->load('com_virtuemart', JPATH_SITE, null, true);
     $this->addViewPath(JPATH_VM_SITE . DS . 'views');
     $format = 'html';
     $viewName = 'invoice';
     $view = $this->getView($viewName, $format);
     $view->addTemplatePath(JPATH_VM_SITE . DS . 'views' . DS . 'invoice' . DS . 'tmpl');
     $view->invoiceNumber = $invoiceNumberDate[0];
     $view->invoiceDate = $invoiceNumberDate[1];
     $view->orderDetails = $orderDetails;
     $view->uselayout = 'invoice';
     ob_start();
     $view->display();
     $html = ob_get_contents();
     ob_end_clean();
     // create new PDF document
     $pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     // set document information
     $pdf->SetCreator('Invoice by VirtueMart 2, used library tcpdf');
     $pdf->SetAuthor($view->vendor->vendor_name);
     $pdf->SetTitle(JText::_('COM_VIRTUEMART_INVOICE_TITLE'));
     $pdf->SetSubject(JText::sprintf('COM_VIRTUEMART_INVOICE_SUBJ', $view->vendor->vendor_store_name));
     $pdf->SetKeywords('Invoice by VirtueMart 2');
     //virtuemart.cloudaccess.net/index.php?option=com_virtuemart&view=invoice&layout=details&virtuemart_order_id=18&order_number=6e074d9b&order_pass=p_9cb9e2&task=checkStoreInvoice
     if (empty($view->vendor->images[0])) {
         vmError('Vendor image given path empty ');
     } else {
         if (empty($view->vendor->images[0]->file_url_folder) or empty($view->vendor->images[0]->file_name) or empty($view->vendor->images[0]->file_extension)) {
             vmError('Vendor image given image is not complete ' . $view->vendor->images[0]->file_url_folder . $view->vendor->images[0]->file_name . '.' . $view->vendor->images[0]->file_extension);
             vmdebug('Vendor image given image is not complete, the given media', $view->vendor->images[0]);
         } else {
             if (!empty($view->vendor->images[0]->file_extension) and strtolower($view->vendor->images[0]->file_extension) == 'png') {
                 vmError('Warning extension of the image is a png, tpcdf has problems with that in the header, choose a jpg or gif');
             } else {
                 $imagePath = DS . str_replace('/', DS, $view->vendor->images[0]->file_url_folder . $view->vendor->images[0]->file_name . '.' . $view->vendor->images[0]->file_extension);
                 if (!file_exists(JPATH_ROOT . $imagePath)) {
                     vmError('Vendor image missing ' . $imagePath);
                 } else {
                     $pdf->SetHeaderData($imagePath, 60, $view->vendor->vendor_store_name, $view->vendorAddress);
                 }
             }
         }
     }
     // set header and footer fonts
     $pdf->setHeaderFont(array('helvetica', '', 8));
     $pdf->setFooterFont(array('helvetica', '', 10));
     // set default monospaced font
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     //set margins
     $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
     $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     //set auto page breaks
     $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     //set image scale factor
     $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     //TODO include the right file (in libraries/tcpdf/config/lang set some language-dependent strings
     $l = '';
     $pdf->setLanguageArray($l);
     // set default font subsetting mode
     $pdf->setFontSubsetting(true);
     // Set font
     // dejavusans is a UTF-8 Unicode font, if you only need to
     // print standard ASCII chars, you can use core fonts like
     // helvetica or times to reduce file size.
     $pdf->SetFont('helvetica', '', 8, '', true);
     // Add a page
     // This method has several options, check the source code documentation for more information.
     $pdf->AddPage();
     // Set some content to print
     // $html =
     // Print text using writeHTMLCell()
     $pdf->writeHTMLCell($w = 0, $h = 0, $x = '', $y = '', $html, $border = 0, $ln = 1, $fill = 0, $reseth = true, $align = '', $autopadding = true);
     // Close and output PDF document
     // This method has several options, check the source code documentation for more information.
     $pdf->Output($path, 'F');
     return $path;
 }
Exemple #17
0
 /**
  * Return an array with userFields in several formats.
  *
  * @access public
  * @param $_selection An array, as returned by getuserFields(), with fields that should be returned.
  * @param $_userData Array with userdata holding the values for the fields
  * @param $_prefix string Optional prefix for the formtag name attribute
  * @author Oscar van Eijk
  * @return array List with all userfield data in the format:
  * array(
  *    'fields' => array(   // All fields
  *                   <fieldname> => array(
  *                                     'name' =>       // Name of the field
  *                                     'value' =>      // Existing value for the current user, or the default
  *                                     'title' =>      // Title used for label and such
  *                                     'type' =>       // Field type as specified in the userfields table
  *                                     'hidden' =>     // True/False
  *                                     'required' =>   // True/False. If True, the formcode also has the class "required" for the Joomla formvalidator
  *                                     'formcode' =>   // Full HTML tag
  *                                  )
  *                   [...]
  *                )
  *    'functions' => array() // Optional javascript functions without <script> tags.
  *                           // Possible usage: if (count($ar('functions')>0) echo '<script ...>'.join("\n", $ar('functions')).'</script>;
  *    'scripts'   => array(  // Array with scriptsources for use with JHTML::script();
  *                      <name> => <path>
  *                      [...]
  *                   )
  *    'links'     => array(  // Array with stylesheets for use with JHTML::stylesheet();
  *                      <name> => <path>
  *                      [...]
  *                   )
  * )
  * @example This example illustrates the use of this function. For additional examples, see the Order view
  * and the User view in the administrator section.
  * <pre>
  *   // In the controller, make sure this model is loaded.
  *   // In view.html.php, make the following calls:
  *   $_usrDetails = getUserDetailsFromSomeModel(); // retrieve an user_info record, eg from the usermodel or ordermodel
  *   $_usrFieldList = $userFieldsModel->getUserFields(
  *                    'registration'
  *                  , array() // Default switches
  *                  , array('delimiter_userinfo', 'username', 'email', 'password', 'password2', 'agreed', 'address_type') // Skips
  *    );
  *   $usrFieldValues = $userFieldsModel->getUserFieldsFilled(
  *                      $_usrFieldList
  *                     ,$_usrDetails
  *   );
  *   $this->assignRef('userfields', $userfields);
  *   // In the template, use code below to display the data. For an extended example using
  *   // delimiters, JavaScripts and StyleSheets, see the edit_shopper.php in the user view
  *   <table class="admintable" width="100%">
  *     <thead>
  *       <tr>
  *         <td class="key" style="text-align: center;"  colspan="2">
  *            <?php echo JText::_('COM_VIRTUEMART_TABLE_HEADER') ?>
  *         </td>
  *       </tr>
  *     </thead>
  *      <?php
  *        foreach ($this->shipmentfields['fields'] as $_field ) {
  *          echo '  <tr>'."\n";
  *          echo '    <td class="key">'."\n";
  *          echo '      '.$_field['title']."\n";
  *          echo '    </td>'."\n";
  *          echo '    <td>'."\n";
  *
  *          echo '      '.$_field['value']."\n";    // Display only
  *       Or:
  *          echo '      '.$_field['formcode']."\n"; // Input form
  *
  *          echo '    </td>'."\n";
  *          echo '  </tr>'."\n";
  *        }
  *      ?>
  *    </table>
  * </pre>
  */
 public function getUserFieldsFilled($_selection, $_userData = null, $_prefix = '')
 {
     if (!class_exists('ShopFunctions')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'shopfunctions.php';
     }
     $_return = array('fields' => array(), 'functions' => array(), 'scripts' => array(), 'links' => array());
     $admin = false;
     if (!class_exists('Permissions')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'permissions.php';
     }
     if (Permissions::getInstance()->check('admin', 'storeadmin')) {
         $admin = true;
     }
     // 		vmdebug('my user data in getUserFieldsFilled',$_selection,$_userData);
     $_userData = (array) $_userData;
     if (is_array($_selection)) {
         foreach ($_selection as $_fld) {
             $_return['fields'][$_fld->name] = array('name' => $_prefix . $_fld->name, 'value' => $_userData == null || !array_key_exists($_fld->name, $_userData) ? $_fld->default : @html_entity_decode($_userData[$_fld->name], ENT_COMPAT, 'UTF-8'), 'title' => JText::_($_fld->title), 'type' => $_fld->type, 'required' => $_fld->required, 'hidden' => false, 'formcode' => '', 'description' => JText::_($_fld->description));
             $readonly = '';
             if (!$admin) {
                 if ($_fld->readonly) {
                     $readonly = ' readonly="readonly" ';
                 }
             }
             // 				vmdebug ('getUserFieldsFilled',$_fld->name);
             // 			if($_fld->name==='email') vmdebug('user data email getuserfieldbyuser',$_userData);
             // First, see if there are predefined fields by checking the name
             switch ($_fld->name) {
                 // 				case 'email':
                 // 					$_return['fields'][$_fld->name]['formcode'] = $_userData->email;
                 // 					break;
                 case 'virtuemart_country_id':
                     //For nice lists in the FE
                     /*	$app = JFactory::getApplication();
                     			if($app->isSite()) {
                     				$attrib = array('class'=>'chzn-select');
                     			} else {
                     				$attrib = array();
                     			}*/
                     $attrib = array();
                     $_return['fields'][$_fld->name]['formcode'] = ShopFunctions::renderCountryList($_return['fields'][$_fld->name]['value'], false, $attrib, $_prefix, $_fld->required);
                     if (!empty($_return['fields'][$_fld->name]['value'])) {
                         // Translate the value from ID to name
                         $db = JFactory::getDBO();
                         $q = 'SELECT * FROM `#__virtuemart_countries` WHERE virtuemart_country_id = "' . (int) $_return['fields'][$_fld->name]['value'] . '"';
                         $db->setQuery($q);
                         $r = $db->loadAssoc();
                         if ($r) {
                             $_return['fields'][$_fld->name]['value'] = !empty($r['country_name']) ? $r['country_name'] : '';
                             $_return['fields'][$_fld->name]['country_2_code'] = !empty($r['country_2_code']) ? $r['country_2_code'] : '';
                             $_return['fields'][$_fld->name]['country_3_code'] = !empty($r['country_3_code']) ? $r['country_3_code'] : '';
                         } else {
                             vmError('Model Userfields, country with id ' . $_return['fields'][$_fld->name]['value'] . ' not found');
                         }
                     } else {
                         $_return['fields'][$_fld->name]['value'] = '';
                         $_return['fields'][$_fld->name]['country_2_code'] = '';
                         $_return['fields'][$_fld->name]['country_3_code'] = '';
                     }
                     //$_return['fields'][$_fld->name]['value'] = JText::_(shopFunctions::getCountryByID($_return['fields'][$_fld->name]['value']));
                     //$_return['fields'][$_fld->name]['state_2_code'] = JText::_(shopFunctions::getCountryByID($_return['fields'][$_fld->name]['value']));
                     break;
                 case 'virtuemart_state_id':
                     if (!class_exists('shopFunctionsF')) {
                         require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
                     }
                     $_return['fields'][$_fld->name]['formcode'] = shopFunctions::renderStateList($_return['fields'][$_fld->name]['value'], $_prefix, false, $_fld->required);
                     if (!empty($_return['fields'][$_fld->name]['value'])) {
                         // Translate the value from ID to name
                         $db = JFactory::getDBO();
                         $q = 'SELECT * FROM `#__virtuemart_states` WHERE virtuemart_state_id = "' . (int) $_return['fields'][$_fld->name]['value'] . '"';
                         $db->setQuery($q);
                         $r = $db->loadAssoc();
                         if ($r) {
                             $_return['fields'][$_fld->name]['value'] = !empty($r['state_name']) ? $r['state_name'] : '';
                             $_return['fields'][$_fld->name]['state_2_code'] = !empty($r['state_2_code']) ? $r['state_2_code'] : '';
                             $_return['fields'][$_fld->name]['state_3_code'] = !empty($r['state_3_code']) ? $r['state_3_code'] : '';
                         } else {
                             vmError('Model Userfields, state with id ' . $_return['fields'][$_fld->name]['value'] . ' not found');
                         }
                     } else {
                         $_return['fields'][$_fld->name]['value'] = '';
                         $_return['fields'][$_fld->name]['state_2_code'] = '';
                         $_return['fields'][$_fld->name]['state_3_code'] = '';
                     }
                     //$_return['fields'][$_fld->name]['value'] = shopFunctions::getStateByID($_return['fields'][$_fld->name]['value']);
                     break;
                     //case 'agreed':
                     //	$_return['fields'][$_fld->name]['formcode'] = '<input type="checkbox" id="'.$_prefix.'agreed_field" name="'.$_prefix.'agreed" value="1" '
                     //		. ($_fld->required ? ' class="required"' : '') . ' />';
                     //	break;
                 //case 'agreed':
                 //	$_return['fields'][$_fld->name]['formcode'] = '<input type="checkbox" id="'.$_prefix.'agreed_field" name="'.$_prefix.'agreed" value="1" '
                 //		. ($_fld->required ? ' class="required"' : '') . ' />';
                 //	break;
                 case 'password':
                 case 'password2':
                     $_return['fields'][$_fld->name]['formcode'] = '<input type="password" id="' . $_prefix . $_fld->name . '_field" name="' . $_prefix . $_fld->name . '" size="30" class="inputbox" />' . "\n";
                     break;
                 case 'agreed':
                     $_return['fields'][$_fld->name]['formcode'] = '<input type="checkbox" name="' . $_prefix . $_fld->name . '" id="' . $_prefix . $_fld->name . '_field" value="1" ' . ($_return['fields'][$_fld->name]['value'] ? 'checked="checked"' : '') . '/>';
                     break;
                     // It's not a predefined field, so handle it by it's fieldtype
                 // It's not a predefined field, so handle it by it's fieldtype
                 default:
                     if (strpos($_fld->type, 'plugin') !== false) {
                         JPluginHelper::importPlugin('vmuserfield');
                         $dispatcher = JDispatcher::getInstance();
                         $dispatcher->trigger('plgVmOnUserfieldDisplay', array($_prefix, $_fld, isset($_userData['virtuemart_user_id']) ? $_userData['virtuemart_user_id'] : 0, &$_return));
                         break;
                     }
                     switch ($_fld->type) {
                         case 'hidden':
                             $_return['fields'][$_fld->name]['formcode'] = '<input type="hidden" id="' . $_prefix . $_fld->name . '_field" name="' . $_prefix . $_fld->name . '" size="' . $_fld->size . '" value="' . $_return['fields'][$_fld->name]['value'] . '" ' . ($_fld->required ? ' class="required"' : '') . ($_fld->maxlength ? ' maxlength="' . $_fld->maxlength . '"' : '') . $readonly . ' /> ';
                             $_return['fields'][$_fld->name]['hidden'] = true;
                             break;
                         case 'date':
                         case 'age_verification':
                             //echo JHTML::_('behavior.calendar');
                             /*
                              * TODO We must add the joomla.javascript here that contains the calendar,
                              * since Joomla does not load it when there's no user logged in.
                              * Gotta find out why... some security issue or a bug???
                              * Note by Oscar
                              */
                             // if ($_userData === null) { // Not logged in
                             // $_doc = JFactory::getDocument();
                             // $_doc->addScript( JURI::root(true).'/includes/js/joomla.javascript.js');
                             // }
                             $currentYear = date('Y');
                             //	$calendar = vmJsApi::jDate($_return['fields'][$_fld->name]['value'],  $_prefix.$_fld->name,  $_prefix.$_fld->name . '_field',false,($currentYear-100).':'.$currentYear);
                             //	$_return['fields'][$_fld->name]['formcode'] = $calendar ;
                             //if(empty($_return['fields'][$_fld->name]['value'])){
                             //	$_return['fields'][$_fld->name]['value'] = "1912-01-01 00:00:00";
                             //}                                                     jDate($date='',$name="date",$id=null,$resetBt = true, $yearRange='') {
                             // Year range MUST start 100 years ago, for birthday
                             $_return['fields'][$_fld->name]['formcode'] = vmJsApi::jDate($_return['fields'][$_fld->name]['value'], $_prefix . $_fld->name, $_prefix . $_fld->name . '_field', false, $currentYear - 100 . ':' . $currentYear);
                             break;
                         case 'emailaddress':
                             if (JFactory::getApplication()->isSite()) {
                                 if (empty($_return['fields'][$_fld->name]['value'])) {
                                     $_return['fields'][$_fld->name]['value'] = JFactory::getUser()->email;
                                 }
                             }
                             // 							vmdebug('emailaddress',$_fld);
                         // 							vmdebug('emailaddress',$_fld);
                         case 'text':
                         case 'webaddress':
                             $_return['fields'][$_fld->name]['formcode'] = '<input type="text" id="' . $_prefix . $_fld->name . '_field" name="' . $_prefix . $_fld->name . '" size="' . $_fld->size . '" value="' . $_return['fields'][$_fld->name]['value'] . '" ' . ($_fld->required ? ' class="required"' : '') . ($_fld->maxlength ? ' maxlength="' . $_fld->maxlength . '"' : '') . $readonly . ' /> ';
                             break;
                         case 'textarea':
                             $_return['fields'][$_fld->name]['formcode'] = '<textarea id="' . $_prefix . $_fld->name . '_field" name="' . $_prefix . $_fld->name . '" cols="' . $_fld->cols . '" rows="' . $_fld->rows . '" class="inputbox" ' . $readonly . '>' . $_return['fields'][$_fld->name]['value'] . '</textarea>';
                             break;
                         case 'editorta':
                             jimport('joomla.html.editor');
                             $editor = JFactory::getEditor();
                             $_return['fields'][$_fld->name]['formcode'] = $editor->display($_prefix . $_fld->name, $_return['fields'][$_fld->name]['value'], '150', '100', $_fld->cols, $_fld->rows, array('pagebreak', 'readmore'));
                             break;
                         case 'checkbox':
                             $_return['fields'][$_fld->name]['formcode'] = '<input type="checkbox" name="' . $_prefix . $_fld->name . '" id="' . $_prefix . $_fld->name . '_field" value="1" ' . ($_return['fields'][$_fld->name]['value'] ? 'checked="checked"' : '') . '/>';
                             if ($_return['fields'][$_fld->name]['value']) {
                                 $_return['fields'][$_fld->name]['value'] = JText::_($_prefix . $_fld->title);
                             }
                             break;
                             // /*##mygruz20120223193710 { :*/
                             // case 'userfieldplugin': //why not just vmuserfieldsplugin ?
                             // JPluginHelper::importPlugin('vmuserfield');
                             // $dispatcher = JDispatcher::getInstance();
                             // //Todo to adjust to new pattern, using &
                             // $html = '' ;
                             // $dispatcher->trigger('plgVmOnUserFieldDisplay',array($_return['fields'][$_fld->name], &$html) );
                             // $_return['fields'][$_fld->name]['formcode'] = $html;
                             // break;
                             // /*##mygruz20120223193710 } */
                         // /*##mygruz20120223193710 { :*/
                         // case 'userfieldplugin': //why not just vmuserfieldsplugin ?
                         // JPluginHelper::importPlugin('vmuserfield');
                         // $dispatcher = JDispatcher::getInstance();
                         // //Todo to adjust to new pattern, using &
                         // $html = '' ;
                         // $dispatcher->trigger('plgVmOnUserFieldDisplay',array($_return['fields'][$_fld->name], &$html) );
                         // $_return['fields'][$_fld->name]['formcode'] = $html;
                         // break;
                         // /*##mygruz20120223193710 } */
                         case 'multicheckbox':
                         case 'multiselect':
                         case 'select':
                         case 'radio':
                             $_qry = 'SELECT fieldtitle, fieldvalue ' . 'FROM #__virtuemart_userfield_values ' . 'WHERE virtuemart_userfield_id = ' . $_fld->virtuemart_userfield_id . ' ORDER BY ordering ';
                             $_values = $this->_getList($_qry);
                             // We need an extra lok here, especially for the Bank info; the values
                             // must be translated.
                             // Don't check on the field name though, since others might be added in the future :-(
                             foreach ($_values as $_v) {
                                 $_v->fieldtitle = JText::_($_v->fieldtitle);
                             }
                             $_attribs = array();
                             if ($_fld->readonly and !$admin) {
                                 $_attribs['readonly'] = 'readonly';
                             }
                             if ($_fld->required) {
                                 $_attribs['class'] = 'required';
                             }
                             if ($_fld->type == 'radio' or $_fld->type == 'select') {
                                 $_selected = $_return['fields'][$_fld->name]['value'];
                             } else {
                                 $_attribs['size'] = $_fld->size;
                                 // Use for all but radioselects
                                 if (!is_array($_return['fields'][$_fld->name]['value'])) {
                                     $_selected = explode("|*|", $_return['fields'][$_fld->name]['value']);
                                 } else {
                                     $_selected = $_return['fields'][$_fld->name]['value'];
                                 }
                             }
                             // Nested switch...
                             switch ($_fld->type) {
                                 case 'multicheckbox':
                                     // todo: use those
                                     $_attribs['rows'] = $_fld->rows;
                                     $_attribs['cols'] = $_fld->cols;
                                     $formcode = '';
                                     $field_values = "";
                                     $_idx = 0;
                                     $separator_form = '<br />';
                                     $separator_title = ',';
                                     foreach ($_values as $_val) {
                                         if (in_array($_val->fieldvalue, $_selected)) {
                                             $is_selected = 'checked="checked"';
                                             $field_values .= JText::_($_val->fieldtitle) . $separator_title;
                                         } else {
                                             $is_selected = '';
                                         }
                                         $formcode .= '<input type="checkbox" name="' . $_prefix . $_fld->name . '[]" id="' . $_prefix . $_fld->name . '_field' . $_idx . '" value="' . $_val->fieldvalue . '" ' . $is_selected . '/> <label for="' . $_prefix . $_fld->name . '_field' . $_idx . '">' . JText::_($_val->fieldtitle) . '</label>' . $separator_form;
                                         $_idx++;
                                     }
                                     // remove last br
                                     $_return['fields'][$_fld->name]['formcode'] = substr($formcode, 0, -strlen($separator_form));
                                     $_return['fields'][$_fld->name]['value'] = substr($field_values, 0, -strlen($separator_title));
                                     break;
                                 case 'multiselect':
                                     $_attribs['multiple'] = 'multiple';
                                     $_attribs['class'] = 'vm-chzn-select';
                                     $field_values = "";
                                     $_return['fields'][$_fld->name]['formcode'] = JHTML::_('select.genericlist', $_values, $_prefix . $_fld->name . '[]', $_attribs, 'fieldvalue', 'fieldtitle', $_selected);
                                     $separator_form = '<br />';
                                     $separator_title = ',';
                                     foreach ($_values as $_val) {
                                         if (in_array($_val->fieldvalue, $_selected)) {
                                             $field_values .= JText::_($_val->fieldtitle) . $separator_title;
                                         }
                                     }
                                     $_return['fields'][$_fld->name]['value'] = substr($field_values, 0, -strlen($separator_title));
                                     break;
                                 case 'select':
                                     $_attribs['class'] = 'vm-chzn-select';
                                     $_return['fields'][$_fld->name]['formcode'] = JHTML::_('select.genericlist', $_values, $_prefix . $_fld->name, $_attribs, 'fieldvalue', 'fieldtitle', $_selected);
                                     foreach ($_values as $_val) {
                                         if ($_val->fieldvalue == $_selected) {
                                             $_return['fields'][$_fld->name]['value'] = JText::_($_val->fieldtitle);
                                         }
                                     }
                                     break;
                                 case 'radio':
                                     $_return['fields'][$_fld->name]['formcode'] = JHTML::_('select.radiolist', $_values, $_prefix . $_fld->name, $_attribs, 'fieldvalue', 'fieldtitle', $_selected);
                                     foreach ($_values as $_val) {
                                         if ($_val->fieldvalue == $_selected) {
                                             $_return['fields'][$_fld->name]['value'] = JText::_($_val->fieldtitle);
                                         }
                                     }
                                     break;
                             }
                             break;
                     }
                     break;
             }
         }
     } else {
         vmdebug('getUserFieldsFilled $_selection is not an array ', $_selection);
         // 			$_return['fields'][$_fld->name]['formcode'] = '';
     }
     return $_return;
 }
Exemple #18
0
	/** Delete Invoice when an item is updated
	 *
	 * @author Valérie Isaksen
	 * @param $order_id Id of the order
	 * @return boolean true if deleted successful, false if there was a problem
	 */
	function deleteInvoice($order_id ) {
		$db = JFactory::getDBO();

		$q = 'SELECT * FROM `#__virtuemart_invoices` WHERE `virtuemart_order_id`= "'.$order_id.'" ';

		$db->setQuery($q);
		$data = $db->loadAssoc();
		if(!$data or   empty($data['invoice_number']) ){
			return true;
		}

		// rename invoice pdf file
		$invoice_prefix='vminvoice_';
		$path = shopFunctions::getInvoicePath(VmConfig::get('forSale_path',0));
		$invoice_name_src = $path.DS.$invoice_prefix.$data['invoice_number'].'.pdf';

		if(!file_exists($invoice_name_src)){
			// may be it was already deleted when changing order items
			$data['invoice_number'] = $data['invoice_number'].' not found.';
		} else {
			$date = date("Ymd");
			$data['invoice_number'] = $data['invoice_number'].'_'.$date;
			$invoice_name_dst = $path.DS.$data['invoice_number'].'.pdf';

			if(!class_exists('JFile')) require(VMPATH_LIBS.DS.'joomla'.DS.'filesystem'.DS.'file.php');
			if (!JFile::move($invoice_name_src, $invoice_name_dst)) {
				vmError ('Could not rename Invoice '.$invoice_name_src.'to '. $invoice_name_dst );
			}
		}

		$table = $this->getTable('invoices');
		$table->bindChecknStore($data);

		return true;
	}
Exemple #19
0
 function plgVmConfirmedOrder($cart, $order)
 {
     if (!($method = $this->getVmPluginMethod($order['details']['BT']->virtuemart_paymentmethod_id))) {
         return NULL;
         // Another method was selected, do nothing
     }
     if (!$this->selectedThisElement($method->payment_element)) {
         return FALSE;
     }
     $session = JFactory::getSession();
     $return_context = $session->getId();
     $this->_debug = $method->HEIDELPAY_DEBUG;
     if (!class_exists('VirtueMartModelOrders')) {
         require VMPATH_ADMIN . DS . 'models' . DS . 'orders.php';
     }
     if (!class_exists('VirtueMartModelCurrency')) {
         require VMPATH_ADMIN . DS . 'models' . DS . 'currency.php';
     }
     $address = isset($order['details']['BT']) ? $order['details']['BT'] : $order['details']['ST'];
     if (!class_exists('TableVendors')) {
         require VMPATH_ADMIN . DS . 'table' . DS . 'vendors.php';
     }
     $vendorModel = VmModel::getModel('Vendor');
     $vendorModel->setId(1);
     $vendor = $vendorModel->getVendor();
     $vendorModel->addImages($vendor, 1);
     $this->getPaymentCurrency($method);
     $currency_code_3 = shopFunctions::getCurrencyByID($method->payment_currency, 'currency_code_3');
     $paymentCurrency = CurrencyDisplay::getInstance($method->payment_currency);
     $totalInPaymentCurrency = round($paymentCurrency->convertCurrencyTo($method->payment_currency, $order['details']['BT']->order_total, FALSE), 2);
     $cd = CurrencyDisplay::getInstance($cart->pricesCurrency);
     // prepare the post var values:
     $languageTag = $this->getLang();
     $params = array();
     /*
      * Default configuration for hco
      */
     $params['FRONTEND.MODE'] = "DEFAULT";
     $params['FRONTEND.ENABLED'] = "true";
     $params['FRONTEND.POPUP'] = "false";
     $params['FRONTEND.REDIRECT_TIME'] = "0";
     $params['REQUEST.VERSION'] = "1.0";
     $params['FRONTEND.NEXTTARGET'] = "top.location.href";
     $params['PRESENTATION.AMOUNT'] = $totalInPaymentCurrency;
     $params['PRESENTATION.CURRENCY'] = $currency_code_3;
     $params['FRONTEND.LANGUAGE'] = $languageTag;
     $params['CRITERION.LANG'] = $params['FRONTEND.LANGUAGE'];
     $params['IDENTIFICATION.TRANSACTIONID'] = $order['details']['BT']->order_number;
     /*
      * Set payment methode to PA for online transfer, invoice and prepayment
      */
     $PaymentTypePA = array('OT', 'PP', 'IV');
     if (in_array(substr($method->HEIDELPAY_PAYMENT_TYPE, 0, 2), $PaymentTypePA)) {
         $method->HEIDELPAY_PAYMENT_METHOD = "PA";
     } else {
         $method->HEIDELPAY_PAYMENT_METHOD = $method->HEIDELPAY_PAYMENT_METHOD;
     }
     $params['PAYMENT.CODE'] = substr($method->HEIDELPAY_PAYMENT_TYPE, 0, 2) . "." . $method->HEIDELPAY_PAYMENT_METHOD;
     $params['TRANSACTION.CHANNEL'] = $method->HEIDELPAY_CHANNEL_ID;
     /*
      * Special case for paypal without hco iframe
      */
     if ($method->HEIDELPAY_PAYMENT_TYPE == "VAPAYPAL") {
         $params['PAYMENT.CODE'] = "VA.DB";
         $params['ACCOUNT.BRAND'] = "PAYPAL";
         $params['FRONTEND.PM.DEFAULT_DISABLE_ALL'] = "true";
         $params['FRONTEND.PM.0.ENABLED'] = "true";
         $params['FRONTEND.PM.0.METHOD'] = "VA";
         $params['FRONTEND.PM.0.SUBTYPES'] = "PAYPAL";
     }
     /*
      * Special case for MangirKart without hco iframe
      */
     if ($method->HEIDELPAY_PAYMENT_TYPE == "PCMANGIR") {
         $params['PAYMENT.CODE'] = "PC.PA";
         $params['ACCOUNT.BRAND'] = "MANGIRKART";
     }
     /*
      * case for GiroPay
      */
     if ($method->HEIDELPAY_PAYMENT_TYPE == "OTGIR") {
         $params['FRONTEND.SEPA'] = 'YES';
         $params['FRONTEND.SEPASWITCH'] = 'NO';
     }
     /*
      * Special case for BarPay without hco iframe
      */
     if ($method->HEIDELPAY_PAYMENT_TYPE == "PPBARPAY") {
         $params['PAYMENT.CODE'] = "PP.PA";
         $params['ACCOUNT.BRAND'] = "BARPAY";
     }
     /*
      * Special case for BillSAFE
      */
     if ($method->HEIDELPAY_PAYMENT_TYPE == "IVBILLSAFE") {
         $toCheck = array('last_name', 'first_name', 'middle_name', 'phone_1', 'phone_2', 'fax', 'address_1', 'address_2', 'city', 'virtuemart_state_id', 'virtuemart_country_id', 'zip');
         $bsError = false;
         foreach ($toCheck as $val) {
             if (isset($order['details']['ST']->{$val})) {
                 if ($order['details']['ST']->{$val} != $order['details']['BT']->{$val}) {
                     $bsError = true;
                     $errorVal = $val;
                     break;
                 }
             }
         }
         if ($bsError) {
             $msg = vmText::_('VMPAYMENT_HEIDELPAY_TECHNICAL_ERROR') . "<br />" . vmText::_('VMPAYMENT_HEIDELPAY_BILLSAFE_ERROR') . "<br />";
             $app = JFactory::getApplication();
             $app->redirect('index.php?option=com_virtuemart&view=cart', $msg);
         }
         $params['PAYMENT.CODE'] = "IV.PA";
         $params['ACCOUNT.BRAND'] = "BILLSAFE";
         $params = array_merge($params, $this->getBasketDetails());
     }
     /*
      *  User account information
      */
     $params['ACCOUNT.HOLDER'] = $address->first_name . " " . $address->last_name;
     $params['NAME.GIVEN'] = $address->first_name;
     $params['NAME.FAMILY'] = $address->last_name;
     if (!empty($address->company)) {
         $params['NAME.COMPANY'] = $address->company;
     }
     $params['ADDRESS.STREET'] = $address->address_1;
     isset($address->address_2) ? $params['ADDRESS.STREET'] .= " " . $address->address_2 : '';
     $params['ADDRESS.ZIP'] = $address->zip;
     $params['ADDRESS.CITY'] = $address->city;
     $params['ADDRESS.COUNTRY'] = ShopFunctions::getCountryByID($address->virtuemart_country_id, 'country_2_code');
     $params['CONTACT.EMAIL'] = $order['details']['BT']->email;
     $params['CONTACT.IP'] = $_SERVER['REMOTE_ADDR'];
     /*
      * Add debug informations for merchiant support
      */
     $params['SHOP.TYPE'] = 'VirtueMart ' . VmConfig::getInstalledVersion();
     $params['SHOPMODULE.VERSION'] = $this->version;
     $params['CRITERION.PAYMENT_NAME'] = vmText::_('VMPAYMENT_HEIDELPAY_' . $method->HEIDELPAY_PAYMENT_TYPE);
     $params['CRITERION.PAYMENT_NAME'] = strip_tags($params['CRITERION.PAYMENT_NAME']);
     /*
      * Create hash to secure the response
      */
     $params['CRITERION.SECRET'] = $this->createSecretHash($order['details']['BT']->order_number, $method->HEIDELPAY_SECRET);
     /*
      * Set transaction mode
      */
     if ($method->HEIDELPAY_TRANSACTION_MODE == 2) {
         $params['TRANSACTION.MODE'] = "LIVE";
     } elseif ($method->HEIDELPAY_TRANSACTION_MODE == 0) {
         $params['TRANSACTION.MODE'] = "INTEGRATOR_TEST";
     } else {
         $params['TRANSACTION.MODE'] = "CONNECTOR_TEST";
     }
     /*
      * Add response and css path
      */
     $params['FRONTEND.RESPONSE_URL'] = JROUTE::_(JURI::root(), $xhtml = true, $ssl = 0) . 'plugins/vmpayment/heidelpay/heidelpay/heidelpay_response.php?option=com_virtuemart&view=pluginresponse&task=pluginresponsereceived&on=' . urlencode($order['details']['BT']->order_number) . '&pm=' . $order['details']['BT']->virtuemart_paymentmethod_id;
     $cssFile = "heidelpay_default.css";
     if (!empty($method->HEIDELPAY_STYLE)) {
         $cssFile = $method->HEIDELPAY_STYLE;
     }
     $params['FRONTEND.CSS_PATH'] = JROUTE::_(JURI::root(), $xhtml = true, $ssl = 0) . 'plugins/vmpayment/heidelpay/heidelpay/' . $cssFile;
     $requestUrl = $method->HEIDELPAY_PAYMENT_URL;
     $params['SECURITY.SENDER'] = $method->HEIDELPAY_SECURITY_SENDER;
     $params['USER.LOGIN'] = $method->HEIDELPAY_USER_LOGIN;
     $params['USER.PWD'] = $method->HEIDELPAY_USER_PW;
     if (substr($method->HEIDELPAY_PAYMENT_TYPE, 0, 2) == 'DD') {
         $sepaform = array();
         $sepaform = $this->switchDirectDebitFrom($method->HEIDELPAY_SEPA_FORM);
         $params = array_merge($sepaform, $params);
     }
     /*
      * send request to payment server
      */
     $response = $this->doRequest($requestUrl, $params, $method->HEIDELPAY_DEBUG);
     if ($params['TRANSACTION.MODE'] != "LIVE") {
         vmInfo('VMPAYMENT_HEIDELPAY_PAYMENT_TESTMODE');
     }
     /*
      * On success show iframe or show error information for your customer
      */
     $returnValue = 0;
     if ($response['PROCESSING_RESULT'] == "ACK" || $response['POST_VALIDATION'] == "ACK") {
         $returnValue = 2;
         $html = $this->renderByLayout('displaypayment', array('response' => $response['FRONTEND_REDIRECT_URL']));
     } else {
         $html = vmText::_('VMPAYMENT_HEIDELPAY_TECHNICAL_ERROR') . " <br /> - " . addslashes($response['PROCESSING_RETURN']) . "<br />" . vmText::_('VMPAYMENT_HEIDELPAY_CONTACT_SHOPOWNER');
     }
     /*
      * Show debug information
      */
     if ($method->HEIDELPAY_DEBUG == 1) {
         vmDebug('HEIDELPAY plgVmConfirmedOrder', $params);
     }
     return $this->processConfirmedOrderPaymentResponse($returnValue, $cart, $order, $html, '', '');
 }
Exemple #20
0
 function _check_email_amount_currency($payments, $email, $paypal_data)
 {
     /*
      * TODO Not checking yet because config do not have primary email address
      * Primary email address of the payment recipient (that is, the merchant).
      * If the payment is sent to a non-primary email address on your PayPal account,
      * the receiver_email is still your primary email.
      */
     /*
     if ($payments[0]->payment_order_total==$email) {
     	return true;
     }
     */
     $currency_code_3 = shopFunctions::getCurrencyByID($payments[0]->payment_currency, 'currency_code_3');
     if ($payments[0]->payment_order_total == $paypal_data['mc_gross'] and $currency_code_3 == $paypal_data['mc_currency']) {
         return TRUE;
     }
     $mailsubject = "PayPal Transaction";
     $mailbody = "Hello,\n\t\tAn IPN notification was received with an invalid amount or currency\n\t\t----------------------------------\n\t\tIPN Notification content:\n\t\t";
     foreach ($paypal_data as $key => $value) {
         $mailbody .= $key . " = " . $value . "\n\n";
     }
     $this->sendEmailToVendorAndAdmins($mailsubject, $mailbody);
     return FALSE;
 }
 /**
  * Reimplementation of vmPaymentPlugin::plgVmOnConfirmedOrder()
  *
  * @link http://www.authorize.net/support/AIM_guide.pdf
  * Credit Cards Test Numbers
  * Visa Test Account           4007000000027
  * Amex Test Account           370000000000002
  * Master Card Test Account    6011000000000012
  * Discover Test Account       5424000000000015
  * @author Valerie Isaksen
  */
 function plgVmConfirmedOrder(VirtueMartCart $cart, $order)
 {
     if (!($this->_currentMethod = $this->getVmPluginMethod($order['details']['BT']->virtuemart_paymentmethod_id))) {
         return NULL;
         // Another method was selected, do nothing
     }
     if (!$this->selectedThisElement($this->_currentMethod->payment_element)) {
         return FALSE;
     }
     $this->setInConfirmOrder($cart);
     $usrBT = $order['details']['BT'];
     $usrST = isset($order['details']['ST']) ? $order['details']['ST'] : '';
     $session = JFactory::getSession();
     $return_context = $session->getId();
     $payment_currency_id = shopFunctions::getCurrencyIDByName(self::AUTHORIZE_DEFAULT_PAYMENT_CURRENCY);
     $totalInPaymentCurrency = vmPSPlugin::getAmountInCurrency($order['details']['BT']->order_total, $payment_currency_id);
     $cd = CurrencyDisplay::getInstance($cart->pricesCurrency);
     // Set up data
     $formdata = array();
     $formdata = array_merge($this->_setHeader(), $formdata);
     $formdata = array_merge($this->_setResponseConfiguration(), $formdata);
     $formdata = array_merge($this->_setBillingInformation($usrBT), $formdata);
     if (!empty($usrST)) {
         $formdata = array_merge($this->_setShippingInformation($usrST), $formdata);
     }
     $formdata = array_merge($this->_setTransactionData($order['details']['BT'], $totalInPaymentCurrency['value']), $formdata);
     $formdata = array_merge($this->_setMerchantData(), $formdata);
     // prepare the array to post
     $poststring = '';
     foreach ($formdata as $key => $val) {
         $poststring .= urlencode($key) . "=" . urlencode($val) . "&";
     }
     $poststring = rtrim($poststring, "& ");
     // Prepare data that should be stored in the database
     $dbValues['order_number'] = $order['details']['BT']->order_number;
     $dbValues['virtuemart_order_id'] = $order['details']['BT']->virtuemart_order_id;
     $dbValues['payment_method_id'] = $order['details']['BT']->virtuemart_paymentmethod_id;
     $dbValues['return_context'] = $return_context;
     $dbValues['payment_name'] = parent::renderPluginName($this->_currentMethod);
     $dbValues['cost_per_transaction'] = $this->_currentMethod->cost_per_transaction;
     $dbValues['cost_percent_total'] = $this->_currentMethod->cost_percent_total;
     $dbValues['payment_order_total'] = $totalInPaymentCurrency['value'];
     $dbValues['payment_currency'] = $payment_currency_id;
     $this->debugLog("before store", "plgVmConfirmedOrder", 'debug');
     $this->storePSPluginInternalData($dbValues);
     // send a request
     $response = $this->_sendRequest($poststring);
     $this->debugLog($response, "plgVmConfirmedOrder", 'debug');
     $authnet_values = array();
     // to check the values???
     // evaluate the response
     $html = $this->_handleResponse($response, $authnet_values, $order, $dbValues['payment_name']);
     if ($this->error) {
         $new_status = $this->_currentMethod->payment_declined_status;
         $this->_handlePaymentCancel($order['details']['BT']->virtuemart_order_id, $html);
         return;
         // will not process the order
     } else {
         if ($this->approved) {
             $this->_clearAuthorizeNetSession();
             $new_status = $this->_currentMethod->payment_approved_status;
         } else {
             if ($this->declined) {
                 vRequest::setVar('html', $html);
                 $new_status = $this->_currentMethod->payment_declined_status;
                 $this->_handlePaymentCancel($order['details']['BT']->virtuemart_order_id, $html);
                 return;
             } else {
                 if ($this->held) {
                     $this->_clearAuthorizeNetSession();
                     $new_status = $this->_currentMethod->payment_held_status;
                 }
             }
         }
     }
     $modelOrder = VmModel::getModel('orders');
     $order['order_status'] = $new_status;
     $order['customer_notified'] = 1;
     $order['comments'] = '';
     $modelOrder->updateStatusForOneOrder($order['details']['BT']->virtuemart_order_id, $order, TRUE);
     //We delete the old stuff
     $cart->emptyCart();
     vRequest::setVar('html', $html);
 }
Exemple #22
0
	function getPaypalPaymentCurrency ($getCurrency = FALSE) {

		vmPSPlugin::getPaymentCurrency($this->_method);
		$this->currency_code_3 = shopFunctions::getCurrencyByID($this->_method->payment_currency, 'currency_code_3');

	}
Exemple #23
0
 /**
  * Notifies the customer that the Order Status has been changed
  *
  * @author RolandD, Christopher Roussel, Valérie Isaksen, Max Milbers
  *
  */
 private function notifyCustomer($virtuemart_order_id, $newOrderData = 0)
 {
     // 		vmdebug('notifyCustomer', $newOrderData);
     if (isset($newOrderData['customer_notified']) && $newOrderData['customer_notified'] == 0) {
         return true;
     }
     if (!class_exists('shopFunctionsF')) {
         require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
     }
     //Important, the data of the order update mails, payments and invoice should
     //always be in the database, so using getOrder is the right method
     $orderModel = VmModel::getModel('orders');
     $order = $orderModel->getOrder($virtuemart_order_id);
     $payment_name = $shipment_name = '';
     if (!class_exists('vmPSPlugin')) {
         require JPATH_VM_PLUGINS . DS . 'vmpsplugin.php';
     }
     JPluginHelper::importPlugin('vmshipment');
     JPluginHelper::importPlugin('vmpayment');
     $dispatcher = JDispatcher::getInstance();
     $returnValues = $dispatcher->trigger('plgVmOnShowOrderFEShipment', array($order['details']['BT']->virtuemart_order_id, $order['details']['BT']->virtuemart_shipmentmethod_id, &$shipment_name));
     $returnValues = $dispatcher->trigger('plgVmOnShowOrderFEPayment', array($order['details']['BT']->virtuemart_order_id, $order['details']['BT']->virtuemart_paymentmethod_id, &$payment_name));
     $order['shipmentName'] = $shipment_name;
     $order['paymentName'] = $payment_name;
     if ($newOrderData != 0) {
         //We do not really need that
         $vars['newOrderData'] = (array) $newOrderData;
     }
     $vars['orderDetails'] = $order;
     //$vars['includeComments'] = JRequest::getVar('customer_notified', array());
     //I think this is misleading, I think it should always ask for example $vars['newOrderData']['doVendor'] directly
     //Using this function garantue us that it is always there. If the vendor should be informed should be done by the plugins
     //We may add later something to the method, defining this better
     $vars['url'] = 'url';
     if (!isset($vars['doVendor'])) {
         if (!isset($newOrderData['doVendor'])) {
             $vars['doVendor'] = false;
         } else {
             $vars['doVendor'] = $newOrderData['doVendor'];
         }
     }
     $virtuemart_vendor_id = 1;
     $vendorModel = VmModel::getModel('vendor');
     $vendor = $vendorModel->getVendor($virtuemart_vendor_id);
     $vars['vendor'] = $vendor;
     $vendorEmail = $vendorModel->getVendorEmail($virtuemart_vendor_id);
     $vars['vendorEmail'] = $vendorEmail;
     /*
     		$path = VmConfig::get('forSale_path',0);
     		$orderstatusForInvoice = VmConfig::get('inv_os','C');
     		$pdfInvoice = VmConfig::get('pdf_invoice', 1); // backwards compatible
     */
     // florian : added if pdf invoice are enabled
     //if  ($this->getInvoiceNumber( $order['details']['BT']->virtuemart_order_id ) ){
     $invoiceNumberDate = array();
     if ($orderModel->createInvoiceNumber($order['details']['BT'], $invoiceNumberDate)) {
         $orderstatusForInvoice = VmConfig::get('inv_os', array());
         if (!is_array($orderstatusForInvoice)) {
             $orderstatusForInvoice = array($orderstatusForInvoice);
         }
         // for backward compatibility 2.0.8e
         $pdfInvoice = (int) VmConfig::get('pdf_invoice', 0);
         // backwards compatible
         $force_create_invoice = JRequest::getInt('create_invoice', 0);
         //TODO we need an array of orderstatus
         if (in_array($order['details']['BT']->order_status, $orderstatusForInvoice) or $pdfInvoice == 1 or $force_create_invoice == 1) {
             if (!shopFunctions::InvoiceNumberReserved($invoiceNumberDate[0])) {
                 if (!class_exists('VirtueMartControllerInvoice')) {
                     require_once JPATH_VM_SITE . DS . 'controllers' . DS . 'invoice.php';
                 }
                 $controller = new VirtueMartControllerInvoice(array('model_path' => JPATH_VM_SITE . DS . 'models', 'view_path' => JPATH_VM_SITE . DS . 'views'));
                 $vars['mediaToSend'][] = $controller->checkStoreInvoice($order);
             }
         }
     }
     // Send the email
     if (shopFunctionsF::renderMail('invoice', $order['details']['BT']->email, $vars, null, $vars['doVendor'])) {
         $string = 'COM_VIRTUEMART_NOTIFY_CUSTOMER_SEND_MSG';
     } else {
         $string = 'COM_VIRTUEMART_NOTIFY_CUSTOMER_ERR_SEND';
     }
     vmInfo(JText::_($string, false) . ' ' . $order['details']['BT']->first_name . ' ' . $order['details']['BT']->last_name . ', ' . $order['details']['BT']->email);
     return true;
 }
Exemple #24
0
 function sentProductEmailToShoppers()
 {
     jimport('joomla.utilities.arrayhelper');
     if (!class_exists('ShopFunctions')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'shopfunctions.php';
     }
     $product_id = JRequest::getVar('virtuemart_product_id', '');
     vmdebug('sentProductEmailToShoppers product id', $product_id);
     $vars = array();
     $vars['subject'] = JRequest::getVar('subject');
     $vars['mailbody'] = JRequest::getVar('mailbody');
     $order_states = JRequest::getVar('statut', array(), '', 'ARRAY');
     $productShoppers = $this->getProductShoppersByStatus($product_id, $order_states);
     vmdebug('productShoppers ', $productShoppers);
     $productModel = VmModel::getModel('product');
     $product = $productModel->getProduct($product_id);
     $vendorModel = VmModel::getModel('vendor');
     $vendor = $vendorModel->getVendor($product->virtuemart_vendor_id);
     $vendorModel->addImages($vendor);
     $vars['vendor'] = $vendor;
     $vars['vendorEmail'] = $vendorModel->getVendorEmail($product->virtuemart_vendor_id);
     $vars['vendorAddress'] = shopFunctions::renderVendorAddress($product->virtuemart_vendor_id);
     $orderModel = VmModel::getModel('orders');
     foreach ($productShoppers as $productShopper) {
         $vars['user'] = $productShopper['name'];
         if (shopFunctionsF::renderMail('productdetails', $productShopper['email'], $vars, 'productdetails', TRUE)) {
             $string = 'COM_VIRTUEMART_MAIL_SEND_SUCCESSFULLY';
         } else {
             $string = 'COM_VIRTUEMART_MAIL_NOT_SEND_SUCCESSFULLY';
         }
         /* Update the order history  for each order */
         foreach ($productShopper['order_info'] as $order_info) {
             $orderModel->_updateOrderHist($order_info['order_id'], $order_info['order_status'], 1, $vars['subject'] . ' ' . $vars['mailbody']);
         }
         // todo: when there is an error while sending emails
         //vmInfo (JText::sprintf ($string, $productShopper['email']));
     }
 }
 /**
  * @param $virtuemart_order_id
  * @param $payment_method_id
  * @return null|string
  */
 function plgVmOnShowOrderBEPayment($virtuemart_order_id, $payment_method_id)
 {
     if (!$this->selectedThisByMethodId($payment_method_id)) {
         return NULL;
         // Another method was selected, do nothing
     }
     if (!($this->_currentMethod = $this->getVmPluginMethod($payment_method_id))) {
         return NULL;
         // Another method was selected, do nothing
     }
     if (!($payments = $this->getDatasByOrderId($virtuemart_order_id))) {
         // JError::raiseWarning(500, $db->getErrorMsg());
         return '';
     }
     $this->initKlarnaParams();
     $html = '<table class="adminlist table"  >' . "\n";
     $html .= $this->getHtmlHeaderBE();
     $first = TRUE;
     $code = "klarna";
     $prefix = "KLARNACHECKOUT_";
     foreach ($payments as $key => $payment) {
         $html .= '<tr class="row1"><td><strong>' . JText::_('VMPAYMENT_KLARNACHECKOUT_DATE') . '</strong></td><td align="left"><strong>' . $payment->created_on . '</strong></td></tr>';
         // Now only the first entry has this data when creating the order
         if ($first) {
             $html .= $this->getHtmlRowBE('KLARNACHECKOUT_PAYMENT_NAME', $payment->payment_name);
             // keep that test to have it backwards compatible. Old version was deleting that column  when receiving an IPN notification
             if ($payment->payment_order_total and $payment->payment_order_total != 0.0) {
                 $html .= $this->getHtmlRowBE('KLARNACHECKOUT_PAYMENT_ORDER_TOTAL', $payment->payment_order_total . " " . shopFunctions::getCurrencyByID($payment->payment_currency, 'currency_code_3'));
             }
             if (!empty($payment->email_currency) and $payment->email_currency != 0) {
                 $html .= $this->getHtmlRowBE('KLARNACHECKOUT_PAYMENT_EMAIL_CURRENCY', shopFunctions::getCurrencyByID($payment->email_currency, 'currency_code_3'));
             }
             $first = FALSE;
         }
         // TODO go though the SQL table to have the fields in the correct order
         foreach ($payment as $key => $value) {
             // only displays if there is a value or the value is different from 0.00 and the value
             if ($value) {
                 if (substr($key, 0, strlen($code)) == $code) {
                     $html .= $this->getHtmlRowBE($prefix . $key, $value);
                 }
             }
         }
         if ($payment->action == 'activate') {
             $vm_invoice_name = '';
             $data = json_decode($payment->data);
             $invoice_number = $data[1];
             $klarnaCheckoutInterface = $this->_loadKlarnaCheckoutInterface();
             $invoiceURL = $klarnaCheckoutInterface->getInvoice($invoice_number, $vm_invoice_name);
             $html .= $this->getHtmlRowBE(vmText::_('VMPAYMENT_KLARNACHECKOUT_INVOICE_NUMBER'), $invoice_number);
             //$invoicePdfLink = $klarnaCheckoutInterface->getInvoicePdfLink($payment->virtuemart_order_id);
             $value = '<a target="_blank" href="' . $invoiceURL . '">' . vmText::_('VMPAYMENT_KLARNACHECKOUT_VIEW_INVOICE') . '</a>';
             $html .= $this->getHtmlRowBE("", $value);
         }
         if ($this->_currentMethod->debug) {
             $html .= $this->getTransactionLogContent($payment);
         }
     }
     $html .= '</table>' . "\n";
     if ($this->_currentMethod->debug) {
         $doc = JFactory::getDocument();
         $js = "\njQuery().ready(function(\$) {\n\t\$('.kcoLogOpener').click(function() {\n\t\tvar logId = \$(this).attr('rel');\n\t\t\$('#kcoLog_'+logId).toggle();\n\t\treturn false;\n\t});\n\t\$('.kcoDetailsOpener').click(function() {\n\t\tvar detailsId = \$(this).attr('rel');\n\t\t\$('#kcoDetails_'+detailsId).toggle();\n\t\treturn false;\n\t});\n});";
         $doc->addScriptDeclaration($js);
     }
     return $html;
 }
Exemple #26
0
    /**
     * @param $virtuemart_order_id
     * @return string
     */
    function showOrderBEPayment($virtuemart_order_id)
    {
        $db = JFactory::getDBO();
        $q = 'SELECT * FROM `' . $this->plugin->getTablename() . '` WHERE ';
        $q .= ' `virtuemart_order_id` = ' . $virtuemart_order_id;
        $db->setQuery($q);
        $payments = $db->loadObjectList();
        $html = '<table class="adminlist table">' . "\n";
        $html .= $this->plugin->getHtmlHeaderBE();
        $first = TRUE;
        $lang = JFactory::getLanguage();
        foreach ($payments as $payment) {
            $html .= '<tr class="row1"><td>' . tsmText::_('VMPAYMENT_' . $this->plugin_name . '_DATE') . '</td><td align="left">' . $payment->created_on . '</td></tr>';
            // Now only the first entry has this data when creating the order
            if ($first) {
                $html .= $this->plugin->getHtmlRowBE($this->plugin_name . '_PAYMENT_NAME', $payment->payment_name);
                // keep that test to have it backwards compatible. Old version was deleting that column  when receiving an IPN notification
                if ($payment->payment_order_total and $payment->payment_order_total != 0.0) {
                    $html .= $this->plugin->getHtmlRowBE($this->plugin_name . '_PAYMENT_ORDER_TOTAL', $payment->payment_order_total * 0.01 . " " . shopFunctions::getCurrencyByID($payment->payment_currency, 'currency_code_3'));
                }
                if ($payment->email_currency and $payment->email_currency != 0) {
                    //$html .= $this->getHtmlRowBE($this->_name.'_PAYMENT_EMAIL_CURRENCY', shopFunctions::getCurrencyByID($payment->email_currency, 'currency_code_3'));
                }
                if ($payment->recurring) {
                    $recurring_html = '<table class="adminlist table">' . "\n";
                    $recurring = json_decode($payment->recurring);
                    $recurring_html .= $this->plugin->getHtmlRowBE($this->plugin_name . '_CONF_RECURRING_PERIODICTY', $payment->recurring_periodicity);
                    $recurring_html .= $this->plugin->getHtmlRowBE($this->plugin_name . '_CONF_RECURRING_NUMBER', $payment->recurring_number);
                    //$recurring_html .= $this->getHtmlRowBE(VmText::_('VMPAYMENT_'.$this->_name.'_CONF_RECURRING_PERIODICTY').' '. $payment->recurring_periodicity, VmText::_('VMPAYMENT_'.$this->_name.'_CONF_RECURRING_NUMBER').' '. $payment->recurring_number);
                    for ($i = 1; $i < $payment->recurring_number; $i++) {
                        $index_mont = "PBX_2MONT" . $i;
                        $index_date = "PBX_DATE" . $i;
                        $text_mont = tsmText::_('VMPAYMENT_' . $this->plugin_name . '_PAYMENT_RECURRING_2MONT') . " " . $i;
                        $text_date = tsmText::_('VMPAYMENT_' . $this->plugin_name . '_PAYMENT_RECURRING_DATE') . " " . $i;
                        //$recurring_html .= $this->getHtmlRowBE($text_date, $recurring->$index_date);
                        //$recurring_html .= $this->getHtmlRowBE($text_mont, ($recurring->$index_mont * 0.01) . " " . shopFunctions::getCurrencyByID($payment->payment_currency, 'currency_code_3'));
                        $recurring_html .= $this->plugin->getHtmlRowBE($recurring->{$index_date}, $recurring->{$index_mont} * 0.01 . " " . shopFunctions::getCurrencyByID($payment->payment_currency, 'currency_code_3'));
                    }
                    $recurring_html .= '</table>' . "\n";
                    $html .= $this->plugin->getHtmlRowBE($this->plugin_name . '_RECURRING', $recurring_html);
                }
                $first = FALSE;
            } else {
                if (!empty($payment->paybox_fullresponse)) {
                    $paybox_data = json_decode($payment->paybox_fullresponse);
                    $showOrderBEFields = $this->getOrderBEFields();
                    $prefix = $this->plugin_name . '_RESPONSE_';
                    foreach ($showOrderBEFields as $showOrderBEField) {
                        if (isset($paybox_data->{$showOrderBEField}) and !empty($paybox_data->{$showOrderBEField})) {
                            $key = $prefix . $showOrderBEField;
                            if (method_exists($this, 'getValueBE_' . $showOrderBEField)) {
                                $function = 'getValueBE_' . $showOrderBEField;
                                $paybox_data->{$showOrderBEField} = $this->{$function}($paybox_data->{$showOrderBEField});
                            }
                            $html .= $this->plugin->getHtmlRowBE($key, $paybox_data->{$showOrderBEField});
                        }
                    }
                    $html .= '<tr><td></td><td>
<a href="#" class="PayboxLogOpener" rel="' . $payment->id . '" >
	<div style="background-color: white; z-index: 100; right:0; display: none; border:solid 2px; padding:10px;" class="vm-absolute" id="PayboxLog_' . $payment->id . '">';
                    foreach ($paybox_data as $key => $value) {
                        $langKey = 'VMPAYMENT_' . $prefix . $key;
                        if ($lang->hasKey($langKey)) {
                            $label = tsmText::_($langKey);
                        } else {
                            $label = $key;
                        }
                        $html .= ' <b>' . $label . '</b>:&nbsp;' . wordwrap($value, 50, "\n", true) . '<br />';
                    }
                    $html .= ' </div>
	<span class="icon-nofloat vmicon vmicon-16-xml"></span>&nbsp;';
                    $html .= tsmText::_('VMPAYMENT_' . $this->plugin_name . '_VIEW_TRANSACTION_LOG');
                    $html .= '  </a>';
                    $html .= ' </td></tr>';
                }
            }
        }
        $html .= '</table>' . "\n";
        $doc = JFactory::getDocument();
        $js = "\njQuery().ready(function(\$) {\n\t\$('.PayboxLogOpener').click(function() {\n\t\tvar logId = \$(this).attr('rel');\n\t\t\$('#PayboxLog_'+logId).toggle();\n\t\treturn false;\n\t});\n});";
        $doc->addScriptDeclaration($js);
        return $html;
    }
Exemple #27
0
 /**
  * Notify customers product is back in stock
  *
  * @author RolandD
  * @author Christopher Rouseel
  * @todo Add Itemid
  * @todo Do something if the mail cannot be send
  * @todo Update mail from
  * @todo Get the from name/email from the vendor
  */
 public function notifyList($virtuemart_product_id, $subject = '', $mailbody = '', $max_number = 0)
 {
     if (!$virtuemart_product_id) {
         return FALSE;
     }
     //sanitize id
     $virtuemart_product_id = (int) $virtuemart_product_id;
     $max_number = (int) $max_number;
     if (!class_exists('shopFunctionsF')) {
         require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
     }
     $vars = array();
     $waitinglistModel = VmModel::getModel('waitinglist');
     $waiting_users = $waitinglistModel->getWaitingusers($virtuemart_product_id);
     /* Load the product details */
     $db = JFactory::getDbo();
     $q = "SELECT l.product_name,product_in_stock FROM `#__virtuemart_products_" . VMLANG . "` l\r\n\t\t\t\tJOIN `#__virtuemart_products` p ON p.virtuemart_product_id=l.virtuemart_product_id\r\n\t\t\t   WHERE p.virtuemart_product_id = " . $virtuemart_product_id;
     $db->setQuery($q);
     $item = $db->loadObject();
     $vars['productName'] = $item->product_name;
     /*
     if ($item->product_in_stock <= 0) {
     	return FALSE;
     }
     */
     $url = JURI::root() . 'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $virtuemart_product_id;
     $vars['link'] = '<a href="' . $url . '">' . $item->product_name . '</a>';
     if (empty($subject)) {
         $subject = JText::sprintf('COM_VIRTUEMART_PRODUCT_WAITING_LIST_EMAIL_SUBJECT', $item->product_name);
     }
     $vars['subject'] = $subject;
     $vars['mailbody'] = $mailbody;
     $virtuemart_vendor_id = 1;
     $vendorModel = VmModel::getModel('vendor');
     $vendor = $vendorModel->getVendor($virtuemart_vendor_id);
     $vendorModel->addImages($vendor);
     $vars['vendor'] = $vendor;
     $vars['vendorAddress'] = shopFunctions::renderVendorAddress($virtuemart_vendor_id);
     $vendorEmail = $vendorModel->getVendorEmail($virtuemart_vendor_id);
     $vars['vendorEmail'] = $vendorEmail;
     $i = 0;
     foreach ($waiting_users as $waiting_user) {
         $vars['user'] = $waiting_user->name;
         if (shopFunctionsF::renderMail('productdetails', $waiting_user->notify_email, $vars, 'productdetails')) {
             $db->setQuery('UPDATE #__virtuemart_waitingusers SET notified=1 WHERE virtuemart_waitinguser_id=' . $waiting_user->virtuemart_waitinguser_id);
             $db->query();
             $i++;
         }
         if (!empty($max_number) && $i >= $max_number) {
             break;
         }
     }
     return TRUE;
 }
Exemple #28
0
 /** Delete Invoice when an item is updated
  *
  * @author Valérie Isaksen
  * @param $order_id Id of the order
  * @return boolean true if deleted successful, false if there was a problem
  */
 function deleteInvoice($order_id)
 {
     $db = JFactory::getDBO();
     $q = 'SELECT * FROM `#__virtuemart_invoices` WHERE `virtuemart_order_id`= "' . $order_id . '" ';
     $db->setQuery($q);
     $data = $db->loadAssoc();
     if (!$data or empty($data['invoice_number'])) {
         return true;
     }
     // rename invoice pdf file
     $invoice_prefix = 'vminvoice_';
     $path = shopFunctions::getInvoicePath(VmConfig::get('forSale_path', 0));
     $invoice_name_src = $path . DS . $invoice_prefix . $data['invoice_number'] . '.pdf';
     if (!file_exists($invoice_name_src)) {
         // was already deleted by a previoous change
         return;
     }
     if (!class_exists('JFile')) {
         require JPATH_VM_LIBRARIES . DS . 'joomla' . DS . 'filesystem' . DS . 'file.php';
     }
     if (!JFile::delete($invoice_name_src)) {
         vmError('Could not delete Invoice ' . $invoice_name_src);
     }
 }
 private function showActionOrderBEPayment($virtuemart_order_id, $virtuemart_paymentmethod_id, $payments)
 {
     $orderModel = VmModel::getModel('orders');
     $order = $orderModel->getOrder($virtuemart_order_id);
     $options = array();
     if ($this->isDelayedSettlement()) {
         $options[] = JHTML::_('select.option', 'settlePayment', vmText::_('VMPAYMENT_REALEX_HPP_API_ORDER_BE_CAPTURE'), 'value', 'text');
     }
     $options[] = JHTML::_('select.option', 'rebatePayment', vmText::_('VMPAYMENT_REALEX_HPP_API_ORDER_BE_REBATE'), 'value', 'text');
     $actionList = JHTML::_('select.genericlist', $options, 'action', '', 'value', 'text', 'capturePayment', 'action', true);
     $html = '<table class="adminlist table"  >' . "\n";
     $html .= $this->getHtmlHeaderBE();
     $html .= '<form action="index.php" method="post" name="updateOrderBEPayment" id="updateOrderBEPayment">';
     $html .= '<tr ><td >';
     $html .= $actionList;
     $html .= ' </td><td>';
     $html .= '<input type="text" id="amount" name="amount" size="20" value="" class="required" maxlength="25"  placeholder="' . vmText::sprintf('VMPAYMENT_REALEX_HPP_API_ORDER_BE_AMOUNT', shopFunctions::getCurrencyByID($payments[0]->payment_currency, 'currency_code_3')) . '"/>';
     $html .= '<input type="hidden" name="type" value="vmpayment"/>';
     $html .= '<input type="hidden" name="name" value="realex_hpp_api"/>';
     $html .= '<input type="hidden" name="view" value="plugin"/>';
     $html .= '<input type="hidden" name="option" value="com_virtuemart"/>';
     $html .= '<input type="hidden" name="virtuemart_order_id" value="' . $virtuemart_order_id . '"/>';
     $html .= '<input type="hidden" name="virtuemart_paymentmethod_id" value="' . $virtuemart_paymentmethod_id . '"/>';
     $html .= '<a class="updateOrderBEPayment btn btn-small" href="#"   >' . vmText::_('COM_VIRTUEMART_SAVE') . '</a>';
     $html .= '</form>';
     $html .= ' </td></tr>';
     vmJsApi::addJScript('vmRealex.updateOrderBEPayment', "\n\t\tjQuery(document).ready( function(\$) {\n\t\t\tjQuery('.updateOrderBEPayment').click(function() {\n\t\t\t\tdocument.updateOrderBEPayment.submit();\n\t\t\t\treturn false;\n\n\t});\n});\n");
     //$html .= '</table>'  ;
     return $html;
 }
Exemple #30
0
 /**
  * Return an array with userFields in several formats.
  *
  * @access public
  * @param $_selection An array, as returned by getuserFields(), with fields that should be returned.
  * @param $_userData Array with userdata holding the values for the fields
  * @param $_prefix string Optional prefix for the formtag name attribute
  * @author Oscar van Eijk
  * @return array List with all userfield data in the format:
  * array(
  *    'fields' => array(   // All fields
  *                   <fieldname> => array(
  *                                     'name' =>       // Name of the field
  *                                     'value' =>      // Existing value for the current user, or the default
  *                                     'title' =>      // Title used for label and such
  *                                     'type' =>       // Field type as specified in the userfields table
  *                                     'hidden' =>     // True/False
  *                                     'required' =>   // True/False. If True, the formcode also has the class "required" for the Joomla formvalidator
  *                                     'formcode' =>   // Full HTML tag
  *                                  )
  *                   [...]
  *                )
  *    'functions' => array() // Optional javascript functions without <script> tags.
  *                           // Possible usage: if (count($ar('functions')>0) echo '<script ...>'.join("\n", $ar('functions')).'</script>;
  *    'scripts'   => array(  // Array with scriptsources for use with JHTML::script();
  *                      <name> => <path>
  *                      [...]
  *                   )
  *    'links'     => array(  // Array with stylesheets for use with JHTML::stylesheet();
  *                      <name> => <path>
  *                      [...]
  *                   )
  * )
  * @example This example illustrates the use of this function. For additional examples, see the Order view
  * and the User view in the administrator section.
  * <pre>
  *   // In the controller, make sure this model is loaded.
  *   // In view.html.php, make the following calls:
  *   $_usrDetails = getUserDetailsFromSomeModel(); // retrieve an user_info record, eg from the usermodel or ordermodel
  *   $_usrFieldList = $userFieldsModel->getUserFields(
  *                    'registration'
  *                  , array() // Default switches
  *                  , array('delimiter_userinfo', 'username', 'email', 'password', 'password2', 'agreed', 'address_type') // Skips
  *    );
  *   $usrFieldValues = $userFieldsModel->getUserFieldsFilled(
  *                      $_usrFieldList
  *                     ,$_usrDetails
  *   );
  *   $this->assignRef('userfields', $userfields);
  *   // In the template, use code below to display the data. For an extended example using
  *   // delimiters, JavaScripts and StyleSheets, see the edit_shopper.php in the user view
  *   <table class="admintable" width="100%">
  *     <thead>
  *       <tr>
  *         <td class="key" style="text-align: center;"  colspan="2">
  *            <?php echo JText::_('COM_VIRTUEMART_TABLE_HEADER') ?>
  *         </td>
  *       </tr>
  *     </thead>
  *      <?php
  *        foreach ($this->shipmentfields['fields'] as $_field ) {
  *          echo '  <tr>'."\n";
  *          echo '    <td class="key">'."\n";
  *          echo '      '.$_field['title']."\n";
  *          echo '    </td>'."\n";
  *          echo '    <td>'."\n";
  *
  *          echo '      '.$_field['value']."\n";    // Display only
  *       Or:
  *          echo '      '.$_field['formcode']."\n"; // Input form
  *
  *          echo '    </td>'."\n";
  *          echo '  </tr>'."\n";
  *        }
  *      ?>
  *    </table>
  * </pre>
  */
 public function getUserFieldsFilled($_selection, $_userData = null, $_prefix = '')
 {
     if (!class_exists('ShopFunctions')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'shopfunctions.php';
     }
     $_return = array('fields' => array(), 'functions' => array(), 'scripts' => array(), 'links' => array());
     // 		vmdebug('my user data in getUserFieldsFilled',$_selection,$_userData);
     $_userData = (array) $_userData;
     if (is_array($_selection)) {
         foreach ($_selection as $_fld) {
             $_return['fields'][$_fld->name] = array('name' => $_prefix . $_fld->name, 'value' => $_userData == null || !array_key_exists($_fld->name, $_userData) ? $_fld->default : @$_userData[$_fld->name], 'title' => JText::_($_fld->title), 'type' => $_fld->type, 'required' => $_fld->required, 'hidden' => false, 'formcode' => '');
             // 				vmdebug ('getUserFieldsFilled',$_fld->name);
             // 			if($_fld->name==='email') vmdebug('user data email getuserfieldbyuser',$_userData);
             // First, see if there are predefined fields by checking the name
             switch ($_fld->name) {
                 // 				case 'email':
                 // 					$_return['fields'][$_fld->name]['formcode'] = $_userData->email;
                 // 					break;
                 case 'virtuemart_country_id':
                     $_return['fields'][$_fld->name]['formcode'] = ShopFunctions::renderCountryList($_return['fields'][$_fld->name]['value'], false, array(), $_prefix, $_fld->required);
                     // Translate the value from ID to name
                     $_return['fields'][$_fld->name]['value'] = shopFunctions::getCountryByID($_return['fields'][$_fld->name]['value']);
                     break;
                 case 'virtuemart_state_id':
                     $_return['fields'][$_fld->name]['formcode'] = shopFunctions::renderStateList($_return['fields'][$_fld->name]['value'], $_prefix, false, $_fld->required);
                     $_return['fields'][$_fld->name]['value'] = shopFunctions::getStateByID($_return['fields'][$_fld->name]['value']);
                     break;
                     //case 'agreed':
                     //	$_return['fields'][$_fld->name]['formcode'] = '<input type="checkbox" id="'.$_prefix.'agreed_field" name="'.$_prefix.'agreed" value="1" '
                     //		. ($_fld->required ? ' class="required"' : '') . ' />';
                     //	break;
                 //case 'agreed':
                 //	$_return['fields'][$_fld->name]['formcode'] = '<input type="checkbox" id="'.$_prefix.'agreed_field" name="'.$_prefix.'agreed" value="1" '
                 //		. ($_fld->required ? ' class="required"' : '') . ' />';
                 //	break;
                 case 'password':
                 case 'password2':
                     $_return['fields'][$_fld->name]['formcode'] = '<input type="password" id="' . $_prefix . $_fld->name . '_field" name="' . $_prefix . $_fld->name . '" size="30" class="inputbox" />' . "\n";
                     break;
                 case 'agreed':
                     $_return['fields'][$_fld->name]['formcode'] = '<input type="checkbox" name="' . $_prefix . $_fld->name . '" id="' . $_prefix . $_fld->name . '_field" value="1" ' . ($_return['fields'][$_fld->name]['value'] ? 'checked="checked"' : '') . '/>';
                     break;
                     // It's not a predefined field, so handle it by it's fieldtype
                 // It's not a predefined field, so handle it by it's fieldtype
                 default:
                     if (strpos($_fld->type, 'plugin') !== false) {
                         JPluginHelper::importPlugin('vmuserfield');
                         $dispatcher = JDispatcher::getInstance();
                         $dispatcher->trigger('plgVmOnUserfieldDisplay', array($_prefix, $_fld, &$_return));
                         break;
                     }
                     switch ($_fld->type) {
                         case 'hidden':
                             $_return['fields'][$_fld->name]['formcode'] = '<input type="hidden" id="' . $_prefix . $_fld->name . '_field" name="' . $_prefix . $_fld->name . '" size="' . $_fld->size . '" value="' . $_return['fields'][$_fld->name]['value'] . '" ' . ($_fld->required ? ' class="required"' : '') . ($_fld->maxlength ? ' maxlength="' . $_fld->maxlength . '"' : '') . ($_fld->readonly ? ' readonly="readonly"' : '') . ' /> ';
                             $_return['fields'][$_fld->name]['hidden'] = true;
                             break;
                         case 'date':
                         case 'age_verification':
                             //echo JHTML::_('behavior.calendar');
                             /*
                              * TODO We must add the joomla.javascript here that contains the calendar,
                              * since Joomla does not load it when there's no user logged in.
                              * Gotta find out why... some security issue or a bug???
                              * Note by Oscar
                              */
                             // if ($_userData === null) { // Not logged in
                             // $_doc = JFactory::getDocument();
                             // $_doc->addScript( JURI::root(true).'/includes/js/joomla.javascript.js');
                             // }
                             $currentYear = date('Y');
                             $calendar = vmJsApi::jDate($_return['fields'][$_fld->name]['value'], $_prefix . $_fld->name, $_prefix . $_fld->name . '_field', false, $currentYear - 100 . ':' . $currentYear);
                             $_return['fields'][$_fld->name]['formcode'] = $calendar;
                             break;
                         case 'emailaddress':
                             if (empty($_return['fields'][$_fld->name]['value'])) {
                                 $_return['fields'][$_fld->name]['value'] = JFactory::getUser()->email;
                             }
                             // 							vmdebug('emailaddress',$_fld);
                         // 							vmdebug('emailaddress',$_fld);
                         case 'text':
                         case 'webaddress':
                             $_return['fields'][$_fld->name]['formcode'] = '<input type="text" id="' . $_prefix . $_fld->name . '_field" name="' . $_prefix . $_fld->name . '" size="' . $_fld->size . '" value="' . $_return['fields'][$_fld->name]['value'] . '" ' . ($_fld->required ? ' class="required"' : '') . ($_fld->maxlength ? ' maxlength="' . $_fld->maxlength . '"' : '') . ($_fld->readonly ? ' readonly="readonly"' : '') . ' /> ';
                             break;
                         case 'textarea':
                             $_return['fields'][$_fld->name]['formcode'] = '<textarea id="' . $_prefix . $_fld->name . '_field" name="' . $_prefix . $_fld->name . '" cols="' . $_fld->cols . '" rows="' . $_fld->rows . '" class="inputbox" ' . ($_fld->readonly ? ' readonly="readonly"' : '') . '>' . $_return['fields'][$_fld->name]['value'] . '</textarea>';
                             break;
                         case 'editorta':
                             jimport('joomla.html.editor');
                             $editor = JFactory::getEditor();
                             $_return['fields'][$_fld->name]['formcode'] = $editor->display($_prefix . $_fld->name, $_return['fields'][$_fld->name]['value'], 300, 150, $_fld->cols, $_fld->rows);
                             break;
                         case 'checkbox':
                             $_return['fields'][$_fld->name]['formcode'] = '<input type="checkbox" name="' . $_prefix . $_fld->name . '" id="' . $_prefix . $_fld->name . '_field" value="1" ' . ($_return['fields'][$_fld->name]['value'] ? 'checked="checked"' : '') . '/>';
                             break;
                             // /*##mygruz20120223193710 { :*/
                             // case 'userfieldplugin': //why not just vmuserfieldsplugin ?
                             // JPluginHelper::importPlugin('vmuserfield');
                             // $dispatcher = JDispatcher::getInstance();
                             // //Todo to adjust to new pattern, using &
                             // $html = '' ;
                             // $dispatcher->trigger('plgVmOnUserFieldDisplay',array($_return['fields'][$_fld->name], &$html) );
                             // $_return['fields'][$_fld->name]['formcode'] = $html;
                             // break;
                             // /*##mygruz20120223193710 } */
                         // /*##mygruz20120223193710 { :*/
                         // case 'userfieldplugin': //why not just vmuserfieldsplugin ?
                         // JPluginHelper::importPlugin('vmuserfield');
                         // $dispatcher = JDispatcher::getInstance();
                         // //Todo to adjust to new pattern, using &
                         // $html = '' ;
                         // $dispatcher->trigger('plgVmOnUserFieldDisplay',array($_return['fields'][$_fld->name], &$html) );
                         // $_return['fields'][$_fld->name]['formcode'] = $html;
                         // break;
                         // /*##mygruz20120223193710 } */
                         case 'multicheckbox':
                         case 'select':
                         case 'multiselect':
                         case 'radio':
                             $_qry = 'SELECT fieldtitle, fieldvalue ' . 'FROM #__virtuemart_userfield_values ' . 'WHERE virtuemart_userfield_id = ' . $_fld->virtuemart_userfield_id . ' ORDER BY ordering ';
                             $_values = $this->_getList($_qry);
                             // We need an extra lok here, especially for the Bank info; the values
                             // must be translated.
                             // Don't check on the field name though, since others might be added in the future :-(
                             foreach ($_values as $_v) {
                                 $_v->fieldtitle = JText::_($_v->fieldtitle);
                             }
                             $_attribs = array();
                             if ($_fld->readonly) {
                                 $_attribs['readonly'] = 'readonly';
                             }
                             if ($_fld->required) {
                                 $_attribs['class'] = 'required';
                             }
                             if ($_fld->type == 'radio') {
                                 $_selected = $_return['fields'][$_fld->name]['value'];
                             } else {
                                 $_attribs['size'] = $_fld->size;
                                 // Use for all but radioselects
                                 $_selected = explode("|*|", $_return['fields'][$_fld->name]['value']);
                             }
                             // Nested switch...
                             switch ($_fld->type) {
                                 case 'multicheckbox':
                                     $_return['fields'][$_fld->name]['formcode'] = '';
                                     $_idx = 0;
                                     $rows = $_fld->rows;
                                     $row = 1;
                                     foreach ($_values as $_val) {
                                         if ($row > $rows) {
                                             $row = 1;
                                             $br = '<br />';
                                         } else {
                                             $row++;
                                             $br = '';
                                         }
                                         $_return['fields'][$_fld->name]['formcode'] .= '<input type="checkbox" name="' . $_prefix . $_fld->name . '[]" id="' . $_prefix . $_fld->name . '_field' . $_idx . '" value="' . $_val->fieldvalue . '" ' . (in_array($_val->fieldvalue, $_selected) ? 'checked="checked"' : '') . '/> ' . JText::_($_val->fieldtitle) . $br;
                                         $_idx++;
                                     }
                                     break;
                                 case 'select':
                                     $_return['fields'][$_fld->name]['formcode'] = JHTML::_('select.genericlist', $_values, $_prefix . $_fld->name, $_attribs, 'fieldvalue', 'fieldtitle', $_selected[0]);
                                     break;
                                 case 'multiselect':
                                     $_attribs['multiple'] = 'multiple';
                                     $_attribs['rows'] = $_fld->rows;
                                     $_attribs['cols'] = $_fld->cols;
                                     $_return['fields'][$_fld->name]['formcode'] = JHTML::_('select.genericlist', $_values, $_prefix . $_fld->name . '[]', $_attribs, 'fieldvalue', 'fieldtitle', $_selected);
                                     break;
                                 case 'radio':
                                     $_return['fields'][$_fld->name]['formcode'] = JHTML::_('select.radiolist', $_values, $_prefix . $_fld->name, $_attribs, $_selected, 'fieldvalue', 'fieldtitle');
                                     break;
                             }
                             break;
                     }
                     break;
             }
         }
     } else {
         vmdebug('getUserFieldsFilled $_selection is not an array ', $_selection);
         // 			$_return['fields'][$_fld->name]['formcode'] = '';
     }
     return $_return;
 }