Changeset 49

Show
Ignore:
Timestamp:
07/17/07 19:30:09 (18 months ago)
Author:
aarkerio
Message:

Add calendar and events

Location:
trunk/app
Files:
2 added
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/config/sql/karamelo.sql

    r44 r49  
    864864); 
    865865 
     866CREATE TABLE events ( 
     867    id serial PRIMARY KEY, 
     868   title varchar(100) NOT NULL, 
     869   description  varchar(255) NOT NULL, 
     870    "when" timestamp(0) with time zone DEFAULT now() NOT NULL, 
     871    status int NOT NULL DEFAULT 0 
     872); 
     873 
    866874CREATE TABLE lessons (   --  lessons  
    867875id serial PRIMARY KEY, 
  • trunk/app/controllers/events_controller.php

    r46 r49  
    77  
    88uses('sanitize'); 
     9loadModel('User'); 
     10vendor('Calendar'); 
    911 
    1012class EventsController extends AppController 
     
    1416   public $components    = array('Portal'); 
    1517    
    16    public function display() 
     18   public function calendar() 
    1719   {   
    18       $this->layout    = 'ajax'; 
     20      $this->layout  = 'portal'; 
    1921       
    20       $conditions = null; 
     22      $conditions    = array("Event.status"=>1); 
    2123       
    22       $fields     = array("Subject.id", "Subject.title", "Subject.code"); 
     24      $fields        = array("Event.id", "Event.title", "Event.description", "Event.when"); 
    2325       
    24       $order      = "Subject.title"; 
     26      $order         = "Event.when DESC"; 
    2527       
    26       $limit      =  null; 
     28      $limit         =  null; 
    2729       
    28       $this->set('data', $this->Subject->findAll($conditions, $fields, $order, $limit)); 
     30      $this->set('data', $this->Event->findAll($conditions, $fields, $order, $limit)); 
    2931       
    30       $this->render('qs', 'ajax'); 
     32      $cal = new Calendar ('2007', '7');  
    3133       
     34      $dts['Month']   = $cal->getFullMonthName(); 
     35       
     36      $dts['Display'] = $cal->display(); 
     37       
     38      $this->set('dts', $dts); 
     39       
     40      $this->set('Element', $this->Portal->statics()); // Charge Portal components aka Sidebars 
    3241   } 
    3342    
     
    3645      $this->layout    = 'portal'; 
    3746       
    38       $conditions = array("Subject.code"=>$code); 
     47      $conditions = array("Event.code"=>$code); 
    3948       
    40       $fields     = array("Subject.id", "Subject.title", "Subject.code"); 
     49      $fields     = array("Event.id", "Event.title", "Event.code"); 
    4150       
    42       $order      = "Subject.title"; 
     51      $order      = "Event.title"; 
    4352       
    4453      $limit      =  20; 
    4554       
    46       $this->set('data', $this->Subject->findAll($conditions, $fields, $order, $limit, null, 2)); 
     55      $this->set('data', $this->Event->findAll($conditions, $fields, $order, $limit, null, 2)); 
    4756       
    48         $this->set('Element', $this->Portal->statics()); // Charge Portal components aka Sidebars 
     57      $this->set('Element', $this->Portal->statics()); // Charge Portal components aka Sidebars 
    4958   } 
    5059    
    5160   public function show($subject_id) 
    5261    {    
    53         $this->pageTitle = 'Karamelo :: Subject'; 
     62        $this->pageTitle = 'Karamelo :: Event'; 
    5463        $this->layout    = 'default'; //$this->Blog->field; 
    55         $conditions = array("Subject.id"=>$subject_id); 
    56         $fields     = array("Subject.id", "Subject.title", "Subject.code"); 
    57         $order      = "Subject.title DESC"; 
     64        $conditions = array("Event.id"=>$subject_id); 
     65        $fields     = array("Event.id", "Event.title", "Event.code"); 
     66        $order      = "Event.title DESC"; 
    5867         
    5968        $this->set('subjects', $this->Portal->cms()); // Using Portal component 
     
    6170        $this->set('randomQuote', $this->Portal->quote()); // quote footer 
    6271         
    63         $this->set('data', $this->Subject->findAll($conditions, $fields, $order)); 
     72        $this->set('data', $this->Event->findAll($conditions, $fields, $order)); 
    6473         
    6574    } 
     
    7685      $order      = "title DESC"; 
    7786       
    78       $this->set('data', $this->Subject->findAll($conditions, $fields, $order)); 
     87      $this->set('data', $this->Event->findAll($conditions, $fields, $order)); 
    7988   } 
    8089    
     
    8493      
    8594    // adds new classroom to database 
    86     if (!empty($this->data["Subject"])) 
     95    if (!empty($this->data["Event"])) 
    8796    { 
    8897        $this->Sanitize = new Sanitize; 
    8998         
    90         $this->Sanitize->cleanArray($this->data["Subject"]); //Hopefully this is enough 
     99        $this->Sanitize->cleanArray($this->data["Event"]); //Hopefully this is enough 
    91100         
    92         if ($this->Subject->save($this->data["Subject"])) 
     101        if ($this->Event->save($this->data["Event"])) 
    93102         { 
    94103           $this->msgFlash('Your subject has been saved.','/admin/subjects/listing'); 
     
    101110  { 
    102111      
    103     if (empty($this->data["Subject"])) 
     112    if (empty($this->data["Event"])) 
    104113    { 
    105114        $this->layout = 'admin'; 
    106115         
    107         $this->Subject->id = $id; 
     116        $this->Event->id = $id; 
    108117         
    109         $this->data = $this->Subject->read(); 
     118        $this->data = $this->Event->read(); 
    110119    } 
    111120    else 
     
    113122        $this->Sanitize = new Sanitize; 
    114123         
    115         $this->Sanitize->cleanArray($this->data["Subject"]); //Hopefully this is enough 
     124        $this->Sanitize->cleanArray($this->data["Event"]); //Hopefully this is enough 
    116125         
    117         if ($this->Subject->save($this->data['Subject'])) 
     126        if ($this->Event->save($this->data['Event'])) 
    118127        { 
    119128            $this->msgFlash('Your subject has been updated', '/admin/subjects/listing'); 
     
    125134  { 
    126135        // deletes task from database 
    127         $this->Subject->del($id); 
    128         $this->msgFlash('Subject has been deleted','/admin/subjects/listing'); 
     136        $this->Event->del($id); 
     137        $this->msgFlash('Event has been deleted','/admin/subjects/listing'); 
    129138  } 
    130139   
  • trunk/app/webroot/css/styles.css

    r34 r49  
    396396} 
    397397 
    398  
     398/* overall table */ 
     399#calendar table { 
     400border:1px solid #fff; 
     401padding: 0; 
     402margin:20px; 
     403} 
     404 
     405/* the day headers across the top */ 
     406#calendar th { 
     407background: #565; 
     408color: #fff; 
     409margin: 3px; 
     410padding: 2px 5px; 
     411} 
     412 
     413/* how days this month will look, make dates appear in top right */ 
     414#calendar td { 
     415background: #eee; 
     416color: #000; 
     417padding: 2px; 
     418margin:0; 
     419height:60px; 
     420text-align:right; 
     421vertical-align:top; 
     422border:1px solid #fff; 
     423} 
     424 
     425/* these are the days falling outside this month */ 
     426#calendar td.notInMonth { 
     427background: #999; 
     428} 
     429