Skip to content

Commit

Permalink
Review Controller is now capable of adding customer and supplier
Browse files Browse the repository at this point in the history
  • Loading branch information
pHAlkaline committed Apr 26, 2016
1 parent 4a6b4d7 commit e0cdb66
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 2 deletions.
48 changes: 48 additions & 0 deletions app/Plugin/Phkapa/Controller/ReviewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,54 @@ public function close($id = null) {
$this->Flash->error(__d('phkapa', 'Could not be saved. Please, try again.'));
$this->redirect(array('action' => 'index'));
}

/**
* add_supplier
*
* @return void
* @access public
*/
public function add_supplier($id=null) {
if (!$id) {
$this->Flash->error(__d('phkapa', 'Invalid request.'));
$this->redirect(array('action' => 'index'));
}
if (!empty($this->request->data)) {
$this->Supplier=ClassRegistry::init('Phkapa.Supplier');
$this->request->data['Supplier']['active']=1;
$this->Supplier->create();
if ($this->Supplier->save($this->request->data)) {
$this->Flash->info(__d('phkapa', 'Saved with success.'));
$this->redirect(array('action' => 'edit',$id));
} else {
$this->Flash->error(__d('phkapa', 'Could not be saved. Please, try again.'));
}
}
}

/**
* add_customer
*
* @return void
* @access public
*/
public function add_customer($id=null) {
if (!$id) {
$this->Flash->error(__d('phkapa', 'Invalid request.'));
$this->redirect(array('action' => 'index'));
}
if (!empty($this->request->data)) {
$this->Customer=ClassRegistry::init('Phkapa.Customer');
$this->request->data['Customer']['active']=1;
$this->Customer->create();
if ($this->Customer->save($this->request->data)) {
$this->Flash->info(__d('phkapa', 'Saved with success.'));
$this->redirect(array('action' => 'edit',$id));
} else {
$this->Flash->error(__d('phkapa', 'Could not be saved. Please, try again.'));
}
}
}

/**
* Setup Ticket bind model associations
Expand Down
36 changes: 36 additions & 0 deletions app/Plugin/Phkapa/View/Review/add_customer.ctp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<h2 class="grid_16" id="page-heading"><?php echo __d('phkapa','Register').':'.__d('phkapa','Add %s', __d('phkapa','Customer')); ?></h2>
<div class="grid_16 actionsContainer">
<div class="grid_4" id="actions">

<h2>
<a href="#" id="toggle-admin-actions"><?php echo __d('phkapa','Menu'); ?></a>
</h2>
<div class="block" id="admin-actions">
<h5><?php echo __dn('phkapa','Ticket','Tickets',2); ?></h5>
<ul class="menu">
<li><?php echo $this->Html->link(__d('phkapa','List %s', __dn('phkapa','Ticket','Tickets',2)), array('action' => 'index')); ?></li>
<li><?php echo $this->Html->link(__d('phkapa', 'Add %s', __d('phkapa', 'Ticket')), array('action' => 'add')); ?></li>

</ul>


</div>

</div>



<div class="types form">
<?php echo $this->Form->create('Customer'); ?>
<fieldset class="ui-corner-all ui-widget-content" >
<legend><?php echo __d('phkapa','Record').' '. __d('phkapa','Customer'); ?></legend>
<?php
echo $this->Form->input('Customer.name',array('label' => __d('phkapa','Name')));
echo $this->Form->submit(__d('phkapa', 'Submit'));
?>
</fieldset>
<?php echo $this->Form->end(); ?>
</div>

</div>
<div class="clear"></div>
36 changes: 36 additions & 0 deletions app/Plugin/Phkapa/View/Review/add_supplier.ctp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<h2 class="grid_16" id="page-heading"><?php echo __d('phkapa','Register').':'.__d('phkapa','Add %s', __d('phkapa','Supplier')); ?></h2>
<div class="grid_16 actionsContainer">
<div class="grid_4" id="actions">

<h2>
<a href="#" id="toggle-admin-actions"><?php echo __d('phkapa','Menu'); ?></a>
</h2>
<div class="block" id="admin-actions">
<h5><?php echo __dn('phkapa','Ticket','Tickets',2); ?></h5>
<ul class="menu">
<li><?php echo $this->Html->link(__d('phkapa','List %s', __dn('phkapa','Ticket','Tickets',2)), array('action' => 'index')); ?></li>
<li><?php echo $this->Html->link(__d('phkapa', 'Add %s', __d('phkapa', 'Ticket')), array('action' => 'add')); ?></li>

</ul>


</div>

</div>



<div class="types form">
<?php echo $this->Form->create('Supplier'); ?>
<fieldset class="ui-corner-all ui-widget-content" >
<legend><?php echo __d('phkapa','Record').' '. __d('phkapa','Supplier'); ?></legend>
<?php
echo $this->Form->input('Supplier.name',array('label' => __d('phkapa','Name')));
echo $this->Form->submit(__d('phkapa', 'Submit'));
?>
</fieldset>
<?php echo $this->Form->end(); ?>
</div>

</div>
<div class="clear"></div>
18 changes: 16 additions & 2 deletions app/Plugin/Phkapa/View/Review/edit.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,22 @@ if ($ticket['Ticket']['approved'] === null) {
</div>
<?php
echo $this->Form->input('product',array('label' => __d('phkapa','Product')));
echo $this->Form->input('supplier_id', array('label' => __d('phkapa', 'Supplier'), 'empty' => __d('phkapa', '(choose one)')));
echo $this->Form->input('customer_id', array('label' => __d('phkapa', 'Customer'), 'empty' => __d('phkapa', '(choose one)')));
echo $this->Form->input('supplier_id', array(
'label' => __d('phkapa','Supplier'),
'empty' => __d('phkapa','(choose one)'),
'after'=>$this->Html->link(
__d('phkapa','Add %s', __d('phkapa','Supplier')),
array('action'=>'add_supplier',$ticket['Ticket']['id']),
array('style' => 'padding-left:10px;', 'id' => 'addSupplier')))
);
echo $this->Form->input('customer_id', array(
'label' => __d('phkapa','Customer'),
'empty' => __d('phkapa','(choose one)'),
'after'=>$this->Html->link(
__d('phkapa','Add %s', __d('phkapa','Customer')),
array('action'=>'add_customer',$ticket['Ticket']['id']),
array('style' => 'padding-left:10px;', 'id' => 'addCustomer')))
);
echo $this->Form->input('description', array('label' => __d('phkapa', 'Description')));
echo "<br/>";
echo $this->Form->input('priority_id', array('label' => __d('phkapa', 'Priority'), 'empty' => __d('phkapa', '(choose one)')));
Expand Down

0 comments on commit e0cdb66

Please sign in to comment.