· 8 years ago · Mar 17, 2018, 01:12 PM
1DatesController.php
2
3 public function add($sid = null) {
4 if($this->request->is('post')) {
5 if($this->Date->save($this->request->data)) {
6 $this->Session->setFlash('Dates Saved!');
7 $this->redirect(array('action' => 'school', $sid));
8 }
9 }
10 $this->set('schoolid', $sid);
11 }
12
13Date.php
14
15<?php
16class Date extends AppModel {
17 public $name = 'Date';
18}
19
20add.ctp
21
22<?php
23echo $this->Html->script(array(
24 'dhtmlxCalendar/dhtmlxcalendar.js'
25 ));
26echo $this->Html->css(array('dhtmlxCalendar/dhtmlxcalendar.css', 'dhtmlxCalendar/skins/dhtmlxcalendar_dhx_skyblue.css'));
27?>
28<div style="position:relative;height:380px;">
29<?php echo $this->Form->create('Dates'); ?>
30<?php echo $this->Form->input('schoolid', array('value' => $schoolid, 'type' => 'hidden')); ?>
31<?php echo $this->Form->input('grade', array('options' => array('5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => '10', '11' => '11', '12' => '12'))); ?>
32<?php echo $this->Form->input('startreg', array('label' => 'Start Registration Date')); ?>
33<?php echo $this->Form->input('endreg', array('label' => 'End Registration Date')); ?>
34<?php echo $this->Form->input('lottery', array('label' => 'Lottery Date')); ?>
35<?php echo $this->Form->end('Save Dates'); ?>
36</div>
37<?php echo $this->Html->script(array('Schools/add.js')); ?>
38
39dates MySQL table
40
41
42
43CREATE TABLE IF NOT EXISTS `dates` (
44 `id` int(10) NOT NULL AUTO_INCREMENT,
45 `schoolid` int(2) NOT NULL,
46 `grade` int(2) NOT NULL,
47 `startreg` datetime NOT NULL,
48 `endreg` datetime NOT NULL,
49 `lottery` datetime NOT NULL,
50 PRIMARY KEY (`id`)
51) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;