4
4
var $name = 'Bidders';
6
var $components = array('DataHandler','ForceDownload');
6
var $components = array('DataHandler','ForceDownload');
9
$event = $this->Bidder->Event->find('first',array('conditions' => array('Event.id' => $this->Session->read('event_id'))));
9
$event = $this->Bidder->Event->find('first',array('conditions' => array('Event.id' => $this->Session->read('event_id'))));
10
10
$this->Bidder->recursive = 0;
11
$this->paginate = array('conditions' => array('Bidder.event_id' => $this->Session->read('event_id')),
12
'order' => array('Bidder.last_name' => 'asc'));
13
$bidders = $this->paginate('Bidder');
14
$this->set(compact('bidders','event'));
11
$this->paginate = array('conditions' => array('Bidder.event_id' => $this->Session->read('event_id')),
12
'order' => array('Bidder.last_name' => 'asc'));
13
$bidders = $this->paginate('Bidder');
14
$this->set(compact('bidders','event'));
17
17
function view($id = null) {
19
19
$this->Session->setFlash(__('Invalid bidder', true));
20
20
$this->redirect(array('action' => 'index'));
22
$this->Bidder->unbindModel(
23
array('belongsTo' => array('Event'))
22
$this->Bidder->unbindModel(array('belongsTo' => array('Event')));
26
$this->Bidder->recursive = 2;
27
$bidder = $this->Bidder->read(null, $id);
29
$this->Session->setFlash(__('Invalid Bidder ID', true));
30
$this->redirect(array('action' => 'index'));
24
$this->Bidder->recursive = 2;
25
$bidder = $this->Bidder->read(null, $id);
27
$this->Session->setFlash(__('Invalid Bidder ID', true));
28
$this->redirect(array('action' => 'index'));
33
31
$this->set('bidder', $bidder);
37
35
if (!empty($this->data)) {
38
$this->data['Bidder']['event_id'] = $this->Session->read('event_id');
39
$this->data['Bidder']['phone'] = preg_replace('/[[:punct:]]|[[:space:]]/','',$this->data['Bidder']['phone']);
36
$this->data['Bidder']['event_id'] = $this->Session->read('event_id');
37
$this->data['Bidder']['phone'] = preg_replace('/[[:punct:]]|[[:space:]]/','',$this->data['Bidder']['phone']);
40
38
$this->Bidder->create();
41
39
if ($this->Bidder->save($this->data)) {
42
$this->Session->setFlash(__('The bidder has been saved - ' . $this->data['Bidder']['first_name'] . ' ' . $this->data['Bidder']['last_name'] . ' ID: ' . $this->Bidder->id, true));
40
$this->Session->setFlash(__('The bidder has been saved - ' . $this->data['Bidder']['first_name'] . ' ' .
41
$this->data['Bidder']['last_name'] . ' ID: ' . $this->Bidder->id, true),'default', array('class'=>'info-message'));
44
43
$this->redirect(array('action' => 'add'));
46
45
$this->Session->setFlash(__('The bidder could not be saved. Please, try again.', true));
49
$event = $this->Bidder->Event->find('first',array('conditions' => array('Event.id' => $this->Session->read('event_id'))));
50
$this->set(compact('event'));
48
$event = $this->Bidder->Event->find('first',array('conditions' => array('Event.id' => $this->Session->read('event_id'))));
49
$this->set(compact('event'));
53
52
function edit($id = null) {
58
57
if (!empty($this->data)) {
59
58
$this->data['Bidder']['phone'] = preg_replace('/[[:punct:]]|[[:space:]]/','',$this->data['Bidder']['phone']);
60
if ($this->Bidder->save($this->data)) {
61
$this->Session->setFlash(__('The bidder has been saved', true));
59
if ($this->Bidder->save($this->data)) {
60
$this->Session->setFlash(__('The bidder has been saved', true),'default', array('class'=>'success-message'));
62
61
$this->redirect(array('action' => 'index'));
64
63
$this->Session->setFlash(__('The bidder could not be saved. Please, try again.', true));
82
81
$this->redirect(array('action'=>'index'));
84
83
if ($this->Bidder->delete($id)) {
85
$this->Session->setFlash(__('Bidder deleted', true));
84
$this->Session->setFlash(__('Bidder deleted', true),'default', array('class'=>'success-message'));
86
85
$this->redirect(array('action'=>'index'));
88
87
$this->Session->setFlash(__('Bidder was not deleted', true));
89
88
$this->redirect(array('action' => 'index'));
92
function print_receipt($id = null) {
94
$this->Session->setFlash(__('Invalid bidder', true));
95
$this->redirect(array('action' => 'index'));
91
function print_receipt($id = null) {
93
$this->Session->setFlash(__('Invalid bidder', true));
94
$this->redirect(array('action' => 'index'));
98
$this->Bidder->unbindModel(
99
array('belongsTo' => array('Event'))
101
$this->Bidder->recursive = 2;
102
$bidder = $this->Bidder->read(null, $id);
104
$this->Session->setFlash(__('Invalid Bidder ID', true));
105
$this->redirect(array('action' => 'index'));
107
$this->Bidder->Event->recursive = -1;
108
$event = $this->Bidder->Event->findById($bidder['Bidder']['event_id']);
110
$this->set(compact('bidder','event'));
111
$this->render('print_receipt', 'minimal');
97
$this->Bidder->unbindModel(
98
array('belongsTo' => array('Event'))
100
$this->Bidder->recursive = 2;
101
$bidder = $this->Bidder->read(null, $id);
103
$this->Session->setFlash(__('Invalid Bidder ID', true));
104
$this->redirect(array('action' => 'index'));
106
$this->Bidder->Event->recursive = -1;
107
$event = $this->Bidder->Event->findById($bidder['Bidder']['event_id']);
109
$this->set(compact('bidder','event'));
110
$this->render('print_receipt', 'minimal');
114
function export_csv() {
116
$this->Bidder->recursive = -1;
117
$params = array('conditions' => array('Bidder.event_id' => $this->Session->read('event_id')),
118
'order' => array('Bidder.last_name' => 'asc'));
119
$bidders = $this->Bidder->find('all',$params);
121
$fieldNames = array_keys($bidders[0]['Bidder']);
122
$csv_data = $this->DataHandler->createCSV($bidders,$fieldNames);
123
$this->ForceDownload->forceDownloadStream($csv_data,'csv','bidder_list.csv');
113
function export_csv() {
115
$this->Bidder->recursive = -1;
116
$params = array('conditions' => array('Bidder.event_id' => $this->Session->read('event_id')),
117
'order' => array('Bidder.last_name' => 'asc'));
118
$bidders = $this->Bidder->find('all',$params);
120
$fieldNames = array_keys($bidders[0]['Bidder']);
121
$csv_data = $this->DataHandler->createCSV($bidders,$fieldNames);
122
$this->ForceDownload->forceDownloadStream($csv_data,'csv','bidder_list.csv');
b'\\ No newline at end of file'