| Current Path : /var/www/iplanru/data/www/www.i-plan.ru/modules/mod_zoocost/ |
| Current File : /var/www/iplanru/data/www/www.i-plan.ru/modules/mod_zoocost/helper.php |
<?php
defined('_JEXEC') or die;
class modZoocostHelper
{
public static function getText($par)
{
$h=array();
// $db = &JFactory::getDBO();
$db = JFactory::getDBO();
$array_json=json_decode(modZoocostHelper::getValue('SELECT elements as val FROM #__zoo_item where id='.$par['item_id']), true);
$cost_text_ru=$array_json[$par['alias_ru']]['0']['value'];
$cost_text_en=$array_json[$par['alias_en']]['0']['value'];
$version=isset($array_json["43191a2a-0fb3-4578-b7e0-dbf5e584873d"]["option"]) ? $array_json["43191a2a-0fb3-4578-b7e0-dbf5e584873d"]["option"]['0'] : '' ;
$cost_text_ru = preg_replace('~[^0-9.,]+~', '', $cost_text_ru);
$cost_text_en = preg_replace('~[^0-9.,]+~', '', $cost_text_en);
if (!empty($par['kurs'])){
$cost_text_dol=(float)$cost_text_en/(float)$par['kurs'];
if (is_numeric($cost_text_dol)) $cost_text_dol = number_format($cost_text_dol, 0, ',', ' ');
}
if (is_numeric($cost_text_ru)) $cost_text_ru = number_format($cost_text_ru, 0, ',', ' ');
if (is_numeric($cost_text_en)) $cost_text_en = number_format($cost_text_en, 0, ',', ' ');
if ((empty($_GET['category_id'])) and ($_GET['item_id']==$par['item_id']))
{
if ($version=="est")
{
//if (!empty($cost_text_ru))$h[]="<p style=\"font-size: 12px; color: #000; font-weight: 700;\"> Цена: {$cost_text_ru} руб. </p>";
if (!empty($cost_text_en)){
$h[]='<div id="zoocost1" >';
$h[]="<p>Цена английской версии:<br> {$cost_text_en} руб.</p>";
$h[]='</div>';
if (!empty($par['kurs'])){
$h[]='<div id="zoocost2" >';
$h[]="<p>Price of English version:<br> {$cost_text_dol}$</p>";
$h[]='</div>';
}
}
}
else
{
if (!empty($cost_text_ru)){
$h[]='<div id="zoocost1" >';
$h[]="<p> <span id=\"zoocost-prx\">Цена: </span>
<span id=\"zoocost-cn\">{$cost_text_ru}</span>
<span id=\"zoocost-sfx\"> руб.</span></p>";
$h[]='</div>';
}
if (!empty($cost_text_en)){
$h[]='<div id="zoocost2" >';
$h[]="<p>Цена английской версии:<br> {$cost_text_en} руб.</p>";
if (!empty($par['kurs'])){$h[]="<p>Price of English version:<br> {$cost_text_dol}$</p>";}
$h[]='</div>';
}
}
}
else
{
if ($version=="est")
{
if (!empty($cost_text_en)){
$h[]="<p style=\"font-size: 12px; color: #000; font-weight: 700;\"> Цена: {$cost_text_en} руб. </p>";
}
}
else
{
if (!empty($cost_text_ru))$h[]="<p style=\"font-size: 12px; color: #000; font-weight: 700;\"> Цена: {$cost_text_ru} руб. </p>";
}
}
return implode("\r\n",$h);
}
public static function getValue($sql)
{
// $db= &JFactory::getDBO();
$db= JFactory::getDBO();
$count='';
$ret='';
$field='val';
$db->setQuery($sql, 0, $count);
$rows = $db->loadObjectList();
if (count($rows)<>0)
foreach ($rows as $row)
{$ret=$row->$field;};
return $ret;
}
}