Advertisement
Guest User

Untitled

a guest
Jul 21st, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.12 KB | None | 0 0
  1. <?php if(1 == $_product->getRequestForQuote()) : ?>
  2. <li class="compare"><a href="#" class="link-compare1" onclick="reqQuote('<?php echo $_compareUrl ?>'); return false;" title="<?php echo $this->__('Request for Quote');?>"></a></li>
  3. <?php endif; ?>
  4. </ul>
  5. </div>
  6. <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,300,300italic,400italic,600' rel='stylesheet' type='text/css'>
  7. <link href="//netdna.bootstrapcdn.com/font-awesome/3.1.1/css/font-awesome.css" rel="stylesheet">
  8. <!--<link rel="stylesheet" type="text/css" href="css/registration.css"/>-->
  9. <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
  10. <link rel="stylesheet" href="demo/jquery-ui.css">
  11. <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
  12. <script type="text/javascript">
  13. function reqQuote(url) {
  14. jQuery( "#dialog" ).dialog({
  15. autoOpen: false,
  16. modal: true,
  17. height: 475.733,
  18. width: 572.733,
  19. open: function() {
  20. jQuery('#quote-url').val(url);
  21. jQuery('#quote-prodName').html('<?php echo $_product->getName();?>');
  22. }
  23. });
  24. jQuery( "#dialog" ).dialog( "open" );
  25. }
  26. jQuery(document).ready(function() {
  27. jQuery("#getQuoteBtn").on ("click",function(){
  28. var url = jQuery('#quote-url').val();
  29. url = url.replace("catalog/product_compare/add", 'quickview/index/reuestquote');
  30. var name = jQuery('#quote-name').val();
  31. var contact_no = jQuery('#quote-contact_no').val();
  32. var email = jQuery('#quote-email').val();
  33. var requirement = jQuery('#quote-requirement').val();
  34. jQuery('#cartpro_process').show();
  35.  
  36. jQuery("#quote-name_error").hide();
  37. jQuery("#quote-contact_no_error").hide();
  38. jQuery("#quote-email_error").hide();
  39. jQuery("#quote-requirement_error").hide();
  40. jQuery("#quote-email_error1").hide();
  41. var errorFlag = false;
  42. var emailFlag = true;
  43.  
  44. if ('' == name) {
  45. jQuery("#quote-name_error").show();
  46. jQuery("#quote-name_error").text('*Please enter name');
  47. errorFlag = true;
  48. } else if (!validateName(name)) {
  49. jQuery("#quote-name_error").show();
  50. jQuery("#quote-name_error").text('Invalid name. only character and whitespaces are allowed');
  51. errorFlag = true;
  52. }
  53.  
  54. if ('+91' == contact_no) {
  55. jQuery("#quote-contact_no_error").show();
  56. jQuery("#quote-contact_no_error").text('*Please enter contact no');
  57. errorFlag = true;
  58. }else if (!validateContactNumber(contact_no)) {
  59. jQuery("#quote-contact_no_error").show();
  60. jQuery("#quote-contact_no_error").text('*Invalid Contact Number');
  61. errorFlag = true;
  62. }
  63. var emailFlag = true;
  64. if ('' == email) {
  65. jQuery("#quote-email_error").show();
  66. jQuery("#quote-email_error").text('*Please enter email');
  67. errorFlag = true;
  68. emailFlag = false;
  69. } else if (!validateEmail(email)) {
  70. jQuery("#quote-email_error").show();
  71. emailFlag = false;
  72. errorFlag = true;
  73. jQuery("#quote-email_error").text('Invalid Email Address');
  74. }
  75. if ('' == requirement) {
  76. jQuery("#quote-requirement_error").show();
  77. jQuery("#quote-requirement_error").text('*Please enter requirement');
  78. errorFlag = true;
  79. } else if (!validateRequirement(requirement)) {
  80. jQuery("#quote-requirement_error").show();
  81. jQuery("#quote-requirement_error").text('*Invalid requirement. only character and whitespaces are allowed');
  82. errorFlag = true;
  83. }
  84. if (true == emailFlag && false == errorFlag) {
  85. var quoteUrl = jQuery('#quote-url').val();
  86. quoteUrl = quoteUrl.replace("catalog/product_compare/add", 'quickview/index/getquoteemail');
  87. jQuery.ajax( {
  88. url : quoteUrl,
  89. method: 'POST',
  90. data : {'email' : email},
  91. dataType : 'json',
  92. success : function(data) {
  93. if (data.message != '') {
  94. jQuery("#quote-email_error1").show();
  95. jQuery('#quoteUser').text(jQuery('#quote-name').val());
  96.  
  97.  
  98.  
  99. errorFlag = true;
  100. } else {
  101. jQuery.ajax({
  102. url : url,
  103. method: 'POST',
  104. data : {'name' : name, 'contact_no' : contact_no, 'email' : email, 'requirement' :requirement},
  105. dataType : 'json',
  106. success : function(data) {
  107. if (data.status == 'ERROR') {
  108. alert(data.message);
  109. }
  110. else {
  111. jQuery('#quote-name').val('');
  112. jQuery('#quote-contact_no').val('');
  113. jQuery('#quote-email').val('');
  114. jQuery('#quote-requirement').val('');
  115.  
  116.  
  117. alert(data.message);
  118. jQuery( "#dialog" ).dialog( "close" );
  119. }
  120. }
  121. });
  122. }
  123. }
  124. });
  125. }
  126. if (true == errorFlag) {
  127. e.preventDefault();
  128. return false;
  129. }
  130. });
  131. });
  132. function validateEmail(email) {
  133. var filter = /^[w-.+]+@[a-zA-Z0-9.-]+.[a-zA-z0-9]{2,4}$/;
  134. if (filter.test(email)) {
  135. return true;
  136. }
  137. else {
  138. return false;
  139. }
  140. }
  141.  
  142. function validateName(name) {
  143. var filter = /^[a-zA-Z ]*$/;
  144. if (filter.test(name)) {
  145. return true;
  146. }
  147. else {
  148. return false;
  149. }
  150. }
  151.  
  152. function validateRequirement(requirement) {
  153. var filter = /^[a-zA-Z ]*$/;
  154. if (filter.test(requirement)) {
  155. return true;
  156. }
  157. else {
  158. return false;
  159. }
  160. }
  161.  
  162. function validateContactNumber(contactNo) {
  163. var filter = /^(+91-|+91|0)?d{10}$/;
  164. if (filter.test(contactNo)) {
  165. return true;
  166. }
  167. else {
  168. return false;
  169. }
  170. }
  171.  
  172. </script>
  173.  
  174. <div id="dialog" style="display:none;" title="Request quote for">
  175. <h6 style="background-color:#87CE49; padding:15px;"><span id="quote-prodName" style= "font-weight: bold"></span></h6>
  176. <div id="quote-email_error1" style="color:#2D6CA2; font-weight: bold; margin-left: 89px; padding-top: 12px; display:none">Dear <span id="quoteUser" style="color:#FF5700"></span> you already registered please <a title="<?php echo $this->__("Login"); ?>" class="btn-head" style="text-decoration: underline; text-decoration-color: #008000; color:#FF5700" href="<?php echo $this->getUrl('customer/account/login/') ?>" target="_blank">
  177.  
  178. <?php echo $this->__("Login"); ?>
  179.  
  180. </a>
  181.  
  182. public function reuestquoteAction() {
  183. $prodId = (int) $this->getRequest()->getParam('product');
  184. $qty = (int) $this->getRequest()->getParam('qty');
  185. $organization_name = $this->getRequest()->getParam('organization_name');
  186. $business_vertical = $this->getRequest()->getParam('business_vertical');
  187. $name = $this->getRequest()->getParam('name');
  188. $contact_no = $this->getRequest()->getParam('contact_no');
  189. $email = $this->getRequest()->getParam('email');
  190. $requirement = $this->getRequest()->getParam('requirement');
  191. $dbhost = 'localhost';
  192. $dbuser = 'gazeitso';
  193. $dbpass = 'ganeshsathe3003';
  194. $conn = mysql_connect($dbhost, $dbuser, $dbpass);
  195.  
  196. if(! $conn ) {
  197. die('Could not connect: ' . mysql_error());
  198. }
  199. mysql_select_db('gazeitso_demo');
  200.  
  201. $sql = "INSERT INTO req_for_quote(prod_id,organization_name,business_vertical, name,contact_no,email,requirement) VALUES ".
  202. "('".$prodId."','".$organization_name."','".$business_vertical."','".$name."', '".$contact_no."', '".$email."', '".$requirement."' )";
  203. $query_result = mysql_query( $sql );
  204. if ($query_result) {
  205. $msg = "Thank you request for quote.";
  206. } else {
  207. $msg= "Unable to submit request";
  208. }
  209. $response['message'] = $msg;
  210.  
  211. /*
  212. $data = array('title'=> $postedData['id'],'content'=>'how are you? i am fine over here.','status'=>1);
  213. $model = Mage::getModel('mynews/mynews')->setData($data);
  214. try {
  215. $insertId = $model->save()->getId();
  216. echo "Data successfully inserted. Insert ID: ".$insertId;
  217. } catch (Exception $e){
  218. echo $e->getMessage();
  219. }
  220. */
  221. $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($response));
  222. return;
  223. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement