Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php if(1 == $_product->getRequestForQuote()) : ?>
- <li class="compare"><a href="#" class="link-compare1" onclick="reqQuote('<?php echo $_compareUrl ?>'); return false;" title="<?php echo $this->__('Request for Quote');?>"></a></li>
- <?php endif; ?>
- </ul>
- </div>
- <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,300,300italic,400italic,600' rel='stylesheet' type='text/css'>
- <link href="//netdna.bootstrapcdn.com/font-awesome/3.1.1/css/font-awesome.css" rel="stylesheet">
- <!--<link rel="stylesheet" type="text/css" href="css/registration.css"/>-->
- <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
- <link rel="stylesheet" href="demo/jquery-ui.css">
- <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
- <script type="text/javascript">
- function reqQuote(url) {
- jQuery( "#dialog" ).dialog({
- autoOpen: false,
- modal: true,
- height: 475.733,
- width: 572.733,
- open: function() {
- jQuery('#quote-url').val(url);
- jQuery('#quote-prodName').html('<?php echo $_product->getName();?>');
- }
- });
- jQuery( "#dialog" ).dialog( "open" );
- }
- jQuery(document).ready(function() {
- jQuery("#getQuoteBtn").on ("click",function(){
- var url = jQuery('#quote-url').val();
- url = url.replace("catalog/product_compare/add", 'quickview/index/reuestquote');
- var name = jQuery('#quote-name').val();
- var contact_no = jQuery('#quote-contact_no').val();
- var email = jQuery('#quote-email').val();
- var requirement = jQuery('#quote-requirement').val();
- jQuery('#cartpro_process').show();
- jQuery("#quote-name_error").hide();
- jQuery("#quote-contact_no_error").hide();
- jQuery("#quote-email_error").hide();
- jQuery("#quote-requirement_error").hide();
- jQuery("#quote-email_error1").hide();
- var errorFlag = false;
- var emailFlag = true;
- if ('' == name) {
- jQuery("#quote-name_error").show();
- jQuery("#quote-name_error").text('*Please enter name');
- errorFlag = true;
- } else if (!validateName(name)) {
- jQuery("#quote-name_error").show();
- jQuery("#quote-name_error").text('Invalid name. only character and whitespaces are allowed');
- errorFlag = true;
- }
- if ('+91' == contact_no) {
- jQuery("#quote-contact_no_error").show();
- jQuery("#quote-contact_no_error").text('*Please enter contact no');
- errorFlag = true;
- }else if (!validateContactNumber(contact_no)) {
- jQuery("#quote-contact_no_error").show();
- jQuery("#quote-contact_no_error").text('*Invalid Contact Number');
- errorFlag = true;
- }
- var emailFlag = true;
- if ('' == email) {
- jQuery("#quote-email_error").show();
- jQuery("#quote-email_error").text('*Please enter email');
- errorFlag = true;
- emailFlag = false;
- } else if (!validateEmail(email)) {
- jQuery("#quote-email_error").show();
- emailFlag = false;
- errorFlag = true;
- jQuery("#quote-email_error").text('Invalid Email Address');
- }
- if ('' == requirement) {
- jQuery("#quote-requirement_error").show();
- jQuery("#quote-requirement_error").text('*Please enter requirement');
- errorFlag = true;
- } else if (!validateRequirement(requirement)) {
- jQuery("#quote-requirement_error").show();
- jQuery("#quote-requirement_error").text('*Invalid requirement. only character and whitespaces are allowed');
- errorFlag = true;
- }
- if (true == emailFlag && false == errorFlag) {
- var quoteUrl = jQuery('#quote-url').val();
- quoteUrl = quoteUrl.replace("catalog/product_compare/add", 'quickview/index/getquoteemail');
- jQuery.ajax( {
- url : quoteUrl,
- method: 'POST',
- data : {'email' : email},
- dataType : 'json',
- success : function(data) {
- if (data.message != '') {
- jQuery("#quote-email_error1").show();
- jQuery('#quoteUser').text(jQuery('#quote-name').val());
- errorFlag = true;
- } else {
- jQuery.ajax({
- url : url,
- method: 'POST',
- data : {'name' : name, 'contact_no' : contact_no, 'email' : email, 'requirement' :requirement},
- dataType : 'json',
- success : function(data) {
- if (data.status == 'ERROR') {
- alert(data.message);
- }
- else {
- jQuery('#quote-name').val('');
- jQuery('#quote-contact_no').val('');
- jQuery('#quote-email').val('');
- jQuery('#quote-requirement').val('');
- alert(data.message);
- jQuery( "#dialog" ).dialog( "close" );
- }
- }
- });
- }
- }
- });
- }
- if (true == errorFlag) {
- e.preventDefault();
- return false;
- }
- });
- });
- function validateEmail(email) {
- var filter = /^[w-.+]+@[a-zA-Z0-9.-]+.[a-zA-z0-9]{2,4}$/;
- if (filter.test(email)) {
- return true;
- }
- else {
- return false;
- }
- }
- function validateName(name) {
- var filter = /^[a-zA-Z ]*$/;
- if (filter.test(name)) {
- return true;
- }
- else {
- return false;
- }
- }
- function validateRequirement(requirement) {
- var filter = /^[a-zA-Z ]*$/;
- if (filter.test(requirement)) {
- return true;
- }
- else {
- return false;
- }
- }
- function validateContactNumber(contactNo) {
- var filter = /^(+91-|+91|0)?d{10}$/;
- if (filter.test(contactNo)) {
- return true;
- }
- else {
- return false;
- }
- }
- </script>
- <div id="dialog" style="display:none;" title="Request quote for">
- <h6 style="background-color:#87CE49; padding:15px;"><span id="quote-prodName" style= "font-weight: bold"></span></h6>
- <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">
- <?php echo $this->__("Login"); ?>
- </a>
- public function reuestquoteAction() {
- $prodId = (int) $this->getRequest()->getParam('product');
- $qty = (int) $this->getRequest()->getParam('qty');
- $organization_name = $this->getRequest()->getParam('organization_name');
- $business_vertical = $this->getRequest()->getParam('business_vertical');
- $name = $this->getRequest()->getParam('name');
- $contact_no = $this->getRequest()->getParam('contact_no');
- $email = $this->getRequest()->getParam('email');
- $requirement = $this->getRequest()->getParam('requirement');
- $dbhost = 'localhost';
- $dbuser = 'gazeitso';
- $dbpass = 'ganeshsathe3003';
- $conn = mysql_connect($dbhost, $dbuser, $dbpass);
- if(! $conn ) {
- die('Could not connect: ' . mysql_error());
- }
- mysql_select_db('gazeitso_demo');
- $sql = "INSERT INTO req_for_quote(prod_id,organization_name,business_vertical, name,contact_no,email,requirement) VALUES ".
- "('".$prodId."','".$organization_name."','".$business_vertical."','".$name."', '".$contact_no."', '".$email."', '".$requirement."' )";
- $query_result = mysql_query( $sql );
- if ($query_result) {
- $msg = "Thank you request for quote.";
- } else {
- $msg= "Unable to submit request";
- }
- $response['message'] = $msg;
- /*
- $data = array('title'=> $postedData['id'],'content'=>'how are you? i am fine over here.','status'=>1);
- $model = Mage::getModel('mynews/mynews')->setData($data);
- try {
- $insertId = $model->save()->getId();
- echo "Data successfully inserted. Insert ID: ".$insertId;
- } catch (Exception $e){
- echo $e->getMessage();
- }
- */
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($response));
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement