~mparic/+junk/openauctionlive

« back to all changes in this revision

Viewing changes to app/controllers/bids_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:
18
18
 
19
19
        function add() {
20
20
                if (!empty($this->data)) {
21
 
                  // Is Item ID valid?
22
 
                  $validItem = $this->Bid->Item->find('first',array('conditions' => array('Item.id' => $this->data['Bid']['item_id'])));
23
 
                  // Is Bidder ID valid?
24
 
      $validBidder = $this->Bid->Bidder->find('first',array('conditions' => array('Bidder.id' => $this->data['Bid']['bidder_id'])));
25
 
      if ($validItem && $validBidder) {
26
 
        $this->Bid->create();
27
 
        if ($this->Bid->save($this->data)) {
28
 
          $this->Session->setFlash(__('The bid has been saved', true));
29
 
          $this->redirect(array('action' => 'add'));
30
 
        } else {
31
 
          $this->Session->setFlash(__('The bid could not be saved. Please, try again.', true));
32
 
        }
33
 
      }
34
 
      else {
35
 
        $this->Session->setFlash(__('Not a valid Bidder or Item. Please, try again.', true));
36
 
      }                         
37
 
                }
 
21
                $this->Bid->create();
 
22
                if ($this->Bid->save($this->data)) {
 
23
                        $this->Session->setFlash(__('The bid has been saved', true),'default', array('class'=>'success-message'));
 
24
                        $this->redirect(array('action' => 'add'));
 
25
                } else {
 
26
                $this->Session->setFlash(__('The bid could not be saved. Please, try again.', true));
 
27
                }
 
28
        }                       
38
29
        }
39
30
 
40
31
        function edit($id = null) {
44
35
                }
45
36
                if (!empty($this->data)) {
46
37
                        if ($this->Bid->save($this->data)) {
47
 
                                $this->Session->setFlash(__('The bid has been saved', true));
 
38
                                $this->Session->setFlash(__('The bid has been saved', true),'default', array('class'=>'success-message'));
48
39
                                $this->redirect(array('controller'=>'bidders','action' => 'view',$this->data['Bid']['bidder_id']));
49
40
                        } else {
50
41
                                $this->Session->setFlash(__('The bid could not be saved. Please, try again.', true));
67
58
                        $this->redirect(array('action'=>'index'));
68
59
                }
69
60
                if ($this->Bid->delete($id)) {
70
 
                        $this->Session->setFlash(__('Bid deleted', true));
 
61
                        $this->Session->setFlash(__('Bid deleted', true),'default', array('class'=>'success-message'));
71
62
                        $this->redirect(array('action'=>'index'));
72
63
                }
73
64
                $this->Session->setFlash(__('Bid was not deleted', true));