本文整理汇总了PHP中ConstraintChain类的典型用法代码示例。如果您正苦于以下问题:PHP ConstraintChain类的具体用法?PHP ConstraintChain怎么用?PHP ConstraintChain使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConstraintChain类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _new
public function _new()
{
parent::_new();
$resource = $this->_uses[$this->modeltype];
$db = DB::Instance();
if ($resource->isLoaded()) {
$this->_data['work_schedule_id'] = $resource->work_schedule_id;
$this->view->set('workschedule', $resource->work_schedule_detail);
} elseif (isset($this->_data['work_schedule_id'])) {
$resource->work_schedule_id = $this->_data['work_schedule_id'];
$this->view->set('workschedule', $resource->work_schedule_detail);
} else {
$workschedule = DataObjectFactory::Factory('WorkSchedule');
$cc = new ConstraintChain();
$cc->add(new Constraint('status', '!=', $workschedule->completedStatus()));
$cc->add(new Constraint('status', '!=', $workschedule->cancelledStatus()));
$this->view->set('workschedules', $workschedule->getAll($cc));
}
$person = DataObjectFactory::Factory('Person');
$cc = new ConstraintChain();
$cc->add(new Constraint('company_id', '=', COMPANY_ID));
$this->view->set('people', $person->getAll($cc));
$resources = new EngineeringResourceCollection($this->_templateobject);
$sh = $this->setSearchHandler($resources);
$sh->addConstraint(new Constraint('work_schedule_id', '=', $resource->work_schedule_id));
parent::index($resources, $sh);
$this->view->set('clickaction', 'edit');
}
示例2: getDataOptions
public function getDataOptions($model = '', $cc = '')
{
if (empty($model)) {
$model = $this->getModel();
if (!$model) {
return false;
}
}
$attribute = $this->internal_attribute;
if ($model->idField == $attribute) {
return $model->getAll($cc);
} elseif (isset($model->belongsToField[$attribute])) {
$x = $model->belongsTo[$model->belongsToField[$attribute]]["model"];
if (empty($cc) || !$cc instanceof ConstraintChain) {
$cc = new ConstraintChain();
}
if ($model->belongsTo[$model->belongsToField[$attribute]]["cc"] instanceof ConstraintChain) {
$cc->add($model->belongsTo[$model->belongsToField[$attribute]]["cc"]);
}
$x = new $x();
return $x->getAll($cc);
} else {
return array();
}
}
示例3: getTotals
public function getTotals($_project_id = '', $_task_id = '')
{
if (empty($_project_id)) {
return false;
}
$cc = new ConstraintChain();
$cc->add(new Constraint('project_id', '=', $_project_id));
if (!empty($_task_id)) {
$cc->add(new Constraint('task_id', '=', $_task_id));
}
$costs_charges = array();
foreach ($this->getEnumOptions('item_type') as $key => $type) {
$cc1 = new ConstraintChain();
$cc1->add($cc);
$cc1->add(new Constraint('item_type', '=', $key));
switch ($key) {
case 'PO':
$subkey = 'total_costs';
$tablename = 'project_purchase_orders';
break;
case 'SI':
$subkey = 'total_invoiced';
$tablename = 'project_sales_invoices';
break;
}
$totals = $this->getSumFields(array('net_value'), $cc1, $tablename);
$costs_charges[$subkey] = $totals['net_value'];
}
return $costs_charges;
}
示例4: getTypesForEmployee
function getTypesForEmployee($_employee_id)
{
$cc = new ConstraintChain();
$cc->add(new Constraint('employee_id', '=', $_employee_id));
$this->identifierField = 'authorisation_type';
return $this->getAll($cc);
}
示例5: getBinList
static function getBinList($whlocation_id)
{
$bins = new WHBin();
$cc = new ConstraintChain();
$cc->add(new Constraint('whlocation_id', '=', $whlocation_id));
return $bins->getAll($cc);
}
示例6: getCentres
public function getCentres()
{
$mf_centre = DataObjectFactory::Factory('MFCentre');
$cc = new ConstraintChain();
$cc->add(new Constraint('production_recording', 'is', 'true'));
return $mf_centre->getAll($cc);
}
示例7: _new
public function _new()
{
$resource = $this->_uses[$this->modeltype];
if (!$resource->isLoaded()) {
if (empty($this->_data['project_id'])) {
$project = new Project();
$projects = $project->getAll();
$project_id = key($projects);
} else {
$project_id = $this->_data['project_id'];
}
$this->view->set('project_id', $project_id);
$tasks = $this->getTaskList($project_id);
$dates = $this->getStartEndDate($project_id);
$this->view->set('start_date', $dates['start_date']['data']);
$this->view->set('end_date', $dates['end_date']['data']);
} else {
$tasks = $this->getTaskList($resource->project_id);
}
$this->view->set('tasks', $tasks);
$person = new Person();
$cc = new ConstraintChain();
$cc->add(new Constraint('company_id', '=', COMPANY_ID));
$this->view->set('people', $person->getAll($cc));
parent::_new();
}
示例8: view
public function view()
{
if (!$this->loadData()) {
sendback();
}
$ledgercategory = $this->_uses[$this->modeltype];
$idfield = $ledgercategory->idField;
$id = $ledgercategory->{$idfield};
// Check if Ledger Category is used by Ledger Accounts
$ledgeraccount = new LedgerCategory('ledger_category_accounts');
$ledgeraccount->idField = 'company_id';
$ledgeraccount->identifierField = 'name';
$cc = new ConstraintChain();
$cc->add(new Constraint('category_id', '=', $ledgercategory->category_id));
$ledgeraccounts = $ledgeraccount->getAll($cc);
$sidebar = new SidebarController($this->view);
$sidebarlist = array();
$sidebarlist['all'] = array('link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'index'), 'tag' => 'view_ledger_categories');
$sidebarlist['new'] = array('link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'new'), 'tag' => 'new_ledger_category');
if (count($ledgeraccounts) == 0) {
$sidebarlist['edit'] = array('link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'edit', $idfield => $ledgercategory->{$idfield}), 'tag' => 'edit_ledger_category');
$sidebarlist['delete'] = array('link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'delete', $idfield => $ledgercategory->{$idfield}), 'tag' => 'delete_ledger_category');
}
$sidebar->addList('Actions', $sidebarlist);
$this->view->register('sidebar', $sidebar);
$this->view->set('sidebar', $sidebar);
$this->view->set('model', $ledgercategory);
$this->view->set('count', count($ledgeraccounts));
}
示例9: useDefault
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;
}
示例10: load
function load($sh, $c_query = null)
{
$db = DB::Instance();
$qb = new QueryBuilder($db, $this->_doname);
if ($sh instanceof SearchHandler) {
if ($this->_templateobject->isAccessControlled()) {
if (isModuleAdmin()) {
$cc = new ConstraintChain();
$cc->add(new Constraint('usercompanyid', '=', EGS_COMPANY_ID));
$cc->add(new Constraint('id', '=', EGS_COMPANY_ID), 'OR');
$sh->addConstraintChain($cc);
$qb->setDistinct();
} else {
$cc = new ConstraintChain();
$cc->add(new Constraint('usernameaccess', '=', EGS_USERNAME));
$cc->add(new Constraint('owner', '=', EGS_USERNAME), 'OR');
$cc2 = new ConstraintChain();
$cc2->add(new Constraint('usercompanyid', '=', EGS_COMPANY_ID));
$sh->addConstraintChain($cc);
$sh->addConstraintChain($cc2);
$qb->setDistinct();
}
}
$this->sh = $sh;
}
$this->_load($sh, $qb, $c_query);
}
示例11: index
public function index()
{
$id = $this->_data['stitem_id'];
$transaction = new STItem();
$transaction->load($id);
$this->view->set('transaction', $transaction);
$outside_ops = new MFOutsideOperationCollection($this->_templateobject);
$sh = new SearchHandler($outside_ops, false);
$cc = new ConstraintChain();
$cc->add(new Constraint('stitem_id', '=', $id));
$db = DB::Instance();
$date = Constraint::TODAY;
$between = $date . ' BETWEEN ' . $db->IfNull('start_date', $date) . ' AND ' . $db->IfNull('end_date', $date);
$cc->add(new Constraint('', '', '(' . $between . ')'));
$sh->addConstraintChain($cc);
$sh->setOrderby('op_no');
$outside_ops->load($sh);
$this->view->set('outside_ops', $outside_ops);
$this->view->set('linkfield', 'id');
$this->view->set('linkvaluefield', 'id');
$this->view->set('clickaction', 'view');
$this->view->set('clickcontroller', 'MFOutsideOperations');
$this->view->set('no_ordering', true);
$sidebar = new SidebarController($this->view);
$sidebar->addList('Show', array('allItems' => array('tag' => 'All Items', 'link' => array_merge($this->_modules, array('controller' => 'STItems', 'action' => 'index'))), 'thisItem' => array('tag' => 'Item Detail', 'link' => array_merge($this->_modules, array('controller' => 'STItems', 'action' => 'view', 'id' => $id))), 'addoperation' => array('tag' => 'Add Outside Operation', 'link' => array_merge($this->_modules, array('controller' => $this->name, 'action' => 'new', 'stitem_id' => $id)))));
$this->view->register('sidebar', $sidebar);
$this->view->set('sidebar', $sidebar);
}
示例12: toConstraintChain
public function toConstraintChain()
{
$cc = new ConstraintChain();
if ($this->cleared) {
return $cc;
}
debug('BaseSearch::toConstraintChain Fields: ' . print_r($this->fields, true));
foreach ($this->fields as $group) {
foreach ($group as $field => $searchField) {
if ($field == 'balance') {
$cc1 = new ConstraintChain();
if ($searchField->getValue() == '') {
$cc1->add(new Constraint('balance', '>', '0'));
}
$cc->add($cc1);
} elseif ($field != 'parent_id' && $field != 'search_id') {
$c = $searchField->toConstraint();
if ($c !== false) {
$cc->add($c);
}
}
}
}
debug('BaseSearch::toConstraintChain Constraints: ' . print_r($cc, true));
return $cc;
}
示例13: getCalendarList
function getCalendarList($options = array())
{
$calendars = new CalendarCollection(new Calendar());
$sh = new SearchHandler($calendars, false);
$cc = new ConstraintChain();
$cc->add(new Constraint('owner', '=', EGS_USERNAME));
$cc->add(new Constraint('username', '=', EGS_USERNAME), 'OR');
$sh->addConstraintChain($cc);
$sh->setOrderby('name', 'ASC');
$calendars->load($sh);
$calendar_list = $calendars->getArray();
if (count($calendar_list) > 0) {
foreach ($calendar_list as $key => $value) {
if (isset($options[$value['id']]['status']) && $options[$value['id']]['status'] == 'on') {
$calendar_list[$key]['show'] = true;
} else {
$calendar_list[$key]['show'] = false;
}
switch ($value['type']) {
case "personal":
case "group":
$calendar_list[$key]['url'] = "/?module=calendar&controller=index&action=getJSON&id=" . $value['id'];
break;
case "gcal":
$calendar_list[$key]['url'] = $calendar_list[$key]['gcal_url'];
break;
}
$calendar_list[$key]['className'] = str_replace("#", "", $calendar_list[$key]['colour']);
}
}
return $calendar_list;
}
示例14: edit
public function edit()
{
$this->view->set('field_name', $this->_data['field_name']);
$modulecomponent = new ModuleComponent();
$modulecomponent->load($this->_data['module_components_id']);
$model = new $modulecomponent->name();
$field = $model->getField($this->_data['field_name']);
$this->view->set('field', $field);
if (isset($model->belongsToField[$field->name])) {
$x = $model->belongsTo[$model->belongsToField[$field->name]]["model"];
$cc = new ConstraintChain();
if ($model->belongsTo[$model->belongsToField[$field->name]]["cc"] instanceof ConstraintChain) {
$cc->add($model->belongsTo[$model->belongsToField[$field->name]]["cc"]);
}
$x = new $x();
$this->view->set('options', $x->getAll($cc));
$field->type = 'select';
}
if ($model->isEnum($field->name)) {
$this->view->set('options', $model->getEnumOptions($field->name));
$field->type = 'select';
}
if (empty($this->_data['id'])) {
// sendTo($this->name,'new',$this->_modules);
unset($this->_data['id']);
$this->view->set('module_components_id', $this->_data['module_components_id']);
parent::_new();
$this->_templateName = $this->getTemplateName('new');
} else {
parent::edit();
}
}
示例15: confirmReceipt
public static function confirmReceipt($search_data = null, &$errors = array(), $defaults = null)
{
$search = new pogoodsreceivedSearch($defaults);
// Search by Customer
$search->addSearchField('plmaster_id', 'Supplier', 'select', 0);
$supplier = new PLSupplier();
$options = array('0' => 'Select Supplier');
$suppliers = $supplier->getAll(null, false, true);
$options += $suppliers;
$search->setOptions('plmaster_id', $options);
// Search by Stock Item
$search->addSearchField('stitem_id', 'Stock Item', 'select', 0);
$stitems = new STItem();
$options = array('0' => 'All');
$stitems = $stitems->getAll();
$options += $stitems;
$search->setOptions('stitem_id', $options);
// Search by Order Number
$search->addSearchField('order_id', 'order_number', 'select', 0);
$orderlines = new POrder();
$cc = new ConstraintChain();
$cc->add(new Constraint('status', 'in', "('A','O','P')"));
$orderlines->orderby = 'order_number';
$options = array('0' => 'All');
$orderlines = $orderlines->getAll($cc);
$options += $orderlines;
$search->setOptions('order_id', $options);
$search->setSearchData($search_data, $errors, 'confirmReceipt');
// Do not save the order_id
// - if the order is confirmed, then it will not be in the list on re-query
if (isset($_SESSION['searches'][get_class($search)]['confirmReceipt']['order_id'])) {
unset($_SESSION['searches'][get_class($search)]['confirmReceipt']['order_id']);
}
return $search;
}