/**
  * Form for displaying and merging duplicate clients
  *
  * @return array|\Zend\Http\Response array(form) or Redirect response
  */
 public function manageAction()
 {
     if ($this->getRequest()->isPost()) {
         $this->_showDuplicates->setData($this->params()->fromPost());
         if ($this->_showDuplicates->isValid()) {
             $data = $this->_showDuplicates->getData();
             $this->_duplicates->merge($data['clients'], $data['mergeCustomFields'], $data['mergeGroups'], $data['mergePackages']);
             $this->flashMessenger()->addSuccessMessage('The selected clients have been merged.');
             return $this->redirectToRoute('duplicates', 'index');
         }
     }
     $this->setActiveMenu('Inventory', 'Duplicates');
     $ordering = $this->getOrder('Id', 'asc');
     $clients = $this->_duplicates->find($this->params()->fromQuery('criteria'), $ordering['order'], $ordering['direction']);
     $this->_showDuplicates->setOptions(array('clients' => $clients, 'order' => $ordering['order'], 'direction' => $ordering['direction']));
     return array('form' => $this->_showDuplicates);
 }