Guest User

Untitled

a guest
Apr 21st, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.01 KB | None | 0 0
  1. <?php
  2. switch ($verb) {
  3. case 'view':
  4. # code...
  5. if($patient = ActiveRecord::FindById('patient',$id)){
  6. $page_title = 'Admin';
  7. $page_header = 'Comment';
  8. $out .= '<pre>' . print_r($patient,true) . '</pre>';
  9. $out .= '<p><a href="' . BASE_URL . 'patient/index">Back to List</a> | ' . $patient->link_for('edit','added_at',array('text'=>'Edit this Comment')) . '</p>';
  10. }else{
  11. $out .= flash('Sorry, that comment doesn&rsquo;t seem to be here.','error');
  12. }
  13. $out .= render_partial('patient',$patient);
  14. break;
  15. case 'create':
  16. default:
  17. # code...
  18. $$patient = ActiveRecord::Create('patient');
  19. if(isset($_POST['submit'])){
  20. $patient->populate(clean($_POST));
  21. $patient->save();
  22. $message = 'Thanks for your submission ' . $patient->h('name') . ', now say goodbye.';
  23. $patient->manage_result('_flash','flash',$message,'thanks.php');
  24. }
  25. if(isset($_SESSION['flash'])){
  26. $patient->_flash = $_SESSION['flash'];
  27. unset($_SESSION['flash']);
  28. }
  29. // break;
  30. // $patient = ActiveRecord::Create('patient');
  31. $days = array('Select...','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday');
  32. $day = $patient->day; //setting the global variable to whatever has already been entered for this person
  33. $patient->day_picker = SimpleListBox($days,'day');
  34.  
  35. $hours = range(8,12); //returns array(8,9,10,11,12)
  36. foreach($hours as $k=>$v) $hours[$k] = $v . 'am';
  37. $hours2 = range(1,8);
  38. foreach($hours2 as $k=>$v) $hours2[$k] = $v . 'pm';
  39. $hours = array_merge(array('Select...'),$hours,$hours2); //adding arrays concatenates them together
  40. $patient->time_picker = SimpleListBox($hours,'time');
  41.  
  42. $zones = array('Select...','PST','MST','CST','EST');
  43. $zone = $patient->day; //setting the global variable to whatever has already been entered for this person
  44. $patient->zone_picker = SimpleListBox($zones,'zone');
  45.  
  46. $workshops = array('Select...','Option A','Option B','Option C');
  47. $workshop = $patient->workshop;
  48. $patient->workshop_picker = SimpleListBox($workshops,'workshop');
  49.  
  50. $modalities = array('Select...','Art','Dance');
  51. $modality = $patient->modality;
  52. $patient->modality_picker = SimpleListBox($modalities,'modality');
  53.  
  54. $page_title = 'Patient Form';
  55. $page_header = '';
  56. $out .= render_partial('patient',$patient);
  57. break;
  58. case 'edit':
  59. # code...
  60. if($patient = ActiveRecord::FindById('patient',$id)){
  61. if(isset($_POST['delete'])){
  62. $patient->destroy();
  63. $_SESSION['flash'] = flash('Comment deleted');
  64. header('Location: ' . BASE_URL . 'patient/index');
  65. exit;
  66. }
  67. if(isset($_SESSION['flash'])){
  68. $patient->_flash = $_SESSION['flash'];
  69. unset($_SESSION['flash']);
  70. }
  71. if(isset($_POST['name'])){
  72. $patient->populate(clean($_POST));
  73. $patient->save();
  74. $patient->manage_result('_flash','flash','Changes saved',$self);
  75. }
  76. $days = array('Select...','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday');
  77. $day = $patient->day; //setting the global variable to whatever has already been entered for this person
  78. $patient->day_picker = SimpleListBox($days,'day');
  79.  
  80. $hours = range(8,12); //returns array(8,9,10,11,12)
  81. foreach($hours as $k=>$v) $hours[$k] = $v . 'am';
  82. $hours2 = range(1,8);
  83. foreach($hours2 as $k=>$v) $hours2[$k] = $v . 'pm';
  84. $hours = array_merge(array('Select...'),$hours,$hours2); //adding arrays concatenates them together
  85. $patient->time_picker = SimpleListBox($hours,'time');
  86.  
  87. $zones = array('Select...','PST','MST','CST','EST');
  88. $zone = $patient->day; //setting the global variable to whatever has already been entered for this person
  89. $patient->zone_picker = SimpleListBox($zones,'zone');
  90.  
  91. $workshops = array('Select...','Option A','Option B','Option C');
  92. $workshop = $patient->workshop;
  93. $patient->workshop_picker = SimpleListBox($workshops,'workshop');
  94.  
  95. $modalities = array('Select...','Art','Dance');
  96. $modality = $patient->modality;
  97. $patient->modality_picker = SimpleListBox($modalities,'modality');
  98. $page_title = 'Edit Comment';
  99. $page_header = 'Edit Comment';
  100. $out .= render_partial('patient',$patient);
  101. }else{
  102. $out .= flash('Sorry, that comment doesn&rsquo;t seem to be here.','error');
  103. }
  104. break;
  105. case 'index':
  106. default:
  107. # code...
  108. if(isset($_SESSION['flash'])){
  109. $flash = $_SESSION['flash'];
  110. unset($_SESSION['flash']);
  111. }
  112. $page_title = 'Admin';
  113. $total = ActiveRecord::Count('patient');
  114. $page_header = number_format($total) . ' ' . pluralize('Comment',$total);
  115. $out .= '<p>(Most recent first)</p>' . $flash;
  116. foreach(ActiveRecord::FindAll('patient','1=1','added_at DESC') as $patient) $out .= '<div class="' . alternate() . ' comment">
  117. <pre>' . print_r($patient, true) . '</pre>
  118. <p>By: ' . $patient->s('name') . ' (' . $patient->added_at . ') [ ' . $patient->link_for('view','name',array('text'=>'View')) . ' ] [ ' . $patient->link_for('edit','name',array('text'=>'Edit')) . ' ]</p>
  119. </div>';
  120. break;
  121. $out .= render_partial('patient',$patient);
  122. }
  123. include(APP_ROOT . '/views/index.php');
  124. ?>
Add Comment
Please, Sign In to add comment