Advertisement
Guest User

availability

a guest
Mar 19th, 2015
585
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.40 KB | None | 0 0
  1. <?php
  2. /**
  3. * Magento
  4. *
  5. * NOTICE OF LICENSE
  6. *
  7. * This source file is subject to the Open Software License (OSL 3.0)
  8. * that is bundled with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://opensource.org/licenses/osl-3.0.php
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@magentocommerce.com so we can send you a copy immediately.
  14. *
  15. * @category Techinflo
  16. * @package Techinflo_Checkavailability
  17. * @copyright Techinflo(www.techinflo.com)
  18. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  19. */
  20. /**
  21. * Product view template
  22. *
  23. * @see Techinflo_Checkavailability_Block_view
  24. * @see Techinflo_Checkavailability_Block_view
  25. */
  26. ?>
  27. <?php if ($this->getIsActive()): ?>
  28. <?php $pid = Mage::registry('current_product')->getId(); ?>
  29. <?php $set = $this->cookieparams(); ?>
  30. <div class="chkavl">
  31. <div class="check-avail check-avail1" id="check-avail1"><a href="javascript:void(0);"><?php
  32. if ((($_COOKIE["avl_pin_code"] != '') && isset($_COOKIE["avl_pin_code"])) || (($_COOKIE["pin_code"] != '') && isset($_COOKIE["pin_code"]))) {
  33. if ($_COOKIE["avl_pin_code"] != '' && isset($_COOKIE["avl_pin_code"]))
  34. echo "<span>Location:" . $_COOKIE["avl_pin_code"] . "&nbsp;<span class='changepin'>Change</span></span>";
  35. if ($_COOKIE["pin_code"] != '' && isset($_COOKIE["pin_code"]))
  36. echo "<span>Location:" . $_COOKIE["pin_code"] . "&nbsp;<span class='changepin'>Change</span></span>";
  37. }else {
  38. echo "<span>Check Avaliabilty</span>";
  39. }
  40. ?></a></div>
  41.  
  42. <div id="check-data" >
  43. <input class="check-input" type="text" id="checkpin" name="checkpin" value="" />
  44. <div class="check-data"><button class="btn btn-gray" id="ckhbtn" type="button" onclick="chkavail();" ><span>check</span></button>
  45. <span id="loader" style="display:none;"><img src="<?php echo $this->getSkinUrl('css/techinflo/checkavailability/ajax-loader.gif'); ?>"></span></div>
  46. <div id="resp" style="display:none;"></div>
  47. </div>
  48. <div class="check-avail check-avail2" id="check-avail2" style="display:none;"><a href="javascript:void(0);">
  49.  
  50. <span>Hide</span>
  51. </a></div>
  52. <div id="location_msg" style="display:none"></div>
  53. <div id="location_msg_avl" style="display:none"></div>
  54. </div>
  55.  
  56.  
  57. <script>
  58. <?php if ((isset($_COOKIE["pin_code"]) && $_COOKIE["pin_code"] != '') || (isset($_COOKIE["avl_pin_code"]) && $_COOKIE["avl_pin_code"] != "")) { ?>
  59.  
  60. var cb = jQuery.noConflict();
  61. cb(document).ready(function() {
  62. var cb = jQuery.noConflict();
  63. cb("#resp").html('');
  64. var id = "<?php echo $pid; ?>";
  65. <?php if (isset($_COOKIE["pin_code"]) && $_COOKIE["pin_code"] != '') { ?>
  66. var pintext = "<?php echo $_COOKIE["pin_code"]; ?>";
  67. <?php } else { ?>
  68. var pintext = "<?php echo $_COOKIE["avl_pin_code"]; ?>";
  69. <?php } ?>
  70. url = "<?php echo Mage::getUrl('checkavl/index/detail') ?>" + 'id/' + id + '/pincode/' + pintext;
  71. cb("#loader").show();
  72. cb("#ckhbtn").hide();
  73.  
  74. cb.ajax({url: url, success: function(result) {
  75. var resp_result = cb.trim(result);
  76. var html = "";
  77. res = resp_result.split(",");
  78. if (res[0] == '1') {
  79. setCookie("avl_pin_code", '', 1);
  80. cb("#loader").hide();
  81. cb("#ckhbtn").show();
  82. cb(".add-to-qty").hide();
  83. //cb(".addwhis").hide();
  84. html = '<button class="button btn-cart" title="Add to Cart" type="button"><span>Add to Cart</span></button>';
  85. cb(".addbut").html(html);
  86. cb("#location_msg").show();
  87. cb("#location_msg_avl").hide();
  88. cb("#location_msg").text('<?php echo $this->failureMsg(); ?>');
  89. setCookie("pin_code", res[1], 1);
  90. cb("#check-avail1 a").html('<span class="lbl">Location:</span><span class="pinonly">' + res[1] + '</span>&nbsp;<span class="changepin">Change</span>');
  91. cb("#checkpin").val(cb.trim(res[1]));
  92. var response = "<span class='resp' style='color:red'><?php echo $this->failureMsg(); ?></span>";
  93. } else {
  94. cb("#check-avail1 a").html('<span class="lbl">Location:</span><span class="pinonly">' + result + '</span>&nbsp;<span class="changepin">Change</span>');
  95. cb("#loader").hide();
  96. cb("#ckhbtn").show();
  97. cb(".add-to-qty").show();
  98. setCookie("pin_code", '', 1);
  99. setCookie("avl_pin_code", result, 1);
  100. html = '<button onclick="productAddToCartForm.submit(this)" class="button btn-cart" title="Add to Cart" type="button"><span>Add to Cart</span></button>';
  101. cb(".addbut").html(html);
  102. cb("#location_msg").hide();
  103. cb("#checkpin").val(cb.trim(result));
  104. cb("#location_msg_avl").show();
  105. cb("#location_msg_avl").text('<?php echo $this->successMsg() ?>');
  106. var response = "<span class='resp' style='color:green'><?php echo $this->successMsg() ?>: " + result + "</span>";
  107. }
  108. cb("#resp").html(response);
  109. cb("#resp").show();
  110. }});
  111. return false;
  112. });
  113. <?php } ?>
  114. function chkavail() {
  115. var cb = jQuery.noConflict();
  116. cb("#resp").html('');
  117. var id = "<?php echo $pid; ?>";
  118. var pintext = cb("#checkpin").val();
  119. url = "<?php echo Mage::getUrl('checkavl/index/detail') ?>" + 'id/' + id + '/pincode/' + pintext;
  120. cb("#loader").show();
  121. cb("#ckhbtn").hide();
  122. cb.ajax({url: url, success: function(result) {
  123. var resp_result = cb.trim(result);
  124. var html = "";
  125. res = resp_result.split(",");
  126. if (res[0] == '1' && res[1] != '') {
  127. setCookie("avl_pin_code", '', 1);
  128. cb("#loader").hide();
  129. cb("#ckhbtn").show();
  130. cb(".add-to-qty").hide();
  131. html = '<button class="button btn-cart" title="Add to Cart" type="button"><span>Add to Cart</span></button>';
  132. cb(".addbut").html(html);
  133. cb("#location_msg").show();
  134. cb("#location_msg_avl").hide();
  135. cb("#location_msg").text('<?php echo $this->failureMsg(); ?>');
  136. setCookie("pin_code", res[1], 1);
  137. cb("#check-avail1 a").html('<span class="lbl">Location:</span><span class="pinonly">' + res[1] + '</span>&nbsp;<span class="changepin">Change</span>');
  138. var response = "<span class='resp' style='color:red'><?php echo $this->failureMsg(); ?></span>";
  139. } else {
  140. cb("#check-avail1 a").html('<span class="lbl">Location:</span><span class="pinonly">' + result + '</span>&nbsp;<span class="changepin">Change</span>');
  141. cb("#loader").hide();
  142. cb("#ckhbtn").show();
  143. cb(".add-to-qty").show();
  144. setCookie("pin_code", '', 1);
  145. setCookie("avl_pin_code", result, 1);
  146. html = '<button onclick="productAddToCartForm.submit(this)" class="button btn-cart" title="Add to Cart" type="button"><span>Add to Cart</span></button>';
  147. cb(".addbut").html(html);
  148. cb("#location_msg").hide();
  149. if (cb("#checkpin").val() == "") {
  150. setCookie("pin_code", '', 1);
  151. setCookie("avl_pin_code", '', 1);
  152. cb("#check-avail1 a").html('<span>Check Avaliabilty</span>');
  153. var response = "";
  154. cb("#location_msg_avl").hide();
  155. } else {
  156. cb("#checkpin").val(cb.trim(result));
  157. cb("#location_msg_avl").show();
  158. cb("#location_msg_avl").text('<?php echo $this->successMsg() ?>');
  159. var response = "<span class='resp' style='color:green'><?php echo $this->successMsg() ?>: " + result + "</span>";
  160. }
  161.  
  162. }
  163. cb("#resp").html(response);
  164. cb("#resp").show();
  165. }});
  166.  
  167. return false;
  168. }
  169. function setCookie(c_name, value, exdays)
  170. {
  171. var exdate = new Date();
  172. exdate.setDate(exdate.getDate() + exdays);
  173. var c_value = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString());
  174. document.cookie = c_name + "=" + c_value + ";path=/";
  175. }
  176.  
  177. </script>
  178. <script>
  179. var $p = jQuery.noConflict();
  180. $p('#check-avail1').click(function() {
  181. $p(".check-data").show();
  182. $p("#checkpin").show();
  183. $p(this).hide();
  184. $p('#check-avail2').show();
  185. $p('#check-data').show();
  186. });
  187. $p('#check-avail2').click(function() {
  188. $p(this).hide();
  189. $p('#check-avail1').show();
  190. $p('#check-data').hide();
  191. });
  192. </script>
  193. <?php endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement