Revision 4369213f
Von Werner Hahn vor etwa 7 Jahren hinzugefügt
js/kivi.ShopPart.js | ||
---|---|---|
1 |
namespace('kivi.shop_part', function(ns) { |
|
2 |
var $dialog; |
|
3 |
|
|
4 |
// this is called by sub render, with a certain prerendered html (edit.html,categories.html) |
|
5 |
ns.shop_part_dialog = function(title, html) { |
|
6 |
var id = 'jqueryui_popup_dialog'; |
|
7 |
var dialog_params = { |
|
8 |
id: id, |
|
9 |
width: 800, |
|
10 |
height: 500, |
|
11 |
modal: true, |
|
12 |
close: function(event, ui) { $dialog.remove(); }, |
|
13 |
}; |
|
14 |
|
|
15 |
$('#' + id).remove(); |
|
16 |
|
|
17 |
$dialog = $('<div style="display:none" id="' + id + '"></div>').appendTo('body'); |
|
18 |
$dialog.attr('title', title); |
|
19 |
$dialog.html(html); |
|
20 |
$dialog.dialog(dialog_params); |
|
21 |
|
|
22 |
$('.cancel').click(ns.close_dialog); |
|
23 |
|
|
24 |
return true; |
|
25 |
}; |
|
26 |
|
|
27 |
ns.close_dialog = function() { |
|
28 |
$dialog.dialog("close"); |
|
29 |
} |
|
30 |
|
|
31 |
|
|
32 |
// save existing shop_part_id with new params from form, calls create_or_update and saves to db |
|
33 |
ns.save_shop_part = function(shop_part_id) { |
|
34 |
var form = $('form').serializeArray(); |
|
35 |
form.push( { name: 'action', value: 'ShopPart/update' } |
|
36 |
, { name: 'shop_part_id', value: shop_part_id } |
|
37 |
); |
|
38 |
|
|
39 |
$.post('controller.pl', form, function(data) { |
|
40 |
kivi.eval_json_result(data); |
|
41 |
}); |
|
42 |
} |
|
43 |
|
|
44 |
// add part to a shop |
|
45 |
ns.add_shop_part = function(part_id,shop_id) { |
|
46 |
var form = $('form').serializeArray(); |
|
47 |
form.push( { name: 'action', value: 'ShopPart/update' } |
|
48 |
); |
|
49 |
$.post('controller.pl', form, function(data) { |
|
50 |
kivi.eval_json_result(data); |
|
51 |
}); |
|
52 |
} |
|
53 |
|
|
54 |
// this is called from tabs/_shop.html, opens edit_window (render) |
|
55 |
ns.edit_shop_part = function(shop_part_id) { |
|
56 |
$.post('controller.pl', { action: 'ShopPart/create_or_edit_popup', shop_part_id: shop_part_id }, function(data) { |
|
57 |
kivi.eval_json_result(data); |
|
58 |
}); |
|
59 |
} |
|
60 |
|
|
61 |
// does the same as edit_shop_part (existing), but with part_id and shop_id, opens edit window (render) |
|
62 |
ns.create_shop_part = function(part_id, shop_id) { |
|
63 |
$.post('controller.pl', { action: 'ShopPart/create_or_edit_popup', part_id: part_id, shop_id: shop_id }, function(data) { |
|
64 |
kivi.eval_json_result(data); |
|
65 |
}); |
|
66 |
} |
|
67 |
|
|
68 |
// gets all categories from the webshop |
|
69 |
ns.get_all_categories = function(shop_part_id) { |
|
70 |
//var form = new Array; //$('form').serializeArray(); |
|
71 |
//form.push( { name: 'action', value: 'ShopPart/get_categories' } |
|
72 |
// , { name: 'shop_part_id', value: shop_part_id } |
|
73 |
//); |
|
74 |
$.post('controller.pl', { action: 'ShopPart/get_categories', shop_part_id: shop_part_id }, function(data) { |
|
75 |
kivi.eval_json_result(data); |
|
76 |
}); |
|
77 |
//$.post('controller.pl', form, function(data) { |
|
78 |
// kivi.eval_json_result(data); |
|
79 |
//}); |
|
80 |
} |
|
81 |
// write categories in kivi DB not in the shops DB TODO: create new categories in the shops db |
|
82 |
ns.save_categories = function(shop_part_id, shop_id) { |
|
83 |
var form = $('form').serializeArray(); |
|
84 |
form.push( { name: 'action', value: 'ShopPart/save_categories' } |
|
85 |
, { name: 'shop_id', value: shop_id } |
|
86 |
, { name: 'shop_part_id', value: shop_part_id } |
|
87 |
); |
|
88 |
|
|
89 |
$.post('controller.pl', form, function(data) { |
|
90 |
kivi.eval_json_result(data); |
|
91 |
}); |
|
92 |
} |
|
93 |
|
|
94 |
ns.update_shop_part = function(shop_part_id) { |
|
95 |
$.post('controller.pl', { action: 'ShopPart/update_shop', shop_part_id: shop_part_id }, function(data) { |
|
96 |
kivi.eval_json_result(data); |
|
97 |
}); |
|
98 |
} |
|
99 |
|
|
100 |
ns.update_discount_source = function(row, source, discount_str) { |
|
101 |
$('#active_discount_source_' + row).val(source); |
|
102 |
if (discount_str) $('#discount_' + row).val(discount_str); |
|
103 |
$('#update_button').click(); |
|
104 |
} |
|
105 |
|
|
106 |
ns.show_images = function(id) { |
|
107 |
var url = 'controller.pl?action=ShopPart/show_files&modul=shop_part&id='+id; |
|
108 |
$('#shop_images').load(url); |
|
109 |
} |
|
110 |
|
|
111 |
//shows the Name and price in _shop.html. Pricerules not implemented yet, just master_data and pricegroups |
|
112 |
ns.update_price_n_price_source = function(shop_part_id,price_source) { |
|
113 |
$.post('controller.pl', { action: 'ShopPart/show_price_n_pricesource', shop_part_id: shop_part_id, pricesource: price_source }, function(data) { |
|
114 |
kivi.eval_json_result(data); |
|
115 |
}); |
|
116 |
} |
|
117 |
//shows the local and the online stock |
|
118 |
ns.update_stock = function(shop_part_id) { |
|
119 |
$.post('controller.pl', { action: 'ShopPart/show_stock', shop_part_id: shop_part_id }, function(data) { |
|
120 |
kivi.eval_json_result(data); |
|
121 |
}); |
|
122 |
} |
|
123 |
|
|
124 |
ns.massUploadInitialize = function() { |
|
125 |
kivi.popup_dialog({ |
|
126 |
id: 'status_mass_upload', |
|
127 |
dialog: { |
|
128 |
title: kivi.t8('Status Shopupload') |
|
129 |
} |
|
130 |
}); |
|
131 |
}; |
|
132 |
|
|
133 |
ns.massUploadStarted = function() { |
|
134 |
$('#status_mass_upload').data('timerId', setInterval(function() { |
|
135 |
$.get("controller.pl", { |
|
136 |
action: 'ShopPart/upload_status', |
|
137 |
job_id: $('#smu_job_id').val() |
|
138 |
}, kivi.eval_json_result); |
|
139 |
}, 5000)); |
|
140 |
}; |
|
141 |
|
|
142 |
ns.massUploadFinished = function() { |
|
143 |
clearInterval($('#status_mass_upload').data('timerId')); |
|
144 |
$('.ui-dialog-titlebar button.ui-dialog-titlebar-close').prop('disabled', '') |
|
145 |
}; |
|
146 |
|
|
147 |
ns.imageUpload = function(id,type,filetype,upload_title,gl) { |
|
148 |
kivi.popup_dialog({ url: 'controller.pl', |
|
149 |
data: { action: 'File/ajax_upload', |
|
150 |
file_type: filetype, |
|
151 |
object_type: type, |
|
152 |
object_id: id, |
|
153 |
is_global: gl |
|
154 |
}, |
|
155 |
id: 'files_upload', |
|
156 |
dialog: { title: upload_title, width: 650, height: 240 } }); |
|
157 |
return true; |
|
158 |
} |
|
159 |
|
|
160 |
|
|
161 |
ns.setup = function() { |
|
162 |
kivi.shop_part.massUploadInitialize(); |
|
163 |
kivi.submit_ajax_form('controller.pl?action=ShopPart/mass_upload','[name=shop_parts]'); |
|
164 |
}; |
|
165 |
|
|
166 |
}); |
js/kivi.shop_part.js | ||
---|---|---|
1 |
namespace('kivi.shop_part', function(ns) { |
|
2 |
var $dialog; |
|
3 |
|
|
4 |
// this is called by sub render, with a certain prerendered html (edit.html,categories.html) |
|
5 |
ns.shop_part_dialog = function(title, html) { |
|
6 |
var id = 'jqueryui_popup_dialog'; |
|
7 |
var dialog_params = { |
|
8 |
id: id, |
|
9 |
width: 800, |
|
10 |
height: 500, |
|
11 |
modal: true, |
|
12 |
close: function(event, ui) { $dialog.remove(); }, |
|
13 |
}; |
|
14 |
|
|
15 |
$('#' + id).remove(); |
|
16 |
|
|
17 |
$dialog = $('<div style="display:none" id="' + id + '"></div>').appendTo('body'); |
|
18 |
$dialog.attr('title', title); |
|
19 |
$dialog.html(html); |
|
20 |
$dialog.dialog(dialog_params); |
|
21 |
|
|
22 |
$('.cancel').click(ns.close_dialog); |
|
23 |
|
|
24 |
return true; |
|
25 |
}; |
|
26 |
|
|
27 |
ns.close_dialog = function() { |
|
28 |
$dialog.dialog("close"); |
|
29 |
} |
|
30 |
|
|
31 |
|
|
32 |
// save existing shop_part_id with new params from form, calls create_or_update and saves to db |
|
33 |
ns.save_shop_part = function(shop_part_id) { |
|
34 |
var form = $('form').serializeArray(); |
|
35 |
form.push( { name: 'action', value: 'ShopPart/update' } |
|
36 |
, { name: 'shop_part_id', value: shop_part_id } |
|
37 |
); |
|
38 |
|
|
39 |
$.post('controller.pl', form, function(data) { |
|
40 |
kivi.eval_json_result(data); |
|
41 |
}); |
|
42 |
} |
|
43 |
|
|
44 |
// add part to a shop |
|
45 |
ns.add_shop_part = function(part_id,shop_id) { |
|
46 |
var form = $('form').serializeArray(); |
|
47 |
form.push( { name: 'action', value: 'ShopPart/update' } |
|
48 |
); |
|
49 |
$.post('controller.pl', form, function(data) { |
|
50 |
kivi.eval_json_result(data); |
|
51 |
}); |
|
52 |
} |
|
53 |
|
|
54 |
// this is called from tabs/_shop.html, opens edit_window (render) |
|
55 |
ns.edit_shop_part = function(shop_part_id) { |
|
56 |
$.post('controller.pl', { action: 'ShopPart/create_or_edit_popup', shop_part_id: shop_part_id }, function(data) { |
|
57 |
kivi.eval_json_result(data); |
|
58 |
}); |
|
59 |
} |
|
60 |
|
|
61 |
// does the same as edit_shop_part (existing), but with part_id and shop_id, opens edit window (render) |
|
62 |
ns.create_shop_part = function(part_id, shop_id) { |
|
63 |
$.post('controller.pl', { action: 'ShopPart/create_or_edit_popup', part_id: part_id, shop_id: shop_id }, function(data) { |
|
64 |
kivi.eval_json_result(data); |
|
65 |
}); |
|
66 |
} |
|
67 |
|
|
68 |
// gets all categories from the webshop |
|
69 |
ns.get_all_categories = function(shop_part_id) { |
|
70 |
//var form = new Array; //$('form').serializeArray(); |
|
71 |
//form.push( { name: 'action', value: 'ShopPart/get_categories' } |
|
72 |
// , { name: 'shop_part_id', value: shop_part_id } |
|
73 |
//); |
|
74 |
$.post('controller.pl', { action: 'ShopPart/get_categories', shop_part_id: shop_part_id }, function(data) { |
|
75 |
kivi.eval_json_result(data); |
|
76 |
}); |
|
77 |
//$.post('controller.pl', form, function(data) { |
|
78 |
// kivi.eval_json_result(data); |
|
79 |
//}); |
|
80 |
} |
|
81 |
// write categories in kivi DB not in the shops DB TODO: create new categories in the shops db |
|
82 |
ns.save_categories = function(shop_part_id, shop_id) { |
|
83 |
var form = $('form').serializeArray(); |
|
84 |
form.push( { name: 'action', value: 'ShopPart/save_categories' } |
|
85 |
, { name: 'shop_id', value: shop_id } |
|
86 |
, { name: 'shop_part_id', value: shop_part_id } |
|
87 |
); |
|
88 |
|
|
89 |
$.post('controller.pl', form, function(data) { |
|
90 |
kivi.eval_json_result(data); |
|
91 |
}); |
|
92 |
} |
|
93 |
|
|
94 |
ns.update_shop_part = function(shop_part_id) { |
|
95 |
$.post('controller.pl', { action: 'ShopPart/update_shop', shop_part_id: shop_part_id }, function(data) { |
|
96 |
kivi.eval_json_result(data); |
|
97 |
}); |
|
98 |
} |
|
99 |
|
|
100 |
ns.update_discount_source = function(row, source, discount_str) { |
|
101 |
$('#active_discount_source_' + row).val(source); |
|
102 |
if (discount_str) $('#discount_' + row).val(discount_str); |
|
103 |
$('#update_button').click(); |
|
104 |
} |
|
105 |
|
|
106 |
ns.show_images = function(id) { |
|
107 |
var url = 'controller.pl?action=ShopPart/show_files&modul=shop_part&id='+id; |
|
108 |
$('#shop_images').load(url); |
|
109 |
} |
|
110 |
|
|
111 |
//shows the Name and price in _shop.html. Pricerules not implemented yet, just master_data and pricegroups |
|
112 |
ns.update_price_n_price_source = function(shop_part_id,price_source) { |
|
113 |
$.post('controller.pl', { action: 'ShopPart/show_price_n_pricesource', shop_part_id: shop_part_id, pricesource: price_source }, function(data) { |
|
114 |
kivi.eval_json_result(data); |
|
115 |
}); |
|
116 |
} |
|
117 |
//shows the local and the online stock |
|
118 |
ns.update_stock = function(shop_part_id) { |
|
119 |
$.post('controller.pl', { action: 'ShopPart/show_stock', shop_part_id: shop_part_id }, function(data) { |
|
120 |
kivi.eval_json_result(data); |
|
121 |
}); |
|
122 |
} |
|
123 |
|
|
124 |
ns.massUploadInitialize = function() { |
|
125 |
kivi.popup_dialog({ |
|
126 |
id: 'status_mass_upload', |
|
127 |
dialog: { |
|
128 |
title: kivi.t8('Status Shopupload') |
|
129 |
} |
|
130 |
}); |
|
131 |
}; |
|
132 |
|
|
133 |
ns.massUploadStarted = function() { |
|
134 |
$('#status_mass_upload').data('timerId', setInterval(function() { |
|
135 |
$.get("controller.pl", { |
|
136 |
action: 'ShopPart/upload_status', |
|
137 |
job_id: $('#smu_job_id').val() |
|
138 |
}, kivi.eval_json_result); |
|
139 |
}, 5000)); |
|
140 |
}; |
|
141 |
|
|
142 |
ns.massUploadFinished = function() { |
|
143 |
clearInterval($('#status_mass_upload').data('timerId')); |
|
144 |
$('.ui-dialog-titlebar button.ui-dialog-titlebar-close').prop('disabled', '') |
|
145 |
}; |
|
146 |
|
|
147 |
ns.imageUpload = function(id,type,filetype,upload_title,gl) { |
|
148 |
kivi.popup_dialog({ url: 'controller.pl', |
|
149 |
data: { action: 'File/ajax_upload', |
|
150 |
file_type: filetype, |
|
151 |
object_type: type, |
|
152 |
object_id: id, |
|
153 |
is_global: gl |
|
154 |
}, |
|
155 |
id: 'files_upload', |
|
156 |
dialog: { title: upload_title, width: 650, height: 240 } }); |
|
157 |
return true; |
|
158 |
} |
|
159 |
|
|
160 |
|
|
161 |
ns.setup = function() { |
|
162 |
kivi.shop_part.massUploadInitialize(); |
|
163 |
kivi.submit_ajax_form('controller.pl?action=ShopPart/mass_upload','[name=shop_parts]'); |
|
164 |
}; |
|
165 |
|
|
166 |
}); |
Auch abrufbar als: Unified diff
Shopmodul: js Datei unbenannt CamelCase