~mparic/+junk/openauctionlive

« back to all changes in this revision

Viewing changes to app/controllers/vendors_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 = 'Vendors';
5
5
 
6
 
  function beforeRender(){
7
 
    
8
 
    $this->set('navigation','main_nav_' . $this->Auth->user('role'));
9
 
    
10
 
    $this->set('subNavigation','vendors_' . $this->Auth->user('role'));
11
 
    
12
 
  }
 
6
        function beforeRender(){    
 
7
        $this->set('navigation','main_nav_' . $this->Auth->user('role'));    
 
8
        $this->set('subNavigation','vendors_' . $this->Auth->user('role'));    
 
9
        }
13
10
  
14
11
        function index() {
15
12
                $this->Vendor->recursive = 0;
25
22
        }
26
23
 
27
24
        function add() {
28
 
          $this->isAuthorized();
 
25
                $this->isAuthorized();
29
26
                if (!empty($this->data)) {
30
27
                        $this->Vendor->create();
31
 
      $this->data['Vendor']['phone'] = preg_replace('/[[:punct:]]|[[:space:]]/','',$this->data['Vendor']['phone']);
 
28
                $this->data['Vendor']['phone'] = preg_replace('/[[:punct:]]|[[:space:]]/','',$this->data['Vendor']['phone']);
32
29
                        if ($this->Vendor->save($this->data)) {
33
 
                                $this->Session->setFlash(__('The vendor has been saved. Add Item for this Vendor', true));
 
30
                                $this->Session->setFlash(__('The vendor has been saved. Add Item for this Vendor', true),'default', array('class'=>'success-message'));
34
31
                                $this->redirect(array('controller' => 'items','action' => 'add',$this->Vendor->id));
35
32
                        } else {
36
33
                                $this->Session->setFlash(__('The vendor could not be saved. Please, try again.', true));
39
36
        }
40
37
 
41
38
        function edit($id = null) {
42
 
          $this->isAuthorized();
 
39
                $this->isAuthorized();
43
40
                if (!$id && empty($this->data)) {
44
41
                        $this->Session->setFlash(__('Invalid vendor', true));
45
42
                        $this->redirect(array('action' => 'index'));
47
44
                if (!empty($this->data)) {
48
45
                  $this->data['Vendor']['phone'] = preg_replace('/[[:punct:]]|[[:space:]]/','',$this->data['Vendor']['phone']);
49
46
                        if ($this->Vendor->save($this->data)) {
50
 
                                $this->Session->setFlash(__('The vendor has been saved', true));
 
47
                                $this->Session->setFlash(__('The vendor has been saved', true),'default', array('class'=>'success-message'));
51
48
                                $this->redirect(array('action' => 'index'));
52
49
                        } else {
53
50
                                $this->Session->setFlash(__('The vendor could not be saved. Please, try again.', true));
65
62
                        $this->redirect(array('action'=>'index'));
66
63
                }
67
64
                if ($this->Vendor->delete($id)) {
68
 
                        $this->Session->setFlash(__('Vendor deleted', true));
 
65
                        $this->Session->setFlash(__('Vendor deleted', true),'default', array('class'=>'success-message'));
69
66
                        $this->redirect(array('action'=>'index'));
70
67
                }
71
68
                $this->Session->setFlash(__('Vendor was not deleted', true));