Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision c8e91c4e

Von Tamino Steinert vor etwa 1 Jahr hinzugefügt

  • ID c8e91c4ee39a8915449a2edfcd6257e45d575baa
  • Vorgänger 4cff1777
  • Nachfolger 1881b66a

Records: js-save Aufrufe angepasst und vereinheitlicht

Unterschiede anzeigen:

js/kivi.Reclamation.js
63 63
    }
64 64
  };
65 65

  
66
  ns.save = function(action, warn_on_duplicates, warn_on_reqdate) {
66
  ns.save = function(params) {
67 67
    if (!ns.check_cv()) return;
68

  
69
    const action             = params.action;
70
    const warn_on_duplicates = params.warn_on_duplicates;
71
    const warn_on_reqdate    = params.warn_on_reqdate;
72
    const form_params        = params.form_params;
73

  
68 74
    if (warn_on_duplicates && !ns.check_duplicate_parts()) return;
69 75
    if (warn_on_reqdate    && !ns.check_valid_reqdate())   return;
70 76
    if (!ns.check_valid_reasons())                     return;
71 77

  
72 78
    var data = $('#reclamation_form').serializeArray();
73 79
    data.push({ name: 'action', value: 'Reclamation/' + action });
80
    if (form_params) {
81
      if (Array.isArray(form_params)) {
82
        form_params.forEach(function(item) {
83
          data.push(item);
84
        });
85
      } else {
86
        data.push(form_params);
87
      }
88
    }
74 89

  
75 90
    $.post("controller.pl", data, kivi.eval_json_result);
76 91
  };
......
692 707
    kivi.SalesPurchase.edit_custom_shipto();
693 708
  };
694 709

  
695
  ns.purchase_reclamation_check_for_direct_delivery = function() {
710
  ns.purchase_reclamation_check_for_direct_delivery = function(save_params) {
696 711
    if ($('#type').val() != 'sales_reclamation') {
697 712
      return alert(kivi.t8("Error: This is not a sales reclamation."));
698 713
    }
......
703 718
      empty = false;
704 719
      shipto = $('#reclamation_shipto_id option:selected').text();
705 720
    } else {
706
      $('#shipto_inputs [id^="shipto"]').each(function(idx, elt) {
721
      $('#shipto_inputs [id^="shipto"]').each(function(_idx, elt) {
707 722
        if (!empty)                                     return;
708 723
        if (/^shipto_to_copy/.test($(elt).prop('id')))  return;
709 724
        if (/^shiptocp_gender/.test($(elt).prop('id'))) return;
......
714 729
        }
715 730
      });
716 731
      var shipto_elements = [];
717
      $([$('#shiptoname').val(), $('#shiptostreet').val(), $('#shiptozipcode').val(), $('#shiptocity').val()]).each(function(idx, elt) {
732
      $([$('#shiptoname').val(), $('#shiptostreet').val(), $('#shiptozipcode').val(), $('#shiptocity').val()]).each(function(_idx, elt) {
718 733
        if (elt !== '') shipto_elements.push(elt);
719 734
      });
720 735
      shipto = shipto_elements.join('; ');
721 736
    }
722 737

  
723 738
    if (!empty) {
724
      ns.direct_delivery_dialog(shipto);
739
      ns.direct_delivery_dialog(shipto, save_params);
725 740
    } else {
726
      ns.save('save_and_purchase_reclamation');
741
      ns.save(save_params);
727 742
    }
728 743
  };
729 744

  
730
  ns.direct_delivery_callback = function(accepted) {
745
  ns.direct_delivery_callback = function(accepted, save_params) {
731 746
    $('#direct-delivery-dialog').dialog('close');
732 747

  
733 748
    if (accepted) {
734 749
      $('<input type="hidden" name="use_shipto">').appendTo('#reclamation_form').val('1');
735 750
    }
736 751

  
737
    ns.save('save_and_purchase_reclamation');
752
    ns.save(save_params);
738 753
  };
739 754

  
740
  ns.direct_delivery_dialog = function(shipto) {
755
  ns.direct_delivery_dialog = function(shipto, save_params) {
741 756
    $('#direct-delivery-dialog').remove();
742 757

  
758
    var save_params_string = '{';
759
    if (save_params) {
760
      const action             = save_params.action;
761
      const warn_on_duplicates = save_params.warn_on_duplicates;
762
      const warn_on_reqdate    = save_params.warn_on_reqdate;
763
      const form_params        = save_params.form_params;
764

  
765

  
766
      console.log(form_params)
767
      console.log(Array.isArray(form_params))
768
      if (action)
769
        save_params_string += `'action':'${action}',`;
770
      if (warn_on_duplicates)
771
        save_params_string += `'warn_on_duplicates':'${warn_on_duplicates}',`;
772
      if (warn_on_reqdate)
773
        save_params_string += `'warn_on_reqdate':'${warn_on_reqdate}',`;
774
      if (Array.isArray(form_params)) {
775
        save_params_string += 'form_params:['
776
        form_params.forEach(function(item) {
777
          save_params_string += `{'name':'${item.name}','value':'${item.value}'},`;
778
        });
779
        save_params_string += ']';
780
      } else {
781
        save_params_string += `'form_params':{'name':'${form_params.name}','value':'${form_params.value}'}`;
782
      }
783
    }
784
    save_params_string += '}';
785

  
786
    console.log(save_params_string);
787

  
743 788
    var text1 = kivi.t8('You have entered or selected the following shipping address for this customer:');
744 789
    var text2 = kivi.t8('Do you want to carry this shipping address over to the new purchase reclamation so that the vendor can deliver the goods directly to your customer?');
745 790
    var html  = '<div id="direct-delivery-dialog"><p>' + text1 + '</p><p>' + shipto + '</p><p>' + text2 + '</p>';
746 791
    html      = html + '<hr><p>';
747
    html      = html + '<input type="button" value="' + kivi.t8('Yes') + '" size="30" onclick="kivi.Reclamation.direct_delivery_callback(true)">';
792
    html      = html + '<input type="button" value="' + kivi.t8('Yes') + '" size="30" onclick="kivi.Reclamation.direct_delivery_callback(true,' + save_params_string + ')">';
748 793
    html      = html + '&nbsp;';
749
    html      = html + '<input type="button" value="' + kivi.t8('No')  + '" size="30" onclick="kivi.Reclamation.direct_delivery_callback(false)">';
794
    html      = html + '<input type="button" value="' + kivi.t8('No')  + '" size="30" onclick="kivi.Reclamation.direct_delivery_callback(false,' + save_params_string + ')">';
750 795
    html      = html + '</p></div>';
751 796
    $(html).hide().appendTo('#reclamation_form');
752 797

  

Auch abrufbar als: Unified diff