<modification>
	<name>Advanced Postcode Manager (cartbinder@gmail.com)</name>
	<version>6.1</version>
	<link>http://www.opencart.com/index.php?route=extension/extension/info&amp;extension_id=17980</link>
	<author>CartBinder.com</author>
	<code>apcm</code>
	<file path="admin/controller/common/menu.php">
		<operation>
			<search><![CDATA[$data['text_zone']]]></search>
			<add position="before"><![CDATA[$data['text_pin'] = $this->language->get('text_pin');
				$data['text_pinlist'] = $this->language->get('text_pinlist');
				$data['text_pinsetting'] = $this->language->get('text_pinsetting');
				$data['text_pinimport'] = $this->language->get('text_pinimport');
				$data['text_pinnew'] = $this->language->get('text_pinnew');
				]]></add>
		</operation>
		<operation>
			<search><![CDATA[$data['zone']]]></search>
			<add position="before"><![CDATA[$data['pinlist'] = $this->url->link('tool/indianpin','token=' . $this->session->data['token']);
				$data['pinsetting'] = $this->url->link('tool/pinsetting','token=' . $this->session->data['token']);
				$data['pinimport'] = $this->url->link('tool/pinimport','token=' . $this->session->data['token']);
				$data['pinnew'] = $this->url->link('tool/pinnew','token=' . $this->session->data['token']);
				]]></add>
		</operation>
	</file>
	<file path="admin/language/*/common/menu.php">
		<operation>
			<search><![CDATA[
				$_['text_zone']
				]]>
			</search>
			<add position="before">
				<![CDATA[
				$_['text_pin']              = 'Advanced Postcode';
				$_['text_pinlist']        = 'Postcode List';
				$_['text_pinsetting']    = 'Postcode Settings';
				$_['text_pinimport']    = 'Import / Export Postcode';
				$_['text_pinnew']    = 'New Postal Codes';
				]]>
			</add>
		</operation>
	</file>
	<file path="admin/view/template/common/menu.tpl">
		<operation>
			<search><![CDATA[<li><a href="<?php echo $error_log; ?>"><?php echo $text_error_log; ?></a></li>]]></search>
			<add position="before"><![CDATA[
				<li><a class="parent"><?php echo $text_pin; ?></a>
				            <ul>
				            	<li><a href="<?php echo $pinlist; ?>"><?php echo $text_pinlist; ?></a></li>
				                <li><a href="<?php echo $pinsetting; ?>"><?php echo $text_pinsetting; ?></a></li>
				                <li><a href="<?php echo $pinimport ; ?>"><?php echo $text_pinimport; ?></a></li>
				                <li><a href="<?php echo $pinnew ; ?>"><?php echo $text_pinnew; ?></a></li>
				            </ul>
				        </li>
				]]>
			</add>
		</operation>
	</file>
	<file path="catalog/controller/common/footer.php">
		<operation>
			<search><![CDATA[$this->load->language('common/footer');]]>
			</search>
			<add position="after"><![CDATA[
				$data['pincheckp_status'] = $this->config->get('imdev_config_postcodepopup');
				$data['pinpro'] = array();
				if($data['pincheckp_status'] && !isset($_COOKIE["postcodepopup"])) {
					$this->language->load('module/pincheck');
					$id = $this->config->get('config_language_id');
					$this->load->model('tool/pinpro');
					$data['pinpro'] = $this->model_tool_pinpro->getDynamic($id);
				}
			]]>
			</add>
		</operation>
		<operation>
			<search><![CDATA[public function index() {]]>
			</search>
			<add  position="before"><![CDATA[
				public function devpmcookie() {
					$id = $this->request->post['a'];
					setcookie($id,1);
				}
				]]>
			</add>
		</operation>
	</file>
	<file path="catalog/view/theme/*/template/common/footer.tpl">
		<operation>
			<search><![CDATA[</body>]]>
			</search>
			<add position="before"><![CDATA[         
				<?php if(!empty($pinpro)) { ?>
				<div class="remodal pincodepopup" id="postcodepopup" data-remodal-id="pincode" data-remodal-options="hashTracking: false">
					<button data-remodal-action="close" class="remodal-close"></button>
				<div class="box">
				  <div class="box-heading"><h3 class="checkpinheading"><i class="fa fa-map-marker" aria-hidden="true"></i> <?php echo $pinpro['header'] ?></h3></div>
				  <div class="box-content">
				    <?php if(!empty($pinpro)) { ?>
				        <div class="popuppostcode" style="background:<?php echo $pinpro['theme'] ?>">
				            <div class="pincode">
				                <input type="text" name="pincode" value="" placeholder="<?php echo $pinpro['message'] ?>">
				                <div class="search-postcode">Check availability !</div>
				                <label class="error"></label>
				            </div>
				             <div class="pmessage" style="color:<?php echo $pinpro['font'] ?>;background:<?php echo $pinpro['theme'] ?>;"></div>
				             <button data-remodal-action="cancel" class="remodal-cancel" style="display:none;">Search Again</button>
				             <button data-remodal-action="confirm" class="remodal-confirm" style="display:none;">Close</button>
				        </div>
				      <?php } ?>
				  </div>
				</div>
				</div>
				<?php } ?>
				]]>
			</add>
		</operation>
	</file>
	<file path="catalog/controller/common/header.php">
		<operation>
			<search><![CDATA[$data['base'] = $server;]]>
			</search>
			<add position="after"><![CDATA[
				$data['pincheckp_status'] = $this->config->get('imdev_config_postcodepopup');
				$this->document->addStyle('catalog/view/theme/default/stylesheet/pinpro.css');
				$this->document->addScript('catalog/view/javascript/jquery/pinpro.js');
				if($data['pincheckp_status']) {
					$this->document->addStyle('catalog/view/theme/default/stylesheet/remodal.css');
					$this->document->addScript('catalog/view/javascript/jquery/remodal.js');
				}]]>
			</add>
		</operation>
	</file>
	<file path="catalog/controller/account/register.php">
		<operation>
			<search><![CDATA[if ($country_info && $country_info['postcode_required']]]>
			</search>
			<add position="before"><![CDATA[
			if(isset( $this->request->post['postcode']) &&  $this->request->post['postcode'] != "" && $this->config->get('imdev_config_postcoderegister')) {
				$this->load->model('tool/pinpro');
				$data['pincode'] = $this->request->post['postcode'];
	           	$pinpro = $this->model_tool_pinpro->checkpin($data);
			
		    	if($pinpro['failed'] == '1') {
					$this->error['postcode'] = $pinpro['fail'];
		     	} else {
		     		$this->session->data['shipping_postcode'] = $this->request->post['postcode'];
		     	}
	     	}]]>
			</add>
		</operation>
		<operation>
			<search><![CDATA[$data['postcode'] = $this->session->data['shipping_address']['postcode'];]]>
			</search>
			<add position="after"><![CDATA[
			} else if(isset($this->session->data['shipping_postcode'])) {
			$data['postcode'] = $this->session->data['shipping_postcode'];
			]]>
			</add>
		</operation>	
		<operation>
			<search><![CDATA[$data['country_id'] = $this->session->data['shipping_address']['country_id'];]]>
			</search>
			<add position="after"><![CDATA[
			} else if(isset($this->session->data['advancedpostcode']['country_id'])) {
				$data['country_id'] = $this->session->data['advancedpostcode']['country_id'];
			]]>
			</add>
		</operation>
		<operation>
			<search><![CDATA[$data['zone_id'] = $this->session->data['shipping_address']['zone_id'];]]>
			</search>
			<add position="after"><![CDATA[
			} else if(isset($this->session->data['advancedpostcode']['zone_id'])) {
				$data['zone_id'] = $this->session->data['advancedpostcode']['zone_id'];
			]]>
			</add>
		</operation>	
	</file>
	<file path="catalog/controller/account/address.php">
		<operation>
			<search><![CDATA[if ($country_info && $country_info['postcode_required']]]>
			</search>
			<add position="before"><![CDATA[
			if(isset( $this->request->post['postcode']) &&  $this->request->post['postcode'] != "" && $this->config->get('imdev_config_postcoderegister')) {
				$this->load->model('tool/pinpro');
				$data['pincode'] = $this->request->post['postcode'];
	           	$pinpro = $this->model_tool_pinpro->checkpin($data);
			
		    	if($pinpro['failed'] == '1') {
					$this->error['postcode'] = $pinpro['fail'];
		     	} else {
		     		$this->session->data['shipping_postcode'] = $this->request->post['postcode'];
		     	}
	     	}]]>
			</add>
		</operation>
		<operation>
			<search><![CDATA[$data['postcode'] = $address_info['postcode'];]]>
			</search>
			<add position="after"><![CDATA[
				} else if(isset($this->session->data['shipping_postcode'])) {
			$data['postcode'] = $this->session->data['shipping_postcode'];
			]]>
			</add>
		</operation>
		
	</file>
	<file path="catalog/controller/checkout/register.php">
		<operation>
			<search><![CDATA[if ($this->request->post['country_id'] == '') {]]>
			</search>
			<add position="before"><![CDATA[
			if(isset($this->request->post['postcode']) &&  $this->request->post['postcode'] != "" && !empty($this->request->post['shipping_address']) && $this->config->get('imdev_config_postcoderegister')) {
				$this->load->model('tool/pinpro');
				$data['pincode'] = $this->request->post['postcode'];
	           	$pinpro = $this->model_tool_pinpro->checkpin($data);
			
		    	if($pinpro['failed'] == '1') {
					$json['error']['postcode'] = $pinpro['fail'];
		     	}  else {
		     		$this->session->data['shipping_postcode'] = $this->request->post['postcode'];
		     	}
	     	}]]>
			</add>
		</operation>
		<operation>
			<search><![CDATA[$data['postcode'] = $this->session->data['shipping_address']['postcode'];]]>
			</search>
			<add position="after"><![CDATA[
			} else if(isset($this->session->data['shipping_postcode'])) {
			$data['postcode'] = $this->session->data['shipping_postcode'];
			]]>
			</add>
		</operation>
		<operation>
			<search><![CDATA[$data['country_id'] = $this->session->data['shipping_address']['country_id'];]]>
			</search>
			<add position="after"><![CDATA[
			} else if(isset($this->session->data['advancedpostcode']['country_id'])) {
				$data['country_id'] = $this->session->data['advancedpostcode']['country_id'];
			]]>
			</add>
		</operation>
		<operation>
			<search><![CDATA[$data['zone_id'] = $this->session->data['shipping_address']['zone_id'];]]>
			</search>
			<add position="after"><![CDATA[
			} else if(isset($this->session->data['advancedpostcode']['zone_id'])) {
				$data['zone_id'] = $this->session->data['advancedpostcode']['zone_id'];
			]]>
			</add>
		</operation>
	</file>
	<file path="catalog/controller/checkout/guest.php">
		<operation>
			<search><![CDATA[if ($this->request->post['country_id'] == '') {]]>
			</search>
			<add position="before"><![CDATA[
			if(isset($this->request->post['postcode']) &&  $this->request->post['postcode'] != "" && !empty($this->request->post['shipping_address']) && $this->config->get('imdev_config_postcoderegister')) {
				$this->load->model('tool/pinpro');
				$data['pincode'] = $this->request->post['postcode'];
	           	$pinpro = $this->model_tool_pinpro->checkpin($data);
			
		    	if($pinpro['failed'] == '1') {
					$json['error']['postcode'] = $pinpro['fail'];
		     	}  else {
		     		$this->session->data['shipping_postcode'] = $this->request->post['postcode'];
		     	}
	     	}]]>
			</add>
		</operation>
		<operation>
			<search><![CDATA[$data['postcode'] = $this->session->data['shipping_address']['postcode'];]]>
			</search>
			<add position="after"><![CDATA[
			} else if(isset($this->session->data['shipping_postcode'])) {
			$data['postcode'] = $this->session->data['shipping_postcode'];
			]]>
			</add>
		</operation>
		<operation>
			<search><![CDATA[$data['country_id'] = $this->session->data['shipping_address']['country_id'];]]>
			</search>
			<add position="after"><![CDATA[
			} else if(isset($this->session->data['advancedpostcode']['country_id'])) {
				$data['country_id'] = $this->session->data['advancedpostcode']['country_id'];
			]]>
			</add>
		</operation>
		<operation>
			<search><![CDATA[$data['zone_id'] = $this->session->data['shipping_address']['zone_id'];]]>
			</search>
			<add position="after"><![CDATA[
			} else if(isset($this->session->data['advancedpostcode']['zone_id'])) {
				$data['zone_id'] = $this->session->data['advancedpostcode']['zone_id'];
			]]>
			</add>
		</operation>
	</file>
	<file path="catalog/controller/checkout/shipping_address.php">
		<operation>
			<search><![CDATA[$this->session->data['shipping_address'] = $this->model_account_address->getAddress($this->request->post['address_id']);]]>
			</search>
			<add position="after"><![CDATA[
				$this->session->data['shipping_postcode'] = $this->session->data['shipping_address']['postcode'];
				if($this->config->get('imdev_config_postcoderegister')) {
					if($this->session->data['shipping_address']['postcode'] == "") {
						$json['error']['warning'] = "Address does not contain valid postcode";
					} else {
						$this->load->model('tool/pinpro');
						$data['pincode'] = $this->session->data['shipping_address']['postcode'];
			           	$pinpro = $this->model_tool_pinpro->checkpin($data);
					
				    	if($pinpro['failed'] == '1') {
							$json['error']['warning'] = $pinpro['fail'];	
				     	}  else {
				     		$this->session->data['shipping_postcode'] = $this->session->data['shipping_address']['postcode'];
				     	}
					}
				}]]>
			</add>
		</operation>
		<operation>
			<search><![CDATA[$data['postcode'] = $this->session->data['shipping_address']['postcode'];]]>
			</search>
			<add position="after"><![CDATA[
			} else if(isset($this->session->data['shipping_postcode'])) {
			$data['postcode'] = $this->session->data['shipping_postcode'];
			]]>
			</add>
		</operation>
		<operation>
			<search><![CDATA[$country_info = $this->model_localisation_country->getCountry($this->request->post['country_id']);]]>
			</search>
			<add position="after"><![CDATA[
					if($this->request->post['postcode'] != "" && $this->config->get('imdev_config_postcoderegister')) {
						$this->load->model('tool/pinpro');
						$data['pincode'] = $this->request->post['postcode'];
			           	$pinpro = $this->model_tool_pinpro->checkpin($data);
					
				    	if($pinpro['failed'] == '1') {
							$json['error']['postcode'] = $pinpro['fail'];
				     	}  else {
				     		$this->session->data['shipping_postcode'] = $this->request->post['postcode'];
				     	}
					}]]>
			</add>
		</operation>
		<operation>
			<search><![CDATA[$data['country_id'] = $this->session->data['shipping_address']['country_id'];]]>
			</search>
			<add position="after"><![CDATA[
			} else if(isset($this->session->data['advancedpostcode']['country_id'])) {
				$data['country_id'] = $this->session->data['advancedpostcode']['country_id'];
			]]>
			</add>
		</operation>
		<operation>
			<search><![CDATA[$data['zone_id'] = $this->session->data['shipping_address']['zone_id'];]]>
			</search>
			<add position="after"><![CDATA[
			} else if(isset($this->session->data['advancedpostcode']['zone_id'])) {
				$data['zone_id'] = $this->session->data['advancedpostcode']['zone_id'];
			]]>
			</add>
		</operation>
	</file>
	<file path="catalog/controller/checkout/guest_shipping.php">
		<operation>
			<search><![CDATA[if ($country_info && $country_info['postcode_required'] && (utf8_strlen(trim($this->request->post['postcode'])) < 2 || utf8_strlen(trim($this->request->post['postcode'])) > 10)) {]]>
			</search>
			<add position="before"><![CDATA[
					if($this->request->post['postcode'] != "" && $this->config->get('imdev_config_postcoderegister')) {
						$this->load->model('tool/pinpro');
						$data['pincode'] = $this->request->post['postcode'];
			           	$pinpro = $this->model_tool_pinpro->checkpin($data);
					
				    	if($pinpro['failed'] == '1') {
							$json['error']['postcode'] = $pinpro['fail'];
				     	}  else {
				     		$this->session->data['shipping_postcode'] = $this->request->post['postcode'];
				     	}
					}
				]]>
			</add>
		</operation>
		<operation>
			<search><![CDATA[$data['postcode'] = $this->session->data['shipping_address']['postcode'];]]>
			</search>
			<add position="after"><![CDATA[
			} else if(isset($this->session->data['shipping_postcode'])) {
			$data['postcode'] = $this->session->data['shipping_postcode'];
			]]>
			</add>
		</operation>
		<operation>
			<search><![CDATA[$data['country_id'] = $this->session->data['shipping_address']['country_id'];]]>
			</search>
			<add position="after"><![CDATA[
			} else if(isset($this->session->data['advancedpostcode']['country_id'])) {
				$data['country_id'] = $this->session->data['advancedpostcode']['country_id'];
			]]>
			</add>
		</operation>
		<operation>
			<search><![CDATA[$data['zone_id'] = $this->session->data['shipping_address']['zone_id'];]]>
			</search>
			<add position="after"><![CDATA[
			} else if(isset($this->session->data['advancedpostcode']['zone_id'])) {
				$data['zone_id'] = $this->session->data['advancedpostcode']['zone_id'];
			]]>
			</add>
		</operation>
	</file>
	<file path="catalog/controller/checkout/payment_method.php">
		<operation>
			<search><![CDATA[$results = $this->model_extension_extension->getExtensions('payment');]]>
			</search>
			<add position="after"><![CDATA[
						if(isset($this->session->data['shipping_postcode'])) {
							$this->load->model('tool/pinpro');
							$payments = $this->model_tool_pinpro->getPayments($this->session->data['shipping_postcode']);
							foreach($results as $key => $value) {
								if(!in_array($value['extension_id'],$payments)) {
									unset($results[$key]);
								}
							}
						}
					]]>
			</add>
		</operation>
	</file>
	<file path="catalog/controller/checkout/shipping_method.php">
		<operation>
			<search><![CDATA[$results = $this->model_extension_extension->getExtensions('shipping');]]>
			</search>
			<add position="after"><![CDATA[
					if(isset($this->session->data['shipping_address']) && $this->config->get("imdev_config_pinshippingmethod")) {
							$this->load->model('tool/pinpro');
							$shippings = $this->model_tool_pinpro->getShippings($this->session->data['shipping_address']['postcode']);
							foreach($results as $key => $value) {
								if(!in_array($value['extension_id'],$shippings)) {
									unset($results[$key]);
								}
							}
						}
					]]>
			</add>
		</operation>
	</file>
	<file path="catalog/controller/product/product.php">
		<operation>
			<search><![CDATA[if ($product_info['minimum']) {]]>
			</search>
			<add position="before"><![CDATA[
		if($this->config->get('imdev_config_postcodeproduct')) {
		    $id = $this->config->get('config_language_id');
		    $this->load->model('tool/pinpro');
 		    $data['pinpro'] = $this->model_tool_pinpro->getDynamic($id);
		} else {
			$data['pinpro'] = array();
		}]]>
			</add>
		</operation>
	</file>
	<file path="catalog/view/theme/*/template/product/product.tpl">
		<operation>
			<search><![CDATA[<?php if ($options) { ?>]]>
			</search>
			<add position="before"><![CDATA[<?php if(!empty($pinpro)) { ?>
				<h3 class="checkpinheading"><i class="fa fa-map-marker" aria-hidden="true"></i> <?php echo $pinpro['header'] ?></h3>
        <div class="popupfixed" style="background:<?php echo $pinpro['theme'] ?>"><div class="pincode"><input class="form-control" type="text" name="pincode" value="" placeholder="<?php echo $pinpro['message'] ?>"><div class="search-postcode">Check availability !</div><label class="error"></label></div>
        <div class="pmessage" style="color:<?php echo $pinpro['font'] ?>;background:<?php echo $pinpro['theme'] ?>;"></div>
    </div>
      <?php } ?>]]>
			</add>
		</operation>
	</file>
		<file path="admin/view/template/module/pincheck.tpl">
    <operation>
      <search><![CDATA[</form>]]></search>
      <add  position="after"><![CDATA[
       <div class="pull-right">
          <a data-toggle="tooltip" title="Create a new support request" class="btn btn-primary" target="_blank" href="http://support.cartbinder.com/open.php"><i class="fa fa-life-ring"></i> Support</a>
           <a data-toggle="tooltip" title="Rate and Recommend Extension" class="btn btn-primary" target="_blank" href="http://www.opencart.com/index.php?route=extension/extension/info&extension_id=17980"><i class="fa fa-pencil-square-o"></i> Provide Extension Feedback</a>
       </div>
   ]]></add>
    </operation>
  </file>
</modification>