Odyssey
ProdImpStat.data
1 <?php
2 /*
3  * File: ProdImpStat.data
4  *
5  * Purpose: This script handles the data/business logic for maintaining the cuprodimpstat table.
6  *
7  * History:
8  * 06/15/13 mbl - Modified to link with Implementation menu; stopped using some fields. Added e-mail notification of some
9  * steps (into and out of Published). One-click Next Status button.
10  */
11 
12  $monLibrary= dirname(__FILE__) . "/../library";
13  $monIncludes= dirname(__FILE__) . "/../includes";
14  $sharedLibrary= dirname(__FILE__) . "/../../shared/library";
15  require_once("$monLibrary/cu_top.i");
16  require_once("$monLibrary/ck_hticket.i");
17  require_once("$monIncludes/cu_remote_top.prg");
18  require_once ("$sharedLibrary/errormail.i"); // Be sure errormail is included
19 
20 try {
21  header('Content-Type: application/json');
22 
23  if (!CheckPerm($link, $Hu, basename($_SERVER['SCRIPT_NAME']), $_SERVER['REMOTE_ADDR'])) {
24  // ** Permissions failed
25  // ** throw an error
26  throw new Exception ("Permissions violation");
27  exit;
28  }
29 
30  $dms_ok = array( 'action'=>'string' );
31 
32  dms_import($dms_ok);
33 
34  //get the database connection
35  $dbh = $link;
36 
37  /***** DEBUG *****/
38  $fp = fopen("/tmp/miketest", "w");
39  if ( $fp ) {
40  fwrite( $fp, print_r( $_REQUEST, true ) );
41  }
42 
43  if ( $fp ) {
44  fwrite( $fp, "\naction = $action" );
45  }
46 
47  if ( $fp ) {
48  fwrite( $fp, "\ntime = " . date( "m/d/Y g:ia" ) );
49  }
50 
51  $jTableResult = Array();
52 
53  switch ($action) {
54  case "read":
55  // read ALL the desired data
56  $sql = "SELECT c.*, ci.name
57  FROM cuprodimpstat c
58  INNER JOIN cuinfo ci ON ci.user_name = c.user_name
59  ORDER BY c.enteredon asc ";
60  $impRs = db_query($sql, $dbh);
61 
62  if ( $fp ) {
63  fwrite( $fp, "\nsql = $sql" );
64  }
65 // $jTableResult['Result'] = 'OK';
66  $rowcnt = 0;
67  // return data like the client-side expects
68  while ( $impRow = db_fetch_assoc( $impRs, $rowcnt++ ) ) {
69  // create an md5 hash to help determine if the data changed by someone else
70  $Intermediate = implode( "", $impRow );
71  if ( $fp ) {
72  fwrite( $fp, "\nIntermediate = " . $Intermediate );
73  }
74 
75  $md5 = md5($Intermediate);
76  if ( $fp ) {
77  fwrite( $fp, "\nmd5 = $md5" );
78  }
79 
80  // the entry name has to match the declaration on the client side
81  $impList = array( "impid"=>$impRow["impid"], "md5hash"=>$md5,
82  "cuCode"=>$impRow["user_name"], "impStatus"=>$impRow["productstatus"],
83  "cuName"=>trim($impRow["name"]), "author"=>$impRow["author"],
84  "cuProduct"=>$impRow["product"], "enteredOn"=>$impRow["enteredon"],
85  "billedMonthly"=>$impRow["billedmonthly"], "developer"=>$impRow["developer"],
86  "targetDate"=>$impRow["imptargetdate"], "startOn"=>$impRow["impstarton"],
87  "finishOn"=>$impRow["impfinishon"], "billedSetup"=>$impRow["billedsetup"],
88  "vendor"=>$impRow["productvendor"] );
89  $jTableResult[] = $impList;
90  }
91 
92  break;
93  case "readculist":
94  // read ALL the desired data
95  $sql = "SELECT user_name, name
96  FROM cuinfo
97  WHERE (system_options & $SYS_TYPE_CLOSED) = 0
98  ORDER BY lower(name) ";
99  $cuRs = db_query($sql, $dbh);
100 
101  $rowcnt = 0;
102  // return data like the client-side expects
103  while ( $Row = db_fetch_assoc( $cuRs, $rowcnt++ ) ) {
104  $jTableResult[] = array( "cuCode"=>trim($Row["user_name"]), "cuName"=>trim($Row["name"]) );
105  }
106 
107  if ( $fp ) {
108  fwrite( $fp, "\njTableResult = " . print_r( $jTableResult, true ) );
109  }
110  break;
111  case "reademployees":
112  $sql = "SELECT user_name
113  FROM dmsmonitorusers
114  ORDER BY user_name ";
115  $cuRs = db_query($sql, $dbh);
116 
117  $rowcnt = 0;
118  // display in a javascript array
119  $jTableResult[] = array( "cuEmployee"=>"Unassigned" );
120  while ( $Row = db_fetch_assoc( $cuRs, $rowcnt++ ) ) {
121  $jTableResult[] = array( "cuEmployee"=>trim($Row["user_name"]) );
122  }
123  break;
124 
125  case "readvendor":
126  // read ALL the desired data
127  $sql = "SELECT ssovendor
128  FROM cussovendors
129  ORDER BY ssovendor";
130  $cuRs = db_query($sql, $dbh);
131 
132  $rowcnt = 0;
133  // return data like the client-side expects
134  $jTableResult[] = array( "cuVendor"=>"N/A" );
135  while ( $Row = db_fetch_assoc( $cuRs, $rowcnt++ ) ) {
136  $jTableResult[] = array( "cuVendor"=>trim($Row["ssovendor"]) );
137  }
138  break;
139 
140  case "update":
141  // NOTE: This uses a form post so the data comes in the $_POST variable
142  // get the id
143  $impId = isset( $_REQUEST["impid"] ) && ctype_digit( $_REQUEST["impid"] ) ? $_REQUEST["impid"] : 0;
144 
145  if ( !$impId ) {
146  throw new Exception ("Invalid identifier");
147  }
148 
149  // make sure the row didn't change (compare md5 hash so read the same as the "read" operation)
150  $sql = "SELECT c.*, ci.name
151  FROM cuprodimpstat c
152  INNER JOIN cuinfo ci ON ci.user_name = c.user_name
153  WHERE impid = " . $impId;
154  $impRs = db_query($sql, $dbh);
155  if ( $fp ) {
156  fwrite( $fp, "\nsql = " . $sql );
157  }
158 
159  $impRow = db_fetch_assoc($impRs);
160 
161  $Intermediate = implode( "", $impRow );
162  if ( $fp ) {
163  fwrite( $fp, "\nIntermediate = " . $Intermediate );
164  }
165 
166  $md5 = md5($Intermediate);
167  if ( $fp ) {
168  fwrite( $fp, "\nmd5 = " . $md5 );
169  }
170 
171 
172  $md5Hash = isset( $_REQUEST["md5hash"] ) && ctype_alnum( $_REQUEST["md5hash"] ) ? $_REQUEST["md5hash"] : "";
173 
174  if ( !strlen($md5Hash) ) {
175  throw new Exception ("Missing comparison hash");
176  }
177 
178  if ( $md5 == $md5Hash ) {
179  $cuCode = isset( $_REQUEST["cuCode"] ) && ctype_alnum( $_REQUEST["cuCode"] ) ? $_REQUEST["cuCode"] : "";
180  $impStatus = isset( $_REQUEST["impStatus"] ) && ctype_print( $_REQUEST["impStatus"] ) ? $_REQUEST["impStatus"] : "New";
181  $author = isset( $_REQUEST["author"] ) && ctype_alnum( $_REQUEST["author"] ) ? $_REQUEST["author"] : "Unassigned";
182  $cuProduct = isset( $_REQUEST["cuProduct"] ) && ctype_print( $_REQUEST["cuProduct"] ) ? $_REQUEST["cuProduct"] : "Unassigned";
183  $developer = isset( $_REQUEST["developer"] ) && ctype_alnum( $_REQUEST["developer"] ) ? $_REQUEST["developer"] : "Unassigned";
184  $vendor = isset( $_REQUEST["vendor"] ) && ctype_print( $_REQUEST["vendor"] ) ? $_REQUEST["vendor"] : "N/A";
185 
186  // dates
187  if ( isset( $_REQUEST["enteredOn"] ) && is_string( $_REQUEST["enteredOn"] ) && strlen( $_REQUEST["enteredOn"] ) )
188  $enteredOn = date( "'Y-m-d'", strtotime( $_REQUEST["enteredOn"] ) );
189  else
190  // default to today
191  $enteredOn = date( "'Y-m-d'" );
192 
193  if ( isset( $_REQUEST["targetDate"] ) && is_string( $_REQUEST["targetDate"] ) && strlen( $_REQUEST["targetDate"] ) )
194  $targetDate = date( "'Y-m-d'", strtotime( $_REQUEST["targetDate"] ) );
195  else
196  // default to empty
197  $targetDate = "null";
198 
199  if ( isset( $_REQUEST["startOn"] ) && is_string( $_REQUEST["startOn"] ) && strlen( $_REQUEST["startOn"] ) )
200  $startOn = date( "'Y-m-d'", strtotime( $_REQUEST["startOn"] ) );
201  else
202  // default to null
203  $startOn = "null";
204 
205  if ( isset( $_REQUEST["finishOn"] ) && is_string( $_REQUEST["finishOn"] ) && strlen( $_REQUEST["finishOn"] ) )
206  $finishOn = date( "'Y-m-d'", strtotime( $_REQUEST["finishOn"] ) );
207  else
208  // default to null
209  $finishOn = "null";
210 
211  if ( isset( $_REQUEST["billedSetup"] ) && is_string( $_REQUEST["billedSetup"] ) && strlen( $_REQUEST["billedSetup"] ) )
212  $billedSetup = date( "'Y-m-d'", strtotime( $_REQUEST["billedSetup"] ) );
213  else {
214  $billedSetup = "null";
215  }
216 
217  if ( isset( $_REQUEST["billedMonthly"] ) && is_string( $_REQUEST["billedMonthly"] ) && strlen( $_REQUEST["billedMonthly"] ) )
218  $billedMonthly = date( "'Y-m-d'", strtotime( $_REQUEST["billedMonthly"] ) );
219  else {
220  $billedMonthly = "null";
221  }
222 
223 
224  // some sanity checking
225  $errorList = array();
226  if ( !strlen( $cuCode ) ) $errorList[] = "Invalid CU Code";
227 
228  if ( count( $errorList ) > 0 ) {
229  $errorString = implode( "\n", $errorList );
230  throw new Exception ($errorString);
231  }
232 
233  $sql = "UPDATE cuprodimpstat SET
234  user_name = '$cuCode',
235  productstatus = '$impStatus',
236  author = '$author',
237  product = '$cuProduct',
238  enteredon = $enteredOn,
239  billedsetup = $billedSetup,
240  developer = '$developer',
241  imptargetdate = $targetDate,
242  impstarton = $startOn,
243  impfinishon = $finishOn,
244  billedmonthly = $billedMonthly,
245  productvendor = '$vendor'
246  WHERE impid = $impId ";
247  $upd_rs = db_query ($sql, $dbh);
248 
249  if ( $fp ) {
250  fwrite( $fp, "\nupdate sql = " . $sql );
251  }
252  if (!$upd_rs) {
253  throw new Exception ("Error Updating Record for $cuCode");
254  }
255  // re-read to get the updated md5 hash
256  $sql = "SELECT c.*, ci.name
257  FROM cuprodimpstat c
258  INNER JOIN cuinfo ci ON ci.user_name = c.user_name
259  WHERE impid = " . $impId;
260  $impRs = db_query($sql, $dbh);
261 
262  if ( $fp ) {
263  fwrite( $fp, "\nsql = " . $sql );
264  }
265 
266  $impRow = db_fetch_assoc($impRs);
267 
268  $Intermediate = implode( "", $impRow );
269  if ( $fp ) {
270  fwrite( $fp, "\nIntermediate = " . $Intermediate );
271  }
272 
273  $md5 = md5($Intermediate);
274 
275  // return current data
276  $impList = array( "impid"=>$impRow["impid"], "md5hash"=>$md5,
277  "cuCode"=>$impRow["user_name"], "impStatus"=>$impRow["productstatus"],
278  "cuName"=>trim($impRow["name"]), "author"=>$impRow["author"],
279  "cuProduct"=>$impRow["product"], "enteredOn"=>$impRow["enteredon"],
280  "billedMonthly"=>$impRow["billedmonthly"], "developer"=>$impRow["developer"],
281  "targetDate"=>$impRow["imptargetdate"], "startOn"=>$impRow["impstarton"],
282  "finishOn"=>$impRow["impfinishon"], "billedSetup"=>$impRow["billedsetup"],
283  "vendor"=>$impRow["productvendor"] );
284 
285  $jTableResult[] = $impList;
286 
287  } else {
288  // didn't match so just return current data with an error
289  $impList = array( "impid"=>$impRow["impid"], "md5hash"=>$md5,
290  "cuCode"=>$impRow["user_name"], "impStatus"=>$impRow["productstatus"],
291  "cuName"=>trim($impRow["name"]), "author"=>$impRow["author"],
292  "cuProduct"=>$impRow["product"], "enteredOn"=>$impRow["enteredon"],
293  "billedMonthly"=>$impRow["billedmonthly"], "developer"=>$impRow["developer"],
294  "targetDate"=>$impRow["imptargetdate"], "startOn"=>$impRow["impstarton"],
295  "finishOn"=>$impRow["impfinishon"], "billedSetup"=>$impRow["billedsetup"],
296  "vendor"=>$impRow["productvendor"] );
297 
298  $jTableResult["error"] = "One or more values changed prior to update. Please refresh page and re-enter values.";
299  $jTableResult[] = $impList;
300  }
301  break;
302  case "create":
303  // strings
304  $cuCode = isset( $_REQUEST["cuCode"] ) && ctype_alnum( $_REQUEST["cuCode"] ) ? $_REQUEST["cuCode"] : "";
305  $impStatus = isset( $_REQUEST["impStatus"] ) && ctype_print( $_REQUEST["impStatus"] ) ? $_REQUEST["impStatus"] : "New";
306  $author = isset( $_REQUEST["author"] ) && ctype_alnum( $_REQUEST["author"] ) ? $_REQUEST["author"] : "Unassigned";
307  $cuProduct = isset( $_REQUEST["cuProduct"] ) && ctype_alnum( $_REQUEST["cuProduct"] ) ? $_REQUEST["cuProduct"] : "Unassigned";
308  $developer = isset( $_REQUEST["developer"] ) && ctype_alnum( $_REQUEST["developer"] ) ? $_REQUEST["developer"] : "Unassigned";
309  $vendor = isset( $_REQUEST["vendor"] ) && ctype_print( $_REQUEST["vendor"] ) ? $_REQUEST["vendor"] : "N/A";
310 
311  // dates
312  if ( isset( $_REQUEST["enteredOn"] ) && is_string( $_REQUEST["enteredOn"] ) && strlen( $_REQUEST["enteredOn"] ) )
313  $enteredOn = date( "'Y-m-d'", strtotime( $_REQUEST["enteredOn"] ) );
314  else
315  // default to today
316  $enteredOn = date( "'Y-m-d'" );
317 
318  if ( isset( $_REQUEST["targetDate"] ) && is_string( $_REQUEST["targetDate"] ) && strlen( $_REQUEST["targetDate"] ) )
319  $targetDate = date( "'Y-m-d'", strtotime( $_REQUEST["targetDate"] ) );
320  else
321  // default to today
322  $targetDate = "null";
323 
324  if ( isset( $_REQUEST["startOn"] ) && is_string( $_REQUEST["startOn"] ) && strlen( $_REQUEST["startOn"] ) )
325  $startOn = date( "'Y-m-d'", strtotime( $_REQUEST["startOn"] ) );
326  else
327  // default to null
328  $startOn = "null";
329 
330  // these should be null on create
331  $finishOn = "null";
332  $billedSetup = "null";
333  $billedMonthly = "null";
334 
335  // some sanity checking
336  $errorList = array();
337  if ( !strlen( $cuCode ) ) $errorList[] = "Invalid CU Code";
338 
339  if ( count( $errorList ) ) {
340  $errorString = implode( "\n", $errorList );
341  throw new Exception ($errorString);
342  }
343 
344  // get the next impid since need to return it
345  $sql = "SELECT nextval('cuprodimpstat_impid_seq') as impid";
346  $impRs = db_query($sql, $dbh);
347  $impRow = db_fetch_assoc($impRs);
348  $impId = $impRow["impid"];
349 
350 
351  // add the record
352  $sql = "INSERT INTO cuprodimpstat
353  ( impid, user_name, productstatus, author, product,
354  enteredon, developer, imptargetdate, impstarton,
355  impfinishon, productvendor, billedsetup, billedmonthly, createdon,
356  createdby )
357  VALUES
358  (" . $impId . ",
359  '" . prep_save($cuCode, 12) . "',
360  '" . prep_save($impStatus, 10) . "',
361  '" . prep_save($author, 12) . "',
362  '" . prep_save($cuProduct, 30) . "',
363  " . $enteredOn . ",
364  '" . prep_save($developer, 12) . "',
365  " . $targetDate . ",
366  " . $startOn . ",
367  " . $finishOn . ",
368  '" . prep_save($vendor, 20) . "',
369  " . $billedSetup . ",
370  " . $billedMonthly . ",
371  '" . date( "Y-m-d G:i:s" ) . "',
372  '" . prep_save($Hu, 12) . "')";
373  if ( $fp ) {
374  fwrite( $fp, " create: $sql" );
375  }
376 
377  $updRs = db_query( $sql, $dbh );
378  if (!$updRs) {
379  throw new Exception ("Error Inserting Product Feature Status Record");
380  }
381 
382  // return the unique id and hash
383  $sql = "SELECT c.*, ci.name
384  FROM cuprodimpstat c
385  INNER JOIN cuinfo ci ON ci.user_name = c.user_name
386  WHERE impid = " . $impId;
387  $impRs = db_query($sql, $dbh);
388 
389  if ( $fp ) {
390  fwrite( $fp, "\nsql = " . $sql );
391  }
392 
393  $impRow = db_fetch_assoc($impRs);
394 
395  $Intermediate = implode( "", $impRow );
396  if ( $fp ) {
397  fwrite( $fp, "\nIntermediate = " . $Intermediate );
398  }
399 
400  $md5 = md5($Intermediate);
401 
402  // return current data
403  $impList = array( "impid"=>$impRow["impid"], "md5hash"=>$md5,
404  "cuCode"=>$impRow["user_name"], "impStatus"=>$impRow["productstatus"],
405  "cuName"=>trim($impRow["name"]), "author"=>$impRow["author"],
406  "cuProduct"=>$impRow["product"], "enteredOn"=>$impRow["enteredon"],
407  "billedMonthly"=>$impRow["billedmonthly"], "developer"=>$impRow["developer"],
408  "targetDate"=>$impRow["imptargetdate"], "startOn"=>$impRow["impstarton"],
409  "finishOn"=>$impRow["impfinishon"], "billedSetup"=>$impRow["billedsetup"],
410  "vendor"=>$impRow["productvendor"] );
411 
412  $jTableResult[] = $impList;
413 
414  break;
415  case "delete":
416  // not implementing delete
417  break;
418  case "nextstatus":
419  // advance the status to the next step, performing necessary operations
420  $impId = isset( $_REQUEST["impid"] ) && ctype_digit( $_REQUEST["impid"] ) ? $_REQUEST["impid"] : 0;
421 
422  // get the current info
423  $sql = "SELECT c.*
424  FROM cuprodimpstat c
425  WHERE impid = " . $impId;
426  $impRs = db_query($sql, $dbh);
427 
428  $impRow = db_fetch_assoc( $impRs );
429 
430  switch ( $impRow["productstatus"] ) {
431  case "New":
432  $newDeveloper = ( $impRow["developer"] == "Unassigned") ? $Hu : $impRow["developer"];
433  $newStatus = "In Devel";
434  $startOn = date( 'Y-m-d' );
435 
436  $sql = "UPDATE cuprodimpstat SET
437  developer = '$newDeveloper',
438  productstatus = '$newStatus',
439  impstarton = '$startOn'
440  WHERE impId = $impId";
441  db_query($sql, $dbh);
442  break;
443  case "In Devel":
444  $newStatus = "In Review";
445 
446  $sql = "UPDATE cuprodimpstat SET
447  productstatus = '$newStatus'
448  WHERE impId = $impId";
449  db_query($sql, $dbh);
450  break;
451  case "In Review":
452  $newStatus = "Published";
453  $finishOn = date( 'Y-m-d' );
454 
455  $sql = "UPDATE cuprodimpstat SET
456  productstatus = '$newStatus',
457  impfinishon = '$finishOn'
458  WHERE impId = $impId";
459  db_query($sql, $dbh);
460 
461  // set pre-billing notification e-mail
462  SendNoticeToOwner( $impId, "prebill", "Product Feature is published" );
463  break;
464  case "Published":
465  $newStatus = "Bill Setup";
466 
467  $sql = "UPDATE cuprodimpstat SET
468  productstatus = '$newStatus'
469  WHERE impId = $impId";
470  db_query($sql, $dbh);
471 
472  // set billing notification e-mail
473  SendNoticeToOwner( $impId, "billing", "Product Feature ready for billing" );
474  break;
475  case "Bill Setup":
476  $newStatus = "Bill Month";
477  $billDate = date( 'Y-m-d' );
478 
479  $sql = "UPDATE cuprodimpstat SET
480  productstatus = '$newStatus',
481  billedsetup = '$billDate'
482  WHERE impId = $impId";
483  db_query($sql, $dbh);
484  break;
485  case "Bill Month":
486  $newStatus = "Complete";
487  $billDate = date( 'Y-m-d' );
488 
489  $sql = "UPDATE cuprodimpstat SET
490  productstatus = '$newStatus',
491  billedmonthly = '$billDate'
492  WHERE impId = $impId";
493  db_query($sql, $dbh);
494  break;
495  case "Complete":
496  default:
497  // do nothing
498  break;
499  }
500 
501  if ( $fp ) {
502  fwrite( $fp, "\nsql = " . $sql );
503  }
504 
505  break;
506  }
507 
508 // if ($jTableResult['Result'] == '') {
509 // throw new Exception ("Unknown error - $action");
510 // }
511 
512  print json_encode($jTableResult);
513 }
514 catch(Exception $ex)
515 {
516  //Return error message
517  $jTableResult = array();
518  $jTableResult["error"] = $ex->getMessage();
519  print json_encode($jTableResult);
520 }
521 
522 if ( $fp ) {
523  fwrite( $fp, "\n" . json_encode($jTableResult) );
524 }
525 
526 /*************** Functions ******************/
527 // Send a notice about the product being added to the primary and secondary feature owner.
528 function SendNoticeToOwner( $impId, $owner, $subjectStart ) {
529  global $dbh;
530 
531  // get product info
532  $sql = "SELECT *
533  FROM cuprodimpstat
534  WHERE impid = '$impId' ";
535 
536  if ( $rs = db_query( $sql, $dbh ) ) {
537  $productRow = db_fetch_array( $rs );
538 
539  $cuCode = $productRow["user_name"];
540  $cuProduct = $productRow["product"];
541 
542  // get owner of this step
543  $sql = "SELECT $owner
544  FROM cuprodlist
545  WHERE home_cu_code = '$cuProduct' ";
546 
547  if ( $rs = db_query( $sql, $dbh ) ) {
548  $ownerRow = db_fetch_array( $rs );
549 
550  $owner = trim( $ownerRow["$owner"] );
551  if ( strlen( $owner ) ) {
552  // send notice
553  SendNotice( $owner, $cuCode, $cuProduct, $subjectStart );
554  }
555  }
556  }
557 
558  return;
559 } // end SendNoticeToOwner
560 
561 function SendNotice( $empName, $cuCode, $cuProduct, $subjectStart ) {
562  global $dbh, $Hu;
563 
564  // ** NOTIFY USER if a user was selected to be notified
565  $sql = "SELECT *
566  FROM dmsmonitorusers
567  WHERE user_name = '$empName' ";
568  $notifyRS = db_query( $sql, $dbh );
569 
570  if ( $notifyRS !== FALSE ) {
571 
572  $notifyRow = db_fetch_array( $notifyRS );
573  if ( trim($notifyRow['notifyemail']) !== '' ) {
574  $notifySendTo = trim($notifyRow['notifyemail']);
575 
576  // ** Determine the FROM -- Author Email
577  $sql = "SELECT *
578  FROM dmsmonitorusers
579  WHERE user_name = '$Hu' ";
580  $authorRS = db_query($sql, $dbh);
581  $authorRow = db_fetch_array($authorRS);
582  if ( trim( $authorRow['notifyemail'] ) != '' ) {
583  $notifySendFrm = trim( $authorRow['notifyemail'] );
584  } else {
585  $notifySendFrm = "nobody@homecu.net";
586  }
587 
588  // get the full CU name and service name
589  $sql = "SELECT name
590  FROM cuinfo
591  WHERE user_name = '$cuCode' ";
592  $nameRS = db_query( $sql, $dbh );
593  $nameRow = db_fetch_array($nameRS);
594 
595  $sql = "SELECT home_cu_desc
596  FROM cuprodlist
597  WHERE home_cu_code = '$cuProduct' ";
598  $productRS = db_query( $sql, $dbh );
599  $productRow = db_fetch_array( $productRS );
600 
601  $notifySubject = "$subjectStart: $cuProduct for $cuCode.";
602 
603  // send some more knowledge
604  $notifyMessage = "";
605  $notifyMessage .= "CU: " . trim( $nameRow["name"] ) . " (" . $cuCode . ")\n";
606  $notifyMessage .= "Service: " . $productRow["home_cu_desc"] . "\n\n";
607  $notifyMessage .= "Entered by $Hu\n";
608  $notifyMessage .= date( "m/d/y g:ia" );
609 
610  $notify = new ErrorMail;
611  $notify->mailto = $notifySendTo;
612  $notify->replyto = $notifySendFrm;
613  $notify->mailfrom = $notifySendFrm;
614 
615  $notify->subject = $notifySubject;
616  $notify->msgbody = $notifyMessage;
617  $notify->callingfunction = __FUNCTION__;
618  $notify->file = __FILE__;
619  $notify->cu = $cuCode;
620 
621  $notify->SendMail();
622  }
623  }
624 
625  return;
626 } // end SendNotice
627 /*************** End Functions **************/
628 ?>
SendMail()
Definition: errormail.i:111