public function getFormItems($billing = 1, $shipping = 1, $account = 0)
{
$db = Factory::getDBO();
$user = PhocacartUser::getUser();
$userLevels = implode(',', $user->getAuthorisedViewLevels());
$userGroups = implode(',', PhocacartGroup::getGroupsById($user->id, 1, 1));
$wheres = array();
if ((int) $billing == 1) {
$wheres[] = '(a.display_billing = 1 OR a.display_shipping = 1)';
//$wheres[] = 'a.display_shipping = 1';// they are loaded together (shipping and billing loaded togehter)
// if billing is disabled and shipping enabled we still need to load the billing too
}
if ((int) $shipping == 1) {
$wheres[] = '(a.display_shipping = 1 OR a.display_billing = 1)';
//$wheres[] = 'a.display_billing = 1';// they are loaded together
}
if ((int) $account == 1) {
$wheres[] = 'a.display_account = 1';
}
$wheres[] = 'a.published = 1';
// ACCESS
$wheres[] = " a.access IN (" . $userLevels . ")";
$wheres[] = " (ga.group_id IN (" . $userGroups . ") OR ga.group_id IS NULL)";
$where = count($wheres) ? ' WHERE ' . implode(' AND ', $wheres) : '';
$query = 'SELECT a.id, a.title, a.label, a.description, a.type, a.predefined_values, a.predefined_values_first_option, a.default, a.class, a.read_only, a.required, a.pattern, a.maxlength,' . ' a.display_billing, a.display_shipping, a.display_account, a.validate, a.unique, a.published, a.access' . ' FROM #__phocacart_form_fields AS a' . ' LEFT JOIN #__phocacart_item_groups AS ga ON a.id = ga.item_id AND ga.type = 9' . $where . ' ORDER BY a.ordering';
$db->setQuery($query);
$fields = $db->loadObjectList();
return $fields;
}