/** * Creates new checkbox input element * @param string $name * @param bool $value * @param bool $defaultValue * @param bool $saveValue * @return \Pecee\UI\Html\HtmlCheckbox */ public function bool($name, $value = true, $defaultValue = null, $saveValue = true) { $element = new HtmlCheckbox($name, $defaultValue === null ? '1' : $defaultValue); if ($saveValue !== false) { if ($defaultValue === null) { $defaultValue = $value; } else { $defaultValue = count($_GET) ? null : $defaultValue; } $checked = Boolean::parse(input()->get($name, $defaultValue)); if ($checked) { $element->checked(true); } } else { if (Boolean::parse($value)) { $element->checked(true); } } return $element; }
public static function getTotalBandwidth($organisationId, $startDate = null, $endDate = null, $sourceId = null, $masterOnly = null) { $where = []; if ($sourceId !== null) { $where[] = PdoHelper::formatQuery('`source_id` = %s', [$sourceId]); } else { $where[] = PdoHelper::formatQuery('`source_id` IN((SELECT `id` FROM `source` WHERE `organisation_id` = %s))', [$organisationId]); } if ($startDate !== null) { $where[] = PdoHelper::formatQuery('`created` >= FROM_UNIXTIME(%s)', [strtotime($startDate)]); } if ($endDate !== null) { $where[] = PdoHelper::formatQuery('`created` <= FROM_UNIXTIME(%s)', [strtotime($endDate)]); } if ($masterOnly !== null) { $where[] = PdoHelper::formatQuery('`master` = %s', [Boolean::parse($masterOnly)]); } return self::scalar('SELECT SUM(`filesize`) FROM {table} WHERE ' . join(' && ', $where) . ' ORDER BY `created` DESC'); }