public function service() { $categoryManager = new CategoryManager($this->config, $this->args); $categoryId = $this->secure($_REQUEST["category_id"]); $display_name = $this->secure($_REQUEST["display_name"]); $last_clickable = $this->secure($_REQUEST["last_clickable"]); $adminManager = new AdminManager($this->config, $this->args); $adminId = $this->sessionManager->getUser()->getId(); $adminDto = $adminManager->selectByPK($adminId); if ($adminDto) { $categoryDto = $categoryManager->getCategoryById($categoryId); if (!$categoryDto) { $jsonArr = array('status' => "err", "errText" => "System Error: Category doesn't exist!"); echo json_encode($jsonArr); return false; } $categoryManager->updateCategoryAttributes($categoryId, $display_name, $last_clickable); $jsonArr = array('status' => "ok", "message" => "ok"); echo json_encode($jsonArr); return true; } else { $jsonArr = array('status' => "err", "errText" => "System Error: You are not Admin!"); echo json_encode($jsonArr); return false; } }
public function getCategory() { if (!$this->category) { $categoryManager = new CategoryManager($this->db); $this->category = $categoryManager->findById($this->id_category); } return $this->category; }
function GetAllCategories($b_show_hidden = 0) { require_once 'category/category-manager.class.php'; $category_manager = new CategoryManager($this->GetSettings(), $this->GetDataConnection()); $category_manager->ReadAll(); $categories = $category_manager->GetItems(); unset($category_manager); return new CategoryCollection($categories); }
function OnLoadPageData() { # get item to be deleted if (!is_object($this->data_object)) { $id = $this->manager->GetItemId($this->data_object); $this->manager->ReadById(array($id)); $this->data_object = $this->manager->GetFirst(); } # tidy up unset($this->manager); }
function OnLoadPageData() { # get id of category $i_id = $this->o_category_manager->GetItemId(); # no need to read data if creating a new category if ($i_id and !isset($_POST['item'])) { # get category $this->o_category_manager->ReadById(array($i_id)); $this->o_category = $this->o_category_manager->GetFirst(); } # tidy up unset($this->o_category_manager); }
public function service() { $categoryManager = CategoryManager::getInstance($this->config, $this->args); $categoryHierarchyManager = CategoryHierarchyManager::getInstance($this->config, $this->args); $categoryId = $this->secure($_REQUEST["category_id"]); $adminManager = AdminManager::getInstance($this->config, $this->args); $adminId = $this->sessionManager->getUser()->getId(); $adminDto = $adminManager->selectByPK($adminId); if ($adminDto) { if ($categoryHierarchyManager->hasCategoryChildren($categoryId)) { $jsonArr = array('status' => "err", "errText" => "You can only remove 'Leaf' categories!"); echo json_encode($jsonArr); return false; } $categoryManager->deleteByPK($categoryId); $categoryHierarchyManager->removeCategoryHierarchyByChildCategoryID($categoryId); //todo remove category name from items table `categories_names` field. $jsonArr = array('status' => "ok", "message" => "ok"); echo json_encode($jsonArr); return true; } else { $jsonArr = array('status' => "err", "errText" => "System Error: You are not Admin!"); echo json_encode($jsonArr); return false; } }
function __construct($rootId = 0) { $this->rootNodeId = $rootId; $this->categoryManager = CategoryManager::getInstance(null, null); $this->categoryHierarchyManager = CategoryHierarchyManager::getInstance(null, null); $this->rootNode = $this->initNodes($this->rootNodeId); }
public function load() { $company_id = $_REQUEST['company_id']; $used_columns_indexes_array = array(2, 1, 9, 3, 4, 5, 6, 7); //explode(',', $_REQUEST['used_columns_indexes']); $importItemsTempManager = ImportItemsTempManager::getInstance($this->config, $this->args); $categoryHierarchyManager = CategoryHierarchyManager::getInstance($this->config, $this->args); $categoryManager = CategoryManager::getInstance($this->config, $this->args); $customerLogin = $this->getCustomerLogin(); $priceRowsDtos = $importItemsTempManager->getUserCurrentPriceChangedRows($customerLogin); $columnNames = ImportPriceManager::getColumnNamesMap($used_columns_indexes_array); $rootDto = $categoryManager->getRoot(); $firstLevelCategoriesHierarchyDtos = $categoryHierarchyManager->getCategoryChildren($rootDto->getId()); $firstLevelCategoriesNamesDtos = $categoryHierarchyManager->getCategoriesNamesByParentCategoryId($rootDto->getId()); $firstLevelCategoriesIds = array(); foreach ($firstLevelCategoriesHierarchyDtos as $key => $category) { $firstLevelCategoriesIds[] = $category->getChildId(); } $firstLevelCategoriesNames = array(); foreach ($firstLevelCategoriesNamesDtos as $key => $category) { $firstLevelCategoriesNames[] = $category->getDisplayName(); } $itemManager = ItemManager::getInstance($this->config, $this->args); $companyAllItems = $itemManager->getCompanyItems($company_id, true); $convertDtosArrayToArrayMapById = $this->convertDtosArrayToArrayMapById($companyAllItems); $this->addParam('stockItemsDtosMappedByIds', $convertDtosArrayToArrayMapById); $this->addParam('columnNames', $columnNames); $this->addParam('priceRowsDtos', $priceRowsDtos); $this->addParam('firstLevelCategoriesNames', $firstLevelCategoriesNames); $this->addParam('firstLevelCategoriesIds', $firstLevelCategoriesIds); list($changedRowIds, $changedFields) = $this->findChanges($priceRowsDtos, $convertDtosArrayToArrayMapById, $columnNames); $this->addParam('changedRowsIds', $changedRowIds); $this->addParam('changedFields', $changedFields); }
public function load() { //Load First Level Categories from DB $categoryManager = CategoryManager::getInstance($this->config, $this->args); $categoryHierarchyManager = CategoryHierarchyManager::getInstance($this->config, $this->args); $rootDto = $categoryManager->getRoot(); $firstLevelCategoriesHierarchyDtos = $categoryHierarchyManager->getCategoryChildren($rootDto->getId()); $firstLevelCategoriesNamesDtos = $categoryHierarchyManager->getCategoriesNamesByParentCategoryId($rootDto->getId()); $firstLevelCategoriesIds = array(); foreach ($firstLevelCategoriesHierarchyDtos as $key => $category) { $firstLevelCategoriesIds[] = $category->getChildId(); } $firstLevelCategoriesNames = array(); foreach ($firstLevelCategoriesNamesDtos as $key => $category) { $firstLevelCategoriesNames[] = $category->getDisplayName(); } $this->addParam('firstLevelCategoriesNames', $firstLevelCategoriesNames); $this->addParam('firstLevelCategoriesIds', $firstLevelCategoriesIds); $item_warranty_options = explode(',', $this->getCmsVar('item_warranty_options')); $this->addParam('item_warranty_options', $item_warranty_options); $itemManager = ItemManager::getInstance($this->config, $this->args); if (isset($_REQUEST['item_id'])) { $itemId = $this->secure($_REQUEST['item_id']); $itemDto = $itemManager->selectByPK($itemId); $this->addParam('item_pictures_count', $itemDto->getPicturesCount()); $this->addParam('item_id', $itemDto->getId()); $this->addParam('item_title', $itemDto->getDisplayName()); $this->addParam('item_available', $itemManager->isItemAvailable($itemDto)); $this->addParam('short_description', $itemDto->getShortDescription()); $this->addParam('full_description', $itemDto->getFullDescription()); $this->addParam('dealer_price', $itemDto->getDealerPrice()); $this->addParam('vat_price', $itemDto->getVatPrice()); $this->addParam('dealer_price_amd', $itemDto->getDealerPriceAmd()); $this->addParam('vat_price_amd', $itemDto->getVatPriceAmd()); $this->addParam('selected_warranty_option', $itemDto->getWarranty()); $this->addParam('item_model', $itemDto->getModel()); $this->addParam('item_brand', $itemDto->getBrand()); $this->addParam('order_index_in_price', $itemDto->getOrderIndexInPrice()); $this->addParam('item_available_till_date', $itemDto->getItemAvailableTillDate()); $itemCategoriesIds = $itemDto->getCategoriesIds(); $itemCategoriesIds = trim($itemCategoriesIds, ','); assert(!empty($itemCategoriesIds)); $itemCategoriesIds = explode(',', $itemCategoriesIds); $selectedRootCategoryId = $itemCategoriesIds[0]; $subCategoriesIdsArray = array_slice($itemCategoriesIds, 1); $this->addParam('selectedRootCategoryId', $selectedRootCategoryId); $this->addParam('sub_categories_ids', join(',', $subCategoriesIdsArray)); } else { $selectedRootCategoryId = $firstLevelCategoriesHierarchyDtos[0]->getChildId(); $this->addParam('selected_warranty_option', $item_warranty_options[12]); $this->addParam('selectedRootCategoryId', $selectedRootCategoryId); $this->addParam('sub_categories_ids', ''); } $item_availability_options_names = array("Today", "2 days", "3 days", "1 week", "2 weeks", "1 month"); $item_availability_options_values = array(0, 1, 2, 6, 13, 29); $this->addParam('item_availability_options_names', $item_availability_options_names); $this->addParam('item_availability_options_values', $item_availability_options_values); $this->addParam('item_availability_selected', $item_availability_options_values[3]); $this->addParam('company_id', intval($this->secure($_REQUEST["company_id"]))); }
/** * Returns an singleton instance of this class * * @param object $config * @param object $args * @return */ public static function getInstance($config, $args) { if (self::$instance == null) { self::$instance = new CategoryManager($config, $args); } return self::$instance; }
public function load() { //new items import level $company_id = $_REQUEST['company_id']; $used_columns_indexes_array = array(2, 1, 9, 3, 4, 5, 6, 7); //explode(',', $_REQUEST['used_columns_indexes']); $importItemsTempManager = ImportItemsTempManager::getInstance($this->config, $this->args); $categoryHierarchyManager = CategoryHierarchyManager::getInstance($this->config, $this->args); $categoryManager = CategoryManager::getInstance($this->config, $this->args); $customerLogin = $this->getCustomerLogin(); $priceRowsDtos = $importItemsTempManager->getUserCurrentPriceNewRows($customerLogin); foreach ($priceRowsDtos as $dto) { $itemModel = $dto->getModel(); if (empty($itemModel)) { $model = $importItemsTempManager->findModelFromItemTitle($dto->getDisplayName()); if (!empty($model)) { $dto->setSupposedModel($model); } } else { $dto->setSupposedModel($itemModel); } } $columnNames = ImportPriceManager::getColumnNamesMap($used_columns_indexes_array); $rootDto = $categoryManager->getRoot(); $firstLevelCategoriesHierarchyDtos = $categoryHierarchyManager->getCategoryChildren($rootDto->getId()); $firstLevelCategoriesNamesDtos = $categoryHierarchyManager->getCategoriesNamesByParentCategoryId($rootDto->getId()); $firstLevelCategoriesIds = array(); foreach ($firstLevelCategoriesHierarchyDtos as $key => $category) { $firstLevelCategoriesIds[] = $category->getChildId(); } $firstLevelCategoriesNames = array(); foreach ($firstLevelCategoriesNamesDtos as $key => $category) { $firstLevelCategoriesNames[] = $category->getDisplayName(); } $this->addParam('columnNames', $columnNames); $this->addParam('priceRowsDtos', $priceRowsDtos); $this->addParam('firstLevelCategoriesNames', $firstLevelCategoriesNames); $this->addParam('firstLevelCategoriesIds', $firstLevelCategoriesIds); if (isset($_REQUEST['new_items_row_ids'])) { $this->addParam('new_items_row_ids', explode(',', $_REQUEST['new_items_row_ids'])); } //$json_parsed_price = $_REQUEST['json_parsed_price']; //$parsed_price_array = json_decode($json_parsed_price); /* $companyItems = $itemManager->getCompanyItems($company_id, true); $stockItemModels = array(); $stockItemNames = array(); $stockItemDealerPrices = array(); $stockItemVatPrices = array(); $stockItemIsHidden = array(); foreach ($companyItems as $itemDto) { $stockItemModels[] = } */ }
public function load() { $this->categoryManager = CategoryManager::getInstance($this->config, $this->args); $this->categoryHierarchyManager = CategoryHierarchyManager::getInstance($this->config, $this->args); $rootCategoryId = $this->secure($_REQUEST["item_root_category"]); $rootCategoryDto = $this->categoryManager->getCategoryById($rootCategoryId); $this->treeViewModel = new SubCategorySelectionTreeViewModel($rootCategoryDto->getId(), $rootCategoryDto->getDisplayName(), $rootCategoryDto, true); $this->fillTreeViewModel($rootCategoryDto); $treeView = new SubCategorySelectionTreeView($this->treeViewModel, false, "sub_category_tree"); $treeView->setRowsIndent(25); $this->addParam('selectSubCatTreeView', $treeView); }
public function load() { $this->categoryManager = CategoryManager::getInstance($this->config, $this->args); $this->categoryHierarchyManager = CategoryHierarchyManager::getInstance($this->config, $this->args); $rootDto = $this->categoryManager->getRoot(); $this->treeViewModel = new ItemsCategoryTreeViewModel($rootDto->getId(), $rootDto->getDisplayName(), $rootDto, true); $this->fillTreeViewModel($rootDto); $treeView = new ItemsCategoryTreeView($this->treeViewModel, true, "my_tree"); $this->addParam('treeView', $treeView); $this->addParam("ItemCategoriesLeftBarWidth", $this->getCmsVar("item_categories_left_bar_width")); $this->addParam("ItemCategoriesRightBarWidth", $this->getParam("wholePageWidth") - $this->getCmsVar("item_categories_left_bar_width")); }
public function service() { $categoryManager = new CategoryManager($this->config, $this->args); $categoryHierarchyManager = new CategoryHierarchyManager($this->config, $this->args); $categoryTitle = $this->secure($_REQUEST["category_title"]); $parentCategoryId = $this->secure($_REQUEST["parent_category_id"]); $adminManager = new AdminManager($this->config, $this->args); $adminId = $this->sessionManager->getUser()->getId(); $adminDto = $adminManager->selectByPK($adminId); if ($adminDto) { $sortIndex = count($categoryHierarchyManager->getCategoryChildrenIdsArray($parentCategoryId)) + 1; $categoryId = $categoryManager->addCategory($categoryTitle, '0', '0', '1'); $categoryHierarchyManager->addSubCategoryToCategory($parentCategoryId, $categoryId, $sortIndex); $jsonArr = array('status' => "ok", "message" => "ok"); echo json_encode($jsonArr); return true; } else { $jsonArr = array('status' => "err", "errText" => "System Error: You are not Admin!"); echo json_encode($jsonArr); return false; } }
private function initRootCategories() { $categoryManager = CategoryManager::getInstance($this->config, $this->args); $categoryHierarchyManager = CategoryHierarchyManager::getInstance($this->config, $this->args); $rootDto = $categoryManager->getRoot(); $firstLevelCategoriesHierarchyDtos = $categoryHierarchyManager->getCategoryChildren($rootDto->getId()); $firstLevelCategoriesNamesDtos = $categoryHierarchyManager->getCategoriesNamesByParentCategoryId($rootDto->getId()); $firstLevelCategoriesIds = array(); foreach ($firstLevelCategoriesHierarchyDtos as $key => $category) { $firstLevelCategoriesIds[] = $category->getChildId(); } $firstLevelCategoriesNames = array(); foreach ($firstLevelCategoriesNamesDtos as $key => $category) { $firstLevelCategoriesNames[] = $category->getDisplayName(); } $this->addParam('firstLevelCategoriesNames', $firstLevelCategoriesNames); $this->addParam('firstLevelCategoriesIds', $firstLevelCategoriesIds); }
<?php $itemManager = new ItemManager($db); $categoryManager = new CategoryManager($db); $items = $itemManager->read(); $categories = $categoryManager->read(); require 'views/dashboard_items.phtml';
function importMatching($importedTransaction, $accountId) { global $us; global $badgerDb; static $dateDelta = null; static $amountDelta = null; static $textSimilarity = null; static $categories = null; if (is_null($dateDelta)) { try { $dateDelta = $us->getProperty('matchingDateDelta'); } catch (BadgerException $ex) { $dateDelta = 5; } try { $amountDelta = $us->getProperty('matchingAmountDelta'); } catch (BadgerException $ex) { $amountDelta = 0.1; } try { $textSimilarity = $us->getProperty('matchingTextSimilarity'); } catch (BadgerException $ex) { $textSimilarity = 0.25; } $categoryManager = new CategoryManager($badgerDb); while ($currentCategory = $categoryManager->getNextCategory()) { $categories[$currentCategory->getId()] = preg_split('/[\\n]+/', $currentCategory->getKeywords(), -1, PREG_SPLIT_NO_EMPTY); } } if (!$importedTransaction['valutaDate']) { return $importedTransaction; } $minDate = new Date($importedTransaction['valutaDate']); $minDate->subtractSeconds($dateDelta * 24 * 60 * 60); $maxDate = new Date($importedTransaction['valutaDate']); $maxDate->addSeconds($dateDelta * 24 * 60 * 60); if (!$importedTransaction['amount']) { return $importedTransaction; } $minAmount = new Amount($importedTransaction['amount']); $minAmount->mul(1 - $amountDelta); $maxAmount = new Amount($importedTransaction['amount']); $maxAmount->mul(1 + $amountDelta); $accountManager = new AccountManager($badgerDb); $account = $accountManager->getAccountById($accountId); $account->setFilter(array(array('key' => 'valutaDate', 'op' => 'ge', 'val' => $minDate), array('key' => 'valutaDate', 'op' => 'le', 'val' => $maxDate), array('key' => 'amount', 'op' => 'ge', 'val' => $minAmount), array('key' => 'amount', 'op' => 'le', 'val' => $maxAmount))); $similarTransactions = array(); while ($currentTransaction = $account->getNextTransaction()) { $titleSimilarity = getSimilarity($importedTransaction['title'], $currentTransaction->getTitle(), $textSimilarity); $descriptionSimilarity = getSimilarity($importedTransaction['description'], $currentTransaction->getDescription(), $textSimilarity); $transactionPartnerSimilarity = getSimilarity($importedTransaction['transactionPartner'], $currentTransaction->getTransactionPartner(), $textSimilarity); $currDate = $currentTransaction->getValutaDate(); $impDate = $importedTransaction['valutaDate']; $dateSimilarity = 1 - abs(Date_Calc::dateDiff($currDate->getDay(), $currDate->getMonth(), $currDate->getYear(), $impDate->getDay(), $impDate->getMonth(), $impDate->getYear())) / $dateDelta; $cmpAmount = new Amount($currentTransaction->getAmount()); $impAmount = new Amount($importedTransaction['amount']); $cmpAmount->sub($impAmount); $cmpAmount->abs(); $impAmount->mul($amountDelta); $impAmount->abs(); $amountSimilarity = 1 - $cmpAmount->div($impAmount)->get(); $currentTextSimilarity = ($titleSimilarity + $descriptionSimilarity + $transactionPartnerSimilarity) / 3; // if ($currentTextSimilarity >= $textSimilarity) { $overallSimilarity = ($titleSimilarity + $descriptionSimilarity + $transactionPartnerSimilarity + $dateSimilarity + $amountSimilarity) / 5; //$similarTransactions["$overallSimilarity t:$titleSimilarity d:$descriptionSimilarity tp:$transactionPartnerSimilarity vd:$dateSimilarity a:$amountSimilarity"] = $currentTransaction; $similarTransactions[$overallSimilarity] = $currentTransaction; // } } krsort($similarTransactions); if (count($similarTransactions)) { $importedTransaction['similarTransactions'] = $similarTransactions; return $importedTransaction; } if ($importedTransaction['categoryId']) { return $importedTransaction; } $transactionStrings = array($importedTransaction['title'], $importedTransaction['description'], $importedTransaction['transactionPartner']); foreach ($transactionStrings as $currentTransactionString) { foreach ($categories as $currentCategoryId => $keywords) { foreach ($keywords as $keyword) { if (stripos($currentTransactionString, trim($keyword)) !== false) { $importedTransaction['categoryId'] = $currentCategoryId; break 3; } //if keyword found } //foreach keywords } //foreach categories } //foreach transactionStrings return $importedTransaction; }
<?php if (isset($_GET['page'])) { $action = $_GET['page']; if ($action == 'addCategory') { if (isset($_POST['title'], $_POST['content'])) { $manager = new CategoryManager($db); $idAuthor = $_SESSION['id']; try { $retour = $manager->create($_POST['title'], $_POST['content'], $idAuthor); header('Location: index.php?page=XcategorysX'); exit; } catch (Exception $e) { $errors = $e->getMessage(); } } } else { if ($action == 'updateCategory') { if (isset($_POST['title'], $_POST['content'])) { $manager = new ArticleManager($db); $category = $manager->findById($_GET['id']); if ($category->getIdAuthor() == $currentUser->getId()) { $id = intval($_GET['id']); $category->setTitle($_POST['title']); $category->setContent($_POST['content']); $retour->{$manager}->update($category); } else { $user = $retour; header('Location : index.php?page=home'); exit; }
<?php $categoryManager = new CategoryManager($db); $category = $categoryManager->findById($_GET['id']); $userManager = new UserManager($db); $userCategory = $userManager->findById($category->idAuthor); require 'views/forum/category.phtml'; ?>
$category = new Category($id); if ($category->Edit($name, $priority, $desc)) { $info .= lng('CAT_UPDATED'); } else { $info .= lng('CAT_EXIST'); } } elseif ($id and Filter::input('delete', 'post', 'bool')) { $category = new Category($id); if ($category->Delete()) { $info .= lng('CAT_DELETED'); } else { $info .= lng('CAT_NOT_EXIST'); } $id = false; } $cat_list = CategoryManager::GetList($id); include View::Get('category_header.html', $st_subdir . 'category/'); if ($id) { $cat_item = new Category($id); if ($cat_item->Exist()) { $cat_name = $cat_item->GetName(); $cat_desc = $cat_item->GetDescription(); $cat_priority = $cat_item->GetPriority(); include View::Get('category_edit.html', $st_subdir . 'category/'); if (!$cat_item->IsSystem()) { include View::Get('category_delete.html', $st_subdir . 'category/'); } } unset($cat_item); } else { include View::Get('category_add.html', $st_subdir . 'category/');
<?php $categoryManager = new CategoryManager($db); $categorys = $categoryManager->getList(); $userManager = new UserManager($db); $i = 0; $c = count($categorys); while ($i < $c) { $category = $categorys[$i]; $userCategory = $userManager->findById($category->idAuthor); require 'views/forum/categorys.phtml'; $i++; }
*| _ \ /\ | __ \ / ____| ____| __ \ *| |_) | / \ | | | | | __| |__ | |__) | *| _ < / /\ \ | | | | | |_ | __| | _ / *| |_) / ____ \| |__| | |__| | |____| | \ \ *|____/_/ \_\_____/ \_____|______|_| \_\ * Open Source Financial Management * Visit http://www.badger-finance.org * **/ define("BADGER_ROOT", "../.."); require_once BADGER_ROOT . "/includes/fileHeaderFrontEnd.inc.php"; require_once BADGER_ROOT . '/modules/account/CategoryManager.class.php'; require_once BADGER_ROOT . '/modules/account/AccountManager.class.php'; $redirectPageAfterSave = "CategoryManagerOverview.php"; $pageTitle = getBadgerTranslation2('accountCategory', 'pageTitle'); $cm = new CategoryManager($badgerDb); $am = new AccountManager($badgerDb); $order = array(array('key' => 'title', 'dir' => 'asc')); $cm->setOrder($order); if (isset($_GET['action'])) { switch ($_GET['action']) { case 'delete': //background delete //called by dataGrid if (isset($_GET['ID'])) { $IDs = explode(",", $_GET['ID']); //for all categories which should be deleted foreach ($IDs as $ID) { //for all accounts: $am = new AccountManager($badgerDb); while ($account = $am->getNextAccount()) {
<?php if (isset($_POST['action'])) { if ($_POST['action'] == "add") { if (isset($_POST['name'], $_POST['description'])) { $category_name = $_POST['name']; $category_description = $_POST['description']; $categoryManager = new CategoryManager($database); try { $categoryManager->create($currentUser, $category_name, $category_description); } catch (Exception $e) { $_SESSION['errors'] = $e->getMessage(); } if (!isset($_SESSION['errors']) || $_SESSION['errors'] == "") { $_SESSION['success'] = "Category a bien été crée"; } header('Location: ?page=admin'); exit; } } }
/* * ____ _____ _____ ______ _____ *| _ \ /\ | __ \ / ____| ____| __ \ *| |_) | / \ | | | | | __| |__ | |__) | *| _ < / /\ \ | | | | | |_ | __| | _ / *| |_) / ____ \| |__| | |__| | |____| | \ \ *|____/_/ \_\_____/ \_____|______|_| \_\ * Open Source Financial Management * Visit http://www.badger-finance.org * **/ define('BADGER_ROOT', '../..'); require_once BADGER_ROOT . '/includes/fileHeaderFrontEnd.inc.php'; require_once BADGER_ROOT . '/modules/account/CategoryManager.class.php'; header('Content-Type: text/plain'); define('endl', "\n"); $cm = new CategoryManager($badgerDb); while ($cat = $cm->getNextCategory()) { echo 'Category Title: ' . $cat->getTitle() . endl; } $cat1 = $cm->getCategoryById(1); echo 'Category Id: ' . $cat1->getId() . endl; $cat2 = $cm->addCategory('Neue Kategorie ' . rand(0, 100), 'Bähschraipunk'); echo 'New Category Title: ' . $cat2->getTitle() . endl; $cat3 = $cm->addCategory('Temporäre Kategorie'); $tmpId = $cat3->getId(); echo 'Temporary Category Id: ' . $tmpId . endl; $cm->deleteCategory($tmpId); $cat4 = $cm->getCategoryById($tmpId); echo 'Temporary Category Title (never shown): ' . $cat4->getTitle() . endl;
/** * Define result returned when count products in a category * * @param integer $resultCount */ protected function defineCategoryCountResult($resultCount) { $productManager->expects($this->any())->method('getProductsCountInCategory')->will($this->returnValue($resultCount)); $this->categoryManager->expects($this->any())->method('getEntityRepository')->will($this->returnValue($repository)); }
function update($post, $editor) { parent::update($post, $editor, self::OBJECT_CLASS); if (!AuthorizationManager::canUserDo(DB::EDIT_POST, $object)) { throw new Exception("L'utente non è autorizzato ad effettuare questa operazione."); } $p_old = $this->quickLoad($post->getID()); $data = array(); if (is_null($p_old)) { throw new Exception("L'oggetto da modificare non esiste."); } //cerco le differenze e le salvo. if ($p_old->getTitle() != $post->getTitle()) { $data[DB::POST_TITLE] = $post->getTitle(); } if ($p_old->getSubtitle() != $post->getSubtitle()) { $data[DB::POST_SUBTITLE] = $post->getSubtitle(); } if ($p_old->getHeadline() != $post->getHeadline()) { $data[DB::POST_HEADLINE] = $post->getHeadline(); } if ($p_old->getContent() != $post->getContent()) { if ($post->type == Post::NEWS || $post->type == Post::VIDEOREP) { $data[DB::POST_CONTENT] = $post->getContent(); } else { $data[DB::POST_CONTENT] = serialize($post->getContent()); } } if ($p_old->getPlace() != $post->getPlace()) { $data[DB::POST_PLACE] = $post->getPlace(); } if ($p_old->getPlaceName() != $post->getPlaceName()) { $data[DB::POST_PLACE_NAME] = $post->getPlaceName(); } if ($p_old->getTags() != $post->getTags()) { $data[DB::POST_TAGS] = $post->getTags(); } if ($p_old->getCategories() != $post->getCategories()) { // check sulle categorie, eliminazione di quelle che non esistono nel sistema, se vuoto inserimento di quella di default require_once 'manager/CategoryManager.php'; $new_cat = CategoryManager::filterWrongCategories(explode(",", $post->getCategories())); if (count($new_cat) == 0) { $new_cat[] = self::DEFAULT_CATEGORY; } $post->setCategories(Filter::arrayToText($new_cat)); $data[DB::POST_CATEGORIES] = $post->getCategories(); } if ($p_old->isVisible() !== $post->isVisible()) { $data[DB::POST_VISIBLE] = $post->isVisible() ? 1 : 0; } if ($p_old->getPermalink() != $post->getPermalink()) { if ($this->permalinkExists($post->getPermalink())) { throw new Exception("Il permalink inserito esiste già. Riprova."); } $data[DB::POST_PERMALINK] = $post->getPermalink(); } if (count($data) == 0) { throw new Exception("Nessuna modifica da effettuare."); } $modDate = $_SERVER["REQUEST_TIME"]; $data[DB::POST_MODIFICATION_DATE] = date("Y/m/d G:i:s", $modDate); // se mi dicono di fare l'update, cambio modificationDate //salvo la versione precedente e ne tengo traccia. $history_id = $this->saveHistory($p_old, "UPDATED"); $post->setPreviousVersion($history_id); $data[DB::POST_PREVIOUS_VERSION] = $post->getPreviousVersion(); $rs = $this->db->execute($s = Query::generateUpdateStm($this->table, $data, array(new WhereConstraint($this->table->getColumn(DB::POST_ID), Operator::EQUAL, $post->getID()))), $this->table->getName(), $post); //aggiorno lo stato del post (se chi l'ha modificato è un redattore). if (AuthenticationManager::isEditor($editor)) { $post->setEditable(false); $post->setRemovable(false); $this->updateState($post); } if ($this->db->affected_rows() != 1) { throw new Exception("Si è verificato un errore aggiornando il dato. Riprovare."); } //salvo i tag che non esistono if (isset($data[DB::POST_TAGS]) && !is_null($data[DB::POST_TAGS]) && trim($data[DB::POST_TAGS]) != "") { require_once 'manager/TagManager.php'; TagManager::createTags(explode(",", $data[DB::POST_TAGS])); //TODO } return $post->setModificationDate($modDate); }
/** * Request a category be renamed * * @param $input */ public function requestRename($input) { $path = array_get($input, 'path'); $newName = array_get($input, 'newname'); $this->CategoryManager->renameCategory($path, $newName); }
<?php if (isset($_POST['action'])) { if ($_POST['action'] == "add") { if (isset($_POST['name'], $_POST['category'], $_POST['description'], $_POST['image'])) { $sub_name = $_POST['name']; $sub_id_category = $_POST['category']; $sub_description = $_POST['description']; $sub_image = $_POST['image']; $subcategoryManager = new SubCategoryManager($database); $categoryManager = new CategoryManager($database); $category = $categoryManager->findById($sub_id_category); try { $subcategoryManager->create($sub_name, $sub_description, $sub_image, $category); } catch (Exception $e) { $errors[] = $e->getMessage(); } if (count($errors) == 0) { $_SESSION['success'] = "La sous-categorie a bien été crée"; } else { $_SESSION['errors'] = $errors; } header('Location: ?page=admin'); exit; } } }
function editCategory() { $db =& JFactory::getDBO(); $user =& JFactory::getUser(); $cid = JRequest::getVar('cid', array(0), '', 'array'); $option = JRequest::getCmd('option'); $uid = (int) @$cid[0]; $row =& JTable::getInstance('flippingcategory', 'Table'); $row->load($uid); $javascript = ' '; $lists['preview_image'] = $this->getFilesSelectBox('preview_image', $row->preview_image, 1, 'jpg|jpeg|gif|png|JPG|JPEG|GIF|PNG', ''); for ($i = 1; $i < 11; $i++) { $columns[] = JHTML::_('select.option', $i, $i); $lists['columns'] = JHTML::_('select.genericlist', $columns, 'columns', 'class="inputbox" size="1"', 'value', 'text', $row->columns); } require_once JPATH_COMPONENT . DS . 'views' . DS . 'category_manager.php'; CategoryManager::editCategory($row, $lists); }
public function load() { $this->addParam("searchLeftBarWidth", $this->getCmsVar("search_left_bar_width")); $itemManager = ItemManager::getInstance($this->config, $this->args); $this->setDescriptionTagValue('Serach any item you want. PC, Laptop, Tablet, Computer, Printer, Monitor...'); $this->setTitleTagValue('Pcstore Search'); if (isset($_COOKIE['copied_item_id'])) { $this->addParam('copied_item_id', $_COOKIE['copied_item_id']); } if (isset($this->args[0])) { $this->large_view_load_enable = true; $selectedItemId = $this->args[0]; $this->addParam('selected_item_id', $selectedItemId); } $this->current_page_number = 1; if (isset($_REQUEST["spg"])) { $this->current_page_number = $_REQUEST["spg"]; } $userLevel = $this->getUserLevel(); $this->categoryManager = CategoryManager::getInstance($this->config, $this->args); $this->categoryHierarchyManager = CategoryHierarchyManager::getInstance($this->config, $this->args); $selectedCompanyId = $this->initCompaniesSelectionList(); $selectedCategoryId = 0; if (!empty($_REQUEST["cid"])) { $selectedCategoryId = $this->secure($_REQUEST["cid"]); } $selected_category_property_ids = isset($_REQUEST["scpids"]) ? $this->secure($_REQUEST["scpids"]) : ''; $groupedProperties = null; if (!empty($selected_category_property_ids)) { $this->addParam('selected_category_property_ids', $selected_category_property_ids); $selected_category_property_ids = explode(',', $selected_category_property_ids); $groupedProperties = $this->groupCategoryProperties($selected_category_property_ids); } else { $selected_category_property_ids = array(); $groupedProperties = array(); } $item_search_limit_rows = intval($this->getCmsVar("item_search_limit_rows")); $userId = $this->getUserId(); $price_range_min = isset($_REQUEST["prmin"]) ? $this->secure($_REQUEST["prmin"]) : ''; $price_range_max = isset($_REQUEST["prmax"]) ? $this->secure($_REQUEST["prmax"]) : ''; $this->addParam('search_item_price_range_min_value', $price_range_min); $this->addParam('search_item_price_range_max_value', $price_range_max); if (!empty($price_range_min) && strlen($price_range_min) > 0) { $price_range_min = floatval($this->secure($_REQUEST["prmin"])) / floatval($this->getCmsVar('us_dollar_exchange')); } if (!empty($price_range_max) && strlen($price_range_max) > 0) { $price_range_max = floatval($this->secure($_REQUEST["prmax"])) / floatval($this->getCmsVar('us_dollar_exchange')); } $orderByFieldName = $this->initSortBySelectionList(); if ($orderByFieldName === 'relevance') { $orderByFieldName = null; } $search_text = isset($_REQUEST["st"]) ? $this->secure($_REQUEST["st"]) : ''; $this->addParam("search_text", $search_text); if (!empty($search_text)) { $cmsSearchRequestsManager = CmsSearchRequestsManager::getInstance($this->config, $this->args); $cmsSearchRequestsManager->addRow($search_text, date('Y-m-d H:i:s'), $_REQUEST['win_uid']); } $show_only_vat_items = 0; if (isset($_REQUEST['shov'])) { $show_only_vat_items = $this->secure($_REQUEST['shov']); $this->addParam('show_only_vat_items', 1); } $show_only_non_picture_items = null; if (isset($_REQUEST["show_only_non_picture_items"])) { $show_only_non_picture_items = intval($_REQUEST["show_only_non_picture_items"]); $this->addParam('show_only_non_picture_items', $show_only_non_picture_items); } $show_only_no_short_spec_items = null; if (isset($_REQUEST["show_only_no_short_spec_items"])) { $show_only_no_short_spec_items = intval($_REQUEST["show_only_no_short_spec_items"]); $this->addParam('show_only_no_short_spec_items', $show_only_no_short_spec_items); } $show_only_no_full_spec_items = null; if (isset($_REQUEST["show_only_no_full_spec_items"])) { $show_only_no_full_spec_items = intval($_REQUEST["show_only_no_full_spec_items"]); $this->addParam('show_only_no_full_spec_items', $show_only_no_full_spec_items); } searchStared: $offset = $item_search_limit_rows * ($this->current_page_number - 1); $foundItems = $itemManager->searchItemsByTitle($userId, $userLevel, $search_text, $selectedCompanyId, $price_range_min, $price_range_max, $selectedCategoryId, $groupedProperties, $show_only_vat_items, $show_only_non_picture_items, $show_only_no_short_spec_items, $show_only_no_full_spec_items, $offset, $item_search_limit_rows, $orderByFieldName); $itemsDtosOnlyCategories = $itemManager->searchItemsByTitleRowsCount($userId, $search_text, $selectedCompanyId, $price_range_min, $price_range_max, $selectedCategoryId, null, $show_only_vat_items, $show_only_non_picture_items, $show_only_no_short_spec_items, $show_only_no_full_spec_items); $this->totalItemsRowsCount = 0; $this->categories_count_array = array(); $selectedCategoryGroupedSubProperties = array(); $selectedCategorySubTreeIds = array(); $propertyViewIsVisible = false; $selectedCategoryDto = $this->categoryManager->getCategoryById($selectedCategoryId); if ($selectedCategoryDto->getLastClickable() == 1) { $selectedCategoryGroupedSubProperties = $this->categoryHierarchyManager->getCategoryGroupedSubProperties($selectedCategoryId); $selectedCategorySubTreeIds = $this->categoryHierarchyManager->getCategorySubTreeIds($selectedCategoryId); $propertyViewIsVisible = true; } foreach ($itemsDtosOnlyCategories as $itemDto) { $categoriesIds = trim($itemDto->getCategoriesIds(), ','); $categoriesIdsArray = explode(',', $categoriesIds); $ItemIsVisible = true; foreach ($groupedProperties as $propertiesGroupStaticCategoryId => $propIdsArray) { if (!(empty($propIdsArray) || count(array_intersect($categoriesIdsArray, $propIdsArray)) > 0)) { $ItemIsVisible = false; break; } } if ($ItemIsVisible) { $this->totalItemsRowsCount++; } //here calculating categories count which is valid for only category menu items not properties if (!$propertyViewIsVisible) { foreach ($categoriesIdsArray as $catId) { if (!in_array($catId, $selectedCategorySubTreeIds)) { if (!array_key_exists($catId, $this->categories_count_array)) { $this->categories_count_array[$catId] = 1; } else { $this->categories_count_array[$catId] += 1; } } } } else { //here calculating future selecting properties count foreach ($selectedCategoryGroupedSubProperties as $propertyGroupCategoryId => $propertiesIds) { $isItemVisibleForCurrentlySelectedOtherPropertyGroup = true; foreach ($groupedProperties as $propertiesGroupStaticCategoryId => $propIdsArray) { if ($propertiesGroupStaticCategoryId == $propertyGroupCategoryId) { continue; } if (!(empty($propIdsArray) || count(array_intersect($categoriesIdsArray, $propIdsArray)) > 0)) { $isItemVisibleForCurrentlySelectedOtherPropertyGroup = false; break; } } foreach ($propertiesIds as $proertyId) { if (in_array($proertyId, $selected_category_property_ids)) { //this is for optimization continue; } if ($isItemVisibleForCurrentlySelectedOtherPropertyGroup && in_array($proertyId, $categoriesIdsArray)) { if (!array_key_exists($proertyId, $this->categories_count_array)) { $this->categories_count_array[$proertyId] = 1; } else { $this->categories_count_array[$proertyId] += 1; } } } } } } //if page number exceed last page number then go to last page if (count($foundItems) === 0 && $this->totalItemsRowsCount > 0) { $lastPageNumber = ceil($this->totalItemsRowsCount / $item_search_limit_rows); $this->current_page_number = $lastPageNumber; goto searchStared; } $this->addParam("foundItems", $foundItems); $this->addParam("itemManager", $itemManager); $this->addParam("totalItemsRowsCount", $this->totalItemsRowsCount); ///credit items calculation $creditManager = CreditManager::getInstance($this->config, $this->args); $creditSuppliersManager = CreditSuppliersManager::getInstance($this->config, $this->args); $allCreditSuppliersDtos = $creditSuppliersManager->getAllCreditSuppliers(); $allCreditSuppliersDtos = $creditSuppliersManager->getCreditSuppliersInMapArrayById($allCreditSuppliersDtos); $creditPossibleMonths = $creditManager->getAllSuppliersCombinePossibleMonths($allCreditSuppliersDtos); $this->addParam("creditPossibleMonthsValues", $creditPossibleMonths); $this->addParam("defaultSelectedCreditMonths", end($creditPossibleMonths)); $defaultCreditSupplierDto = reset($allCreditSuppliersDtos); $this->addParam("defaultSupplierCommission", floatval($defaultCreditSupplierDto->getCommission())); $this->addParam("defaultCreditInterestMonthlyRatio", floatval($defaultCreditSupplierDto->getAnnualInterestPercent() / 100 / 12 + $defaultCreditSupplierDto->getAnnualCommision() / 100 / 12)); //categories if ($selectedCategoryDto->getLastClickable() == '0') { $itemCategoryModel = new ItemCategoryModel(!empty($selectedCategoryId) ? $selectedCategoryId : 0); $itemsCategoryMenuView = new ItemsCategoryMenuView($itemCategoryModel, $this->categories_count_array, $this->config, false); $this->addParam('itemsCategoryMenuView', $itemsCategoryMenuView); } //selected category properties $propertiesViews = array(); if (isset($selectedCategoryId) && $this->categoryManager->getCategoryById($selectedCategoryId)->getLastClickable() == '1') { $propertiesHierarchyDtos = $this->categoryHierarchyManager->getCategoryChildren($selectedCategoryId); foreach ($propertiesHierarchyDtos as $propertyHierarchyDto) { $propertyView = new CategoryPropertyView($this->categoryManager, $this->categoryHierarchyManager, $this->categories_count_array, $propertyHierarchyDto->getChildId(), $selected_category_property_ids); $propertiesViews[] = $propertyView; } } $this->addParam("properties_views", $propertiesViews); $this->addParam('category_id', $selectedCategoryId); $this->addParam('category_dto', $selectedCategoryDto); if ($selectedCategoryId > 0) { $categoryFullPath = $this->categoryManager->getCategoryFullPath($selectedCategoryId); if (count($categoryFullPath) >= 1) { $this->addParam('category_path', $categoryFullPath); $this->addParam('itemSearchManager', ItemSearchManager::getInstance($this->config, $this->args)); } } }