Advertisement
my_vet_meds

Untitled

Nov 25th, 2011
125
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.16 KB | None
  1. <?php
  2. set_include_path('.');
  3. include("functions.inc.php");
  4. writeheader ();
  5.  
  6.  
  7. $today = date("d/m/Y");
  8. $want_date= $_POST['from'];
  9. $dateUF=strtotime($_POST['from']);
  10. $dateF=date("d-m-Y", $dateUF);
  11. $row = 0;
  12. $count = 1;
  13.  
  14. //Extract the data from blubolt file
  15. $url="http://www.myvetmeds.co.uk/oversight/products/getProductStats?prescription=prescription&date=".$want_date;
  16. $handle = fopen($url,'r');
  17. $count=0;
  18. $num=0;
  19. //Convert date format: 22/06/2011 22:26 "d/m/Y H:m" to SQL format "Y-m-d"
  20. $header="FALSE";
  21. while (($data = fgetcsv($handle, 1000, ",")) !== FALSE)
  22. {
  23. if (isset($data[3]))
  24. {
  25. if ($header=="FALSE")
  26. {
  27. echo "<BR>Today is: ".$today." Data Below Refers to: ".$dateF."<BR>";
  28. echo"<form method='post' action='report_remote2.php'><table border='1' cellspacing='2' cellpadding='2' name='add' id='add'><tr>
  29. <td><font face='Arial, Helvetica, sans-serif'>First Name</font></th>
  30. <td><font face='Arial, Helvetica, sans-serif'>Last Name</font></th>
  31. <td><font face='Arial, Helvetica, sans-serif'>Order ID</font></th>
  32. <td><font face='Arial, Helvetica, sans-serif'>Product Name</font></th>
  33. <td><font face='Arial, Helvetica, sans-serif'>No Repeats</font></th>
  34. <td><font face='Arial, Helvetica, sans-serif'>Email Address</font></th>
  35. <td><font face='Arial, Helvetica, sans-serif'>Date of Next Order</font></th>
  36. <td><font face='Arial, Helvetica, sans-serif'>Pet Name</font></th>
  37. <td><font face='Arial, Helvetica, sans-serif'>Date of Order</font></th>
  38. <td><font face='Arial, Helvetica, sans-serif'>Confirm</font></th></tr>";
  39. $header="TRUE";
  40. }
  41. $count ++;
  42. $num ++;
  43. $aname = explode(" ", $data[3]);
  44.  
  45. echo "
  46. <tr>
  47. <td><font face='Arial, Helvetica, sans-serif'><input name='FirstName$count' type='text' id='FirstName$count' value='$aname[0]'></font></td>
  48. <td><font face='Arial, Helvetica, sans-serif'><input name='LastName$count' type='text' id='LastName$count' value='$aname[1]'></font></td>
  49. <td><font face='Arial, Helvetica, sans-serif'><input name='OrderID$count' readonly='readonly' type='text' id='OrderID$count' value='$data[6]'></font></td>
  50. <td><font face='Arial, Helvetica, sans-serif'><input name='ProductName$count' readonly='readonly' type='text' id='ProductName$count' value='$data[1]'></font></td>
  51. <td><font face='Arial, Helvetica, sans-serif'><input name='Num_Repeats$count' type='text' value='1' id='Num_Repeats$count' size='3'></font></td>
  52. <td><font face='Arial, Helvetica, sans-serif'><input name='EmailAddress$count' readonly='readonly' type='text' id='EmailAddress$count' value='$data[4]'></font></td>
  53. <td><font face='Arial, Helvetica, sans-serif'><input name='ExpiryDate$count' type='date' id='ExpiryDate$count' size='10' value='$want_date'></td></font></td>
  54.  
  55. <td><font face='Arial, Helvetica, sans-serif'><input name='PetName$count' type='text' id='PetName$count' size='10'></td></font></td>
  56. <td><font face='Arial, Helvetica, sans-serif'><input name='OrderDate$count' type='date' readonly='readonly' id='OrderDate$count' value='$want_date' size='10'></td></font></td>
  57.  
  58.  
  59.  
  60. <td><font face='Arial, Helvetica, sans-serif'><input name='ID$count' type='checkbox' id='ID$count' value='$count'></font></td>
  61. </tr>
  62. ";
  63.  
  64.  
  65. }
  66. else
  67. {
  68. echo "<font color='red'>No data found!</font><BR><BR>";
  69. break;
  70.  
  71. }
  72. fclose($handle);
  73. if ($header=="TRUE")
  74. {echo "</table><BR><BR><input name='numids' type='hidden' value='$count'><input name='processim' type='submit' id='processim' value='Confirm' ></form><BR>Rows: $count <BR>";}
  75. $validate = $count;
  76. //use a loop for this
  77.  
  78. echo "<script type='text/javascript'>$(document).ready(function() {";
  79. for ($thisvalidate = 1; $thisvalidate <= $validate; $thisvalidate++) {
  80. echo"
  81.  
  82. $('#ID$thisvalidate').click(function() {
  83. if ($('#ID$thisvalidate').is(':checked')) {
  84.  
  85. var FirstName$thisvalidate = new LiveValidation( 'FirstName$thisvalidate', {onlyOnSubmit: false } );
  86. FirstName$thisvalidate.add( Validate.Presence );
  87. var LastName$thisvalidate = new LiveValidation( 'LastName$thisvalidate', {onlyOnSubmit: false} );
  88. LastName$thisvalidate.add( Validate.Presence );
  89. var Num_Repeats$thisvalidate = new LiveValidation( 'Num_Repeats$thisvalidate', {onlyOnSubmit: false } );
  90. Num_Repeats$thisvalidate.add( Validate.Presence );
  91. var ExpiryDate$thisvalidate = new LiveValidation( 'ExpiryDate$thisvalidate', {onlyOnSubmit: false } );
  92. ExpiryDate$thisvalidate.add( Validate.Presence );
  93. ExpiryDate$thisvalidate.add( Validate.Exclusion, { within: [ '$want_date' ] } );
  94.  
  95. }
  96. else{
  97. FirstName$thisvalidate.disable();
  98. LastName$thisvalidate.disable();
  99. Num_Repeats$thisvalidate.disable();
  100. ExpiryDate$thisvalidate.disable();
  101. }
  102. })
  103.  
  104. ";
  105.  
  106. //End of For Loop
  107. }
  108. echo "});</script><script type='text/javascript'>
  109.  
  110. var automaticOnSubmit = FirstName1.form.onsubmit;
  111. FirstName1.form.onsubmit = function(){
  112. var valid = automaticOnSubmit();
  113. if(valid)
  114. {alert('The form is valid!'); document.getElementById('add').submit();
  115. return false; }
  116. </script>";
  117.  
  118. if ($header=="TRUE")
  119. {
  120. writefooter ();}
  121. ?>
Advertisement
RAW Paste Data Copied
Advertisement