Advertisement
Guest User

Untitled

a guest
May 25th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.85 KB | None | 0 0
  1. $(function () {
  2. const languageList = $("#languageList");
  3. const selectedLanguage = $(".language_selected");
  4. var savingDraft = false;
  5. var currentQuote = null;
  6.  
  7. $("#accountCompanyRequest").submit(function (e) {
  8. e.preventDefault();
  9. requestEdit({companyName: value("#editCompanyInput")},"edit/company.php");
  10. });
  11.  
  12. $("#accountPasswordRequest").submit(function(e){
  13. e.preventDefault();
  14. var data = {currentPassword : value("#editPasswordCurrent"), newPassword : value("#editPasswordNew"), repeatPassword: value("#editPasswordValidate")};
  15. requestEdit(data,"edit/password.php");
  16. });
  17. $("#requestSubmit").click(function(){
  18. var data = {
  19. data: JSON.stringify(requestDataTable.getInstance().getData()),
  20. firstName: value("#requestFirstName"),
  21. surName: value("#requestSurName"),
  22. phone: value("#requestPhone"),
  23. email: value("#requestEmail"),
  24. company: value("#requestName"),
  25. address: value("#requestAddress"),
  26. zipcode: value("#requestZipcode"),
  27. end_copy: $('#requestSendCopy').prop('checked')};
  28. sendUserRequest("request.php", data, function(callback){
  29. if(callback != 'true') displayDialogError(callback);
  30. else window.location.reload(false);
  31. });
  32. return false;
  33. });
  34.  
  35. $("#requestPreview").click(function(){
  36. if($(this).hasClass('preview_valid')){
  37. var target = $("#requestPreviewImage");
  38. $(".lightbox-image").attr('src', target.attr('src'));
  39. $("#requestPreviewLightbox").modal('show');
  40. $("#requestPreviewLightboxCaption").html(target.attr('title'));
  41. }
  42. });
  43. $("#requestSubmitSelection").click(function(){
  44. var tableData = [];
  45. var dataTable = $("#requestDataTable").handsontable('getInstance');
  46. for(var i = 0; i < dataTable.countRows(); i++){ tableData.push(dataTable.getDataAtRow(i));}
  47. $.post(corePath+"system/data/validateData.php", {data: JSON.stringify(tableData)}, function(response) {
  48. if (response === 'true') $("#requestDialog").modal('show');
  49. else {
  50. alert(response);
  51. }
  52. });
  53. });
  54.  
  55. $(".modal-toggle").click(function(){ $('body').css('padding-right', '0');});
  56. $("#navigationMenuToggle").click(function(){ $("#menuList").toggle(500); });
  57. selectedLanguage.click(function(){ languageList.toggle(500); });
  58.  
  59. $(".language_option").click(function(){
  60. languageList.toggle(500);
  61. var languageSelected = $(this).children().attr('title');
  62. $.ajax({
  63. url: 'core/util/languageRequest.php', type: 'POST', dataType: 'html', data: {language: languageSelected },
  64. success: function(){ window.location.reload(false); }
  65. });
  66. var _html = $(this).html();
  67. $(this).html(selectedLanguage.html());
  68. selectedLanguage.html(_html);
  69. });
  70.  
  71. $("#historyNextPage").click(function(){ changeModulePage("history", null, +1)});
  72. $("#historyPreviousPage").click(function(){ changeModulePage("history", null, -1)});
  73.  
  74. $(".modal").on('hidden.bs.modal', function(){
  75. $(".modal-error").hide();
  76. $.post(corePath+'system/misc/modalCloseTrigger.php');
  77. });
  78. $("#loginSubmit").click(function(){
  79. var data = {username: value("#loginUsername"), password: value("#loginPassword")};
  80. sendUserRequest("login.php", data, function(response){
  81. var rtn = JSON.parse(response);
  82. if(rtn.success == 'true'){
  83. window.location.href = rtn.response;
  84. } else displayDialogError(rtn.response);
  85. });
  86. return false;
  87. });
  88.  
  89. $("#logoutButton").click(function(){
  90. window.location.href= rootPath;
  91. sendUserRequest('logout.php', null, function(){});
  92. });
  93.  
  94. $("#requestAddFile").click(function(){$("#requestUpload").click();});
  95. $(".page_error_close").click(function(){$("."+($(this).closest('div').attr('class'))).fadeOut(500); });
  96. $("#registerSubmit").click(function(){
  97. var data = {company: value("#registerName"),
  98. email: value("#registerEmail"),
  99. username: value("#registerUsername"),
  100. password: value("#registerPassword"),
  101. password_validated: value("#registerPasswordValidate")
  102. };
  103. sendUserRequest("register.php", data, function(callback){
  104. if(callback == 'true') window.location.reload(false);
  105. else displayDialogError(callback);
  106. });
  107. return false;
  108. });
  109.  
  110. $(".deleteQuoteImage").click(function(){
  111. var quoteID = $(this).attr("rel");
  112. var targetDialog = $("#validateQuoteRemovalDialog");
  113. $("#quoteDisplayID").html(quoteID);
  114. targetDialog.modal({show:true});
  115. targetDialog.attr('rel', quoteID);
  116. });
  117.  
  118. $(".viewQuoteImage").click(function(){
  119. var hashID = $(this).attr("rel");
  120. window.location.replace(rootPath+"/request/view/"+hashID);
  121. });
  122.  
  123. $("#deleteQuoteSubmit").click(function(){
  124. var hashedID = $("#validateQuoteRemovalDialog").attr('rel');
  125. var data = {quoteID : hashedID};
  126. sendUserRequest("remove/quote.php",data, function(callback){
  127. });
  128. });
  129.  
  130. $("#dropdownSelection li a").click(function(){
  131. $(".btn:first-child").text($(this).text());
  132. $(".btn:first-child").val($(this).text());
  133. });
  134.  
  135. $("#requestUpload").change(function(){
  136. var files = $(this)[0].files;
  137. var requests = [];
  138. var tableRows = [];
  139. var denied = [];
  140. jQuery.each(files, function(i, file) {
  141. var data = new FormData();
  142. data.append('validate', false);
  143. data.append('file', file);
  144. requests.push($.ajax({
  145. url: corePath+"system/file/uploadFile.php",
  146. data: data, contentType: false, type: 'POST',
  147. processData: false, cache: false, success: function(response){
  148. if(response == 'true'){
  149. var row = new TableRow(file.name);
  150. tableRows.push(row);
  151. requestDataTable.appendRow(row);
  152. }else{
  153. denied.push(file.name);
  154. }
  155. }
  156. }));
  157. });
  158. $.when.apply(null, requests).done(function(){
  159. loadPreviewSource(tableRows, $("#requestPreview"), $("#requestPreviewImage"));
  160. displayDeniedFilesError(denied);
  161. });
  162. });
  163.  
  164. $("#requestRemoveFile").click(function(){
  165. requestDataTable.removeSelectedRows(function(callback){
  166. $.post(corePath+"system/file/removeFile.php", {fileNames: callback});
  167. });
  168. });
  169. $("#quotePreviousPageButton").click(function(){attemptNextPage(-1,"quote");});
  170. $("#quoteNextPageButton").click(function(){attemptNextPage(1,"quote");});
  171.  
  172. $("#requestSave").click(function(){
  173. if(savingDraft) return;
  174. if(requestDataTable.getInstance() !== undefined){
  175. var data = requestDataTable.getInstance().getData();
  176. savingDraft=true;
  177. $.post(corePath+"system/user/saveData.php", {data: JSON.stringify(data)}, function(response){
  178. if(response == 'true') $("#requestSaveResponse").fadeIn(500).delay(2000).fadeOut(500, function(){ savingDraft=false;});
  179. else savingDraft=false;
  180. });
  181. }
  182. });
  183. $(".download_xls_format").click(function(){window.location = corePath+"system/misc/downloadFormat.php";});
  184. $("#requestLoadExcel").click(function(){ $("#uploadFormatDialog").modal('show'); });
  185. $("#uploadXLSButton").click(function(){ $("#requestUploadExcel").click(); });
  186.  
  187. $("#requestUploadExcel").change(function(){
  188. var selectedFile = $(this)[0].files[0];
  189. var data = new FormData();
  190. var loadingImg = $("#uploadXLSLoadingbar");
  191. loadingImg.show();
  192. data.append('file', selectedFile);
  193. $.ajax({
  194. url: corePath+"system/data/uploadDataFile.php", type: 'POST', data: data,
  195. processData: false, cache: false, contentType: false, success: function(response){
  196. if(response == 'true') window.location.reload(false);
  197. else displayDialogError(response);
  198. loadingImg.fadeOut(200);
  199. }
  200. });
  201. });
  202. $(".accountInputDetails input").change(function(){
  203. $(this).css({"border": "1px solid orange"});
  204. append(new Change($(this).attr("name"),$(this).val()));
  205. });
  206.  
  207. $("#sendAccountDetails").click(function () {
  208. var successMessage = $(".accountSuccessMessage");
  209. var errorMessage = $(".accountErrorMessage");
  210. var data = {changes : JSON.stringify(parseArray())};
  211. sendUserRequest("edit/detail.php", data,function (callback) {
  212. window.scrollTo(0, 0);
  213. if(callback == "true"){
  214. errorMessage.hide();
  215. successMessage.show();
  216. }else{
  217. successMessage.hide();
  218. errorMessage.html(callback);
  219. errorMessage.show();
  220. }
  221. });
  222. });
  223.  
  224. $(".quoteTableRow").click(function(){
  225. var id = $(this).attr("rel");
  226. var container = $("#table_row_details_"+ id);
  227. if(currentQuote != null && container.attr('id') != currentQuote.attr('id')){
  228. if(currentQuote.is(':visible')) currentQuote.slideUp();
  229. }else if(container.is(':visible')){ container.slideUp(); return; }
  230. currentQuote = container;
  231. container.slideToggle(300, function () {
  232. $.post(corePath+"system/data/index/quoteDataIndex.php", {ID : id},
  233. function(rtn) {initMultiTable(JSON.parse(rtn));}
  234. );
  235. });
  236. });
  237.  
  238. $('body').on('click', '.quotePreviewImage', function(){
  239. var imageName = ($(this).attr('title'));
  240. $.post(corePath+"system/file/requestPreview.php", {requested : imageName},
  241. function(response){
  242. var rtn = JSON.parse(response);
  243. if(rtn.valid){
  244. $("")
  245. }
  246. });
  247. });
  248.  
  249. function initMultiTable(data) {
  250. var table = $(".quoteTableDetails");
  251. table.find("tr:gt(0)").remove();
  252. var tableBuilder = "";
  253. for(var row = 0; row< data.length; row++){
  254. tableBuilder += "<tr>";
  255. for(var column = 0 ; column<8; column++) {
  256. tableBuilder += "<td>" + data[row][column] + "</td>";
  257. }
  258. tableBuilder += "<td><img class='quotePreviewImage' title='"+data[row][0]+"' src='" + rootPath + "/res/img/view_icon.png' width='25px' height='auto'></td></tr>";
  259. }
  260. table.append(tableBuilder);
  261. }
  262.  
  263.  
  264. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement