Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var $compconfig = function () { }
- $compconfig = {
- isproduct: false,
- time_WhatYouSale: 0,
- companyid: null,
- iseshop:true,
- init: function () {
- //this.compverified();
- $commonFn.initactioloader($("#configuration"));
- $.when($eshop.getdata.configuration()).then(function ($data) {
- $("#configuration").html("");
- $("#configuration").html($data);
- $commonFn.removeactionloader();
- });
- },
- compverified: {
- init:function(){
- if (!$compconfig.options.compverified) {
- $compconfig.options.compverified = true;
- $commonFn.initactioloader($("#partial-billingmethods"));
- $.when($compconfig.compverified.get()).then(function ($data) {
- $("#partial-billingmethods").html("");
- $("#partial-billingmethods").html($data);
- $commonFn.removeactionloader();
- });
- }
- },
- get:function(){
- var dfd = $.Deferred();
- $.ajax({
- type: "GET",
- url: "/payments/billing/loadbillingmethods",
- contentType: "application/json; charset=utf-8",
- datatype: "json",
- success: function (result) {
- dfd.resolve(result);
- return dfd.promise();
- },
- error: function (er) {
- var _er = er;
- dfd.fail(_er);
- return dfd.promise();
- }
- });
- return dfd.promise();
- }
- },
- compdetails: {
- init: function () {
- if (!$compconfig.options.compdetails) {
- $compconfig.options.compdetails = true;
- $commonFn.initactioloader($("#company_configuration"));
- $.when($compconfig.compdetails.get()).then(function ($data) {
- $("#company_configuration").html("");
- $("#company_configuration").html($data);
- $commonFn.removeactionloader();
- });
- }
- },
- get: function () {
- var dfd = $.Deferred();
- $.ajax({
- type: "GET",
- url: "/Supplier/CompanyProfile",
- contentType: "application/json; charset=utf-8",
- datatype: "json",
- success: function (result) {
- dfd.resolve(result);
- },
- error: function (er) {
- var _er = er;
- dfd.fail(_er);
- return dfd.promise();
- }
- });
- return dfd.promise();
- }
- },
- compengine: {
- init: function () {
- if (!$compconfig.options.compengine) {
- $compconfig.options.compengine = true;
- $commonFn.initactioloader($("#dvcofieshop"));
- $.when($compconfig.compengine.get()).then(function ($data) {
- $("#dvcofieshop").html("");
- $("#dvcofieshop").html($data);
- $eshopsetting.init();
- $commonFn.removeactionloader();
- });
- }
- },
- get: function () {
- var dfd = $.Deferred();
- $.ajax({
- type: "GET",
- url: "/supplier/companyconfiguration",
- contentType: "application/json; charset=utf-8",
- datatype: "json",
- success: function (result) {
- dfd.resolve(result);
- },
- error: function (er) {
- var _er = er;
- dfd.fail(_er);
- return dfd.promise();
- }
- });
- return dfd.promise();
- }
- },
- compeshopsetup: {
- init: function () {
- if (!$compconfig.options.compeshopsetup) {
- $compconfig.options.compeshopsetup = true;
- $commonFn.initactioloader($("#publicprofilesetup"));
- $.when($compconfig.compeshopsetup.get()).then(function ($data) {
- $("#publicprofilesetup").html("");
- $("#publicprofilesetup").html($data);
- $commonFn.removeactionloader();
- });
- }
- },
- get: function () {
- var dfd = $.Deferred();
- $.ajax({
- type: "GET",
- url: "/supplier/companyeshopsetup",
- contentType: "application/json; charset=utf-8",
- datatype: "json",
- success: function (result) {
- dfd.resolve(result);
- },
- error: function (er) {
- var _er = er;
- dfd.fail(_er);
- return dfd.promise();
- }
- });
- return dfd.promise();
- }
- },
- compshippingsetup: {
- init: function () {
- if (!$compconfig.options.compshippingsetup) {
- $compconfig.options.compshippingsetup = true;
- $commonFn.initactioloader($("#compshipsetup"));
- $.when($compconfig.compshippingsetup.get()).then(function ($data) {
- $("#compshipsetup").html($data);
- $("#compshipsetup").html($data);
- $commonFn.removeactionloader();
- });
- }
- },
- get: function () {
- var dfd = $.Deferred();
- $.ajax({
- type: "GET",
- url: "/supplier/companyshippingsetup",
- contentType: "application/json; charset=utf-8",
- datatype: "json",
- success: function (result) {
- dfd.resolve(result);
- },
- error: function (er) {
- var _er = er;
- dfd.fail(_er);
- return dfd.promise();
- }
- });
- return dfd.promise();
- }
- },
- compbookingsetup: {
- init: function () {
- if (!$compconfig.options.compbookingsetup) {
- $compconfig.options.compbookingsetup = true;
- $commonFn.initactioloader($("#compbooksetup"));
- $.when($compconfig.compbookingsetup.get()).then(function ($data) {
- $("#compbooksetup").html("");
- $("#compbooksetup").html($data);
- $commonFn.removeactionloader();
- });
- }
- },
- get: function () {
- var dfd = $.Deferred();
- $.ajax({
- type: "GET",
- url: "/supplier/companybookingsetup",
- contentType: "application/json; charset=utf-8",
- datatype: "json",
- success: function (result) {
- dfd.resolve(result);
- },
- error: function (er) {
- var _er = er;
- dfd.fail(_er);
- return dfd.promise();
- }
- });
- return dfd.promise();
- }
- },
- compopenhours: {
- init: function () {
- if (!$compconfig.options.compopenhours) {
- $compconfig.options.compopenhours = true;
- $commonFn.initactioloader($("#copenhours"));
- $.when($compconfig.compopenhours.get()).then(function ($data) {
- $("#copenhours").html("");
- $("#copenhours").html($data);
- $commonFn.removeactionloader();
- });
- }
- },
- get: function () {
- var dfd = $.Deferred();
- $.ajax({
- type: "GET",
- url: "/supplier/PlateformAccessOpening",
- contentType: "application/json; charset=utf-8",
- datatype: "json",
- success: function (result) {
- dfd.resolve(result);
- },
- error: function (er) {
- var _er = er;
- dfd.fail(_er);
- return dfd.promise();
- }
- });
- return dfd.promise();
- },
- initsave: function () {
- var fv = $("#platfomrAccessOpeningHours").data('formValidation');
- fv.validate();
- if (!fv.isValid()) {
- return false;
- }
- if ($('#hdnopentime').val() == 0) {
- var $isvalidate = validaionopentime();
- if ($isvalidate == true) {
- $updateplateformopen.initsave();
- }
- else {
- return false;
- }
- }
- else {
- return false;
- }
- return true;
- }
- },
- comptime: {
- init: function () {
- if (!$compconfig.options.comptime) {
- $compconfig.options.comptime = true;
- $commonFn.initactioloader($("#ctime"));
- $.when($compconfig.comptime.get()).then(function ($data) {
- $("#ctime").html("");
- $("#ctime").html($data);
- $('#plateform_company_id').val($compconfig.companyid);
- $("#hdnWhatYouSale").val($compconfig.time_WhatYouSale);
- $("#time_WhatYouSale").val($compconfig.time_WhatYouSale);
- $commonFn.removeactionloader();
- });
- }
- },
- get: function () {
- var dfd = $.Deferred();
- $.ajax({
- type: "GET",
- url: "/supplier/paccessopeningtime",
- contentType: "application/json; charset=utf-8",
- datatype: "json",
- success: function (result) {
- dfd.resolve(result);
- },
- error: function (er) {
- var _er = er;
- dfd.fail(_er);
- return dfd.promise();
- }
- });
- return dfd.promise();
- },
- initsave: function () {
- $('#platfomrAccessSetup').formValidation({
- framework: 'bootstrap',
- fields: {
- time_OperationLanguageID: {
- validators: {
- notEmpty: {
- message: 'This field is requered'
- }
- }
- },
- time_CurrencyID: {
- validators: {
- notEmpty: {
- message: 'This field is requered'
- }
- }
- },
- time_TimeZone: {
- validators: {
- notEmpty: {
- message: 'This field is requered'
- }
- }
- },
- time_WhatYouSale: {
- validators: {
- notEmpty: {
- message: 'This field is requered'
- }
- }
- },
- },
- err: {
- clazz: 'text-help'
- },
- row: {
- invalid: 'has-danger'
- }
- });
- var fv = $("#platfomrAccessSetup").data('formValidation');
- fv.validate();
- if (!fv.isValid()) {
- return false;
- }
- //if ($compconfig.isproduct == 'True') {
- //
- // //shipping
- // RefreshcompanyshippingWizard();
- // var fv1 = $("#companyshippingForm").data('formValidation');
- // fv1.validate();
- // if (!fv1.isValid()) {
- //
- // return false;
- // }
- // var $isshippingvalidate = Revalidateshipping();
- // //if ($isshippingvalidate == true) {
- // // saveupdatecompanyshipping();
- // //}
- // if ($isshippingvalidate == false) {
- // return $isshippingvalidate;
- // }
- // //end shipping
- //}
- $updateplateformtime.initsave();
- return true;
- }
- },
- compsector: {
- init: function () {
- if (!$compconfig.options.compsector) {
- $compconfig.options.compsector = true;
- $commonFn.initactioloader($("#comp-sectors"));
- $.when($compconfig.compsector.get()).then(function ($data) {
- $("#comp-sectors").html("");
- $("#comp-sectors").html($data);
- $commonFn.removeactionloader();
- });
- }
- },
- get: function () {
- var dfd = $.Deferred();
- $.ajax({
- type: "GET",
- url: "",
- contentType: "application/json; charset=utf-8",
- datatype: "json",
- success: function (result) {
- dfd.resolve(result);
- },
- error: function (er) {
- var _er = er;
- dfd.fail(_er);
- return dfd.promise();
- }
- });
- return dfd.promise();
- }
- },
- options: {
- compverified: false,
- compdetails: false,
- compengine: false,
- compeshopsetup: false,
- compbookingsetup: false,
- compopenhours: false,
- comptime: false,
- compsector: false
- },
- }
- var eshopsetting = function () {
- this.EshopTitle;
- this.EshopDescription;
- this.EshopKeyWords;
- this.AllowSearchEngines;
- this.CompanyID;
- };
- var $eshopsetting = $.extend(true, {}, new eshopsetting());
- $eshopsetting = {
- LoadDetails: function () {
- $commonFn.waitLoader("Please wait while we are saving details.");
- $.when($eshopsetting.GetDetails()).then(function (item) {
- if (item != null) {
- $('#eshoptitle').val() = item.Title;
- $('#eshopcontent').val() = item.Description;
- $('#eshopkeywordserach').val() = item.SearchKeyword;
- //item.IsAllowSearch == true ? $('#isserachallow').prop('checked', true) : $('#isserachallow').prop('checked', true);
- }
- $commonFn.closeWaitLoader();
- });
- },
- GetDetails: function () {
- var _campaignId = $('#campaignId-id').val();
- var dfd = $.Deferred();
- $.ajax({
- type: "GET",
- url: "/admin/campaign/getcampaignbyId",
- data: { campaignId: _campaignId },
- contentType: "application/json; charset=utf-8",
- datatype: "json",
- success: function (result) {
- dfd.resolve(result);
- return dfd.promise();
- },
- error: function (er) {
- var _er = er;
- return dfd.promise();
- }
- });
- return dfd.promise();
- },
- init: function () {
- $('#eshopsettingform').validate({
- highlight: function (element) {
- $(element).closest('.form-group').removeClass('has-success').addClass('has-error');
- },
- success: function (element) {
- $(element).closest('.form-group').removeClass('has-error');
- },
- });
- if ($('#eshopAllowSearchEngines').val() == 1) {
- $(".toggle-eshop").toggles({
- on: true,
- height: 26
- });
- }
- else {
- $(".toggle-eshop").toggles({
- on: false,
- height: 26
- });
- }
- $('#isserachallow .toggle-on').click(function () {
- $('#eshopAllowSearchEngines').val(0);
- });
- $('#isserachallow .toggle-off').click(function () {
- $('#eshopAllowSearchEngines').val(1);
- });
- $(document).on('click', "#btn-eshop-setting", function () {
- $('.all-fields-error').hide();
- if ($("#eshopsettingform").valid()) {
- $commonFn.waitLoader("Please wait while we are saving your eshop setting.");
- $.when($eshopsetting.save()).then(function ($data) {
- $commonFn.closeWaitLoader();
- if ($data == "true") {
- //$eshopsetting.resetform();
- swal("Congratulations", "Your eshop settings has been updated successfully", "success");
- $('#set-eshopsettings i').removeClass('fa-times').removeClass('text-danger').addClass('fa-check').addClass('text-success');
- }
- else {
- swal("Oops...!", "Your eshop settings has not been updated", "error");
- }
- });
- }
- else {
- $('.all-fields-error').show();
- }
- });
- $("#eshoptitle").keyup(function (event) {
- var val = $("#eshoptitle").val();
- $('#peshoptitle').html(val);
- $eshop.countTitle(val);
- });
- $("#eshopcontent").keyup(function (event) {
- var val = $("#eshopcontent").val();
- $('#peshopcontent').html(val);
- $eshop.countContent(val);
- });
- },
- save: function () {
- $eshopsetting.EshopTitle = $('#eshoptitle').val();
- $eshopsetting.EshopDescription = $('#eshopcontent').val();
- $eshopsetting.EshopKeyWords = $('#eshopkeywordserach').val();
- $eshopsetting.CompanyID = $('#eshopcompanyid').val();
- $eshopsetting.AllowSearchEngines = $('#eshopAllowSearchEngines').val() == 1 ? true : false;
- var $data = JSON.stringify($eshopsetting);
- var dfd = $.Deferred();
- $.ajax({
- type: "POST",
- url: "/supplier/updateeshopsetting",
- data: JSON.stringify({ Obj: $data }),
- contentType: "application/json; charset=utf-8",
- datatype: "json",
- success: function (result) {
- dfd.resolve(result);
- return dfd.promise();
- },
- error: function (er) {
- var _er = er;
- return dfd.promise();
- }
- });
- return dfd.promise();
- },
- resetform: function () {
- $('#eshoptitle').val('');
- $('#eshopcontent').val('');
- $('#eshopkeywordserach').val('');
- $('#isserachallow').prop('checked', true);
- }
- }
- //$(document).ready(function () {
- // $compconfig.init();
- //})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement