Advertisement
Guest User

Untitled

a guest
Aug 19th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var $compconfig = function () { }
  2. $compconfig = {
  3.     isproduct: false,
  4.     time_WhatYouSale: 0,
  5.     companyid: null,
  6.     iseshop:true,
  7.  
  8.     init: function () {
  9.         //this.compverified();
  10.         $commonFn.initactioloader($("#configuration"));
  11.         $.when($eshop.getdata.configuration()).then(function ($data) {
  12.             $("#configuration").html("");
  13.             $("#configuration").html($data);
  14.             $commonFn.removeactionloader();
  15.         });
  16.     },
  17.  
  18.     compverified: {
  19.         init:function(){
  20.             if (!$compconfig.options.compverified) {
  21.                 $compconfig.options.compverified = true;
  22.                 $commonFn.initactioloader($("#partial-billingmethods"));
  23.                 $.when($compconfig.compverified.get()).then(function ($data) {
  24.                     $("#partial-billingmethods").html("");
  25.                     $("#partial-billingmethods").html($data);
  26.                     $commonFn.removeactionloader();
  27.                 });
  28.             }
  29.         },
  30.         get:function(){
  31.             var dfd = $.Deferred();
  32.             $.ajax({
  33.                 type: "GET",
  34.                 url: "/payments/billing/loadbillingmethods",
  35.                 contentType: "application/json; charset=utf-8",
  36.                 datatype: "json",
  37.                 success: function (result) {
  38.                     dfd.resolve(result);
  39.                     return dfd.promise();
  40.                 },
  41.                 error: function (er) {
  42.                     var _er = er;
  43.                     dfd.fail(_er);
  44.                     return dfd.promise();
  45.                 }
  46.             });
  47.             return dfd.promise();
  48.         }
  49.     },
  50.  
  51.     compdetails: {
  52.         init: function () {
  53.             if (!$compconfig.options.compdetails) {
  54.                 $compconfig.options.compdetails = true;
  55.                 $commonFn.initactioloader($("#company_configuration"));
  56.                 $.when($compconfig.compdetails.get()).then(function ($data) {
  57.                     $("#company_configuration").html("");
  58.                     $("#company_configuration").html($data);
  59.                     $commonFn.removeactionloader();
  60.                 });
  61.             }
  62.         },
  63.  
  64.         get: function () {
  65.             var dfd = $.Deferred();
  66.             $.ajax({
  67.                 type: "GET",
  68.                 url: "/Supplier/CompanyProfile",
  69.                 contentType: "application/json; charset=utf-8",
  70.                 datatype: "json",
  71.                 success: function (result) {
  72.                     dfd.resolve(result);
  73.                 },
  74.                 error: function (er) {
  75.                     var _er = er;
  76.                     dfd.fail(_er);
  77.                     return dfd.promise();
  78.                 }
  79.             });
  80.             return dfd.promise();
  81.         }
  82.     },
  83.  
  84.     compengine: {
  85.         init: function () {
  86.             if (!$compconfig.options.compengine) {
  87.                 $compconfig.options.compengine = true;
  88.                 $commonFn.initactioloader($("#dvcofieshop"));
  89.                 $.when($compconfig.compengine.get()).then(function ($data) {
  90.                     $("#dvcofieshop").html("");
  91.                     $("#dvcofieshop").html($data);
  92.                     $eshopsetting.init();
  93.                     $commonFn.removeactionloader();
  94.                 });
  95.             }
  96.         },
  97.  
  98.         get: function () {
  99.             var dfd = $.Deferred();
  100.             $.ajax({
  101.                 type: "GET",
  102.                 url: "/supplier/companyconfiguration",
  103.                 contentType: "application/json; charset=utf-8",
  104.                 datatype: "json",
  105.                 success: function (result) {
  106.                     dfd.resolve(result);
  107.                 },
  108.                 error: function (er) {
  109.                     var _er = er;
  110.                     dfd.fail(_er);
  111.                     return dfd.promise();
  112.                 }
  113.             });
  114.             return dfd.promise();
  115.         }
  116.     },
  117.  
  118.     compeshopsetup: {
  119.         init: function () {
  120.             if (!$compconfig.options.compeshopsetup) {
  121.                 $compconfig.options.compeshopsetup = true;
  122.                 $commonFn.initactioloader($("#publicprofilesetup"));
  123.                 $.when($compconfig.compeshopsetup.get()).then(function ($data) {
  124.                     $("#publicprofilesetup").html("");
  125.                     $("#publicprofilesetup").html($data);
  126.                     $commonFn.removeactionloader();
  127.                 });
  128.             }
  129.         },
  130.         get: function () {
  131.             var dfd = $.Deferred();
  132.             $.ajax({
  133.                 type: "GET",
  134.                 url: "/supplier/companyeshopsetup",
  135.                 contentType: "application/json; charset=utf-8",
  136.                 datatype: "json",
  137.                 success: function (result) {
  138.                     dfd.resolve(result);
  139.                 },
  140.                 error: function (er) {
  141.                     var _er = er;
  142.                     dfd.fail(_er);
  143.                     return dfd.promise();
  144.                 }
  145.             });
  146.             return dfd.promise();
  147.         }
  148.     },
  149.  
  150.     compshippingsetup: {
  151.         init: function () {
  152.             if (!$compconfig.options.compshippingsetup) {
  153.                 $compconfig.options.compshippingsetup = true;
  154.                 $commonFn.initactioloader($("#compshipsetup"));
  155.                 $.when($compconfig.compshippingsetup.get()).then(function ($data) {
  156.                     $("#compshipsetup").html($data);
  157.                     $("#compshipsetup").html($data);
  158.                     $commonFn.removeactionloader();
  159.                 });
  160.             }
  161.         },
  162.         get: function () {
  163.             var dfd = $.Deferred();
  164.             $.ajax({
  165.                 type: "GET",
  166.                 url: "/supplier/companyshippingsetup",
  167.                 contentType: "application/json; charset=utf-8",
  168.                 datatype: "json",
  169.                 success: function (result) {
  170.                     dfd.resolve(result);
  171.                 },
  172.                 error: function (er) {
  173.                     var _er = er;
  174.                     dfd.fail(_er);
  175.                     return dfd.promise();
  176.                 }
  177.             });
  178.             return dfd.promise();
  179.         }
  180.     },
  181.  
  182.     compbookingsetup: {
  183.         init: function () {
  184.             if (!$compconfig.options.compbookingsetup) {
  185.                 $compconfig.options.compbookingsetup = true;
  186.                 $commonFn.initactioloader($("#compbooksetup"));
  187.                 $.when($compconfig.compbookingsetup.get()).then(function ($data) {
  188.                     $("#compbooksetup").html("");
  189.                     $("#compbooksetup").html($data);
  190.                     $commonFn.removeactionloader();
  191.                 });
  192.             }
  193.         },
  194.         get: function () {
  195.             var dfd = $.Deferred();
  196.             $.ajax({
  197.                 type: "GET",
  198.                 url: "/supplier/companybookingsetup",
  199.                 contentType: "application/json; charset=utf-8",
  200.                 datatype: "json",
  201.                 success: function (result) {
  202.                     dfd.resolve(result);
  203.                 },
  204.                 error: function (er) {
  205.                     var _er = er;
  206.                     dfd.fail(_er);
  207.                     return dfd.promise();
  208.                 }
  209.             });
  210.             return dfd.promise();
  211.         }
  212.     },
  213.  
  214.     compopenhours: {
  215.         init: function () {
  216.             if (!$compconfig.options.compopenhours) {
  217.                 $compconfig.options.compopenhours = true;
  218.                 $commonFn.initactioloader($("#copenhours"));
  219.                 $.when($compconfig.compopenhours.get()).then(function ($data) {
  220.                     $("#copenhours").html("");
  221.                     $("#copenhours").html($data);
  222.                     $commonFn.removeactionloader();
  223.                 });
  224.             }
  225.         },
  226.  
  227.         get: function () {
  228.             var dfd = $.Deferred();
  229.             $.ajax({
  230.                 type: "GET",
  231.                 url: "/supplier/PlateformAccessOpening",
  232.                 contentType: "application/json; charset=utf-8",
  233.                 datatype: "json",
  234.                 success: function (result) {
  235.                     dfd.resolve(result);
  236.                 },
  237.                 error: function (er) {
  238.                     var _er = er;
  239.                     dfd.fail(_er);
  240.                     return dfd.promise();
  241.                 }
  242.             });
  243.             return dfd.promise();
  244.         },
  245.  
  246.         initsave: function () {
  247.             var fv = $("#platfomrAccessOpeningHours").data('formValidation');
  248.             fv.validate();
  249.             if (!fv.isValid()) {
  250.                 return false;
  251.             }
  252.             if ($('#hdnopentime').val() == 0) {
  253.                 var $isvalidate = validaionopentime();
  254.                 if ($isvalidate == true) {
  255.                     $updateplateformopen.initsave();
  256.                 }
  257.                 else {
  258.                     return false;
  259.                 }
  260.             }
  261.             else {
  262.                 return false;
  263.             }
  264.             return true;
  265.         }
  266.     },
  267.  
  268.     comptime: {
  269.         init: function () {
  270.             if (!$compconfig.options.comptime) {
  271.                 $compconfig.options.comptime = true;
  272.                 $commonFn.initactioloader($("#ctime"));
  273.                 $.when($compconfig.comptime.get()).then(function ($data) {
  274.                     $("#ctime").html("");
  275.                     $("#ctime").html($data);
  276.                     $('#plateform_company_id').val($compconfig.companyid);
  277.                     $("#hdnWhatYouSale").val($compconfig.time_WhatYouSale);
  278.                     $("#time_WhatYouSale").val($compconfig.time_WhatYouSale);
  279.                     $commonFn.removeactionloader();
  280.                 });
  281.             }
  282.            
  283.         },
  284.         get: function () {
  285.             var dfd = $.Deferred();
  286.             $.ajax({
  287.                 type: "GET",
  288.                 url: "/supplier/paccessopeningtime",
  289.                 contentType: "application/json; charset=utf-8",
  290.                 datatype: "json",
  291.                 success: function (result) {
  292.                     dfd.resolve(result);
  293.                 },
  294.                 error: function (er) {
  295.                     var _er = er;
  296.                     dfd.fail(_er);
  297.                     return dfd.promise();
  298.                 }
  299.             });
  300.             return dfd.promise();
  301.         },
  302.  
  303.         initsave: function () {
  304.             $('#platfomrAccessSetup').formValidation({
  305.                 framework: 'bootstrap',
  306.                 fields: {
  307.                     time_OperationLanguageID: {
  308.                         validators: {
  309.                             notEmpty: {
  310.                                 message: 'This field is requered'
  311.                             }
  312.                         }
  313.                     },
  314.                     time_CurrencyID: {
  315.                         validators: {
  316.                             notEmpty: {
  317.                                 message: 'This field is requered'
  318.                             }
  319.                         }
  320.                     },
  321.                     time_TimeZone: {
  322.                         validators: {
  323.                             notEmpty: {
  324.                                 message: 'This field is requered'
  325.                             }
  326.                         }
  327.                     },
  328.                     time_WhatYouSale: {
  329.                         validators: {
  330.                             notEmpty: {
  331.                                 message: 'This field is requered'
  332.                             }
  333.                         }
  334.                     },
  335.  
  336.                 },
  337.                 err: {
  338.                     clazz: 'text-help'
  339.                 },
  340.                 row: {
  341.                     invalid: 'has-danger'
  342.                 }
  343.             });
  344.             var fv = $("#platfomrAccessSetup").data('formValidation');
  345.             fv.validate();
  346.             if (!fv.isValid()) {
  347.                 return false;
  348.             }
  349.             //if ($compconfig.isproduct == 'True') {
  350.             //    
  351.             //    //shipping
  352.             //    RefreshcompanyshippingWizard();
  353.             //    var fv1 = $("#companyshippingForm").data('formValidation');
  354.             //    fv1.validate();
  355.             //    if (!fv1.isValid()) {
  356.             //        
  357.             //        return false;
  358.             //    }
  359.             //    var $isshippingvalidate = Revalidateshipping();
  360.             //    //if ($isshippingvalidate == true) {
  361.             //    //    saveupdatecompanyshipping();
  362.             //    //}
  363.  
  364.             //    if ($isshippingvalidate == false) {
  365.             //        return $isshippingvalidate;
  366.             //    }
  367.             //    //end shipping
  368.             //}
  369.            
  370.             $updateplateformtime.initsave();
  371.             return true;
  372.         }
  373.     },
  374.  
  375.  
  376.     compsector: {
  377.         init: function () {
  378.             if (!$compconfig.options.compsector) {
  379.                 $compconfig.options.compsector = true;
  380.                 $commonFn.initactioloader($("#comp-sectors"));
  381.                 $.when($compconfig.compsector.get()).then(function ($data) {
  382.                     $("#comp-sectors").html("");
  383.                     $("#comp-sectors").html($data);
  384.                     $commonFn.removeactionloader();
  385.                 });
  386.             }
  387.         },
  388.  
  389.         get: function () {
  390.             var dfd = $.Deferred();
  391.             $.ajax({
  392.                 type: "GET",
  393.                 url: "",
  394.                 contentType: "application/json; charset=utf-8",
  395.                 datatype: "json",
  396.                 success: function (result) {
  397.                     dfd.resolve(result);
  398.                 },
  399.                 error: function (er) {
  400.                     var _er = er;
  401.                     dfd.fail(_er);
  402.                     return dfd.promise();
  403.                 }
  404.             });
  405.             return dfd.promise();
  406.         }
  407.     },
  408.  
  409.  
  410.     options: {
  411.         compverified: false,
  412.         compdetails: false,
  413.         compengine: false,
  414.         compeshopsetup: false,
  415.         compbookingsetup: false,
  416.         compopenhours: false,
  417.         comptime: false,
  418.         compsector: false
  419.     },
  420. }
  421.  
  422. var eshopsetting = function () {
  423.     this.EshopTitle;
  424.     this.EshopDescription;
  425.     this.EshopKeyWords;
  426.     this.AllowSearchEngines;
  427.     this.CompanyID;
  428. };
  429.  
  430. var $eshopsetting = $.extend(true, {}, new eshopsetting());
  431. $eshopsetting = {
  432.     LoadDetails: function () {
  433.         $commonFn.waitLoader("Please wait while we are saving details.");
  434.         $.when($eshopsetting.GetDetails()).then(function (item) {
  435.             if (item != null) {
  436.                 $('#eshoptitle').val() = item.Title;
  437.                 $('#eshopcontent').val() = item.Description;
  438.                 $('#eshopkeywordserach').val() = item.SearchKeyword;
  439.                 //item.IsAllowSearch == true ? $('#isserachallow').prop('checked', true) : $('#isserachallow').prop('checked', true);
  440.             }
  441.             $commonFn.closeWaitLoader();
  442.         });
  443.     },
  444.  
  445.     GetDetails: function () {
  446.         var _campaignId = $('#campaignId-id').val();
  447.         var dfd = $.Deferred();
  448.         $.ajax({
  449.             type: "GET",
  450.             url: "/admin/campaign/getcampaignbyId",
  451.             data: { campaignId: _campaignId },
  452.             contentType: "application/json; charset=utf-8",
  453.             datatype: "json",
  454.             success: function (result) {
  455.                 dfd.resolve(result);
  456.                 return dfd.promise();
  457.             },
  458.             error: function (er) {
  459.                 var _er = er;
  460.                 return dfd.promise();
  461.             }
  462.         });
  463.         return dfd.promise();
  464.     },
  465.  
  466.     init: function () {
  467.         $('#eshopsettingform').validate({
  468.             highlight: function (element) {
  469.                 $(element).closest('.form-group').removeClass('has-success').addClass('has-error');
  470.             },
  471.             success: function (element) {
  472.                 $(element).closest('.form-group').removeClass('has-error');
  473.             },
  474.         });
  475.  
  476.  
  477.         if ($('#eshopAllowSearchEngines').val() == 1) {
  478.             $(".toggle-eshop").toggles({
  479.                 on: true,
  480.                 height: 26
  481.             });
  482.         }
  483.         else {
  484.             $(".toggle-eshop").toggles({
  485.                 on: false,
  486.                 height: 26
  487.             });
  488.         }
  489.  
  490.         $('#isserachallow .toggle-on').click(function () {
  491.             $('#eshopAllowSearchEngines').val(0);
  492.         });
  493.  
  494.         $('#isserachallow .toggle-off').click(function () {
  495.             $('#eshopAllowSearchEngines').val(1);
  496.         });
  497.  
  498.         $(document).on('click', "#btn-eshop-setting", function () {
  499.             $('.all-fields-error').hide();
  500.             if ($("#eshopsettingform").valid()) {
  501.                 $commonFn.waitLoader("Please wait while we are saving your eshop setting.");
  502.                 $.when($eshopsetting.save()).then(function ($data) {
  503.                     $commonFn.closeWaitLoader();
  504.                     if ($data == "true") {
  505.                         //$eshopsetting.resetform();
  506.                         swal("Congratulations", "Your eshop settings has been updated successfully", "success");
  507.                         $('#set-eshopsettings i').removeClass('fa-times').removeClass('text-danger').addClass('fa-check').addClass('text-success');
  508.                     }
  509.                     else {
  510.                         swal("Oops...!", "Your eshop settings has not been updated", "error");
  511.                     }
  512.                 });
  513.             }
  514.             else {
  515.  
  516.                 $('.all-fields-error').show();
  517.             }
  518.         });
  519.  
  520.         $("#eshoptitle").keyup(function (event) {
  521.             var val = $("#eshoptitle").val();
  522.             $('#peshoptitle').html(val);
  523.             $eshop.countTitle(val);
  524.         });
  525.  
  526.         $("#eshopcontent").keyup(function (event) {
  527.             var val = $("#eshopcontent").val();
  528.             $('#peshopcontent').html(val);
  529.             $eshop.countContent(val);
  530.  
  531.         });
  532.     },
  533.  
  534.     save: function () {
  535.         $eshopsetting.EshopTitle = $('#eshoptitle').val();
  536.         $eshopsetting.EshopDescription = $('#eshopcontent').val();
  537.         $eshopsetting.EshopKeyWords = $('#eshopkeywordserach').val();
  538.         $eshopsetting.CompanyID = $('#eshopcompanyid').val();
  539.         $eshopsetting.AllowSearchEngines = $('#eshopAllowSearchEngines').val() == 1 ? true : false;
  540.  
  541.         var $data = JSON.stringify($eshopsetting);
  542.         var dfd = $.Deferred();
  543.         $.ajax({
  544.             type: "POST",
  545.             url: "/supplier/updateeshopsetting",
  546.             data: JSON.stringify({ Obj: $data }),
  547.             contentType: "application/json; charset=utf-8",
  548.             datatype: "json",
  549.             success: function (result) {
  550.                 dfd.resolve(result);
  551.                 return dfd.promise();
  552.             },
  553.             error: function (er) {
  554.                 var _er = er;
  555.                 return dfd.promise();
  556.             }
  557.         });
  558.         return dfd.promise();
  559.     },
  560.  
  561.     resetform: function () {
  562.         $('#eshoptitle').val('');
  563.         $('#eshopcontent').val('');
  564.         $('#eshopkeywordserach').val('');
  565.         $('#isserachallow').prop('checked', true);
  566.     }
  567. }
  568.  
  569. //$(document).ready(function () {
  570. //    $compconfig.init();
  571. //})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement