Added the ability to edit a tender. I've locked this down to just editing the data1-4 fields at the moment, since there are accounting ramifications if we were to change the tender type.
git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716@519 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -163,16 +163,23 @@ class TendersController extends AppController {
|
||||
));
|
||||
|
||||
|
||||
// Set up dynamic menu items
|
||||
$this->sidemenu_links[] =
|
||||
array('name' => 'Operations', 'header' => true);
|
||||
|
||||
// Watch out for the special "Closing" entries
|
||||
if (!empty($tender['TenderType']['id']))
|
||||
$this->sidemenu_links[] =
|
||||
array('name' => 'Edit',
|
||||
'url' => array('action' => 'edit',
|
||||
$id));
|
||||
|
||||
if (!empty($tender['Tender']['deposit_transaction_id'])
|
||||
&& empty($tender['Tender']['nsf_transaction_id'])
|
||||
// Hard to tell what types of items can come back as NSF.
|
||||
// For now, assume iff it is a named item, it can be NSF.
|
||||
&& !empty($tender['TenderType']['data1_name'])
|
||||
) {
|
||||
// Set up dynamic menu items
|
||||
$this->sidemenu_links[] =
|
||||
array('name' => 'Operations', 'header' => true);
|
||||
|
||||
$this->sidemenu_links[] =
|
||||
array('name' => 'NSF',
|
||||
'url' => array('action' => 'nsf',
|
||||
@@ -183,4 +190,73 @@ class TendersController extends AppController {
|
||||
$title = "Tender #{$tender['Tender']['id']} : {$tender['Tender']['name']}";
|
||||
$this->set(compact('tender', 'title'));
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
**************************************************************************
|
||||
**************************************************************************
|
||||
* action: edit
|
||||
* - Edit tender information
|
||||
*/
|
||||
|
||||
function edit($id = null) {
|
||||
if (isset($this->data)) {
|
||||
// Check to see if the operation was cancelled.
|
||||
if (isset($this->params['form']['cancel'])) {
|
||||
if (empty($this->data['Tender']['id']))
|
||||
$this->redirect(array('action'=>'index'));
|
||||
|
||||
$this->redirect(array('action'=>'view', $this->data['Tender']['id']));
|
||||
}
|
||||
|
||||
// Make sure we have tender data
|
||||
if (empty($this->data['Tender']) || empty($this->data['Tender']['id']))
|
||||
$this->redirect(array('action'=>'index'));
|
||||
|
||||
// Figure out which tender type was chosen
|
||||
// REVISIT <AP>: 20090810; Not ready to change tender type
|
||||
// $tender_type_id = $this->data['Tender']['tender_type_id'];
|
||||
$tender_type_id = $this->Tender->field('tender_type_id');
|
||||
if (empty($tender_type_id))
|
||||
$this->redirect(array('action'=>'view', $this->data['Tender']['id']));
|
||||
|
||||
// Get data fields from the selected tender type
|
||||
$this->data['Tender'] += $this->data['type'][$tender_type_id];
|
||||
unset($this->data['type']);
|
||||
|
||||
// Save the tender and all associated data
|
||||
$this->Tender->create();
|
||||
$this->Tender->id = $this->data['Tender']['id'];
|
||||
if (!$this->Tender->save($this->data, false)) {
|
||||
$this->Session->setFlash("TENDER SAVE FAILED", true);
|
||||
pr("TENDER SAVE FAILED");
|
||||
}
|
||||
|
||||
$this->redirect(array('action'=>'view', $this->Tender->id));
|
||||
|
||||
// For debugging, only if the redirects above have been
|
||||
// commented out, otherwise this section isn't reached.
|
||||
$this->render('/fake');
|
||||
return;
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$this->data = $this->Tender->findById($id);
|
||||
} else {
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
|
||||
$tender_types = $this->Tender->TenderType->find
|
||||
('list', array('order' => array('name')));
|
||||
$this->set(compact('tender_types'));
|
||||
|
||||
$types = $this->Tender->TenderType->find('all', array('contain' => false));
|
||||
$this->set(compact('types'));
|
||||
|
||||
// Prepare to render.
|
||||
$title = ('Tender #' . $this->data['Tender']['id'] .
|
||||
' : ' . $this->data['Tender']['name'] .
|
||||
" : Edit");
|
||||
$this->set(compact('title'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user