Click here to Skip to main content
15,389,918 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
"Save & Exit" and "Save & Preview" button stopped working. Data not getting saved in database nor it is showing in the saved list page. No error message. No action happening on click.

JavaScript
  1  $(document).ready(function() {
  2      $("#save_exit").click(function(){
  3          $("#form_action").val("save_exit");
  4      })
  5  
  6      $("#save_create_performa").click(function(){
  7          $("#form_action").val("save_create_performa");
  8      })
  9  
 10      $("#save_preview").click(function(){
 11          $("#form_action").val("save_preview");
 12      })
 13  
 14      $("#frm").validate({
 15          rules: { 
 16                  purchase_order_type: "required",
 17                  name_add_consignee: "required",
 18                  name_add_buyer: "required",
 19                  paying_authority: "required",
 20                  //tin_no: "required",
 21                  po_no: "required",
 22                  invoice_date: "required",
 23                  date_prepration: "required",
 24                  date_removal: "required",
 25                  'product_name[]': {
 26                      required: true
 27                  },
 28                  'desc_packages[]': {
 29                      required: true
 30                  },
 31                  'no_of_pack[]': {
 32                      required: true
 33                  },
 34                  'qty[]': {
 35                      required: true
 36                  },
 37                  'unit[]': {
 38                      required: true
 39                  },
 40                  'rate[]': {
 41                      required: true
 42                  }
 43              },
 44              messages: { 
 45                  purchase_order_type: "",
 46                  name_add_consignee: "",
 47                  name_add_buyer: "",
 48                  paying_authority: "",
 49                  //tin_no: "",
 50                   po_no: "",
 51                  invoice_date: "",
 52                  date_prepration: "",
 53                  date_removal: "",
 54                  'product_name[]': {
 55                      required: ""
 56                  },
 57                  'desc_packages[]': {
 58                      required: ""
 59                  },
 60                  'no_of_pack[]': {
 61                      required: ""
 62                  },
 63                  'qty[]': {
 64                      required: ""
 65                  },
 66                  'unit[]': {
 67                      required: ""
 68                  },
 69                  'rate[]': {
 70                      required: ""
 71                  }
 72              },
 73              submitHandler: function(form) {
 74                  ////alert($("#form_action").val())
 75                  var value = $("#frm").serialize();
 76                  var lop = $(".product_name:input[value!='']").length
 77                  var pid_err = []  ;
 78                  var p_desc_err = []  ;
 79                  var p_qty_err = []  ;
 80                  var p_rate_err = []  ;
 81  
 82                  for(var a =0 ; a<lop; a++){
 83                      var product_id=$(".product_id").eq(a).val();
 84                      p_description=$(".desc_packages").eq(a).val();
 85                      p_qty=$(".qty").eq(a).val();
 86                      p_rate=$(".rate").eq(a).val();
 87                      if($.trim(product_id)=="")
 88                         pid_err.push(a);
 89                 }
 90  
 91                 if($.trim(p_description)=="")
 92                     p_desc_err.push(a);
 93                 if($.trim(p_qty)=="")
 94                     p_qty_err.push(a);
 95                 if($.trim(p_rate)=="")
 96                     p_rate_err.push(a);
 97                 if(pid_err.length> 0){
 98                      for (i=0;i<pid_err.length;i++){
 99                          $(".product_name").eq(pid_err[i]).addclass("error");
100                      }
101  
102                      return false;
103                else
104                    $(".product_name").removeclass("error");
105  
106                if(p_desc_err.length> 0){
107                    for (i=0;i<p_desc_err.length;i++){
108                        $(".desc_packages").eq(p_desc_err[i]).addclass("error");
109                    }
110  
111                    return false;
112               else
113                   $(".desc_packages").removeclass("error");
114  
115               if(p_qty_err.length=""> 0){
116                   for (i=0;i<p_qty_err.length;i++){
117                       $(".qty").eq(p_qty_err[i]).addclass("error");
118                   }
119  
120                   return false;
121               else
122                   $(".qty").removeclass("error");
123  
124               if(p_rate_err.length=""> 0){
125                   for (i=0;i<p_rate_err.length;i++){
126                       $(".rate").eq(p_rate_err[i]).addclass("error");
127                   }
128  
129                   return false;
130              else
131                  $(".rate").removeclass("error");
132  
133              $.ajax({
134                  type: "post",
135                  url: "ajax_create_retail_invoice.php",
136                  data: "type="saveData&"" +="" value,
137                  beforesend: function(){
138                      $("#inprocess").html("<div="" id="inprocess"><div id="inprocessimg"></div> <div id="inprocesstxt">Processing...</div>");
139                  },
140                  success: function(msg){
141                          //////  alert(msg)
142                           var redirect = $("#form_action").val();
143                          setTimeout(function(){
144                              $("#INPROCESS").html("");
145                              var spl_txt = msg.split("~~~"); 
146                              ////alert(spl_txt[0]);
147                              if(parseInt(spl_txt[0]) == '1'){
148                                  ////alert("asdasdsa")
149                                  colorStyle = "successTxt";
150                                  setTimeout(function(){
151                                      if($.trim(redirect)=='save_exit'){
152                                          window.location.href = "list_retail_invoice.php"    
153                                      }
154                                      else if($.trim(redirect)=='save_create_performa'){
155                                          window.location.href = "create_retail_final_invoice.php?ri_id="+spl_txt[2] ; 
156                                      }
157                                      else if($.trim(redirect)=='save_preview'){
158                                          window.location.href = "view_retail_invoice.php?ri_id="+spl_txt[2];  
159                                      }
160                                  },2500);
161                               }
162                               else {
163                                  ///alert("else")
164                                  colorStyle = "errorTxt";
165                               }
166                              $("#INPROCESS").html("<div id="inprocess"><div id="inprocessimg"></div> <div id="" + colorStyle + "">" + spl_txt[1] + "</div></div>");
167  
168                              $("#inprocess").fadeOut(4500);
169                              
170                              setTimeout(function(){
171                                  $("#INPROCESS").html('');
172                              },2000);
173                          },2000);
174                     }
175                  });
176              }
177          });
178  
179      function log(event, data, formatted) {
180          $("<li>").html( !data ? "No match!" : "Selected: " + formatted).appendTo("#result");
181      }
182  
183      function formatItem(row) {
184         ////alert("sdfsdf")
185         var rw = row[1].split("~~~");
186          return rw[0] ;
187      }
188  
189      function formatResult(row) {
190             ///alert(row);
191          var rw = row[1].split("~~~");
192          return rw[0] ;
193      }
194  
195      $(".product_name").autocomplete('search.php', {
196          width: 300,
197          multiple: false,
198          matchContains: true,
199          formatItem: formatItem,
200          formatResult: formatResult
201      }); 
202  
203      $(".product_name").result(function(event, data, formatted) {
204          var this_index = $(".product_name").index(this);
205          $(".product_id").eq(this_index).val(data[0]);
206          var rw = data[1].split("~~~");
207          var tariff_val = $("#tariff_hidden").val();
208          var tariff_txt = "";
209          var tarrif_arr = "";
210          if($.trim(tariff_val)!=""){
211              tarrif_arr = tariff_val.split(", ");   
212          }
213  
214          var find = "11003";
215          var tarriff_st = "ADD";
216          if(tarrif_arr.length > 0){
217              if(in_array(rw[1], tarrif_arr)){
218                  tarriff_st = "NO";
219              }
220              else {
221                  tarriff_st = "ADD";
222              }
223          }
224  
225          if($.trim(tariff_val)=="") {
226              $("#tariff_hidden").val(rw[1]);
227              $("#product_tariff").html(rw[1])
228          }
229          else {
230              if(tarriff_st == "ADD") {
231                  $("#tariff_hidden").val(tariff_val+", "+rw[1]);
232                  $("#product_tariff").html(tariff_val+", "+rw[1])
233              }
234          }
235      });
236  
237      ///////////////PAYING AUTHORITY
238      $("#paying_authority").autocomplete('ajax_paying_authority.php?type=autosearch', {
239          width: 300,
240          multiple: false,
241          matchContains: true,
242          formatItem: formatItem,
243          formatResult: formatResult
244      }); 
245  
246      $("#paying_authority").result(function(event, data, formatted) {
247           // ????
248      });
249  
250  $(".qty").live("keyup",function(e) {  
251      ///// alert("sdfsdf")
252      var qty_index = $(".qty").index(this);
253        $('.qty').calculate_row({index:qty_index}); 
254  });
255  
256  $(".rate").live("keyup",function(e) {     
257      var rate_index = $(".rate").index(this);
258        $('.rate').calculate_row({index:rate_index}); 
259  });


What I have tried:

Tried increasing the disk quota from cpanel. No benefit.
Posted
Updated 23-Jun-22 23:11pm
v2
Comments
Richard Deeming 24-Jun-22 5:13am
   
Your code is an absolute mess. I've done what I can to tidy it up, but you still have lots of syntax errors - presumably where you pasted the code and didn't check what had been pasted.

If the data is not being sent to the server, then something is going wrong in your validation code. You need to debug your code to find out why it's not working. We can't do that for you.
BHANU PRATAP 2022 24-Jun-22 7:07am
   
Hi Richard, thanks for the help. I just copy pasted the code from the file. This code was working fine from more than 6 years. Stopped working all of sudden. I am not sure what exactly I should paste for better understanding. This is not the complete code due character limitation.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900