-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnewEmptyPHP.php
111 lines (92 loc) · 2.55 KB
/
newEmptyPHP.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
App::uses('AppModel', 'Model');
/**
* SchoolYear Model
*
* @property Setting $Setting
* @property StudentRecordHeader $StudentRecordHeader
*/
class SchoolYear extends AppModel {
/**
* Display field
*
* @var string
*/
public $displayField = 'school_year';
/**
* Validation rules
*
* @var array
*/
public $validate = array(
'school_year' => array(
'notEmpty' => array(
'rule' => array('notEmpty'),
//'message' => 'Your custom message here',
//'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
'validSchoolYear' => array(
'rule' => '/^[0-9]{4}\-[0-9]{4}$/',
'message' => 'Pleas input a valid school year sample 2001-2002',
//'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
'mustNextShoolYear' => array(
'rule' => 'nextSchoolYear',
'message' => 'Pleas input a valid school year sample 2001-2002',
//'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
),
);
//The Associations below have been created with all possible keys, those that are not needed can be removed
/**
* hasMany associations
*
* @var array
*/
public $hasMany = array(
'Setting' => array(
'className' => 'Setting',
'foreignKey' => 'school_year_id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
),
'StudentRecordHeader' => array(
'className' => 'StudentRecordHeader',
'foreignKey' => 'school_year_id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
)
);
public function nextSchoolYear($check){
$currSY = $this->find('first',array('order'=>array('id'=>'desc')));
$currSY = explode('-',$currSY['school_year']);
$tmpCheck = explode('-',$check);
if(((int)$currSY[1] = $tmpCheck[0]) && ((int)$tmpCheck[1] == ((int)$currSY[1]+1) ) ){
return true;
}
return false;
}
}