Всем привет. Столкнулся с проблемой Iprice Calculator Light - хочу сделать чтобы по клику по строчки категории все её элементы исчезали. Пытался использовать вот эти примеры (
), но безуспешно, почему-то не работают. Помогите, может я просто некорректно вставляю их.
<?php
/**
* @package Joomla
* @copyright Copyright (C) 2013 IPrice web solutions. All rights reserved.
* @license GNU/GPL, see LICENSE.php
*/
defined( '_JEXEC' ) or die( 'Restricted access' );
$ver30 = version_compare(JVERSION, '3.0', 'ge');
$itemid = JRequest::getVar('Itemid', '');
$introtext = $this->params->get('introtext','');
$headertext = $this->params->get('headertext','');
$usecents = (int) $this->params->get('usecents','1');
$showprices = (int) $this->params->get('showprices','1');
$numselitems = (int) $this->params->get('numselitems','0');
$usetabs = (int) $this->params->get('use_tabs','1');
if ($usetabs) {
if($ver30)
jimport('joomla.html.html.bootstrap');
else
jimport('joomla.html.pane');
}
$totalratio = (float) str_replace(',','.', $this->params->get('totalratio','0'));
$showtotalratio = (int)$this->params->get('showtotalratio','1');
$totalratioview = (int) $this->params->get('totalratioview','0');
if ($totalratio) {
if ($totalratioview==1)
$totalratiodisplay = ($totalratio-1)*100 . '%';
else
$totalratiodisplay = (string) $totalratio;
}
$countdig = ($usecents == 1 ? "2" : "0" );
$sym = trim($this->curr->symbol);
if ($this->curr->symplace) {
$currmask = $sym.($this->curr->usespace == 1 ? " " : "" ).($usecents == 1 ? "%01.2f" : "%d" );
$currmaskjs = "'".$sym."'+".($this->curr->usespace == 1 ? "' '+" : "" )."%s";
}
else {
$currmask = ($usecents == 1 ? "%01.2f" : "%d" ).($this->curr->usespace == 1 ? " " : "" ).$sym;
$currmaskjs = "%s".($this->curr->usespace == 1 ? "+' '" : "" )."+'".$sym."'";
}
$user = &JFactory::getUser();
$doc =& JFactory::getDocument();
$doc->addStyleSheet( JURI::base(true)."/components/com_ipricecalc/views/price/tmpl/ipricecalc.css" );
?>
<script language="javascript" type="text/javascript">
var numselitems = <?php echo (int)$numselitems; ?>;
if (!numselitems) numselitems = 1;
function form_hasValue(object, obj_type, optional_1, optional_2, optional_3) {
switch (obj_type) {
case "TEXT":
if (object.value.length < 5) {return false;}
return true;
case "EMAIL":
if (object.value.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1) {return false;}
return true;
case "TEXTAREA":
if (object.value.length < 1) {return false;}
return true;
case "SELECT":
for (i=0; i < object.length; i++) {
if (object.options[i].selected && object.options[object.selectedIndex].value != 0 ) {return true;}
}
return false;
case "SINGLE_VALUE_RADIO":
if (object.checked) {return true;}
return false;
case "SINGLE_VALUE_CHECKBOX":
if (object.checked) {return true;}
return false;
case "RADIO":
for (i=0; i < object.length; i++) {
if (object[i].checked) {return true;}
}
return false;
case "CHECKBOX":
for (i=0; i < object.length; i++) {
if (object[i].checked) {return true;}
}
return false;
case "INTEGER":
if (object.value.length == 0) {return false;}
else {
if (object.value.search(/^\d+$/) == -1) {return false;}
}
return true;
case "NUMBER":
if (object.value.search(/^\-?\+?\d*\.?\d+$/) == -1) {return false;}
return true;
case "PHONE_NUMBER":
if (object.value.search(/^[ \+\-\(\)\d]{5,}$/) == -1) {return false;}
return true;
case "SELECTNOTZERO":
for (i=0; i < object.length; i++) {
if (object.options[i].selected) {
if(object.options[i].value != 0) {return true;}
}
}
return false;
}
}
function checkHaveValues (checkList) {
var loopLength = checkList.length / 3;
for (x=0;x<loopLength;x++) {
var message = checkList[(x*3)];
var checkItem = checkList[(x*3)+1];
var type = checkList[(x*3)+2];
if (!form_hasValue(checkItem,type)) {
alert(message);
if (checkItem.type == "TEXT" || checkItem.type == "PASSWORD") {
checkItem.focus();
}
return false;
}
}
return true;
}
function ipricevalidate(formName) {
if (!checkHaveValues(new Array(
"<?php echo JText::_('Contact_person_needed');?>",formName.fio,"TEXT",
"<?php echo JText::_('Phone_number_needed');?>",formName.phone,"TEXT",
"<?php echo JText::_('Correct_email_needed');?>",formName.email,"EMAIL")))
{return false;}
else {
formName.submit();
return true;
}
}
function show_desc(iid) {
if (iid.style.display == '') iid.style.display='none'; else iid.style.display='';
};
var price_list=new Array();
function initprice(){
<?php
$curcatnum = -1;
$itemnum = -1;
$curcat = '';
foreach ($this->items as $item) {
$itemnum++;
if ($curcat != $item->category) {
$curcatnum++;
$itemnum = 0;
$curcat = $item->category;
echo ('price_list['.$curcatnum.'] = new Array();'."\n");
};
echo (" price_list[".$curcatnum."][".$itemnum."] = ".$item->cost."; ");
}
?>
}
function check_event(checknum){
var sum_ = new Array();
var j;
var jj = 0;
var numsel = 0;
for (var i = 0; i < price_list.length; i++){
sum_[i]=0;
for (j = 0; j < price_list[i].length; j++){
tot=0;
i_type = document.getElementById('itemtype_'+jj).value;
if (i_type == 0)
inp = document.getElementById('i_box_'+jj);
else if (i_type == 1)
inp = document.getElementById('i_'+jj);
else
inp = document.getElementById('i_radio_'+jj);
if((i_type == 0 || i_type == 2) && inp.checked) {
numsel++;
tot = price_list[i][j];
}
else if (i_type == 1 && inp.value != '0') {
numsel++;
tot = price_list[i][j] * inp.value;
};
sum_[i] = sum_[i] + tot;
el = document.getElementById('total_'+jj);
if (el)
el.innerHTML = <?php echo sprintf($currmaskjs,'tot.toFixed('.$countdig.')'); ?>;
jj++;
};
};
var SUM=0,zero=0;
for(i=0; i<price_list.length;i++) {
SUM = SUM + sum_[i];
el = document.getElementById('results_'+i);
if (el) {
el.innerHTML = <?php echo sprintf($currmaskjs,'zero.toFixed('.$countdig.')'); ?>;
/* if (numsel >= numselitems)*/
el.innerHTML = <?php echo sprintf($currmaskjs,'sum_[i].toFixed('.$countdig.')'); ?>;
}
}
elr = document.getElementById('results_bottom');
elg = document.getElementById('grandtotal');
if (elr)
elr.innerHTML = <?php echo sprintf($currmaskjs,'zero.toFixed('.$countdig.')'); ?>;
<?php if ($totalratio) { ?>
if (elg)
elg.innerHTML = <?php echo sprintf($currmaskjs,'zero.toFixed('.$countdig.')'); ?>;
<?php } ?>
if (numsel >= numselitems) {
if (elr)
elr.innerHTML = <?php echo sprintf($currmaskjs,'SUM.toFixed('.$countdig.')'); ?>;
<?php if ($totalratio) { ?>
SUM = SUM * <?php echo $totalratio; ?>;
if (elg)
elg.innerHTML = <?php echo sprintf($currmaskjs,'SUM.toFixed('.$countdig.')'); ?>;
<?php } ?>
}
if (checknum && numsel < numselitems) {
alert("<?php echo JText::_('NEEDED_ITEMS_NOT_SELECTED')?>"+" "+numselitems);
return false;
} else
return true;
};
</script>
<?php
if ($headertext) { ?>
<h2><?php echo $headertext;?></h2>
<?php
}
if ($introtext) { ?>
<div class="iprice_intro"><?php echo $introtext;?></div>
<?php
}
?>
<form action="index.php?option=com_ipricecalc" name="filter_form" id="filter_form" method="post" >
<?php
$currselect = (int)$this->params->get('showcurrselect','2');
if ($currselect) {
require_once( JPATH_SITE.'/components/com_ipricecalc/helpers/html.php');
JHTMLIpriceList::currSelectorHTML($this->curr->currcode);
echo '<div style="clear:both"></div>';
}
?>
<input type="hidden" name="redir" value="<?php echo urlencode(JFactory::getURI()->toString());?>" />
<input type="hidden" name="task" value="submitfilter" />
<?php echo JHTML::_( 'form.token' ); ?>
</form>
<form action="" name="calc_form" method="POST" >
<script language="javascript" type="text/javascript">
function pressplus(objid) {
var qty_el = document.getElementById(objid);
if( !isNaN( qty_el.value )) qty_el.value++; else qty_el.value=1;
check_event(false);
}
function pressminus(objid) {
var qty_el = document.getElementById(objid);
if( !isNaN( qty_el.value ) && qty_el.value>0) qty_el.value--; else qty_el.value=0;
check_event(false);
}
</script>
<?php
defined( '_JEXEC' ) or die( 'Restricted access' );
$usecents = (int) $this->params->get('usecents','1');
$showprices = (int) $this->params->get('showprices','1');
$numselitems = (int) $this->params->get('numselitems','0');
$countdig = ($usecents == 1 ? "2" : "0" );
$sym = trim($this->curr->symbol);
if ($this->curr->symplace) {
$currmask = $sym.($this->curr->usespace == 1 ? " " : "" ).($usecents == 1 ? "%01.2f" : "%d" );
$currmaskjs = "'".$sym."'+".($this->curr->usespace == 1 ? "' '+" : "" )."%s";
}
else {
$currmask = ($usecents == 1 ? "%01.2f" : "%d" ).($this->curr->usespace == 1 ? " " : "" ).$sym;
$currmaskjs = "%s".($this->curr->usespace == 1 ? "+' '" : "" )."+'".$sym."'";
}
$i = -1;
$curcatnum = -1;
$itemnum = -1;
$curcat = '';
$totalcolspan = 2;
$totalpricecolspan = 1;
$delimcolspan = 3;
$headerHTML = '<table class="tablenoborder" width="100%" border="0" align="center" cellPadding=3 cellSpacing=0 >'."\n";
$headerHTML .= '<tr class="tablzag3"><td class="tablzag3">'.JText::_('Item_name').'</td><td class="tablzag3" align="center">'.JText::_('Short_description')
.'</td><td align=center class="tablzag3">'.JText::_('Select').'</td>';
if ($showprices) {
$headerHTML .= '<td align=center class="tablzag3">'.JText::_('Cost').'</td>';
$headerHTML .= '<td align=center class="tablzag3">'.JText::_('Total').'</td>';
$totalcolspan = $totalcolspan+2;
$totalpricecolspan = 0;
$delimcolspan = $delimcolspan+2;
}
$headerHTML .= '</tr>'."\n";
if ($usetabs) {
if ($ver30) {
$ccnum = -1;
$catid=-1;
echo '<ul class="nav nav-tabs" id="myTab">';
foreach ($this->items as $item)
if ($catid != $item->catid) {
$ccnum++;
$catid = $item->catid;
echo '<li><a data-toggle="tab" href="#cat'.$ccnum.'">'.$item->category.'</a></li>';
}
echo '</ul>';
echo JHtml::_('bootstrap.startPane', 'myTab', array('active' => 'cat0'));
}
else {
$jPaneTabs =& JPane::getInstance('tabs');
echo $jPaneTabs->startPane("pane")."\n";
}
} else
echo $headerHTML;
foreach ($this->items as $item) :
$i++;
$itemnum++;
if ($curcat != $item->category) {
$curcatnum++;
$itemnum = 0;
if ($curcatnum>0) { ?>
<?php if ($showprices) { ?>
<tr>
<td colspan="<?php echo $totalcolspan;?>" align="right" valign="middle" class="tablitogo" ><?php echo JText::_('Subtotals').' "'.$curcat.'"' ?> : </td>
<td <?php if ($totalpricecolspan) echo 'colspan="'.$totalpricecolspan.'"'; ?> align="right" valign="middle" class="tablitogo" ><span id="results_<?php echo ($curcatnum-1);?>" ><?php echo sprintf($currmask,0)?></span></td>
</tr>
<?php } ?>
<!--
<tr>
<td colspan="<?php echo $delimcolspan;?>" align="right" class="tabldelim"></td>
</tr>
-->
<?php
if ($usetabs) {
echo '</table>';
if ($ver30)
echo JHtml::_('bootstrap.endPanel');
else
echo $jPaneTabs->EndPanel();
}
}
$curcat = $item->category;
if ($usetabs) {
if ($ver30)
echo JHtml::_('bootstrap.addPanel', 'myTab', 'cat'.$curcatnum);
else
echo $jPaneTabs->startPanel($curcat, $curcatnum);
echo $headerHTML;
}
echo ('<tr><td colspan="'.$delimcolspan.'" class="tablzag2" >'.$item->category.'</td></tr>');
};
?>
<tr valign="middle">
<td width="30%" align="left" class="tablchet">
<div align="left"><a href="javascript:show_desc(document.getElementById('d_<?php echo $item->id;?>'));" class="tablchet" ><span class="tablcheta"><?php echo $item->name;?></span></a></div>
</td>
<td align="left" class="tablchet">
<div align="center"><?php echo $item->shortdesc ?></div>
</td>
<td width="10%" align="center" nowrap="nowrap">
<?php if ($item->showcount==1) { ?>
<span class="minus" onClick="pressminus('i_<?php echo ($i);?>')">-</span>
<input type="text" maxlength="5" onFocus="if (this.value=='0') this.value='';" onBlur="if (this.value=='') this.value='0';"
onchange="check_event(false)" style="width: 30px; text-align: right" value="0"
id="i_<?php echo ($i);?>" name="i_<?php echo ($i);?>" />
<span class="plus" onClick="pressplus('i_<?php echo ($i);?>')">+</span>
<?php } elseif ($item->showcount==2) { ?>
<input type="radio" onclick="check_event(false)"
id="i_radio_<?php echo ($i);?>" name="i_radio_<?php echo ($item->radiogroup);?>" value="<?php echo ($item->id);?>" />
<?php } else { ?>
<input type="checkbox" onclick="check_event(false)" id="i_box_<?php echo ($i);?>" name="i_box_<?php echo ($i);?>" />
<?php } ?>
<input type="hidden" name="itemid_<?php echo ($i);?>" value="<?php echo $item->id; ?>" />
<input type="hidden" name="itemtype_<?php echo ($i);?>" id="itemtype_<?php echo ($i);?>" value="<?php echo $item->showcount; ?>" />
</td>
<?php if ($showprices) : ?>
<td width="15%" align="right">
<nobr class="tablchet"><?php echo sprintf($currmask,$item->cost);?></nobr>
</td>
<td width="15%" align="right">
<span id="total_<?php echo ($i);?>" class="tablchet" ><?php echo sprintf($currmask,0);?></span>
</td>
<?php endif; ?>
</tr>
<tr>
<td colspan="<?php echo $delimcolspan;?>" align="left" class="tabldiv" >
<div align="justify" class="tabldiv" id="d_<?php echo $item->id;?>" style="display: none;" name="d_<?php echo $item->id;?>"><?php echo $item->description; ?></div>
</td>
</tr>
<?php endforeach;
if ($showprices) {
if ($curcatnum>-1) : ?>
<tr>
<td colspan="<?php echo $totalcolspan;?>" align="right" valign="middle" class="tablitogo" ><?php echo JText::_('Subtotals').' "'.$curcat?>" : </td>
<td <?php if ($totalpricecolspan) echo 'colspan="'.$totalpricecolspan.'"'; ?> align="right" valign="middle" class="tablitogo" ><span id="results_<?php echo ($curcatnum);?>" ><?php echo sprintf($currmask,0);?></span></td>
</tr>
<?php endif; ?>
<?php }
if ($curcatnum>-1) {
if ($usetabs) {
echo '</table>'."\n";
if ($ver30) {
echo JHtml::_('bootstrap.endPanel');
echo JHtml::_('bootstrap.endPane');
} else {
echo $jPaneTabs->EndPanel();
echo $jPaneTabs->EndPane();
}
}
}
if ($showprices) {
if ($usetabs)
echo '<table class="tablenoborder" width="100%" border="0" align="center" cellPadding=3 cellSpacing=0 >'."\n";
?>
<tr><td colspan="<?php echo $delimcolspan;?>" align=right class="tabldelim" ></td></tr>
<tr>
<td colspan="<?php echo $totalcolspan;?>" align="right" class="tablitogo"><?php echo JText::_('Totals');?></td>
<td <?php if ($totalpricecolspan) echo 'colspan="'.$totalpricecolspan.'"'; ?> align="right" width="15%" class="tablitogo"><span class="textwarn" id="results_bottom"><?php echo sprintf($currmask,0);?></span></td>
</tr>
<?php
if ($usetabs)
echo '</table>';
}
if (!$usetabs)
echo '</table>';
if ($totalratio && showprices) : ?>
<table class="tablenoborder" width="100%" border=0 align=center cellPadding=3 cellSpacing=0 VALIGN="TOP">
<?php if ($showtotalratio) : ?>
<tr><td class="tabldelim" ></td></tr>
<tr>
<td align="right" valign="middle" class="tablitogo" ><?php echo JText::_('Total_ratio'); ?> </td>
<td width="20%" align="right" valign="middle" class="tablitogo" ><?php echo $totalratiodisplay;?></td>
</tr>
<?php endif; ?>
<tr><td class="tabldelim" ></td></tr>
<tr>
<td align="right" class="tablitogo"><?php echo JText::_('Grand_total');?></td>
<td width="20%" align="right" class="tablitogo"><span class="textwarn" id="grandtotal"><?php echo sprintf($currmask,0);?></span></td>
</tr>
</table>
<?php endif; ?>
<br />
<center><input type="button" id="preorder" class="button" onclick="if (!check_event(true)) return false; document.getElementById('order_dat').style.display=''; style.display='none'" value="<?php echo JText::_('Preorder');?>" />
</center>
<br>
<div style="display: none;" id="order_dat" name="order_dat">
<table class="tablenoborder" cellSpacing="0" cellPadding="0" width="100%" border="0" align="center">
<tr class>
<td class="tablzag2"><?php echo JText::_('Contact_info');?></td>
</tr>
<tr><td>
<table class="tablenoborder" cellpadding=0 cellspacing=0 width=100% border=0>
<tr class="tablchet" >
<td align=right class="tablchet"> </td>
<td class="tablchet"> </td>
</tr>
<tr class="tablchet" >
<td align=right width=200px class="tablchet"><?php echo JText::_('Contact_person');?><span class="textwarn">*</span>:</td>
<td class="tablchet"><input name="fio" maxlength="90" type=text value="<?php echo $user->get('name',''); ?>" class="form" /></td>
</tr>
<tr class="tablchet" >
<td align=right width=200px class="tablchet"><?php echo JText::_('Company_name');?></td>
<td class="tablchet"><input name="firm" maxlength="90" type=text class="form" value="" /></td>
</tr>
<tr class="tablchet" >
<td align=right width=200px class="tablchet"><?php echo JText::_('PHONE_NUMBER');?><span class="textwarn">*</span>:</td>
<td class="tablchet"><input name="phone" maxlength="60" type=text class="form" value="" /></td>
</tr>
<tr class="tablchet" >
<td align=right width=200px class="tablchet" ><?php echo JText::_('EMail');?><span class="textwarn">*</span>:</td>
<td class="tablchet" ><input name="email" type=text maxlength="60" value="<?php echo $user->get('email','') ;?>" class="form" /></td>
</tr>
<tr class="tablchet" >
<td align=right width=200px class="tablchet"><?php echo JText::_('Comments');?></td>
<td class="tablchet" ><textarea name="comments" cols="50" rows=5 class="textarea" ></textarea></td>
</tr>
<tr class="tablchet" >
<td align=right width=200px class="tablchet"><?php echo JText::_('Send_copy');?></td>
<td class="tablchet" ><input name="copyemail" type="checkbox" CHECKED /></td>
</tr>
<tr class="tablchet" >
<td align=right colspan=2 class="tablchet"><span class="textwarn">*</span><?php echo JText::_('Mandatory');?></td>
</tr>
<tr class="tablchet" >
<td align=right width=200px class="tablchet"> </td>
<td class="tablchet" >
<?php
$user = JFactory::getUser();
if ( $this->params->get('usecaptcha')!= 0 && ($this->params->get('usecaptchareg') == 1 || $this->params->get('usecaptchareg') == 0 && $user->get('id')==0 )) {
if ($this->params->get('usecaptcha') == 1 ) {
$dispatcher = &JDispatcher::getInstance();
// Captcha Extention patch rev. 4.5.0 Stable
echo '<p>';
$dispatcher->trigger( 'onCaptchaView', array( '', 0, '', '<br />' ) );
echo '</p>';
} elseif ($this->params->get('usecaptcha',0) == 2) {
require_once( JPATH_COMPONENT_ADMINISTRATOR.'/tables/recaptcha.php');
$captcha = IpriceSpamRecaptcha::getInstance();
$captchaHtml = $captcha->getHtml();
if ( !$captchaHtml ) {
JFactory::getApplication ()->enqueueMessage ( $captcha->getError(), 'error' );
} else
echo $captchaHtml;
}
}
?>
<input name="ipricebt1" id="ipricebt1" type="button" class="button" onclick="ipricevalidate(this.form);" value="<?php echo JText::_('Send_order');?>" />
</td>
</tr>
</table>
</td></tr>
</table>
</div>
<input type="hidden" name="countitems" value="<?php echo count($this->items)?>" />
<input type="hidden" name="curr" value="<?php echo $this->curr->currcode?>" />
<input type="hidden" name="redir" value="<?php $uri = JFactory::getURI(); echo urlencode($uri->toString());?>" />
<?php if ($itemid) : ?>
<input type="hidden" name="itemid" value="<?php echo $itemid?>" />
<?php endif;
?>
<input type="hidden" name="option" value="com_ipricecalc" />
<input type="hidden" name="view" value="price" />
<input type="hidden" name="task" value="submit" />
<center style="font-size:9px"><a href="http://www.iprice-web.ru" target="_blank" rel="follow">Powered by IPrice</a></center>
<input type="hidden" name="itemno" value="1" />
<?php echo JHTML::_( 'form.token' ); ?>
</form>
<script language="javascript" type="text/javascript">
initprice();
</script>