public function getTransferDetails($_whaction_id = '')
 {
     // Used by Ajax to get the From/To Locations/Bins based on Stock Item
     if (isset($this->_data['ajax'])) {
         if (!empty($this->_data['entry_point'])) {
             $_entry_point = $this->_data['entry_point'];
         }
         if (!empty($this->_data['whaction_id'])) {
             $_whaction_id = $this->_data['whaction_id'];
         }
         if (!empty($this->_data['stitem_id'])) {
             $_stitem_id = $this->_data['stitem_id'];
         }
         if (!empty($this->_data['from_whlocation_id'])) {
             $_from_location_id = $this->_data['from_whlocation_id'];
         }
         if (!empty($this->_data['from_whbin_id'])) {
             $_from_bin_id = $this->_data['from_whbin_id'];
         }
         if (!empty($this->_data['to_whlocation_id'])) {
             $_to_location_id = $this->_data['to_whlocation_id'];
         }
     } else {
         // if this is Save and Add Another then need to get $_POST values to set context
         $_stitem_id = isset($_POST[$this->modeltype]['stitem_id']) ? $_POST[$this->modeltype]['stitem_id'] : '';
         $_from_location_id = isset($_POST[$this->modeltype]['from_whlocation_id']) ? $_POST[$this->modeltype]['from_whlocation_id'] : '';
     }
     //		echo '$_stitem_id='.$_stitem_id.'<br>';
     // store the ajax status in a different var, then unset the current one
     // we do this because we don't want the functions we all to get confused
     $ajax = isset($this->_data['ajax']);
     unset($this->_data['ajax']);
     // ****************************************************************************
     // Get the To Locations for the selected action
     $from_locations = $this->getFromLocations($_whaction_id);
     $from_whlocation_ids = array_keys($from_locations);
     if (empty($_entry_point) || $_entry_point == $this->modeltype . '_stitem_id') {
         $this->view->set('from_locations', $from_locations);
         if (empty($_from_location_id)) {
             $_from_location_id = key($from_locations);
         }
         $this->view->set('from_whlocation', $from_locations[$_from_location_id]);
         $output['from_whlocation_id'] = array('data' => $from_locations, 'is_array' => is_array($from_locations));
     } elseif (empty($_from_location_id)) {
         $_from_location_id = key($from_locations);
     }
     $this->view->set('from_whlocation_id', $_from_location_id);
     //		echo '$_from_location_id='.$_from_location_id.'<br>';
     $from_location = new WHLocation();
     $from_location->load($_from_location_id);
     // ****************************************************************************
     // Get the Stock Item list if no stock item is selected
     $stitem = new STItem();
     if (empty($_entry_point)) {
         // No item selected so get list of items and set default as first in list
         $stock_items = array();
         if ($from_location->haveBalances($from_whlocation_ids)) {
             $stock_items = STBalance::getStockList($from_whlocation_ids);
         } else {
             $stock_items = $stitem->getAll();
         }
         if (empty($_stitem_id)) {
             $_stitem_id = key($stock_items);
         }
         $this->view->set('stock_item', $stock_items[$_stitem_id]);
         $this->view->set('stock_items', $stock_items);
         $output['stitem_id'] = array('data' => $stock_items, 'is_array' => is_array($stock_items));
     }
     if (empty($_entry_point) || $_entry_point == $this->modeltype . '_stitem_id') {
         $_entry_point = $this->modeltype . '_from_whlocation_id';
     }
     //		echo '$_stitem_id='.$_stitem_id.'<br>';
     $stitem->load($_stitem_id);
     $this->view->set('stitem_id', $_stitem_id);
     $this->view->set('uom', $stitem->uom_name);
     $output['uom_id'] = array('data' => $stitem->uom_name, 'is_array' => is_array($stitem->uom_name));
     // ****************************************************************************
     // Get the list of bins for the To Location if it is bin controlled
     if ($_entry_point == $this->modeltype . '_from_whlocation_id') {
         $from_bins = array();
         if ($from_location->isBinControlled()) {
             $from_bins = $stitem->getBinList($_from_location_id);
             $this->view->set('from_bins', $from_bins);
             // check if the input bin present and exists in the bin list
             // if not, check for an error (exists in post data)
             // then check if in bin list; if not, use first in bin list
             if (empty($_from_bin_id) || !isset($from_bins[$_from_bin_id])) {
                 if (isset($_POST[$this->modeltype]['from_whbin_id'])) {
                     $_from_bin_id = $_POST[$this->modeltype]['from_whbin_id'];
                     if (!isset($from_bins[$_from_bin_id])) {
                         $_from_bin_id = key($from_bins);
                     }
                 } else {
                     $_from_bin_id = key($from_bins);
                 }
             }
         } else {
             $_from_bin_id = '';
         }
         $output['from_whbin_id'] = array('data' => $from_bins, 'is_array' => is_array($from_bins));
     }
     //echo 'SttransactionsController::getTransferDetails bins<pre>'.print_r($from_bins,true).'</pre><br>';
     // ****************************************************************************
     // Get the balance of the selected Item for the selected From Location/Bin
     if ($from_location->isBalanceEnabled()) {
         $balance = $this->getBalance($_stitem_id, $_from_location_id, $_from_bin_id);
         $this->view->set('balance', $balance);
         $output['balance'] = array('data' => $balance, 'is_array' => is_array($balance));
     } else {
         $output['balance'] = '';
     }
     // ****************************************************************************
     // get the associated 'To Location' values for the selected from location
     if ($_entry_point == $this->modeltype . '_from_whlocation_id') {
         $to_locations = $this->getToLocations($_from_location_id, $_whaction_id);
         $this->view->set('to_locations', $to_locations);
         $this->view->set('to_whlocation', $to_locations[$_to_location_id]);
         //			if (empty($_to_location_id)) {
         $_to_location_id = key($to_locations);
         //			}
         $output['to_whlocation_id'] = array('data' => $to_locations, 'is_array' => is_array($to_locations));
         $_entry_point = $this->modeltype . '_to_whlocation_id';
     }
     $this->view->set('to_whlocation_id', $_to_location_id);
     $to_location = new WHLocation();
     $to_location->load($_to_location_id);
     // ****************************************************************************
     // Get the bin list for the To Location if it is bin controlled
     if ($_entry_point == $this->modeltype . '_to_whlocation_id') {
         $to_bins = array();
         if ($to_location->isBinControlled()) {
             $to_bins = $this->getBinList($_to_location_id);
             $this->view->set('to_bins', $to_bins);
         }
         $output['to_whbin_id'] = array('data' => $to_bins, 'is_array' => is_array($to_bins));
     }
     if ($ajax) {
         $this->view->set('data', $output);
         $this->setTemplateName('ajax_multiple');
     }
 }