PageRenderTime 123ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 1ms

/pvaccine.php

https://github.com/johntrombly/vtracnow
PHP | 2349 lines | 1737 code | 105 blank | 507 comment | 274 complexity | b7d74c46e905bcc2c9f72658a850d40c MD5 | raw 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, $q, "consumed");
  1158. if ($usr_access > 50) {
  1159. echo "<center><table width='60%' border='1' cellspacing='0' cellpadding='4'>\n";
  1160. echo "<tr>";
  1161. echo "<td><center><form action='$cgi' method='post'>\n";
  1162. echo "<input type='hidden' name='act' value='mul_dump'>\n";
  1163. echo "<input type='hidden' name='type' value='xls'>\n";
  1164. echo "<input type='hidden' name='bio_id' value='$bio_id'>\n";
  1165. echo "<input type='hidden' name='bio_name' value='$bio_name'>\n";
  1166. echo "<input type='hidden' name='consumed_ynd' value='Y'>\n";
  1167. echo "<br><input type='submit' value='Dump Selected to Spreadsheet'>\n";
  1168. echo "</form></center></td>\n";
  1169. echo "<td><center><form action='$cgi' method='post'>\n";
  1170. echo "<input type='hidden' name='act' value='mul_dump'>\n";
  1171. echo "<input type='hidden' name='type' value='txt'>\n";
  1172. echo "<input type='hidden' name='bio_id' value='$bio_id'>\n";
  1173. echo "<input type='hidden' name='bio_name' value='$bio_name'>\n";
  1174. echo "<input type='hidden' name='consumed_ynd' value='Y'>\n";
  1175. echo "<br><input type='submit' value='Dump Selected to Text'>\n";
  1176. echo "</form></center></td>\n";
  1177. echo "</tr></table></center><br><br>\n";
  1178. }
  1179. NavBar($cgi, $act, $usr_access);
  1180. break;
  1181. // end of consumed_list
  1182. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1183. //destroyed_list * ok
  1184. // From Mix (Main Menu) selecting Destroyed
  1185. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1186. case "destroyed_list":
  1187. // bio_name, id, $stock_type is Passed
  1188. // if cargo = destroy or cargo = consume... need to mark that entry, then do the listing again
  1189. // Process the Mul check out as well as the single line
  1190. $stock_type_desc = "Commercial";
  1191. if ($stock_type == 'S') $stock_type_desc = "State Sponsored";
  1192. mybanner("Listing of $stock_type_desc, <u>DESTROYED</u> $bio_name", "none", $user_name);
  1193. $q = "select a.exp_date as exp_date, a.lot_num as lot_num, a.c_name as c_name,
  1194. a.c_date as c_date, a.c_time as c_time, a.c_ip as c_ip,
  1195. a.biological_id as bio_id, a.id as det_id, a.note as note
  1196. from $mydbf.$mytable a
  1197. where a.consumed_ynd = 'D'
  1198. and a.biological_id = $d_quote$bio_id$d_quote
  1199. order by a.c_date ASC, a.c_time ASC";
  1200. //echo "<br>$q<br>";
  1201. My_Lister($bio_name, $q, "destroyed");
  1202. if ($usr_access > 50) {
  1203. echo "<center><table width='60%' border='1' cellspacing='0' cellpadding='4'>\n";
  1204. echo "<tr>";
  1205. echo "<td><center><form action='$cgi' method='post'>\n";
  1206. echo "<input type='hidden' name='act' value='mul_dump'>\n";
  1207. echo "<input type='hidden' name='type' value='xls'>\n";
  1208. echo "<input type='hidden' name='bio_id' value='$bio_id'>\n";
  1209. echo "<input type='hidden' name='bio_name' value='$bio_name'>\n";
  1210. echo "<input type='hidden' name='consumed_ynd' value='D'>\n";
  1211. echo "<br><input type='submit' value='Dump Selected to Spreadsheet'>\n";
  1212. echo "</form></center></td>\n";
  1213. echo "<td><center><form action='$cgi' method='post'>\n";
  1214. echo "<input type='hidden' name='act' value='mul_dump'>\n";
  1215. echo "<input type='hidden' name='type' value='txt'>\n";
  1216. echo "<input type='hidden' name='bio_id' value='$bio_id'>\n";
  1217. echo "<input type='hidden' name='bio_name' value='$bio_name'>\n";
  1218. echo "<input type='hidden' name='consumed_ynd' value='D'>\n";
  1219. echo "<br><input type='submit' value='Dump Selected to Text'>\n";
  1220. echo "</form></center></td>\n";
  1221. echo "</tr></table></center><br><br>\n";
  1222. }
  1223. NavBar($cgi, $act, $usr_access);
  1224. break;
  1225. // end of Destroyed_list
  1226. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1227. // stock_validate * ok
  1228. // From Navagation selecting List on Hand
  1229. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1230. case "stock_validate":
  1231. // Passed qty, stock_type, bio_id, exp_date, lot_num, r_name
  1232. mybanner("Validate the addition of Shots to Inventory", "none", $user_name);
  1233. $qty = FixMyString($qty);
  1234. //$bio_id = FixMyString($bio_id);
  1235. $exp_date = FixMyString($exp_date);
  1236. $lot_num= FixMyString($lot_num);
  1237. $r_name = FixMyString($r_name);
  1238. $mydate = getdate(time());
  1239. //echo "<br>mydate = $mydate<br>";
  1240. $r_date = $mydate["year"] . "-" . $mydate["mon"] . "-" . $mydate["mday"];
  1241. //echo "<br>mydate = $r_date<br>";
  1242. $r_time = format_time($mydate);
  1243. // need to make sure that 9:00 becomes 09:00
  1244. // otherwise the sorts will not work
  1245. // $r_time = str_pad($r_time,5,"0",STR_PAD_LEFT);
  1246. $r_ip = $REMOTE_ADDR;
  1247. //$r_name = $PHP_AUTH_USER;
  1248. $errString = "";
  1249. $errString .= ValadateInput($qty, "num", "Quantity");
  1250. if ($qty == 0) $errString .= "<center>Quantity cannot be Zero!</center>";
  1251. $errString .= ValadateInput($exp_date, "date", "Expiration Date");
  1252. $errString .= ValadateInput($lot_num, "name", "Lot Number");
  1253. $errString .= ValadateInput($r_name, "name", "Receiver Name");
  1254. //$r_date = LinuxDate($r_date);
  1255. $exp_date = LinuxDate($exp_date);
  1256. if (strlen($errString) < 5) {
  1257. for ($i = 1; $i <= $qty; $i++)
  1258. {
  1259. $q = "insert into $mytable set
  1260. biological_id = $d_quote$bio_id$d_quote,
  1261. stock_type = $d_quote$stock_type$d_quote,
  1262. man_id = $d_quote$man_id$d_quote,
  1263. exp_date = $d_quote$exp_date$d_quote,
  1264. lot_num = $d_quote$lot_num$d_quote,
  1265. r_name = $d_quote$r_name$d_quote,
  1266. r_date = $d_quote$r_date$d_quote,
  1267. r_time = $d_quote$r_time$d_quote,
  1268. r_ip = $d_quote$r_ip$d_quote,
  1269. consumed_ynd = 'N'";
  1270. $r = mysql_query($q) or die(mysql_error());
  1271. //echo "<br>$i $q<br>";
  1272. }
  1273. $comment = "You have added $qty Shots into Inventory!";
  1274. SendEmail($comment, $bio_table, $detail_table, $email_table);
  1275. echo "<br><center><font size='+1'>$comment</font></center><br>\n";
  1276. } else {
  1277. echo "<center><font size='+2'><br><font color=#ff0000>ERROR</font><br>$errString</font><br>Press back and try again</center><br><br>";
  1278. }
  1279. NavBar($cgi, $act, $usr_access);
  1280. break;
  1281. // end of stock_validate
  1282. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1283. // Stock Add * ok
  1284. // From Main Menu - "Add New Stock"
  1285. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1286. case "stock_add":
  1287. // Add inventory to b_detail
  1288. mybanner("Add Shots to Inventory", "none", $user_name);
  1289. echo "<center><font size='+2'>You are about to add new stock to inventory</font><br></center><br><br>\n";
  1290. echo "<center><font size='+1'>Please enter the following information</font></center>\n";
  1291. echo "<hr width='25%' align=center>\n";
  1292. $mydate = getdate(time());
  1293. $r_date = $mydate["year"] . "-" . $mydate["mon"] . "-" . $mydate["mday"];
  1294. $today = $mydate["mon"] . "/" . $mydate["mday"] . "/" . $mydate["year"];
  1295. $r_time = format_time($mydate);
  1296. // $r_time = str_pad($r_time,5,"0",STR_PAD_LEFT);
  1297. $r_ip = $REMOTE_ADDR;
  1298. echo "<center><form action='$cgi' method='post'>\n";
  1299. echo "<input type='hidden' name='act' value='stock_validate'>\n";
  1300. echo "<br>Qty to add: <input type='text' name='qty' maxlength='2' size='2' value='1'><br>\n";
  1301. echo "<br>Ownership: <select name='stock_type'>\n";
  1302. echo "<option value='P'>Privately Owned</option>\n";
  1303. echo "<option value='S'>State Owned</option>\n";
  1304. echo "</select><br>\n";
  1305. echo "Vaccine: <select name='bio_id'>\n";
  1306. $q = "select * from $bio_table order by name";
  1307. $r = mysql_query($q) or die(mysql_error());
  1308. while ($row = mysql_fetch_array($r))
  1309. {
  1310. $name = $row["name"];
  1311. $id = $row["id"];
  1312. echo "<option value=$id>$name</option>\n";
  1313. }
  1314. echo "</select><br>\n\n";
  1315. echo "Manufacturer: <select name='man_id'>\n";
  1316. $q = "select * from $man_table order by name";
  1317. $r = mysql_query($q) or die(mysql_error());
  1318. while ($row = mysql_fetch_array($r))
  1319. {
  1320. $name = $row["name"];
  1321. $id = $row["id"];
  1322. echo "<option value=$id>$name</option>\n";
  1323. }
  1324. echo "</select><br>\n\n";
  1325. echo "Expiration Date: <input type='text' name='exp_date' maxlength='10' size='10' value = '$today'> (mm/dd/yyyy)<br>\n";
  1326. echo "Lot #: <input type='text' name='lot_num' maxlength='80'><br>\n";
  1327. echo "<font size='+3'><b>Who Received: $user_name</b></font><br>\n";
  1328. echo "<input type='hidden' name='r_name' value='$user_name'>\n";
  1329. echo "<br><input type='submit' value='Record new stock'>\n";
  1330. echo "</form></center>\n";
  1331. NavBar($cgi, $act, $usr_access);
  1332. break;
  1333. // end of stock_add
  1334. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1335. //vaccine_list * ok
  1336. // From Navigation "On Hand" in Module Expire
  1337. // Handles expire and consume Links
  1338. // From Navagation selecting List on Hand
  1339. // Need to make a deture for the consume and delete so a "note" can be entered.
  1340. // The "note" needs to be ran through the validation to prevent SQL injection
  1341. // Have this module accept info for Create or destroy, so it can be handled (Introduce by banner) properly
  1342. // After collection of the "note", return here for processing so they return to the expire screen
  1343. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1344. case "vaccine_list":
  1345. // if cargo = destroy or cargo = consume... need to mark that entry, then do the listing again
  1346. // mybanner("Total listing of <u>On-Hand</u> by vaccine then in order of expiration Date", "none", $PHP_AUTH_USER);
  1347. // $q = "select a.exp_date, a.lot_num, a.r_name,
  1348. // a.r_date, a.r_time, a.r_ip, b.name as bio_name,c.name as man_name,
  1349. // a.biological_id as bio_id, a.id as det_id,
  1350. // datediff( a.exp_date, now() ) as exp
  1351. // from $mydbf.$mytable a, $bio_table b, $man_table c
  1352. // where a.consumed_ynd = 'N' and b.id = a.biological_id and a.man_id = c.id
  1353. // order by bio_name, exp_date";
  1354. mybanner("Total listing of <u>On-Hand</u> in order of expiration Date", "none", $user_name);
  1355. $q = "select a.exp_date, a.lot_num, a.r_name,
  1356. a.r_date, a.r_time, a.r_ip, b.name as bio_name,c.name as man_name,
  1357. a.biological_id as bio_id, a.id as det_id,
  1358. datediff( a.exp_date, now() ) as exp
  1359. from $mydbf.$mytable a, $bio_table b, $man_table c
  1360. where a.consumed_ynd = 'N' and b.id = a.biological_id and a.man_id = c.id
  1361. order by exp_date";
  1362. //echo "<br>$q<br>";
  1363. $r = mysql_query($q) or die(mysql_error());
  1364. $max = mysql_num_rows($r);
  1365. if ($max > 0) {
  1366. // echo "<hr width='45%' align=center>";
  1367. echo "<center><table width='95%' border='1' cellspacing='0' cellpadding='4'>\n";
  1368. echo "<tr bgcolor=#ffffff><td colspan=11><center>$max records found</center></td></tr>";
  1369. echo "<tr bgcolor=#ffffff><td>Vaccine</td><td>Man</td><td>Lot #</td><td>Exp Date</td><td>Exp in</td>
  1370. <td>Received by</td><td>Date</td><td>Time</td><td>Computer</td>
  1371. <td colspan=2><center>Consume | Destroy</center></td></tr>";
  1372. $color = 0;
  1373. while ($row = mysql_fetch_array($r)) {
  1374. $color = MeColorTR($color, 1);
  1375. $lot_num = $row["lot_num"];
  1376. $exp_date = DosDate($row["exp_date"]);
  1377. $exp = $row["exp"];
  1378. $man_name = $row["man_name"];
  1379. $colorexp = "<font color='FFFF00'>"; // Yellow
  1380. if ($exp > $colorsafe) $colorexp = $black;
  1381. if ($exp < $colorwarn) {
  1382. $colorexp = $red;
  1383. if ($exp > -1) $colorexp = $green;
  1384. }
  1385. $r_name = $row["r_name"];
  1386. $r_date = DosDate($row["r_date"]);
  1387. $r_time = str_pad($row["r_time"],5,"0",STR_PAD_LEFT);
  1388. $r_ip = $row["r_ip"];
  1389. $bio_id = $row["bio_id"];
  1390. $bio_name = $row["bio_name"];
  1391. $det_id = $row["det_id"];
  1392. //$computer = $row["computer"];
  1393. echo "<td>$bio_name</td><td>$man_name</td><td>$lot_num</td><td>$exp_date</td><td>$colorexp$exp</font></td><td>$r_name</td>
  1394. <td>$r_date</td><td>$r_time</td><td>$r_ip</td>";
  1395. 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>
  1396. <td><a href='$cgi?act=get_note&det_id=$det_id&bio_id=$bio_id&bio_name=$bio_name&cargo=destroy'>Destroy</a></td>";
  1397. echo "</tr>\n";
  1398. }
  1399. echo "</table></center><br><br>\n";
  1400. if ($usr_access > 50) {
  1401. echo "<center><table width='60%' border='1' cellspacing='0' cellpadding='4'>\n";
  1402. echo "<tr>";
  1403. echo "<td><center><form action='$cgi' method='post'>\n";
  1404. echo "<input type='hidden' name='act' value='mul_dump'>\n";
  1405. echo "<input type='hidden' name='type' value='xls'>\n";
  1406. echo "<input type='hidden' name='consumed_ynd' value='instock'>\n";
  1407. echo "<br><input type='submit' value='Dump Selected to Spreadsheet'>\n";
  1408. echo "</form></center></td>\n";
  1409. echo "<td><center><form action='$cgi' method='post'>\n";
  1410. echo "<input type='hidden' name='act' value='mul_dump'>\n";
  1411. echo "<input type='hidden' name='type' value='txt'>\n";
  1412. echo "<input type='hidden' name='consumed_ynd' value='instock'>\n";
  1413. echo "<br><input type='submit' value='Dump Selected to Text'>\n";
  1414. echo "</form></center></td>\n";
  1415. echo "</tr></table></center><br><br>\n";
  1416. }
  1417. } else {
  1418. echo "<center><font size='+2'><br><font color=#ff0000>ERROR</font><br>There are no Vaccines On Hand</font></center><br><br>";
  1419. }
  1420. NavBar($cgi, $act, $usr_access);
  1421. break;
  1422. // end of vaccine_list
  1423. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1424. // Date Report
  1425. // From Navigation "Report by Date Range"
  1426. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1427. case "date_report":
  1428. // Report Usage by date/Date range
  1429. // echo "<center><font size='+2'>I as still working on this!</font><br></center><br><br>\n";
  1430. // echo "<hr width='25%' align=center>\n";
  1431. // Very carefull here. Colm says received and must include items that may be consumed or destroyed.
  1432. // For received, you must only apply the date on the received column, not just the consumed_ynd flag
  1433. $mydate = getdate(time());
  1434. $r_date = $mydate["year"] . "-" . $mydate["mon"] . "-" . $mydate["mday"];
  1435. $today = $mydate["mon"] . "/" . $mydate["mday"] . "/" . $mydate["year"];
  1436. $r_time = format_time($mydate);
  1437. // $r_time = str_pad($r_time,5,"0",STR_PAD_LEFT);
  1438. $r_ip = $REMOTE_ADDR;
  1439. $c_date = $mydate["year"] . "-" . $mydate["mon"] . "-" . $mydate["mday"];
  1440. $c_time = format_time($mydate);
  1441. // $c_time = str_pad($c_time,5,"0",STR_PAD_LEFT);
  1442. $c_ip = $REMOTE_ADDR;
  1443. if (isset($cargo))
  1444. {
  1445. if ($cargo == "got_date")
  1446. {
  1447. // Need to do a sanity check on the dates
  1448. $err_str = ValadateInput($s_date, "date", "Start Date");
  1449. $err_str = $err_str . ValadateInput($e_date, "date", "End Date");
  1450. // next need to make sure that the start date is less than the beginning date
  1451. if (strlen($err_str) > 5) {
  1452. mybanner("ERROR", "none", $user_name);
  1453. echo $err_str;
  1454. echo "<br><center><font size=+2>Try Again</font></center><br>";
  1455. } else {
  1456. mybanner("Usage Report $s_date to $e_date", "none", $user_name);
  1457. $q = "select * from $bio_table order by name";
  1458. $r = mysql_query($q) or die(mysql_error());
  1459. $s_date = LinuxDate($s_date);
  1460. $e_date = LinuxDate($e_date);
  1461. echo "<center><table width='75%' border='1' cellspacing='0' cellpadding='4'>\n";
  1462. echo "<tr><td><center>Name</center></td>";
  1463. echo "<td><center>Received</center></td>
  1464. <td><center>Consumed</center></td>
  1465. <td><center>Destroyed</center></td>
  1466. </tr>\n";
  1467. $color = 0;
  1468. $form_txt = "<form action='$cgi' method='post'>
  1469. <input type='hidden' name='act' value='%%var1%%'>
  1470. <input type='hidden' name='bio_id' value='%%bio_id%%'>
  1471. <input type='hidden' name='vac_name' value='%%name%%'>
  1472. <input type='hidden' name='s_date' value='$s_date'>
  1473. <input type='hidden' name='e_date' value='$e_date'>
  1474. <input type='submit' value=%%value%%>
  1475. </form>";
  1476. if (mysql_num_rows($r) > 0) {
  1477. while ($row = mysql_fetch_array($r)) {
  1478. $bio_id = $row["id"];
  1479. $name = $row["name"];
  1480. // $q2 = "select count(*) as mycount from $mytable where biological_id = '$bio_id' and consumed_ynd = 'N'
  1481. // and r_date >= $d_quote$s_date$d_quote and r_date <= $d_quote$e_date$d_quote";
  1482. $q2 = "select count(*) as mycount from $mytable where biological_id = '$bio_id'
  1483. and r_date >= $d_quote$s_date$d_quote and r_date <= $d_quote$e_date$d_quote";
  1484. $qy = "select count(*) as mycount from $mytable where biological_id = '$bio_id' and consumed_ynd = 'Y'
  1485. and c_date >= $d_quote$s_date$d_quote and c_date <= $d_quote$e_date$d_quote";
  1486. $qd = "select count(*) as mycount from $mytable where biological_id = '$bio_id' and consumed_ynd = 'D'
  1487. and c_date >= $d_quote$s_date$d_quote and c_date <= $d_quote$e_date$d_quote";
  1488. $r2 = mysql_query($q2) or die(mysql_error());
  1489. $ry = mysql_query($qy) or die(mysql_error());
  1490. $rd = mysql_query($qd) or die(mysql_error());
  1491. $row2 = mysql_fetch_array($r2);
  1492. $rowy = mysql_fetch_array($ry);
  1493. $rowd = mysql_fetch_array($rd);
  1494. $mycount1 = $row2["mycount"];
  1495. $mycounty = $rowy["mycount"];
  1496. $mycountd = $rowd["mycount"];
  1497. $temp = $form_txt;
  1498. $color = MeColorTR($color, 1);
  1499. // Echo link for the Vaccine name
  1500. if (($mycount1 + $mycounty + $mycountd) > 0) {
  1501. $temp = str_replace('%%var1%%', 'date_vac_list', $temp);
  1502. $temp = str_replace('%%value%%', $name, $temp);
  1503. $temp = str_replace('%%bio_id%%', $bio_id, $temp);
  1504. $temp = str_replace('%%name%%', $name, $temp);
  1505. echo "<td><center>$temp</center></td>";
  1506. } else {
  1507. echo "<td><center>$name</center></td>";
  1508. }
  1509. $temp = $form_txt;
  1510. if ($mycount1 > 0) {
  1511. $temp = str_replace('%%var1%%', 'one_received_list', $temp);
  1512. $temp = str_replace('%%value%%', $mycount1, $temp);
  1513. $temp = str_replace('%%bio_id%%', $bio_id, $temp);
  1514. $temp = str_replace('%%name%%', $name, $temp);
  1515. echo "<td><center>$temp</center></td>";
  1516. } else {
  1517. echo "<td><center>0</center></td>";
  1518. }
  1519. $temp = $form_txt;
  1520. if ($mycounty > 0) {
  1521. $temp = str_replace('%%var1%%', 'one_consumed_list', $temp);
  1522. $temp = str_replace('%%value%%', $mycounty, $temp);
  1523. $temp = str_replace('%%bio_id%%', $bio_id, $temp);
  1524. $temp = str_replace('%%name%%', $name, $temp);
  1525. echo "<td><center>$temp</center></td>";
  1526. } else {
  1527. echo "<td><center>0</center></td>";
  1528. }
  1529. $temp = $form_txt;
  1530. if ($mycountd > 0) {
  1531. $temp = str_replace('%%var1%%', 'one_destroyed_list', $temp);
  1532. $temp = str_replace('%%value%%', $mycountd, $temp);
  1533. $temp = str_replace('%%bio_id%%', $bio_id, $temp);
  1534. $temp = str_replace('%%name%%', $name, $temp);
  1535. echo "<td><center>$temp</center></td>";
  1536. } else {
  1537. echo "<td><center>0</center></td>";
  1538. }
  1539. echo "</tr>\n";
  1540. }
  1541. echo "</table></center><br><br>";
  1542. if ($usr_access > 50) {
  1543. echo "<center><table width='60%' border='1' cellspacing='0' cellpadding='4'>\n";
  1544. echo "<tr>";
  1545. echo "<td><center><form action='$cgi' method='post'>\n";
  1546. echo "<input type='hidden' name='act' value='mul_dump'>\n";
  1547. echo "<input type='hidden' name='type' value='xls'>\n";
  1548. echo "<input type='hidden' name='s_date' value=$s_date>\n";
  1549. echo "<input type='hidden' name='e_date' value=$e_date>\n";
  1550. echo "<br><input type='submit' value='Dump Selected to Spreadsheet'>\n";
  1551. echo "</form></center></td>\n";
  1552. echo "<td><center><form action='$cgi' method='post'>\n";
  1553. echo "<input type='hidden' name='act' value='mul_dump'>\n";
  1554. echo "<input type='hidden' name='type' value='txt'>\n";
  1555. echo "<input type='hidden' name='s_date' value=$s_date>\n";
  1556. echo "<input type='hidden' name='e_date' value=$e_date>\n";
  1557. echo "<br><input type='submit' value='Dump Selected to Text'>\n";
  1558. echo "</form></center></td>\n";
  1559. echo "</tr></table></center><br><br>\n";
  1560. }
  1561. } else {
  1562. 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>";
  1563. }
  1564. }
  1565. }
  1566. } else {
  1567. mybanner("Enter Date Range for Usage Report", "none", $user_name);
  1568. echo "<center><form action='$cgi' method='post'>\n";
  1569. echo "<input type='hidden' name='act' value='date_report'>\n";
  1570. echo "<input type='hidden' name='cargo' value='got_date'>\n";
  1571. echo "Start Date: <input type='text' name='s_date' maxlength='10' size='10' value = '$today'> (mm/dd/yyyy)<br>\n";
  1572. echo "End Date: <input type='text' name='e_date' maxlength='10' size='10' value = '$today'> (mm/dd/yyyy)<br>\n";
  1573. echo "<br><input type='submit' value='Create Report'>\n";
  1574. echo "</form></center>\n";
  1575. }
  1576. NavBar($cgi, $act, $usr_access);
  1577. break;
  1578. // end of date_report
  1579. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1580. // one_received_list
  1581. // From Navigation, Report by Date Range, From Form "Received" Select button
  1582. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1583. case "one_received_list":
  1584. mybanner("Received $vac_name Vaccine from $s_date to $e_date", "none", $user_name);
  1585. // $q = "select * from $mytable where biological_id = '$bio_id' and consumed_ynd = 'N'
  1586. // and r_date >= $d_quote$s_date$d_quote and r_date <= $d_quote$e_date$d_quote
  1587. // order by r_date ASC, r_time ASC";
  1588. $q = "select * from $mytable where biological_id = '$bio_id'
  1589. and r_date >= $d_quote$s_date$d_quote and r_date <= $d_quote$e_date$d_quote
  1590. order by r_date ASC, r_time ASC";
  1591. My_Lister($vac_name, $q, "received");
  1592. // echo "<br>$q<br>";
  1593. if ($usr_access > 50) {
  1594. echo "<center><table width='60%' border='1' cellspacing='0' cellpadding='4'>\n";
  1595. echo "<tr>";
  1596. echo "<td><center><form action='$cgi' method='post'>\n";
  1597. echo "<input type='hidden' name='act' value='mul_dump'>\n";
  1598. echo "<input type='hidden' name='type' value='xls'>\n";
  1599. echo "<input type='hidden' name='s_date' value=$s_date>\n";
  1600. echo "<input type='hidden' name='e_date' value=$e_date>\n";
  1601. echo "<input type='hidden' name='bio_id' value='$bio_id'>\n";
  1602. echo "<input type='hidden' name='bio_name' value='$vac_name'>\n";
  1603. echo "<input type='hidden' name='consumed_ynd' value='N'>\n";
  1604. echo "<br><input type='submit' value='Dump Selected to Spreadsheet'>\n";
  1605. echo "</form></center></td>\n";
  1606. echo "<td><center><form action='$cgi' method='post'>\n";
  1607. echo "<input type='hidden' name='act' value='mul_dump'>\n";
  1608. echo "<input type='hidden' name='type' value='txt'>\n";
  1609. echo "<input type='hidden' name='s_date' value=$s_date>\n";
  1610. echo "<input type='hidden' name='e_date' value=$e_date>\n";
  1611. echo "<input type='hidden' name='bio_id' value='$bio_id'>\n";
  1612. echo "<input type='hidden' name='bio_name' value='$vac_name'>\n";
  1613. echo "<input type='hidden' name='consumed_ynd' value='N'>\n";
  1614. echo "<br><input type='submit' value='Dump Selected to Text'>\n";
  1615. echo "</form></center></td>\n";
  1616. echo "</tr></table></center><br><br>\n";
  1617. }
  1618. NavBar($cgi, $act, $usr_access);
  1619. break;
  1620. // end of one_received_list
  1621. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1622. // one_consumed_list
  1623. // From Navigation, Report by Date Range, From Form "Consumed" Select button
  1624. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1625. case "one_consumed_list":
  1626. mybanner("Consumed $vac_name Vaccine from $s_date to $e_date", "none", $user_name);
  1627. $q = "select * from $mytable where biological_id = '$bio_id' and consumed_ynd = 'Y'
  1628. and c_date >= $d_quote$s_date$d_quote and c_date <= $d_quote$e_date$d_quote
  1629. order by c_date ASC, c_time ASC";
  1630. My_Lister($vac_name, $q, "consumed");
  1631. // echo "<br>$q<br>";
  1632. if ($usr_access > 50) {
  1633. echo "<center><table width='60%' border='1' cellspacing='0' cellpadding='4'>\n";
  1634. echo "<tr>";
  1635. echo "<td><center><form action='$cgi' method='post'>\n";
  1636. echo "<input type='hidden' name='act' value='mul_dump'>\n";
  1637. echo "<input type='hidden' name='type' value='xls'>\n";
  1638. echo "<input type='hidden' name='s_date' value=$s_date>\n";
  1639. echo "<input type='hidden' name='e_date' value=$e_date>\n";
  1640. echo "<input type='hidden' name='bio_id' value='$bio_id'>\n";
  1641. echo "<input type='hidden' name='bio_name' value='$vac_name'>\n";
  1642. echo "<input type='hidden' name='consumed_ynd' value='Y'>\n";
  1643. echo "<br><input type='submit' value='Dump Selected to Spreadsheet'>\n";
  1644. echo "</form></center></td>\n";
  1645. echo "<td><center><form action='$cgi' method='post'>\n";
  1646. echo "<input type='hidden' name='act' value='mul_dump'>\n";
  1647. echo "<input type='hidden' name='type' value='txt'>\n";
  1648. echo "<input type='hidden' name='s_date' value=$s_date>\n";
  1649. echo "<input type='hidden' name='e_date' value=$e_date>\n";
  1650. echo "<input type='hidden' name='bio_id' value='$bio_id'>\n";
  1651. echo "<input type='hidden' name='bio_name' value='$vac_name'>\n";
  1652. echo "<input type='hidden' name='consumed_ynd' value='Y'>\n";
  1653. echo "<br><input type='submit' value='Dump Selected to Text'>\n";
  1654. echo "</form></center></td>\n";
  1655. echo "</tr></table></center><br><br>\n";
  1656. }
  1657. NavBar($cgi, $act, $usr_access);
  1658. break;
  1659. // end of one_consumed_list
  1660. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1661. // one_destroyed_list
  1662. // From Navigation, Report by Date Range, From Form "Destroyed" Select button
  1663. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1664. case "one_destroyed_list":
  1665. mybanner("Destroyed $vac_name Vaccine from $s_date to $e_date", "none", $user_name);
  1666. $q = "select * from $mytable where biological_id = '$bio_id' and consumed_ynd = 'D'
  1667. and c_date >= $d_quote$s_date$d_quote and c_date <= $d_quote$e_date$d_quote
  1668. order by c_date ASC, c_time ASC";
  1669. My_Lister($vac_name, $q, "destroyed");
  1670. // echo "<br>$q<br>";
  1671. if ($usr_access > 50) {
  1672. echo "<center><table width='60%' border='1' cellspacing='0' cellpadding='4'>\n";
  1673. echo "<tr>";
  1674. echo "<td><center><form action='$cgi' method='post'>\n";
  1675. echo "<input type='hidden' name='act' value='mul_dump'>\n";
  1676. echo "<input type='hidden' name='type' value='xls'>\n";
  1677. echo "<input type='hidden' name='s_date' value=$s_date>\n";
  1678. echo "<input type='hidden' name='e_date' value=$e_date>\n";
  1679. echo "<input type='hidden' name='bio_id' value='$bio_id'>\n";
  1680. echo "<input type='hidden' name='bio_name' value='$vac_name'>\n";
  1681. echo "<input type='hidden' name='consumed_ynd' value='D'>\n";
  1682. echo "<br><input type='submit' value='Dump Selected to Spreadsheet'>\n";
  1683. echo "</form></center></td>\n";
  1684. echo "<td><center><form action='$cgi' method='post'>\n";
  1685. echo "<input type='hidden' name='act' value='mul_dump'>\n";
  1686. echo "<input type='hidden' name='type' value='txt'>\n";
  1687. echo "<input type='hidden' name='s_date' value=$s_date>\n";
  1688. echo "<input type='hidden' name='e_date' value=$e_date>\n";
  1689. echo "<input type='hidden' name='bio_id' value='$bio_id'>\n";
  1690. echo "<input type='hidden' name='bio_name' value='$vac_name'>\n";
  1691. echo "<input type='hidden' name='consumed_ynd' value='D'>\n";
  1692. echo "<br><input type='submit' value='Dump Selected to Text'>\n";
  1693. echo "</form></center></td>\n";
  1694. echo "</tr></table></center><br><br>\n";
  1695. }
  1696. NavBar($cgi, $act, $usr_access);
  1697. break;
  1698. // end of one_destroyed_list
  1699. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1700. // date_vac_list
  1701. // From Navigation, Report by Date Range, From Form "Name" Select button
  1702. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1703. case "date_vac_list":
  1704. mybanner("All $vac_name Vaccine from $s_date to $e_date", "none", $user_name);
  1705. $q = "select * from $mytable
  1706. where biological_id = '$bio_id'
  1707. and ((r_date >= $d_quote$s_date$d_quote and r_date <= $d_quote$e_date$d_quote)
  1708. or (c_date >= $d_quote$s_date$d_quote and c_date <= $d_quote$e_date$d_quote))
  1709. order by consumed_ynd, r_date, r_time";
  1710. // echo "<BR><BR>$q<BR><BR>";
  1711. Full_Lister($bio_name, $q);
  1712. // echo "<br>$q<br>";
  1713. if ($usr_access > 50) {
  1714. echo "<center><table width='60%' border='1' cellspacing='0' cellpadding='4'>\n";
  1715. echo "<tr>";
  1716. echo "<td><center><form action='$cgi' method='post'>\n";
  1717. echo "<input type='hidden' name='act' value='mul_dump'>\n";
  1718. echo "<input type='hidden' name='type' value='xls'>\n";
  1719. echo "<input type='hidden' name='s_date' value=$s_date>\n";
  1720. echo "<input type='hidden' name='e_date' value=$e_date>\n";
  1721. echo "<input type='hidden' name='bio_id' value='$bio_id'>\n";
  1722. echo "<input type='hidden' name='bio_name' value='$vac_name'>\n";
  1723. echo "<br><input type='submit' value='Dump Selected to Spreadsheet'>\n";
  1724. echo "</form></center></td>\n";
  1725. echo "<td><center><form action='$cgi' method='post'>\n";
  1726. echo "<input type='hidden' name='act' value='mul_dump'>\n";
  1727. echo "<input type='hidden' name='type' value='txt'>\n";
  1728. echo "<input type='hidden' name='s_date' value=$s_date>\n";
  1729. echo "<input type='hidden' name='e_date' value=$e_date>\n";
  1730. echo "<input type='hidden' name='bio_id' value='$bio_id'>\n";
  1731. echo "<input type='hidden' name='bio_name' value='$vac_name'>\n";
  1732. echo "<br><input type='submit' value='Dump Selected to Text'>\n";
  1733. echo "</form></center></td>\n";
  1734. echo "</tr></table></center><br><br>\n";
  1735. }
  1736. NavBar($cgi, $act, $usr_access);
  1737. break;
  1738. // end of date_vac_list
  1739. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1740. // Get_note
  1741. // From Navagation selecting "List on Hand" in the expire module and selecting 'consume' or 'expire'
  1742. // Need to collect the note and make sure the string is ok and then return to the "expire" module for update SQL
  1743. // Upon return to expire module you will need.
  1744. // Need to make a deture for the consume and delete so a "note" can be entered.
  1745. // The "note" needs to be ran through the validation to prevent SQL injection
  1746. // Have this module accept info for Create or destroy, so it can be handled (Introduce by banner) properly
  1747. // After collection of the "note", return here for processing so they return to the expire screen
  1748. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1749. case "get_note":
  1750. $progress_str = "You have selected to $cargo a $bio_name vaccine";
  1751. $mydate = getdate(time());
  1752. $r_date = $mydate["year"] . "-" . $mydate["mon"] . "-" . $mydate["mday"];
  1753. $today = $mydate["mon"] . "/" . $mydate["mday"] . "/" . $mydate["year"];
  1754. $r_time = format_time($mydate);
  1755. // $r_time = str_pad($r_time,5,"0",STR_PAD_LEFT);
  1756. $r_ip = $REMOTE_ADDR;
  1757. $c_date = $mydate["year"] . "-" . $mydate["mon"] . "-" . $mydate["mday"];
  1758. $c_time = format_time($mydate);
  1759. // $c_time = str_pad($c_time,5,"0",STR_PAD_LEFT);
  1760. $c_ip = $REMOTE_ADDR;
  1761. if (isset($note)) {
  1762. $note = FixMyString($note);
  1763. $q1 = "update $mytable set c_name= $d_quote$user_name$d_quote,
  1764. c_date = $d_quote$c_date$d_quote,
  1765. c_time = $d_quote$c_time$d_quote,
  1766. c_ip = $d_quote$c_ip$d_quote,
  1767. note = $d_quote$note$d_quote,
  1768. consumed_ynd = ";
  1769. $q3 = " where id = $d_quote$det_id$d_quote";
  1770. if ($cargo == "destroy")
  1771. {
  1772. mybanner("one $bio_name has been marked DESTROYED", "none", $user_name);
  1773. $q2 = $d_quote . "D" . $d_quote;
  1774. }
  1775. if ($cargo == "consume")
  1776. {
  1777. mybanner("one $bio_name has been marked CONSUMED", "none", $user_name);
  1778. $q2 = $d_quote . "Y" . $d_quote;
  1779. }
  1780. $q = $q1 . $q2 . $q3;
  1781. // echo "<br>$q<br>";
  1782. $r = mysql_query($q) or die(mysql_error());
  1783. echo "<br><center><font size=+2>Success!</font></center><br>";
  1784. SendEmail($progress_str, $bio_table, $detail_table, $email_table);
  1785. } else {
  1786. mybanner($progress_str, "none", $user_name);
  1787. echo "<br><center><font +1><b>Please enter comment below</b></font></center><br>";
  1788. // mybanner("Consume/Delete Comment Collection", "none", $PHP_AUTH_USER);
  1789. // Go back to vaccine_list when done with collecting and validating note!
  1790. // Go back to stock_list when done with collecting and validating note!
  1791. // echo "<td><a href='$cgi?act=stock_list&det_id=$det_id&bio_id=$bio_id&bio_name=$bio_name&cargo=consume'>Consume</a></td>
  1792. // <td><a href='$cgi?act=stock_list&det_id=$det_id&bio_id=$bio_id&bio_name=$bio_name&cargo=destroy'>Destroy</a></td>";
  1793. echo "<center><form action='$cgi' method='post'>\n";
  1794. echo "<input type='hidden' name='act' value='get_note'>\n";
  1795. echo "<input type='hidden' name='cargo' value='$cargo'>\n";
  1796. echo "<input type='hidden' name='bio_id' value='$bio_id'>\n";
  1797. echo "<input type='hidden' name='bio_name' value='$bio_name'>\n";
  1798. echo "<input type='hidden' name='det_id' value='$det_id'>\n";
  1799. echo "Note/Comment: <input type='text' name='note' maxlength='132' size='40' value = ''><br>\n";
  1800. echo "<br><input type='submit' value='Record $cargo of $bio_name'>\n";
  1801. echo "</form></center>\n";
  1802. // echo "<br>det_id=$det_id<br>bio_id=$bio_id<br>bio_name=$bio_name<br>cargo=$cargo<br>note=$note<br>";
  1803. }
  1804. NavBar($cgi, $act, $usr_access);
  1805. break;
  1806. // end of get_note
  1807. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1808. // dumpxl
  1809. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1810. case "dumpxl":
  1811. //die( "<br>Q_str = $q_str<br>\n");
  1812. header("Cache-control: private");
  1813. header('Content-type: application/vnd.ms-excel');
  1814. header("Content-Disposition: attachment ; filename=vaccine_dump." . "xls");
  1815. $q = "select a.exp_date, a.lot_num, a.r_name,
  1816. a.r_date, a.r_time, a.r_ip, b.name as bio_name, c.name as man_name,
  1817. a.biological_id as bio_id, a.id as det_id,
  1818. datediff( a.exp_date, now() ) as exp
  1819. from $mydbf.$mytable a, $bio_table b, $man_table c
  1820. where a.consumed_ynd = 'N' and b.id = a.biological_id and a.man_id = c.id
  1821. order by bio_name, exp_date";
  1822. //echo "<br><br>$q<br><br>";
  1823. My_xls_dump($q);
  1824. break;
  1825. // end of dumpxl
  1826. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1827. // dumptxt
  1828. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1829. case "dumptxt":
  1830. header("Cache-control: private");
  1831. header('Content-type: application/vnd.ms-notepad ; filename=biopsy_entry_dump.' . 'txt');
  1832. header("Content-Disposition: attachment ; filename=vaccine_dump." . "txt");
  1833. $q = "select a.exp_date, a.lot_num, a.note,
  1834. a.r_name, a.r_date, a.r_time, a.r_ip,
  1835. a.c_name, a.c_date, a.c_time, a.c_ip,
  1836. b.name as bio_name, a.consumed_ynd,
  1837. a.biological_id as bio_id, a.id as det_id
  1838. from $mydbf.$mytable a, $bio_table b
  1839. where b.id = a.biological_id
  1840. order by bio_name, consumed_ynd, lot_num";
  1841. My_txt_dump($q);
  1842. break;
  1843. // end of dumptxt
  1844. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1845. // mul_dump
  1846. // Need a case for one Vaccine or all Vaccines - (bio_id, bio_name)
  1847. // Need to see if it is for all, received, consumed, or destroyed - (consumed_ynd)
  1848. // need to see if there is a date range - (s_date, e_date)
  1849. // $a as well as the file name need to adjust for each one!
  1850. // Passed possibilities are:
  1851. // s_date, bio_id, bio_name, consumed_ynd
  1852. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1853. case "mul_dump":
  1854. //die( "<br>Q_str = $q_str<br>\n");
  1855. $filename = "vaccine_dump";
  1856. $q1 = "";
  1857. $q2 = "";
  1858. $q3 = "";
  1859. if (isset($consumed_ynd)) {
  1860. if ($consumed_ynd == "Y") {
  1861. $filename = $filename . "-Consumed";
  1862. $q2 = $q2 . " and consumed_ynd = $d_quote$consumed_ynd$d_quote";
  1863. }
  1864. if ($consumed_ynd == "D") {
  1865. $filename = $filename . "-Destroyed";
  1866. $q2 = $q2 . " and consumed_ynd = $d_quote$consumed_ynd$d_quote";
  1867. }
  1868. if ($consumed_ynd == "N") {
  1869. $filename = $filename . "-Received";
  1870. $q2 = $q2 . " and consumed_ynd = 'N'";
  1871. // if this happens to be the in house, then apply the ynd filter
  1872. }
  1873. if ($consumed_ynd == "instock") {
  1874. $filename = $filename . "-InStock";
  1875. // if this happens to be the in house, then apply the ynd filter
  1876. $q2 = $q2 . " and consumed_ynd = 'N'";
  1877. // echo "<br><br>Here I am<br><br>";
  1878. }
  1879. }
  1880. if (isset($lot_num)) {
  1881. $q2 = $q2 . " and a.lot_num = $d_quote$lot_num$d_quote";
  1882. $filename = $filename . "-lot_num:$lot_num";
  1883. }
  1884. if (isset($bio_id)) {
  1885. $q2 = $q2 . " and a.biological_id = $d_quote$bio_id$d_quote";
  1886. $filename = $filename . "-$bio_name";
  1887. }
  1888. if (isset($s_date) ) {
  1889. if (isset($consumed_ynd)) {
  1890. if ($consumed_ynd == "N") {
  1891. $q2 = $q2 . " and (r_date >= $d_quote$s_date$d_quote and r_date <= $d_quote$e_date$d_quote)";
  1892. } elseif (($consumed_ynd == "Y") or ($consumed_ynd == "D")) {
  1893. $q2 = $q2 . " and (c_date >= $d_quote$s_date$d_quote and c_date <= $d_quote$e_date$d_quote)";
  1894. }// isset($consumed_ynd
  1895. } else { // isset($consumed_ynd
  1896. $q2 = $q2 . " and ((r_date >= $d_quote$s_date$d_quote and r_date <= $d_quote$e_date$d_quote)";
  1897. $q2 = $q2 . " or (c_date >= $d_quote$s_date$d_quote and c_date <= $d_quote$e_date$d_quote))";
  1898. } // isset($consumed_ynd
  1899. $filename = $filename . "-$s_date-to-$e_date";
  1900. }
  1901. if ($type == "xls") $filename = $filename . ".xls";
  1902. if ($type == "txt") $filename = $filename . ".txt";
  1903. //echo "<br><BR><BR>$filename<BR><BR>";
  1904. $q1 = "select a.exp_date, a.lot_num, a.note,
  1905. a.r_name, a.r_date, a.r_time, a.r_ip,
  1906. a.c_name, a.c_date, a.c_time, a.c_ip,
  1907. b.name as bio_name, a.consumed_ynd,
  1908. a.biological_id as bio_id, a.id as det_id, c.name as man_name
  1909. from $mydbf.$mytable a, $bio_table b, $man_table c
  1910. where b.id = a.biological_id and a.man_id = c.id";
  1911. $q3 = " order by bio_name, consumed_ynd, lot_num";
  1912. $q = $q1 . $q2 . $q3;
  1913. //echo "<br><br><br>$q<br><br><br>";
  1914. //echo "<br><br><br>$filename<br><br><br>";
  1915. if ($type == "xls") {
  1916. header("Cache-control: private");
  1917. header('Content-type: application/vnd.ms-excel');
  1918. header("Content-Disposition: attachment ; filename=$filename");
  1919. My_xls_dump($q);
  1920. }
  1921. if ($type == "txt") {
  1922. header("Cache-control: private");
  1923. header("Content-type: application/vnd.ms-notepad ; filename=$filename");
  1924. header("Content-Disposition: attachment ; filename=$filename");
  1925. My_txt_dump($q);
  1926. }
  1927. break;
  1928. // end of mul_dump
  1929. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1930. // trash
  1931. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1932. case "trash":
  1933. mybanner("Removal of Consumed and Destroyed History", "none", $user_name);
  1934. if ($usr_access > 50) {
  1935. if (isset($date_del_hist)) {
  1936. $errString = "";
  1937. $errString .= ValadateInput($date_del_hist, "date", "Delete History Date");
  1938. if (strlen($errString) < 5) {
  1939. if (isset($del_ok)) {
  1940. $date_del_hist = LinuxDate($date_del_hist);
  1941. $q = "delete from $mytable where consumed_ynd <> 'N' and c_date <= $d_quote$date_del_hist$d_quote";
  1942. $r = mysql_query($q) or die(mysql_error());
  1943. $comment = "You have successfully deleted history dated $date_del_hist and prior";
  1944. echo "<br><center><font size='+3'>$comment</font></center>\n";
  1945. echo "<br><center>$q</center>\n";
  1946. SendEmail($comment, $bio_table, $detail_table, $email_table);
  1947. } else { // isset(del_ok)
  1948. echo "<font size='+3'><br><center>You are about to delete history from $date_del_hist and before<br>\n";
  1949. echo "There is no <b>undo</b> from here<br>\n";
  1950. echo "Are you sure!</center></font><br>\n";
  1951. echo "<center>\n";
  1952. echo "<center><form action='$cgi' method='post'>\n";
  1953. echo "<input type='hidden' name='act' value='trash'>\n";
  1954. echo "<input type='hidden' name='date_del_hist' value='$date_del_hist'>\n";
  1955. echo "<input type='hidden' name='del_ok' value='ok'>\n";
  1956. echo "<br><font><input type='submit' value='Click here to complete deletion' style='font-size:18px'>\n";
  1957. echo "</form></center><br>\n";
  1958. } // isset(del_ok)
  1959. } else { // strlen errString < 5
  1960. echo "$errString\n";
  1961. } // strlen errString < 5
  1962. } else {
  1963. // need to ask for the date marking the most recent consumed/destroy date
  1964. // All data from that point and before will be removed
  1965. // This has no undo
  1966. // first pre-populate with max(`c_date`)
  1967. $q = "SELECT max(c_date) as mydate1, min(c_date) as mydate2 FROM $mytable where c_date <> '0000-00-00'";
  1968. $r = mysql_query($q) or die(mysql_error());
  1969. $row = mysql_fetch_array($r);
  1970. $mydate1 = $row["mydate1"];
  1971. $mydate1 = DosDate($mydate1);
  1972. $mydate2 =$row["mydate2"];
  1973. $mydate2 = DosDate($mydate2);
  1974. echo "<center><br>First history entry was $mydate2 and the most recent is $mydate1<br><br>";
  1975. echo "Please be careful of your selection<br>There is no undo from here!<br>\n";
  1976. echo "The default selection below will <font size=+3>remove all history!</font><br>\n";
  1977. echo "</center><br>";
  1978. echo "<center><form action='$cgi' method='post'>\n";
  1979. echo "<input type='hidden' name='act' value='trash'>\n";
  1980. echo "Enter Date to remove history on this date and before: <input type='text' name='date_del_hist' maxlength='10' size='10' value = '$mydate1'><br>\n";
  1981. echo "<br><font><input type='submit' value='Remove history for this date and before' style='font-size:18px'>\n";
  1982. echo "</form></center>\n";
  1983. }// date_del_hist is set
  1984. } else { // user_access > 50
  1985. echo "<br><br><center><font size=+3>You do not have security settings for this page!</font></center><br><br>\n";
  1986. } // user_access > 50
  1987. NavBar($cgi, $act, $usr_access);
  1988. break;
  1989. // end of trash
  1990. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1991. // lot_grid
  1992. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1993. case "lot_grid":
  1994. mybanner("Vaccine Lot Number Grid", "none", $user_name);
  1995. $q = "select distinct lot_num from $mydbf.$mytable order by lot_num";
  1996. $r = mysql_query($q) or die(mysql_error());
  1997. $max = mysql_num_rows($r);
  1998. $color = 0;
  1999. if ($max > 0) {
  2000. echo "<center><table width='60%' border='1' cellspacing='0' cellpadding='4'>\n";
  2001. echo "<tr bgcolor=#ffffff><td colspan=4><center>$max Lot numbers foud</center></td></tr>";
  2002. echo "<tr bgcolor=#ffffff><td><center>Stock Number</center></td>";
  2003. echo "<td><center>On Hand</center></td>";
  2004. echo "<td><center>Consumed</center></td>";
  2005. echo "<td><center>Destroyed</center></td>";
  2006. echo "</tr>";
  2007. $form_txt = "<form action='$cgi' method='post'>
  2008. <input type='hidden' name='act' value='%%var1%%'>
  2009. <input type='hidden' name='lot_num' value='%%lot_num%%'>
  2010. <input type='submit' value='%%value%%'>
  2011. </form>";
  2012. while ($row = mysql_fetch_array($r)) {
  2013. $lot = $row["lot_num"];
  2014. $color = MeColorTR($color, 1);
  2015. $temp = $form_txt;
  2016. $temp = str_replace('%%lot_num%%', $lot, $temp);
  2017. $temp = str_replace('%%var1%%', 'lot_detail', $temp);
  2018. $temp = str_replace('%%value%%', $lot, $temp);
  2019. echo "<td><center>$temp</center></td>"; // On Hand
  2020. // echo "<td>$lot</td>";
  2021. $q2 = "select count(*) as mycount from $mytable where lot_num = $d_quote$lot$d_quote and consumed_ynd = 'N'";
  2022. $q3 = "select count(*) as mycount from $mytable where lot_num = $d_quote$lot$d_quote and consumed_ynd = 'Y'";
  2023. $q4 = "select count(*) as mycount from $mytable where lot_num = $d_quote$lot$d_quote and consumed_ynd = 'D'";
  2024. $r2 = mysql_query($q2) or die(mysql_error());
  2025. $r3 = mysql_query($q3) or die(mysql_error());
  2026. $r4 = mysql_query($q4) or die(mysql_error());
  2027. $row2 = mysql_fetch_array($r2);
  2028. $row3 = mysql_fetch_array($r3);
  2029. $row4 = mysql_fetch_array($r4);
  2030. $count2 = $row2["mycount"];
  2031. if ($count2 < 1) {
  2032. echo "<td><center>--</center></td>"; // On Hand
  2033. } else { //$count2 < 1
  2034. $temp = $form_txt;
  2035. $temp = str_replace('%%lot_num%%', $lot, $temp);
  2036. $temp = str_replace('%%var1%%', 'lot_on_hand', $temp);
  2037. $temp = str_replace('%%value%%', $count2, $temp);
  2038. echo "<td><center>$temp</center></td>"; // On Hand
  2039. } //$count2 < 1
  2040. $count3 = $row3["mycount"];
  2041. if ($count3 < 1) {
  2042. echo "<td><center>--</center></td>"; // Consumed
  2043. } else { // $count3 < 1
  2044. $temp = $form_txt;
  2045. $temp = str_replace('%%lot_num%%', $lot, $temp);
  2046. $temp = str_replace('%%var1%%', 'lot_consumed', $temp);
  2047. $temp = str_replace('%%value%%', $count3, $temp);
  2048. echo "<td><center>$temp</center></td>"; // Consumed
  2049. } // $count3 < 1
  2050. $count4 = $row4["mycount"];
  2051. if ($count4 < 1) { //$count4 < 1
  2052. echo "<td><center>--</center></td>"; // Destroyed
  2053. } else { // $count4 < 1
  2054. $temp = $form_txt;
  2055. $temp = str_replace('%%lot_num%%', $lot, $temp);
  2056. $temp = str_replace('%%var1%%', 'lot_destroyed', $temp);
  2057. $temp = str_replace('%%value%%', $count4, $temp);
  2058. echo "<td><center>$temp</center></td>"; // Destroyed
  2059. } // $count4 < 1
  2060. echo "</tr>";
  2061. } // end while
  2062. echo "</table></center><br><br>";
  2063. } // end max > 0
  2064. NavBar($cgi, $act, $usr_access);
  2065. break;
  2066. // end of lot_grid
  2067. // start of the 4 musketeers!
  2068. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2069. // lot_detail #1
  2070. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2071. case "lot_detail":
  2072. mybanner("All Vaccines from lot #: $lot_num", "none", $user_name);
  2073. $q = "select * from $mytable
  2074. where lot_num = '$lot_num'
  2075. order by consumed_ynd, r_date, r_time";
  2076. Full_Lister($lot_num, $q);
  2077. // echo "<br>$q<br>";
  2078. if ($usr_access > 50) {
  2079. echo "<center><table width='60%' border='1' cellspacing='0' cellpadding='4'>\n";
  2080. echo "<tr>";
  2081. echo "<td><center><form action='$cgi' method='post'>\n";
  2082. echo "<input type='hidden' name='act' value='mul_dump'>\n";
  2083. echo "<input type='hidden' name='type' value='xls'>\n";
  2084. echo "<input type='hidden' name='lot_num' value='$lot_num'>\n";
  2085. echo "<br><input type='submit' value='Dump Selected to Spreadsheet'>\n";
  2086. echo "</form></center></td>\n";
  2087. echo "<td><center><form action='$cgi' method='post'>\n";
  2088. echo "<input type='hidden' name='act' value='mul_dump'>\n";
  2089. echo "<input type='hidden' name='type' value='txt'>\n";
  2090. echo "<input type='hidden' name='lot_num' value='$lot_num'>\n";
  2091. echo "<br><input type='submit' value='Dump Selected to Text'>\n";
  2092. echo "</form></center></td>\n";
  2093. echo "</tr></table></center><br><br>\n";
  2094. }
  2095. NavBar($cgi, $act, $usr_access);
  2096. break;
  2097. // end of lot_detail
  2098. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2099. // lot_on_hand #2
  2100. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2101. case "lot_on_hand":
  2102. mybanner("Oh Hand Vaccines for lot #: $lot_num", "none", $user_name);
  2103. $q = "select * from $mytable
  2104. where lot_num = '$lot_num' and consumed_ynd = 'N'
  2105. order by consumed_ynd, r_date, r_time";
  2106. // echo "<BR><BR>$q<BR><BR>";
  2107. Full_Lister($lot_num, $q);
  2108. // echo "<br>$q<br>";
  2109. if ($usr_access > 50) {
  2110. echo "<center><table width='60%' border='1' cellspacing='0' cellpadding='4'>\n";
  2111. echo "<tr>";
  2112. echo "<td><center><form action='$cgi' method='post'>\n";
  2113. echo "<input type='hidden' name='act' value='mul_dump'>\n";
  2114. echo "<input type='hidden' name='type' value='xls'>\n";
  2115. echo "<input type='hidden' name='lot_num' value='$lot_num'>\n";
  2116. echo "<input type='hidden' name='consumed_ynd' value='N'>\n";
  2117. echo "<br><input type='submit' value='Dump Selected to Spreadsheet'>\n";
  2118. echo "</form></center></td>\n";
  2119. echo "<td><center><form action='$cgi' method='post'>\n";
  2120. echo "<input type='hidden' name='act' value='mul_dump'>\n";
  2121. echo "<input type='hidden' name='type' value='txt'>\n";
  2122. echo "<input type='hidden' name='lot_num' value='$lot_num'>\n";
  2123. echo "<input type='hidden' name='consumed_ynd' value='N'>\n";
  2124. echo "<br><input type='submit' value='Dump Selected to Text'>\n";
  2125. echo "</form></center></td>\n";
  2126. echo "</tr></table></center><br><br>\n";
  2127. }
  2128. NavBar($cgi, $act, $usr_access);
  2129. break;
  2130. // end of lot_on_hand
  2131. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2132. // lot_consumed #3
  2133. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2134. case "lot_consumed":
  2135. mybanner("Consumed Vaccines from lot #: $lot_num", "none", $user_name);
  2136. $q = "select * from $mytable
  2137. where lot_num = '$lot_num' and consumed_ynd = 'Y'
  2138. order by consumed_ynd, r_date, r_time";
  2139. // echo "<BR><BR>$q<BR><BR>";
  2140. Full_Lister($lot_num, $q);
  2141. // echo "<br>$q<br>";
  2142. if ($usr_access > 50) {
  2143. echo "<center><table width='60%' border='1' cellspacing='0' cellpadding='4'>\n";
  2144. echo "<tr>";
  2145. echo "<td><center><form action='$cgi' method='post'>\n";
  2146. echo "<input type='hidden' name='act' value='mul_dump'>\n";
  2147. echo "<input type='hidden' name='type' value='xls'>\n";
  2148. echo "<input type='hidden' name='lot_num' value='$lot_num'>\n";
  2149. echo "<input type='hidden' name='consumed_ynd' value='Y'>\n";
  2150. echo "<br><input type='submit' value='Dump Selected to Spreadsheet'>\n";
  2151. echo "</form></center></td>\n";
  2152. echo "<td><center><form action='$cgi' method='post'>\n";
  2153. echo "<input type='hidden' name='act' value='mul_dump'>\n";
  2154. echo "<input type='hidden' name='type' value='txt'>\n";
  2155. echo "<input type='hidden' name='lot_num' value='$lot_num'>\n";
  2156. echo "<input type='hidden' name='consumed_ynd' value='Y'>\n";
  2157. echo "<br><input type='submit' value='Dump Selected to Text'>\n";
  2158. echo "</form></center></td>\n";
  2159. echo "</tr></table></center><br><br>\n";
  2160. }
  2161. NavBar($cgi, $act, $usr_access);
  2162. break;
  2163. // end of lot_consumed
  2164. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2165. // lot_destroyed #4
  2166. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2167. case "lot_destroyed":
  2168. mybanner("Destroyed Vaccines from lot #: $lot_num", "none", $user_name);
  2169. $q = "select * from $mytable
  2170. where lot_num = '$lot_num' and consumed_ynd = 'D'
  2171. order by consumed_ynd, r_date, r_time";
  2172. // echo "<BR><BR>$q<BR><BR>";
  2173. Full_Lister($lot_num, $q);
  2174. // echo "<br>$q<br>";
  2175. if ($usr_access > 50) {
  2176. echo "<center><table width='60%' border='1' cellspacing='0' cellpadding='4'>\n";
  2177. echo "<tr>";
  2178. echo "<td><center><form action='$cgi' method='post'>\n";
  2179. echo "<input type='hidden' name='act' value='mul_dump'>\n";
  2180. echo "<input type='hidden' name='type' value='xls'>\n";
  2181. echo "<input type='hidden' name='lot_num' value='$lot_num'>\n";
  2182. echo "<input type='hidden' name='consumed_ynd' value='D'>\n";
  2183. echo "<br><input type='submit' value='Dump Selected to Spreadsheet'>\n";
  2184. echo "</form></center></td>\n";
  2185. echo "<td><center><form action='$cgi' method='post'>\n";
  2186. echo "<input type='hidden' name='act' value='mul_dump'>\n";
  2187. echo "<input type='hidden' name='type' value='txt'>\n";
  2188. echo "<input type='hidden' name='lot_num' value='$lot_num'>\n";
  2189. echo "<input type='hidden' name='consumed_ynd' value='D'>\n";
  2190. echo "<br><input type='submit' value='Dump Selected to Text'>\n";
  2191. echo "</form></center></td>\n";
  2192. echo "</tr></table></center><br><br>\n";
  2193. }
  2194. NavBar($cgi, $act, $usr_access);
  2195. break;
  2196. // end of lot_destroyed
  2197. } // end of switch
  2198. } // end of missing act=
  2199. /*
  2200. //// useful for cut and paste
  2201. if ($usr_access > 50) {
  2202. echo "<center><table width='60%' border='1' cellspacing='0' cellpadding='4'>\n";
  2203. echo "<tr>";
  2204. echo "<td><center><form action='$cgi' method='post'>\n";
  2205. echo "<input type='hidden' name='act' value='mul_dump'>\n";
  2206. echo "<input type='hidden' name='type' value='xls'>\n";
  2207. echo "<input type='hidden' name='s_date' value=$s_date>\n";
  2208. echo "<input type='hidden' name='e_date' value=$e_date>\n";
  2209. echo "<input type='hidden' name='bio_id' value='$bio_id'>\n";
  2210. echo "<input type='hidden' name='bio_name' value='$vac_name'>\n";
  2211. echo "<input type='hidden' name='consumed_ynd' value='N'>\n";
  2212. echo "<br><input type='submit' value='Dump Selected to Spreadsheet'>\n";
  2213. echo "</form></center></td>\n";
  2214. echo "<td><center><form action='$cgi' method='post'>\n";
  2215. echo "<input type='hidden' name='act' value='mul_dump'>\n";
  2216. echo "<input type='hidden' name='type' value='txt'>\n";
  2217. echo "<input type='hidden' name='s_date' value=$s_date>\n";
  2218. echo "<input type='hidden' name='e_date' value=$e_date>\n";
  2219. echo "<input type='hidden' name='bio_id' value='$bio_id'>\n";
  2220. echo "<input type='hidden' name='bio_name' value='$vac_name'>\n";
  2221. echo "<input type='hidden' name='consumed_ynd' value='N'>\n";
  2222. echo "<br><input type='submit' value='Dump Selected to Text'>\n";
  2223. echo "</form></center></td>\n";
  2224. echo "</tr></table></center><br><br>\n";
  2225. }
  2226. $r = mysql_query($q) or die(mysql_error());
  2227. $max = mysql_num_rows($r);
  2228. echo "<center><table width='95%' border='1' cellspacing='0' cellpadding='4'>\n";
  2229. echo "<tr bgcolor=#ffffff><td colspan=9><center>$max records found</center></td></tr>";
  2230. $r_time = str_pad($r_time,5,"0",STR_PAD_LEFT);
  2231. UPDATE `p_detail` SET `r_time` = lpad(`r_time`,5,'0');
  2232. UPDATE `p_detail` SET `c_time` = lpad(`c_time`,5,'0');
  2233. */
  2234. ?>