本文整理汇总了PHP中SearchHandler::setOrderBy方法的典型用法代码示例。如果您正苦于以下问题:PHP SearchHandler::setOrderBy方法的具体用法?PHP SearchHandler::setOrderBy怎么用?PHP SearchHandler::setOrderBy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SearchHandler
的用法示例。
在下文中一共展示了SearchHandler::setOrderBy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: useDefault
public static function useDefault($search_data = null, &$errors = array(), $defaults = null)
{
$search = new VatSearch($defaults);
$search->addSearchField('box', 'Box', 'hidden', '', 'hidden');
$default_year = date('Y');
$default_tax_period = 1;
$glperiod = GLPeriod::getPeriod(date('Y-m-d'));
if ($glperiod && count($glperiod) > 0) {
$default_year = $glperiod['year'];
$default_tax_period = $glperiod['tax_period'];
}
$search->addSearchField('year', 'Year', 'select', $default_year, 'basic');
$search->addSearchField('tax_period', 'Tax Period', 'select', $default_tax_period, 'basic');
$glperiods = new GLPeriodCollection();
$sh = new SearchHandler($glperiods, false);
$sh->setOrderBy('year');
$glperiods->load($sh);
$glperiods = $glperiods->getContents();
$options = array();
foreach ($glperiods as $glperiod) {
if (!array_key_exists($glperiod->year, $options)) {
$options[$glperiod->year] = $glperiod->year;
}
}
$search->setOptions('year', $options);
$tax_periods = GLPeriod::getTaxPeriods();
$options = array_combine($tax_periods, $tax_periods);
$search->setOptions('tax_period', $options);
$search->setSearchData($search_data, $errors);
return $search;
}
示例2: populate
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();
}
示例3: _new
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);
}
示例4: array
function __construct($tablename = 'projects')
{
// Register non-persistent attributes
// Contruct the object
parent::__construct($tablename);
// Set specific characteristics
$this->idField = 'id';
$this->identifierField = array('job_no', 'name');
$this->orderby = 'job_no';
// Define relationships
$this->belongsTo('Company', 'company_id', 'company');
$this->belongsTo('User', 'owner', 'project_owner');
$this->belongsTo('User', 'altered_by', 'altered');
$this->belongsTo('Person', 'person_id', 'person', null, "surname || ', ' || firstname");
$cc = new ConstraintChain();
$cc->add(new Constraint('company_id', '=', EGS_COMPANY_ID));
$this->belongsTo('Person', 'key_contact_id', 'key_contact', $cc, "surname || ', ' || firstname");
$this->belongsTo('Opportunity', 'opportunity_id', 'opportunity');
$this->belongsTo('Projectcategory', 'category_id', 'category');
$this->belongsTo('Projectworktype', 'work_type_id', 'work_type');
$this->belongsTo('Projectphase', 'phase_id', 'phase');
$this->hasMany('ProjectBudget', 'budgets');
$this->hasMany('Task', 'tasks');
// $this->hasMany('ProjectIssue','issues');
$this->hasMany('ProjectNote', 'notes');
$this->hasMany('Hour', 'hours');
$this->hasMany('Expense', 'expenses');
$this->hasMany('Resource', 'resources');
// Note: 'projectattachment' model does not exist - it is here to generate
// the sidebar related link to projectattachmentcontroller
$this->hasMany('projectattachment', 'attachments');
$this->hasMany('LoggedCall', 'calls');
$this->hasMany('ProjectEquipmentAllocation', 'equipment_allocations', 'project_id');
$this->hasMany('ProjectCostCharge', 'actuals', 'project_id');
// $this->hasMany('ProjectCostCharge', 'purchase_orders', 'project_id');
// $this->hasMany('ProjectCostCharge', 'sales_invoices', 'project_id');
$this->hasMany('POrder', 'porders');
$this->hasMany('PInvoice', 'pinvoices');
$this->hasMany('SOrder', 'sorders');
$this->hasMany('SInvoice', 'sinvoices');
$this->hasMany('MFWorkorder', 'mfworkorders');
$tasks = new TaskCollection(new Task());
$sh = new SearchHandler($tasks, false);
$sh->addConstraint(new Constraint('parent_id', ' is ', 'NULL'));
$sh->setOrderBy('start_date');
$this->addSearchHandler('tasks', $sh);
// Define field formats
$this->getField('cost')->setFormatter(new PriceFormatter());
$this->getField('value')->setFormatter(new PriceFormatter());
// Define field defaults
$this->getField('status')->setDefault('N');
// Define validation
$this->validateUniquenessOf(array("job_no"));
// Define enumerated types
$this->setEnum('status', array('N' => 'New', 'A' => 'Active', 'C' => 'Complete', 'X' => 'Cancelled'));
// Define link rules for sidebar related view
$this->linkRules = array('expenses' => array('modules' => array('link' => array('module' => 'hr'), 'new' => array('module' => 'hr')), 'actions' => array('link', 'new'), 'rules' => array()), 'mfworkorders' => array('modules' => array('link' => array('module' => 'manufacturing')), 'actions' => array('link'), 'rules' => array(), 'label' => 'Show Works Orders'), 'porders' => array('modules' => array('link' => array('module' => 'purchase_order'), 'new' => array('module' => 'purchase_order')), 'actions' => array('link', 'new'), 'rules' => array(), 'label' => 'Show Purchase Orders'), 'pinvoices' => array('modules' => array('link' => array('module' => 'purchase_invoicing'), 'new' => array('module' => 'purchase_invoicing')), 'actions' => array('link', 'new'), 'rules' => array(), 'label' => 'Show Purchase Invoices'), 'sorders' => array('modules' => array('link' => array('module' => 'sales_order'), 'new' => array('module' => 'sales_order')), 'actions' => array('link'), 'rules' => array(), 'label' => 'Show Sales Orders'), 'sinvoices' => array('modules' => array('link' => array('module' => 'sales_invoicing'), 'new' => array('module' => 'sales_invoicing')), 'actions' => array('link'), 'rules' => array(), 'label' => 'Show Sales Invoices'));
}
示例5: showParts
public function showParts($id)
{
$elements = new MFWOStructureCollection(new MFWOStructure());
$sh = new SearchHandler($elements, false);
$sh->addConstraint(new Constraint('work_order_id', '=', $id));
$sh->setOrderBy('line_no');
$sh->extractOrdering();
$elements->load($sh);
return $elements;
}
示例6: sumByStatus
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);
}
示例7: getMostRecent
public static function getMostRecent($stitem_id, $type)
{
$cc = new ConstraintChain();
$cc->add(new Constraint('stitem_id', '=', $stitem_id));
$cc->add(new Constraint('type', '=', $type));
$sh = new SearchHandler(new STCostCollection(), false);
$sh->addConstraintChain($cc);
$sh->setOrderBy(array('lastupdated', 'id'), array('DESC', 'DESC'));
$stcost = new STCost();
return $stcost->loadBy($sh);
}
示例8: getAuthSummary
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);
}
示例9: populate
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());
}
示例10: populate
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();
}
示例11: getAuthList
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);
}
示例12: populate
function populate()
{
if (!$this->isCached()) {
$pl = new PageList('recently_added_leads');
$companies_do = new CompanyCollection(new Company());
$sh = new SearchHandler($companies_do, false);
$sh->extract();
$sh->addConstraint(new Constraint('is_lead', '=', 'true'));
$sh->setLimit(10);
$sh->setOrderBy('created', 'DESC');
$companies_do->load($sh);
$pl->addFromCollection($companies_do, array('module' => 'contacts', 'controller' => 'companys', 'action' => 'view'), array('id'), 'company', 'name');
$this->setCache($pl->getPages()->toArray());
}
$this->contents = $this->getCache();
}
示例13: populate
function populate()
{
$pl = new PageList('my_tickets');
$my_tickets = new TicketCollection(new Ticket());
$sh = new SearchHandler($my_tickets, false);
$sh->extract();
$sh->addConstraint(new Constraint('assigned_to', 'IS', 'NULL'));
$cc = new ConstraintChain();
$cc->add(new Constraint('internal_status_code', '=', 'NEW'), 'OR');
$cc->add(new Constraint('internal_status_code', '=', 'OPEN'), 'OR');
$sh->addConstraintChain($cc);
$sh->setLimit(10);
$sh->setOrderBy('created', 'DESC');
$my_tickets->load($sh);
$pl->addFromCollection($my_tickets, array('module' => 'ticketing', 'controller' => 'tickets', 'action' => 'view'), array('id'), 'ticket', 'summary');
$this->contents = $pl->getPages()->toArray();
}
示例14: statusSummary
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;
}
示例15: populate
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');
}