Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(function () {
- const languageList = $("#languageList");
- const selectedLanguage = $(".language_selected");
- var savingDraft = false;
- var currentQuote = null;
- $("#accountCompanyRequest").submit(function (e) {
- e.preventDefault();
- requestEdit({companyName: value("#editCompanyInput")},"edit/company.php");
- });
- $("#accountPasswordRequest").submit(function(e){
- e.preventDefault();
- var data = {currentPassword : value("#editPasswordCurrent"), newPassword : value("#editPasswordNew"), repeatPassword: value("#editPasswordValidate")};
- requestEdit(data,"edit/password.php");
- });
- $("#requestSubmit").click(function(){
- var data = {
- data: JSON.stringify(requestDataTable.getInstance().getData()),
- firstName: value("#requestFirstName"),
- surName: value("#requestSurName"),
- phone: value("#requestPhone"),
- email: value("#requestEmail"),
- company: value("#requestName"),
- address: value("#requestAddress"),
- zipcode: value("#requestZipcode"),
- end_copy: $('#requestSendCopy').prop('checked')};
- sendUserRequest("request.php", data, function(callback){
- if(callback != 'true') displayDialogError(callback);
- else window.location.reload(false);
- });
- return false;
- });
- $("#requestPreview").click(function(){
- if($(this).hasClass('preview_valid')){
- var target = $("#requestPreviewImage");
- $(".lightbox-image").attr('src', target.attr('src'));
- $("#requestPreviewLightbox").modal('show');
- $("#requestPreviewLightboxCaption").html(target.attr('title'));
- }
- });
- $("#requestSubmitSelection").click(function(){
- var tableData = [];
- var dataTable = $("#requestDataTable").handsontable('getInstance');
- for(var i = 0; i < dataTable.countRows(); i++){ tableData.push(dataTable.getDataAtRow(i));}
- $.post(corePath+"system/data/validateData.php", {data: JSON.stringify(tableData)}, function(response) {
- if (response === 'true') $("#requestDialog").modal('show');
- else {
- alert(response);
- }
- });
- });
- $(".modal-toggle").click(function(){ $('body').css('padding-right', '0');});
- $("#navigationMenuToggle").click(function(){ $("#menuList").toggle(500); });
- selectedLanguage.click(function(){ languageList.toggle(500); });
- $(".language_option").click(function(){
- languageList.toggle(500);
- var languageSelected = $(this).children().attr('title');
- $.ajax({
- url: 'core/util/languageRequest.php', type: 'POST', dataType: 'html', data: {language: languageSelected },
- success: function(){ window.location.reload(false); }
- });
- var _html = $(this).html();
- $(this).html(selectedLanguage.html());
- selectedLanguage.html(_html);
- });
- $("#historyNextPage").click(function(){ changeModulePage("history", null, +1)});
- $("#historyPreviousPage").click(function(){ changeModulePage("history", null, -1)});
- $(".modal").on('hidden.bs.modal', function(){
- $(".modal-error").hide();
- $.post(corePath+'system/misc/modalCloseTrigger.php');
- });
- $("#loginSubmit").click(function(){
- var data = {username: value("#loginUsername"), password: value("#loginPassword")};
- sendUserRequest("login.php", data, function(response){
- var rtn = JSON.parse(response);
- if(rtn.success == 'true'){
- window.location.href = rtn.response;
- } else displayDialogError(rtn.response);
- });
- return false;
- });
- $("#logoutButton").click(function(){
- window.location.href= rootPath;
- sendUserRequest('logout.php', null, function(){});
- });
- $("#requestAddFile").click(function(){$("#requestUpload").click();});
- $(".page_error_close").click(function(){$("."+($(this).closest('div').attr('class'))).fadeOut(500); });
- $("#registerSubmit").click(function(){
- var data = {company: value("#registerName"),
- email: value("#registerEmail"),
- username: value("#registerUsername"),
- password: value("#registerPassword"),
- password_validated: value("#registerPasswordValidate")
- };
- sendUserRequest("register.php", data, function(callback){
- if(callback == 'true') window.location.reload(false);
- else displayDialogError(callback);
- });
- return false;
- });
- $(".deleteQuoteImage").click(function(){
- var quoteID = $(this).attr("rel");
- var targetDialog = $("#validateQuoteRemovalDialog");
- $("#quoteDisplayID").html(quoteID);
- targetDialog.modal({show:true});
- targetDialog.attr('rel', quoteID);
- });
- $(".viewQuoteImage").click(function(){
- var hashID = $(this).attr("rel");
- window.location.replace(rootPath+"/request/view/"+hashID);
- });
- $("#deleteQuoteSubmit").click(function(){
- var hashedID = $("#validateQuoteRemovalDialog").attr('rel');
- var data = {quoteID : hashedID};
- sendUserRequest("remove/quote.php",data, function(callback){
- });
- });
- $("#dropdownSelection li a").click(function(){
- $(".btn:first-child").text($(this).text());
- $(".btn:first-child").val($(this).text());
- });
- $("#requestUpload").change(function(){
- var files = $(this)[0].files;
- var requests = [];
- var tableRows = [];
- var denied = [];
- jQuery.each(files, function(i, file) {
- var data = new FormData();
- data.append('validate', false);
- data.append('file', file);
- requests.push($.ajax({
- url: corePath+"system/file/uploadFile.php",
- data: data, contentType: false, type: 'POST',
- processData: false, cache: false, success: function(response){
- if(response == 'true'){
- var row = new TableRow(file.name);
- tableRows.push(row);
- requestDataTable.appendRow(row);
- }else{
- denied.push(file.name);
- }
- }
- }));
- });
- $.when.apply(null, requests).done(function(){
- loadPreviewSource(tableRows, $("#requestPreview"), $("#requestPreviewImage"));
- displayDeniedFilesError(denied);
- });
- });
- $("#requestRemoveFile").click(function(){
- requestDataTable.removeSelectedRows(function(callback){
- $.post(corePath+"system/file/removeFile.php", {fileNames: callback});
- });
- });
- $("#quotePreviousPageButton").click(function(){attemptNextPage(-1,"quote");});
- $("#quoteNextPageButton").click(function(){attemptNextPage(1,"quote");});
- $("#requestSave").click(function(){
- if(savingDraft) return;
- if(requestDataTable.getInstance() !== undefined){
- var data = requestDataTable.getInstance().getData();
- savingDraft=true;
- $.post(corePath+"system/user/saveData.php", {data: JSON.stringify(data)}, function(response){
- if(response == 'true') $("#requestSaveResponse").fadeIn(500).delay(2000).fadeOut(500, function(){ savingDraft=false;});
- else savingDraft=false;
- });
- }
- });
- $(".download_xls_format").click(function(){window.location = corePath+"system/misc/downloadFormat.php";});
- $("#requestLoadExcel").click(function(){ $("#uploadFormatDialog").modal('show'); });
- $("#uploadXLSButton").click(function(){ $("#requestUploadExcel").click(); });
- $("#requestUploadExcel").change(function(){
- var selectedFile = $(this)[0].files[0];
- var data = new FormData();
- var loadingImg = $("#uploadXLSLoadingbar");
- loadingImg.show();
- data.append('file', selectedFile);
- $.ajax({
- url: corePath+"system/data/uploadDataFile.php", type: 'POST', data: data,
- processData: false, cache: false, contentType: false, success: function(response){
- if(response == 'true') window.location.reload(false);
- else displayDialogError(response);
- loadingImg.fadeOut(200);
- }
- });
- });
- $(".accountInputDetails input").change(function(){
- $(this).css({"border": "1px solid orange"});
- append(new Change($(this).attr("name"),$(this).val()));
- });
- $("#sendAccountDetails").click(function () {
- var successMessage = $(".accountSuccessMessage");
- var errorMessage = $(".accountErrorMessage");
- var data = {changes : JSON.stringify(parseArray())};
- sendUserRequest("edit/detail.php", data,function (callback) {
- window.scrollTo(0, 0);
- if(callback == "true"){
- errorMessage.hide();
- successMessage.show();
- }else{
- successMessage.hide();
- errorMessage.html(callback);
- errorMessage.show();
- }
- });
- });
- $(".quoteTableRow").click(function(){
- var id = $(this).attr("rel");
- var container = $("#table_row_details_"+ id);
- if(currentQuote != null && container.attr('id') != currentQuote.attr('id')){
- if(currentQuote.is(':visible')) currentQuote.slideUp();
- }else if(container.is(':visible')){ container.slideUp(); return; }
- currentQuote = container;
- container.slideToggle(300, function () {
- $.post(corePath+"system/data/index/quoteDataIndex.php", {ID : id},
- function(rtn) {initMultiTable(JSON.parse(rtn));}
- );
- });
- });
- $('body').on('click', '.quotePreviewImage', function(){
- var imageName = ($(this).attr('title'));
- $.post(corePath+"system/file/requestPreview.php", {requested : imageName},
- function(response){
- var rtn = JSON.parse(response);
- if(rtn.valid){
- $("")
- }
- });
- });
- function initMultiTable(data) {
- var table = $(".quoteTableDetails");
- table.find("tr:gt(0)").remove();
- var tableBuilder = "";
- for(var row = 0; row< data.length; row++){
- tableBuilder += "<tr>";
- for(var column = 0 ; column<8; column++) {
- tableBuilder += "<td>" + data[row][column] + "</td>";
- }
- tableBuilder += "<td><img class='quotePreviewImage' title='"+data[row][0]+"' src='" + rootPath + "/res/img/view_icon.png' width='25px' height='auto'></td></tr>";
- }
- table.append(tableBuilder);
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement