public function save() { $row = new ItemGroup(); $row->load($_POST['id']); $post = AECToolbox::cleanPOST($_POST, false); $row->savePOSTsettings($post); if (!$row->check()) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-2); </script>\n"; exit; } if (!$row->store()) { echo "<script> alert('" . $row->getError() . "'); window.history.go(-2); </script>\n"; exit; } $row->reorder(); if ($_POST['id']) { $id = $_POST['id']; } else { $id = $row->getMax(); } if (empty($_POST['id'])) { ItemGroupHandler::setChildren(1, array($id), 'group'); } $this->setMessage(JText::_('AEC_MSG_SUCESSFULLY_SAVED')); }
public function createGroups($amount) { $db = JFactory::getDBO(); if (!$_POST['create_groups']) { $query = 'SELECT MIN(id)' . ' FROM #__acctexp_itemgroups' . ' WHERE `id` > 1'; $db->setQuery($query); $this->range['groups']['start'] = $db->loadResult(); $query = 'SELECT MAX(id)' . ' FROM #__acctexp_itemgroups'; $db->setQuery($query); $this->range['groups']['end'] = $db->loadResult(); return array(); } $colors = array('1f77b4', 'aec7e8', 'ff7f0e', 'ffbb78', '2ca02c', '98df8a', 'd62728', 'ff9896', '9467bd', 'c5b0d5', '8c564b', 'c49c94', 'e377c2', 'f7b6d2', '7f7f7f', 'c7c7c7', 'bcbd22', 'dbdb8d', '17becf', '9edae5', 'BBDDFF', '5F8BC4', 'A2BE72', 'DDFF99', 'D07C30', 'C43C42', 'AA89BB', 'B7B7B7', '808080'); $grouplist = array(); for ($i = 0; $i <= $amount; $i++) { $row = new ItemGroup(); $post = array('active' => 1, 'visible' => 0, 'name' => 'Group ' . ($i + 1), 'desc' => 'Group ' . ($i + 1), 'color' => $colors[$i % 29]); $row->savePOSTsettings($post); $row->storeload(); ItemGroupHandler::setChildren(1, array($row->id), $type = 'group'); if ($i == 0) { $this->range['groups']['start'] = $row->id; } elseif ($i == $amount) { $this->range['groups']['end'] = $row->id; } $grouplist[] = $row->id; } return $grouplist; }