function getCompanies() { $sh = new SearchHandler($this, false); $sh->setFields(array('company_id', 'company')); $this->load($sh); return $this->getAssoc(); }
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'; }
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; }
function getPermissionIDs($systemcompany, $orderby = 'permission') { $sh = new SearchHandler($this, false, false); $sh->setFields(array('permissionid', 'permission')); $sh->addConstraint(new Constraint('usercompanyid', '=', $systemcompany)); $sh->setOrderby($orderby); $this->load($sh); return $this->getAssoc(); }
public static function getOutsideOperationCosts(ConstraintChain $cc, $type = 'latest') { $mfoutsideops = new MFOutsideOperationCollection(); $sh = new SearchHandler($mfoutsideops, false); $sh->addConstraintChain($cc); $fields = array('id', 'op_no', 'description', $type . '_osc'); $sh->setFields($fields); $sh->setOrderby('op_no'); $mfoutsideops->load($sh); return $mfoutsideops; }
function sumByStatus($cc = '') { $sh = new SearchHandler($this, FALSE); if ($cc instanceof ConstraintChain) { $sh->addConstraintChain($cc); } $sh->setFields(array('status as id', 'status', 'sum(num_days) as num_days')); $sh->setGroupBy(array('status as id', 'status')); $sh->setOrderBy('status'); return $this->load($sh); }
public function getAuthSummary($_order_id) { $sh = new SearchHandler($this, false); $fields = array("glcentre||' '||glaccount", 'glcentre_id', 'glaccount_id'); $sh->setGroupBy($fields); $sh->setOrderBy($fields); $fields[] = 'sum(base_net_value) as net_value'; $sh->setFields($fields); $sh->addConstraint(new Constraint('order_id', '=', $_order_id)); $sh->addConstraint(new Constraint('status', '!=', $this->_templateobject->cancelStatus())); $this->load($sh); }
function summaryPayments() { $sh = new SearchHandler($this, false); $sh->addConstraint(new Constraint('for_payment', 'is', 'true')); $sh->addConstraint(new Constraint('status', '=', 'O')); $fields = array('currency', 'payment_type', 'currency_id', 'payment_type_id'); $sh->setGroupBy($fields); $sh->setOrderby($fields); $fields[] = 'sum(os_value) as payment'; $fields[] = 'count(*) as records'; $sh->setFields($fields); $this->load($sh); }
public function getItemDates($cc = "") { $sh = new SearchHandler($this, false); $DisplayFields = array('due_delivery_date', 'stitem_id', 'stitem', 'uom_name', 'on_order'); $sh->setOrderby('due_delivery_date'); $sh->setFields($DisplayFields); if (!empty($cc) && $cc instanceof ConstraintChain) { $sh->addConstraintChain($cc); } $this->_tablename = 'po_itemdates'; $this->load($sh); return $this; }
function getToLocations($whaction_id, $from_whlocation_id) { $sh = new SearchHandler($this, false); $sh->addConstraint(new Constraint('whaction_id', '=', $whaction_id)); if (!is_array($from_whlocation_id)) { $from_whlocation_id = array($from_whlocation_id); } if (count($from_whlocation_id) > 0) { $sh->addConstraint(new Constraint('from_whlocation_id', '=', '(' . implode(',', $from_whlocation_id) . ')')); } $sh->setFields(array('to_whlocation_id', 'to_location')); $this->load($sh); return $this->getAssoc(); }
function populate() { $tasks_do = new TaskCollection(); $tasks_do->setParams(); $sh = new SearchHandler($tasks_do, false); $sh->setFields(array('id', 'name')); $this->setSearchLimit($sh); $sh->setOrderBy('created', 'ASC'); $sh->addConstraint(new Constraint('progress', '<', 100)); $sh->addConstraint(new Constraint('owner', '=', EGS_USERNAME)); $tasks_do->load($sh); $tasks_do->clickcontroller = 'tasks'; $tasks_do->editclickaction = 'view'; $this->contents = $tasks_do; }
function populate() { $po_obj = new DataObject('po_no_auth_user'); $po_obj->idField = 'id'; $po_obj->identifierField = 'order_number'; $po_col = new DataObjectCollection($po_obj); $po_col->setParams(); $sh = new SearchHandler($po_col, false); $sh->setFields(array('id', 'order_number', 'supplier', 'status')); $sh->addConstraint(new Constraint('status', '!=', 'X')); $this->setSearchLimit($sh); $sh->setOrderby(array('order_date', 'due_date', 'order_number')); $po_col->load($sh); $this->contents = $po_col; }
function summaryPayments() { $sh = new SearchHandler($this, false); $sh->addConstraint(new Constraint('for_payment', 'is', 'true')); $sh->addConstraint(new Constraint('status', '=', 'O')); $fields = array('currency', 'payment_type', 'currency_id', 'payment_type_id'); $sh->setGroupBy($fields); $sh->setOrderby($fields); // Sum the os_value of all rows marked for_payment // less the settlement_discount for those rows marked for_payment and include_discount $fields[] = 'sum(os_value-cast(include_discount as integer)*coalesce(settlement_discount,0)) as payment'; $fields[] = 'count(*) as records'; $sh->setFields($fields); $this->load($sh); }
function populate() { $header = DataObjectFactory::Factory('GLTransactionHeader'); $journals = new GLTransactionHeaderCollection($header); $journals->setParams(); $sh = new SearchHandler($journals, false); $sh->addConstraint(new Constraint('status', '=', $header->newStatus())); $sh->addConstraint(new Constraint('type', '=', $header->standardJournal())); $sh->setFields(array('id', 'docref', 'transaction_date', 'glperiod', 'reference', 'comment')); $this->setSearchLimit($sh); $journals->load($sh); $journals->clickcontroller = 'gltransactionheaders'; $journals->editclickaction = 'view'; $this->contents = $journals; }
public function index() { $collection = new TicketCollection($this->_templateobject); $sh = new SearchHandler($collection, false); $sh->extract(); $sh->setFields(array('id' => 'id', 'summary' => 'summary', 'originator_person' => 'originator_person', 'client_ticket_status' => 'client_ticket_status', 'client_ticket_priority' => 'client_ticket_priority', 'client_ticket_severity' => 'client_ticket_severity', 'created' => 'created', 'lastupdated' => 'lastupdated')); $this->setSearch('TicketsSearch', 'useClient'); parent::index($collection, $sh); $this->view->set('no_delete', true); $this->view->set('clickaction', 'view'); $sidebar = new SidebarController($this->view); $sidebar->addList('Actions', array('new' => array('link' => array('module' => 'ticketing', 'controller' => 'client', 'action' => 'new'), 'tag' => 'New Ticket'))); $this->view->register('sidebar', $sidebar); $this->view->set('sidebar', $sidebar); }
public function accrueLine($_ids = '', &$errors = array(), $_reverse_accrual = FALSE) { if (empty($_ids) || !is_array($_ids)) { return FALSE; } $db =& DB::Instance(); $db->StartTrans(); $poreceivedline = DataObjectFactory::Factory('POReceivedLine'); $poreceivedlines = new POReceivedLineCollection($poreceivedline); $sh = new SearchHandler($poreceivedlines, FALSE); $sh->addConstraint(new Constraint('id', 'in', '(' . implode(',', array_keys($_ids)) . ')')); $glparams = DataObjectFactory::Factory('GLParams'); $accrual_control = $glparams->accruals_control_account(); $result = TRUE; if (!empty($accrual_control)) { $cost_centre = $glparams->balance_sheet_cost_centre(); $sh->setFields(array('id', 'glaccount_id', 'glcentre_id', 'item_description', 'net_value', 'order_number', 'rate', 'received_date')); $rows = $poreceivedlines->load($sh, null, RETURN_ROWS); $gltransactions = GLTransaction::makeFromGRN(array('control_glaccount_id' => $accrual_control, 'control_glcentre_id' => $cost_centre, 'reverse_accrual' => $_reverse_accrual), $rows, $errors); if (count($errors) > 0) { $result = FALSE; $errors[] = 'Error saving GL Transaction : ' . $db->ErrorMsg(); } else { // Save the GL Transactions and update the balances if (!GLTransaction::saveTransactions($gltransactions, $errors)) { $result = FALSE; $errors[] = 'Error saving GL Transaction : ' . $db->ErrorMsg(); } } } // Now update the received lines status to accrued if ($result !== FALSE) { if ($_reverse_accrual) { $result = $poreceivedlines->update('status', $poreceivedline->writeOffStatus(), $sh); } else { $result = $poreceivedlines->update('status', $poreceivedline->accrualStatus(), $sh); } if ($result !== FALSE && $result != count($_ids)) { $errors[] = 'Updated ' . $result . ' expected ' . count($_ids); $result = FALSE; } } if ($result === FALSE) { $db->FailTrans(); } $db->CompleteTrans(); return $result; }
public function getItemOrders($cc = "") { $sh = new SearchHandler($this, FALSE); $DisplayFields = array('id', 'stitem_id', 'due_despatch_date', 'stitem', 'order_number', 'line_number', 'order_id', 'customer', 'slmaster_id', 'stuom', 'required', 'delivery_note', 'despatch_action', 'status', 'account_status', 'status', 'item_description', 'productline_id'); // $sh->setOrderby( // array('order_number', 'line_number'), // array('ASC', 'ASC') // ); $sh->setFields($DisplayFields); if (!empty($cc) && $cc instanceof ConstraintChain) { $sh->addConstraintChain($cc); } $this->_tablename = 'so_itemorders'; $this->load($sh); return $this; }
function statusSummary($orderline_id) { // Returns an array of the statuses of POReceived lines // for the supplied orderline_id // i.e. there can be more than one received line (part delivery) for an order line $sh = new SearchHandler($this, false); $sh->addConstraint(new Constraint('orderline_id', '=', $orderline_id)); $sh->setFields(array('status', 'sum(received_qty) as received_qty')); $sh->setGroupBy(array('status')); $sh->setOrderBy(array('status')); $rows = $this->load($sh, null, RETURN_ROWS); $status = array(); foreach ($rows as $line) { $status[$line['id']] = $line['received_qty']; } return $status; }
function populate() { $module = DataObjectFactory::Factory('ModuleObject'); $module->loadBy('name', $_GET['module']); $files = new EntityAttachmentCollection(); $files->setParams(); $pl = new PageList(' Documents'); $sh = new SearchHandler($files, FALSE); $fields = array('id', 'file as document', 'revision', 'note', 'file_id'); $sh->setOrderBy('file'); $sh->setFields($fields); $sh->addConstraint(new Constraint('entity_id', '=', $module->id)); $sh->addConstraint(new Constraint('data_model', '=', 'moduleobject')); $this->setSearchLimit($sh); $files->load($sh); $this->contents = $files; $ao = AccessObject::Instance(); $this->contents->can_upload = $ao->hasPermission($_GET['module'], 'attachments', 'new'); }
public function create($period) { $balance = new GLBalance(); // Set the identifier field - this is used by bulk_insert // to count the distinct rows that should be inserted $balance->identifierField = "glcentre_id||'-'||glaccount_id"; $balance->orderby = ''; $balances = new GLBalanceCollection($balance); $balances->setTablename('gl_year_to_date_summary'); $balances->orderby = ''; $sh = new SearchHandler($balances, false); $fields = array($period->id . ' as glperiods_id'); $fields = array('glcentre_id', 'glaccount_id', 'glperiods_id', 'mth_actual', 'ytd_actual', 'usercompanyid', "'" . EGS_USERNAME . "' as createdby", "'" . EGS_USERNAME . "' as alteredby"); $sh->setFields($fields); $sh->addConstraint(new Constraint('year', '=', $period->year)); $sh->addConstraint(new Constraint('period', '=', $period->period)); // Insert the year to date values $result = $this->bulk_insert(array('glcentre_id', 'glaccount_id', 'glperiods_id', 'mth_actual', 'ytd_actual', 'usercompanyid', 'createdby', 'alteredby'), $sh); return $result; }
function getServiceHistory() { $enddate = fix_date('01/' . date('m/Y')); $startdate = fix_date(date(DATE_FORMAT, strtotime("-12 months", strtotime($enddate)))); $enddate = fix_date(date(DATE_FORMAT)); $this->_tablename = 'customer_service_summary'; $sh = new SearchHandler($this, FALSE); $sh->addConstraint(new Constraint('despatch_date', 'between', "'" . $startdate . "' and '" . $enddate . "'")); $sh->setFields(array('year_month', 'sum(ontime) as ontime', 'sum(infull) as infull', 'sum(otif) as otif', 'sum(count) as count')); $sh->setGroupBy("year_month"); $sh->setOrderBy("year_month"); $this->load($sh); for ($i = 0; $i < 13; $i++) { $date = date('Y/m', strtotime("+" . $i . " months", strtotime($startdate))); $this->customerorders['previous'][$date]['ontime'] = 0; $this->customerorders['previous'][$date]['infull'] = 0; $this->customerorders['previous'][$date]['ontime_infull'] = 0; $this->customerorders['previous'][$date]['count'] = 0; } foreach ($this as $despatch) { if (isset($this->customerorders['previous'][$despatch->id])) { $this->customerorders['previous'][$despatch->id]['ontime'] = $despatch->ontime; $this->customerorders['previous'][$despatch->id]['infull'] = $despatch->infull; $this->customerorders['previous'][$despatch->id]['ontime_infull'] = $despatch->otif; $this->customerorders['previous'][$despatch->id]['count'] = $despatch->count; } } foreach ($this->customerorders['previous'] as $date => $month) { if ($month['count'] == 0) { $this->customerorders['previous'][$date]['ontime%'] = 0; $this->customerorders['previous'][$date]['infull%'] = 0; $this->customerorders['previous'][$date]['ontime_infull%'] = 0; } else { $this->customerorders['previous'][$date]['ontime%'] = $month['ontime'] * 100 / $month['count']; $this->customerorders['previous'][$date]['infull%'] = $month['infull'] * 100 / $month['count']; $this->customerorders['previous'][$date]['ontime_infull%'] = $month['ontime_infull'] * 100 / $month['count']; } } return $this->customerorders; }
function getYearEndBalances($glperiod_ids, $type) { if (count($glperiod_ids) > 0) { $sh = new SearchHandler($this, false); switch ($type) { case 'P': $fields = array('actype'); break; case 'B': $fields = array('glcentre_id||\'-\'||glaccount_id', 'glcentre_id', 'glaccount_id'); break; } $sh->setGroupBy($fields); $sh->setOrderBy($fields); $fields[] = 'sum(value) as value'; $sh->setFields($fields); $periodsYTD = '(' . implode(',', $glperiod_ids) . ')'; $sh->addConstraint(new Constraint('actype', '=', $type)); $sh->addConstraint(new Constraint('glperiods_id', 'in', $periodsYTD)); $this->load($sh); } }
function populate() { $orderline = DataObjectFactory::Factory('SOrderLine'); $cc = new ConstraintChain(); $cc->add(new Constraint('status', 'in', "('D', 'P')")); $order_total = $orderline->getSum('base_net_value', $cc); $orders = new SOrderLineCollection($orderline); $orders->setParams(); $sh = new SearchHandler($orders, FALSE); $fields = array('order_id', 'order_number', 'customer', 'order_date', 'actual_despatch_date'); $sh->setGroupBy($fields); $sh->setOrderBy(array('actual_despatch_date', 'order_number', 'customer')); $fields[] = 'sum(base_net_value) as base_net_value'; $sh->setFields($fields); $sh->addConstraint($cc); $this->setSearchLimit($sh); $orders->load($sh); $orders->collection_date_label = 'actual_despatch_date'; $orders->collection_total_label = 'Total (Base Net Value) Order Lines not Invoiced'; $orders->collection_total = $order_total; $this->contents = $orders; }
public function getLocationList($stitem_id, $cc = '') { // Move this to STBalance as getAll - more efficient! $sh = new SearchHandler($this, false); if (!is_array($stitem_id)) { $sh->addConstraint(new Constraint('stitem_id', '=', $stitem_id)); } else { $sh->addConstraint(new Constraint('stitem_id', 'in', '(' . implode(',', $stitem_id) . ')')); } if ($cc instanceof ConstraintChain) { $sh->addConstraintChain($cc); } $sh->setFields(array('whlocation_id', 'whlocation')); // Return rows to loop round array $rows = $this->load($sh, '', RETURN_ROWS); $list = array(); if (count($rows) > 0) { foreach ($rows as $row) { $list[$row['id']] = $row['whlocation']; } } return $list; }
protected function getLineStatuses($_orderline, $_orderlines) { $linestatus = array(); $statuses = $_orderline->getEnumOptions('status'); foreach ($statuses as $key => $name) { $linestatus['linecount'] = 0; $linestatus['count'][$key] = 0; $linestatus['value'][$name] = 0; } $sh = new SearchHandler($_orderlines, false); $sh->setFields(array('status', 'sum(net_value) as net_value', 'count(*) as count')); $sh->setGroupBy('status'); $sh->setOrderBy('status'); $sh->addConstraint(new Constraint('order_id', '=', $this->id)); $_orderlines->load($sh); if ($_orderlines->count() > 0) { foreach ($_orderlines as $status) { $linestatus['linecount'] += $status->count; $linestatus['count'][$status->id] = $status->count; $linestatus['value'][$statuses[$status->id]] = $status->net_value; } } return $linestatus; }
function getVAT($data, $glperiod_ids, $control_accounts, $sum = false, $paging = false) { if (count($glperiod_ids) > 0) { $glperiods = implode(', ', $glperiod_ids); // Set data source switch ($data['box']) { // Tax overview case 1: case 4: case 7: case 6: $this->_tablename = 'gltransactions_vat'; break; // EU sales // EU sales case 8: $this->_tablename = 'gl_taxeusales'; break; // EU purchases // EU purchases case 2: case 9: $this->_tablename = 'gl_taxeupurchases'; break; } // Set constraints $cc = new ConstraintChain(); $cc->add(new Constraint('glperiods_id', ' IN', '(' . $glperiods . ')')); switch ($data['box']) { // VAT output case 1: $cc->add(new Constraint('glaccount_id', '=', $control_accounts['vat_output'])); break; // EU acquisitions // EU acquisitions case 2: case 9: $cc->add(new Constraint('glaccount_id', '=', $control_accounts['eu_acquisitions'])); break; // VAT input - also requires value from box 2 // VAT input - also requires value from box 2 case 4: $cc->add(new Constraint('glaccount_id', '=', $control_accounts['vat_input'])); break; // VAT output // VAT output case 6: case 8: $cc->add(new Constraint('glaccount_id', '=', $control_accounts['vat_output'])); break; // VAT input // VAT input case 7: $cc->add(new Constraint('glaccount_id', '=', $control_accounts['vat_input'])); break; } if (isset($data['page'])) { $sh = new SearchHandler($this, true); } else { $sh = new SearchHandler($this, false); } if ($sum) { $fields = array('1'); $sh->setGroupBy($fields); $sh->setOrderby($fields); // Set aggregate field switch ($data['box']) { // VAT output case 1: $fields[] = 'SUM(vat) * -1 AS sum'; break; // EU acquisitions (positive values only) // EU acquisitions (positive values only) case 2: // VAT input/EU acquisitions (positive values only) // VAT input/EU acquisitions (positive values only) case 4: $fields[] = 'SUM(vat) AS sum'; break; // VAT output // VAT output case 6: case 8: $fields[] = 'SUM(net) * -1 AS sum'; break; // VAT input // VAT input case 7: case 9: $fields[] = 'SUM(net) AS sum'; break; } } else { // $this->num_pages = 1; // $this->cur_page = 1; $fields = array('id', 'docref', 'glaccount_id', 'glcentre_id', 'glperiods_id', 'transaction_date', 'source', 'comment', 'type', 'usercompanyid'); switch ($data['box']) { // VAT output case 1: case 6: case 8: $fields[] = 'vat * -1 AS vat'; $fields[] = 'net * -1 AS net'; break; default: $fields[] = 'vat'; $fields[] = 'net'; break; } $sh->setOrderby(array('transaction_date', 'docref')); if ($paging) { $sh->extract(); } } $sh->setFields($fields); $sh->addConstraintChain($cc); $this->load($sh); } }
public function edit() { $id = $this->_data['username']; $this->_uses[$this->modeltype]->load($id); $user = $this->_uses[$this->modeltype]; $this->view->set('current', $user->roles->getAssoc()); $companies = new UsercompanyaccessCollection(DataObjectFactory::Factory('Usercompanyaccess')); $sh = new SearchHandler($companies, FALSE, FALSE); $sh->addConstraint(new Constraint('username', '=', $id)); $sh->setFields(array('id', 'usercompanyid')); $companies->load($sh); $this->view->set('selected_companies', $companies->getAssoc()); $this->view->set('username', $id); $this->view->set('edit', TRUE); $this->_new(); $this->setTemplateName('new'); $debug = DebugOption::getUserOption($id); $this->view->set('debug_id', $debug->id); $this->view->set('selected_options', $debug->getOptions()); }
public function make_payment() { $this->view->set('CBTransaction', DataObjectFactory::Factory('CBTransaction')); $this->view->set('company', SYSTEM_COMPANY); $this->view->set('company_id', COMPANY_ID); $employee = $this->_uses[$this->modeltype]; if (isset($this->_data['employee_id'])) { $employee->load($this->_data['employee_id']); $this->view->set('employees', array($employee->person_id => $employee->employee)); } else { $people = new EmployeeCollection(); $sh = new SearchHandler($people, false); $sh->setFields(array('person_id', 'employee')); $people->load($sh); $this->view->set('employees', $people->getAssoc()); } $tax = DataObjectFactory::Factory('TaxRate'); $rates = $tax->getAll(); $this->view->set('rates', $rates); $account = DataObjectFactory::Factory('CBAccount'); $accounts = $account->getAll(); $this->view->set('accounts', $accounts); if (isset($this->_data['cb_account_id'])) { $default_account = $this->_data['cb_account_id']; $account->load($default_account); $this->view->set('account', $account->name); } else { $account->getDefaultAccount(key($accounts)); $default_account = $account->{$account->idField}; } $this->view->set('account_id', $default_account); $currency = DataObjectFactory::Factory('Currency'); $currencies = $currency->getAll(); $this->view->set('currencies', $currencies); $this->view->set('currency_id', $account->currency_id); $this->view->set('rate', $this->getAccountCurrencyRate($default_account, $account->currency_id)); }
public function getHours($_start_date = '', $_end_date = '', $_user = '') { // Used by Ajax to get a list of hours for a user between two dates if (isset($this->_data['ajax'])) { if (!empty($this->_data['start_date'])) { $_start_date = fix_date($this->_data['start_date']); } if (!empty($this->_data['end_date'])) { $_end_date = $this->_data['end_date']; } if (!empty($this->_data['person_id'])) { $_user = $this->_data['person_id']; } } if (empty($_start_date)) { $_start_date = fix_date(date(DATE_FORMAT)); } if (empty($_end_date)) { $_end_date = fix_date(date(DATE_FORMAT, strtotime("+1 day", strtotime($_start_date)))); } if (empty($_user)) { $user = getCurrentUser(); if (!is_null($user->person_id)) { $_user = $user->person_id; } } $hours = new HourCollection(); if (!empty($_user)) { $sh = new SearchHandler($hours, false); $sh->addConstraint(new Constraint('person_id', '=', $_user)); $sh->addConstraint(new Constraint('start_time', 'between', "'" . $_start_date . "' and '" . $_end_date . "'")); $sh->setFields(array('id', 'start_time', 'type', 'duration')); $sh->setOrderBy('start_time', 'ASC'); $hours->load($sh); } if (isset($this->_data['ajax'])) { $this->view->set('no_ordering', true); $this->view->set('collection', $hours); $this->view->set('showheading', true); $this->setTemplateName('datatable_inline'); } else { return $hours; } }
public function ordersForInvoicing() { $sh = new SearchHandler($this, false); $DisplayFields = array('order_id', 'order_number'); $sh->setOrderby(array('order_number'), array('ASC')); $sh->setFields($DisplayFields); $sh->setGroupBy($DisplayFields); $order = DataObjectFactory::Factory('Sorder'); $sh->addConstraint(new Constraint('status', '=', $order->despatchStatus())); $this->load($sh); return $this; }