<?xml version="1.0" encoding="utf-8"?> 
<modification> 
 <name><![CDATA[So Product Feature]]></name> 
 <code>ocmod-productoption</code> 
 <version><![CDATA[1.0.0]]></version> 
 <author><![CDATA[OpencartWorks]]></author> 
 <link>http://www.OpencartWorks.com</link> 
 
<!--========Catalog/controller/product=============--> 
<file path="admin/language/*/catalog/product.php">
	<operation>
		 <search><![CDATA[// Entry]]></search>
		<add position="after"><![CDATA[
			// Backend Product Options
			$_['tab_feature']                     = 'SO Feature <span class="label label-primary">News</span>';
			$_['entry_video_link']                = 'Video youtube link';
			$_['entry_custom_tab_title']          = 'Title custom tab ';
			$_['entry_description_custom_tab']          = 'Description custom tab ';

		]]></add>
	</operation>
</file>
 <file path="admin/model/catalog/product.php">
	<operation>
		<search><![CDATA[$this->db->query("INSERT INTO " . DB_PREFIX . "product_description SET product_id = '" . (int)$product_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "', description = '" . $this->db->escape($value['description']) . "', tag = '" . $this->db->escape($value['tag']) . "', meta_title = '" . $this->db->escape($value['meta_title']) . "', meta_description = '" . $this->db->escape($value['meta_description']) . "', meta_keyword = '" . $this->db->escape($value['meta_keyword']) . "'");]]></search>
		<add position="replace"><![CDATA[
			if ($this->checkProductOptionColumnExist()) {
				$this->db->query("INSERT INTO " . DB_PREFIX . "product_description SET product_id = '" . (int)$product_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "', description = '" . $this->db->escape($value['description']) . "', tag = '" . $this->db->escape($value['tag']) . "', meta_title = '" . $this->db->escape($value['meta_title']) . "', meta_description = '" . $this->db->escape($value['meta_description']) . "', meta_keyword = '" . $this->db->escape($value['meta_keyword']) . "', video = '" . $this->db->escape($value['video']) . "', tab_title = '" . $this->db->escape($value['tab_title']) . "', html_product_tab = '" . $this->db->escape($value['html_product_tab']) .  "'");
			}
			else {
				$this->db->query("INSERT INTO " . DB_PREFIX . "product_description SET product_id = '" . (int)$product_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "', description = '" . $this->db->escape($value['description']) . "', tag = '" . $this->db->escape($value['tag']) . "', meta_title = '" . $this->db->escape($value['meta_title']) . "', meta_description = '" . $this->db->escape($value['meta_description']) . "', meta_keyword = '" . $this->db->escape($value['meta_keyword']) . "'");
			}
		]]></add>
	</operation>
	<operation>
		<search><![CDATA[public function getTotalProductsByTaxClassId($tax_class_id) {]]></search>
		<add position="before"><![CDATA[
			public function checkProductOptionColumnExist() {
				$sql = "SHOW COLUMNS FROM " .DB_PREFIX. "product_description LIKE 'video'";
				$query = $this->db->query($sql);
				return count($query->rows)>0 ? true : false;
			}
		]]></add>
	</operation>
	<operation>
		<search><![CDATA[$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_description WHERE product_id = '" . (int)$product_id . "'");]]></search>
		<add position="after" offset="2"><![CDATA[
			$product_video = array();
			$product_tabtitle = array();
			$product_tabproduct = array();
			if(isset($result['video']))$product_video = $result['video'];
			if(isset($result['tab_title']))$product_tabtitle = $result['tab_title'];
			if(isset($result['html_product_tab']))$product_tabproduct = $result['html_product_tab'];
						 
		]]></add>
	</operation>
	<operation>
		<search><![CDATA['tag'              => $result['tag']]]></search>
		<add position="before" offset="2"><![CDATA[
			'video'               => $product_video,
			'tab_title'          => $product_tabtitle,
			'html_product_tab'    => $product_tabproduct,             
		]]></add>
	</operation>
	
	
</file>

<file path="admin/controller/catalog/product.php">
	<operation>
		<search><![CDATA[$data['products'][] = array]]></search>
		<add position="before" ><![CDATA[
		$product_video = array();
		$product_tabtitle = array();
		if(isset($result['video'])){$product_video = $result['video'];}
		if(isset($result['tab_title'])){$product_tabtitle = $result['tab_title'];}
		]]></add>
	</operation>
	<operation>
		<search><![CDATA[$data['products'][] = array]]></search>
		<add position="after" offset="2"><![CDATA['video'               => $product_video,
			'tab_title'          => $product_tabtitle,]]></add>
	</operation>
	<operation>
            <search><![CDATA[$data['layouts'] = $this->model_design_layout->getLayouts();]]></search>
            <add position="after"><![CDATA[
                $checkProductOptionColumn = "SHOW COLUMNS FROM " .DB_PREFIX. "product_description LIKE 'video'";
				$querycheckProductOption = $this->db->query($checkProductOptionColumn);
				$data['checkProductOption']= !empty($querycheckProductOption->rows) ? true : false;]]></add>
    </operation>
</file> 
<file path="admin/view/template/catalog/product_list.twig">
	<operation>
		<search><![CDATA[<td class="text-left">{{ product.name }}</td>]]></search>
		<add position="replace"><![CDATA[
			<td class="text-left">{{ product.name }} {% if product.video or product.tab_title %}<span class="label label-primary">SO Feature</span>{% endif %}</td>
		]]>
		</add>
	</operation>
</file> 
<file path="admin/view/template/catalog/product_form.twig">
	<operation>
		<search><![CDATA[<li class="active"><a href="#tab-general" data-toggle="tab">{{ tab_general }}</a></li>]]></search>
		<add position="after"><![CDATA[{% if checkProductOption %}<li><a href="#tab-soproduct" data-toggle="tab">{{ tab_feature }}</a></li>{% endif %}]]>
		</add>
	</operation>
	<operation>
		<search><![CDATA[ <div class="tab-pane" id="tab-data">]]></search>
		<add position="before"><![CDATA[
			{% if checkProductOption %}
			 <div class="tab-pane" id="tab-soproduct">
              <ul class="nav nav-tabs" id="solanguage">
                {% for language in languages %}
                <li><a href="#solanguage{{ language.language_id }}" data-toggle="tab"><img src="language/{{ language.code }}/{{ language.code }}.png" title="{{ language.name }}" /> {{ language.name }}</a></li>
                {% endfor %}
              </ul>
              <div class="tab-content">
                {% for language in languages %}
                <div class="tab-pane" id="solanguage{{ language.language_id }}">
                    <div class="form-group ">
                        <label class="col-sm-2 control-label" for="input-video{{ language.language_id }}">
                            <strong style="color:red">NEW! </strong>
                            <span data-toggle="tooltip" title="" data-original-title="Enter full video thumbnail link on Product Page"> {{entry_video_link}} </span>
                            <div style="font-weight:normal;">
                                (e.g. https://www.youtube.com/watch?v=Wdtw_A5FDGs)
                            </div>
                        </label>
                        <div class="col-sm-10">

                          <input type="text" name="product_description[{{ language.language_id }}][video]" value="{{ product_description[language.language_id] ? product_description[language.language_id].video }}" placeholder="{{ entry_video_link }}" id="input-video{{ language.language_id }}" class="form-control" />
                         
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label" >
                            <strong style="color:red">NEW! </strong>
                            <span data-toggle="tooltip" title="" data-original-title="Enter title for custom tab on Product Page"> {{entry_custom_tab_title}} </span>
                        </label>

                        <div class="col-sm-10">
                          <input type="text" name="product_description[{{ language.language_id }}][tab_title]" value="{{ product_description[language.language_id] ? product_description[language.language_id].tab_title }}" placeholder="{{ entry_custom_tab_title }}" id="input-tab-title{{ language.language_id }}" class="form-control" />
                         
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label" >
                            <strong style="color:red">NEW! </strong>
                            <span data-toggle="tooltip" title="" data-original-title="Enter any html content for custom tab on Product Page">
                               {{ entry_description_custom_tab }}</span>
                        </label>

                        <div class="col-sm-10">
                          <textarea name="product_description[{{ language.language_id }}][html_product_tab]" placeholder="{{ entry_description }}" id="input-html_product_tab{{ language.language_id }}" data-toggle="summernote" data-lang="{{ summernote }}" class="form-control">{{ product_description[language.language_id] ? product_description[language.language_id].html_product_tab }}</textarea>
                        </div>
                    </div>
                  
             
                </div>
                {% endfor %}
                </div>
            </div>
			<script type="text/javascript"><!--
			$('#tab-soproduct .nav-tabs > li:first').tab('show');
			$('#tab-soproduct .tab-content > .tab-pane:first').addClass('active');
			--> 
			</script> 
			{% endif %}
		]]>
		</add>
	</operation>
</file> 

 <file path="catalog/controller/product/product.php"> 
 <operation> 
 <search ><![CDATA[$data['options'] = array();]]></search> 
	 <add position="before"><![CDATA[ 
	$productoption_info = $this->model_extension_soconfig_general->getProduct($product_id);
	$data['product_video'] = array();
	$data['product_tabtitle'] = array();
	$data['product_tabcontent'] = array();
	if(isset($productoption_info['video'])) $data['product_video'] = $productoption_info['video'];
	if(isset($productoption_info['tab_title'])) $data['product_tabtitle'] = $productoption_info['tab_title'];
	if(isset($productoption_info['html_product_tab'])) $data['product_tabcontent'] = html_entity_decode($productoption_info['html_product_tab'], ENT_QUOTES, 'UTF-8');
	 ]]></add> 
 </operation> 
 </file> 
</modification> 