PageRenderTime 54ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/pvaccine.php

https://github.com/johntrombly/vtracnow
PHP | 2349 lines | 1737 code | 105 blank | 507 comment | 274 complexity | b7d74c46e905bcc2c9f72658a850d40c MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. // http://nathanj.github.io/gitguide/tour.html
  3. $crlf = chr(13) . chr(10);
  4. $d_quote = chr(34);
  5. $cgi = $_SERVER['PHP_SELF'];
  6. include ('include.txt');
  7. $bio_table = "vt_test_biological";
  8. $detail_table = "vt_test_detail";
  9. $email_table = "vt_test_email";
  10. $man_table = "vt_test_man";
  11. $mydbf = "vaccine";
  12. // $PHP_AUTH_USER is not used for the test application
  13. // Set a var called $user_name
  14. // The commented text is not changed
  15. $user_name = "Test Web User";
  16. $usr_access = "100";
  17. // for pvaccine.php use $mytable = "p_detail";
  18. // for pvaccine_state.php use $mytable = $mytable = "p_detail_mcd";
  19. //$mytable = "p_detail"; // pvaccine.php
  20. $mytable = $detail_table; // pvaccine.php
  21. $content = "The following is an automated message from the Commercial Pediatric Vaccine Tracker.\r\nPlease do not respond via email reply because the reply mail box is bogus.\r\n\r\nMessage: %%message%%\r\n\r\n";
  22. $from_string_addr = "From: Vaccine Tracker\r\n" ."Reply-To: webmaster@asthmaandallergy.com\r\n" ."X-Mailer: PHP/" . phpversion();
  23. //$mytable = "p_detail_mcd"; // pvaccine_state.php
  24. // in mybanner change the backgrounds pvaccine.php and pvaccine_state.php
  25. // use the top one for Pedi Commercial vaccines ---pvaccine.php---
  26. //$bk = "background='/backgrounds/water003.jpg'";
  27. // use the next one for Pedi State vaccines ---pvaccine_state.php--
  28. //$bk = "background='/backgrounds/comp010.jpg'";
  29. // Also comment out the proper item below in the mybanner section
  30. // echo "<title>Commercial Pediatric Vaccine Tracker</title>\n";
  31. // echo "<title>State Pediatric Vaccine Tracker</title>\n";
  32. $exp_window = 30;
  33. // time needs to have the format of 99:99 or else the sort will not work properly
  34. // ie order by r_date, r_time ASC as well as c_date, c_time ASC!!!
  35. // vaccine_list and expire seem to be the same code!
  36. // Need to consolidate if true
  37. // Keep expire and remove vaccine_list
  38. //--
  39. //-- Database: `inventory`
  40. //--
  41. //-- --------------------------------------------------------
  42. //--
  43. //-- Table structure for table `biological`
  44. //--
  45. //CREATE TABLE `biological` (
  46. // `id` double NOT NULL auto_increment,
  47. // `name` varchar(32) NOT NULL default '',
  48. // `state_memo` text NOT NULL,
  49. // `comm_memo` text NOT NULL,
  50. // PRIMARY KEY (`id`)
  51. //) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=21 ;
  52. //
  53. //-- --------------------------------------------------------
  54. //--
  55. //-- Table structure for table `detail`
  56. //--
  57. //CREATE TABLE `detail` (
  58. // `id` double NOT NULL auto_increment,
  59. // `biological_id` double NOT NULL default '0',
  60. // `man_id` double NOT NULL default '1',
  61. // `exp_date` date NOT NULL default '0000-00-00',
  62. // `lot_num` varchar(80) NOT NULL default '',
  63. // `r_name` varchar(30) NOT NULL default '',
  64. // `r_date` date NOT NULL default '0000-00-00',
  65. // `r_time` varchar(5) NOT NULL default '',
  66. // `r_ip` varchar(15) NOT NULL default '',
  67. // `consumed_ynd` enum('Y','N','D') NOT NULL default 'N',
  68. // `c_name` varchar(30) NOT NULL default '',
  69. // `c_date` date NOT NULL default '0000-00-00',
  70. // `c_time` varchar(5) NOT NULL default '',
  71. // `c_ip` varchar(15) NOT NULL default '',
  72. // `note` varchar(132) NOT NULL default '',
  73. // PRIMARY KEY (`id`),
  74. // KEY `exp_date` (`exp_date`),
  75. // KEY `r_date` (`r_date`),
  76. // KEY `c_date` (`c_date`),
  77. // KEY `bilogical_id` (`biological_id`)
  78. //) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=136 ;
  79. //--
  80. //-- Table structure for table `vt_test_man`
  81. //--
  82. //
  83. //CREATE TABLE `vt_test_man` (
  84. // `id` double NOT NULL auto_increment,
  85. // `name` varchar(32) NOT NULL default '',
  86. // PRIMARY KEY (`id`)
  87. //) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ;
  88. //
  89. //--
  90. //-- Dumping data for table `vt_test_man`
  91. //--
  92. //
  93. //INSERT INTO `vt_test_man` (`id`, `name`) VALUES
  94. //(1, 'unknown'),
  95. //(2, 'GSK'),
  96. //(3, 'Merck'),
  97. //(4, 'Norvatis'),
  98. //(5, 'Sanofi'),
  99. //(6, 'Wyeth'),
  100. //(7, 'MedImmune');
  101. // below is the short version of the program name ie secure.html
  102. // use this one if we want the security to work reguardless of where the program lives
  103. //$cgi = substr($PHP_SELF,strrpos($cgi,"/")+1);
  104. // Select host here
  105. $myHost = "local";
  106. //$myHost = "ras";
  107. //$myHost = "nec";
  108. // end of Selection host
  109. // Make dbf connection here ($dbh)
  110. $dbh = mysql_connect('localhost', 'vtracuser','74mgMqGeL1nySu7xzMfl') or die("unable to open database");
  111. // $mydbf can change
  112. $mydbf = "vaccine";
  113. mysql_select_db("$mydbf") or die("unable to access database");
  114. /*
  115. // security code
  116. if (!isset($PHP_AUTH_USER)) {
  117. Header("WWW-Authenticate: Basic realm=\"Pediatric Vaccine Tracker\"");
  118. Header("HTTP/1.0 401 Unauthorized");
  119. echo "Cancled by user\n";
  120. exit;
  121. } else {
  122. // first let's do some self enrollment
  123. $q = "select count(id) from s_prog where name = $d_quote$cgi$d_quote";
  124. $r = mysql_query($q) or die(mysql_error());
  125. $found = mysql_result($r, 0, 0);
  126. if ($found < 1) { // time to enroll!
  127. $comment = "Name:" . chr(13) . "General:" . chr(13) . "Features:" . chr(13) . "Model:";
  128. $q = "insert into s_prog set name = $d_quote$cgi$d_quote, comment = $d_quote$comment$d_quote";
  129. $r = mysql_query($q) or die(mysql_error());
  130. // it is now enrolled!
  131. }
  132. $q = "select a.id
  133. from s_usr a, s_prog b, s_usr_prog_x c
  134. where a.name = $d_quote$PHP_AUTH_USER$d_quote and a.pass = $d_quote$PHP_AUTH_PW$d_quote and
  135. b.id = c.s_prog_id and a.id = s_usr_id";
  136. $r = mysql_query($q) or die(mysql_error());
  137. $found = mysql_num_rows($r);
  138. if ($found < 1) { // User is not in database
  139. echo '<center><font size="+2">Access Forbidden!</font></center>';
  140. echo "<center><font size='+2'>User $PHP_AUTH_USER not on File<br>or password does not match</font></center>";
  141. exit;
  142. } else { // is this person registered with permission to this program?
  143. $row = mysql_fetch_array($r);
  144. $user_id = $row["id"]; // this is the user id
  145. // what is the program id??
  146. $q = "select id from s_prog where name = $d_quote$cgi$d_quote";
  147. $r = mysql_query($q) or die(mysql_error());
  148. $prog_id = mysql_result($r, 0, 0);
  149. // prepair the SQL
  150. $q = "select id, usr_access from s_usr_prog_x where s_usr_id = $d_quote$user_id$d_quote and s_prog_id = $d_quote$prog_id$d_quote";
  151. $r = mysql_query($q) or die(mysql_error());
  152. $found = mysql_num_rows($r);
  153. if ($found == 0) { //Houston, we have a problem
  154. echo '<center><font size="+2">Access Forbidden!</font></center>';
  155. echo "<center><font size='+2'>User $PHP_AUTH_USER does not have access to $cgi</font></center>";
  156. exit;
  157. } else {
  158. $row = mysql_fetch_array($r);
  159. $usr_access = $row["usr_access"];
  160. }
  161. }
  162. }
  163. // end of expermental code
  164. //-------------------
  165. */
  166. function SendEmail($comment, $bio_table, $detail_table, $email_table)
  167. {
  168. $content = "The following is an automated message from the Commercial Pediatric Vaccine Tracker.\r\nPlease do not respond via email reply because the reply mail box is bogus.\r\n\r\nMessage: %%message%%\r\n\r\n";
  169. $from_string_addr = "From: Commercial Vaccine Tracker\r\n" ."Reply-To: webmaster@asthmaandallergy.com\r\n" ."X-Mailer: PHP/" . phpversion();
  170. $q = "select * from $bio_table order by name";
  171. $r = mysql_query($q) or die(mysql_error());
  172. $message = "The following is a listing of the existing Commercial Pediatric Vaccine Inventory\n";
  173. if (mysql_num_rows($r) > 0) {
  174. while ($row = mysql_fetch_array($r)) {
  175. $bio_id = $row["id"];
  176. $name = $row["name"];
  177. $q2 = "select count(*) as mycount from $detail_table where biological_id = '$bio_id' and consumed_ynd = 'N'";
  178. $r2 = mysql_query($q2) or die(mysql_error());
  179. $row2 = mysql_fetch_array($r2);
  180. $mycount = $row2["mycount"];
  181. if ($mycount > 0) {
  182. $message = $message . "$mycount - $name\n";
  183. }
  184. }
  185. } else {
  186. $message = $message . "No Stock to report for the Commercial Pediatric Vaccine Inventory";
  187. }
  188. $q = "select * from $bio_table order by name";
  189. $r = mysql_query($q) or die(mysql_error());
  190. $message = $message . "\n\nThe following is a listing of the existing State Pediatric Vaccine Inventory\n";
  191. if (mysql_num_rows($r) > 0) {
  192. while ($row = mysql_fetch_array($r)) {
  193. $bio_id = $row["id"];
  194. $name = $row["name"];
  195. $q2 = "select count(*) as mycount from $detail_table where biological_id = '$bio_id' and consumed_ynd = 'N'";
  196. $r2 = mysql_query($q2) or die(mysql_error());
  197. $row2 = mysql_fetch_array($r2);
  198. $mycount = $row2["mycount"];
  199. if ($mycount > 0) {
  200. $message = $message . "$mycount - $name\n";
  201. }
  202. }
  203. $content = str_replace("%%message%%", $message, $content);
  204. } else {
  205. $message = $message . "No Stock to report for the State Pediatric Vaccine Inventory";
  206. }
  207. // $content = $comment . "\n" . $content;
  208. $q = "select * from $email_table where active_yn = 'Y'";
  209. $r = mysql_query($q) or die(mysql_error());
  210. $content = $comment . "\n" . $content;
  211. while ($row = mysql_fetch_array($r)) {
  212. $to = $row["addr"];
  213. mail($to, "Automated Phone Message", $content, $from_string_addr);
  214. // mail($to, "$comment", $content, $from_string_addr);
  215. // echo "<br><center>Message has been sent to $to</center><br>";
  216. }
  217. } // end SendEmail
  218. //-------------------
  219. function ValadateInput($txt, $type, $comment)
  220. {
  221. // send text and a type and get back an error comment
  222. // if the error comment is empty, then it is ok
  223. $retval = "";
  224. switch ($type) {
  225. case "sname";
  226. $retval = "";
  227. if (strlen($txt) < 2) {
  228. $retval = "$comment '$txt' is too short<BR>\nMust be at least 2 characters long<br>\n";
  229. }
  230. break;
  231. case "name";
  232. $retval = "";
  233. if (strlen($txt) < 3) {
  234. $retval = "$comment '$txt' is too short<BR>\nMust be at least 3 characters long<br>\n";
  235. }
  236. break;
  237. case "date":
  238. $err_date = "Invalid date format for $comment: <BR>Cannot determine '$txt' as being a valid date<BR>";
  239. $retval = "";
  240. if (ereg ("([0-9]{1,2})/([0-9]{1,2})/([0-9]{2,4})", $txt, $regs)) {
  241. $mymonth = $regs[1];
  242. $mydate = $regs[2];
  243. $myyear = $regs[3];
  244. settype($mymonth, "integer");
  245. settype($mydate, "integer");
  246. settype($myyear, "integer");
  247. if ($myyear < 1 or $myyear > 2071) {
  248. $retval .= "<CENTER>$err_date The year is in question<br></CENTER><BR>";
  249. } else {
  250. if (($mymonth < 1) or ($mymonth > 12)) $retval .= "<CENTER>$err_date Month should be between 1 and 12<br></CENTER><BR>";
  251. if ($mydate < 1 or $mydate > 31) {
  252. $retval .= "<CENTER>$err_date No month has more than 31 days or less than 1 day<br></CENTER><BR>";
  253. } else {
  254. if ($mymonth == 4 or $mymonth == 6 or $mymonth == 9 or $mymonth == 11) {
  255. if ($mydate == 31) $retval .= "<CENTER>$err_date Only 30 days in this month (month #$mymonth)<BR></CENTER><BR>";
  256. }
  257. if ($mymonth == 2) {
  258. if ($mydate > 29) $retval .= "<CENTER>$err_date There can never be more than 29 days in ANY Febuary<br></CENTER><BR>";
  259. if ($mydate == 29 and $myyear % 4 > 0) $retval .= "<CENTER>$err_date Only 28 days in THIS Febuary<br></CENTER><BR>";
  260. }
  261. }
  262. }
  263. } else {
  264. $retval .= "<center>$err_date Try using the MM/DD/YYYY format<BR></CENTER><BR>";
  265. }
  266. break;
  267. case "email":
  268. $at_loc = strpos($txt, "@");
  269. $email_exp = "^[a-z0-9\._-]+@[a-z0-9\._-]+\.+[a-z]{2,3}$";
  270. if ($at_loc < 2) {
  271. $retval .= "Please check the prefix and @ sign<br>\n";
  272. }
  273. $firstdot = strpos($txt, ".");
  274. $afterdot = substr($txt, $firstdot + 1);
  275. if ($firstdot < 1) {
  276. $retval .= "Please check the suffix for accuracy.<br>\n";
  277. $retval .= "(It should include a .com,.net,.org,.gov,.mil, or other)<br>\n";
  278. // 3/26/2003 jbt
  279. // Found email address with a dot prior to the @ ie john.trombly@goofy.org
  280. // making sure that there is a . after the @ and not allowing more than 2 dots prior to the @
  281. } else {
  282. if ($at_loc > $firstdot + strpos($afterdot, ".")) {
  283. $retval .= "Max of one dot prior to the @ sign<br>and<br>must have a dot after the @ sign<br>\n";
  284. }
  285. }
  286. if (!eregi($email_exp, $txt)) {
  287. $retval .= "Check Email address again for valid form";
  288. }
  289. if (strlen($retval) > 0) {
  290. $retval = "<center>Sorry. This $comment '$txt' seems wrong.<br>\n" . $retval . "</center><br>\n";
  291. }
  292. break;
  293. case "num":
  294. if (strlen($txt) < 1) {
  295. $retval = "$comment is too short<BR>\nPut $comment in number format ie 999<br>\n";
  296. } else {
  297. if (!ereg("(^[0-9]{1,6})$", $txt)) {
  298. $retval = "$comment must be in this format<BR>9999<br>\n";
  299. }
  300. }
  301. if (strlen($retval) > 0) {
  302. $retval = "<center>Error in $comment ($txt).<br>\n" . $retval . "</center><br>\n";
  303. }
  304. break;
  305. case "num62":
  306. if (strlen($txt) < 1) {
  307. $retval = "$comment is too short<BR>\nPut $comment in number format ie 999.99<br>\n";
  308. } else {
  309. if (!ereg("(^[0-9]{1,3}.[0-9]{1,2})$", $txt)) {
  310. $retval = "$comment must be in this format<BR>999.99<br>\n";
  311. }
  312. }
  313. if (strlen($retval) > 0) {
  314. $retval = "<center>Error in $comment ($txt).<br>\n" . $retval . "</center><br>\n";
  315. }
  316. break;
  317. case "phone":
  318. if (strlen($txt) < 12) {
  319. $retval = "$comment is too short<BR>\nPut phone number in 999-999-9999<br>\n";
  320. } else {
  321. if (!ereg("([0-9]{3,3})-([0-9]{3,3})-([0-9]{3,3})", $txt)) {
  322. $retval = "Phone number must be in this format<BR>999-999-9999<br>\n";
  323. }
  324. }
  325. if (strlen($retval) > 0) {
  326. $retval = "<center>Error in $comment ($txt).<br>\n" . $retval . "</center><br>\n";
  327. }
  328. break;
  329. case "time":
  330. if (strlen($txt) != 5) {
  331. $retval = "<br>$comment is not 5 characters long<br>Put time string like 99:99";
  332. } else {
  333. if (!ereg("([0-2]{1,1})([0-9]{1,1}):([0-5]{1,1})([0-9]{1,1})", $txt)) {
  334. $retval = "<br><b>$comment</b> is time and must be in this format<BR>hh:mm<br>hh must be less than 30<br>mm must be less than 60<br>\n"; }
  335. }
  336. break;
  337. case "time15":
  338. if (strlen($txt) != 5) {
  339. $retval = "<br>$comment is not 5 characters long<br>Put time string like 99:99";
  340. } else {
  341. if (!ereg("([0-2]{1,1})([0-9]{1,1}):([0-5]{1,1})([0-9]{1,1})", $txt)) {
  342. $retval = "<br><b>$comment</b> is time and must be in this format<BR>hh:mm<br>hh must be less than 30<br>mm must be less than 60<br>\n";
  343. } else {
  344. // 15 min or less!
  345. if (nJbtmin($txt) > 15 ) {
  346. $retval = "<br><b>$comment</b> is more than 15 min<BR>Try a setting of 15min or less<br>\n";
  347. }
  348. }
  349. }
  350. break;
  351. case "YN":
  352. if (strlen($txt) != 1) {
  353. $retval = "<br>$comment is not 1 characters long<br>Only put Y or N";
  354. } else {
  355. if ($txt != 'Y' and $txt != 'N') {
  356. $retval = "<br>$comment can only be <b>Y</b> or <b>N</b><br>\n";
  357. }
  358. }
  359. break;
  360. default:
  361. $retval = "<center>Error<BR>Unable to data<BR>Data Type unknown</center><br>\n";
  362. break;
  363. } // end switch
  364. return $retval;
  365. } // end ValadateInput
  366. //--------
  367. function FixMyStringquote($mystring)
  368. {
  369. // *** ATTENTION ***
  370. // Special Modified version allows single quotes to pass!
  371. // Be sure that when this text is sent, double quites surround it in the SQL statement!
  372. // *** ATTENTION ***
  373. // This will remove the dangerous characters quotes and question mark
  374. $temp = $mystring;
  375. //$temp = str_replace("'", "", $mystring); // byby single quote
  376. $temp = str_replace('"', '"', $temp); // byby double quotes
  377. $temp = str_replace("?", "", $temp); // byby question mark
  378. $temp = str_replace("$", "", $temp); // byby Dollar sign (just for good measure
  379. // no HTML tags should pass so no < or >
  380. //$temp = str_replace("<", "", $temp); // byby start of HTML Tags
  381. //$temp = str_replace(">", "", $temp); // byby end of HTML Tags
  382. $mylen_now = strlen($temp);
  383. $mylen_prior = $mylen_now + 1;
  384. while ($mylen_now <> $mylen_prior) {
  385. $mylen_prior = strlen($temp);
  386. $temp = str_replace(" ", " ", $temp); // Get rid of ** ALL ** the white space!!
  387. $mylen_now = strlen($temp);
  388. }
  389. $bkslach = chr(92);
  390. $temp = str_replace($bkslach, "", $temp); // byby Backslash because this is used to signal special characters)
  391. return $temp;
  392. } // end of FixMyStringquote
  393. //--------
  394. function LinuxDate($date)
  395. {
  396. // takes a date string in MM/DD/YYYY format
  397. // and returns it in YYYY-MM-DD format (for Mysql)
  398. if (ereg ("([0-9]{1,2})/([0-9]{1,2})/([0-9]{2,4})", $date, $regs)) {
  399. $retval = "$regs[3]-$regs[1]-$regs[2]";
  400. }
  401. return $retval;
  402. } //end of LinuxDate function
  403. //---------
  404. function DosDate($date)
  405. {
  406. // takes a date string in YYYY-MM-DD format
  407. // and returns it in MM/DD/YYYY format (for Regular People)
  408. if (ereg ("([0-9]{2,4})-([0-9]{1,2})-([0-9]{1,2})", $date, $regs)) {
  409. $retval = "$regs[2]/$regs[3]/$regs[1]";
  410. }
  411. return $retval;
  412. } //end of LinuxDate function
  413. //----------
  414. function FixMyString($mystring)
  415. {
  416. // *** ATTENTION ***
  417. // Special Modified version allows single quotes to pass!
  418. // Be sure that when this text is sent, double quites surround it in the SQL statement!
  419. // *** ATTENTION ***
  420. // This will remove the dangerous characters quotes and question mark
  421. $temp = $mystring;
  422. $temp = str_replace("'", "", $mystring); // byby single quote
  423. $temp = str_replace('"', "", $temp); // byby double quotes
  424. $temp = str_replace("?", "", $temp); // byby question mark
  425. $temp = str_replace("$", "", $temp); // byby Dollar sign (just for good measure
  426. $temp = str_replace("&", "", $temp); // byby AND sign (makes html crankey
  427. $temp = str_replace(",", "", $temp); // byby comma sign (makes html crankey as well
  428. // no HTML tags should pass so no < or >
  429. $temp = str_replace("<", "", $temp); // byby start of HTML Tags
  430. $temp = str_replace(">", "", $temp); // byby end of HTML Tags
  431. $mylen_now = strlen($temp);
  432. $mylen_prior = $mylen_now + 1;
  433. while ($mylen_now <> $mylen_prior) {
  434. $mylen_prior = strlen($temp);
  435. $temp = str_replace(" ", " ", $temp); // Get rid of ** ALL ** the white space!!
  436. $mylen_now = strlen($temp);
  437. }
  438. $bkslach = chr(92);
  439. $temp = str_replace($bkslach, "", $temp); // byby Backslash because this is used to signal special characters)
  440. return $temp;
  441. } // end of FixMyString
  442. function MeColorTR($count, $numCols)
  443. {
  444. // Puts in the color tag for a row (TR>
  445. // numCols is the # of Colums desired
  446. $setColor = $count % $numCols;
  447. if ($setColor == 0 ) {
  448. // Here is where we plan the color for the new Row
  449. $setColor = intval($count / $numCols);
  450. $setColor = $setColor%3;
  451. switch ($setColor) {
  452. case "0":
  453. echo "\n<tr bgcolor=#DDDDDD>";
  454. break;
  455. case "1":
  456. echo "\n<tr bgcolor=#CCCCCC>";
  457. break;
  458. case "2":
  459. echo "\n<tr bgcolor=#C0C0C0>";
  460. break;
  461. case "3":
  462. echo "\n<tr>";
  463. break;
  464. } // end switch
  465. }
  466. // increment the counter
  467. $retval = $count + 1;
  468. return $retval;
  469. } // end of MeColorTR
  470. function format_time($time)
  471. {
  472. $retval = $time["hours"];
  473. if (strlen(trim($retval)) < 2) $ret_val = "0" . $retvalue;
  474. if (strlen(trim($time["minutes"])) < 2) {
  475. $retval = $retval . ":0" . $time["minutes"];
  476. } else {
  477. $retval = $retval . ":" . $time["minutes"];
  478. }
  479. $retval = str_pad($retval,5,"0",STR_PAD_LEFT);
  480. return $retval;
  481. } // end of format_time
  482. function mybanner($string, $ding,$user_name)
  483. {
  484. // default banner for this program
  485. // in mybanner change the backgrounds pvaccine.php and pvaccine_state.php
  486. // use the top one for Pedi Commercial vaccines ---pvaccine.php---
  487. $bk = "background='/backgrounds/pa-sw-602.jpg'";
  488. $bk = "background='/backgrounds/1.gif'";
  489. $bk = "background='/backgrounds/2.gif'";
  490. $bk = "background='/backgrounds/3.gif'";
  491. $bk = "background='/backgrounds/4.gif'";
  492. $bk = "background='/backgrounds/1a.gif'";
  493. $bk = "background='/backgrounds/bg1.png'";
  494. $bk = "background='/backgrounds/bg1a.png'";
  495. $bk = "background='/backgrounds/bg1c.png'";
  496. // public_html
  497. // pa-sw-602.jpg
  498. $myheadder = "== VTRACNOW ==<br>Vaccine Tracker";
  499. // use the next one for Pedi State vaccines ---pvaccine_state.php--
  500. // $bk = "background='/backgrounds/comp010.jpg'";
  501. // $myheadder = "State Pediatric Vaccine Tracker";
  502. // use the top one for Pedi Commercial vaccines
  503. echo '<!doctype html public "-//w3c//dtd html 3.2//en">' . "\n";
  504. echo "<html>\n";
  505. echo "<head>\n";
  506. // echo "<title>$myheadder</title>\n";
  507. echo "</head>\n";
  508. switch ($ding) {
  509. case "yes":
  510. echo '<body bgcolor="#ffffff"' . $bk . ' text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000"><bgsound src="cashregister.wav" loop="1">';
  511. break;
  512. case "foghorn":
  513. echo '<body bgcolor="#ffffff"' . $bk . ' text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000"><bgsound src="foghorn.wav" loop="1">';
  514. break;
  515. case "tadah":
  516. echo '<body bgcolor="#ffffff"' . $bk . ' text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000"><bgsound src="chimeup.wav" loop="1">';
  517. break;
  518. case "order":
  519. echo '<body bgcolor="#ffffff"' . $bk . ' text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000"><bgsound src="order.wav" loop="1">';
  520. break;
  521. default :
  522. echo '<body bgcolor="#ffffff"' . $bk . ' text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">';
  523. break;
  524. }
  525. echo "<center><font size='+2'><b>$myheadder Administration</b></font></center><br>\n";
  526. echo "<center>Maintain Inventory<br><font size='+2'><b>User: $user_name</b></font></center>" . "\n";
  527. echo "<center><b><font size='+2'>== $string ==</font></b></center>\n";
  528. echo '<center>===================</center>' . "\n";
  529. $mydate = getdate(time());
  530. echo "<center><b>" . $mydate["month"] . " " . $mydate["mday"] . ", " .$mydate["year"] . "</b></center><br>\n";
  531. // No Back Button!!!!!
  532. echo "<script>\n";
  533. echo "history.forward();\n";
  534. echo "</script>\n";
  535. } // end of mybanner
  536. function NavBar($cgi, $act, $usr_access)
  537. {
  538. // Displays links for navigation in this program
  539. $d_quote = chr(34);
  540. echo "<center><table width='80%' border='1' cellspacing='0' cellpadding='4'>\n";
  541. if ($usr_access > 50) {
  542. echo "<tr><td colspan='5'><center>== Main Navigation Controls $usr_access ==</center></td></tr>\n";
  543. $width = "20%";
  544. } else {
  545. echo "<tr><td colspan='4'><center>== Main Navigation Controls $usr_access ==</center></td></tr>\n";
  546. $width = "25%";
  547. }
  548. echo "<td width='$width'><center><a href='$cgi?act=menu'>List or Add Vaccine</a></center></td>\n";
  549. echo "<td width='$width'><center><a href='$cgi?act=vaccine_list'>List On-Hand</a></center></td>\n";
  550. echo "<td width='$width'><center><a href='$cgi?act=date_report'>Report by Date Range</a></center></td>\n";
  551. echo "<td width='$width'><center><a href='$cgi?act=lot_grid'>Lot Number Grid</a></center></td>\n";
  552. if ($usr_access > 50) {
  553. // echo "<td width='$width'><center><a href='$cgi?act=trash'>Remove Consume/Destroy History</a></center></td>\n";
  554. }
  555. // echo "<td width='25%'><center><a href='$cgi?act=income'>Incoming</a></center></td></tr>\n";
  556. echo "</table></center>\n";
  557. if ($usr_access > 50) {
  558. echo "<br><br><center><table width='60%' border='1' cellspacing='0' cellpadding='4'>\n";
  559. echo "<tr><td><center><a href='$cgi?act=dumpxl'>Dump All Records to Spreadsheet</a></center></td>";
  560. echo "<td><center><a href='$cgi?act=dumptxt'>Dump All Records to Text</a></center></td>";
  561. echo "</tr></table></center>";
  562. }
  563. /*
  564. $q = "select count(id) from counter where
  565. act = $d_quote$act$d_quote and cgi = $d_quote$cgi$d_quote";
  566. //echo "$q<br>";
  567. $r = mysql_query($q) or die(mysql_error());
  568. $found = mysql_result($r, 0, 0);
  569. if ($found > 0) { // We have a counter
  570. $q = "select id, count from counter where act = $d_quote$act$d_quote and cgi = $d_quote$cgi$d_quote";
  571. $r = mysql_query($q) or die(mysql_error());
  572. $row = mysql_fetch_array($r);
  573. $myid = $row["id"];
  574. $mycount = $row["count"];
  575. ++$mycount;
  576. $q = "update counter set count = $d_quote$mycount$d_quote where id = $d_quote$myid$d_quote";
  577. $r = mysql_query($q) or die(mysql_error());
  578. } else {
  579. $mycount = 1;
  580. $q = "insert into counter set act = $d_quote$act$d_quote, cgi = $d_quote$cgi$d_quote, count = $d_quote$mycount$d_quote";
  581. $r = mysql_query($q) or die(mysql_error());
  582. }
  583. echo '<br><CENTER><A HREF="http://gnatbox/ccaac/index.php">Main page</A></CENTER>' . "\n";
  584. // now we have the digits to worry about. note that the text version is commented out
  585. $dig_array = array("bluesky", "curly", "default", "embwhite", "led", "led_g",
  586. "led_r", "links", "odometer", "plain_b", "pumpkin", "xmas");
  587. $dig_dir = "/images/digits/" . $dig_array[rand() % 11] . "/";
  588. $tempString = $mycount;
  589. $end = strlen($tempString);
  590. echo "<br><center>";
  591. //lets get the characters!
  592. for ($i = 0; $i < $end; $i++) {
  593. echo "<img src='";
  594. echo $dig_dir . substr($tempString,$i,1) . ".gif'>";
  595. }
  596. echo "</center>";
  597. echo '<H1 align=right><IMG SRC="/images/php-small-white.gif" ALT="Powered by PHP!"></H1>' . "\n";
  598. echo "</body></html>";
  599. */
  600. } // end of NavBar
  601. function My_Lister($bio_name, $q, $type)
  602. {
  603. // $type consumed
  604. $r = mysql_query($q) or die(mysql_error());
  605. $max = mysql_num_rows($r);
  606. // echo "<br>$q<br>";
  607. if ($max > 0) {
  608. // echo "<hr width='45%' align=center>";
  609. echo "<center><table width='95%' border='1' cellspacing='0' cellpadding='4'>\n";
  610. echo "<tr bgcolor=#ffffff><td colspan=7><center>$max records found</center></td></tr>";
  611. if ($type == "received") {
  612. echo "<tr bgcolor=#ffffff><td>Lot #</td><td>Exp Date</td>
  613. <td>Recorded Reveived by</td><td>Date</td><td>Time</td><td>Computer</td><td>Note</td>
  614. </tr>";
  615. } else {
  616. if ($type == "destroyed") {
  617. echo "<tr bgcolor=#ffffff><td>Lot #</td><td>Exp Date</td>
  618. <td>Recorded Destroyed by</td><td>Date</td><td>Time</td><td>Computer</td><td>Note</td>
  619. </tr>";
  620. } else {
  621. echo "<tr bgcolor=#ffffff><td>Lot #</td><td>Exp Date</td>
  622. <td>Recorded Consumed by</td><td>Date</td><td>Time</td><td>Computer</td><td>Note</td>
  623. </tr>";
  624. }
  625. }
  626. $color = 0;
  627. while ($row = mysql_fetch_array($r)) {
  628. $color = MeColorTR($color, 1);
  629. $lot_num = $row["lot_num"];
  630. $exp_date = DosDate($row["exp_date"]);
  631. $c_name = $row["c_name"];
  632. $c_date = DosDate($row["c_date"]);
  633. // $c_time = str_pad($row["c_time"],5,"0",STR_PAD_LEFT);
  634. $c_time = $row["c_time"];
  635. $c_ip = $row["c_ip"];
  636. $r_name = $row["r_name"];
  637. $r_date = DosDate($row["r_date"]);
  638. // $r_time = str_pad($row["r_time"],5,"0",STR_PAD_LEFT);
  639. $r_time = $row["r_time"];
  640. $r_ip = $row["r_ip"];
  641. $bio_id = $row["bio_id"];
  642. $det_id = $row["det_id"];
  643. $note = $row["note"];
  644. if (strlen($note) < 1) $note = "--";
  645. //$computer = $row["computer"];
  646. if ($type == "received") {
  647. echo "<td>$lot_num</td><td>$exp_date</td><td>$r_name</td>
  648. <td>$r_date</td><td>$r_time</td><td>$r_ip</td><td>$note</td>";
  649. echo "</tr>\n";
  650. } else {
  651. echo "<td>$lot_num</td><td>$exp_date</td><td>$c_name</td>
  652. <td>$c_date</td><td>$c_time</td><td>$c_ip</td><td>$note</td>";
  653. echo "</tr>\n";
  654. }
  655. }
  656. echo "</table></center><br><br>\n";
  657. } else {
  658. echo "<center><font size='+2'><br><font color=#ff0000>ERROR</font><br>There are no consumed $bio_name</font></center><br><br>";
  659. }
  660. // echo "<br><br><center>Done by My_Lister</center><br>";
  661. } // end of My_Lister
  662. function Full_Lister($bio_name, $q)
  663. {
  664. // $type consumed
  665. $r = mysql_query($q) or die(mysql_error());
  666. $max = mysql_num_rows($r);
  667. if ($max > 0) {
  668. // echo "<hr width='45%' align=center>";
  669. echo "<center><table width='95%' border='1' cellspacing='0' cellpadding='4'>\n";
  670. echo "<tr bgcolor=#ffffff><td colspan=12><center>$max records found</center></td></tr>";
  671. echo "<tr bgcolor=#ffffff>
  672. <td>Consumed Destroyed or Received</td>
  673. <td>Lot #</td><td>Exp Date</td>
  674. <td>Recorded Reveived by</td><td>Date</td><td>Time</td><td>Computer</td>
  675. <td>Recorded Consumed or Destroyed by</td><td>Date</td><td>Time</td><td>Computer</td>
  676. <td>Note</td>
  677. </tr>";
  678. $color = 0;
  679. while ($row = mysql_fetch_array($r)) {
  680. $color = MeColorTR($color, 1);
  681. $lot_num = $row["lot_num"];
  682. $exp_date = DosDate($row["exp_date"]);
  683. $r_name = $row["r_name"];
  684. $r_date = DosDate($row["r_date"]);
  685. $r_time = str_pad($row["r_time"],5,"0",STR_PAD_LEFT);
  686. $r_ip = $row["r_ip"];
  687. $c_name = $row["c_name"];
  688. if (strlen(trim($c_name)) < 1) $c_name = "--";
  689. $c_date = DosDate($row["c_date"]);
  690. if ($c_date == "00/00/0000") $c_date = "--";
  691. $c_time = str_pad($row["c_time"],5,"0",STR_PAD_LEFT);
  692. if ($c_time == "00000") $c_time = "--";
  693. $c_ip = $row["c_ip"];
  694. if (strlen(trim($c_ip)) < 1) $c_ip = "--";
  695. $bio_id = $row["bio_id"];
  696. $det_id = $row["det_id"];
  697. $ynd = $row["consumed_ynd"];
  698. if ($ynd == "Y") $ynd = "Consumed";
  699. if ($ynd == "N") $ynd = "Received";
  700. if ($ynd == "D") $ynd = "Destroyed";
  701. $note = $row["note"];
  702. if (strlen($note) < 1) $note = "--";
  703. //$computer = $row["computer"];
  704. echo "<td>$ynd</td><td>$lot_num</td><td>$exp_date</td>
  705. <td>$r_name</td><td>$r_date</td><td>$r_time</td><td>$r_ip</td>
  706. <td>$c_name</td><td>$c_date</td><td>$c_time</td>";
  707. if ($c_ip == "--") {
  708. echo "<td>$c_ip</td>";
  709. } else {
  710. echo "<td>$c_ip</td>";
  711. }
  712. echo "<td>$note</td>";
  713. echo "</tr>\n";
  714. }
  715. echo "</table></center><br><br>\n";
  716. } else {
  717. echo "<center><font size='+2'><br><font color=#ff0000>ERROR</font><br>There are no consumed $bio_name</font></center><br><br>";
  718. }
  719. // echo "<br><br><center>Done by Full_Lister</center><br>";
  720. } // end of Full_Lister
  721. function My_xls_dump($q)
  722. {
  723. $r = mysql_query($q) or die(mysql_error());
  724. echo "<table>";
  725. echo "<tr><td>Vaccine</td><td>Man</td><td>Consumed Destroyed or Received</td>
  726. <td>Lot #</td><td>Exp Date</td>
  727. <td>Recorded Reveived by</td><td>Date</td><td>Time</td><td>Computer</td>
  728. <td>Recorded Consumed or Destroyed by</td><td>Date</td><td>Time</td><td>Computer</td>
  729. <td>Notes</td></tr>";
  730. while ($row = mysql_fetch_array($r)) {
  731. $vac_name = $row["bio_name"];
  732. $man_name = $row["man_name"];
  733. $lot_num = $row["lot_num"];
  734. $exp_date = DosDate($row["exp_date"]);
  735. $r_name = $row["r_name"];
  736. $r_date = DosDate($row["r_date"]);
  737. $r_time = str_pad($row["r_time"],5,"0",STR_PAD_LEFT);
  738. $r_ip = $row["r_ip"];
  739. $c_name = $row["c_name"];
  740. if (strlen(trim($c_name)) < 1) $c_name = "--";
  741. $c_date = DosDate($row["c_date"]);
  742. if ($c_date == "00/00/0000") $c_date = "--";
  743. $c_time = str_pad($row["c_time"],5,"0",STR_PAD_LEFT);
  744. if ($c_time == "00000") $c_time = "--";
  745. $c_ip = $row["c_ip"];
  746. if (strlen(trim($c_ip)) < 1) $c_ip = "--";
  747. $bio_id = $row["bio_id"];
  748. $det_id = $row["det_id"];
  749. $ynd = $row["consumed_ynd"];
  750. if ($ynd == "Y") $ynd = "Consumed";
  751. if ($ynd == "N") $ynd = "Received";
  752. if ($ynd == "D") $ynd = "Destroyed";
  753. $note = $row["note"];
  754. if (strlen($note) < 1) $note = "--";
  755. //$computer = $row["computer"];
  756. echo "<td>$vac_name</td><td>$man_name</td><td>$ynd</td><td>$lot_num</td><td>$exp_date</td>
  757. <td>$r_name</td><td>$r_date</td><td>$r_time</td><td>$r_ip</td>
  758. <td>$c_name</td><td>$c_date</td><td>$c_time</td>";
  759. echo "<td>$c_ip</td>";
  760. echo "<td>$note</td>";
  761. echo "</tr>\n";
  762. }
  763. echo "</table>";
  764. } // end of My_xls_dump
  765. function My_txt_dump($q)
  766. {
  767. $crlf = chr(13) . chr(10);
  768. $d_quote = chr(34);
  769. $tab = chr(9);
  770. $r = mysql_query($q) or die(mysql_error());
  771. echo str_pad("Vaccine",32) . $tab;
  772. echo str_pad("Man",32) . $tab;
  773. echo str_pad("Consumed Destroyed or Received",31) . $tab;
  774. echo str_pad("Lot #",80) . $tab;
  775. echo str_pad("Exp Date",10) . $tab;
  776. echo str_pad("Recorded Reveived by", 30) . $tab;
  777. echo str_pad("Date", 10) . $tab;
  778. echo str_pad("Time", 5) . $tab;
  779. echo str_pad("Computer IP", 15) . $tab;
  780. echo str_pad("Recorded Consumed or Destroyed by", 30) . $tab;
  781. echo str_pad("Date", 10) . $tab;
  782. echo str_pad("Time", 5) . $tab;
  783. echo str_pad("Computer IP", 15) . $tab;
  784. echo str_pad("Comment", 132) . $tab;
  785. echo $crlf;
  786. while ($row = mysql_fetch_array($r)) {
  787. $vac_name = $row["bio_name"];
  788. $man_name = $row["man_name"];
  789. $lot_num = $row["lot_num"];
  790. $exp_date = DosDate($row["exp_date"]);
  791. $r_name = $row["r_name"];
  792. $r_date = DosDate($row["r_date"]);
  793. $r_time = str_pad($row["r_time"],5,"0",STR_PAD_LEFT);
  794. $r_ip = $row["r_ip"];
  795. $c_name = $row["c_name"];
  796. if (strlen(trim($c_name)) < 1) $c_name = "--";
  797. $c_date = DosDate($row["c_date"]);
  798. if ($c_date == "00/00/0000") $c_date = "--";
  799. $c_time = str_pad($row["c_time"],5,"0",STR_PAD_LEFT);
  800. if ($c_time == "00000") $c_time = "--";
  801. $c_ip = $row["c_ip"];
  802. if (strlen(trim($c_ip)) < 1) $c_ip = "--";
  803. $bio_id = $row["bio_id"];
  804. $det_id = $row["det_id"];
  805. $ynd = $row["consumed_ynd"];
  806. if ($ynd == "Y") $ynd = "Consumed";
  807. if ($ynd == "N") $ynd = "Received";
  808. if ($ynd == "D") $ynd = "Destroyed";
  809. $note = $row["note"];
  810. if (strlen($note) < 1) $note = "--";
  811. //$computer = $row["computer"];
  812. echo str_pad($vac_name,32) . $tab;
  813. echo str_pad($man_name,32) . $tab;
  814. echo str_pad($ynd,31) . $tab;
  815. echo str_pad($lot_num,80) . $tab;
  816. echo str_pad($exp_date,10) . $tab;
  817. echo str_pad($r_name, 30) . $tab;
  818. echo str_pad($r_date, 10) . $tab;
  819. echo str_pad($r_time, 5) . $tab;
  820. echo str_pad($r_ip, 15) . $tab;
  821. echo str_pad($c_name, 30) . $tab;
  822. echo str_pad($c_date, 10) . $tab;
  823. echo str_pad($c_time, 5) . $tab;
  824. echo str_pad($c_ip, 15) . $tab;
  825. echo str_pad($note, 132) . $tab;
  826. echo $crlf;
  827. }
  828. } // end of My_txt_dump
  829. // ---------------- End of Functions
  830. // ---------------
  831. // ---------------
  832. // ---------------- Start of Code
  833. $mydbf = "vaccine";
  834. mysql_select_db("$mydbf") or die("unable to access database");
  835. $red = "<font color='#FF0000'>";
  836. $pink = "<font color='#FF00FF'>";
  837. $orange = "<font color='FF8040'>";
  838. $yellow = "<font color='#FFFF00'>";
  839. $black = "<font color='#000000'>";
  840. $green = "<font color='#00FF00'>";
  841. //$green = $pink;
  842. $colorsafe = 60;
  843. $colorwarn = 30;
  844. if ($act == "") {
  845. // echo "act was blank!!<br>";
  846. $act = "menu";
  847. }
  848. //$act="menu";
  849. if ($act == "Please Change Me") {
  850. print ("<center><b><font size='+2'>*** ERROR ***</font></b></center>");
  851. print ("<center><b><font size='+2'>This page <u>MUST</u> be called from a menu</font></b></center>");
  852. }
  853. else
  854. {
  855. if ($act == "menu") $act = "mix";
  856. switch ($act) {
  857. case "menu":
  858. // Main menu
  859. // force to mix
  860. mybanner("Main Menu", "none", $user_name);
  861. NavBar($cgi, $act, $usr_access);
  862. break;
  863. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  864. // MemoChange
  865. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  866. case "memo_change":
  867. // Edit/Show memo
  868. mybanner("Notes for Vaccine $name", "none", $user_name);
  869. if ($usr_access > 50) {
  870. $state_memo = FixMyString($mynotes);
  871. $q = "update $bio_table set comm_memo = $d_quote$state_memo$d_quote where id = $d_quote$bio_id$d_quote";
  872. $r = mysql_query($q) or die(mysql_error());
  873. echo "<br><center>Memo has been changed</center><br><br>";
  874. } else {
  875. echo "<br><br><center>You are not allowed access!</center>";
  876. }
  877. echo "<br><br>";
  878. NavBar($cgi, $act, $usr_access);
  879. break;
  880. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  881. // My Memo
  882. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  883. case "my_memo":
  884. // Edit/Show memo
  885. mybanner("Notes for Vaccine $name", "none", $user_name);
  886. if ($usr_access > 50) {
  887. $q = "select * from $bio_table where id = $d_quote$bio_id$d_quote";
  888. $r = mysql_query($q) or die(mysql_error());
  889. $row = mysql_fetch_array($r);
  890. $name = $row["name"];
  891. $state_memo = $row["state_memo"];
  892. $comm_memo = $row["comm_memo"];
  893. echo "<br><center><font size='+2'>Edit Vaccine Memo for<br>$name</font></center><br>\n";
  894. echo "<br><br>";
  895. echo "<center><form action='$cgi' method='post'>\n";
  896. echo "<input type='hidden' name='act' value='memo_change'>\n";
  897. echo "<input type='hidden' name='bio_id' value='$bio_id'>\n";
  898. echo "<textarea name='mynotes' rows='6' cols='75'>\n";
  899. echo "$comm_memo";
  900. echo "</textarea>\n";
  901. echo "<br><br><center><input type='submit' value='Change'>\n";
  902. echo "<input type='reset' value='Undo'></form></center>\n";
  903. } else {
  904. echo "<br><br><center>You are not allowed access!</center>";
  905. }
  906. echo "<br><br>";
  907. NavBar($cgi, $act, $usr_access);
  908. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  909. // mix * ok
  910. // Main Menu
  911. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  912. case "mix":
  913. // Select injectable
  914. mybanner("Vaccine Selection", "none", $user_name);
  915. echo "<br><center><font size='+2'>Select Vaccine to List</font></center><br>\n";
  916. // passed NADA
  917. $q = "select * from $bio_table order by name";
  918. $r = mysql_query($q) or die(mysql_error());
  919. if (mysql_num_rows($r) > 0) {
  920. echo "<center><table width='75%' border='1' cellspacing='0' cellpadding='4'>\n";
  921. echo "<tr><td><center>Name</center></td>";
  922. echo "<td colspan = '3'><center>State<br>In Stock | Consumed | Destroyed</center></td>
  923. <td colspan = '3'><center>Commercial<br>In Stock | Consumed | Destroyed</center></td>
  924. </tr>\n";
  925. $color = 0;
  926. while ($row = mysql_fetch_array($r)) {
  927. $form_txt = "<form action='$cgi' method='post'>
  928. <input type='hidden' name='act' value='%%var1%%'>
  929. <input type='hidden' name='bio_id' value='%%bio_id%%'>
  930. <input type='hidden' name='stock_type' value='%%stock_type%%'>
  931. <input type='submit' value=%%value%%>
  932. </form>";
  933. $bio_id = $row["id"];
  934. $name = $row["name"];
  935. $state_memo = $row["state_memo"];
  936. $comm_memo = $row["comm_memo"];
  937. $temp = $form_txt;
  938. $temp = str_replace('%%name%%', $name, $temp);
  939. $temp = str_replace('%%bio_id%%', $bio_id, $temp);
  940. $form_txt = $temp;
  941. $q_instock_public_commercial = "select count(*) as mycount from $mytable where biological_id = '$bio_id' and consumed_ynd = 'N' and stock_type = 'P'";
  942. $q_instock_state_owned = "select count(*) as mycount from $mytable where biological_id = '$bio_id' and consumed_ynd = 'N' and stock_type = 'S'";
  943. $q_consumed_public_commercial = "select count(*) as mycount from $mytable where biological_id = '$bio_id' and consumed_ynd = 'Y' and stock_type = 'P'";
  944. $q_consumed_state_owned = "select count(*) as mycount from $mytable where biological_id = '$bio_id' and consumed_ynd = 'Y' and stock_type = 'S'";
  945. $q_deleted_public_commercial = "select count(*) as mycount from $mytable where biological_id = '$bio_id' and consumed_ynd = 'D' and stock_type = 'P'";
  946. $q_deleted_state_owned = "select count(*) as mycount from $mytable where biological_id = '$bio_id' and consumed_ynd = 'D' and stock_type = 'S'";
  947. $r_instock_public_commercial = mysql_query($q_instock_public_commercial) or die(mysql_error());
  948. $r_instock_state_owned = mysql_query($q_instock_state_owned) or die(mysql_error());
  949. $r_consumed_public_commercial = mysql_query($q_consumed_public_commercial) or die(mysql_error());
  950. $r_consumed_state_owned = mysql_query($q_consumed_state_owned) or die(mysql_error());
  951. $r_deleted_public_commercial = mysql_query($q_deleted_public_commercial) or die(mysql_error());
  952. $r_deleted_state_owned = mysql_query($q_deleted_state_owned) or die(mysql_error());
  953. $row_instock_public_commercial = mysql_fetch_array($r_instock_public_commercial);
  954. $row_instock_state_owned = mysql_fetch_array($r_instock_state_owned);
  955. $row_consumed_public_commercial = mysql_fetch_array($r_consumed_public_commercial);
  956. $row_consumed_state_owned = mysql_fetch_array($r_consumed_state_owned);
  957. $row_deleted_public_commercial = mysql_fetch_array($r_deleted_public_commercial);
  958. $row_deleted_state_owned = mysql_fetch_array($r_deleted_state_owned);
  959. $mycount_instock_public_commercial = $row_instock_public_commercial["mycount"];
  960. $mycount_instock_state_owned = $row_instock_state_owned["mycount"];
  961. $mycount_consumed_public_commercial = $row_consumed_public_commercial["mycount"];
  962. $mycount_consumed_state_owned = $row_consumed_state_owned["mycount"];
  963. $mycount_deleted_public_commercial = $row_deleted_public_commercial["mycount"];
  964. $mycount_deleted_state_owned = $row_deleted_state_owned["mycount"];
  965. $color = MeColorTR($color, 1);
  966. //echo "<td><center><a href='$cgi?act=order&bio_id=$bio_id'>$name</a><center></td>";
  967. echo "<td><center>";
  968. if ($usr_access > 50) {
  969. echo "<form action='$cgi' method='post'>";
  970. echo "<input type='hidden' name='act' value='my_memo'>";
  971. echo "<input type='hidden' name='bio_id' value='$bio_id'>";
  972. echo "<img src='info.gif' title=$d_quote$comm_memo$d_quote>&nbsp;";
  973. echo "<input type='submit' value='$name'>";
  974. echo "</form>";
  975. } else {
  976. echo "<img src='info.gif' title=$d_quote$comm_memo$d_quote>&nbsp;$name";
  977. }
  978. echo "<center></td>";
  979. // State -> In Stock | Consumed | Destroyed
  980. // State -> In Stock
  981. $temp = $form_txt; // reset form data
  982. if ($mycount_instock_state_owned > 0)
  983. {
  984. $temp = str_replace('%%var1%%', 'stock_list', $temp);
  985. $temp = str_replace('%%value%%', $mycount_instock_state_owned, $temp);
  986. $temp = str_replace('%%stock_type%%', 'S', $temp);
  987. echo "<td><center>$temp</center></td>";
  988. } else {
  989. echo "<td><center>0</center></td>";
  990. }
  991. // State -> Consumed
  992. $temp = $form_txt; // reset form data
  993. if ($mycount_consumed_state_owned > 0)
  994. {
  995. $temp = str_replace('%%var1%%', 'consumed_list', $temp);
  996. $temp = str_replace('%%value%%', $mycount_consumed_state_owned, $temp);
  997. $temp = str_replace('%%stock_type%%', 'S', $temp);
  998. echo "<td><center>$temp</center></td>";
  999. } else {
  1000. echo "<td><center>0</center></td>";
  1001. }
  1002. // State -> Destroyed
  1003. $temp = $form_txt; // reset form data
  1004. if ($mycount_deleted_state_owned > 0)
  1005. {
  1006. $temp = str_replace('%%var1%%', 'destroyed_list', $temp);
  1007. $temp = str_replace('%%value%%', $mycount_deleted_state_owned, $temp);
  1008. $temp = str_replace('%%stock_type%%', 'S', $temp);
  1009. echo "<td><center>$temp</center></td>";
  1010. } else {
  1011. echo "<td><center>0</center></td>";
  1012. }
  1013. // Commercial -> In Stock | Consumed | Destroyed
  1014. // Commercial -> In Stock
  1015. $temp = $form_txt; // reset form data
  1016. if ($mycount_instock_public_commercial > 0)
  1017. {
  1018. $temp = str_replace('%%var1%%', 'stock_list', $temp);
  1019. $temp = str_replace('%%value%%', $mycount_instock_public_commercial, $temp);
  1020. $temp = str_replace('%%stock_type%%', 'P', $temp);
  1021. echo "<td><center>$temp</center></td>";
  1022. } else {
  1023. echo "<td><center>0</center></td>";
  1024. }
  1025. // Commercial -> Consumed
  1026. $temp = $form_txt; // reset form data
  1027. if ($mycount_consumed_public_commercial > 0)
  1028. {
  1029. $temp = str_replace('%%var1%%', 'consumed_list', $temp);
  1030. $temp = str_replace('%%value%%', $mycount_consumed_public_commercial, $temp);
  1031. $temp = str_replace('%%stock_type%%', 'P', $temp);
  1032. echo "<td><center>$temp</center></td>";
  1033. } else {
  1034. echo "<td><center>0</center></td>";
  1035. }
  1036. // Commercial -> Destroyed
  1037. $temp = $form_txt; // reset form data
  1038. if ($mycount_deleted_public_commercial > 0)
  1039. {
  1040. $temp = str_replace('%%var1%%', 'destroyed_list', $temp);
  1041. $temp = str_replace('%%value%%', $mycount_deleted_public_commercial, $temp);
  1042. $temp = str_replace('%%stock_type%%', 'P', $temp);
  1043. echo "<td><center>$temp</center></td>";
  1044. } else {
  1045. echo "<td><center>0</center></td>";
  1046. }
  1047. echo "</tr>\n"; // End of Table Row
  1048. }
  1049. echo "</table></center><br><br>";
  1050. } else {
  1051. echo "<center><font size='+2'><br><font color=#ff0000>ERROR</font><br>Appears that there are no Vaccines in the Database<br>Press back and try again</font></center><br><br>";
  1052. }
  1053. echo "<center><a href='$cgi?act=stock_add'>Add new Stock</a></center><br>";
  1054. NavBar($cgi, $act, $usr_access);
  1055. break;
  1056. // end of mix
  1057. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1058. //stock & stock_list * ok but cargo not tested
  1059. // from Mix (Main Menu) selecting In Stock
  1060. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1061. case "stock_list":
  1062. // bio_name, id, and stock_type is Passed
  1063. // if cargo = destroy or cargo = consume... need to mark that entry, then do the listing again
  1064. $stock_type_desc = "Commercial";
  1065. if ($stock_type == 'S') $stock_type_desc = "State Sponsored";
  1066. mybanner("Listing of $stock_type_desc, <u>ON HAND</u> $bio_name", "none", $user_name);
  1067. // Process the Mul check out as well as the single line
  1068. $q = "select a.exp_date as exp_date, a.lot_num as lot_num, a.r_name as r_name,
  1069. a.r_date as r_date, a.r_time as r_time, a.r_ip as r_ip,
  1070. a.biological_id as bio_id, a.id as det_id, datediff( a.exp_date, now() ) as exp
  1071. from $mytable a
  1072. where a.consumed_ynd = 'N'
  1073. and a.biological_id = $d_quote$bio_id$d_quote
  1074. and stock_type = $d_quote$stock_type$d_quote
  1075. order by a.exp_date, a.lot_num";
  1076. //echo "<br>$q<br>";
  1077. $r = mysql_query($q) or die(mysql_error());
  1078. $max = mysql_num_rows($r);
  1079. if ($max > 0) {
  1080. // echo "<hr width='45%' align=center>";
  1081. echo "<center><table width='95%' border='1' cellspacing='0' cellpadding='4'>\n";
  1082. echo "<tr bgcolor=#ffffff><td colspan=9><center>$max records found</center></td></tr>";
  1083. echo "<tr bgcolor=#ffffff><td>Lot #</td><td>Exp Date</td><td>Exp in</td>
  1084. <td>Recieved by</td><td>Date</td><td>Time</td><td>Computer</td>
  1085. <td colspan=2><center>Consume | Destroy</center></td></tr>";
  1086. $color = 0;
  1087. while ($row = mysql_fetch_array($r)) {
  1088. $color = MeColorTR($color, 1);
  1089. $lot_num = $row["lot_num"];
  1090. $exp_date = DosDate($row["exp_date"]);
  1091. $exp = $row["exp"];
  1092. $colorexp = "<font color='FFFF00'>"; // Yellow
  1093. if ($exp > $colorsafe) $colorexp = $black;
  1094. if ($exp < $colorwarn) {
  1095. $colorexp = $red;
  1096. if ($exp > -1) $colorexp = $green;
  1097. }
  1098. $r_name = $row["r_name"];
  1099. $r_date = DosDate($row["r_date"]);
  1100. $r_time = str_pad($row["r_time"],5,"0",STR_PAD_LEFT);
  1101. $r_ip = $row["r_ip"];
  1102. $bio_id = $row["bio_id"];
  1103. $det_id = $row["det_id"];
  1104. //$computer = $row["computer"];
  1105. echo "<td>$lot_num</td><td>$exp_date</td>
  1106. <td>$colorexp$exp</font></td>
  1107. <td>$r_name</td><td>$r_date</td><td>$r_time</td><td>$r_ip</td>";
  1108. echo "<td><a href='$cgi?act=get_note&det_id=$det_id&bio_id=$bio_id&bio_name=$bio_name&cargo=consume'>Consume</a></td>
  1109. <td><a href='$cgi?act=get_note&det_id=$det_id&bio_id=$bio_id&bio_name=$bio_name&cargo=destroy'>Destroy</a></td>";
  1110. echo "</tr>\n";
  1111. }
  1112. echo "</table></center><br><br>\n";
  1113. if ($usr_access > 50) {
  1114. echo "<center><table width='60%' border='1' cellspacing='0' cellpadding='4'>\n";
  1115. echo "<tr>";
  1116. echo "<td><center><form action='$cgi' method='post'>\n";
  1117. echo "<input type='hidden' name='act' value='mul_dump'>\n";
  1118. echo "<input type='hidden' name='type' value='xls'>\n";
  1119. echo "<input type='hidden' name='bio_id' value='$bio_id'>\n";
  1120. echo "<input type='hidden' name='bio_name' value='$bio_name'>\n";
  1121. echo "<input type='hidden' name='consumed_ynd' value='instock'>\n";
  1122. echo "<br><input type='submit' value='Dump Selected to Spreadsheet'>\n";
  1123. echo "</form></center></td>\n";
  1124. echo "<td><center><form action='$cgi' method='post'>\n";
  1125. echo "<input type='hidden' name='act' value='mul_dump'>\n";
  1126. echo "<input type='hidden' name='type' value='txt'>\n";
  1127. echo "<input type='hidden' name='bio_id' value='$bio_id'>\n";
  1128. echo "<input type='hidden' name='bio_name' value='$bio_name'>\n";
  1129. echo "<input type='hidden' name='consumed_ynd' value='instock'>\n";
  1130. echo "<br><input type='submit' value='Dump Selected to Text'>\n";
  1131. echo "</form></center></td>\n";
  1132. echo "</tr></table></center><br><br>\n";
  1133. }
  1134. } else {
  1135. echo "<center><font size='+2'><br><font color=#ff0000>ERROR</font><br>There is no $bio_name vaccines on hand<br>Please Select a different Vaccine<br>ICN# $det_id</font></center><br><br>";
  1136. }
  1137. NavBar($cgi, $act, $usr_access);
  1138. break;
  1139. // end of stock_list
  1140. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1141. //consumed_list * ok
  1142. // From Mix (Main Menu) selecting Consumed
  1143. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1144. case "consumed_list":
  1145. // bio_name, id, $stock_type is Passed
  1146. $stock_type_desc = "Commercial";
  1147. if ($stock_type == 'S') $stock_type_desc = "State Sponsored";
  1148. mybanner("Listing of $stock_type_desc, <u>CONSUMED</u> $bio_name", "none", $user_name);
  1149. $q = "select a.exp_date as exp_date, a.lot_num as lot_num, a.c_name as c_name,
  1150. a.c_date as c_date, a.c_time as c_time, a.c_ip as c_ip,
  1151. a.biological_id as bio_id, a.id as det_id, a.note as note
  1152. from $mydbf.$mytable a
  1153. where a.consumed_ynd = 'Y'
  1154. and a.biological_id = $d_quote$bio_id$d_quote
  1155. order by a.c_date ASC, a.c_time ASC";
  1156. //echo "<br>$q<br>";
  1157. My_Lister($bio_name,

Large files files are truncated, but you can click here to view the full file