-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathReservationLocationHelper.php
More file actions
92 lines (78 loc) · 2.28 KB
/
ReservationLocationHelper.php
File metadata and controls
92 lines (78 loc) · 2.28 KB
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
<?php
/**
* ReservationLocationHelper.php
*
* @author Ryuji AMANO <ryuji@ryus.co.jp>
* @link http://www.netcommons.org NetCommons Project
* @license http://www.netcommons.org/license.txt NetCommons License
*/
/**
* Reservation location Helper
*
* @author Ryuji AMANO <ryuji@ryus.co.jp>
* @package NetCommons\Reservations\View\Helper
* @SuppressWarnings(PHPMD)
*/
class ReservationLocationHelper extends AppHelper {
/**
* 使用するヘルパー
*
* @var array
*/
public $helpers = array(
'NetCommons.NetCommonsForm',
'Rooms.Rooms',
);
/**
* 予約できる権限チェックボックス表示
*
* @param string $model モデル名
* @param array $attributes Formヘルパーのオプション
* @return string HTML
*/
public function checkboxReservablePermission($model, $attributes = array()) {
$html = '';
if (! isset($this->_View->request->data[$model])) {
return $html;
}
$html .= '<div class="form-inline">';
foreach ($this->_View->request->data[$model] as $roleKey => $role) {
if (! $role['default'] && $role['fixed']) {
continue;
}
$html .= $this->__inputPermission($model, $roleKey, $attributes);
}
$html .= '</div>';
return $html;
}
/**
* 予約できる権限のチェックボックス表示
*
* @param string $model モデル名
* @param string $roleKey ロールキー
* @param array $attributes Formヘルパーのオプション
* @return string HTML
*/
private function __inputPermission($model, $roleKey, $attributes = array()) {
$html = '';
$html .= '<div class="checkbox checkbox-inline">';
$fieldName = $model . '.' . $roleKey;
if (! Hash::get($this->_View->request->data, $fieldName . '.fixed')) {
$html .= $this->NetCommonsForm->hidden($fieldName . '.id');
}
$options = Hash::merge(array(
'div' => false,
'disabled' => (bool)Hash::get($this->_View->request->data, $fieldName . '.fixed'),
), $attributes);
if (! $options['disabled']) {
$options['ng-click'] = 'clickRole($event, \'' . Inflector::variable($roleKey) . '\')';
}
$options['label'] = $this->Rooms->roomRoleName(
$roleKey, ['help' => true, 'roles' => $this->_View->viewVars['roles']]
);
$options['escape'] = false;
$html .= $this->NetCommonsForm->checkbox($fieldName . '.value', $options);
$html .= '</div>';
return $html;
}
}