~mparic/+junk/openauctionlive

« back to all changes in this revision

Viewing changes to app/controllers/reports_controller.php

  • Committer: Michael Paric
  • Date: 2012-01-07 20:21:14 UTC
  • Revision ID: mparic@compbizsolutions.com-20120107202114-6q89jiel6y3rbwgc
Updated validation rules to prevent duplicate Bid and Bidder entries; updated return message color for successful form entry to differentiate from error; added simlink in img/ for image to be used in reports - just change what auction_logo.jpg points to instead of changing View code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 
4
4
        var $name = 'Reports';
5
5
  
6
 
  var $uses = array('Bidder','Item');
 
6
        var $uses = array('Bidder','Item');
7
7
 
8
8
        function index($event_id = null) {
9
9
          
10
 
    $event = $this->Bidder->Event->find('first',array('conditions' => array('Event.id' => (($event_id) ? $event_id : $this->Session->read('event_id')))));
11
 
    $this->set(compact('event')); 
 
10
        $event = $this->Bidder->Event->find('first',array('conditions' => array('Event.id' => (($event_id) ? $event_id : $this->Session->read('event_id')))));
 
11
        $this->set(compact('event')); 
12
12
 
13
13
        }
14
14
  
15
 
  function search() {
 
15
        function search() {
16
16
 
17
17
    if (!empty($this->data)) {
18
18
    
19
 
      $conditions = array ('OR' => array (
20
 
                        'Bidder.first_name LIKE' => '%' . $this->data['Report']['search_phrase'] . '%',
21
 
                        'Bidder.last_name LIKE' => '%' . $this->data['Report']['search_phrase'] . '%'
22
 
                        )
23
 
                      );
24
 
      $event = $this->Bidder->Event->find('first',array('conditions' => array('Event.id' => $this->Session->read('event_id'))));
25
 
      $this->Bidder->recursive = 0;
26
 
      $this->paginate = array('conditions' => $conditions,
27
 
                            'order' => array('Bidder.last_name' => 'asc'));
28
 
      $bidders = $this->paginate('Bidder');
29
 
      $this->set(compact('bidders','event'));            
30
 
 
31
 
    }
 
19
              $conditions = array ('OR' => array (
 
20
                                'Bidder.first_name LIKE' => '%' . $this->data['Report']['search_phrase'] . '%',
 
21
                                'Bidder.last_name LIKE' => '%' . $this->data['Report']['search_phrase'] . '%'
 
22
                                )
 
23
                              );
 
24
              $event = $this->Bidder->Event->find('first',array('conditions' => array('Event.id' => $this->Session->read('event_id'))));
 
25
              $this->Bidder->recursive = 0;
 
26
              $this->paginate = array('conditions' => $conditions,'order' => array('Bidder.last_name' => 'asc'));
 
27
              $bidders = $this->paginate('Bidder');
 
28
              $this->set(compact('bidders','event'));            
 
29
        
 
30
            }
32
31
    // Show blank form  
33
 
  }
 
32
        }
34
33
  
35
 
  function revenue_by_event($id=null) {
 
34
        function revenue_by_event($id=null) {
36
35
    
37
 
    if ($id) {
38
 
      
39
 
      $this->Item->order = array('ItemType.description ASC, Item.title ASC');
40
 
      $items = $this->Item->findAllByEventId($id);
41
 
      if ($items) {
42
 
        $event['Event'] = $items[0]['Event'];
43
 
        $this->set(compact('items','event'));
44
 
        $this->render('revenue_by_event','minimal');
45
 
      }
46
 
      else {
47
 
        $this->Session->setFlash(__('Not Items in this Event', true));
48
 
        $this->redirect(array('action' => 'index')); 
49
 
      }
50
 
      
51
 
    }
52
 
    else {
53
 
      $this->Session->setFlash(__('Invalid Event ID', true));
54
 
      $this->redirect(array('action' => 'index'));      
55
 
    }
56
 
  }
 
36
            if ($id) {        
 
37
              $this->Item->order = array('ItemType.description ASC, Item.title ASC');
 
38
              $items = $this->Item->findAllByEventId($id);
 
39
              if ($items) {
 
40
                $event['Event'] = $items[0]['Event'];
 
41
                $this->set(compact('items','event'));
 
42
                $this->render('revenue_by_event','minimal');
 
43
              }
 
44
              else {
 
45
                $this->Session->setFlash(__('No Items in this Event', true));
 
46
                $this->redirect(array('action' => 'index')); 
 
47
              }
 
48
              
 
49
            }
 
50
            else {
 
51
              $this->Session->setFlash(__('Invalid Event ID', true));
 
52
              $this->redirect(array('action' => 'index'));      
 
53
            }
 
54
        }
57
55
  
58
56
    function items_by_bid_winner($id=null) {
59
57
    
60
 
    if ($id) {
61
 
      
62
 
      $this->Bidder->recursive = 0;
63
 
      $this->Bidder->order = array('Bidder.last_name ASC, Bidder.first_name ASC');
64
 
      $bidders = $this->Bidder->findAllByEventId($id);
65
 
      $x=0;
66
 
      foreach ($bidders as $bidder) {
67
 
        $bids = $this->Bidder->Bid->findAllByBidderId($bidder['Bidder']['id']);
68
 
        $bidders[$x]['Bid'] = $bids;
69
 
        $x++;
70
 
      }
71
 
      //pr($bidders);exit();
72
 
      if ($bidders) {
73
 
        $event['Event'] = $bidders[0]['Event'];
74
 
        $this->set(compact('bidders','event'));
75
 
        $this->render('items_by_bid_winner','minimal');
76
 
      }
77
 
      else {
78
 
        $this->Session->setFlash(__('Not Bidders in this Event', true));
79
 
        $this->redirect(array('action' => 'index')); 
80
 
      }
81
 
      
82
 
    }
83
 
    else {
84
 
      $this->Session->setFlash(__('Invalid Event ID', true));
85
 
      $this->redirect(array('action' => 'index'));      
86
 
    }
87
 
  }
 
58
            if ($id) {
 
59
              
 
60
              $this->Bidder->recursive = 0;
 
61
              $this->Bidder->order = array('Bidder.last_name ASC, Bidder.first_name ASC');
 
62
              $bidders = $this->Bidder->findAllByEventId($id);
 
63
              $x=0;
 
64
              foreach ($bidders as $bidder) {
 
65
                $bids = $this->Bidder->Bid->findAllByBidderId($bidder['Bidder']['id']);
 
66
                $bidders[$x]['Bid'] = $bids;
 
67
                $x++;
 
68
              }
 
69
              //pr($bidders);exit();
 
70
              if ($bidders) {
 
71
                $event['Event'] = $bidders[0]['Event'];
 
72
                $this->set(compact('bidders','event'));
 
73
                $this->render('items_by_bid_winner','minimal');
 
74
              }
 
75
              else {
 
76
                $this->Session->setFlash(__('No Bidders in this Event', true));
 
77
                $this->redirect(array('action' => 'index')); 
 
78
              }
 
79
              
 
80
            }
 
81
            else {
 
82
              $this->Session->setFlash(__('Invalid Event ID', true));
 
83
              $this->redirect(array('action' => 'index'));      
 
84
            }
 
85
        }
88
86
 
89
87
        function print_booklet($id=null) {
90
 
    if ($id) {
91
 
      $items = $this->Item->find('all',array('conditions' => array('Item.event_id' => $id),
92
 
                                            'order' => array('ItemType.description' => 'DESC','Item.id' => 'ASC','Item.title' => 'ASC')));
93
 
      $this->set(compact('items'));
94
 
      $this->render('print_booklet','booklet');
95
 
        }
96
 
    else {
97
 
      $this->Session->setFlash(__('Invalid Event ID', true));
98
 
      $this->redirect(array('action' => 'index'));      
99
 
    }
100
 
  }
 
88
            if ($id) {
 
89
              $items = $this->Item->find('all',array('conditions' => array('Item.event_id' => $id),
 
90
                                                    'order' => array('ItemType.description' => 'DESC','Item.id' => 'ASC','Item.title' => 'ASC')));
 
91
              $this->set(compact('items'));
 
92
              $this->render('print_booklet','booklet');
 
93
                }
 
94
            else {
 
95
              $this->Session->setFlash(__('Invalid Event ID', true));
 
96
              $this->redirect(array('action' => 'index'));      
 
97
            }
 
98
         }
101
99
}
102
100
?>
 
 
b'\\ No newline at end of file'