1 namespace('kivi.ShopPart', function(ns) {
4 ns.shop_part_dialog = function(title, html) {
5 var id = 'jqueryui_popup_dialog';
11 close: function(event, ui) { $dialog.remove(); },
16 $dialog = $('<div style="display:none" id="' + id + '"></div>').appendTo('body');
17 $dialog.attr('title', title);
19 $dialog.dialog(dialog_params);
21 $('.cancel').click(ns.close_dialog);
26 ns.close_dialog = function() {
27 $dialog.dialog("close");
30 ns.save_shop_part = function(shop_part_id) {
31 var form = $('form').serializeArray();
32 form.push( { name: 'action', value: 'ShopPart/update' }
33 , { name: 'shop_part_id', value: shop_part_id }
36 $.post('controller.pl', form, function(data) {
37 kivi.eval_json_result(data);
41 ns.add_shop_part = function(part_id,shop_id) {
42 var form = $('form').serializeArray();
43 form.push( { name: 'action', value: 'ShopPart/update' }
45 $.post('controller.pl', form, function(data) {
46 kivi.eval_json_result(data);
50 ns.edit_shop_part = function(shop_part_id) {
51 $.post('controller.pl', { action: 'ShopPart/create_or_edit_popup', shop_part_id: shop_part_id }, function(data) {
52 kivi.eval_json_result(data);
56 ns.create_shop_part = function(part_id, shop_id) {
57 $.post('controller.pl', { action: 'ShopPart/create_or_edit_popup', part_id: part_id, shop_id: shop_id }, function(data) {
58 kivi.eval_json_result(data);
62 ns.get_all_categories = function(shop_part_id) {
63 $.post('controller.pl', { action: 'ShopPart/get_categories', shop_part_id: shop_part_id }, function(data) {
64 kivi.eval_json_result(data);
68 ns.save_categories = function(shop_part_id, shop_id) {
69 var form = $('form').serializeArray();
70 form.push( { name: 'action', value: 'ShopPart/save_categories' }
71 , { name: 'shop_id', value: shop_id }
72 , { name: 'shop_part_id', value: shop_part_id }
75 $.post('controller.pl', form, function(data) {
76 kivi.eval_json_result(data);
80 ns.update_shop_part = function(shop_part_id) {
81 $.post('controller.pl', { action: 'ShopPart/update_shop', shop_part_id: shop_part_id }, function(data) {
82 kivi.eval_json_result(data);
86 ns.update_discount_source = function(row, source, discount_str) {
87 $('#active_discount_source_' + row).val(source);
88 if (discount_str) $('#discount_' + row).val(discount_str);
89 $('#update_button').click();
92 ns.show_images = function(id) {
93 var url = 'controller.pl?action=ShopPart/show_files&id='+id;
94 $('#shop_images').load(url);
97 ns.update_price_n_price_source = function(shop_part_id,price_source) {
98 $.post('controller.pl', { action: 'ShopPart/show_price_n_pricesource', shop_part_id: shop_part_id, pricesource: price_source }, function(data) {
99 kivi.eval_json_result(data);
103 ns.update_stock = function(shop_part_id) {
104 $.post('controller.pl', { action: 'ShopPart/show_stock', shop_part_id: shop_part_id }, function(data) {
105 kivi.eval_json_result(data);
109 ns.massUploadInitialize = function() {
111 id: 'status_mass_upload',
113 title: kivi.t8('Status Shopupload')
118 ns.massUploadStarted = function() {
119 $('#status_mass_upload').data('timerId', setInterval(function() {
120 $.get("controller.pl", {
121 action: 'ShopPart/upload_status',
122 job_id: $('#smu_job_id').val()
123 }, kivi.eval_json_result);
127 ns.massUploadFinished = function() {
128 clearInterval($('#status_mass_upload').data('timerId'));
129 $('.ui-dialog-titlebar button.ui-dialog-titlebar-close').prop('disabled', '')
132 ns.imageUpload = function(id,type,filetype,upload_title,gl) {
133 kivi.popup_dialog({ url: 'controller.pl',
134 data: { action: 'File/ajax_upload',
141 dialog: { title: kivi.t8('File upload'), width: 650, height: 240 } });
146 ns.setup = function() {
147 kivi.ShopPart.massUploadInitialize();
148 kivi.submit_ajax_form('controller.pl?action=ShopPart/mass_upload','[name=shop_parts]');