-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd_product.php
138 lines (134 loc) · 5.42 KB
/
add_product.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php
require_once("includes/Marker.php");
require_once("includes/Product.php");
require_once("includes/BarcodeType.php");
require_once("includes/global.php");?>
<!DOCTYPE HTML>
<html>
<head>
<!--Map set to 100%, not resizable by user-->
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
/*#map_canvas { height: 100% }*/
.info { width: 250px; }
#scrolling_pane {
height: 435px;
width: 600px;
overflow: scroll;
border: dashed 1px maroon;
}
</style>
<!--Sensor means using GPS locator to determine the user's location-->
<script type="text/javascript" src="../common/scripts/jquery/jquery.js"></script>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=true">//sensor=set_to_true_or_false</script>
<script type="text/javascript" src="http://code.google.com/apis/gears/gears_init.js"></script>
<script type="text/javascript"
src="http://www.google.com/jsapi?key=ABQIAAAA-O3c-Om9OcvXMOJXreXHAxQGj0PqsCtxKvarsoS-iqLdqZSKfxS27kJqGZajBjvuzOBLizi931BUow">
</script>
<script type="text/javascript">
$(document).ready(function() {
change_products();
$('input[name=submit]').click(function() {
//console.log('submitted...');
var searchUrl = 'ajax/add_product.php?type=json&product_name='+$('input[name=name]').val()+
'&image='+$('input[name=image]').val()+'&barcode='+$('input[name=barcode]').val()+
'&barcode_type='+$('select[name=barcode_type]').val();
$.getJSON(searchUrl, function(data) {
}).success( function() { })
.error ( function() { console.log('error here');})
.done ( function() { console.log('done'); change_products(); });
});
});
function change_products() {
var searchUrl = 'ajax/get_product.php?type=json';
$.getJSON(searchUrl, function(data) {
$('#scrolling_pane').html('<table style="width:100%;">');
$.each(data, function(key,value) {
// product name / barcode / image
var image = '';
var color = 'white';
if (key%2 == 0) { color = '#bc8f8f'; }
if(value.image == '') { image = value.barcode; } else { image = value.image; }
$('#scrolling_pane').append('<tr>');
$('#scrolling_pane').append('<td style="background-color:'+color+';">'+value.product_name);
$('#scrolling_pane').append('</td>');
$('#scrolling_pane').append('<td style="background-color:'+color+';">'+value.barcode);
$('#scrolling_pane').append('</td>');
$('#scrolling_pane').append('<td style="background-color:'+color+';"><image src="images/products/'+image+'.jpg"/>');
$('#scrolling_pane').append('</td>');
$('#scrolling_pane').append('</tr>');
});
$('#scrolling_pane').append('</table>');
}).success( function() { console.log('success');})
.error ( function() { console.log('error...');})
.done ( function() { console.log('done'); });
}
</script>
</head>
<body>
<form action="SERVER::PHP_SELF" style="height:30%">
<table>
<tr>
<td>
<table valign="top" align="top" style="align:top;valign:top;">
<tr>
<th>
Product Name
</th>
<td>
<input type="text" name="name" />
</td>
</tr>
<tr>
<th>
Product Image
</th>
<td>
<input type="text" name="image" />
</td>
</tr>
<tr>
<th>
Barcode
</th>
<td>
<input type="text" name="barcode" />
</td>
</tr>
<tr>
<th>
Barcode Type
</th>
<td>
<select name="barcode_type" accesskey="">
<?php foreach (BarcodeType::getBarcodeTypes() as $r) { ?>
<option value="<?=$r->barcode_type_id;?>"><?=$r->barcode_type_name;?></option>
<?php } ?>
</select>
</td>
</tr>
<tr>
<td>
<input type="button" name="submit" value="Submit"/>
</td>
</tr>
</table>
</td>
<td>
<table>
<tr>
<td>
<div id="scrolling_pane">
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>