Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 2
0
 public function delete()
 {
     $flash = Flash::Instance();
     $db = DB::Instance();
     $db->StartTrans();
     $result = parent::delete();
     // Save the header to update the header totals
     if ($result && !$this->invoice_detail->save()) {
         $result = false;
         $flash->addError('Error updating header');
     }
     if ($result) {
         // Now update the line numbers of following lines
         $sinvoicelines = new SInvoiceLineCollection($this);
         $sh = new SearchHandler($sinvoicelines, false);
         $sh->addConstraint(new Constraint('invoice_id', '=', $this->invoice_id));
         $sh->addConstraint(new Constraint('line_number', '>', $this->line_number));
         if ($sinvoicelines->update('line_number', '(line_number-1)', $sh) === false) {
             $flash->addError('Error updating line numbers ' . $db->ErrorMsg());
             $result = false;
         }
     }
     if ($result === false) {
         $db->FailTrans();
     }
     $db->CompleteTrans();
     return $result;
 }
Ejemplo n.º 3
0
 function populate()
 {
     $tickets = new TicketCollection(new Ticket());
     $pl = new PageList('current_tickets');
     $ticket_sh = new SearchHandler($tickets, false);
     $ticket_sh->setLimit(10);
     $ticket_sh->setOrderBy('created', 'ASC');
     $user = new User();
     $user->loadBy('username', EGS_USERNAME);
     $ticket_sh->addConstraint(new Constraint('originator_person_id', '=', $user->username));
     $ticket_sh->addConstraint(new Constraint('usercompanyid', '=', EGS_COMPANY_ID));
     // Find open statuses
     $statuses = new TicketStatusCollection(new TicketStatus());
     $status_sh = new SearchHandler($statuses);
     $status_sh->addConstraint(new Constraint('usercompanyid', '=', EGS_COMPANY_ID));
     $status_sh->addConstraint(new Constraint('status_code', '=', 'NEW'), 'OR');
     $status_sh->addConstraint(new Constraint('status_code', '=', 'OPEN'), 'OR');
     $statuses->load($status_sh);
     foreach ($statuses->getContents() as $status) {
         $ticket_sh->addConstraint(new Constraint('client_ticket_status_id', '=', $status->id), 'OR');
     }
     $tickets->load($ticket_sh);
     $pl->addFromCollection($tickets, array('module' => 'ticketing', 'controller' => 'tickets', 'action' => 'view'), array('id'), 'ticket', 'summary');
     $this->contents = $pl->getPages()->toArray();
 }
Ejemplo n.º 4
0
 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';
 }
Ejemplo n.º 5
0
 function remittanceList($trans_id)
 {
     $sh = new SearchHandler($this, false);
     $sh->addConstraint(new Constraint('status', '=', 'P'));
     $sh->addConstraint(new Constraint('cross_ref', '=', $trans_id));
     $sh->setOrderby('transaction_date');
     $this->load($sh);
 }
Ejemplo n.º 6
0
 function getPermissions($systemcompany, $roles = null, $orderby = 'permission')
 {
     $sh = new SearchHandler($this, false);
     $sh->addConstraint(new Constraint('usercompanyid', '=', $systemcompany));
     if (!empty($roles)) {
         $sh->addConstraint(new Constraint('roleid', 'in', '(' . $roles . ')'));
     }
     $sh->setOrderby($orderby);
     $this->load($sh);
 }
 function getCompanies($category_id)
 {
     $sh = new SearchHandler($this, false);
     if (is_array($category_id)) {
         $sh->addConstraint(new Constraint('category_id', 'in', '(' . implode(',', $category_id) . ')'));
     } else {
         $sh->addConstraint(new Constraint('category_id', '=', $category_id));
     }
     $sh->setOrderby('company');
     $this->load($sh);
 }
Ejemplo n.º 8
0
 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);
 }
Ejemplo n.º 9
0
 function populate()
 {
     $pp = new PeriodicPaymentCollection();
     $pl = new PageList('overdue_periodic_payments');
     $sh = new SearchHandler($pp, false);
     $sh->addConstraint(new Constraint('status', '=', "('A')"));
     $sh->addConstraint(new Constraint('next_due_date', '<=', fix_date(date(DATE_FORMAT))));
     $this->setSearchLimit($sh);
     $sh->setOrderBy('next_due_date');
     $pp->load($sh);
     $this->contents = $pp;
 }
Ejemplo n.º 10
0
 function loadBy($username = '', $order = '')
 {
     $db = DB::Instance();
     $sh = new SearchHandler($this, false);
     if (!empty($username)) {
         $sh->addConstraint(new Constraint('username', '=', $username));
     }
     if (!empty($order)) {
         $sh->addConstraint(new Constraint('order_id', '=', $order));
     }
     $this->load($sh);
 }
Ejemplo n.º 11
0
 public function getRows($object_id = '', $object_type, $accesstype = '')
 {
     $sh = new SearchHandler($this, false);
     if (!empty($object_id)) {
         $sh->addConstraint(new Constraint('object_id', '=', $object_id));
     }
     $sh->addConstraint(new Constraint('object_type', '=', $object_type));
     $sh->addConstraint(new Constraint('username', '=', EGS_USERNAME));
     if (!empty($accesstype)) {
         $sh->addConstraint(new Constraint('"' . $accesstype . '"', 'is', true));
     }
     $this->load($sh);
 }
Ejemplo n.º 12
0
 function remittanceList($trans_id)
 {
     $allocation = DataObjectFactory::Factory('PLAllocation');
     $allocation->loadBy('transaction_id', $trans_id);
     if ($allocation->isLoaded()) {
         $sh = new SearchHandler($this, false);
         $sh->addConstraint(new Constraint('transaction_type', '!=', 'P'));
         $sh->addConstraint(new Constraint('status', '=', 'P'));
         $sh->addConstraint(new Constraint('allocation_id', '=', $allocation->allocation_id));
         $sh->setOrderby('transaction_date');
         $this->load($sh);
     }
 }
Ejemplo n.º 13
0
 function populate()
 {
     $pl = new PageList('companies_added_today');
     $companies_do = new CompanyCollection(new Company());
     $sh = new SearchHandler($companies_do, false);
     $sh->extract();
     $sh->addConstraint(new Constraint('is_lead', '=', 'false'));
     $sh->addConstraint(new Constraint('created', '>', fix_date(date(DATE_FORMAT))));
     $sh->setLimit(10);
     $companies_do->load($sh);
     $pl->addFromCollection($companies_do, array('module' => 'contacts', 'controller' => 'companys', 'action' => 'view'), array('id'), 'company', 'name');
     $this->contents = $pl->getPages()->toArray();
 }
Ejemplo n.º 14
0
 function populate()
 {
     $orders = new POrderLineCollection();
     $orders->setParams();
     $sh = new SearchHandler($orders, false);
     $sh->addConstraint(new Constraint('status', 'in', "('A','P')"));
     $sh->addConstraint(new Constraint('order_status', '!=', "X"));
     $sh->addConstraint(new Constraint('due_delivery_date', '<', fix_date(date(DATE_FORMAT))));
     $this->setSearchLimit($sh);
     $sh->setOrderBy(array('due_delivery_date', 'id'));
     $orders->load($sh);
     $this->contents = $orders;
 }
Ejemplo n.º 15
0
 function populate()
 {
     $pl = new PageList('open_opportunities');
     $open_opportunities = new OpportunityCollection(new Opportunity());
     $sh = new SearchHandler($open_opportunities, false);
     $sh->extract();
     $sh->addConstraint(new Constraint('owner', '=', EGS_USERNAME));
     $sh->addConstraint(new Constraint('open', '=', 'true'));
     $sh->setLimit(10);
     $sh->setOrderBy('cost', 'DESC');
     $open_opportunities->load($sh);
     $pl->addFromCollection($open_opportunities, array('module' => 'crm', 'controller' => 'opportunitys', 'action' => 'view'), array('id'), 'opportunity', 'name');
     $this->setData($pl->getPages()->toArray());
 }
Ejemplo n.º 16
0
 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();
 }
 static function getDefinitionTree($definition_id, $parent_id = null)
 {
     $nextlevel = new DataDefinitionDetailCollection(new DataDefinitionDetail());
     $sh = new SearchHandler($nextlevel, false);
     $sh->addConstraint(new Constraint('data_definition_id', '=', $definition_id));
     if (empty($parent_id)) {
         $sh->addConstraint(new Constraint('parent_id', 'is', 'NULL'));
     } else {
         $sh->addConstraint(new Constraint('parent_id', '=', $parent));
     }
     $sh->setOrderby('position');
     $nextlevel->load($sh);
     return $nextlevel;
 }
Ejemplo n.º 18
0
 function populate()
 {
     $my_issues = new ProjectIssueLineCollection();
     $my_issues->setParams();
     $sh = new SearchHandler($my_issues, false);
     $sh->addConstraint(new Constraint('completed', 'is', 'NULL'));
     $sh->addConstraint(new Constraint('assigned_to', '=', EGS_USERNAME));
     $this->setSearchLimit($sh);
     $sh->setFields(array('id', 'title', 'description'));
     $sh->setOrderBy('created', 'DESC');
     $my_issues->load($sh);
     $tasks_do->clickcontroller = 'projectissues';
     $tasks_do->editclickaction = 'view';
     $this->contents = $my_issues;
 }
Ejemplo n.º 19
0
 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;
 }
Ejemplo n.º 20
0
 function populate()
 {
     $pl = new PageList('current_activities');
     $current_activities = new ActivityCollection(new Activity());
     $sh = new SearchHandler($current_activities, false);
     $sh->extract();
     $sh->addConstraint(new Constraint('assigned', '=', EGS_USERNAME));
     $sh->addConstraint(new Constraint('completed', 'IS', 'NULL'));
     $sh->addConstraint(new Constraint('startdate', '<', '(now())'));
     $sh->setLimit(10);
     $sh->setOrderBy('created', 'DESC');
     $current_activities->load($sh);
     $pl->addFromCollection($current_activities, array('module' => 'crm', 'controller' => 'activitys', 'action' => 'view'), array('id'), 'activity', 'name');
     $this->contents = $pl->getPages()->toArray();
 }
Ejemplo n.º 21
0
 function getPeople($category_id)
 {
     $sh = new SearchHandler($this, false);
     $sh->addConstraint(new Constraint('category_id', '=', $category_id));
     $sh->setOrderby('surname');
     $this->load($sh);
 }
Ejemplo n.º 22
0
 public function _new()
 {
     parent::_new();
     // For new actions the stitem_id and from_uom_id will be set
     // For edit actions, the id will be set pointing to the uom conversion to be edited
     if ($this->_data['action'] == 'edit') {
         $stuom = $this->_uses[$this->modeltype];
         $stitem_id = $stuom->stitem_id;
         $stitem_uom_id = $stuom->from_uom_id;
         $stitem_uom_name = $stuom->from_uom_name;
     } else {
         $stitem = new STitem();
         $stitem->load($this->_data['stitem_id']);
         $stitem_id = $stitem->id;
         $stitem_uom_id = $stitem->uom_id;
         $stitem_uom_name = $stitem->uom_name;
     }
     $this->view->set('stitem_id', $stitem_id);
     $this->view->set('stitem_uom_id', $stitem_uom_id);
     $this->view->set('stitem_uom_name', $stitem_uom_name);
     $this->view->set('stitem', Stuomconversion::getStockItem($stitem_id));
     $elements = new STuomconversionCollection(new STuomconversion());
     $sh = new SearchHandler($elements, false);
     $sh->extract();
     $sh->addConstraint(new Constraint('stitem_id', '=', $stitem_id));
     $sh->setOrderBy('from_uom_name');
     $sh->extractOrdering();
     $sh->extractPaging();
     $elements->load($sh);
     $this->view->set('elements', $elements);
     $this->view->set('no_ordering', true);
 }
Ejemplo n.º 23
0
 public function view()
 {
     if (!$this->loadData()) {
         $this->dataError();
         sendBack();
     }
     $transaction = $this->_uses[$this->modeltype];
     $id = $transaction->id;
     $this->view->set('transaction', $transaction);
     $elements = new WHTransferruleCollection(new WHTransferrule());
     $sh = new SearchHandler($elements, false);
     $sh->extract();
     $sh->addConstraint(new Constraint('whaction_id', '=', $id));
     $sh->extractOrdering();
     $sh->extractPaging();
     $elements->load($sh);
     $this->view->set('elements', $elements);
     $sidebar = new SidebarController($this->view);
     $sidebar->addList('Show', array('all' => array('tag' => 'All Actions', 'link' => array_merge($this->_modules, array('controller' => $this->name, 'action' => 'index'))), 'locations' => array('tag' => 'All Stores', 'link' => array_merge($this->_modules, array('controller' => 'WHStores', 'action' => 'index')))));
     $sidebarlist = array();
     $sidebarlist['edit'] = array('tag' => 'Edit', 'link' => array_merge($this->_modules, array('controller' => $this->name, 'action' => 'edit', 'id' => $id)));
     $sidebarlist['delete'] = array('tag' => 'Delete', 'link' => array_merge($this->_modules, array('controller' => $this->name, 'action' => 'delete', 'id' => $id)));
     if (is_null($transaction->max_rules) || $elements->count() < $transaction->max_rules) {
         $sidebarlist['Add'] = array('tag' => 'Add Rule', 'link' => array_merge($this->_modules, array('controller' => 'WHTransferrules', 'action' => 'new', 'whaction_id' => $id)));
     }
     $sidebar->addList('This Action', $sidebarlist);
     $this->view->register('sidebar', $sidebar);
     $this->view->set('sidebar', $sidebar);
     $this->view->set('clickaction', 'view');
     $this->view->set('clickcontroller', 'WHTransferrules');
     $this->view->set('no_ordering', true);
 }
Ejemplo n.º 24
0
 function getAuthList($account = '', $centre = '', $value = '')
 {
     $this->_tablename = "po_authlist";
     $sh = new SearchHandler($this, false);
     if (!empty($account)) {
         $sh->addConstraint(new Constraint('glaccount_id', '=', $account));
     }
     if (!empty($centre)) {
         $sh->addConstraint(new Constraint('glcentre_id', '=', $centre));
     }
     if (!empty($value)) {
         $sh->addConstraint(new Constraint('order_limit', '>=', $value));
     }
     $sh->setOrderBy('username');
     $this->load($sh);
 }
Ejemplo n.º 25
0
 public function close_off_current($_employee_id, $_end_date)
 {
     $sh = new SearchHandler($this, FALSE);
     $sh->addConstraint(new Constraint('employee_id', '=', $_employee_id));
     $sh->addConstraintChain(new Constraint('end_date', 'is', 'NULL'));
     return $this->update('end_date', $_end_date, $sh);
 }
Ejemplo n.º 26
0
 public function _new()
 {
     parent::_new();
     $permissions = new PermissionCollection(new Permission());
     $sh = new SearchHandler($permissions, FALSE);
     $sh->addConstraint(new Constraint('parent_id', 'is', 'NULL'));
     $sh->setOrderby('title');
     $permissions->load($sh);
     $systemcompany = $this->_uses[$this->modeltype];
     if ($systemcompany->isLoaded()) {
         $companypermissions = new CompanypermissionCollection(new Companypermission());
         $checked = $companypermissions->getPermissionIDs($systemcompany->id);
         $this->view->set('checked', $checked);
         $debug = DebugOption::getCompanyOption($systemcompany->id);
         $this->view->set('debug_id', $debug->id);
         $this->view->set('selected_options', $debug->getOptions());
         foreach ($permissions as $permission) {
             $permission->setAdditional('permissions');
             if (isset($checked[$permission->id])) {
                 $permission->permissions = TRUE;
             } else {
                 $permission->permissions = FALSE;
             }
         }
     }
     $this->view->set('permissions', $permissions);
     $debug = new DebugOption();
     $this->view->set('debug_options', $debug->getEnumOptions('options'));
 }
Ejemplo n.º 27
0
 function getRoles()
 {
     $roles = new RoleCollection(new Role());
     $sh = new SearchHandler($roles, false, false);
     $sh->addConstraint(new Constraint('usercompanyid', '=', $this->usercompanyid));
     $roles->load($sh);
     return $roles;
 }
Ejemplo n.º 28
0
 function populate()
 {
     $invoices = new PInvoiceCollection();
     $invoices->setParams();
     $sh = new SearchHandler($invoices, false);
     $sh->addConstraint(new Constraint('status', '=', 'O'));
     $sh->addConstraint(new Constraint('due_date', '<=', fix_date(date(DATE_FORMAT))));
     $this->setSearchLimit($sh);
     $sh->setOrderBy('due_date');
     $invoices->load($sh);
     $this->contents = $invoices;
     // set vars
     $this->vars['type_label'] = 'Supplier';
     $this->vars['type_field'] = 'supplier';
     $this->vars['module'] = 'purchase_invoicing';
     $this->vars['controller'] = 'pinvoices';
 }
Ejemplo n.º 29
0
 function getJSON()
 {
     $cal_events = new CalendarEventCollection(new CalendarEvent());
     $sh = new SearchHandler($cal_events, false);
     $sh->addConstraint(new Constraint('end_time', '>=', date('o-m-d H:i:s', $this->_data['start'])));
     $sh->addConstraint(new Constraint('start_time', '<', date('o-m-d H:i:s', $this->_data['end'])));
     $sh->addConstraint(new Constraint('calendar_id', '=', $this->_data['id']));
     $cal_events->load($sh);
     $calendar = $this->_uses['Calendar'];
     $editable = $calendar->isWritable($this->_data['id']);
     $events = array();
     foreach ($cal_events as $key => $value) {
         $events[] = array('id' => $value->id, 'title' => $value->private == 't' && $value->owner != EGS_USERNAME ? 'Private' : $value->title, 'allDay' => $value->all_day == 't' ? true : false, 'start' => strtotime($value->start_time), 'end' => strtotime($value->end_time), 'editable' => $editable, 'url' => $value->private == 't' && $value->owner != EGS_USERNAME ? '' : '/?module=calendar&controller=calendarevents&action=view&id=' . $value->id, 'className' => 'fc_' . str_replace("#", "", $value->colour) . ' fc_' . $value->calendar_id);
     }
     echo json_encode($events);
     exit;
 }
Ejemplo n.º 30
0
 function populate()
 {
     $po_obj = new DataObject('po_auth_summary');
     $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', 'username', 'supplier', 'status'));
     $sh->addConstraint(new Constraint('username', '=', EGS_USERNAME));
     $sh->addConstraint(new Constraint('status', '!=', 'X'));
     $sh->addConstraint(new Constraint('type', '=', 'R'));
     $this->setSearchLimit($sh);
     $sh->setOrderby(array('order_date', 'due_date', 'order_number'));
     $po_col->load($sh);
     $this->contents = $po_col;
 }