+ns.time_cost_estimate_input_key_down = function(event) {
+ if(event.keyCode == 13) {
+ event.preventDefault();
+ ns.standard_time_cost_estimate_ajax_call('save');
+ return false;
+ }
+};
+
+// -------------------------------------------------------------------------
+// --------------------------- quotations/orders ---------------------------
+// -------------------------------------------------------------------------
+
+ns.find_quotation_order_id = function(clicked_elt) {
+ return $(clicked_elt).find('>[name=order_id]').val();
+};
+
+ns.standard_quotation_order_ajax_call = function(key, opt) {
+ if (key == 'cancel') {
+ if (confirm(kivi.t8('Do you really want to cancel?'))) {
+ $('#quotations_and_orders').show();
+ $('#quotations_and_orders_article_assignment,#quotations_and_orders_new,#quotations_and_orders_update').remove();
+ }
+ return true;
+ }
+
+ else if ((key == 'create') && $('#quotations_and_orders_form INPUT[name="sections[].order_part_id"]').filter(function(idx, elt) { return ($(elt).val() || '') == '' }).size()) {
+ alert(kivi.t8('There is one or more sections for which no part has been assigned yet; therefore creating the new record is not possible yet.'));
+ return false;
+ }
+
+ var data = 'action=RequirementSpecOrder/' + key
+ + '&' + $('#requirement_spec_id').serialize();
+
+ if ((key == 'save_assignment') || (key == 'create') || (key == 'do_update'))
+ data += '&' + $('#quotations_and_orders_form').serialize();
+ else if ((key == 'update') || (key == 'delete'))
+ data += '&rs_order_id=' + encodeURIComponent(ns.find_quotation_order_id(opt.$trigger));
+
+ // console.log("I would normally POST the following now:");
+ // console.log(data);
+ $.post("controller.pl", data, kivi.eval_json_result);
+
+ return true;
+};
+
+ns.ask_delete_quotation_order = function(key, opt) {
+ if (confirm(kivi.t8("Are you sure?")))
+ ns.standard_quotation_order_ajax_call(key, opt);
+ return true;
+};
+
+ns.disable_edit_quotation_order_commands = function(key, opt) {
+ return ns.find_quotation_order_id(opt.$trigger) == undefined;
+};
+
+ns.disable_create_quotation_order_commands = function(key, opt) {
+ return !$('#quotations_and_orders_sections');
+};
+
+ns.assign_order_part_id_to_all = function() {
+ var order_part_id = $('#quotations_and_orders_order_id').val();
+ var order_part_name = $('#quotations_and_orders_order_id_name').val();
+
+ $('#quotations_and_orders_form INPUT[name="sections[].order_part_id"]').each(function(idx, elt) {
+ $(elt).val(order_part_id);
+ });
+
+ $('#quotations_and_orders_form [id^=quotations_and_orders_sections_order_pard_id_]').filter(function() {
+ return $(this).attr('id') && $(this).attr('id').match("^quotations_and_orders_sections_order_pard_id_[0-9]+_name$");
+ }).each(function(idx, elt) {
+ $(elt).val(order_part_name);
+ });
+};
+