-
Notifications
You must be signed in to change notification settings - Fork 0
/
CreateProject.php
148 lines (116 loc) · 3.58 KB
/
CreateProject.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
<?php
include('private/session.php');
require_once("WS/DemoDB.php");
require_once("private/utils.php");
if($_SESSION['login_user_type']!=TRAINER){
header('Location: index.php'); // Redirecting To Login Page
}
?>
<?php
$error=''; // Variable To Store Error Message
if (isset($_POST['submit'])) {
if (empty($_POST['title']) || empty($_POST['subject']) || empty($_POST['class_id']) ) {
$error = "Fields can not be empty";
}
else
{
}
}
?>
<html lang="en">
<head>
<?php require 'base/head.html';?>
<title>Create a new Project</title>
</head>
<body>
<?php require 'base/top.html';?>
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
<?php
print $error;
?>
<h1 class="page-header">Create a new Project</h1>
<div class="row placeholders"></div>
<!-- <h2 class="sub-header">List of Identities</h2> -->
<form id="form" class="form-horizontal" role="form" action="" method="post">
<div class="form-group">
<label class="control-label col-sm-2" for="title">Title:</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="title" id="title"
placeholder="Enter title" required>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="subject">Subject:</label>
<div class="col-sm-10">
<input type="text" class="form-control" name="subject" id="subject"
placeholder="Enter subject" required>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="deadline">Deadline:</label>
<div class="col-sm-10">
<input type="date" class="form-control" name="deadline" id="deadline"
placeholder="Enter Deadline">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="class_id">Class:</label>
<div class="col-sm-10">
<!-- <input type="number" class="form-control" name="class_id" id="class_id"
placeholder="Enter Class id"> -->
<select class="form-control" id="class_id" name="class_id">
<?php
$result = getClassData();
if ($result != null) {
foreach ($result as $key => $value) {
echo "<option value='".$value['id'] ."'>".$value['name']. "</option>";
}
}
?>
</select>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button id="submit" type="submit" class="btn btn-default">Submit</button>
</div>
</div>
</form>
<script>
$(document).ready(function () {
// Get data from server when click on Reload button
$("#submit").click(function (event) {
event.preventDefault();
var body = $("#form").serialize();
body = body + "&owner_id=<?= $_SESSION['login_user_id'] ?>";
console.log(body);
$.ajax({
// HTTP mthod
type: "PUT",
url: "/TCP/WS/ProjectResource.php?id=1",
// return type
data:body,
// error processing
// xhr is the related XMLHttpRequest object
error: function (xhr, string) {
console.log(xhr.status );
console.log(xhr.statusText );
console.log(xhr.responseText );
//var msg = (xhr.status == 404 ? "Person not found": "Error : " + xhr.status + " " + xhr.statusText;
//$("#message").html(msg);
},
// success processing (when 200,201, 204 etc)
success: function (data) {
window.location="/TCP/CreateProject.php";
//$("#name").val(data.name);
//$("#message").html("Person loaded")
}
});
}
);
});
</script>
</div>
<?php require 'base/bottom.html';?>
</body>
</html>