-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaddrentalsto.php
executable file
·287 lines (269 loc) · 13.8 KB
/
addrentalsto.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
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
<?php
include_once 'header.php';
include_once 'headerfiles.php';
?>
<body class="skin-blue sidebar-collapse">
<div class="wrapper">
<!-- Main Header -->
<?php
include_once 'navigation.php';
include_once 'sidebar.php';
if(isset($_POST['date']))
{
$_POST['date']=ymdDate($_POST['date']);
$_POST['rentfrom']=ymdDate($_POST['rentfrom']);
$_POST['rentupto']=ymdDate($_POST['rentupto']);
query('rentalsto');
$query="Select rentalstoid from rentalsto order by rentalstoid desc limit 1";
$result=queryMysql($query);
$row=mysqli_fetch_array($result);
$rentalstoid=$row['rentalstoid'];
$index=0;
foreach($_POST['itemid'] as $itemid)
{
$quantity=$_POST['quantity'][$index];
$itemid=$_POST['itemid'][$index++];
$query="Insert into rentalstoitems(quantity,itemid,rentalstoid) values($quantity,$itemid,$rentalstoid)";
$result=queryMysql($query);
$query="Update items set quantity=quantity-$quantity where itemid=$itemid";
$result=queryMysql($query);
}
}
?>
<!-- Left side column. contains the logo and sidebar -->
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
Add Rentals to
<small>Enter rental details</small>
</h1>
<ol class="breadcrumb">
<li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
<li>Rentals to</li>
<li class="active">Add</li>
</ol>
</section>
<!-- Main content -->
<section class="content">
<!-- Your Page Content Here -->
<div class="row">
<div class="col-md-12">
<div class="box box-primary">
<form class="myform" action="addrentalsto.php" method="post">
<div class="box-body">
<div class="row">
<div class="col-md-3">
<div class="form-group">
<label>Rental Id</label>
<?php
$query="Select rentalstoid from rentalsto order by rentalstoid desc limit 1";
$result= queryMysql($query);
$row=mysqli_fetch_array($result);
$rentalstoid=id($row['rentalstoid']+1);
$rentalstoid="RT-".$rentalstoid;
echo <<<_END
<input type="text" value="$rentalstoid" class="form-control" placeholder="Rental Id"/>
_END;
?>
</div>
</div>
<div class="col-md-3 col-md-offset-6">
<div class="form-group">
<label>Date:</label>
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-calendar"></i>
</div>
<?php
$date=dmyDate(date("Y-m-d"));
echo<<<_END
<input tabindex="0" type="text" name="date" value="$date" class="form-control mandatory focus" data-inputmask="'alias': 'dd/mm/yyyy'" data-mask/>
_END;
?>
</div><!-- /.input group -->
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label>Customer Name</label>
<select name="customerid" class="form-control mandatory">
<option value="">Select</option>
<?php
$query="Select customerid,name from customers";
$result= queryMysql($query);
while($row=mysqli_fetch_array($result))
{
echo "<option value='$row[customerid]'>$row[name]</option>";
}
?>
</select>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label>Manager</label>
<select name="managerid" class="form-control mandatory" id="order-manager">
<option value="">Select</option>
<?php
$query="Select managerid,name from managers";
$result= queryMysql($query);
while($row=mysqli_fetch_array($result))
{
echo "<option value='$row[managerid]'>$row[name]</option>";
}
?>
</select>
</div>
</div>
<div class="col-md-4">
<div class="col-md-5" style="width:48%">
<div class="form-group">
<label>Rent from:</label>
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-calendar"></i>
</div>
<input type="text" name="rentfrom" class="form-control" data-inputmask="'alias': 'dd/mm/yyyy'" data-mask/>
</div><!-- /.input group -->
</div>
</div>
<div class="col-md-5" style="width:48%">
<div class="form-group">
<label>Rent upto:</label>
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-calendar"></i>
</div>
<input type="text" name="rentupto" class="form-control" data-inputmask="'alias': 'dd/mm/yyyy'" data-mask/>
</div><!-- /.input group -->
</div>
</div>
</div>
</div>
<div class="row">
<div class="box-header with-border">
<h3 class="box-title">Item Details</h3>
</div>
<div class="box-body">
<div class="col-md-12">
<table class="table table-bordered table-striped order-table">
<tr>
<th style="width: 10px">#</th>
<th class="col-md-2">Item Name</th>
<th class="col-md-2">Item Type</th>
<th class="col-md-3">Item Description</th>
<th class="col-md-3">Godown/Venue</th>
<th class="col-md-1">Item ID</th>
<th class="col-md-1">Quantity</th>
<th class="visible-sm-block">Delete</th>
</tr>
<tr class="order-row">
<td class="orderid">1</td>
<td>
<div class="form-group">
<select class="form-control mandatory item item-name">
<option value="">Select</option>
<?php
$query="Select distinct name from items order by name";
$result= queryMysql($query);
while($row=mysqli_fetch_array($result))
{
echo "<option value='$row[name]'>$row[name]</option>";
}
?>
</select>
</div>
</td>
<td>
<div class="form-group">
<select class="form-control mandatory item-type">
</select>
</div>
</td>
<td>
<div class="form-group">
<select class="form-control mandatory item-description">
</select>
</div>
</td>
<td>
<div class="form-group">
<select name="itemid[]" class="form-control mandatory item-godown">
</select>
</div>
</td>
<td>
<input type="text" class="form-control itemid mandatory" placeholder="Item ID"/>
<input type="hidden" class="item-id" />
</td>
<td class="order-quantity">
<div class="form-group">
<input type="number" name="quantity[]" min="1" class="form-control mandatory new-order-row item-quantity"/>
</div>
</td>
<td class="visible-sm-block">
<a class="delete-row" href="javascript:void(0)">Delete</a>
</td>
</tr>
</table>
<!-- <a href="#">
<span class="glyphicon glyphicon-plus"></span>
Add More Items</a>-->
</div>
</div>
</div>
<div class="row">
<div class="box-body">
<div class="col-md-2">
<button class="btn btn-block btn-primary submit">Save</button>
</div>
<div class="col-md-2">
<button class="btn btn-block btn-warning cancel">Cancel</button>
</div>
</div>
</div>
<div id="myModal" class="modal fade" role="dialog" tabindex="-1">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Image</h4>
</div>
<div class="modal-body">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
<?php
$business=$_SESSION['business'];
echo<<<_END
<input type="hidden" name="business" value="$business"/>
_END;
?>
</form>
</div>
</div>
</div>
</section><!-- /.content -->
</div><!-- /.content-wrapper -->
<!-- Main Footer -->
<footer class="main-footer">
<!-- To the right -->
<div class="pull-right hidden-xs">
TMStock - The Makers Stock
</div>
<!-- Default to the left -->
<strong>Copyright © 2015 <a href="http://themakersweb.com">The Makers Web</a>.</strong> All rights reserved.
</footer>
</div><!-- ./wrapper -->
</body>
</html>