function SmartChimpNewslettersTable() { $table = new HasManyComplexTableField($controller = $this, $name = "SmartChimpNewsletters", $sourceClass = "SmartChimpNewsletter", $fieldList = null, $detailFormFields = null, $sourceFilter = "ParentID = " . $this->ID); $table->setPageSize(100); $table->setPermissions(array('export', 'show', 'edit', 'delete')); return $table; }
function getFormFieldExplanationHasManyTable() { $bt = defined('DB::USE_ANSI_SQL') ? "\"" : "`"; $field = new HasManyComplexTableField($controller = $this->owner, $name = "FormFieldExplanation", $sourceClass = "FormFieldExplanation", $fieldList = array("Title" => "Title"), $detailFormFields = null, $sourceFilter = "{$bt}ParentID{$bt} =" . $this->owner->ID, $sourceSort = "", $sourceJoin = ""); $field->setPermissions(array("edit", "delete")); $field->setParentClass($this->owner->class); $field->relationAutoSetting = true; return $field; }
function getQuery() { $query = parent::getQuery(); $query->select[] = "CASE WHEN \"{$this->manyManyParentClass}ID\" IS NULL THEN '0' ELSE '1' END AS \"Checked\""; $query->groupby[] = "\"{$this->manyManyParentClass}ID\""; // necessary for Postgres return $query; }
function __construct($controller, $name, $sourceClass, $fieldList, $detailFormFields = null, $sourceFilter = "", $sourceSort = "", $sourceJoin = "") { parent::__construct($controller, $name, $sourceClass, $fieldList, $detailFormFields, $sourceFilter, $sourceSort, $sourceJoin); $classes = array_reverse(ClassInfo::ancestry($this->controller->ClassName)); foreach ($classes as $class) { $singleton = singleton($class); $manyManyRelations = $singleton->uninherited('many_many', true); if (isset($manyManyRelations) && array_key_exists($this->name, $manyManyRelations)) { $this->manyManyParentClass = $class; $manyManyTable = $class . '_' . $this->name; break; } $belongsManyManyRelations = $singleton->uninherited('belongs_many_many', true); if (isset($belongsManyManyRelations) && array_key_exists($this->name, $belongsManyManyRelations)) { $this->manyManyParentClass = $class; $manyManyTable = $belongsManyManyRelations[$this->name] . '_' . $this->name; break; } } $source = $this->sourceClass; $sourceField = $this->sourceClass; if ($this->manyManyParentClass == $source) { $sourceField = 'Child'; } $parentID = $this->controller->ID; $this->sourceJoin .= " LEFT JOIN `{$manyManyTable}` ON (`{$source}`.`ID` = `{$sourceField}ID` AND `{$this->manyManyParentClass}ID` = '{$parentID}')"; $this->joinField = 'Checked'; }
/** * *@return HasManyComplexTableField **/ public function OrderStatusLogsTable($sourceClass, $title, $fieldList = null, $detailedFormFields = null) { $orderStatusLogsTable = new HasManyComplexTableField($this, "OrderStatusLogs", $sourceClass, null, null, "\"OrderID\" = " . $this->ID . ""); $orderStatusLogsTable->setPageSize(100); $orderStatusLogsTable->setShowPagination(false); $orderStatusLogsTable->setRelationAutoSetting(true); if ($title) { $orderStatusLogsTable->setAddTitle($title); } return $orderStatusLogsTable; }
function getQuery() { $query = parent::getQuery(); $query->select[] = "CASE WHEN \"{$this->manyManyParentClass}ID\" IS NULL THEN '0' ELSE '1' END AS Checked"; return $query; }
function getQuery() { $query = parent::getQuery(); $query->select[] = "IF(`{$this->manyManyParentClass}ID` IS NULL, '0', '1') AS Checked"; return $query; }