<?php
/*
 * @package Joomla
 * @copyright Copyright (C) Open Source Matters. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 * @component Phoca Cart
 * @copyright Copyright (C) Jan Pavelka www.phoca.cz
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
 */
defined('_JEXEC') or die();

Joomla\CMS\HTML\HTMLHelper::_('bootstrap.tooltip');
Joomla\CMS\HTML\HTMLHelper::_('behavior.multiselect');
Joomla\CMS\HTML\HTMLHelper::_('dropdown.init');
Joomla\CMS\HTML\HTMLHelper::_('formbehavior.chosen', 'select');


//- $link		= JRoute::_( 'index.php?option='.$this->t['o'].'&view=phocacarteditproductpricehistory&tmpl=component&id='.(int)$this->id);


echo '<div id="phAdminEditPopup" class="ph-edit-price-history-box">';

/*
echo '<div class="alert alert-info"><button type="button" class="close" data-dismiss="alert">&times;</button>'
	. '<ul><li>'.JText::_('COM_PHOCACART_TO_SEE_ALL_CUSTOMER_GROUPS_LISTED_CLOSE_WINDOW_SAVE_THE_PRODUCT_FIRST') . '</li>'
	.'</ul></div>';
*/


//- echo '<div class="ph-product-price-history-box">';

//- echo '<form action="'.$link.'" method="post">';


	/*
echo '<div class="ph-product-price-history-box">';

echo '<div class="row-fluid ph-row">'."\n";
echo '<div class="col-xs-12 col-sm-3 col-md-3">'.JText::_('COM_PHOCACART_DATE').'</div>';
echo '<div class="col-xs-12 col-sm-2 col-md-2">'.JText::_('COM_PHOCACART_PRICE').'</div>';
echo '<div class="col-xs-12 col-sm-1 col-md-1"></div>';
echo '<div class="col-xs-12 col-sm-6 col-md-6"></div>';
echo '</div>';
echo '<div class="ph-cb"></div>'."\n";


$r 						= new PhocacartRenderAdminview();

if (!empty($this->t['history'])) {
	$i = 0;
	foreach($this->t['history'] as $k => $v) {
		echo $r->additionalPricehistoryRow((int)$i, (int)$v['id'], $v['price'], $v['date'], $this->id, 0);
		$i++;
	}

	$newRow = $r->additionalPricehistoryRow('\' + phRowCountPricehistory +  \'', '', '', '', $this->id, 1);
	$newRow = preg_replace('/[\x00-\x1F\x80-\x9F]/u', '', $newRow);
	PhocacartRenderAdminjs::renderJsManageRowPricehistory($i, $newRow);
} else {
	$newRow = $r->additionalPricehistoryRow('\' + phRowCountPricehistory +  \'', '', '', '', $this->id, 1);
	$newRow = preg_replace('/[\x00-\x1F\x80-\x9F]/u', '', $newRow);
	PhocacartRenderAdminjs::renderJsManageRowPricehistory(0, $newRow);

}
echo $r->addRowButton(JText::_('COM_PHOCACART_ADD_PRICE'), 'pricehistory');
	//echo '</td></tr>';



echo '<div class="col-xs-12 col-sm-3 col-md-3"></div>';

echo '<div class="col-xs-12 col-sm-2 col-md-2">';
echo '<input type="hidden" name="id" value="'.(int)$this->id.'">';
echo '<input type="hidden" name="task" value="phocacarteditproductpricehistory.save">';
echo '<input type="hidden" name="tmpl" value="component" />';
echo '<input type="hidden" name="option" value="com_phocacart" />';
echo '<button class="btn btn-success btn-sm ph-btn"><span class="icon-ok ph-icon-white"></span> '.JText::_('COM_PHOCACART_SAVE').'</button>';
echo Joomla\CMS\HTML\HTMLHelper::_('form.token');
echo '</div>';

echo '<div class="col-xs-12 col-sm-1 col-md-1"></div>';
echo '<div class="col-xs-12 col-sm-6 col-md-6"></div>';


*/


$app 		= JFactory::getApplication();
$input 		= $app->input;
$class		= $this->t['n'] . 'RenderAdminview';
$r 			=  new PhocacartRenderAdminview();
$isModal    = $input->get('layout') == 'modal' ? true : false;
$layout     = $isModal ? 'modal' : 'edit';
$tmpl       = $isModal || $input->get('tmpl', '', 'cmd') === 'component' ? 'component' : '';


//phocacartitem-form => adminForm
echo $r->startForm($this->t['o'], $this->t['task'], (int)$this->id, 'adminForm', 'adminForm', '', $layout, $tmpl);

echo '<div class="span12 form-horizontal">';

echo '<div class="tab-pane" id="price_history">'. "\n";
echo '<h3>'.JText::_($this->t['l'].'_PRICE_HISTORY').'</h3>';
$formArray = array ('price_history');
echo $r->group($this->form, $formArray);
echo '</div>'. "\n";

//echo $r->formInputs($this->t['task']);
echo '<input type="hidden" name="id" value="'.(int)$this->id.'">';
echo '<input type="hidden" name="task" value="phocacarteditproductpricehistory.save">';
echo '<input type="hidden" name="tmpl" value="component" />';
echo '<input type="hidden" name="option" value="com_phocacart" />';
echo '<button class="btn btn-success btn-sm ph-btn pull-right ph-right"><span class="icon-ok ph-icon-white"></span> '.JText::_('COM_PHOCACART_SAVE').'</button>';
echo Joomla\CMS\HTML\HTMLHelper::_('form.token');

echo '</div>';

echo $r->endForm();

echo '</div>';// end ph-product-price-history-box
?>
