PageRenderTime 39ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/otd/serviceSummary.php

https://github.com/zsalwen/Service-Office
PHP | 208 lines | 200 code | 1 blank | 7 comment | 85 complexity | 58c59b591c6281062111473d2bf530d5 MD5 | raw file
  1. <?
  2. include 'common.php';
  3. function monthConvert($month){
  4. if ($month == '01'){ return 'January'; }
  5. if ($month == '02'){ return 'February'; }
  6. if ($month == '03'){ return 'March'; }
  7. if ($month == '04'){ return 'April'; }
  8. if ($month == '05'){ return 'May'; }
  9. if ($month == '06'){ return 'June'; }
  10. if ($month == '07'){ return 'July'; }
  11. if ($month == '08'){ return 'August'; }
  12. if ($month == '09'){ return 'September'; }
  13. if ($month == '10'){ return 'October'; }
  14. if ($month == '11'){ return 'November'; }
  15. if ($month == '12'){ return 'December'; }
  16. }
  17. function month2num($month){
  18. if (strtoupper($month) == 'JANUARY' || $month == 1){
  19. return '1';
  20. }elseif (strtoupper($month) == 'FEBRUARY' || $month == 2){
  21. return '2';
  22. }elseif (strtoupper($month) == 'MARCH' || $month == 3){
  23. return '3';
  24. }elseif (strtoupper($month) == 'APRIL' || $month == 4){
  25. return '4';
  26. }elseif (strtoupper($month) == 'MAY' || $month == 5){
  27. return '5';
  28. }elseif (strtoupper($month) == 'JUNE' || $month == 6){
  29. return '6';
  30. }elseif (strtoupper($month) == 'JULY' || $month == 7){
  31. return '7';
  32. }elseif (strtoupper($month) == 'AUGUST' || $month == 8){
  33. return '8';
  34. }elseif (strtoupper($month) == 'SEPTEMBER' || $month == 9){
  35. return '9';
  36. }elseif (strtoupper($month) == 'OCTOBER' || $month == 10){
  37. return '10';
  38. }elseif (strtoupper($month) == 'NOVEMBER' || $month == 11){
  39. return '11';
  40. }elseif (strtoupper($month) == 'DECEMBER' || $month == 12){
  41. return '12';
  42. }else{
  43. return $month;
  44. }
  45. }
  46. function dateExplode($date){
  47. $date=explode('-',$date);
  48. $date=monthConvert($date[1])." ".$date[2].", ".$date[0];
  49. return $date;
  50. }
  51. function dateImplode($date){
  52. $str=explode(' AT ',$date);
  53. $time=str_replace(' ','',$str[1]);
  54. $date2=explode(' ',$str[0]);
  55. $month=month2num(trim($date2[0]));
  56. $day=str_replace(',','',$date2[1]);
  57. $year=$date2[2];
  58. return $month.'/'.$day.'/'.$year.' @ '.$time;
  59. }
  60. function postDateImplode($date){
  61. $str=explode(' ',$date);
  62. $time=$str[3].$str[4];
  63. $month=month2num(trim($str[0]));
  64. $day=str_replace(',','',$str[1]);
  65. $year=$str[2];
  66. return $month.'/'.$day.'/'.$year.' @ '.$time;
  67. }
  68. function attorneyCustomLang($att,$str){
  69. $r=@mysql_query("SELECT * FROM ps_str_replace where attorneys_id = '$att'");
  70. while ($d=mysql_fetch_array($r, MYSQL_ASSOC)){
  71. if ($d['str_search'] && $d['str_replace'] && $str && $att){
  72. $str = str_replace($d['str_search'], strtoupper($d['str_replace']), $str);
  73. $str = str_replace(strtoupper($d['str_search']), strtoupper($d['str_replace']), $str);
  74. //echo "<script>alert('Replacing ".strtoupper($d['str_search'])." with ".strtoupper($d['str_replace']).".');< /script>";
  75. }
  76. }
  77. return $str;
  78. }
  79. function historyList($packet,$defendant,$attorneys_id){
  80. $qn="SELECT * FROM ps_history WHERE packet_id = '$packet' and defendant_id = '$defendant' order by history_id ASC";
  81. $rn=@mysql_query($qn);
  82. $list = "<div>";
  83. $counter=0;
  84. while ($dn=mysql_fetch_array($rn, MYSQL_ASSOC)){$counter++;
  85. $action_str=str_replace('<LI>','',strtoupper($dn[action_str]));
  86. $action_str=str_replace('</LI>','',$action_str);
  87. $list .= "<div class='list'>#$dn[history_id] : ".id2server($dn[serverID]).' '.$dn[wizard].'<br>'.stripslashes(attorneyCustomLang($attorneys_id,$action_str));
  88. if ($dn[wizard] == 'BORROWER' || $dn[wizard] == 'NOT BORROWER'){
  89. $list .= '<br>'.attorneyCustomLang($attorneys_id,$dn[residentDesc]);
  90. }
  91. $list .= "</div>";
  92. }
  93. $list .= "</div>";
  94. return $list;
  95. }
  96. function nameDef($defendant,$packet){
  97. $r=@mysql_query("SELECT name".$defendant." from ps_packets WHERE packet_id='$packet'") or die (mysql_error());
  98. $d=mysql_fetch_array($r,MYSQL_ASSOC);
  99. return strtoupper($d["name$defendant"]);
  100. }
  101. function deliveryExplode($packet,$defendant){
  102. $qh="SELECT action_str, serverID, address, wizard, resident, residentDesc FROM ps_history WHERE packet_id='$packet' AND defendant_id='$defendant' AND (WIZARD='BORROWER' OR WIZARD='NOT BORROWER')";
  103. $rh=@mysql_query($qh) or die (mysql_error());
  104. $dh=mysql_fetch_array($rh,MYSQL_ASSOC);
  105. if ($dh != ''){
  106. $action=explode('DATE OF SERVICE: ',strtoupper($dh[action_str]));
  107. $dt=explode('<BR>',$action[1]);
  108. $dt=dateImplode($dt[0]);
  109. $serverID=id2name($dh[serverID]);
  110. if ($dh[wizard] == 'BORROWER'){
  111. $serverID .= " To: ".nameDef($defendant,$packet);
  112. }else{
  113. $serverID .= " To: ".strtoupper($dh[resident]);
  114. }
  115. $address=explode(',',$dh[address]);
  116. $PDAddress=substr($address[0],0,16);
  117. $residentDesc=$dh[residentDesc];
  118. $entry="<table align='center'>
  119. <tr>
  120. <td width='300px' style='border-bottom:solid 1px'>Personal Delivery @ ".$PDAddress."</td>
  121. <td width='30px' style='border-bottom:solid 1px'>Date:</td>
  122. <td width='140px' style='border-bottom:solid 1px'>".$dt."</td>
  123. <td width='200px' style='border-bottom:solid 1px'>By: ".$serverID."</td>
  124. <td width='600px' style='border-bottom:solid 1px'>Desc: ".$residentDesc."</td>
  125. </tr>
  126. </table>";
  127. }
  128. return $entry;
  129. }
  130. function descExplode($str){
  131. $action_str=explode('<BR>',$str);
  132. $count=count($action_str)-1;
  133. return $action_str["$count"];
  134. }
  135. function attemptExplode($packet,$defendant,$address,$type){
  136. $qh="SELECT action_str, serverID FROM ps_history WHERE packet_id='$packet' AND defendant_id='$defendant' AND action_str LIKE '%$address%' AND WIZARD='$type'";
  137. $rh=@mysql_query($qh) or die (mysql_error());
  138. while ($dh=mysql_fetch_array($rh,MYSQL_ASSOC)){
  139. if ($dh != ''){
  140. $action=explode('</LI>',strtoupper($dh[action_str]));
  141. $dt=explode('<BR>',$action[1]);
  142. $attAddress=$dt[1];
  143. if ($type == 'POSTING DETAILS'){
  144. $dt=postDateImplode($dt[0]);
  145. }else{
  146. $dt=dateImplode($dt[0]);
  147. }
  148. $serverID=id2name($dh[serverID]);
  149. $desc=descExplode($dh[action_str]);
  150. $entry .= "<table align='center'>
  151. <tr>
  152. <td width='350px' style='border-bottom:solid 1px'>$attAddress</td>
  153. <td width='30px' style='border-bottom:solid 1px'>Date:</td>
  154. <td width='140px' style='border-bottom:solid 1px'>$dt</td>
  155. <td width='150px' style='border-bottom:solid 1px'>By: $serverID</td>
  156. <td width='600px' style='border-bottom:solid 1px'>Desc: $desc</td>
  157. </tr>
  158. </table>";
  159. }
  160. }
  161. return $entry;
  162. }
  163. ?>
  164. <style>
  165. body{padding:0px; margin:0px;}
  166. td{font-size:11px;}
  167. div{font-size:10px; text-align:left;}
  168. fieldset, legend, div, table, tr, td, input {padding:0px;}
  169. div.list {border-bottom:solid 1px;}
  170. </style>
  171. <?
  172. //service summary (for client updates)
  173. $packet=$_GET[packet];
  174. $q="SELECT * from ps_packets WHERE packet_id='$packet'";
  175. $r=@mysql_query($q) or die(mysql_error());
  176. $d=mysql_fetch_array($r, MYSQL_ASSOC);
  177. $i=0;
  178. $date=date("m/d/Y h:i:s A");
  179. echo "<div class='list'>Service Summary for Process Serving Packet $packet - <b>Printed $date</b></div>";
  180. while ($i < 6){$i++;
  181. if ($d["name$i"]){
  182. echo "<fieldset>";
  183. echo "<legend>".$d["name$i"]."</legend>";
  184. echo deliveryExplode($packet,$i);
  185. if ($d["address$i"]){
  186. $address=strtoupper($d["address$i"]);
  187. echo attemptExplode($packet,$i,$address,"FIRST EFFORT");
  188. echo attemptExplode($packet,$i,$address,"SECOND EFFORT");
  189. echo attemptExplode($packet,$i,$address,"POSTING DETAILS");
  190. }
  191. foreach(range('a','e') as $letter){
  192. if ($d["address$i$letter"]){
  193. $address=strtoupper($d["address$i$letter"]);
  194. echo attemptExplode($packet,$i,$address,"FIRST EFFORT");
  195. echo attemptExplode($packet,$i,$address,"SECOND EFFORT");
  196. echo attemptExplode($packet,$i,$address,"POSTING DETAILS");
  197. }
  198. }
  199. /*$q1="SELECT * from ps_history WHERE packet_id='$packet' AND defendant_id='$i'"
  200. $r1=@mysql_query($q1) or die(mysql_error());
  201. while ($d1=mysql_fetch_array($r1, MYSQL_ASSOC)){
  202. }*/
  203. echo "</fieldset>";
  204. }
  205. }
  206. ?>