Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- switch ($verb) {
- case 'view':
- # code...
- if($patient = ActiveRecord::FindById('patient',$id)){
- $page_title = 'Admin';
- $page_header = 'Comment';
- $out .= '<pre>' . print_r($patient,true) . '</pre>';
- $out .= '<p><a href="' . BASE_URL . 'patient/index">Back to List</a> | ' . $patient->link_for('edit','added_at',array('text'=>'Edit this Comment')) . '</p>';
- }else{
- $out .= flash('Sorry, that comment doesn’t seem to be here.','error');
- }
- $out .= render_partial('patient',$patient);
- break;
- case 'create':
- default:
- # code...
- $$patient = ActiveRecord::Create('patient');
- if(isset($_POST['submit'])){
- $patient->populate(clean($_POST));
- $patient->save();
- $message = 'Thanks for your submission ' . $patient->h('name') . ', now say goodbye.';
- $patient->manage_result('_flash','flash',$message,'thanks.php');
- }
- if(isset($_SESSION['flash'])){
- $patient->_flash = $_SESSION['flash'];
- unset($_SESSION['flash']);
- }
- // break;
- // $patient = ActiveRecord::Create('patient');
- $days = array('Select...','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday');
- $day = $patient->day; //setting the global variable to whatever has already been entered for this person
- $patient->day_picker = SimpleListBox($days,'day');
- $hours = range(8,12); //returns array(8,9,10,11,12)
- foreach($hours as $k=>$v) $hours[$k] = $v . 'am';
- $hours2 = range(1,8);
- foreach($hours2 as $k=>$v) $hours2[$k] = $v . 'pm';
- $hours = array_merge(array('Select...'),$hours,$hours2); //adding arrays concatenates them together
- $patient->time_picker = SimpleListBox($hours,'time');
- $zones = array('Select...','PST','MST','CST','EST');
- $zone = $patient->day; //setting the global variable to whatever has already been entered for this person
- $patient->zone_picker = SimpleListBox($zones,'zone');
- $workshops = array('Select...','Option A','Option B','Option C');
- $workshop = $patient->workshop;
- $patient->workshop_picker = SimpleListBox($workshops,'workshop');
- $modalities = array('Select...','Art','Dance');
- $modality = $patient->modality;
- $patient->modality_picker = SimpleListBox($modalities,'modality');
- $page_title = 'Patient Form';
- $page_header = '';
- $out .= render_partial('patient',$patient);
- break;
- case 'edit':
- # code...
- if($patient = ActiveRecord::FindById('patient',$id)){
- if(isset($_POST['delete'])){
- $patient->destroy();
- $_SESSION['flash'] = flash('Comment deleted');
- header('Location: ' . BASE_URL . 'patient/index');
- exit;
- }
- if(isset($_SESSION['flash'])){
- $patient->_flash = $_SESSION['flash'];
- unset($_SESSION['flash']);
- }
- if(isset($_POST['name'])){
- $patient->populate(clean($_POST));
- $patient->save();
- $patient->manage_result('_flash','flash','Changes saved',$self);
- }
- $days = array('Select...','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday');
- $day = $patient->day; //setting the global variable to whatever has already been entered for this person
- $patient->day_picker = SimpleListBox($days,'day');
- $hours = range(8,12); //returns array(8,9,10,11,12)
- foreach($hours as $k=>$v) $hours[$k] = $v . 'am';
- $hours2 = range(1,8);
- foreach($hours2 as $k=>$v) $hours2[$k] = $v . 'pm';
- $hours = array_merge(array('Select...'),$hours,$hours2); //adding arrays concatenates them together
- $patient->time_picker = SimpleListBox($hours,'time');
- $zones = array('Select...','PST','MST','CST','EST');
- $zone = $patient->day; //setting the global variable to whatever has already been entered for this person
- $patient->zone_picker = SimpleListBox($zones,'zone');
- $workshops = array('Select...','Option A','Option B','Option C');
- $workshop = $patient->workshop;
- $patient->workshop_picker = SimpleListBox($workshops,'workshop');
- $modalities = array('Select...','Art','Dance');
- $modality = $patient->modality;
- $patient->modality_picker = SimpleListBox($modalities,'modality');
- $page_title = 'Edit Comment';
- $page_header = 'Edit Comment';
- $out .= render_partial('patient',$patient);
- }else{
- $out .= flash('Sorry, that comment doesn’t seem to be here.','error');
- }
- break;
- case 'index':
- default:
- # code...
- if(isset($_SESSION['flash'])){
- $flash = $_SESSION['flash'];
- unset($_SESSION['flash']);
- }
- $page_title = 'Admin';
- $total = ActiveRecord::Count('patient');
- $page_header = number_format($total) . ' ' . pluralize('Comment',$total);
- $out .= '<p>(Most recent first)</p>' . $flash;
- foreach(ActiveRecord::FindAll('patient','1=1','added_at DESC') as $patient) $out .= '<div class="' . alternate() . ' comment">
- <pre>' . print_r($patient, true) . '</pre>
- <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>
- </div>';
- break;
- $out .= render_partial('patient',$patient);
- }
- include(APP_ROOT . '/views/index.php');
- ?>
Add Comment
Please, Sign In to add comment