Example #1
0
 /**
  * Create new empty item in DB
  * @param int    $appId
  * @param string $type
  * @param string $nameSuf
  * @return Item
  */
 public function createEmpty($appId, $type, $nameSuf = null)
 {
     // some vars
     $now = $this->app->date->create()->toSQL();
     $userId = $this->app->user->get()->get('id');
     // create empty item
     $item = $this->app->object->create('Item');
     // set default data
     $item->application_id = (int) $appId;
     $item->type = $type;
     $item->state = 0;
     $item->access = $this->app->joomla->getDefaultAccess();
     $item->modified_by = $userId;
     $item->created_by = $userId;
     $item->created = $now;
     $item->modified = $now;
     $item->publish_up = $now;
     $item->name = JText::_('JBZOO_NEW_ITEM_NAME') . ($nameSuf ? ' #' . $nameSuf : '');
     $item->alias = uniqid('item-uid-');
     // hack for speed
     // set default params
     $item->getParams()->loadArray(array("metadata.title" => "", "metadata.description" => "", "metadata.keywords" => "", "metadata.robots" => "", "metadata.author" => "", "config.enable_comments" => 1, "config.primary_category" => "", "jbzoo.no_index" => 1));
     // for create item_id in new Item object
     $this->_table->save($item);
     return $item;
 }
Example #2
0
 /**
  * Check, if current url has old format - execute 301 redirect to correct address
  * @param $params
  */
 protected function _checkRedirect($params)
 {
     // get vars
     $segments = $params['segments'];
     $segCout = count($segments);
     // item url
     if ('item' == $segments[0] && 2 == $segCout) {
         $itemId = $this->_aliasItem->translateAliasToID($segments[1]);
         $item = $this->_itemTable->get((int) $itemId);
         $newUrl = $this->_getUrl($item, 'item');
         $this->_redirect($newUrl);
     }
     // for excess get param category_id
     if ($this->_config->get('fix_category_id', 0)) {
         $reg = '#' . $segments[0] . '\\?category_id=\\d*$#i';
         $curUrl = $this->app->jbenv->getCurrentUrl();
         if (preg_match($reg, $curUrl, $matches)) {
             $itemId = $this->_aliasItem->translateAliasToID($segments[0]);
             $item = $this->_itemTable->get((int) $itemId);
             $newUrl = $this->_getUrl($item, 'item');
             $this->_redirect($newUrl);
         }
     }
     // category url
     if ('category' == $segments[0] && (2 == $segCout || 3 == $segCout)) {
         // simple variant
         if (2 == $segCout) {
             $catId = $this->_aliasCat->translateAliasToID($segments[1]);
             $category = $this->_catTable->get((int) $catId);
             $newUrl = $this->_getUrl($category, 'category');
             $this->_redirect($newUrl);
         } else {
             if (3 == $segCout) {
                 // with pagination
                 $catId = $this->_aliasCat->translateAliasToID($segments[1]);
                 $category = $this->_catTable->get((int) $catId);
                 $newUrl = $this->_getUrl($category, 'category') . (int) $segments[2];
                 $this->_redirect($newUrl);
             }
         }
     }
     // feed
     if ('feed' == $segments[0] && ('rss' == $segments[1] || 'atom' == $segments[1]) && (3 == $segCout || 4 == $segCout)) {
         $appId = $this->_aliasApp->translateAliasToID($segments[2]);
         if ($appId) {
             if (isset($segments[3])) {
                 $categoryId = $this->_aliasCat->translateAliasToID($segments[3]);
                 $category = $this->_catTable->get($categoryId);
             } else {
                 $category = $this->app->object->create('category');
                 $category->id = 0;
                 $category->name = 'ROOT';
                 $category->alias = '_root';
             }
             $newUrl = $this->_getUrl($category, 'feed', $segments[1]);
             $this->_redirect($newUrl);
         }
     }
 }
Example #3
0
    echo TimeslotItemTable::add_timeslot_item($_POST["itemName"], $_POST["timeslotName"]);
}
if (isset($_POST["RemoveTimeslotItem"])) {
    echo TimeslotItemTable::remove_timeslot_item($_POST["itemName"], $_POST["timeslotName"]);
}
if (isset($_POST["UpdateTimeslotFactor"])) {
    echo TimeslotItemTable::update_timeslot_factor($_POST["tsiId"], $_POST["factor"]);
}
if (isset($_POST["updateItems"])) {
    echo ItemTable::update_item_details($_POST["itemId"], $_POST["itemName"], $_POST["itemUnit"]);
}
if (isset($_POST["updateRoundingOption"])) {
    echo ItemTable::update_rounding_option($_POST["roundingOption"], $_POST["itemId"]);
}
if (isset($_POST["updateRoundingFactor"])) {
    echo ItemTable::update_rounding_factor($_POST["roundingFactor"], $_POST["itemId"]);
}
if (isset($_POST["addRecipeItem"])) {
    echo RecipeItemTable::add_recipe_item($_POST["itemId"], $_POST["recipeId"]);
}
if (isset($_POST["deleteRecipeItem"])) {
    echo RecipeItemTable::delete_recipe_item($_POST["itemId"], $_POST["recipeId"]);
}
if (isset($_POST["getRecipeItems"])) {
    $result = RecipeItemTable::get_recipe_items($_POST["recipeId"]);
    if ($result) {
        echo '<ul class="category_list" id="categorized_list" >';
        while ($row = $result->fetch_assoc()) {
            echo '<li class="list_li recipe_item" recipe-item-id="' . $row["id"] . '" item-name="' . $row["name"] . '">' . $row["name"] . '
                  <input type="number" value="' . $row["quantity"] . '" onchange=updateQuantity(this)></li>';
        }
Example #4
0
            </div>
        </div>

        <div class="list_container" id="list_container">
            <div class="div_item_list">
                <h4>Items in Recipe</h4><hr>
                <div id="div" class="div_list">
                    <ul class="category_list" name="" id="categorized_list" ></ul>
                </div>
            </div>
            <div class="div_item_list">
                <h4>Items List</h4><hr>
                <div class="div_list">
                    <ul class="category_list" >
                    <?php 
$result = ItemTable::get_items();
?>
                    <?php 
while ($row = $result->fetch_assoc()) {
    ?>
                        <li class="list_li all_items" id="list_li" item-id="<?php 
    echo $row['id'];
    ?>
"><?php 
    echo $row["name"];
    ?>
</li>
                    <?php 
}
?>
                    </ul>
Example #5
0
                </div>
                <div class="block" id="item_add_div" >
                    <input type="submit" value="Add Item" class="button button_add_drawer" id="item_add_button">
                </div>
            </div>
            </div>
            <button id="drawer_tag_item" class="drawer_tag_open">Close</button>
        </div>
        <div class="div_fade"></div>

        <div class="div_category" id="item_list_div">
            <ul class="category_list">
                <button class="button_flat inline" id="item_list_cancel">Close</button>
                <h4 class="inline">ALL ITEMS</h4><hr>
                <?php 
$result = ItemTable::get_items_categories();
?>
                <?php 
$current_category = 1;
?>
                <?php 
while ($row = $result->fetch_assoc()) {
    ?>
                    <?php 
    if ($row["category_name"] != $current_category and $row["category_name"] != null) {
        ?>
                       <?php 
        $current_category = $row["category_name"];
        ?>
                        <li class="list_li_category">
                            <span><?php 
Example #6
0
            </div>
        </div>

        <div class="list_container" id="list_container">
            <div class="div_item_list">
                <h4>Categorized Items</h4><hr>
                <div id="div" class="div_list">
                    <ul class="category_list" name="" id="categorized_list" ></ul>
                </div>
            </div>
            <div class="div_item_list">
                <h4>Uncategorized Items</h4><hr>
                <div class="div_list">
                    <ul class="category_list" name="select_uncat" id="uncategorized_list" >
                    <?php 
$result = ItemTable::get_uncategorized_items();
?>
                    <?php 
while ($row = $result->fetch_assoc()) {
    ?>
                        <li class="list_li" id="<?php 
    echo $row['id'];
    ?>
" item-name="<?php 
    echo $row['name'];
    ?>
"><?php 
    echo $row["name"];
    ?>
</li>
                    <?php 
Example #7
0
    echo $row["name"];
    ?>
</span>
                    <input type="hidden" id="category_id" name="category_id" value="<?php 
    echo $row['id'];
    ?>
">
                    <span class="item_counter" id="total"><?php 
    echo ItemTable::get_total_items($row['id'], $_SESSION["date"]);
    ?>
</span>
                    <span class="float_right" id="<?php 
    echo $row['name'] . '_count';
    ?>
"><?php 
    echo ItemTable::get_updated_items_count($row['id'], $_SESSION["date"]) . "/";
    ?>
 </span>
                 </li>
            <?php 
}
?>
            </ul>
        </div>
        <div class="inventory_div">
            <div class="inventory_toolbar">
                <label class="switch float_left">
                    <input class="switch-input" type="checkbox" onclick=checkEmpty() />
                    <span class="switch-label" data-on="incomplete" data-off="All"></span>
                    <span class="switch-handle"></span>
                </label>