-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtable.php
More file actions
167 lines (153 loc) · 4.84 KB
/
table.php
File metadata and controls
167 lines (153 loc) · 4.84 KB
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<?php
/**
* Created by PhpStorm.
* User: shady
* Date: 3/3/19
* Time: 5:53 AM
*/
include "./functions.php";
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="../../favicon.ico">
<title>Narrow Jumbotron Template for Bootstrap</title>
<!-- Bootstrap core CSS -->
<link href="./css/bootstrap.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="./css/narrow-jumbotron.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.21/dist/vue.js"></script>
</head>
<style>
</style>
<body>
<div class="container">
<div class="header clearfix">
<nav>
<ul class="nav nav-pills float-right">
<li class="nav-item">
<a class="nav-link active" href="table.php">Quantity Table</a>
</li>
</ul>
</nav>
<h3 class="text-muted">Vue Quantity Table</h3>
</div>
<div class="jumbotron">
<h1 class="display-3">Vue Quantity Table</h1>
<p class="lead">A wizard built using php and vue.js</p>
</div>
<div class="container">
<div class="wizard" id="app">
<table class="table">
<thead>
<tr>
<th scope="col"># Quantity</th>
<th scope="col">Item</th>
<th scope="col">Price</th>
<th scope="col">Total</th>
</tr>
</thead>
<tbody>
<tr v-for="row in rows">
<th>
<span v-if="cansubmit">{{ row.quantity }}</span>
<input v-if="!cansubmit" type="number" v-model="row.quantity">
</th>
<td>{{ row.item }} </td>
<td>{{ row.price }}</td>
<td>{{ row.quantity * row.price }}</td>
</tr>
<tr>
<th colspan="3">Total</th>
<td >
{{ total }}
</td>
</tr>
</tbody>
</table>
<hr>
<div>
<button v-if="cansubmit" type="button" @click="edit()" class="btn btn-primary float-left">Edit</button>
<button v-if="!cansubmit" type="button" @click="finish()" class="btn btn-primary float-left">Finish</button>
<form v-if="cansubmit" action="submit.php" method="get">
<input type="hidden" v-model="formdata" name="data">
<button type="submit" class="btn btn-primary float-right">Submit</button>
</form>
</div>
<br><br>
</div>
</div>
<footer class="footer">
<p>© Company 2017</p>
</footer>
</div> <!-- /container -->
<script>
var myObject = new Vue({
el: '#app',
data : {
message: "",
updatedToDos : "",
stale: false,
showElement: "none",
cansubmit : false,
formdata : "",
rows : {
1 : {
'quantity' : 0,
'price' : 3.00,
'total' : 0,
'item' : "HB Pencil"
},
2 : {
'quantity' : 0,
'price' : 3.00,
'total' : 0,
'item' : "Manilla Envelope"
},
3 : {
'quantity' : 0,
'price' : 150.00,
'total' : 0,
'item' : "Cross Black Ink Pen"
},
4 : {
'quantity' : 0,
'price' : 10.00,
'total' : 0,
'item' : "Paper Clips"
},
}
},
methods : {
test : function(){
var total=this.rows[1];
console.log(total.total);
},
finish : function(){
this.cansubmit = true;
this.createFormData();
},
edit : function(){
this.cansubmit = false;
},
createFormData : function(){
this.formdata = JSON.stringify(this.rows);
}
},
computed : {
total : function(){
var total = 0;
for(var i =1; i <= Object.keys(this.rows).length; i++){
total += this.rows[i].price * this.rows[i].quantity;
}
return total;
}
}
})
</script>
</body>
</html>