public function damaged($id = null)
 {
     $this->layoutOpt['left_nav_selected'] = false;
     if (!empty($this->request->data)) {
         $this->request->data['ItemInventoryTransaction']['direction'] = 'out';
         $this->request->data['ItemInventoryTransaction']['item_id'] = $id;
         $this->request->data['ItemInventoryTransaction']['type'] = "damaged";
         $item = $this->Item->find("first", array("conditions" => array("Item.id" => $id)));
         $item['Item']['current_stock'] = $item['Item']['current_stock'] - $this->request->data['ItemInventoryTransaction']['count'];
         $item['Item']['id'] = $id;
         $this->Item->save($item);
         App::import('Model', 'Inventory.ItemInventoryTransaction');
         $iteminventorytransaction = new ItemInventoryTransaction();
         $inventory = $iteminventorytransaction->save($this->request->data);
         if ($inventory['ItemInventoryTransaction']['id']) {
             $this->Session->setFlash(SAVE_SUCCESS_MSG, "Messages/success");
             $this->redirect(array("controller" => "items", "action" => "detail", $id));
         } else {
             $this->Session->setFlash(SAVE_FAILED_MODAL_MSG, "Messages/failed");
             $this->redirect(array("controller" => "items", "action" => "detail", $id));
         }
     }
     $this->set(compact('id'));
 }
 /**
  * detail method
  *
  * @param string $id
  * @return void
  */
 public function detail_section($item_id = null, $section = null, $edit = true)
 {
     $this->layoutOpt['left_nav_selected'] = "view_item";
     $this->Item->id = $item_id;
     if (!$this->Item->exists()) {
         throw new NotFoundException(__('Invalid item'));
     }
     $item = $this->Item->read(null, $item_id);
     App::import('Model', 'Inventory.ItemInventoryTransaction');
     $itemInventoryTransactionModel = new ItemInventoryTransaction();
     $itemInventoryTransaction = $itemInventoryTransactionModel->find('all', array('conditions' => array('ItemInventoryTransaction.item_id' => $item_id)));
     $this->set(compact('item', 'itemInventoryTransaction', 'section', 'item_id', 'edit'));
 }