-
Notifications
You must be signed in to change notification settings - Fork 0
/
add-catch.php
187 lines (176 loc) · 8.85 KB
/
add-catch.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
<?php include 'php/templates/header.php'; ?>
<script>
app.controller('addCatch', function($scope, $http, $rootScope)
{
$http.get('https://fishevents-api-chown9835.c9users.io/catch/<?= $_GET['id']; ?>?token=' + $.cookie('token'))
.then(function(response)
{
<?php if(isset($_GET['id'])) { ?>
$scope.data = response.data;
$rootScope.globalData = response.data;
<?php } ?>
});
});
</script>
<div class="ui text container" ng-controller="addCatch">
<p> </p>
<div class="ui segment" style="max-width: 550px; margin: 0 auto">
<h1 class="ui center aligned icon header">
<i class="trophy icon"></i>
Catch
<div class="sub header">Add your gifts here.</div>
</h1>
<form class="ui form">
<h2 class="ui dividing header">Profile</h2>
<div class="fields">
<div class="four wide field">
<label>Weight</label>
<div class="ui input">
<input type="text" name="weight" value="{{ data.species.weight }}" placeholder="Weight">
</div>
</div>
<div class="four wide field">
<label>Amount</label>
<div class="ui input">
<input type="text" name="counts" value="{{ data.total.counts }}" placeholder="Amount">
</div>
</div>
<div class="four wide field">
<label>Pricing</label>
<div class="ui input">
<input type="text" name="pricing" value="{{ data.species.pricing }}" placeholder="Pricing">
</div>
</div>
<div class="four wide field">
<label>For Sell</label>
<div class="ui toggle checkbox">
<input type="checkbox" name="selling" ng-checked="data.selling" ng-true-value="on" ng-false-value="off">
<label></label>
</div>
</div>
</div>
<div class="fields">
<div class="twelve wide field">
<label>Date</label>
<div class="fields">
<div class="four wide field">
<select name="day" class="ui fluid dropdown">
<option value="">Day</option>
<?php for($i = 1; $i < 31; $i++) { ?>
<option <?= $i == date('j') ? 'selected="selected"' : null ?> value="<?= $i ?>"><?= $i ?></option>
<?php } ?>
</select>
</div>
<div class="six wide field">
<select name="month" class="ui fluid dropdown">
<option value="">Month</option>
<option <?= date('n') == 1 ? 'selected="selected"' : null ?> value="1">January</option>
<option <?= date('n') == 2 ? 'selected="selected"' : null ?> value="2">February</option>
<option <?= date('n') == 3 ? 'selected="selected"' : null ?> value="3">March</option>
<option <?= date('n') == 4 ? 'selected="selected"' : null ?> value="4">April</option>
<option <?= date('n') == 5 ? 'selected="selected"' : null ?> value="5">May</option>
<option <?= date('n') == 6 ? 'selected="selected"' : null ?> value="6">June</option>
<option <?= date('n') == 7 ? 'selected="selected"' : null ?> value="7">July</option>
<option <?= date('n') == 8 ? 'selected="selected"' : null ?> value="8">August</option>
<option <?= date('n') == 9 ? 'selected="selected"' : null ?> value="9">September</option>
<option <?= date('n') == 10 ? 'selected="selected"' : null ?> value="10">October</option>
<option <?= date('n') == 11 ? 'selected="selected"' : null ?> value="11">November</option>
<option <?= date('n') == 12 ? 'selected="selected"' : null ?> value="12">December</option>
</select>
</div>
<div class="six wide field">
<select name="year" class="ui fluid dropdown">
<option value="">Year</option>
<?php for($i = date('Y'); $i > 1960; $i--) { ?>
<option <?= $i == date('Y') ? 'selected="selected"' : null ?> value="<?= $i ?>"><?= $i ?></option>
<?php } ?>
</select>
</div>
</div>
</div>
<div class="four wide field">
<label>Sold</label>
<div class="ui input">
<input type="text" name="sold" value="{{ data.species.sold }}" placeholder="Sold amount">
</div>
</div>
</div>
<div class="field" ng-controller="myPermits">
<label>Permit ID</label>
<div class="ui fluid search selection dropdown">
<input type="hidden" name="permit" value="{{ globalData.permit }}">
<i class="dropdown icon"></i>
<div class="default text">Select Permit ID</div>
<div class="menu">
<div class="item" ng-repeat="data in datas" data-value="{{data._id}}">{{data._id}}</div>
</div>
</div>
<script>
app.controller('myPermits', function($scope, $http)
{
$http.get('https://fishevents-api-chown9835.c9users.io/permit?token=' + $.cookie('token'))
.then(function(response)
{
$scope.datas = response.data;
setTimeout(function(){$('.ui.dropdown').dropdown()}, 0)
});
});
</script>
</div>
<button class="ui fluid primary button" type="submit"><?= isset($_GET['id']) ? 'Edit' : 'Add'; ?></button>
</form>
</div>
<p> </p>
<script>
$(function()
{
//var data = $('form').serializeObject();
$('form').on('submit', function()
{
var data =
{
total : {
weight: $('input[name="weight"]').val(),
counts: $('input[name="counts"]').val()
},
selling: $('input[name="selling"]').val(),
permit : $('input[name="permit"]').val(),
date : $('select[name="year"]').val() + '-' + $('select[name="month"]').val() + '-' + $('select[name="day"]').val(),
species: {
profile: 'dkdkelrkdorkdorkdorkelek',
weight : $('input[name="weight"]').val(),
sold : $('input[name="sold"]').val(),
pricing: $('input[name="pricing"]').val(),
}
}
$('.primary.button').addClass('loading').attr('disabled', 'disabled')
$.ajax({
url : 'https://fishevents-api-chown9835.c9users.io/catch?token=' + $.cookie('token'),
contentType: 'application/json',
data : JSON.stringify(data),
type : "PUT",
dataType: 'json',
success: function(msg)
{
$('.primary.button').removeClass('loading primary')
.addClass('positive')
.text('<?= isset($_GET['id']) ? 'Edited' : 'Added'; ?> successfully!')
setTimeout(function()
{
$('.positive.button').text('<?= isset($_GET['id']) ? 'Edit' : 'Add'; ?>')
.removeClass('positive')
.addClass('primary')
.removeAttr('disabled')
}, 1500)
},
error: function(xhr, ajaxOptions, thrownError)
{
$('.primary.button').removeClass('loading')
.removeAttr('disabled')
}
});
})
})
</script>
</div>
<?php include 'php/templates/footer.php'; ?>