Odyssey
upgrade_svs.prg
1 <?php
2 $monLibrary= dirname(__FILE__) . "/../library";
3 require_once("$monLibrary/cu_top.i");
4 require_once("$monLibrary/ck_hticket.i");
5 
6  if (!CheckPerm($link, $Hu, basename($_SERVER['SCRIPT_NAME']), $_SERVER['REMOTE_ADDR'])) {
7  // ** Permissions failed
8  // ** redirect to new page
9  header("Location: /hcuadm/hcu_noperm.prg");
10  exit;
11  }
12 
13 $dms_ok=array('action'=>'string','act'=>'string','user_name'=>'string',
14 'sys_typ_asp'=>'digits','sys_typ_batch'=>'digits',
15 'sys_typ_closed'=>'digits','sys_typ_ivr'=>'digits','sys_typ_live'=>'digits',
16 'sys_typ_upgrade'=>'digits','sys_typ_webonly'=>'digits','sys_typ_voip'=>'digits',
17 'next_contact_date'=>'string','target_launch'=>'string','showrows'=>'digits',
18 'sys_typ_upg' => 'digits',
19 'msg'=>'string','cu_products'=>'array','cu_prodmaster'=>'array');
20 
21 dms_import($dms_ok);
22 
23 $act = (empty($act) ? "show" : $act);
24 $msg = isset($msg) ? $msg : "";
25 $cu_products = isset($cu_products) ? $cu_products : array();
26 
27 $self = $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING'];
28 
29 switch ($act) {
30 case "save":
31 case "savehide":
32  $err_msg = "";
33 
34  /* VALIDATE THE INFORMATION - whether it's been saved before or NOT
35  After validation fails it will send the information back to the edit form
36  So it looks like it did before, fail info will be at the bottom of the
37  screen.
38  */
39  // Target Launch Date -- Can be empty, but if entered must be a valid date.
40  $target_launch = trim( $target_launch );
41  if (strlen($target_launch) > 0) {
42  if ( $target_launch != "FLEX" && $target_launch != "TBD" && !($target_launch = mdydate($target_launch)))
43  $err_msg .= "{Target Launch Date} is an invalid date. A valid date must be entered, or the value 'FLEX', or the value 'TBD'.<br>";
44  } else {
45  $err_msg .= "Need a Target Launch Date. A valid date must be entered, or the value 'FLEX', or the value 'TBD'.<br>";
46  }
47 
48  // Next Contact Date -- Can be empty, but if entered must be a valid date.
49  if (strlen($next_contact_date) > 0)
50  if ( !($next_contact_date = mdydate($next_contact_date)))
51  $err_msg .= "{Next Contact Date} is an invalid date. A valid date must be entered or leave blank.<br>";
52 
53  // ** Make sure one of the Home CU Type options is selected -- but there are rules on which ones may be selected
54  if ((!isset($sys_typ_batch) && !isset($sys_typ_live) && !isset($sys_typ_ivr) && !isset($sys_typ_voip) && !isset($sys_typ_webonly)) && !$sys_typ_closed) {
55  $err_msg .= "<li>To complete setup, a valid HomeCU Type must be selected. Please select one of the Home CU Type options and try again.<br>";
56  } else {
57  // ** Check to make sure the selected options do NOT conflict
58  if (isset($sys_typ_webonly) && (isset($sys_typ_batch) || isset($sys_typ_live) || isset($sys_typ_asp))) {
59  $err_msg .= "<li>When Web Only is selected you may not choose one of these {live, batch, asp, upgrade}. Please select correctly and try again.<br>";
60  } elseif (isset($sys_typ_batch) && (isset($sys_typ_live))) {
61  $err_msg .= "<li>When Batch is selected you may not choose the 'Live' options. Please correct this and try again.<br>";
62  }
63 
64  }
65 
66  // Everything validated ok so far, get the sql ready:
67 
68  $cuinfo_query = "SELECT user_name,coalesce(system_options,0) FROM cuinfo WHERE user_name = '$user_name'";
69  // Execute the query and find out how many rows are in the query
70  $db_result = db_query($cuinfo_query, $link);
71  if (db_num_rows($db_result) == 0) {
72  $err_msg .= "<li>No info record found for clien $user_name. Cannot update.<br>";
73  }
74  list($dname, $dsysops) = db_fetch_array($db_result,0);
75 
76  // ** SET the {SYSTEM OPTIONS} value to be saved
77  $upd_sys_opt = 0;
78 
79  $upd_sys_opt = (
80  (isset($sys_typ_batch) ? $sys_typ_batch : 0) +
81  (isset($sys_typ_live) ? $sys_typ_live : 0) +
82  (isset($sys_typ_asp) ? $sys_typ_asp : 0) +
83  (isset($sys_typ_ivr) ? $sys_typ_ivr : 0) +
84  (isset($sys_typ_voip) ? $sys_typ_voip : 0) +
85  (isset($sys_typ_webonly) ? $sys_typ_webonly : 0) +
86  (isset($sys_typ_upgrade) ? $sys_typ_upgrade : 0) +
87  (isset($sys_typ_closed) ? $sys_typ_closed : 0) +
88  (isset($sys_typ_upg) ? $sys_typ_upg : 0)
89  );
90 
91  if ($dsysops > $upd_sys_opt) {
92  $err_msg .= "<li>Cannot remove service options from here.<br>";
93  }
94  if ($err_msg == "") {
95  if ( $target_launch != "FLEX" && $target_launch != "TBD" ) {
96  $target_launch = dateformat("Y-m-d", $target_launch);
97  }
98 
99  // UPDATE the information into the table
100  $qry_stmt = sprintf("UPDATE cuinfo\n");
101  $qry_stmt .= sprintf("SET system_options='%s',\n",$upd_sys_opt);
102  $qry_stmt .= sprintf("target_launch='%s',\n",$target_launch);
103  $qry_stmt .= sprintf("next_contact_date=%s\n",save_date($next_contact_date));
104  $qry_stmt .= sprintf("WHERE user_name = '%s'; \n",$user_name);
105 
106  $qry_stmt .= "DELETE from cuproducts WHERE user_name = '$user_name';";
107  if (is_array($cu_products)) {
108  foreach ($cu_products as $code=>$value) {
109  $qry_stmt .= "INSERT into cuproducts values ('$code','$user_name');";
110  }
111  }
112 
113  # run sql and show result
114 // print "$qry_stmt<br>";
115  if ($err_msg == "") {
116  if (!($db_result=db_query($qry_stmt, $link)))
117  $err_msg = pg_errormessage();
118  }
119  if ($err_msg == "") {
120  $msg="Upgrade Information Saved Successfully";
121  } else {
122 # $msg="$qry_stmt<br>$err_msg";
123  $msg=$err_msg;
124  }
125  }
126 ## end of save -- falls through to display (with bad data in case of error)
127 ## savehide just quits
128  if ($act == "savehide") {
129 
130  print "<html><head>
131  <link rel=stylesheet href='/monitor/css/monitor.css' type='text/css'>
132 </head><body class='dtll'><div class='msg'>$msg</div>
133  </body>
134 </html>";
135  break;
136  }
137 
138  case "show":
139 
140  cu_header("Home CU - Upgrade Information");
141 
142  print <<< js_code
143 <link type="text/css" href="/monitor/css/jquery-ui-1.8.18.custom.css" rel="stylesheet" />
144 <script type="text/javascript" src="/monitor/js/jquery-1.7.1.min.js"></script>
145 <script type="text/javascript" src="/monitor/js/jquery-ui-1.8.18.custom.min.js"></script>
146  <script type="text/javascript">
147  $(function(){
148 
149  // Datepicker
150  $('#targetlaunch').datepicker({
151  inline: true
152  });
153  // Datepicker2
154  $('#nextcontact').datepicker({
155  inline: true
156  });
157  //hover states on the static widgets
158  $('#dialog_link, ul#icons li').hover(
159  function() { $(this).addClass('ui-state-hover'); },
160  function() { $(this).removeClass('ui-state-hover'); }
161  );
162 
163  });
164  function sendform(act)
165  {
166  document.forms[0].act.value=act;
167  document.forms[0].submit();
168  }
169  </script>
170 
171 js_code;
172 
173  print "<form action='$self' name='cuup' method='post'>";
174 ?>
175 
176  <?php
177  // If not already loaded, get the cu info from the database
178  $loadrec = isset($showrows);
179  if ($loadrec == 0 ) {
180  $query = "select system_options, target_launch, next_contact_date
181  from cuinfo where user_name = '$user_name'";
182  $result = db_query($query, $link);
183 
184  list( $system_options, $target_launch, $next_contact_date) = db_fetch_array($result,0);
185 
186  $sys_typ_batch = ($system_options & $SYS_TYPE_BATCH ? $SYS_TYPE_BATCH : NULL);
187  $sys_typ_live = ($system_options & $SYS_TYPE_LIVE ? $SYS_TYPE_LIVE : NULL);
188  $sys_typ_asp = ($system_options & $SYS_TYPE_ASP ? $SYS_TYPE_ASP : NULL);
189  $sys_typ_ivr = ($system_options & $SYS_TYPE_IVR ? $SYS_TYPE_IVR : NULL);
190  $sys_typ_voip = ($system_options & $SYS_TYPE_VOIP ? $SYS_TYPE_VOIP : NULL);
191  $sys_typ_webonly = ($system_options & $SYS_TYPE_WEBONLY ? $SYS_TYPE_WEBONLY : NULL);
192  $sys_typ_upgrade = ($system_options & $SYS_TYPE_UPGRADE ? $SYS_TYPE_UPGRADE : NULL);
193  $sys_typ_closed = ($system_options & $SYS_TYPE_CLOSED ? $SYS_TYPE_CLOSED : NULL);
194 
195  /** SET THE HB Upgrade Options **/
196  // ** For the purpose of the home banking flags, i can just use the combined
197  // * value from the system_options, and it will use bitwise operators
198  // * do decide the flags
199  $sys_typ_upg = $system_options;
200 
201  $target_launch = trim($target_launch);
202  if ( $target_launch != "FLEX" && $target_launch != "TBD" ) {
203  $target_launch = dms_disphtml(dateformat("m/d/Y",$target_launch));
204  }
205  $next_contact_date = dateformat("m/d/Y",trim($next_contact_date));
206 
207  $query = "select trim(home_cu_code)as home_cu_code
208  from cuproducts where user_name='$user_name'";
209  $result = db_query($query, $link);
210 
211  $row=0;
212  while ($sql_row = db_fetch_array($result, $row++)) {
213  $code=$sql_row['home_cu_code'];
214  $cu_products["$code"]=1;
215  }
216  $query = "select trim(home_cu_code)as home_cu_code,
217  trim(home_cu_desc) as home_cu_desc from cuprodlist
218  order by home_cu_desc";
219  $result = db_query($query, $link);
220 
221  $row=0;
222  while ($sql_row = db_fetch_array($result, $row++)) {
223  $code=$sql_row['home_cu_code'];
224  $product=$sql_row['home_cu_desc'];
225  $cu_prodmaster["$code"]=$product;
226  }
227  }
228  $sys_typ_upg_test = ($sys_typ_upg & $SYS_TYPE_UPG_TEST ? $SYS_TYPE_UPG_TEST : NULL);
229  $sys_typ_upg_beta = ($sys_typ_upg & $SYS_TYPE_UPG_BETA ? $SYS_TYPE_UPG_BETA : NULL);
230  $sys_typ_upg_comp = ($sys_typ_upg & $SYS_TYPE_UPG_COMP ? $SYS_TYPE_UPG_COMP : NULL);
231 
232 print "<table cellspacing='0' cellpadding='1' border='0' width='100%' bgcolor=white>";
233 
234  if (isset($err_msg) && strlen($err_msg) > 0)
235  print "<tr><td colspan='5' class='msg' align='left'>Errors occured -- changes not saved<br>$err_msg</td></tr>";
236  if ("$msg" != "")
237  print "<tr><td colspan='5' class='msg' align='left'>$msg</td></tr>";
238 
239 print "<tr><td colspan='5'>";
240 print "<input type=\"hidden\" name=\"user_name\" value=\"$user_name\">";
241 print "<input type=\"hidden\" name=\"sys_typ_batch\" value=\"". (isset($sys_typ_batch) ? $sys_typ_batch : "") ."\">";
242 print "<input type=\"hidden\" name=\"sys_typ_live\" value=\"". (isset($sys_typ_live) ? $sys_typ_live : "") ."\">";
243 print "<input type=\"hidden\" name=\"sys_typ_asp\" value=\"". (isset($sys_typ_asp) ? $sys_typ_asp : "") ."\">";
244 print "<input type=\"hidden\" name=\"sys_typ_webonly\" value=\"". (isset($sys_typ_webonly) ? $sys_typ_webonly : "") ."\">";
245 print "<input type=\"hidden\" name=\"sys_typ_closed\" value=\"". (isset($sys_typ_closed) ? $sys_typ_closed : "") ."\">";
246 print "<input type=\"hidden\" name=\"showrows\" value=\"1\">";
247 print "</td></tr>";
248 
249 ?>
250  <tr>
251  <td colspan="2" class="hdr">
252  Current Service:
253  </td>
254  <td colspan="3" class="hdr">
255  Upgrade Service:
256  </td>
257  </tr>
258  <tr>
259  <td class='iright' width='12%' valign="top">
260  <input type='checkbox' name='show_batch' value='1' <?php echo (isset($sys_typ_batch) ? "CHECKED" : ""); ?> disabled>Batch<br>
261  <input type='checkbox' name='show_live' value='2' <?php echo (isset($sys_typ_live) ? "CHECKED" : ""); ?> disabled>Live<br>
262  <input type='checkbox' name='show_asp' value='4' <?php echo (isset($sys_typ_asp) ? "CHECKED" : ""); ?> disabled>ASP<br>
263  </td>
264  <td class='iright' width='12%' valign="top">
265  <input type='checkbox' name='show_webonly' value='16' <?php echo (isset($sys_typ_webonly) ? "CHECKED" : ""); ?> disabled>Web ONLY<br>
266  <input type='checkbox' name='show_closed' value='64' <?php echo (isset($sys_typ_closed) ? "CHECKED" : ""); ?> disabled>Closed CU<br>
267  </td>
268  <td class='iright' valign="top">
269  <input type='checkbox' name='sys_typ_upgrade' value='32' <?php echo (isset($sys_typ_upgrade) ? "CHECKED" : ""); ?>>Upgrade / Conversion<br>
270  <input type='checkbox' name='sys_typ_ivr' value='8' <?php echo (isset($sys_typ_ivr) ? "CHECKED" : ""); ?>>IVR<br>
271  <input type='checkbox' name='sys_typ_voip' value='<?php echo $SYS_TYPE_VOIP; ?>' <?php echo (isset($sys_typ_voip) ? "CHECKED" : ""); ?>>VOIP<br>
272  </td>
273  <td nowrap align="right" class="dtl">
274  Target Launch Date:<br>
275  Next Contact Date:
276  </td>
277  <td nowrap class='dtl'>
278  <input type="text" name="target_launch" size="11" maxlength="10" id="targetlaunch" value="<?php echo $target_launch ?>">
279  &nbsp;
280  <font color="green">MM/DD/YYYY</font>
281  &nbsp;
282  <a id="setFlex" style="font-size:12px;" href="#" onClick="$('#targetlaunch').val('FLEX'); return false;">FLEX</a>
283  &nbsp;
284  <a id="setTbd" style="font-size:12px;" href="#" onClick="$('#targetlaunch').val('TBD'); return false;">TBD</a>
285  <br>
286  <input type="text" name="next_contact_date" size="11" maxlength="10" id="nextcontact" value="<?php echo $next_contact_date ?>">
287  &nbsp;
288  <font color="green">MM/DD/YYYY</font>
289  </td>
290 </tr>
291  <tr>
292  <td nowrap colspan='5' valign="top" class="dtl">
293  Home CU Upgrade Status:
294  <select name="sys_typ_upg">
295  <option value="0">No Upgrade in Process</option>
296  <option value="128" <?php echo (isset($sys_typ_upg_test) ? "SELECTED" : ""); ?>>Setup</option>
297  <option value="256" <?php echo (isset($sys_typ_upg_beta) ? "SELECTED" : ""); ?>>Beta</option>
298  <option value="512" <?php echo (isset($sys_typ_upg_comp) ? "SELECTED" : ""); ?>>Complete</option>
299  </select>
300  </td>
301  </tr>
302 
303  <tr>
304  <td colspan="5" class="hdr">
305  Current Products:
306  </td>
307  </tr>
308  <tr>
309  <td nowrap colspan='5' class='dtll'>
310 <?php
311  foreach ($cu_prodmaster as $code => $product) {
312  print "<input type='checkbox' name='cu_products[$code]' value='1'";
313  if (HCU_array_key_value($code, $cu_products)) print " checked";
314  print "> $product <input type='hidden' name='cu_prodmaster[$code]' value='$product'><br>";
315  }
316 
317 ?>
318  </td>
319  </tr>
320  <tr>
321  <td nowrap colspan='5' class='dtlc'>
322  <input type=hidden name="act" value="">
323  <br><input type="submit" name="Save" Value="Save" onClick="sendform('save')">
324  </td>
325  </tr>
326  </table>
327  </form>
328  </body>
329 </html>
330 <?php
331 break;
332  case "hiding":
333 # skinnied down to button only for inclusion in cuview iframe
334 # cu_header("Home CU - Upgrade Information");
335  print "<html><head>
336  <link rel=stylesheet href='/monitor/css/monitor.css' type='text/css'>
337 </head><body class='dtll'>";
338 ?>
339 
340  <?php
341  // Get the cu info from the database
342  $query = "select system_options,
343  case when target_launch = 'ASAP' or target_launch is null or
344  trim(target_launch)='' then null
345  when CURRENT_DATE > to_date(target_launch,'MM/DD/YYYY')
346  then null else target_launch end as target_launch,
347  case when CURRENT_DATE > next_contact_date then null
348  else next_contact_date end as next_contact_date,
349  case when date_live is null then 'PENDING'
350  else 'UPGRADE' end as data_status
351  from cuinfo where user_name = '$user_name'";
352  $result = db_query($query, $link);
353 
354  list( $system_options, $target_launch, $next_contact_date,$data_status) = db_fetch_array($result,0);
355 
356  $sys_typ_batch = ($system_options & $SYS_TYPE_BATCH ? $SYS_TYPE_BATCH : NULL);
357  $sys_typ_live = ($system_options & $SYS_TYPE_LIVE ? $SYS_TYPE_LIVE : NULL);
358  $sys_typ_asp = ($system_options & $SYS_TYPE_ASP ? $SYS_TYPE_ASP : NULL);
359  $sys_typ_ivr = ($system_options & $SYS_TYPE_IVR ? $SYS_TYPE_IVR : NULL);
360  $sys_typ_voip = ($system_options & $SYS_TYPE_VOIP ? $SYS_TYPE_VOIP : NULL);
361  $sys_typ_webonly = ($system_options & $SYS_TYPE_WEBONLY ? $SYS_TYPE_WEBONLY : NULL);
362  $sys_typ_upgrade = ($system_options & $SYS_TYPE_UPGRADE ? $SYS_TYPE_UPGRADE : NULL);
363  $sys_typ_closed = ($system_options & $SYS_TYPE_CLOSED ? $SYS_TYPE_CLOSED : NULL);
364 
365  $target_launch = dateformat("m/d/Y",trim($target_launch));
366  $next_contact_date = dateformat("m/d/Y",trim($next_contact_date));
367 
368 $msg='';
369 if (!is_null($sys_type_closed)) $msg.='Cannot upgrade closed client<br>';
370 if (($system_options & $SYS_TYPE_UPGRADE) || $data_status=="PENDING") $msg.="$data_status Target Launch $target_launch ~ Next Contact $next_contact_date<br>";
371 
372 if ($msg > '') {
373  print "<div class='msg'>$msg</div>
374  </body>
375 </html>";
376 } else {
377  print "<form action='$self' name='cuup' method='post'>";
378 print <<<EOP
379 <input type="hidden" name="sys_typ_batch" value="$sys_typ_batch">
380 <input type="hidden" name="sys_typ_live" value="$sys_typ_live">
381 <input type="hidden" name="sys_typ_asp" value="$sys_typ_asp">
382 <input type="hidden" name="sys_typ_webonly" value="$sys_typ_webonly">
383 <input type="hidden" name="sys_typ_closed" value="$sys_typ_closed">
384 <input type="hidden" name="sys_typ_upgrade" value="32">
385 <input type="hidden" name="sys_typ_ivr" value="$sys_typ_ivr">
386 <input type="hidden" name="sys_typ_voip" value="$sys_typ_voip">
387 <input type="hidden" name="target_launch" value="$target_launch">
388 <input type="hidden" name="next_contact_date" value="$next_contact_date">
389 <input type=hidden name="act" value="savehide">
390 <input type="submit" name="UPD" Value="Upgrade Service">
391  </form>
392 EOP;
393 
394 break;
395 }
396 }
397 ?>