Ejemplo n.º 1
0
 public function index()
 {
     $flash = Flash::Instance();
     // Preserve any search criteria selection so that the context is maintained
     $s_data = array();
     if (isset($this->_data['id'])) {
         $s_data['wh_transfer_id'] = $this->_data['id'];
     }
     $this->view->set('clickaction', 'view');
     $whtransfer = new WHTransfer();
     $whtransfer->load($this->_data['id']);
     $this->view->set('whtransfer', $whtransfer);
     $from_store = WHLocation::getStoreLocation($whtransfer->from_whlocation_id);
     $this->view->set('from_store', $from_store);
     $to_store = WHLocation::getStoreLocation($whtransfer->to_whlocation_id);
     $this->view->set('to_store', $to_store);
     $this->setSearch('whtransfersSearch', 'useDefault', $s_data);
     parent::index(new WHTransferlineCollection($this->_templateobject));
     $sidebar = new SidebarController($this->view);
     $sidebarlist = array();
     $sidebarlist['all'] = array('tag' => 'View All Transfers', 'link' => array_merge($this->_modules, array('controller' => 'WHTransfers', 'action' => 'index')));
     if ($whtransfer->awaitingTransfer()) {
         $sidebarlist['edit'] = array('tag' => 'Edit this Transfer', 'link' => array_merge($this->_modules, array('controller' => 'WHTransfers', 'action' => 'edit', 'id' => $whtransfer->id)));
         $sidebarlist['cancel'] = array('tag' => 'Cancel this Transfer', 'link' => array_merge($this->_modules, array('controller' => 'WHTransfers', 'action' => 'cancel', 'id' => $whtransfer->id)));
     }
     $sidebar->addList('Actions', $sidebarlist);
     $this->view->register('sidebar', $sidebar);
     $this->view->set('sidebar', $sidebar);
 }
Ejemplo n.º 2
0
 public function view()
 {
     $flash = Flash::Instance();
     // Preserve any search criteria selection so that the context is maintained
     $s_data = array();
     if (isset($this->_data['id'])) {
         $s_data['wh_transfer_id'] = $this->_data['id'];
     }
     $whtransfer = new WHTransfer();
     $whtransfer->load($this->_data['id']);
     $this->view->set('whtransfer', $whtransfer);
     $from_store = WHLocation::getStoreLocation($whtransfer->from_whlocation_id);
     $this->view->set('from_store', $from_store);
     $to_store = WHLocation::getStoreLocation($whtransfer->to_whlocation_id);
     $this->view->set('to_store', $to_store);
     $this->setSearch('whtransfersSearch', 'useDefault', $s_data);
     parent::index(new WHTransferlineCollection($this->_templateobject));
     $sidebar = new SidebarController($this->view);
     $sidebarlist = array();
     $sidebarlist['awaiting'] = array('link' => array_merge($this->_modules, array('controller' => 'WHTransfers', 'action' => 'selectWHTransfers')), 'tag' => 'View Transfers Awaiting Despatch');
     $sidebarlist['completed'] = array('link' => array_merge($this->_modules, array('controller' => 'WHTransfers', 'action' => 'viewWHTransfers')), 'tag' => 'View Completed Transfers');
     if ($whtransfer->awaitingTransfer()) {
         $sidebarlist['edit'] = array('link' => array_merge($this->_modules, array('controller' => 'WHTransfers', 'action' => 'transferStock', 'id' => $whtransfer->id)), 'tag' => 'Action this Transfer');
     }
     if ($whtransfer->transferred()) {
         $sidebarlist['edit'] = array('link' => array_merge($this->_modules, array('controller' => 'WHTransfers', 'action' => 'printaction', 'printaction' => 'printTransferNote', 'filename' => 'WHT' . $whtransfer->transfer_number, 'id' => $whtransfer->id)), 'tag' => 'Reprint Transfer Note');
     }
     $sidebar->addList('Actions', $sidebarlist);
     $this->view->register('sidebar', $sidebar);
     $this->view->set('sidebar', $sidebar);
 }
Ejemplo n.º 3
0
 public function printTransferNote()
 {
     $flash = Flash::Instance();
     if (isset($this->_data['cancel'])) {
         $flash->addMessage('Print Despatch Note Canceled');
         sendBack();
     }
     $whtransfer = new WHTransfer();
     $whtransfer->load($this->_data['id']);
     $report = new WarehouseTransfer($whtransfer);
     $errors = array();
     if ($report->setPrintParams($this->_data, $errors)) {
         if ($report->constructPrint()) {
             $flash->addMessage('Print Warehouse Transfer Note Completed');
         } else {
             $flash->addError('Print Warehouse Transfer Note Failed');
         }
     } else {
         $flash->addErrors($errors);
     }
     sendTo($this->name, 'selectwhtransfers', $this->_modules);
 }
Ejemplo n.º 4
0
 public function save()
 {
     $flash = Flash::Instance();
     if (strtolower($this->_data['saveform']) == 'cancel') {
         $flash->addMessage('Action cancelled');
         sendTo($this->name, 'index', $this->_modules);
     }
     $errors = array();
     $db = DB::Instance();
     $db->StartTrans();
     $header_data = $this->_data['WHTransfer'];
     $lines_data = array();
     if (isset($this->_data['WHTransferLine'])) {
         $lines_data = $this->_data['WHTransferLine'];
         $lines_data = DataObjectCollection::joinArray($lines_data);
     } else {
         $errors[] = 'No Transfer Lines entered';
     }
     if (isset($header_data['id']) && $header_data['id'] != '') {
         $action = 'updated';
         // delete any lines not submitted
         $update = array();
         foreach ($lines_data as $line) {
             $update[$line['id']] = $line['id'];
         }
         $whtransfer = new WHTransfer();
         $whtransfer->load($header_data['id']);
         if ($whtransfer) {
             foreach ($whtransfer->transfer_lines as $line) {
                 if (!isset($update[$line->id])) {
                     $whtransferline = new WHTransferline();
                     $whtransferline->delete($line->id);
                 }
             }
         }
     } else {
         $action = 'added';
     }
     $whtransfer = WHTransfer::Factory($header_data, $lines_data, $errors);
     if ($whtransfer && count($errors) == 0) {
         $whtransfer->save($errors);
     }
     if (count($errors) == 0 && $db->CompleteTrans()) {
         $flash->addMessage('Transfer Number ' . $whtransfer->transfer_number . ' ' . $action . ' successfully');
         sendTo($this->name, 'index', $this->_modules);
     } else {
         $db->FailTrans();
         $flash->addErrors($errors);
         $this->_new();
         $this->_templateName = $this->getTemplateName('new');
     }
 }