-
Notifications
You must be signed in to change notification settings - Fork 2
/
booking_timeslots.booking.controller.inc
103 lines (89 loc) · 2.31 KB
/
booking_timeslots.booking.controller.inc
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
<?php
/**
* @file
*/
/**
*
*/
class Booking extends Entity {
public
$cid,
$created,
$uid,
$primary_id,
$secondary_id,
$tertiary_id,
$quaternary_id,
$slot_time,
$duration,
$players,
$total,
$deposit,
$tax,
$notes;
/**
*
*/
public function __construct($values = array()) {
// Following construction mean that the booking_timeslots_booking_* handlers will be used to manage this entity.
parent::__construct($values, 'booking');
}
}
/**
*
*/
class BookingController extends EntityAPIControllerExportable {
/**
*
*/
public function create(array $values = array()) {
$values === NULL ?: $values = array();
$values += array(
'created' => REQUEST_TIME,
// 'slot_time' => date('Y-' . sprintf("%02s", rand(1, 12)) . '-' . sprintf("%02s", rand(1, 28)) . ' ' . sprintf("%02s", rand(0, 23)) . ':' . sprintf("%02s", rand(0, 59)) . ':' . sprintf("%02s", rand(0, 59))),.
);
// var_dump($_POST);
return parent::create($values);
}
/**
*
*/
public function buildContent($entity, $view_mode = 'full', $langcode = NULL, $content = array()) {
$wrapper = entity_metadata_wrapper('booking', $entity);
return parent::buildContent($entity, $view_mode, $langcode, $content);
}
/**
* Protected function buildQuery($ids, $conditions = array(), $revision_id = FALSE) {
* Ensure that uid is taken from the {node} table,
* alias timestamp to revision_timestamp and add revision_uid.
* $query = parent::buildQuery($ids, $conditions, $revision_id);
* $fields =& $query->getFields();
* $query->addField('revision', 'timestamp', 'revision_timestamp');
* $fields['uid']['table'] = 'base';
* $query->addField('revision', 'uid', 'revision_uid');
* return $query;
* }.
*/
public function load($ids = array(), $conditions = array()) {
return parent::load($ids, $conditions);
}
/**
*
*/
public function save($entity, DatabaseTransaction $transaction = NULL) {
return parent::save($entity, $transaction);
}
}
/**
*
*/
class BookingUIController extends EntityDefaultUIController {
/**
* Overrides hook_menu() defaults.
*/
public function hook_menu() {
$items = parent::hook_menu();
$items[$this->path]['description'] = 'Manage bookings.';
return $items;
}
}