<modification>
	<id>Additional Product Tabs</id>
	<version>1.0.3</version>
	<vqmver>2.2.1</vqmver>
	<author>Godfrey Livinstone</author>
	<decription><![CDATA[
		/*
			This file is part of the "Extra Product Tabs Opencart Extension"

			The "Extra Product Tabs Opencart Extension" is free software: you can redistribute it and/or modify it under
			the terms of the GNU General Public License as published by the Free Software
			Foundation, either version 3 of the License, or (at your option) any later version.

			The Extra Product Tabs Opencart Extension is distributed in the hope that it will be useful,
			but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
			FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

			---------------------------------------------------------------------
			Name:		Extra Product Tabs Opencart Extension
			
			Version: 1.0.4

			OpenCart:	Version 1.5.4.1, 1.5.5.1

			Author: 	rebdog (Godfrey Livinsgtone godfrey@satelliteshop.co.nz)

			Copyright 2012, 2013

		*/
		]]>
	</decription>

	<file name="catalog/view/theme/*/template/product/product.tpl" error="log">

		<!-- Add Position 1 Tabs -->
		<operation error="log">
			<search position="replace"><![CDATA[
				<a href="#tab-description"><?php echo $tab_description; ?></a>
				]]>
			</search>
			<add trim="true"><![CDATA[
				<?php if ($product_tabs_1) { ?>
					<?php foreach($product_tabs_1 as $product_tab_1) { ?>
						<a href="#tab-product-tab<?php echo $product_tab_1['tab_id'];?>"><?php echo $product_tab_1['name']; ?></a>
					<?php } ?>
				<?php } ?>
				<a href="#tab-description"><?php echo $tab_description; ?></a>
        ]]>
			</add>
		</operation>

		<!-- Add Position 2 Tabs -->
	  <operation error="log">
			<search position="before" index="1"><![CDATA[
				<?php if ($attribute_groups) { ?>
				]]>
			</search>
			<add trim="true"><![CDATA[
				<?php if ($product_tabs_2) { ?>
					<?php foreach($product_tabs_2 as $product_tab_2) { ?>
						<a href="#tab-product-tab<?php echo $product_tab_2['tab_id'];?>"><?php echo $product_tab_2['name']; ?></a>
					<?php } ?>
				<?php } ?>
        ]]>
			</add>
		</operation>

		<!-- Add Position 3 Tabs -->
	  <operation error="log">
			<search position="before" index="2"><![CDATA[
				<?php if ($review_status) { ?>
				]]>
			</search>
			<add trim="true"><![CDATA[
				<?php if ($product_tabs_3) { ?>
					<?php foreach($product_tabs_3 as $product_tab_3) { ?>
						<a href="#tab-product-tab<?php echo $product_tab_3['tab_id'];?>"><?php echo $product_tab_3['name']; ?></a>
					<?php } ?>
				<?php } ?>
        ]]>
			</add>
		</operation>

		<!-- Add Position 4 Tabs -->
	  <operation error="log">
			<search position="before" index="1"><![CDATA[
				<?php if ($products) { ?>
				]]>
			</search>
			<add trim="true"><![CDATA[
				<?php if ($product_tabs_4) { ?>
					<?php foreach($product_tabs_4 as $product_tab_4) { ?>
						<a href="#tab-product-tab<?php echo $product_tab_4['tab_id'];?>"><?php echo $product_tab_4['name']; ?></a>
					<?php } ?>
				<?php } ?>
        ]]>
			</add>
		</operation>

		<!-- Add Position 5 Tabs -->
	  <operation error="log">
			<search position="after" index="1" offset="2"><![CDATA[
				<?php if ($products) { ?>
				]]>
			</search>
			<add trim="true"><![CDATA[
				<?php if ($product_tabs_5) { ?>
					<?php foreach($product_tabs_5 as $product_tab_5) { ?>
						<a href="#tab-product-tab<?php echo $product_tab_5['tab_id'];?>"><?php echo $product_tab_5['name']; ?></a>
					<?php } ?>
				<?php } ?>
        ]]>
			</add>
		</operation>

		<!-- Add Position 1 Tabs Content -->
		<operation error="log">
			<search position="before"><![CDATA[
				<div id="tab-description" class="tab-content"><?php echo $description; ?></div>
				]]>
			</search>
			<add trim="true"><![CDATA[
				<?php if ($product_tabs_1) { ?>
					<?php foreach($product_tabs_1 as $product_tab_1) { ?>
						<div id="tab-product-tab<?php echo $product_tab_1['tab_id'];?>" class="tab-content"><?php echo $product_tab_1['text']; ?></div>
					<?php } ?>
				<?php } ?>
				]]>
			</add>
		</operation>

		<!-- Add Position 2 Tabs Content -->
		<operation error="log">
			<search position="before" offset="1"><![CDATA[
				<div id="tab-attribute" class="tab-content">
				]]>
			</search>
			<add trim="true"><![CDATA[
				<?php if ($product_tabs_2) { ?>
					<?php foreach($product_tabs_2 as $product_tab_2) { ?>
						<div id="tab-product-tab<?php echo $product_tab_2['tab_id'];?>" class="tab-content"><?php echo $product_tab_2['text']; ?></div>
					<?php } ?>
				<?php } ?>
				]]>
			</add>
		</operation>

		<!-- Add Position 3 Tabs Content -->
		<operation error="log">
			<search position="before" offset="1"><![CDATA[
				<div id="tab-review" class="tab-content">
				]]>
			</search>
			<add trim="true"><![CDATA[
				<?php if ($product_tabs_3) { ?>
					<?php foreach($product_tabs_3 as $product_tab_3) { ?>
						<div id="tab-product-tab<?php echo $product_tab_3['tab_id'];?>" class="tab-content"><?php echo $product_tab_3['text']; ?></div>
					<?php } ?>
				<?php } ?>
				]]>
			</add>
		</operation>


		<!-- Add Position 4 Tabs Content -->
		<operation error="log">
			<search position="before" offset="1"><![CDATA[
				<div id="tab-related" class="tab-content">
				]]>
			</search>
			<add trim="true"><![CDATA[
				<?php if ($product_tabs_4) { ?>
					<?php foreach($product_tabs_4 as $product_tab_4) { ?>
						<div id="tab-product-tab<?php echo $product_tab_4['tab_id'];?>" class="tab-content"><?php echo $product_tab_4['text']; ?></div>
					<?php } ?>
				<?php } ?>
				]]>
			</add>
		</operation>

		<!-- Add Position 5 Tabs Content -->
		<operation error="log">
			<search position="before"><![CDATA[
				<?php if ($tags) { ?>
				]]>
			</search>
			<add trim="true"><![CDATA[
				<?php if ($product_tabs_5) { ?>
					<?php foreach($product_tabs_5 as $product_tab_5) { ?>
						<div id="tab-product-tab<?php echo $product_tab_5['tab_id'];?>" class="tab-content"><?php echo $product_tab_5['text']; ?></div>
					<?php } ?>
				<?php } ?>
				]]>
			</add>
		</operation>

	</file>

	<file name="catalog/controller/product/product.php" error="log">

    <operation error="log">
			<search position="before"><![CDATA[
				$results = $this->model_catalog_product->getProductRelated($this->request->get['product_id']);
				]]>
			</search>
			<add trim="true"><![CDATA[

				for( $i=1; $i< 6; $i++) {
					$this->data['product_tabs_' . $i] = array();
				}

				$product_tabs = $this->model_catalog_product->getProductTabs($this->request->get['product_id']);

				foreach ($product_tabs as $product_tab) {

					$this->data['product_tabs_' . $product_tab['position']][] = array(
						'tab_id' 	=> $product_tab['tab_id'],
						'name'    => $product_tab['name'],
						'text'    => html_entity_decode($product_tab['text'], ENT_QUOTES, 'UTF-8')
					);

				}
				]]>
			</add>
		</operation>

	</file>

	<file name="catalog/model/catalog/product.php" error="log">
		<operation error="log">
			<search position="bottom" offset="2"></search>
			<add trim="true"><![CDATA[
				public function getProductTabs($product_id) {

					$product_tab_data = array();

					$product_tab_query = $this->db->query("SELECT t.tab_id, td.name, pt.text, t.position, t.show_empty FROM " . DB_PREFIX . "product_tab pt LEFT JOIN " . DB_PREFIX . "tab t ON (pt.tab_id = t.tab_id) LEFT JOIN " . DB_PREFIX . "tab_description td ON (t.tab_id = td.tab_id) WHERE pt.product_id = '" . (int)$product_id . "' AND td.language_id = '" . (int)$this->config->get('config_language_id') . "' AND pt.language_id = '" . (int)$this->config->get('config_language_id') . "' AND t.status = '1' AND ( t.show_empty = '1' OR NOT pt.text REGEXP '^[[:space:]]*$' ) ORDER BY t.position, t.sort_order, td.name");

					foreach ($product_tab_query->rows as $product_tab) {

						$product_tab_data[] = array(
								'tab_id' 				=> $product_tab['tab_id'],
								'name'      		=> $product_tab['name'],
								'text'      		=> $product_tab['text'],
								'position' 			=> $product_tab['position']
							);
					}

					return $product_tab_data;
				}
				]]>
			</add>
		</operation>
	</file>

</modification>