www/js/import_ingredients.js

Sat, 25 Sep 2021 10:42:54 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sat, 25 Sep 2021 10:42:54 +0200
changeset 778
e64fd38c469c
parent 529
bb8a37fe6326
permissions
-rw-r--r--

If during styles import the CATEGORY_NUMBER is empty, insert 0 in the database instead.

311
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /*****************************************************************************
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 * Copyright (C) 2019
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 *
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 * Michiel Broek <mbroek at mbse dot eu>
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 *
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 * This file is part of BMS
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 *
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 * This is free software; you can redistribute it and/or modify it
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * under the terms of the GNU General Public License as published by the
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 * Free Software Foundation; either version 2, or (at your option) any
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 * later version.
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 *
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 * BrewCloud is distributed in the hope that it will be useful, but
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 * General Public License for more details.
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 *
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19 * along with ThermFerm; see the file COPYING. If not, write to the Free
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21 *****************************************************************************/
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23
529
bb8a37fe6326 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
24 $(document).ready(function() {
311
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25
529
bb8a37fe6326 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
26 var url = '';
311
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27
529
bb8a37fe6326 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
28 if (my_select == 'fermentables')
bb8a37fe6326 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
29 url = 'upl_fermentables.php';
bb8a37fe6326 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
30 else if (my_select == 'hops')
bb8a37fe6326 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
31 url = 'upl_hops.php';
bb8a37fe6326 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
32 else if (my_select == 'miscs')
bb8a37fe6326 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
33 url = 'upl_miscs.php';
bb8a37fe6326 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
34 else if (my_select == 'yeasts')
bb8a37fe6326 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
35 url = 'upl_yeasts.php';
bb8a37fe6326 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
36 else if (my_select == 'styles')
bb8a37fe6326 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
37 url = 'upl_styles.php';
311
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
38
529
bb8a37fe6326 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
39 $('#jqxFileUpload').jqxFileUpload({
bb8a37fe6326 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
40 width: 300,
bb8a37fe6326 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
41 browseTemplate: 'success',
bb8a37fe6326 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
42 cancelTemplate: 'inverse',
bb8a37fe6326 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
43 uploadTemplate: 'primary',
bb8a37fe6326 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
44 theme: theme,
bb8a37fe6326 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
45 multipleFilesUpload: false,
bb8a37fe6326 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
46 accept: 'application/xml',
bb8a37fe6326 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
47 uploadUrl: url,
bb8a37fe6326 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
48 fileInputName: 'fileToUpload'
bb8a37fe6326 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
49 });
bb8a37fe6326 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
50 $('#eventsPanel').jqxPanel({
bb8a37fe6326 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
51 width: 800,
bb8a37fe6326 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
52 height: 200,
bb8a37fe6326 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
53 theme: theme
bb8a37fe6326 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
54 });
bb8a37fe6326 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
55 $('#jqxFileUpload').on('select', function(event) {
bb8a37fe6326 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
56 var args = event.args,
bb8a37fe6326 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
57 fileName = args.file,
bb8a37fe6326 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
58 fileSize = args.size;
bb8a37fe6326 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
59 $('#eventsPanel').jqxPanel('clearcontent');
bb8a37fe6326 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
60 $('#eventsPanel').jqxPanel('append', '<strong>' + event.type + ':</strong> ' + fileName + ' size: ' + fileSize + '<br />');
bb8a37fe6326 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
61 });
bb8a37fe6326 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
62 $('#jqxFileUpload').on('uploadEnd', function(event) {
bb8a37fe6326 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
63 var args = event.args,
bb8a37fe6326 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
64 fileName = args.file,
bb8a37fe6326 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
65 serverResponce = args.response;
bb8a37fe6326 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
66 $('#eventsPanel').jqxPanel('append', '<strong>' + event.type + ':</strong> ontvangen ' + fileName + '<br />' + serverResponce + '<br />');
bb8a37fe6326 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
67 });
311
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
68
f6fafccd8a6d Added xml import for fermentables, hops, miscs, yeasts and styles. Fixed update IBU calculation in the editor hop popups.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
69 });

mercurial