PluginProbe
ShiftController Employee Shift Scheduling / 3.2.4
ShiftController Employee Shift Scheduling v3.2.4
4.9.97 4.9.96 4.9.95 4.9.74 4.9.75 4.9.76 4.9.77 4.9.78 4.9.84 4.9.85 4.9.87 4.9.91 4.9.92 trunk 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 3.2.4 All 38 releases
shiftcontroller / application / models / shift_template.php

shift_template.php in ShiftController Employee Shift Scheduling 3.2.4, at application/models/shift_template.php

43 lines 1021 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 class Shift_Template_HC_Model extends MY_model
3 {
4 /*
5 properties:
6 name
7 start
8 end
9 */
10
11 var $table = 'shift_templates';
12 var $default_order_by = array('start' => 'ASC');
13 var $validation = array(
14 'name' => array('required', 'trim', 'max_length' => 50, 'unique'),
15 'start' => array('required', 'trim'),
16 'end' => array('required', 'trim', 'differs' => 'start', 'check_break'),
17 'lunch_break' => array('check_break'),
18 );
19
20 public function get_duration( $use_break = TRUE )
21 {
22 if( $this->end > $this->start )
23 $return = $this->end - $this->start;
24 else
25 $return = $this->end + (24*60*60 - $this->start);
26
27 if( $use_break ){
28 if( isset($this->lunch_break) && $this->lunch_break ){
29 $return = $return - $this->lunch_break;
30 }
31 }
32 return $return;
33 }
34
35 public function _check_break( $field )
36 {
37 $return = ( $this->get_duration(FALSE) > $this->lunch_break ) ? TRUE : FALSE;
38 if( ! $return ){
39 $return = HCM::__('The break should not be longer than the shift itself');
40 }
41 return $return;
42 }
43 }