<?xml version="1.0" encoding="UTF-8"?>
<modification>
	<name>Hızlı Ürün Aç / Kapa</name>
	<version>1.04</version>
	<author>info@yesilkare.com</author>
	<link>https://www.yesilkare.com</link>
	<code>enable-disable-products</code>
	<file path="admin/view/template/catalog/product_list.tpl">
		<operation>
			<search index="0"><![CDATA[
<div class="pull-right">
			]]></search>
			<add position="replace"><![CDATA[
<!-- EnableDisable -->
      <div class="pull-right">
		<span style="padding-right:20px;">
        <button type="button" data-toggle="tooltip" title="<?php echo $button_enable_product; ?>" class="btn btn-success" onclick="$('#form-product').attr('action', '<?php echo $enable_product; ?>'); $('#form-product').submit();"><i class="fa fa-plus"></i></button>
        <button type="button" data-toggle="tooltip" title="<?php echo $button_disable_product; ?>" class="btn btn-danger" onclick="$('#form-product').attr('action', '<?php echo $disable_product; ?>'); $('#form-product').submit();"><i class="fa fa-minus"></i></button>
		</span>
		<span style="padding-right:10px;">
	  <a href="<?php echo $enable_all; ?>" data-toggle="tooltip" title="<?php echo $button_enable_all; ?>" data-confirm="<?php echo $button_enable_all; ?>" class="btn btn-success"><i class="fa fa-check"></i></a>
	  <a href="<?php echo $disable_all; ?>" data-toggle="tooltip" title="<?php echo $button_disable_all; ?>" data-confirm="<?php echo $button_disable_all; ?>" class="btn btn-danger"><i class="fa fa-power-off"></i></a>
		</span>
<!-- EnableDisable -->
			]]></add>
		</operation>
		<operation>
			<search><![CDATA[
<?php echo $button_filter; ?></button>
			]]></search>
			<add position="after"><![CDATA[
<!-- EnableDisable -->
			  <div class="pull-right">&nbsp;</div>
              <button type="button" id="button-clear" class="btn btn-info pull-right"><i class="fa fa-eraser"></i> Clear</button>
<!-- EnableDisable -->
			]]></add>
		</operation>
		<operation>
			<search><![CDATA[
<?php echo $footer; ?>
			]]></search>
			<add position="before"><![CDATA[
<!-- EnableDisable -->
<script type="text/javascript"><!--
$(document).ready(function() {
	$('a[data-confirm]').click(function(ev) {
		var href = $(this).attr('href');
		if (!$('#dataConfirmModal').length) {
			$('body').append('<div id="dataConfirmModal" class="modal" role="dialog" aria-labelledby="dataConfirmLabel" aria-hidden="true"><div class="modal-dialog"><div class="modal-content"><div class="modal-body"></div><div class="modal-footer"><button class="btn btn-default" data-dismiss="modal" aria-hidden="true"><?php echo $text_no; ?></button><a class="btn btn-danger" id="dataConfirmOK"><?php echo $text_yes; ?></a></div></div></div></div>');
		} 
		$('#dataConfirmModal').find('.modal-body').text($(this).attr('data-confirm')+' ?');
		$('#dataConfirmOK').attr('href', href);
		$('#dataConfirmModal').modal({show:true});
		return false;
	});
});

$('#button-clear').on('click', function() {
	$('select[class=\'form-control\']').val('*');
	$('input[class=\'form-control\']').val('');
	$('#button-filter').click();
	// return false;
});

$('input[class=\'form-control\']').keydown(function(e) {
	if (e.keyCode == 13) {
		$('#button-filter').click();
	}
});
//--></script>
			]]></add>
		</operation>
	</file>

<!-- 2102 -->
	<file path="admin/controller/catalog/product.php">
		<operation error="skip">
			<search><![CDATA[
$data['delete'] = $this->url->link('catalog/product/delete', 'token=' . $this->session->data['token'] . $url, 'SSL');
			]]></search>
			<add position="after"><![CDATA[
		// EnableDisable
			$data['enable_all'] = $this->url->link('catalog/product/enable_all', 'token=' . $this->session->data['token'] . $url, 'SSL');
			$data['disable_all'] = $this->url->link('catalog/product/disable_all', 'token=' . $this->session->data['token'] . $url, 'SSL');
			$data['enable_product'] = $this->url->link('catalog/product/enable_product', 'token=' . $this->session->data['token'] . $url, 'SSL');
			$data['disable_product'] = $this->url->link('catalog/product/disable_product', 'token=' . $this->session->data['token'] . $url, 'SSL');
		// EnableDisable end
			]]></add>
		</operation>
	</file>

<!-- 2200 -->
	<file path="admin/controller/catalog/product.php">
		<operation error="skip">
			<search><![CDATA[
$data['delete'] = $this->url->link('catalog/product/delete', 'token=' . $this->session->data['token'] . $url, true);
			]]></search>
			<add position="after"><![CDATA[
		// EnableDisable
			$data['enable_all'] = $this->url->link('catalog/product/enable_all', 'token=' . $this->session->data['token'] . $url, true);
			$data['disable_all'] = $this->url->link('catalog/product/disable_all', 'token=' . $this->session->data['token'] . $url, true);
			$data['enable_product'] = $this->url->link('catalog/product/enable_product', 'token=' . $this->session->data['token'] . $url, true);
			$data['disable_product'] = $this->url->link('catalog/product/disable_product', 'token=' . $this->session->data['token'] . $url, true);
		// EnableDisable end
			]]></add>
		</operation>
	</file>

	<file path="admin/controller/catalog/product.php">
		<operation>
			<search><![CDATA[
$data['button_delete'] = $this->language->get('button_delete');
			]]></search>
			<add position="after"><![CDATA[
		// EnableDisable
			$data['token'] = $this->session->data['token'];
			$data['text_yes'] = $this->language->get('text_yes');
			$data['text_no'] = $this->language->get('text_no');
			$data['button_enable_all'] = $this->language->get('button_enable_all');
			$data['button_disable_all'] = $this->language->get('button_disable_all');
			$data['button_enable_product'] = $this->language->get('button_enable_product');
			$data['button_disable_product'] = $this->language->get('button_disable_product');
		// EnableDisable end
			]]></add>
		</operation>
		<operation>
			<search><![CDATA[
public function delete() {
			]]></search>
			<add position="before"><![CDATA[
		// EnableDisable
	public function disable_all() {
		$this->load->language('catalog/product');
 
		$this->document->setTitle($this->language->get('heading_title'));
		
		$this->load->model('catalog/product');

		if (!$this->user->hasPermission('modify', 'catalog/product')) {
			$this->error['warning'] = $this->language->get('error_permission');

		} else {
			
			$this->model_catalog_product->disableAllProduct();
			
			$this->session->data['success'] = $this->language->get('text_success');

			$url = '';

			if (isset($this->request->get['filter_name'])) {
				$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
			}

			if (isset($this->request->get['filter_model'])) {
				$url .= '&filter_model=' . urlencode(html_entity_decode($this->request->get['filter_model'], ENT_QUOTES, 'UTF-8'));
			}

			if (isset($this->request->get['filter_price'])) {
				$url .= '&filter_price=' . $this->request->get['filter_price'];
			}

			if (isset($this->request->get['filter_quantity'])) {
				$url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
			}

			if (isset($this->request->get['filter_status'])) {
				$url .= '&filter_status=' . $this->request->get['filter_status'];
			}

			if (isset($this->request->get['sort'])) {
				$url .= '&sort=' . $this->request->get['sort'];
			}

			if (isset($this->request->get['order'])) {
				$url .= '&order=' . $this->request->get['order'];
			}

			if (isset($this->request->get['page'])) {
				$url .= '&page=' . $this->request->get['page'];
			}

			if (VERSION >= '2.2') {
				$this->response->redirect($this->url->link('catalog/product', 'token=' . $this->session->data['token'] . $url, true));
			} else {
				$this->response->redirect($this->url->link('catalog/product', 'token=' . $this->session->data['token'] . $url, 'SSL'));
			}
		}

		$this->getList();
	}

	public function enable_all() {
		$this->language->load('catalog/product');
 
		$this->document->setTitle($this->language->get('heading_title'));
		
		$this->load->model('catalog/product');

		if (!$this->user->hasPermission('modify', 'catalog/product')) {
			$this->error['warning'] = $this->language->get('error_permission');

		} else {
			
			$this->model_catalog_product->enableAllProduct();
			
			$this->session->data['success'] = $this->language->get('text_success');

			$url = '';

			if (isset($this->request->get['filter_name'])) {
				$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
			}

			if (isset($this->request->get['filter_model'])) {
				$url .= '&filter_model=' . urlencode(html_entity_decode($this->request->get['filter_model'], ENT_QUOTES, 'UTF-8'));
			}

			if (isset($this->request->get['filter_price'])) {
				$url .= '&filter_price=' . $this->request->get['filter_price'];
			}

			if (isset($this->request->get['filter_quantity'])) {
				$url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
			}

			if (isset($this->request->get['filter_status'])) {
				$url .= '&filter_status=' . $this->request->get['filter_status'];
			}

			if (isset($this->request->get['sort'])) {
				$url .= '&sort=' . $this->request->get['sort'];
			}

			if (isset($this->request->get['order'])) {
				$url .= '&order=' . $this->request->get['order'];
			}

			if (isset($this->request->get['page'])) {
				$url .= '&page=' . $this->request->get['page'];
			}

			if (VERSION >= '2.2') {
				$this->response->redirect($this->url->link('catalog/product', 'token=' . $this->session->data['token'] . $url, true));
			} else {
				$this->response->redirect($this->url->link('catalog/product', 'token=' . $this->session->data['token'] . $url, 'SSL'));
			}
		}

		$this->getList();
	}

	public function enable_product() {
		$this->language->load('catalog/product');
 
		$this->document->setTitle($this->language->get('heading_title'));
		
		$this->load->model('catalog/product');

		if (isset($this->request->post['selected']) && $this->validateDelete()) {
			foreach ($this->request->post['selected'] as $product_id) {
			$this->model_catalog_product->enableProduct($product_id);
			}

			$this->session->data['success'] = $this->language->get('text_success');

			$url = '';

			if (isset($this->request->get['filter_name'])) {
				$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
			}

			if (isset($this->request->get['filter_model'])) {
				$url .= '&filter_model=' . urlencode(html_entity_decode($this->request->get['filter_model'], ENT_QUOTES, 'UTF-8'));
			}

			if (isset($this->request->get['filter_price'])) {
				$url .= '&filter_price=' . $this->request->get['filter_price'];
			}

			if (isset($this->request->get['filter_quantity'])) {
				$url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
			}

			if (isset($this->request->get['filter_status'])) {
				$url .= '&filter_status=' . $this->request->get['filter_status'];
			}

			if (isset($this->request->get['sort'])) {
				$url .= '&sort=' . $this->request->get['sort'];
			}

			if (isset($this->request->get['order'])) {
				$url .= '&order=' . $this->request->get['order'];
			}

			if (isset($this->request->get['page'])) {
				$url .= '&page=' . $this->request->get['page'];
			}

			if (VERSION >= '2.2') {
				$this->response->redirect($this->url->link('catalog/product', 'token=' . $this->session->data['token'] . $url, true));
			} else {
				$this->response->redirect($this->url->link('catalog/product', 'token=' . $this->session->data['token'] . $url, 'SSL'));
			}
		}

		$this->getList();
	}

	public function disable_product() {
		$this->language->load('catalog/product');
 
		$this->document->setTitle($this->language->get('heading_title'));
		
		$this->load->model('catalog/product');

		if (isset($this->request->post['selected']) && $this->validateDelete()) {
			foreach ($this->request->post['selected'] as $product_id) {
			$this->model_catalog_product->disableProduct($product_id);
			}

			$this->session->data['success'] = $this->language->get('text_success');

			$url = '';

			if (isset($this->request->get['filter_name'])) {
				$url .= '&filter_name=' . urlencode(html_entity_decode($this->request->get['filter_name'], ENT_QUOTES, 'UTF-8'));
			}

			if (isset($this->request->get['filter_model'])) {
				$url .= '&filter_model=' . urlencode(html_entity_decode($this->request->get['filter_model'], ENT_QUOTES, 'UTF-8'));
			}

			if (isset($this->request->get['filter_price'])) {
				$url .= '&filter_price=' . $this->request->get['filter_price'];
			}

			if (isset($this->request->get['filter_quantity'])) {
				$url .= '&filter_quantity=' . $this->request->get['filter_quantity'];
			}

			if (isset($this->request->get['filter_status'])) {
				$url .= '&filter_status=' . $this->request->get['filter_status'];
			}

			if (isset($this->request->get['sort'])) {
				$url .= '&sort=' . $this->request->get['sort'];
			}

			if (isset($this->request->get['order'])) {
				$url .= '&order=' . $this->request->get['order'];
			}

			if (isset($this->request->get['page'])) {
				$url .= '&page=' . $this->request->get['page'];
			}

			if (VERSION >= '2.2') {
				$this->response->redirect($this->url->link('catalog/product', 'token=' . $this->session->data['token'] . $url, true));
			} else {
				$this->response->redirect($this->url->link('catalog/product', 'token=' . $this->session->data['token'] . $url, 'SSL'));
			}
		}

		$this->getList();
	}
		// EnableDisable end
			]]></add>
		</operation>
	</file>

	<file path="admin/model/catalog/product.php">		
		<operation>
			<search><![CDATA[
public function getProduct($product_id) {
			]]></search>
			<add position="before"><![CDATA[
	// EnableDisable
		public function disableAllProduct() {
			$query = $this->db->query("UPDATE " . DB_PREFIX . "product SET `status`='0' ");
			$this->cache->delete('product');
		}

		public function enableAllProduct() {
			$query = $this->db->query("UPDATE " . DB_PREFIX . "product SET `status`='1' ");
			$this->cache->delete('product');
		}

		public function enableProduct($product_id) {
			$this->db->query("UPDATE " . DB_PREFIX . "product SET `status`='1' WHERE product_id = '" . (int)$product_id . "'");
			$this->cache->delete('product');	
		}

		public function disableProduct($product_id) {
			$this->db->query("UPDATE " . DB_PREFIX . "product SET `status`='0' WHERE product_id = '" . (int)$product_id . "'");
			$this->cache->delete('product');	
		}
	// EnableDisable end
			]]></add>
		</operation>
	</file>

	<file path="admin/language/russian/catalog/product.php">		
		<operation error="skip">
			<search><![CDATA[
<?php
			]]></search>
			<add position="after"><![CDATA[
			// EnableDisable
				$_['button_enable_all']    = 'Включить все товары';
				$_['button_disable_all']   = 'Отключить все товары';
				$_['button_enable_product']    = 'Включить выбранные';
				$_['button_disable_product']   = 'Отключить выбранные';
			// EnableDisable end
			]]></add>
		</operation>
	</file>
	<file path="admin/language/ru-ru/catalog/product.php">		
		<operation error="skip">
			<search><![CDATA[
<?php
			]]></search>
			<add position="after"><![CDATA[
			// EnableDisable
				$_['button_enable_all']    = 'Включить все товары';
				$_['button_disable_all']   = 'Отключить все товары';
				$_['button_enable_product']    = 'Включить выбранные';
				$_['button_disable_product']   = 'Отключить выбранные';
			// EnableDisable end
			]]></add>
		</operation>
	</file>
	<file path="admin/language/english/catalog/product.php">		
		<operation error="skip">
			<search><![CDATA[
<?php
			]]></search>
			<add position="after"><![CDATA[
			// EnableDisable
				$_['button_enable_all']    = 'Enable All Products';
				$_['button_disable_all']   = 'Disable All Products';
				$_['button_enable_product']    = 'Enable Selected';
				$_['button_disable_product']   = 'Disable Selected';
			// EnableDisable end
			]]></add>
		</operation>
	</file>
	<file path="admin/language/tr-tr/catalog/product.php">		
		<operation error="skip">
			<search><![CDATA[
<?php
			]]></search>
			<add position="after"><![CDATA[
			// EnableDisable
				$_['button_enable_all']    = 'Tüm Ürünleri Açık Yap';
				$_['button_disable_all']   = 'Tüm Ürünleri Kapalı Yap';
				$_['button_enable_product']    = 'Seçili Olanları Açık Yap';
				$_['button_disable_product']   = 'Seçili Olanları Kapalı Yap';
			// EnableDisable end
			]]></add>
		</operation>
	</file>
</modification>