コード例 #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);
 }
コード例 #2
0
 public function save()
 {
     $flash = Flash::Instance();
     $errors = array();
     $data = $this->_data[$this->modeltype];
     $obj = '';
     if (!empty($data['task_id'])) {
         $obj = new Task();
         $obj->load($data['task_id']);
     } elseif (!empty($data['project_id'])) {
         $obj = new Project();
         $obj->load($data['project_id']);
     }
     if ($obj instanceof DataObject && $obj->isLoaded()) {
         if (fix_date($data['start_date']) < $obj->start_date) {
             $errors['start_date'] = 'Start date before ' . get_class($obj) . ' start date';
         }
         if (fix_date($data['end_date']) > $obj->end_date) {
             $errors['end_date'] = 'End date after ' . get_class($obj) . ' end date';
         }
     }
     if (!empty($data['person_id']) && $data['quantity'] > 1) {
         $errors['person_id'] = 'Quantity must be 1 for a person';
     }
     if (count($errors) == 0 && parent::save($this->modeltype, '', $errors)) {
         sendBack();
     } else {
         $flash->addErrors($errors);
         $this->refresh();
     }
 }
コード例 #3
0
 function populate()
 {
     if (!isModuleAdmin()) {
         $flash = Flash::Instance();
         $flash->addError('You don\'t have permission to view the Sales Team summary EGlets');
         $this->should_render = false;
         return false;
     }
     $db =& DB::Instance();
     $query = 'SELECT s.id,s.name FROM opportunitystatus s WHERE usercompanyid=' . $db->qstr(EGS_COMPANY_ID) . ' ORDER BY position DESC';
     $statuses = $db->GetAssoc($query);
     $query = 'SELECT DISTINCT assigned FROM opportunities o WHERE o.usercompanyid=' . EGS_COMPANY_ID . ' AND extract(\'' . $this->timeframe . '\' FROM o.enddate)=extract(\'' . $this->timeframe . '\' FROM now())';
     $users = $db->GetCol($query);
     $options = array();
     foreach ($users as $username) {
         if (empty($username)) {
             continue;
         }
         $data = array();
         foreach ($statuses as $id => $status) {
             $query = 'SELECT COALESCE(sum(cost),0) FROM opportunities o WHERE o.assigned=' . $db->qstr($username) . ' AND o.status_id=' . $db->qstr($id) . ' AND o.usercompanyid=' . EGS_COMPANY_ID . ' AND extract(\'' . $this->timeframe . '\' FROM o.enddate)=extract(\'' . $this->timeframe . '\' FROM now())';
             $data['x'][] = $status;
             $data['y'][] = (double) $db->GetOne($query);
         }
         $options['seriesList'][] = array('label' => $username, 'legendEntry' => TRUE, 'data' => $data);
     }
     if (!isset($options['seriesList']) || empty($options['seriesList'])) {
         return false;
     }
     $options['type'] = 'bar';
     $options['identifier'] = __CLASS__ . $this->timeframe;
     $this->contents = json_encode($options);
 }
コード例 #4
0
 public function save()
 {
     $flash = Flash::Instance();
     $errors = array();
     $partyaddress = $this->_uses[$this->modeltype];
     if (!empty($this->_data[$this->modeltype][$partyaddress->idField])) {
         // This is an update to an existing party address/address
         // so check if the address is used by other parties
         // - update it if address is only used by this party
         // - insert it if the current address is used by other parties and it does not already exist
         // - otherwise, no need to do anything here (but see below)
         if ($partyaddress->load($this->_data[$this->modeltype][$partyaddress->idField])) {
             $partyaddress->checkAddress($this->_data);
         } else {
             $errors[] = 'Error loading current Address details ' . $db->errorMsg();
         }
     }
     if (isset($this->_data['Address'])) {
         // Check if this address exists; if it does, point the PartyAddress to it
         // and remove the input address as it does not need inserting/updating
         $address = DataObjectFactory::Factory('Address');
         $address->check_exists($this->_data['Address']);
         if ($address->isLoaded()) {
             unset($this->_data['Address']);
             $this->_data[$this->modeltype]['address_id'] = $address->{$address->idField};
         }
     }
     if (count($errors) == 0 && parent::save($this->modeltype)) {
         sendTo($_SESSION['refererPage']['controller'], $_SESSION['refererPage']['action'], $_SESSION['refererPage']['modules'], isset($_SESSION['refererPage']['other']) ? $_SESSION['refererPage']['other'] : null);
     } else {
         $flash->addErrors($errors);
         $this->refresh();
     }
 }
コード例 #5
0
 public function _new()
 {
     $flash = Flash::Instance();
     parent::_new();
     $gl_params = $this->_uses[$this->modeltype];
     $unassigned = $gl_params->unassignedParams();
     if (count($unassigned) > 0) {
         $this->view->set('unassigned', $unassigned);
     } elseif (count($unassigned) == 0 && $this->_data['action'] == 'new') {
         $flash->addMessage('All parameters have been assigned');
         sendTo($this->name, 'index', $this->_modules);
     } elseif ($this->_data['action'] == 'new') {
         $flash->addError('Error getting Parameter List');
         sendback();
     }
     if (isset($_POST[$this->modeltype]['paramdesc'])) {
         $this->selectlist($_POST[$this->modeltype]['paramdesc']);
     } elseif ($gl_params->isLoaded()) {
         $this->selectlist($gl_params->paramdesc);
         $this->view->set('selected', $gl_params->paramvalue_id);
     } else {
         $this->selectlist(key($unassigned));
     }
     $sidebar = new SidebarController($this->view);
     $sidebarlist = array();
     $sidebarlist['view'] = array('tag' => 'View Parameters', 'link' => array_merge($this->_modules, array('controller' => $this->name, 'action' => 'index')));
     $sidebar->addList('Actions', $sidebarlist);
     $this->view->register('sidebar', $sidebar);
     $this->view->set('sidebar', $sidebar);
 }
コード例 #6
0
 public function view_allocations()
 {
     $flash = Flash::Instance();
     $collection = new SLTransactionCollection($this->_templateobject);
     $this->_templateobject->setAdditional('payment_value', 'numeric');
     $allocation = DataObjectFactory::Factory('SLAllocation');
     $allocationcollection = new SLAllocationCollection($allocation);
     $collection->_tablename = $allocationcollection->_tablename;
     $sh = $this->setSearchHandler($collection);
     $fields = array("our_reference||'-'||transaction_type as id", 'customer', 'slmaster_id', 'transaction_date', 'transaction_type', 'our_reference', 'ext_reference', 'currency', 'gross_value', 'allocation_date');
     $sh->setGroupBy($fields);
     $fields[] = 'sum(payment_value) as payment_value';
     $sh->setFields($fields);
     if (isset($this->_data['trans_id'])) {
         $allocation->identifierField = 'allocation_id';
         $cc = new ConstraintChain();
         $cc->add(new Constraint('transaction_id', '=', $this->_data['trans_id']));
         $alloc_ids = $allocation->getAll($cc);
         if (count($alloc_ids) > 0) {
             $sh->addConstraint(new Constraint('allocation_id', 'in', '(' . implode(',', $alloc_ids) . ')'));
         } else {
             $flash->addError('Error loading allocation');
             sendBack();
         }
     }
     parent::index($collection, $sh);
     $this->view->set('collection', $collection);
     $this->view->set('invoice_module', 'sales_invoicing');
     $this->view->set('invoice_controller', 'sinvoices');
     $this->view->set('clickaction', 'view');
     $this->view->set('clickcontroller', 'slcustomers');
     $this->view->set('linkvaluefield', 'slmaster_id');
 }
コード例 #7
0
 public function _new()
 {
     $flash = Flash::Instance();
     $errors = array();
     $glaccounts = new GLAccount();
     if ($glaccounts->getCount() == 0) {
         $errors[] = 'No GL Accounts defined';
     }
     $glcentres = new GLCentre();
     if ($glcentres->getCount() == 0) {
         $errors[] = 'No GL Centres defined';
     }
     if (count($errors) > 0) {
         $flash->addErrors($errors);
         sendback();
     }
     parent::_new();
     $currency = $this->_uses[$this->modeltype];
     $glaccounts = $glaccounts->getAll();
     if (isset($_POST[$this->modeltype]['writeoff_glaccount_id'])) {
         $default_glaccount_id = $_POST[$this->modeltype]['writeoff_glaccount_id'];
     } elseif (isset($this->_data['writeoff_glaccount_id'])) {
         $default_glaccount_id = $this->_data['writeoff_glaccount_id'];
     } elseif ($currency->isLoaded()) {
         $default_glaccount_id = $currency->writeoff_glaccount_id;
     } else {
         $default_glaccount_id = key($glaccounts);
     }
     $this->view->set('glcentres', $this->getCentres($default_glaccount_id));
 }
コード例 #8
0
 public function save()
 {
     if (!$this->checkParams($this->modeltype)) {
         sendBack();
     }
     $flash = Flash::Instance();
     $errors = array();
     $contains = array();
     foreach ($this->_data[$this->modeltype] as $key => $packinglist) {
         if (is_array($packinglist) && isset($packinglist['contains'])) {
             if ($packinglist['contains'] > $packinglist['available']) {
                 $errors[] = 'Pack qty for ' . $key . ' exceeds that available for packing';
             } else {
                 $contains[$key] = $packinglist['contains'];
             }
         }
     }
     $this->_data[$this->modeltype]['contents'] = base64_encode(serialize($contains));
     if (count($errors) == 0 && parent::save($this->modeltype)) {
         sendTo('sorders', 'view', $this->_modules, array('id' => $this->_data[$this->modeltype]['order_id']));
     } else {
         $flash->addErrors($errors);
         $this->_data['order_id'] = $this->_data[$this->modeltype]['order_id'];
         $this->refresh();
     }
 }
コード例 #9
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);
 }
コード例 #10
0
ファイル: AddresssController.php プロジェクト: uzerpllp/uzerp
 public function save()
 {
     $flash = Flash::Instance();
     if (parent::save('Address')) {
         sendTo($_SESSION['refererPage']['controller'], $_SESSION['refererPage']['action'], $_SESSION['refererPage']['modules'], isset($_SESSION['refererPage']['other']) ? $_SESSION['refererPage']['other'] : null);
     }
     $this->refresh();
 }
コード例 #11
0
 public function save()
 {
     $flash = Flash::Instance();
     if (parent::save('ComplaintVolume')) {
         sendTo($this->name, 'index', $this->_modules);
     }
     $this->refresh();
 }
コード例 #12
0
 public function save()
 {
     $flash = Flash::Instance();
     if (parent::save($this->modeltype)) {
         sendTo($this->name, 'index', $this->_modules);
     }
     $this->refresh();
 }
コード例 #13
0
ファイル: IndexController.php プロジェクト: uzerpllp/uzerp
 public function index()
 {
     $glparams = DataObjectFactory::Factory('GLParams');
     if (is_null($glparams->ar_disposals_proceeds_account()) || is_null($glparams->ar_disposals_proceeds_centre()) || is_null($glparams->ar_pl_suspense_account()) || is_null($glparams->ar_pl_suspense_centre())) {
         $flash = Flash::Instance();
         $flash->addError('GL Support is not enabled');
     }
     parent::index();
 }
コード例 #14
0
ファイル: function.flash.php プロジェクト: uzerpllp/uzerp
function smarty_function_flash($params, &$smarty)
{
    $flash = Flash::Instance();
    $flash->restore();
    $data = array('messages' => $flash->messages, 'warnings' => $flash->warnings, 'errors' => $flash->errors);
    $flash->clear();
    // fetch smarty plugin template
    return smarty_plugin_template($smarty, $data, 'function.flash');
}
コード例 #15
0
 public function save()
 {
     $flash = Flash::Instance();
     if (parent::save('CSFailureCode')) {
         sendTo($this->name, 'index', $this->_modules);
     } else {
         $this->refresh();
     }
 }
コード例 #16
0
ファイル: UzletsController.php プロジェクト: uzerpllp/uzerp
 public function save()
 {
     $flash = Flash::Instance();
     $errors = array();
     // delete any existing uzlet / module relationships
     if (isset($this->_data['Uzlet']['id']) && !empty($this->_data['Uzlet']['id'])) {
         $uzlet_modules = new UzletModuleCollection(DataObjectFactory::Factory('UzletModule'));
         $sh = new SearchHandler($uzlet_modules, false);
         $sh->addConstraint(new Constraint('uzlet_id', '=', $this->_data['Uzlet']['id']));
         $uzlet_modules->delete($sh);
     }
     // apply uzlet_id to UzletModulesCollection
     if (isset($this->_data['UzletModuleCollection']) && !empty($this->_data['UzletModuleCollection']['module_id'])) {
         foreach ($this->_data['UzletModuleCollection']['module_id'] as $key => $value) {
             $this->_data['UzletModuleCollection']['uzlet_id'][$key] = '';
         }
     }
     // delete any existing calls
     if (isset($this->_data['Uzlet']['id']) && !empty($this->_data['Uzlet']['id'])) {
         $uzlet_calls = new UzletCallCollection(DataObjectFactory::Factory('UzletCall'));
         $sh = new SearchHandler($uzlet_calls, false);
         $sh->addConstraint(new Constraint('uzlet_id', '=', $this->_data['Uzlet']['id']));
         $uzlet_calls->delete($sh);
     }
     // prepare the call field
     if (isset($this->_data['UzletCallCollection']['Call']) && $this->_data['UzletCallCollection']['Call'] != '') {
         // split up the call field by line
         $arr = explode("\n", $this->_data['UzletCallCollection']['Call']);
         foreach ($arr as $key => $value) {
             // we're not interested in empty lines
             $empty_test = trim($value);
             if (!empty($empty_test)) {
                 $pieces = explode(":", $value);
                 // we're also only interested if we have two pieces to work with
                 // actually we're interested if we have MORE THAN 2 parts, the arguement might be json for example
                 if (count($pieces) >= 2) {
                     $this->_data['UzletCallCollection']['uzlet_id'][$key] = '';
                     $this->_data['UzletCallCollection']['func'][$key] = $pieces[0];
                     // remove the function from the array, bind all the remaining part back together
                     // this will preserve any parameter that contains JSON etc (well, anything with a ":")
                     unset($pieces[0]);
                     $this->_data['UzletCallCollection']['arg'][$key] = implode(':', $pieces);
                 }
             }
         }
         unset($this->_data['UzletCallCollection']['Call']);
     } else {
         unset($this->_data['UzletCallCollection']);
     }
     if (parent::save('Uzlet', '', $errors)) {
         sendBack();
     } else {
         $flash->addErrors($errors);
         sendBack();
     }
 }
コード例 #17
0
 public function save()
 {
     if (!$this->CheckParams($this->modeltype)) {
         sendBack();
     }
     $flash = Flash::Instance();
     $errors = array();
     $db = DB::Instance();
     $db->StartTrans();
     $current_accounts = array();
     if (isset($this->_data[$this->modeltype]['id'])) {
         $centre = $this->_templateobject;
         $centre->load($this->_data[$this->modeltype]['id']);
         if ($centre->isLoaded()) {
             foreach ($centre->accounts as $accountcentre) {
                 // Delete any existing entries not in the supplied list
                 if (!empty($this->_data[$this->modeltype]['account_id']) && in_array($accountcentre->glaccount_id, $this->_data[$this->modeltype]['account_id'])) {
                     $current_accounts[$accountcentre->glaccount_id] = $accountcentre->glaccount_id;
                 } elseif (!$accountcentre->delete(null, $errors)) {
                     $errors[] = 'Failed to update Account Centre Reference ' . $accountcentre->glaccount;
                 }
             }
         }
     }
     if (count($errors) === 0 && parent::save_model($this->modeltype)) {
         if (isset($this->_data[$this->modeltype]['account_id'])) {
             foreach ($this->_data[$this->modeltype]['account_id'] as $account_id) {
                 if (!key_exists($account_id, $current_accounts)) {
                     $data = array();
                     $data['glaccount_id'] = $account_id;
                     $data['glcentre_id'] = $this->saved_model->id;
                     $accountcentre = GLAccountCentre::Factory($data, $errors, 'GLAccountCentre');
                     if ($accountcentre) {
                         $accountcentre->save();
                         if (!$accountcentre) {
                             $errors[] = 'Failed to save reference to Account';
                             break;
                         }
                     } else {
                         $errors[] = 'Failed to save reference to Account';
                         break;
                     }
                 }
             }
         }
         if (count($errors) == 0) {
             $db->CompleteTrans();
             sendTo($this->name, 'index', $this->_modules);
         }
     } else {
         $errors[] = 'Failed to save GL Centre';
     }
     $db->FailTrans();
     $flash->addErrors($errors);
     $this->refresh();
 }
コード例 #18
0
 public function save()
 {
     $flash = Flash::Instance();
     if (parent::save('CompanyPermission')) {
         sendTo('CompanyPermissions', 'index', array('admin'));
     } else {
         $this->_new();
         $this->_templateName = $this->getTemplateName('new');
     }
 }
コード例 #19
0
 public function save()
 {
     $flash = Flash::Instance();
     if (parent::save('MFWOStructure')) {
         sendTo('Mfworkorders', 'reviewMaterials', $this->_modules, array('id' => $this->_data['MFWOStructure']['work_order_id']));
     }
     $this->_data['work_order_id'] = $this->_data['MFWOStructure']['work_order_id'];
     $this->_data['ststructure_id'] = $this->_data['MFWOStructure']['ststructure_id'];
     $this->refresh();
 }
コード例 #20
0
 public function save()
 {
     $flash = Flash::Instance();
     if (parent::save('Campaign')) {
         sendTo($_SESSION['refererPage']['controller'], $_SESSION['refererPage']['action'], $_SESSION['refererPage']['modules'], isset($_SESSION['refererPage']['other']) ? $_SESSION['refererPage']['other'] : null);
     } else {
         $this->_new();
         $this->_templateName = $this->getTemplateName('new');
     }
 }
コード例 #21
0
 public function save()
 {
     $flash = Flash::Instance();
     if (parent::save($this->modeltype)) {
         sendTo($this->name, 'view', $this->_modules, array('id' => $this->_data['id']));
     } else {
         $this->_new();
         $this->_templateName = $this->getTemplateName('new');
     }
 }
コード例 #22
0
 public function save()
 {
     $flash = Flash::Instance();
     if (parent::save('Usercompanyaccess')) {
         sendBack();
     } else {
         $this->_new();
         $this->_templateName = $this->getTemplateName('new');
     }
 }
コード例 #23
0
ファイル: SystemsController.php プロジェクト: uzerpllp/uzerp
 public function save()
 {
     $flash = Flash::Instance();
     if (parent::save('System')) {
         sendTo($this->name, 'index', $this->_modules);
     } else {
         $this->_new();
         $this->_templateName = $this->getTemplateName('new');
     }
 }
コード例 #24
0
 public function save()
 {
     $flash = Flash::Instance();
     if (parent::save($this->modeltype)) {
         sendTo('HasRoles', 'index', array('admin'));
     } else {
         $this->_new();
         $this->_templateName = $this->getTemplateName('new');
     }
 }
コード例 #25
0
 public function createperiods()
 {
     $flash = Flash::Instance();
     $errors = array();
     periodHandling::createPeriods($errors);
     if (count($errors) > 0) {
         $flash->addErrors($errors);
     }
     sendTo($this->name, 'index', $this->_modules);
 }
コード例 #26
0
 public function save()
 {
     $flash = Flash::Instance();
     if (parent::save('SalesPerson')) {
         sendBack();
     } else {
         $this->_new();
         $this->_templateName = $this->getTemplateName('new');
     }
 }
コード例 #27
0
 public function save()
 {
     $flash = Flash::Instance();
     if (parent::save('OpportunityNote')) {
         sendBack();
     } else {
         $this->_new();
         $this->_templateName = $this->getTemplateName('new');
     }
 }
コード例 #28
0
 public function delete()
 {
     $flash = Flash::Instance();
     if (!isModuleAdmin()) {
         $flash->addError('Sorry, must be a module admin to delete resource templates.');
         sendBack();
     }
     parent::delete('Resourcetemplate');
     sendTo('resourcetemplate', 'index', 'projects');
 }
コード例 #29
0
 public function save()
 {
     $flash = Flash::Instance();
     if (parent::save('ProjectIssueHeader')) {
         sendTo('projectissues', 'view', array('projects'), array('id' => $this->saved_model->id));
     } else {
         $this->_new();
         $this->_templateName = $this->getTemplateName('new');
     }
 }
コード例 #30
0
 public function save()
 {
     $flash = Flash::Instance();
     if (parent::save('CalendarEventAttendee')) {
         sendBack();
     } else {
         $this->_new();
         $this->_templateName = $this->getTemplateName('new');
     }
 }