-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcreate_group.php
81 lines (77 loc) · 2.57 KB
/
create_group.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
<?php
/**
* File create_group.php
*
* PHP version 5.3+
* A view to get user interface of create group form
*
* @author Dzung Nguyen <[email protected]>
* @copyright 2013-2015 evolpas
* @license http://www.evolpas.com license
* @version XXX
* @link http://www.evolpas.com
* @category root
*/
require_once 'autoloader.php';
$contactCtrl = new Controllers\GroupController();
$groups = $contactCtrl->getAllGroups();
if (!empty($_POST)) {
$contactCtrl->data = $_POST;
$insert = $contactCtrl->createGroupAction();
if ($insert !== false) {
header('Location: groups.php');
} else {
$error_log = 'Error: Cannot insert data!';
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Address book :: Create group</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="stylesheet" href="assets/css/main.css">
</head>
<body>
<!-- container -->
<div id="container">
<!-- main -->
<div id="main">
<div class="center">
<h2 class="title">Create group</h2>
<div class="nav-menu">
<a href="groups.php">Groups list</a> | <a href="index.php">Contacts list</a>
</div>
<div id="form">
<?php if (isset($error_log)) { ?>
<span class='error'><?php echo $error_log; ?></span>
<?php } ?>
<form id="fmCreateGroup" method="POST" action="create_group.php">
<label for="name">Name</label>
<input type="text" id="name" name="group_name" class="text" required>
<label for="description">Description</label>
<textarea id="description" rows="2"name="description"></textarea>
<label for="name">Inherit contacts from</label>
<div id="checkbox" style="width:340px">
<ul>
<?php foreach ($groups as $group): ?>
<li>
<input type="checkbox" class="check-group" style="display:inline" id="group_<?php echo $group['id'] ?>" value="<?php echo $group['id'] ?>" name="id_parent[]">
<label style="display:inline" for="group_<?php echo $group['id'] ?>"><?php echo $group['group_name'] ?></lable>
</li>
<?php endforeach; ?>
</ul>
</div>
<input type="submit" value="Save" class="submit" />
<input type="reset" value="Cancel" class="submit" />
</form>
</div>
</div>
</div>
</div>
<!-- script -->
<script src="assets/js/main.js"></script>
</body>
</html>