Example #1
0
 function __construct($getCurrentValues = true, $model = 'UserPreferences', $username = EGS_USERNAME)
 {
     parent::__construct();
     $userPreferences = $model::instance($username);
     $this->setModuleName('shared');
     // items-per-page
     if ($getCurrentValues) {
         $num_items = $userPreferences->getPreferenceValue('items-per-page', 'shared');
     } else {
         $num_items = 10;
     }
     $this->registerPreference(array('name' => 'items-per-page', 'display_name' => 'Items to display per page', 'type' => 'select', 'value' => $num_items, 'data' => array(array('label' => 5, 'value' => 5), array('label' => 10, 'value' => 10), array('label' => 15, 'value' => 15), array('label' => 20, 'value' => 20), array('label' => 25, 'value' => 25), array('label' => 30, 'value' => 30), array('label' => 35, 'value' => 35), array('label' => 40, 'value' => 40), array('label' => 45, 'value' => 45), array('label' => 50, 'value' => 50)), 'default' => '10', 'position' => 1));
     // default_printer
     $printerlist = array();
     foreach (printController::selectPrinters() as $key => $printer) {
         $printerlist[] = array('label' => $printer, 'value' => $key);
     }
     if ($getCurrentValues) {
         $current_printer = $userPreferences->getPreferenceValue('default_printer', 'shared');
     } else {
         $current_printer = '';
     }
     $this->registerPreference(array('name' => 'default_printer', 'display_name' => 'Default Printer', 'type' => 'select', 'value' => $current_printer, 'data' => $printerlist, 'default' => '', 'position' => 2));
     // password change
     if ($username == EGS_USERNAME) {
         $this->registerField(array('name' => 'current_password', 'display_name' => 'Current Password', 'type' => 'password', 'value' => '', 'position' => 3));
         $this->registerHandledPreference(array('name' => 'new_password', 'display_name' => 'New Password', 'type' => 'password', 'value' => '', 'position' => 4, 'callback' => 'changePassword'));
         $this->registerField(array('name' => 'confirm_password', 'display_name' => 'Confirm Password', 'type' => 'password', 'value' => '', 'position' => 5));
     }
     // pdf-preview/pdf-browser-printing
     if ($getCurrentValues) {
         $pdf_preview = $userPreferences->getPreferenceValue('pdf-preview', 'shared');
         $pdf_browser_printing = $userPreferences->getPreferenceValue('pdf-browser-printing', 'shared');
     } else {
         $pdf_preview = 'off';
         $pdf_browser_printing = 'off';
     }
     $this->registerPreference(array('name' => 'pdf-preview', 'display_name' => 'Enable PDF Preview', 'type' => 'checkbox', 'status' => empty($pdf_preview) || $pdf_preview == 'off' ? 'off' : 'on', 'default' => 'off', 'position' => 6));
     $this->registerPreference(array('name' => 'pdf-browser-printing', 'display_name' => 'Enable browser PDF printing', 'type' => 'checkbox', 'status' => empty($pdf_browser_printing) || $pdf_browser_printing == 'off' ? 'off' : 'on', 'default' => 'off', 'position' => 7));
     // default_page
     $modulelist = array();
     // Get modules user has access to
     $ao = AccessObject::instance();
     $per = DataObjectFactory::Factory('Permission');
     $permissions = $ao->getUserModules($username);
     if (!empty($permissions)) {
         foreach ($permissions as $permission) {
             $modulelist[] = array('label' => $permission['title'], 'value' => strtolower($per->getEnum('type', $permission['type'])) . ',' . $permission['permission']);
         }
     }
     if ($getCurrentValues) {
         $default_page = $userPreferences->getPreferenceValue('default_page', 'shared');
     } else {
         $default_page = '';
     }
     $this->registerPreference(array('name' => 'default_page', 'display_name' => 'Home page', 'type' => 'select', 'value' => $default_page, 'data' => $modulelist, 'default' => '', 'position' => 8));
 }
Example #2
0
 public function getAddress()
 {
     $address = DataObjectFactory::Factory('Companyaddress');
     $address->load($this->address_id);
     if ($address) {
         return printController::formatAddress($address);
     } else {
         return '';
     }
 }
Example #3
0
 public function index()
 {
     $errors = array();
     $this->setSearch('glcentresSearch', 'useDefault');
     $this->view->set('clickaction', 'view');
     parent::index(new GLCentreCollection($this->_templateobject));
     $sidebar = new SidebarController($this->view);
     $sidebar->addList('Actions', array('viewall' => array('link' => array_merge($this->_modules, array('controller' => 'glaccounts', 'action' => 'index')), 'tag' => 'View All Accounts'), 'viewbalances' => array('link' => array_merge($this->_modules, array('controller' => 'glbalances', 'action' => 'index')), 'tag' => 'View Balances'), 'viewtransactions' => array('link' => array_merge($this->_modules, array('controller' => 'gltransactions', 'action' => 'index')), 'tag' => 'View Transactions')));
     $this->view->register('sidebar', $sidebar);
     $this->view->set('sidebar', $sidebar);
 }
 public function save()
 {
     $flash = Flash::Instance();
     $errors = array();
     $save = parent::save('CRMCalendarEvent', array(), $errors);
     if (is_ajax()) {
         echo json_encode(array('status' => $save));
         exit;
     } else {
         sendBack();
     }
 }
Example #5
0
 public function save_model($modelName, $dataIn = array(), &$errors = array(), &$warnings = array(), $duplicates = '')
 {
     // Need to define error array here due to too many nested levels
     $flash = Flash::Instance();
     $edi_errors = array();
     if ($duplicates != 'R') {
         // Do not reject duplicates - so check if record exists
         $model = new $modelName();
         $identifierFields = $model->getIdentifierFields();
         $identifierValues = array();
         foreach ($identifierFields as $key => $field) {
             if (isset($dataIn[$modelName][$field]) && $model->checkUniqueness($field)) {
                 $identifier_string = $field . ' : ' . $dataIn[$modelName][$field] . ',';
                 $identifierValues[$key] = $dataIn[$modelName][$field];
             } else {
                 unset($identifierFields[$key]);
             }
         }
         if (count($identifierFields) > 0 && count($identifierFields) == count($identifierValues)) {
             $model->loadBy($identifierFields, $identifierValues);
             if ($model->isLoaded()) {
                 if ($duplicates == 'I') {
                     // Ignore duplicates so return true
                     $warnings[] = 'Duplicate  ' . $identifier_string . ' Ignored';
                     return true;
                 } else {
                     // replace/update duplicate so set id field value
                     $dataIn[$modelName][$model->idField] = $model->{$model->idField};
                 }
             }
         }
     }
     $result = parent::save($modelName, $dataIn, $edi_errors);
     if (count($edi_errors) > 0) {
         // Add the Identifier Values to the errors to identify the data in error
         // Assumes the $dataIn array is an array of [ModelName][ModelData]
         // and that the input $modelName is the identifying model for the data
         $model = new $modelName();
         foreach ($model->getIdentifierFields() as $field) {
             $errors[] = prettify($field) . ' : ' . $dataIn[$modelName][$field];
         }
         $flash->addErrors($edi_errors);
         foreach ($edi_errors as $error) {
             $errors[] = $error;
         }
     }
     return $result;
 }
 protected function save_model($modelName, $dataIn = array(), &$errors = array())
 {
     return parent::save($modelName, $dataIn, $errors);
 }
Example #7
0
 public function save_data_input()
 {
     $flash = Flash::Instance();
     $errors = array();
     $_SESSION['di_search'] = $this->_data['Search'];
     if (parent::save('GLBudgetCollection', '', $errors)) {
         sendBack();
     } else {
         $flash->addErrors($errors);
         sendBack();
     }
 }
 protected function getPageName($base = null, $action = null)
 {
     return parent::getPageName($base ? $base : 'SO_product_lines', $action);
 }
 protected function getPageName($base = null, $action = null)
 {
     $base = empty($base) ? $this->_templateobject->getTitle() : $base;
     return parent::getPageName(empty($base) ? 'work_schedules' : $base, $action);
 }
Example #10
0
 public function _new()
 {
     parent::_new();
     $roles = DataObjectFactory::Factory('Role');
     $this->view->set('roles', $roles->getAll());
     $sc = DataObjectFactory::Factory('Systemcompany');
     $companies = new SystemcompanyCollection($sc);
     $this->view->set('companies', $companies->getCompanies());
     $sc->load(EGS_COMPANY_ID);
     $current_people = $sc->getCurrentPeople();
     $assigned_users = $this->_uses[$this->modeltype]->getAssignedPeople();
     $this->view->set('people', array_diff_key($current_people, $assigned_users));
     $debug = DataObjectFactory::Factory('DebugOption');
     $this->view->set('debug_options', $debug->getEnumOptions('options'));
 }
Example #11
0
 public function save()
 {
     $flash = Flash::Instance();
     if (parent::save('Activity')) {
         // Ensures return to viewing the new activity after saving a follow-up
         if ($_SESSION['refererPage']['controller'] == $this->name && $_SESSION['refererPage']['action'] == 'view') {
             sendTo($this->name, 'view', $this->_modules, ['id' => $this->saved_model->id]);
         }
         // Return to the refering page, e.g. when adding an activity from the contacts module
         sendTo($_SESSION['refererPage']['controller'], $_SESSION['refererPage']['action'], $_SESSION['refererPage']['modules'], isset($_SESSION['refererPage']['other']) ? $_SESSION['refererPage']['other'] : null);
     } else {
         $this->refresh();
     }
 }
 public function updateEvent()
 {
     $event = $this->_uses['SODespatchEvent'];
     $event->load($this->_data['id']);
     $data = $event->_data;
     // I'm sure there's a better way to format these dates...
     switch ($this->_data['type']) {
         case "drop":
             $data['start_time'] = un_fix_date(date('o-m-d H:i:s', strtotime("+" . $this->_data['day'] . " day", strtotime("+" . $this->_data['minute'] . " minute", strtotime($data['start_time'])))), true);
             $data['end_time'] = un_fix_date(date('o-m-d H:i:s', strtotime("+" . $this->_data['day'] . " day", strtotime("+" . $this->_data['minute'] . " minute", strtotime($data['end_time'])))), true);
             break;
         case "resize":
             $data['start_time'] = un_fix_date($data['start_time'], true);
             $data['end_time'] = un_fix_date(date('o-m-d H:i:s', strtotime("+" . $this->_data['day'] . " day", strtotime("+" . $this->_data['minute'] . " minute", strtotime($data['end_time'])))), true);
             break;
     }
     $errors = array();
     if (parent::save('SODespatchEvent', $data, $errors)) {
         json_reply(array('success' => TRUE));
     } else {
         json_reply(array('success' => FALSE));
     }
 }
 protected function getPageName($base = null, $action = null)
 {
     return parent::getPageName(empty($base) ? 'sales_ledger_transactions' : $base, $action);
 }
 protected function getPageName($base = null, $action = null)
 {
     return parent::getPageName(empty($base) ? 'periodic_payments' : $base, $action);
 }
Example #15
0
 private function viewEuTransactions($collection, $sh)
 {
     $errors = array();
     $s_data = array();
     $flash = Flash::Instance();
     $this->view->set('page_title', $collection->title);
     if (isset($this->search)) {
         if ($this->isPrintDialog()) {
             $_SESSION['printing'][$this->_data['index_key']]['search_id'] = $sh->search_id;
             return $this->printCollection();
         } elseif ($this->isPrinting()) {
             $_SESSION['printing'][$this->_data['index_key']]['search_id'] = $sh->search_id;
             $sh->setLimit(0);
             $collection->load($sh);
             //				$this->setParams();
             $this->printCollection($collection);
             exit;
         }
     }
     parent::index($collection, $sh);
     $this->view->set('transactions', $collection);
     $sidebar = new SidebarController($this->view);
     $sidebar->addList('Intrastat', $this->intrastatSidebar());
     $sidebar->addList('Actions', $this->vatReturnSidebar());
     $this->view->register('sidebar', $sidebar);
     $this->view->set('sidebar', $sidebar);
     $this->view->set('display_fields', '');
     $this->view->set('selected_fields', '');
     $this->setTemplateName('vieweutransactions');
 }
 protected function getPageName($base = null, $type = null)
 {
     return parent::getPageName(empty($base) ? 'cashbook_transactions' : $base, $type);
 }
Example #17
0
 protected function getPageName($base = null, $action = null)
 {
     return parent::getPageName(empty($base) ? 'Warehouse Transfers' : $base, $action);
 }
Example #18
0
 protected function getPageName($base = null, $action = null)
 {
     return parent::getPageName(empty($base) ? 'sales_invoices' : $base, $action);
 }
 private function create_standard($header, $errors = array())
 {
     if (isset($this->_data['reverse']) && $this->_data['reverse'] == 'yes') {
         $reversal = true;
     }
     // Create new header from selected header
     $newheader = array();
     foreach ($header->getFields() as $fieldname => $field) {
         $newheader[$fieldname] = $header->{$fieldname};
     }
     unset($newheader['id']);
     unset($newheader['docref']);
     $period = DataObjectFactory::Factory('GLPeriod');
     $period->getCurrentPeriod();
     $newheader['transaction_date'] = un_fix_date($period->enddate);
     $newheader['glperiods_id'] = $period->id;
     if ($reversal) {
         $newheader['comment'] = 'Reversal of Ref:' . $header->docref . ' ' . $newheader['comment'];
         if ($newheader['glperiods_id'] == $header->glperiods_id) {
             $newheader['glperiods_id'] = key($this->getPeriods($newheader['transaction_date']));
         }
     } elseif ($newheader['accruals'] == 't') {
         $newheader['accrual_period_id'] = key($this->getPeriods($newheader['transaction_date']));
     }
     $newheader['type'] = $header->standardJournal();
     // Save the header and transactions
     $result = parent::save($this->modeltype, $newheader, $errors);
     if ($result) {
         // Copy existing header journal transactions to unposted transactions table
         $header->setTransactionsCollection();
         $sh = $this->setSearchHandler($header->transactions);
         $sh->setFields('*');
         // Ignore any reverse accruals when copying posted transactions
         $header->setTransactionsConstraints($sh, TRUE);
         $transactions = $header->transactions->load($sh, null, RETURN_ROWS);
         $docref = $this->saved_model->docref;
         foreach ($transactions as $row) {
             unset($row['id']);
             $row['docref'] = $docref;
             if ($reversal) {
                 $row['value'] = bcmul($row['value'], -1);
             }
             $result = DataObject::Factory($row, $errors, $header->unpostedTransactionFactory());
             if (!$result) {
                 break;
             } else {
                 $newtrans[] = $result;
             }
         }
         if ($result) {
             foreach ($newtrans as $unposted) {
                 if (!$unposted->save()) {
                     $result = FALSE;
                     $errors[] = 'Error creating journal transactions : ' . $db->ErrorMsg();
                     break;
                 }
             }
         }
     }
     if ($result) {
         // now set header to saved model and go to view the new header
         return $this->saved_model;
     }
     return FALSE;
 }
 protected function getPageName($base = null, $action = null)
 {
     return parent::getPageName(!empty($base) ? $base : 'purchase_invoice_line', $action);
 }
Example #21
0
 protected function getPageName($base = null, $action = null)
 {
     return parent::getPageName('Datasets');
 }
 protected function getPageName($base = null, $action = null)
 {
     return parent::getPageName($base ? $base : 'goods_received_note', $action);
 }
Example #23
0
 protected function getPageName($base = null, $action = null)
 {
     return parent::getPageName(empty($base) ? 'general_ledger_balances' : $base, $action);
 }
Example #24
0
 protected function getPageName($base = null, $action = null)
 {
     return parent::getPageName(empty($base) ? 'locations' : $base, $action);
 }
Example #25
0
 protected function getPageName($base = null, $type = null)
 {
     return parent::getPageName(empty($base) ? 'person' : $base, $type);
 }
 public function view_allocations()
 {
     $flash = Flash::Instance();
     $collection = new PLTransactionCollection($this->_templateobject);
     $this->_templateobject->setAdditional('payment_value', 'numeric');
     $allocation = DataObjectFactory::Factory('PLAllocation');
     $allocationcollection = new PLAllocationCollection($allocation);
     $collection->_tablename = $allocationcollection->_tablename;
     $sh = $this->setSearchHandler($collection);
     $fields = array("our_reference||'-'||transaction_type as id", 'supplier', 'plmaster_id', 'payee_name', 'transaction_date', 'transaction_type', 'our_reference', 'ext_reference', 'currency', 'currency_id', 'gross_value', 'allocation_date');
     $sh->setGroupBy($fields);
     $fields[] = 'sum(payment_value) as payment_value';
     $sh->setFields($fields);
     if (isset($this->_data['trans_id'])) {
         $allocation->loadBy('transaction_id', $this->_data['trans_id']);
         if ($allocation->isLoaded()) {
             $sh->addConstraint(new Constraint('allocation_id', '=', $allocation->allocation_id));
         } else {
             $flash->addError('Error loading allocation');
             sendBack();
         }
     }
     parent::index($collection, $sh);
     $this->view->set('collection', $collection);
     $this->view->set('invoice_module', 'purchase_invoicing');
     $this->view->set('invoice_controller', 'pinvoices');
     $this->view->set('clickaction', 'view');
     $this->view->set('clickcontroller', 'plsuppliers');
     $this->view->set('linkvaluefield', 'plmaster_id');
 }
Example #27
0
 function edit_gcal()
 {
     $flash = Flash::Instance();
     $calendar = new Calendar();
     $calendar->load($this->_data['id']);
     $this->view->set('calendar', $calendar);
     if (!$calendar->isOwner($this->_data['id'])) {
         $flash->addError("You cannot edit a calendar that doesn't belong to you");
         sendTo('calendars', 'index', 'calendar');
     }
     $colours = $calendar->getEnumOptions('colour');
     $this->view->set('colours', $colours);
     $user = new User();
     $users = $user->getAll();
     foreach ($users as $key => $value) {
         if ($value != EGS_USERNAME) {
             $usernames[$key] = $value;
         }
     }
     $this->view->set('users', $usernames);
     $shared_users = array();
     $shared_user = new CalendarShareCollection(new CalendarShare());
     $sh = new SearchHandler($shared_user, false);
     $sh->addConstraint(new Constraint('calendar_id', '=', $this->_data['id']));
     $sh->addConstraint(new Constraint('username', '!=', EGS_USERNAME));
     $sh->setFields(array('id', 'calendar_id', 'username'));
     $shared_user->load($sh);
     if (count($shared_user->getArray()) > 0) {
         foreach ($shared_user->getArray() as $key => $value) {
             $shared_users[$key] = $value['username'];
         }
     }
     $this->view->set('shared_users', $shared_users);
     $sidebar = new SidebarController($this->view);
     $sidebar->addList('calendar_views', array('view_calendar' => array('link' => array('module' => 'calendar'), 'tag' => 'View Calendar')));
     $sidebar->addList('calendars', array('manage_calendars' => array('link' => array('module' => 'calendar', 'controller' => 'calendars', 'action' => 'index'), 'tag' => 'Manage Calendars')));
     $this->view->register('sidebar', $sidebar);
     $this->view->set('sidebar', $sidebar);
     parent::_new();
 }
Example #28
0
 public function save()
 {
     $flash = Flash::Instance();
     $errors = array();
     $calendar = $this->_templateobject;
     if (!isset($this->_data['CRMCalendar']['colour'])) {
         $colours = $calendar->getEnumOptions('colour');
         $this->_data['CRMCalendar']['colour'] = $colours[array_rand($colours)];
     }
     if (parent::save('CRMCalendar', '', $errors)) {
         sendBack();
     } else {
         sendBack();
     }
 }
 protected function getPageName($base = null, $action = null)
 {
     return parent::getPageName(!empty($base) ? $base : 'sales_order_packing_slip', $action);
 }
 private function getItemPlan()
 {
     // Get the list of saleable items
     $s_data = array();
     // Set context from calling module
     if (isset($this->_data['stitem_id'])) {
         $s_data['stitem_id'] = $this->_data['stitem_id'];
     }
     if (isset($this->_data['prod_group_id'])) {
         $s_data['prod_group_id'] = $this->_data['prod_group_id'];
     }
     $this->setSearch('productlinesSearch', 'customerItems', $s_data);
     $items = new SOProductlineHeaderCollection($this->_templateobject);
     $sh = $this->setSearchHandler($items);
     $items->getItems($sh);
     parent::index($items, $sh);
     // Now get totals for Sales Orders, In Stock, Work Orders
     $itemplan = array();
     foreach ($items as $item) {
         $stitem = DataObjectFactory::Factory('STItem');
         if ($stitem->load($item->stitem_id)) {
             $itemplan[$item->stitem_id]['stitem_id'] = $item->stitem_id;
             $itemplan[$item->stitem_id]['stitem'] = $item->stitem;
             $itemplan[$item->stitem_id]['uom_name'] = $item->uom_name;
             $itemplan[$item->stitem_id]['in_stock'] = $stitem->currentBalance();
             $itemplan[$item->stitem_id]['required'] = 0;
             $itemplan[$item->stitem_id]['on_order']['po_value'] = 0;
             $itemplan[$item->stitem_id]['on_order']['wo_value'] = 0;
             $porders = $stitem->getPOrderLines();
             foreach ($porders as $porder) {
                 $itemplan[$item->stitem_id]['on_order']['po_value'] += round($stitem->convertToUoM($porder->stuom_id, $stitem->uom_id, $porder->os_qty), $stitem->qty_decimals);
             }
             $sorders = $stitem->getSOrderLines();
             foreach ($sorders as $sorder) {
                 $itemplan[$item->stitem_id]['required'] += round($stitem->convertToUoM($sorder->stuom_id, $stitem->uom_id, $sorder->os_qty), $stitem->qty_decimals);
             }
             $worders = $stitem->getWorkOrders();
             foreach ($worders as $worder) {
                 $itemplan[$item->stitem_id]['on_order']['wo_value'] += round($worder->order_qty - $worder->made_qty < 0 ? 0 : $worder->order_qty - $worder->made_qty, $stitem->qty_decimals);
             }
             $salelocations = WHLocation::getSaleLocations();
             if (empty($salelocations)) {
                 $itemplan[$item->stitem_id]['for_sale'] = 0;
             } else {
                 $cc = new ConstraintChain();
                 $cc->add(new Constraint('stitem_id', '=', $item->stitem_id));
                 $cc->add(new Constraint('whlocation_id', 'in', '(' . implode(',', $salelocations) . ')'));
                 $itemplan[$item->stitem_id]['for_sale'] = STBalance::getBalances($cc);
             }
             $itemplan[$item->stitem_id]['in_stock'] -= $itemplan[$item->stitem_id]['for_sale'];
             $itemplan[$item->stitem_id]['actual_shortfall'] = $itemplan[$item->stitem_id]['required'] - ($itemplan[$item->stitem_id]['for_sale'] + $itemplan[$item->stitem_id]['in_stock']);
             $itemplan[$item->stitem_id]['shortfall'] = $itemplan[$item->stitem_id]['actual_shortfall'] - $itemplan[$item->stitem_id]['on_order']['po_value'] - $itemplan[$item->stitem_id]['on_order']['wo_value'];
             $itemplan[$item->stitem_id]['indicator'] = 'green';
             if ($itemplan[$item->stitem_id]['actual_shortfall'] <= 0) {
                 $itemplan[$item->stitem_id]['actual_shortfall'] = 0;
             } else {
                 $itemplan[$item->stitem_id]['indicator'] = 'amber';
             }
             if ($itemplan[$item->stitem_id]['shortfall'] <= 0) {
                 $itemplan[$item->stitem_id]['shortfall'] = 0;
             } else {
                 $itemplan[$item->stitem_id]['indicator'] = 'red';
             }
         }
     }
     return $itemplan;
 }