public static function transactions($search_data = null, &$errors = array(), $defaults = null) { $search = new assetsSearch($defaults); $trans = DataObjectFactory::Factory('ARTransaction'); // Search by Transaction Date $search->addSearchField('transaction_date', 'Transaction Date between', 'between', '', 'basic'); // Search by Asset $search->addSearchField('armaster_id', 'Asset', 'select', 0, 'basic'); $asset = DataObjectFactory::Factory('Asset'); $options = array('0' => 'All'); $assets = $asset->getAll(); $options += $assets; $search->setOptions('armaster_id', $options); // Search by Transaction Type $search->addSearchField('transaction_type', 'Transaction Type', 'multi_select', array(''), 'advanced'); $search->setOptions('transaction_type', $trans->getEnumOptions('transaction_type')); // Search by Group $search->addSearchField('to_group_id', 'Group', 'multi_select', array(0), 'advanced'); $argroup = DataObjectFactory::Factory('ARGroup'); $search->setOptions('to_group_id', $argroup->getAll()); // Search by Location $search->addSearchField('to_location_id', 'Location', 'multi_select', array(0), 'advanced'); $arlocation = DataObjectFactory::Factory('ARLocation'); $search->setOptions('to_location_id', $arlocation->getAll()); $search->setSearchData($search_data, $errors); return $search; }
function setData($bacs_reference, $payments, &$errors = array(), $data, $plpayment) { $this->bacs_reference = $bacs_reference; $this->payments = $payments; $this->plpayment = $plpayment; $account = DataObjectFactory::Factory('CBAccount'); if (isset($data['cb_account_id'])) { $account->load($data['cb_account_id']); } $this->account = $account; $userPreferences = UserPreferences::instance(EGS_USERNAME); $defaultPrinter = $userPreferences->getPreferenceValue('default_printer', 'shared'); $params = $data['print']; $print_params = array(); $params['printer'] = empty($data['printer']) ? $defaultPrinter : $data['printer']; if (!$this->controller->setPrintParams($params, $print_params, $errors)) { $errors[] = 'Failed to set print parameters'; } $year = date('y'); $create_date = bcadd(date('z'), 1, 0); $this->create_date = $year . str_pad($create_date, 3, '0', STR_PAD_LEFT); $expiry_date = bcadd(date('z', strtotime($this->plpayment->payment_date)), 1, 0); $processing_date = bcadd(date('z', strtotime($this->getProcessDate($plpayment->payment_date))), 1, 0); $this->processing_date = $year . str_pad($processing_date, 3, '0', STR_PAD_LEFT); $this->expiry_date = $year . str_pad($expiry_date, 3, '0', STR_PAD_LEFT); if ($plpayment->override === 'f') { $this->validate(array('payment_date' => un_fix_date($plpayment->payment_date)), $errors); if ($this->processing_date <= $this->create_date) { $errors[] = 'Invalid Processing Date'; } } }
public function _new($followup = FALSE) { if (array_key_exists('followup', $this->_data)) { $followup = $this->_data['followup']; } $this->view->set('page_title', 'New CRM Activity'); // New follow-up activity if ($followup) { $this->view->set('page_title', 'New CRM Follow-up Activity'); unset($this->_data['id']); $activity = new Activity(); $activity->load($followup); $this->_data['person_id'] = $activity->person_id; $this->_data['company_id'] = $activity->company_id; $this->_data['name'] = $activity->name; $this->_data['description'] = $activity->description; $this->_data['completed'] = ''; } // Edit existing activity if (isset($this->_data['id'])) { $this->view->set('page_title', 'Edit CRM Activity'); } // New activity from opportunity if (isset($this->_data['opportunity_id'])) { $this->view->set('page_title', 'New CRM Activity'); $opportunity = DataObjectFactory::Factory('Opportunity'); $opportunity->load($this->_data['opportunity_id']); $this->_data['person_id'] = $opportunity->person_id; $this->_data['company_id'] = $opportunity->company_id; } parent::_new(); }
static function getComponentId($_module_name, $_component_name) { $module = ModuleObject::getModule($_module_name); $modulecomponent = DataObjectFactory::Factory(__CLASS__); $modulecomponent->loadBy(array('name', 'module_id'), array($_component_name, $module->id)); return $modulecomponent->id; }
public function __construct($module = null, $action = null) { parent::__construct($module, $action); $this->_templateobject = DataObjectFactory::Factory('Personaddress'); $this->uses($this->_templateobject); $this->related['person'] = array('clickaction' => 'edit'); }
public static function workSchedules($search_data = null, &$errors, $defaults = null) { $search = new EngineeringSearch($defaults); // Search on Job Number $search->addSearchField('job_no', 'job_number', 'equal'); // Search on Job Number $search->addSearchField('description', 'description', 'contains'); // Search on Status $search->addSearchField('status', 'status', 'multi_select', array('A')); $project = DataObjectFactory::Factory('WorkSchedule'); $options = array('' => 'All'); $statuses = $project->getEnumOptions('status'); $options += $statuses; $search->setOptions('status', $options); // Search on Work Centre $search->addSearchField('centre_id', 'centre', 'select', '', 'advanced'); $centre = DataObjectFactory::Factory('MFCentre'); $centres = $centre->getAll(); $options = array('' => 'all'); $options += $centres; $search->setOptions('centre_id', $options); // Search on Downtime Code $search->addSearchField('mf_downtime_code_id', 'Downtime Code', 'select', '', 'advanced'); $downtimecode = DataObjectFactory::Factory('MFDowntimeCode'); $downtimecodes = $downtimecode->getAll(); $options = array('' => 'all'); $options += $downtimecodes; $search->setOptions('mf_downtime_code_id', $options); $search->setSearchData($search_data, $errors, workSchedules); return $search; }
function getObjectPolicyValue() { $policy_detail = DataObjectFactory::Factory('SystemObjectPolicy'); $policy_detail->load($this->object_policies_id); $policy_value = $policy_detail->getComponentTitle() . ' ' . prettify($policy_detail->get_field()) . ' ' . $policy_detail->getFormatted('operator') . ' ' . $policy_detail->getvalue(); return $policy_value; }
public static function useDefault($search_data = null, &$errors = array(), $defaults = null) { $search = new poauthlimitsSearch($defaults); // Search by Person $search->addSearchField('username', 'Person', 'select', ''); $people = DataObjectFactory::Factory('Usercompanyaccess'); $people->idField = 'username'; $people->identifierField = 'username'; $people->orderby = 'username'; $options = array('0' => 'All'); $cc = new ConstraintChain(); $cc->add(new Constraint('usercompanyid', '=', EGS_COMPANY_ID)); $peoplelist = $people->getAll($cc); $options += $peoplelist; $search->setOptions('username', $options); // Search by GL Centre $search->addSearchField('glcentre_id', 'GL Centre', 'select', 0); $options = array('0' => 'All'); $centres = DataObjectFactory::Factory('GLCentre'); $centrelist = $centres->getAll(); $options += $centrelist; $search->setOptions('glcentre_id', $options); $search->setSearchData($search_data, $errors); return $search; }
public function getCentres() { $mf_centre = DataObjectFactory::Factory('MFCentre'); $cc = new ConstraintChain(); $cc->add(new Constraint('production_recording', 'is', 'true')); return $mf_centre->getAll($cc); }
function getvalue() { $model = $this->get_model(); if ($this->idField == $this->fieldname) { $cc = new ConstraintChain(); if (substr($this->value, -1) == ')') { $cc->add(new Constraint($model->idField, 'IN', $this->value)); } else { $cc->add(new Constraint($model->idField, '=', $this->value)); } $values = $model->getAll($cc); if (count($values) > 0) { return implode(',', $values); } } elseif (isset($model->belongsToField[$this->fieldname])) { if ($this->value === "'NULL'") { return 'NULL'; } $fk = DataObjectFactory::Factory($model->belongsTo[$model->belongsToField[$this->fieldname]]['model']); $fk->load($this->value); return $fk->getIdentifierValue(); } elseif ($model->isEnum($this->fieldname)) { return $model->getEnum($this->fieldname, $this->value); } return $this->value; }
function populate() { $employee = DataObjectFactory::Factory('Employee'); $user = getCurrentUser(); if (!is_null($user->person_id)) { $employee->loadBy('person_id', $user->person_id); } if ($employee->isLoaded()) { $authorisor_model = $employee->holiday_model(); $employee->authorisationPolicy($authorisor_model); $authorisees = $employee->getAuthorisees($authorisor_model); } else { $authorisees = array(); } $holiday = DataObjectFactory::Factory('HolidayRequest'); $holidays = new HolidayrequestCollection($holiday); if (count($authorisees) > 0) { $holidays->setParams(); $sh = new SearchHandler($holidays, false); $sh->setFields(array('id', 'employee', 'employee_id', 'start_date', 'end_date', 'num_days')); $sh->addConstraint(new Constraint('status', '=', $holiday->newRequest())); $sh->addConstraint(new Constraint('employee_id', 'in', '(' . implode(',', $authorisees) . ')')); $this->setSearchLimit($sh); $sh->setOrderby(array('employee', 'start_date')); $holidays->load($sh); $holidays->clickcontroller = 'holidayrequests'; $holidays->editclickaction = 'view'; } $this->contents = $holidays; }
public static function useDefault($search_data = null, &$errors = array(), $defaults = null) { $search = new pinvoicesSearch($defaults); $invoice = DataObjectFactory::Factory('PInvoice'); // Search by Customer $search->addSearchField('plmaster_id', 'Supplier', 'select', 0, 'advanced'); $supplier = DataObjectFactory::Factory('PLSupplier'); $options = array('0' => 'All'); $suppliers = $supplier->getAll(null, false, true, '', ''); $options += $suppliers; $search->setOptions('plmaster_id', $options); // Search by Invoice Number $search->addSearchField('invoice_number', 'invoice_number', 'equal', '', 'advanced'); // Search by Invoice Number $search->addSearchField('ext_reference', 'supplier_reference begins', 'begins', '', 'advanced'); // Search by Purchase Order Number $search->addSearchField('purchase_order_number', 'PO Number', 'equal', '', 'advanced'); // Search by Invoice Date $search->addSearchField('invoice_date', 'invoice_date_between', 'between', '', 'basic'); // Search by Transaction Type $search->addSearchField('transaction_type', 'transaction_type', 'select', '', 'advanced'); $options = array_merge(array('' => 'All'), $invoice->getEnumOptions('transaction_type')); $search->setOptions('transaction_type', $options); // Search by Status $search->addSearchField('status', 'status', 'select', '', 'advanced'); $options = array_merge(array('' => 'All'), $invoice->getEnumOptions('status')); $search->setOptions('status', $options); $search->setSearchData($search_data, $errors); return $search; }
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'); }
function populate() { $employee = DataObjectFactory::Factory('Employee'); $user = getCurrentUser(); if (!is_null($user->person_id)) { $employee->loadBy('person_id', $user->person_id); } if ($employee->isLoaded()) { $authorisor_model = $employee->expense_model(); $employee->authorisationPolicy($authorisor_model); $authorisees = $employee->getAuthorisees($authorisor_model); } else { $authorisees = array(); } $expense = DataObjectFactory::Factory('Expense'); $expenses = new ExpenseCollection($expense); if (count($authorisees) > 0) { $expenses->setParams(); $sh = new SearchHandler($expenses, false); $sh->setFields(array('id', 'expense_number', 'employee', 'employee_id', 'description', 'gross_value')); $sh->addConstraint(new Constraint('status', '=', $expense->statusAwaitingAuthorisation())); $sh->addConstraint(new Constraint('employee_id', 'in', '(' . implode(',', $authorisees) . ')')); $this->setSearchLimit($sh); $sh->setOrderby(array('expense_number')); $expenses->load($sh); $expenses->clickcontroller = 'expenses'; $expenses->editclickaction = 'view'; } $this->contents = $expenses; $this->vars['module'] = 'hr'; $this->vars['controller'] = 'expenses'; }
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(); } }
public function index() { // Cater for no module to edit. if (empty($this->_data['for_module'])) { $this->_data['for_module'] = 'shared'; } $sidebarList['shared'] = array('tag' => 'Shared', 'link' => array('module' => 'dashboard', 'controller' => 'preferences', 'action' => 'index', 'for_module' => 'shared')); $accessObject =& AccessObject::Instance(EGS_USERNAME); $module = DataObjectFactory::Factory('ModuleObject'); $modules = $module->getAll(); $sidebar = new SidebarController($this->view); foreach ($modules as $module) { if (!class_exists(ucfirst($module) . 'Preferences')) { continue; } if ($accessObject->hasPermission($module, 'preferences')) { $sidebarList[$module] = array('tag' => ucfirst($module) . ' Preferences', 'link' => array('module' => 'dashboard', 'controller' => 'preferences', 'action' => 'index', 'for_module' => $module)); } } if (empty($sidebarList)) { $flash = Flash::Instance(); $flash->addError('There are no preferences you can edit'); sendTo('index', 'index', array('dashboard')); } else { $sidebar->addList('Modules', $sidebarList); } $this->view->register('sidebar', $sidebar); $this->view->set('sidebar', $sidebar); $module = $this->getPreferenceClass($this->_data['for_module']); $this->view->set('templateCode', $module->generateTemplate()); $this->view->set('page_title', $this->getPageName($this->_data['for_module'], 'Preferences for')); }
public function _new() { parent::_new(); $mfshiftwaste = $this->_uses[$this->modeltype]; if ($mfshiftwaste->isLoaded()) { $this->_data['mf_shift_outputs_id'] = $mfshiftwaste->mf_shift_outputs_id; $this->_data['mf_centre_waste_type_id'] = $mfshiftwaste->mf_centre_waste_type_id; } if (isset($this->_data['mf_shift_outputs_id'])) { $mfshiftoutput = DataObjectFactory::Factory('MFShiftOutput'); $mfshiftoutput->load($this->_data['mf_shift_outputs_id']); if ($mfshiftoutput->isLoaded()) { $mfshift = $mfshiftoutput->shift_detail; if ($mfshift->isLoaded()) { $waste_types = $mfshift->getWasteTypes(); $this->view->set('waste_types', $waste_types); } } } if (isset($_POST[$this->modeltype]['mf_centre_waste_type_id'])) { $waste_type_id = $_POST[$this->modeltype]['mf_centre_waste_type_id']; } elseif (isset($this->_data['mf_centre_waste_type_id'])) { $waste_type_id = $this->_data['mf_centre_waste_type_id']; } else { $waste_type_id = key($waste_types); } $this->view->set('uom', $this->getWasteUom($waste_type_id)); }
public static function useDefault($search_data = null, &$errors, $defaults = null) { $search = new expenseSearch($defaults); // Employee Name $search->addSearchField('employee', 'name_contains', 'contains', '', 'basic'); // Status $search->addSearchField('status', 'status', 'multi_select', array('A', 'O', 'W'), 'basic'); $expense = DataObjectFactory::Factory('Expense'); $options = array('' => 'all'); $options += $expense->getEnumOptions('status'); $search->setOptions('status', $options); // Reference $search->addSearchField('our_reference', 'Reference', 'contains', '', 'advanced'); // Description $search->addSearchField('description', 'Description', 'contains', '', 'advanced'); // Project $search->addSearchField('project_id', 'Project', 'select', '', 'advanced'); $project = DataObjectFactory::Factory('Project'); $projects = $project->getAll(null, TRUE, TRUE); $options = array('' => 'all'); $options += $projects; $search->setOptions('project_id', $options); // Task $search->addSearchField('task_id', 'Task', 'select', '', 'advanced'); $task = DataObjectFactory::Factory('Task'); $tasks = $task->getAll(null, TRUE, TRUE); $options = array('' => 'all'); $options += $tasks; $search->setOptions('task_id', $options); $search->setSearchData($search_data, $errors); return $search; }
public function __construct($module = null, $action = null) { parent::__construct($module, $action); $this->_templateobject = DataObjectFactory::Factory('Companycontactmethod'); $this->uses($this->_templateobject); $this->related['company'] = array('clickaction' => 'edit'); }
/** * getCustomerLines - Return a list of customer product lines (prices) * * Returns an array of product line id, product line description * containing all product lines specific to a customer * and all other non-specific customer product lines * that are for items not specific to the customer * * NOTE: To get filtered results in a single query, this function * uses sql queries, instead of constraint-chains and the * DataObject functions from the framework. It *should* be * faster than executing multiple queries and concatenating * the results in PHP. * * @param int $customer * sl_master table record id * @param string $productsearch * begining of description to search * @return (int|string)[] */ public function getCustomerLines($customer, $productsearch = '') { $customerdetail = DataObjectFactory::Factory('SLCustomer'); $customerdetail->load($customer); $price_type = $customerdetail->so_price_type_id; if (!is_null($price_type)) { $params_productsearch = [$productsearch . '%', EGS_COMPANY_ID, $customer, $price_type, $productsearch . '%', EGS_COMPANY_ID, $customer, $productsearch . '%', EGS_COMPANY_ID, $price_type, $productsearch . '%', EGS_COMPANY_ID]; $params = [EGS_COMPANY_ID, $customer, $price_type, EGS_COMPANY_ID, $customer, EGS_COMPANY_ID, $price_type, EGS_COMPANY_ID]; // Find prices for cust/price_type, cust only, price_type only, // default prices with no cust or price_type, // filtering out any prices found in the previous query. $query_productsearch = "WITH cust_type_prices AS\n \t (SELECT id, description, productline_header_id\n \t FROM so_productlines_overview\n \t WHERE description ILIKE ?\n \t AND (usercompanyid = ?\n \t AND ((start_date <= 'today'::date AND (end_date is NULL OR end_date >= 'today'::date))\n \t AND (slmaster_id = ? AND so_price_type_id = ?)))),\n \t cust_type_products AS (SELECT productline_header_id FROM cust_type_prices)\n \t SELECT id, description FROM cust_type_prices\n \t UNION\n \t SELECT id, description\n \t FROM so_productlines_overview\n \t WHERE description ilike ?\n \t AND productline_header_id NOT IN (SELECT * FROM cust_type_products)\n \t AND (usercompanyid = ? AND ((start_date <= 'today'::date AND (end_date is NULL OR end_date >= 'today'::date))\n \t AND (slmaster_id = ? AND so_price_type_id is NULL)))\n \t UNION\n \t (WITH cust_prices AS\n \t (SELECT id, description, productline_header_id\n \t FROM so_productlines_overview\n \t WHERE description ilike ?\n \t AND productline_header_id NOT IN (SELECT * FROM cust_type_products)\n \t AND (usercompanyid = ? AND ((start_date <= 'today'::date AND (end_date is NULL OR end_date >= 'today'::date))\n \t AND (slmaster_id IS NULL AND so_price_type_id = ?)))),\n \t cust_products AS (SELECT productline_header_id FROM cust_prices)\n \t SELECT id, description FROM cust_prices\n \t UNION\n \t SELECT id, description\n \t FROM so_productlines_overview\n \t WHERE description ilike ?\n \t AND productline_header_id NOT IN (SELECT * FROM cust_type_products UNION SELECT * FROM cust_products)\n \t AND (usercompanyid = ? AND ((start_date <= 'today'::date AND (end_date is NULL OR end_date >= 'today'::date))\n \t AND (slmaster_id IS NULL AND so_price_type_id IS NULL)))\n \t )\n \t ORDER BY description"; // Save 100ms approx, if product search not needed $query = "WITH cust_type_prices AS\n \t (SELECT id, description, productline_header_id\n \t FROM so_productlines_overview\n \t WHERE (usercompanyid = ?\n \t AND ((start_date <= 'today'::date AND (end_date is NULL OR end_date >= 'today'::date))\n \t AND (slmaster_id = ? AND so_price_type_id = ?)))),\n \t cust_type_products AS (SELECT productline_header_id FROM cust_type_prices)\n \t SELECT id, description FROM cust_type_prices\n \t UNION\n \t SELECT id, description\n \t FROM so_productlines_overview\n \t WHERE productline_header_id NOT IN (SELECT * FROM cust_type_products)\n \t AND (usercompanyid = ? AND ((start_date <= 'today'::date AND (end_date is NULL OR end_date >= 'today'::date))\n \t AND (slmaster_id = ? AND so_price_type_id is NULL)))\n \t UNION\n \t (WITH cust_prices AS\n \t (SELECT id, description, productline_header_id\n \t FROM so_productlines_overview\n \t WHERE productline_header_id NOT IN (SELECT * FROM cust_type_products)\n \t AND (usercompanyid = ? AND ((start_date <= 'today'::date AND (end_date is NULL OR end_date >= 'today'::date))\n \t AND (slmaster_id IS NULL AND so_price_type_id = ?)))),\n \t cust_products AS (SELECT productline_header_id FROM cust_prices)\n \t SELECT id, description FROM cust_prices\n \t UNION\n \t SELECT id, description\n \t FROM so_productlines_overview\n \t WHERE productline_header_id NOT IN (SELECT * FROM cust_type_products UNION SELECT * FROM cust_products)\n \t AND (usercompanyid = ? AND ((start_date <= 'today'::date AND (end_date is NULL OR end_date >= 'today'::date))\n \t AND (slmaster_id IS NULL AND so_price_type_id IS NULL)))\n \t )\n \t ORDER BY description"; } else { $params_productsearch = [$productsearch . '%', EGS_COMPANY_ID, $customer, $productsearch . '%', EGS_COMPANY_ID]; $params = [EGS_COMPANY_ID, $customer, EGS_COMPANY_ID]; $query_productsearch = "WITH cust_prices AS\n\t (SELECT id, description, productline_header_id\n\t FROM so_productlines_overview\n\t WHERE description ILIKE ? AND\n\t (usercompanyid = ? AND ((start_date <= 'today'::date AND (end_date is NULL OR end_date >= 'today'::date))\n\t AND (slmaster_id = ? AND so_price_type_id IS NULL)))),\n cust_products AS (SELECT productline_header_id FROM cust_prices)\n SELECT id, description FROM cust_prices\n UNION\n SELECT id, description\n\t FROM so_productlines_overview\n\t WHERE description ILIKE ? AND\n\t productline_header_id NOT IN (SELECT * FROM cust_products)\n\t AND (usercompanyid = ? AND ((start_date <= 'today'::date AND (end_date is NULL OR end_date >= 'today'::date))\n\t AND (slmaster_id IS NULL AND so_price_type_id IS NULL)))\n ORDER BY description"; $query = "WITH cust_prices AS\n\t (SELECT id, description, productline_header_id\n\t FROM so_productlines_overview\n\t WHERE (usercompanyid = ? AND ((start_date <= 'today'::date AND (end_date is NULL OR end_date >= 'today'::date))\n\t AND (slmaster_id = ? AND so_price_type_id IS NULL)))),\n cust_products AS (SELECT productline_header_id FROM cust_prices)\n SELECT id, description FROM cust_prices\n UNION\n SELECT id, description\n\t FROM so_productlines_overview\n\t WHERE productline_header_id NOT IN (SELECT * FROM cust_products)\n\t AND (usercompanyid = ? AND ((start_date <= 'today'::date AND (end_date is NULL OR end_date >= 'today'::date))\n\t AND (slmaster_id IS NULL AND so_price_type_id IS NULL)))\n ORDER BY description"; } if ($productsearch != '') { $query = $query_productsearch; $params = $params_productsearch; } $db =& DB::Instance(); $rset = $db->Execute($query, $params); if ($rset) { $rows = $rset->GetAssoc(); return $rows; } return []; }
public static function useDefault(&$search_data = null, &$errors = array(), $defaults = null) { $search = new sttransactionsSearch($defaults); // Search by Stock Item $search->addSearchField('stitem_id', 'Stock Item', 'select', '', 'basic'); $stitem = DataObjectFactory::Factory('STItem'); $options = array('' => 'All'); $stitems = $stitem->getAll(); $options += $stitems; $search->setOptions('stitem_id', $options); // Search by Status $search->addSearchField('status', 'Status', 'select', '', 'advanced'); $transaction = DataObjectFactory::Factory('STTransaction'); $options = array('' => 'All'); $statuses = $transaction->getEnumOptions('status'); $options += $statuses; $search->setOptions('status', $options); // Search by Location $search->addSearchField('whlocation_id', 'Location', 'select', '', 'advanced'); $whlocation = new WHLocationCollection(); $options = array('' => 'All'); $whlocations = $whlocation->getLocationList(); $options += $whlocations; $search->setOptions('whlocation_id', $options); // Search by Process $search->addSearchField('process_name', 'Process', 'select', '', 'advanced'); $options = array('' => 'All'); $statuses = $transaction->getEnumOptions('process_name'); $options += $statuses; $search->setOptions('process_name', $options); // Search by Date $search->addSearchField('created', 'Date between', 'between', '', 'advanced'); $search->setSearchData($search_data, $errors); return $search; }
public static function useDefault($search_data = null, &$errors = array(), $defaults = null) { $search = new mfshiftsSearch($defaults); $mfshift = DataObjectFactory::Factory('MFShift'); // Search by Shift $search->addSearchField('shift', 'shift', 'multi_select', array()); $search->setOptions('shift', $mfshift->getEnumOptions('shift')); // Search by Shift Date $search->addSearchField('shift_date', 'Required Between', 'between', '', 'advanced'); // Search by Dept $search->addSearchField('mf_dept_id', 'Dept', 'select', '', 'advanced'); $depts = $mfshift->getAllDept(); $options = array('' => 'All'); $options = $options + $depts; $search->setOptions('mf_dept_id', $options); // Search by Centre /* This needs to be constrained by the selection of the dept code * $search->addSearchField( 'mf_centre_id', 'Centre', 'select', '', 'advanced' ); $centres=$mfshift->getAllCentres(); $options=array(''=>'All'); $options=$options+$centres; $search->setOptions('mf_dept_id',$options); */ $search->setSearchData($search_data, $errors); return $search; }
public static function useDefault($search_data = null, &$errors = array(), $defaults = null) { $search = new sltransactionsSearch($defaults); $sltrans = DataObjectFactory::Factory('SLTransaction'); // Search by Customer $search->addSearchField('slmaster_id', 'Customer', 'select', 0, 'advanced'); $customer = DataObjectFactory::Factory('SLCustomer'); $options = array('0' => 'All'); $customers = $customer->getAll(null, false, true); $options += $customers; $search->setOptions('slmaster_id', $options); // Search by Person $search->addSearchField('person', 'person', 'contains', '', 'advanced'); // Search by Invoice Number $search->addSearchField('our_reference', 'our_reference', 'equal', '', 'advanced'); // Search by Sales Order Number $search->addSearchField('transaction_date', 'transaction_date_between', 'between', '', 'advanced'); // Search by Customer Reference $search->addSearchField('ext_reference', 'customer reference', 'equal', '', 'advanced'); // Search by Invoice Date $search->addSearchField('due_date', 'due_date_between', 'between', '', 'advanced'); // Search by Transaction Type $search->addSearchField('transaction_type', 'transaction_type', 'select', '', 'advanced'); $options = array_merge(array('' => 'All'), $sltrans->getEnumOptions('transaction_type')); $search->setOptions('transaction_type', $options); // Search by Status $search->addSearchField('status', 'status', 'select', '', 'advanced'); $options = array_merge(array('' => 'All'), $sltrans->getEnumOptions('status')); $search->setOptions('status', $options); $search->setSearchData($search_data, $errors); return $search; }
public function getBinLocationList($source) { $WHLocation = DataObjectFactory::Factory('WHLocation'); $cc = new ConstraintChain(); $cc->add(new Constraint('whstore_id', '=', $source)); $cc->add(new Constraint('bin_controlled', '=', 'true')); return $WHLocation->getAll($cc); }
function getAccessValue() { if ($this->isLoaded()) { $access_type = DataObjectFactory::Factory($this->access_type); $access_type->load($this->access_object_id); return $access_type->getIdentifierValue(); } }
public function getWasteTypes() { $centrewastetypes = DataObjectFactory::Factory('MFCentreWasteType'); $cc = new ConstraintChain(); $cc->add(new Constraint('mf_centre_id', '=', $this->mf_centre_id)); $centrewastetypes->identifierField = 'waste_type'; return $centrewastetypes->getAll($cc, null, true); }
public static function getReportsByType($_report_type_id) { $report_definition = DataObjectFactory::Factory('ReportDefinition'); $report_definition->idField = 'name'; $cc = new ConstraintChain(); $cc->add(new Constraint('report_type_id', '=', $_report_type_id)); return $report_definition->getAll($cc); }
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)); }
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(); }
static function Factory($data, &$errors = array(), $do_name = null) { $address = DataObjectFactory::Factory($do_name); $address->check_exists($data); if ($address->isLoaded()) { return $address; } return parent::factory($data, $errors, $address); }