Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var productrating = function () {
- this.ProductID = null;
- this.CompanyID = null;
- this.OverallRate = null;
- this.OverallFeedback = null;
- this.DescriptionRate = null;
- this.ImageRate = null;
- this.ProductDescriptionFeedback = null;
- this.ProductDescriptionImages = null;
- this.DeliveryRate = null;
- this.OrderStateRate = null;
- this.DeliveryFeedback = null;
- this.DeliveryImages = null;
- this.AfterSalesRate = null;
- this.AfterSalesFeedback = null;
- this.Isanonymous = null;
- this.ID = null;
- this.SaleID = null;
- }
- var $rpwizard = function () { };
- $rpwizard = {
- isloaded: false,
- attatchmentdescription: null,
- attatchmentdelivery: null,
- productid: null,
- companyid: null,
- feedbackid: null,
- saleid: null,
- init: function () {
- if (!this.isloaded) {
- this.isloaded = true;
- this.wizard.init();
- this.initfileupload();
- this.actions();
- }
- },
- initfileupload: function () {
- $("#pdescription").fileupload({
- //url: "/customer/Uploadcompanybrandstatus/",
- url: "/customer/Uploadproductrating/",
- autoUpload: !0,
- change: function (e, data) {
- var size = (data.files[0].size / 1024 / 1024).toFixed(2);
- if (size > 5) {
- swal("Cancelled", "Maximum file size limit is 5 MB.", "error");
- return false;
- }
- var count = $('#ptbodydescription tr').length;
- if (count == 5) {
- swal("Cancelled", "Maximum file upload limit is 5.", "error");
- return false;
- }
- },
- success: function (file) {
- var attach_name = $rpwizard.attatchmentdescription;
- var seperator = ",";
- var attach = "";
- if (attach_name != "") {
- attach_name = attach_name + seperator + file;
- attach = '<a href="' + file + '" target="blank" data-lightbox="roadtrip" class="myattach"><img class="img-rounded" src="' + file + '" height="0" width="0" /></a>';
- }
- else {
- attach_name = file;
- attach = '<a href="' + file + '" target="blank" data-lightbox="roadtrip" class="myattach"><img class="img-rounded" src="' + file + '" height="0" width="0" /></a>';
- }
- $rpwizard.attatchmentdescription = attach_name;
- }
- }),
- $.support.cors && $.ajax({ url: "/customer/Uploadproductrating/", type: "HEAD" }).fail(function () {
- $('<span class="alert alert-error"/>').text("Upload server currently unavailable - " + new Date).appendTo("#pdescription")
- });
- $("#pratedelivservice").fileupload({
- url: "/customer/Uploadproductrating/",
- autoUpload: !0,
- change: function (e, data) {
- var size = (data.files[0].size / 1024 / 1024).toFixed(2);
- if (size > 5) {
- swal("Cancelled", "Maximum file size limit is 5 MB.", "error");
- return false;
- }
- var count = $('#ptbodydelivery tr').length;
- if (count == 5) {
- swal("Cancelled", "Maximum file upload limit is 5.", "error");
- return false;
- }
- },
- success: function (file) {
- var attach_name = $rpwizard.attatchmentdelivery;
- var seperator = ",";
- var attach = "";
- if (attach_name != "") {
- attach_name = attach_name + seperator + file;
- attach = '<a href="' + file + '" target="blank" data-lightbox="roadtrip" class="myattach"><img class="img-rounded" src="' + file + '" height="0" width="0" /></a>';
- }
- else {
- attach_name = file;
- attach = '<a href="' + file + '" target="blank" data-lightbox="roadtrip" class="myattach"><img class="img-rounded" src="' + file + '" height="0" width="0" /></a>';
- }
- $rpwizard.attatchmentdelivery = attach_name;
- }
- }),
- $.support.cors && $.ajax({ url: "/customer/Uploadproductrating/", type: "HEAD" }).fail(function () {
- $('<span class="alert alert-error"/>').text("Upload server currently unavailable - " + new Date).appendTo("#pratedelivservice")
- });
- },
- deleteattatchment: function (img, id) {
- var attach_name = null;
- if (id == 'pdescription') {
- attach_name = $rpwizard.attatchmentdescription.split(",");
- }
- else {
- attach_name = $rpwizard.attatchmentdelivery.split(",");
- }
- var seperator = ",";
- var new_attach_name = "";
- var attach = "";
- for (var i = 0; i < attach_name.length; i++) {
- if (attach_name[i].indexOf(img) > -1) {
- // Do nothing
- }
- else {
- if (new_attach_name != "") {
- new_attach_name = new_attach_name + seperator + attach_name[i];
- }
- else {
- new_attach_name = attach_name[i];
- }
- }
- }
- if (id == 'pdescription') {
- $rpwizard.attatchmentdescription = new_attach_name;
- attach_name = $rpwizard.attatchmentdescription.split(",");
- }
- else {
- $rpwizard.attatchmentdelivery = new_attach_name;
- }
- },
- initload: function ($productid, $companyid, $saleid, $feedbackid) {
- if (!this.isloaded) {
- $rpwizard.init();
- this.isloaded = true;
- this.wizard.init();
- this.actions();
- }
- $rpwizard.reset();
- if (typeof $productid !== 'undefined') {
- $rpwizard.productid = $productid;
- }
- if (typeof $companyid !== 'undefined') {
- $rpwizard.companyid = $companyid;
- }
- if (typeof $feedbackid !== 'undefined') {
- $rpwizard.feedbackid = $feedbackid;
- }
- if (typeof $saleid !== 'undefined') {
- $rpwizard.saleid = $saleid;
- }
- if ($rpwizard.feedbackid != '') {
- $commonFn.waitLoader("Please wait while loading.");
- $.when($rpwizard.getfeedback()).then(function ($data) {
- $rpwizard.load($data);
- $commonFn.closeWaitLoader();
- $('#product-rating-modal').modal('show');
- });
- }
- else {
- $('#product-rating-modal').modal('show');
- }
- },
- getfeedback:function(){
- var dfd = $.Deferred();
- $.ajax({
- type: "GET",
- url: "/customer/getfeedbackproduct",
- data: { feedbackid: $rpwizard.feedbackid},
- 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();
- },
- load: function ($details) {
- $rpwizard.feedbackid = $details.ID;
- $rpwizard.saleid = $details.SaleID;
- $rpwizard.productid = $details.ProductID;
- $rpwizard.companyid = $details.CompanyID;
- $('#poverallrate').rating('update', $details.OverallRate).trigger('rating.change');
- $('#poverallfeedback').val($details.OverallFeedback);
- $('#pdescriptionrate').rating('update', $details.DeliveryRate).trigger('rating.change');
- $('#pimagerate').rating('update', $details.OrderStateRate).trigger('rating.change');
- $('#pdescriptionfeedback').val($details.ProductDescriptionFeedback);
- $('#ptbodydescription').html();
- var $html = ''
- if ($details.ProductDescriptionImages != "" && $details.ProductDescriptionImages != null) {
- var $img = $details.ProductDescriptionImages.split(',');
- $.each($img, function (i, $ite) {
- if ($ite != "null") {
- $html = $html + '<tr class="template-download fade in">'
- $html = $html + '<td class="name" width="30%">'
- $html = $html + '<a href="' + $ite + '" title="' + $ite.split("/").pop(-1) + '" target="_blank" data-gallery="" download="' + $ite.split("/").pop(-1) + '">' + $ite.split("/").pop(-1) + '</a>'
- $html = $html + '</td>'
- $html = $html + '<td class="size" width="40%">'
- $html = $html + '<span></span>'
- $html = $html + '</td>'
- $html = $html + '<td colspan="2"></td>'
- $html = $html + '<td class="delete" width="10%" align="right">'
- $html = $html + '<button class="btn default btn-sm" onclick="$rpwizard.deleteattatchment(\'' + $ite + '\',\'pdescription\')" data-type="" data-url="">'
- $html = $html + '<i class="fa fa-times"></i>'
- $html = $html + '</button>'
- $html = $html + '</td>'
- $html = $html + '</tr>'
- }
- })
- }
- $('#ptbodydescription').html($html);
- $rpwizard.attatchmentdescription = $details.ProductDescriptionImages;
- $('#pdeliveryrate').rating('update', $details.DeliveryRate).trigger('rating.change');
- $('#porderstaterate').rating('update', $details.OrderStateRate).trigger('rating.change');
- $('#pdeliveryfeedback').val($details.DeliveryFeedback);
- $('#ptbodydelivery').html();
- var $html = '';
- if ($details.DeliveryImages != "" && $details.DeliveryImages != null) {
- var $img = $details.DeliveryImages.split(',');
- $.each($img, function (i, $ite) {
- if ($ite != "null") {
- $html = $html + '<tr class="template-download fade in">'
- $html = $html + '<td class="name" width="30%">'
- $html = $html + '<a href="' + $ite + '" title="' + $ite.split("/").pop(-1) + '" target="_blank" data-gallery="" download="' + $ite.split("/").pop(-1) + '">' + $ite.split("/").pop(-1) + '</a>'
- $html = $html + '</td>'
- $html = $html + '<td class="size" width="40%">'
- $html = $html + '<span></span>'
- $html = $html + '</td>'
- $html = $html + '<td colspan="2"></td>'
- $html = $html + '<td class="delete" width="10%" align="right">'
- $html = $html + '<button class="btn default btn-sm" onclick="$rpwizard.deleteattatchment(\'' + $ite + '\',\'ptbodydelivery\')" data-type="" data-url="">'
- $html = $html + '<i class="fa fa-times"></i>'
- $html = $html + '</button>'
- $html = $html + '</td>'
- $html = $html + '</tr>'
- }
- })
- }
- $('#ptbodydelivery').html($html);
- $rpwizard.attatchmentdelivery = $details.DeliveryImages;
- $('#paftersalesrate').rating('update', $details.AfterSalesRate).trigger('rating.change');
- $('#paftersalesfeedback').val($details.AfterSalesFeedback);
- $details.Isanonymous == true ? $('#pisanonymous').prop('checked', true) : $('#pisanonymous').prop('checked', false);
- },
- actions: function () {
- $("#poverallrate").on('rating.change', function () {
- $('#errpoverallrate').addnd();
- });
- $("#pdescriptionrate").on('rating.change', function () {
- $("#errpdescriptionrate").addnd();
- });
- $("#pimagerate").on('rating.change', function () {
- $("#errpimagerate").addnd();
- });
- $("#pdeliveryrate").on('rating.change', function () {
- $("#errpdeliveryrate").addnd();
- });
- $("#porderstaterate").on('rating.change', function () {
- $("#errporderstaterate").addnd();
- });
- $("#paftersalesrate").on('rating.change', function () {
- $("#errpaftersalesrate").addnd();
- });
- },
- reset: function () {
- //$('#poverallrate').rating('update', 4).trigger('rating.change');
- $("#productratingwizard").wizard('goTo', 0);
- $rpwizard.productid = null;
- $rpwizard.companyid = null;
- $rpwizard.feedbackid = null;
- $rpwizard.saleid = null;
- $('#poverallrate').rating('reset').trigger('rating.change');
- $('#poverallfeedback').val('');
- $('#pdescriptionrate').rating('reset').trigger('rating.change');
- $('#pimagerate').rating('reset').trigger('rating.change');
- $('#pdescriptionfeedback').val('');
- $rpwizard.attatchmentdescription = null;
- $('#pdeliveryrate').rating('reset').trigger('rating.change');
- $('#porderstaterate').rating('reset').trigger('rating.change');
- $('#pdeliveryfeedback').val('');
- $rpwizard.attatchmentdelivery = null;
- $('#paftersalesrate').rating('reset').trigger('rating.change');
- $('#paftersalesfeedback').val('');
- $('#pisanonymous').prop('checked', false);
- $("#ptbodydescription").html("");
- $("#ptbodydelivery").html("");
- $('#errpoverallrate').addnd();
- $("#errpdescriptionrate").addnd();
- $("#errpimagerate").addnd();
- $("#errpdeliveryrate").addnd();
- $("#errporderstaterate").addnd();
- $("#errpaftersalesrate").addnd();
- },
- wizard: {
- init: function () {
- $('#pratesellerform').formValidation({
- framework: 'bootstrap',
- fields: {
- //p_depositamount: {
- // validators: {
- // notEmpty: {
- // message: 'Please enter amount'
- // }
- // }
- //}
- },
- err: {
- clazz: 'text-help'
- },
- row: {
- invalid: 'has-danger'
- }
- });
- $('#pdescriptionForm').formValidation({
- framework: 'bootstrap',
- fields: {
- //p_depositamount: {
- // validators: {
- // notEmpty: {
- // message: 'Please enter amount'
- // }
- // }
- //}
- },
- err: {
- clazz: 'text-help'
- },
- row: {
- invalid: 'has-danger'
- }
- });
- $('#pratedelivserviceForm').formValidation({
- framework: 'bootstrap',
- fields: {
- //p_depositamount: {
- // validators: {
- // notEmpty: {
- // message: 'Please enter amount'
- // }
- // }
- //}
- },
- err: {
- clazz: 'text-help'
- },
- row: {
- invalid: 'has-danger'
- }
- });
- $('#prateaftersaleForm').formValidation({
- framework: 'bootstrap',
- fields: {
- //p_depositamount: {
- // validators: {
- // notEmpty: {
- // message: 'Please enter amount'
- // }
- // }
- //}
- },
- err: {
- clazz: 'text-help'
- },
- row: {
- invalid: 'has-danger'
- }
- });
- var defaults = $rpwizard.wizard.getdefaults();
- var options = $.extend(true, {}, defaults, {
- submited: false,
- onNext: function (from, to) {
- },
- onBack: function (from, to) {
- },
- onFinish: function () {
- },
- keyboard: false,
- buttonsAppendTo: '.prating-wizard-buttons'
- });
- var wizardproduct = $("#productratingwizard").wizard(options).data('wizard');
- wizardproduct.get("#prateseller").setValidator(function () {
- var fv = $("#pratesellerform").data('formValidation');
- fv.validate();
- if (!fv.isValid()) {
- return false;
- }
- if ($("#poverallrate").val() == 0) {
- $("#errpoverallrate").removend();
- return false;
- }
- return true;
- });
- wizardproduct.get("#pdescription").setValidator(function () {
- var fv = $("#pdescriptionForm").data('formValidation');
- fv.validate();
- if (!fv.isValid()) {
- return false;
- }
- if ($("#pdescriptionrate").val() == 0) {
- $("#errpdescriptionrate").removend();
- return false;
- }
- if ($("#pimagerate").val() == 0) {
- $("#errpimagerate").removend();
- return false;
- }
- return true;
- });
- wizardproduct.get("#pratedelivservice").setValidator(function () {
- var fv = $("#pratedelivserviceForm").data('formValidation');
- fv.validate();
- if (!fv.isValid()) {
- return false;
- }
- if ($("#pdeliveryrate").val() == 0) {
- $("#errpdeliveryrate").removend();
- return false;
- }
- if ($("#porderstaterate").val() == 0) {
- $("#errporderstaterate").removend();
- return false;
- }
- return true;
- });
- wizardproduct.get("#prateaftersale").setValidator(function () {
- var fv = $("#prateaftersaleForm").data('formValidation');
- fv.validate();
- if (!fv.isValid()) {
- return false;
- }
- return true;
- });
- },
- getdefaults: function () {
- return {
- step: '.steps .step, .pearls .pearl',
- templates: {
- buttons: function buttons() {
- var options = this.options;
- return '<div class="wizard-buttons"><a class="btn btn-sm btn-prev" href="#' + this.id + '" data-wizard="back" role="button"><i class="fa fa-angle-left"></i>' + options.buttonLabels.back + '</a><a class="btn btn-sm btn-next pull-right" href="#' + this.id + '" data-wizard="next" role="button">' + options.buttonLabels.next + ' <i class="fa fa-angle-right"></i></a>' +
- '<a class="btn btn-sm btn-finish pull-right" id="pw_btn_finish" onclick="$rpwizard.wizard.finish()" href="#' + this.id + '" data-wizard="finish" role="button"><i class="fa fa-save"></i> <span>Save Feedback</span></a></div>';
- }
- },
- classes: {
- button: {
- hide: 'hidden-up',
- disabled: 'disabled'
- }
- }
- };
- },
- finish: function () {
- if ($("#paftersalesrate").val() == 0) {
- $("#errpaftersalesrate").removend();
- return false;
- }
- else {
- $rpwizard.create.init();
- }
- }
- },
- setobject: function () {
- var $rating = new servicerating();
- $rating.ID = $rpwizard.feedbackid;
- $rating.SaleID = $rpwizard.saleid;
- $rating.ProductID = $rpwizard.productid;
- $rating.CompanyID = $rpwizard.companyid;
- $rating.OverallRate = $('#poverallrate').val();
- $rating.OverallFeedback = $('#poverallfeedback').val();
- $rating.DescriptionRate = $('#pdescriptionrate').val();
- $rating.ImageRate = $('#pimagerate').val();
- $rating.ProductDescriptionFeedback = $('#pdescriptionfeedback').val();;
- $rating.ProductDescriptionImages = $rpwizard.attatchmentdescription;
- $rating.DeliveryRate = $('#pdeliveryrate').val();
- $rating.OrderStateRate = $('#porderstaterate').val();
- $rating.DeliveryFeedback = $('#pdeliveryfeedback').val();
- $rating.DeliveryImages = $rpwizard.attatchmentdelivery;
- $rating.AfterSalesRate = $('#paftersalesrate').val();
- $rating.AfterSalesFeedback = $('#paftersalesfeedback').val();
- $rating.Isanonymous = $('#pisanonymous').prop('checked') ? true : false;
- return $rating;
- },
- create: {
- init: function () {
- $('#product-rating-modal').modal('hide');
- $commonFn.waitLoader("Please wait while we are saving your feedback.");
- $.when($rpwizard.create.save()).then(function ($data) {
- $commonFn.closeWaitLoader();
- if ($data == "true") {
- if ($rpwizard.feedbackid != '') {
- swal("Congratulation", "Your feedback has been updated successfully.", "success");
- }
- else {
- swal("Congratulation", "Your feedback has been saved successfully.", "success");
- }
- }
- else {
- swal("Oops...!", "Some error has been occurred please try after some time.", "error");
- }
- $rpwizard.reset();
- });
- },
- save: function () {
- var $rating = $rpwizard.setobject();
- var dfd = $.Deferred();
- $.ajax({
- type: "POST",
- url: "/customer/saveproductrating",
- data: JSON.stringify({ rating: $rating }),
- contentType: "application/json; charset=utf-8",
- datatype: "json",
- processData: false,
- success: function (result) {
- dfd.resolve(result);
- return dfd.promise();
- },
- error: function (er) {
- var _er = er;
- return dfd.promise();
- }
- });
- return dfd.promise();
- }
- },
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement