This repository has been archived by the owner on Apr 4, 2022. It is now read-only.
forked from etsy/opsweekly
-
Notifications
You must be signed in to change notification settings - Fork 1
/
edit_profile.php
104 lines (93 loc) · 4.47 KB
/
edit_profile.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
<?php
include_once("phplib/base.php");
$my_username = getUsername();
$page_title = getTeamName() . " Weekly Updates - Edit your profile";
include_once('phplib/header.php');
include_once('phplib/nav.php');
?>
<div class="container">
<h1>Edit profile <small>for user <?php echo $my_username; ?></small></h1>
<?php
if (!$profile = checkForUserProfile($my_username)) {
echo insertNotify("info", "Welcome to your profile page! Fill in the data below");
$profile = null;
} else {
$sleeptracking_settings = json_decode($profile['sleeptracking_settings'], 1);
}
if (isset($_GET['succ'])) {
echo insertNotify("success", "Thanks! Your profile details have been saved. ");
}
?>
<div class="row">
<div class="span12">
<form method='POST' action='<?php echo $ROOT_URL; ?>/save_profile.php'>
<fieldset>
<legend>User details</legend>
<label>Full Name</label><input type="text" placeholder="Bob Robertson" name="full_name" value="<?php echo $profile['full_name']; ?>">
<label>Time Zone</label>
<select name="timezone">
<option></option>
<?php
foreach($locales as $l => $d) {
$checked = ($profile['timezone'] == $l) ? " selected" : "";
echo "<option value='{$l}'{$checked}>{$d}</option>";
}
?>
</select>
<label>Team</label>
<select name="team">
<option></option>
<?php foreach($gblTeams as $t) {
$checked = ($profile['team'] == $t) ? " selected" : "";
echo "<option value='{$t}'{$checked}>{$t}</option>";
}
?>
</select>
</fieldset>
<br />
<fieldset>
<legend>Sleep Tracking</legend>
<label class="radio">
<input type="radio" name="sleeptracking_provider" id="sleeptracking-none" value="none" checked>
No sleep tracking - I hate my life and my sleep doesn't matter to me
</label>
<?php
foreach ($sleep_providers as $provider_id => $p_config) {
$checked = ($profile['sleeptracking_provider'] == $provider_id) ? " checked" : "";
echo '<label class="radio">';
echo "<input type='radio' name='sleeptracking_provider' id='sleeptracking-{$provider_id}' value='{$provider_id}'{$checked}>";
echo "<img src='{$ROOT_URL}{$p_config['logo']}'> <strong>{$p_config['display_name']}</strong> - {$p_config['description']}";
echo "</label>";
echo "<div class='well hide options_div' id='{$provider_id}-options'>";
foreach ($p_config['options'] as $option_id => $o_config) {
echo "<label><strong>{$o_config['name']}</strong></label>";
echo "<input type='{$o_config['type']}' name='sleeptracking[{$provider_id}][{$option_id}]' placeholder='{$o_config['placeholder']}'
data-toggle='tooltip' title='{$o_config['description']}' value='{$sleeptracking_settings[$provider_id][$option_id]}'>";
}
echo "</div>";
}
?>
</fieldset>
<div class="form-actions">
<button type="submit" class="btn btn-primary">Save changes</button>
<button type="button" class="btn">Cancel</button>
</div>
</form>
<script>
// Show/hide the options windows as the option is chosen
$("input:radio").click(function() {
$(".options_div").fadeOut("fast");
var show_div = "#" + $(this).val() + "-options";
$(show_div).fadeIn("fast");
});
$("input:text").tooltip({
placement: "right",
trigger: "focus"
});
</script>
</div>
</div>
</div>
<?php include_once('phplib/footer.php'); ?>
</body>
</html>