-
Notifications
You must be signed in to change notification settings - Fork 0
/
client_profile.php
224 lines (207 loc) · 9.67 KB
/
client_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
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
<?php
require("mysql_connect.php");
$clientID = $_REQUEST['clientID'] ?? null;
$staffID = $_REQUEST['staffID'] ?? null;
if(!empty($clientID)) {
$c = mysqli_query($dbc, "SELECT * FROM clients WHERE id='".$clientID."'") or die(mysql_error());
if(mysqli_num_rows($c)>0)$client=mysqli_fetch_array($c);
$y = mysqli_query($dbc, "SELECT SUM(Hours) as hoursYTD FROM journal WHERE ClientID = $clientID AND YEAR(Date) = YEAR(CURDATE()) GROUP BY ClientID") or die(mysql_error());
if(mysqli_num_rows($y)>0)$hoursYTD=mysqli_fetch_array($y);
$q = mysqli_query($dbc, "SELECT SUM(Hours) as hoursQ FROM journal WHERE ClientID = $clientID AND QUARTER(Date) = QUARTER(CURDATE()) GROUP BY ClientID") or die(mysql_error());
if(mysqli_num_rows($q)>0)$hoursQ=mysqli_fetch_array($q);
}
if (isset($_POST['submit']) || isset($_POST['addnew'])) {
if(!empty($_REQUEST['code'])){$cols[]='code';$vals[]=mysqli_real_escape_string($dbc, $_REQUEST['code'] ?? null);}
if(!empty($_REQUEST['name'])){$cols[]='name';$vals[]=mysqli_real_escape_string($dbc, $_REQUEST['name'] ?? null);}
$cols[]='total_hours';$vals[]=mysqli_real_escape_string($dbc, $_REQUEST['total_hours'] ?? null);
$cols[]='address';$vals[]=mysqli_real_escape_string($dbc, $_REQUEST['address'] ?? null);
$cols[]='city';$vals[]=mysqli_real_escape_string($dbc, $_REQUEST['city'] ?? null);
$cols[]='state';$vals[]=mysqli_real_escape_string($dbc, $_REQUEST['state'] ?? null);
$cols[]='zip';$vals[]=mysqli_real_escape_string($dbc, $_REQUEST['zip'] ?? null);
$cols[]='url';$vals[]=mysqli_real_escape_string($dbc, $_REQUEST['url'] ?? null);
$cols[]='contact_details';$vals[]=mysqli_real_escape_string($dbc, $_REQUEST['contact_details'] ?? null);
$cols[]='gm_name';$vals[]=mysqli_real_escape_string($dbc, $_REQUEST['gm_name'] ?? null);
$cols[]='gm_contact';$vals[]=mysqli_real_escape_string($dbc, $_REQUEST['gm_contact'] ?? null);
$cols[]='gm_email';$vals[]=mysqli_real_escape_string($dbc, $_REQUEST['gm_email'] ?? null);
$cols[]='chair_name';$vals[]=mysqli_real_escape_string($dbc, $_REQUEST['chair_name'] ?? null);
$cols[]='chair_contact';$vals[]=mysqli_real_escape_string($dbc, $_REQUEST['chair_contact'] ?? null);
$cols[]='board_name';$vals[]=mysqli_real_escape_string($dbc, $_REQUEST['board_name'] ?? null);
$cols[]='board_contact';$vals[]=mysqli_real_escape_string($dbc, $_REQUEST['board_contact'] ?? null);
$cols[]='chair_email';$vals[]=mysqli_real_escape_string($dbc, $_REQUEST['chair_email'] ?? null);
$cols[]='RetreatDate';$vals[]=mysqli_real_escape_string($dbc, $_REQUEST['RetreatDate'] ?? null);
$cols[]='ExpireDate';$vals[]=mysqli_real_escape_string($dbc, $_REQUEST['ExpireDate'] ?? null);
$cols[]='RetreatDesc';$vals[]=mysqli_real_escape_string($dbc, $_REQUEST['RetreatDesc'] ?? null);
$cols[]='UsingPG';$vals[]=mysqli_real_escape_string($dbc, $_REQUEST['UsingPG'] ?? null);
$cols[]='Expansion';$vals[]=mysqli_real_escape_string($dbc, $_REQUEST['Expansion'] ?? null);
$cols[]='NewGM';$vals[]=mysqli_real_escape_string($dbc, $_REQUEST['NewGM'] ?? null);
$cols[]='Retain';$vals[]=mysqli_real_escape_string($dbc, $_REQUEST['Retain'] ?? null);
$cols[]='board_email';$vals[]=mysqli_real_escape_string($dbc, $_REQUEST['board_email'] ?? null);
if ($_POST['Expansion'] ?? null == 0) { $Expansion = 0; } else { $Expansion = 1; }
$cols[]='Expansion';$vals[]="$Expansion";
if ($_POST['NewGM'] ?? null == 0) { $NewGM = 0; } else { $NewGM = 1; }
$cols[]='NewGM';$vals[]="$NewGM";
if ($_POST['BalancedHrsUse'] ?? null == 0) { $BalancedHrsUse = 0; } else { $BalancedHrsUse = 1; }
$cols[]='BalancedHrsUse';$vals[]="$BalancedHrsUse";
if ($_POST['Retain'] ?? null == 0) { $Retain = 0; } else { $Retain = 1; }
$cols[]='Retain';$vals[]="$Retain";
if(!empty($clientID)){
$upd=db_send($cols,$vals,'clients','update',"id='$clientID'",0);
} else {
$ins=db_send($cols,$vals,'clients','insert');
$clientID=mysql_insert_id();
}
if($_REQUEST['RetreatDate']!=$client['RetreatDate'] && $client['RetreatDate']>'0000-00-00'){//repos
$cols_rr[]='RetreatDate';$vals_rr[]=$client['RetreatDate'];
$cols_rr[]='clientID';$vals_rr[]=$clientID;
$ins=db_send($cols_rr,$vals_rr,'clients_retreat_repos','insert');
}
header('Location: client_profile.php?clientID='.$clientID);
} else{ ?>
<html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<!-- <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8"></link> -->
<!-- <link rel="stylesheet" href="css/tablesort.css" type="text/css" charset="utf-8"> -->
<!-- <script src="js/jquery.tablesorter.js" type="text/javascript" charset="utf-8"></script> -->
<!-- <link rel="stylesheet" href="css/jquery-ui.css" type="text/css" charset="utf-8"></link> -->
<!-- <script src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.min.js" type="text/javascript"></script> -->
<!-- <script src="js/jquery.js" type="text/javascript" charset="utf-8"></script> -->
<!-- <script src="js/jquery-ui.js" type="text/javascript" charset="utf-8"></script> -->
</head>
<body>
<?php
include_once('topbar.php');
// include ('main_select.php');
echo "<br /><br />";
echo "<h2>" . $client['name'] . " — Client Profile</h2>";
?>
<div id="wrapper">
<div id="client_profile">
<div style="margin-right:60px;">
<?php mini_dash($clientID,'right'); ?>
</div>
<form method='POST' action='<?php echo $_SERVER['PHP_SELF']?>'>
<div id="left_col">
<div class="form_field">
<h3>Client Name</h3>
<input type="text" name="name" value="<?php echo $client['name']?>" size="60">
</div>
<div class="form_field">
<h3>Address</h3>
<input type="text" name="address" value="<?php echo @$client['address']?>" size="60">
</div>
<div class="form_field">
<table border="0" width="">
<tr>
<td><h3>City</h3>
<input type="text" name="city" value="<?php echo @$client['city']?>" size="37"></td>
<td><h3>State</h3>
<input type="text" name="state" value="<?php echo @$client['state']?>" size="2"></td>
<td><h3>Zip</h3>
<input type="text" name="zip" value="<?php echo @$client['zip']?>" size="10"></td>
</tr>
</table>
</div>
<div class="form_field">
<h3>Website</h3>
<input type="text" name="url" value="<?php echo @$client['url']?>" size="40">
</div>
<div class="form_field">
<h3>GM Name</h3>
<input type="text" name="gm_name" value="<?php echo @$client['gm_name']?>" size="40">
</div>
<div class="form_field">
<table border="0" width="">
<tr>
<td><h3>GM Phone</h3>
<input type="text" name="gm_contact" value="<?php echo @$client['gm_contact']?>" size="16"></td>
<td><h3>GM Email</h3>
<input type="text" name="gm_email" value="<?php echo @$client['gm_email']?>" size="40">
</td>
</tr>
</table>
</div>
<div class="form_field">
<h3>Chair Name</h3>
<input type="text" name="chair_name" value="<?php echo @$client['chair_name']?>" size="40">
</div>
<div class="form_field">
<table border="0" width="">
<tr>
<td><h3>Chair Phone</h3>
<input type="text" name="chair_contact" value="<?php echo @$client['chair_contact']?>" size="16"></td>
<td><h3>Chair Email</h3>
<input type="text" name="chair_email" value="<?php echo @$client['chair_email']?>" size="40"></td>
</tr>
</table>
</div>
<div class="form_field">
<h3>Board Name</h3>
<input type="text" name="board_name" value="<?php echo @$client['board_name']?>" size="40">
</div>
<div class="form_field">
<table border="0" width="">
<tr>
<td><h3>Board Phone</h3>
<input type="text" name="board_contact" value="<?php echo @$client['board_contact']?>" size="16"></td>
<td><h3>Board Email</h3>
<input type="text" name="board_email" value="<?php echo @$client['board_email']?>" size="40"></td>
</tr>
</table>
</div>
</div>
<!-- RIGHT COLUMN -->
<div id="right_col">
<div class="form_field">
<h3>Client Code (3 letters)</h3>
<input type="text" name="code" value="<?php echo @$client['code']?>" size="3">
</div>
<div class="form_field">
<h3><?php echo date('Y'); ?> Annual Support Hours (Total)</h3>
<input type="text" name="total_hours" value="<?php echo @$client['total_hours']?>">
</div>
<div class="form_field">
<h3>Contract Expires (yyyy-mm-dd)</h3>
<input type="text" name="ExpireDate" class="datepicker" value="<?php echo @$client['ExpireDate']?>">
</div>
<div class="form_field">
<h3>Retreat Date (yyyy-mm-dd)</h3>
<input type="text" name="RetreatDate" class="datepicker" value="<?php echo @$client['RetreatDate']?>">
</div>
<div class="form_field">
<h3>Retreat Description</h3>
<textarea name="RetreatDesc" cols=40 rows=4><?php echo @$client['RetreatDesc']?></textarea>
</div>
<br /><br />
<div class="form_field">
<h3><input type="checkbox" name="UsingPG" id="UsingPG" value="1" <?php echo (@$client['UsingPG']==1?'checked="checked"':'')?>> <label for="UsingPG">Using PG?</label></h3>
</div>
<div class="form_field">
<h3><input type="checkbox" name="Expansion" id="Expansion" value="1" <?php echo (@$client['Expansion']==1?'checked="checked"':'')?>> <label for="Expansion">Expansion</label></h3>
</div>
<div class="form_field">
<h3><input type="checkbox" name="NewGM" id="NewGM" value="1" <?php echo (@$client['NewGM']==1?'checked="checked"':'')?>> <label for="NewGM">New GM</label></h3>
</div>
<div class="form_field">
<h3><input type="checkbox" name="Retain" id="Retain" value="1" <?php echo (@$client['Retain']==1?'checked="checked"':'')?>> <label for="Retain">Retain in <?php echo (date('Y') + 1)?>?</label></h3>
</div>
</div>
<div id="other">
<br />
<div class="form_field">
<input type="hidden" name="clientID" value="<?php echo @$clientID?>" />
<input type="submit" name="submit" value="Save >>">
</div>
</div>
</div>
</div>
</form>
</body>
</html>
<?php }?>
<script>
$(function() {
$( ".datepicker" ).datepicker({ dateFormat: 'yy-mm-dd' });
});
</script>