Example #1
0
<?php

session_start();
require_once '../classes/connection.class.php';
require_once '../classes/category.class.php';
$addCategoryObj = new Category();
if (isset($_POST['add_category'])) {
    $category_id = $_POST['category_id'];
    $category_title = $_POST['category_title'];
    $category_thumb_image = $_POST['category_thumb_image'];
}
$addCategoryObj->setCategoryID($category_id);
$addCategoryObj->setCategoryTitle($category_title);
$addCategoryObj->setCategoryThumbImage($category_thumb_image);
/*echo '<pre>';
print_r($addCategoryObj);
echo '</pre>';
exit;*/
$flag = $addCategoryObj->addCategory();
/*echo '<pre>';
print_r($addCategoryObj->addCategory());
echo '</pre>';
exit;*/
if ($flag) {
    $_SESSION['error'] = $addCategoryObj->er = "The category successfully added";
    header('location:../index.php?page=category&action=view');
} else {
    $_SESSION['error'] = $addCategoryObj->er = "The category couldn't be added";
    header('location:../index.php?page=category&action=add');
}
Example #2
0
    <?php 
if (sizeof($views > 0)) {
    foreach ($views as $value) {
        ?>
    <tr>
      <th scope="row">&nbsp; <?php 
        echo $value['menu_id'];
        ?>
</th>
      <td>&nbsp;<?php 
        echo $value['menu_title'];
        ?>
</td>
      <td>&nbsp;<?php 
        $menu_category = $value['menu_category'];
        $addcategoyobj->setCategoryID($menu_category);
        $category_values = $addcategoyobj->viewCategory();
        foreach ($category_values as $cate_value) {
            echo $cate_value['category_title'];
        }
        ?>
</td>
      <td>&nbsp;<?php 
        echo $value['menu_price'];
        ?>
</td>
      
      
      <td ><a onClick="return confirm('Are you sure you want to delete')"
      			 href="index.php?page=menu&action=delete&menu_id=<?php 
        echo $value['menu_id'];
<?php

session_start();
require_once '../classes/connection.class.php';
require_once '../classes/category.class.php';
require_once '../classes/locate.class.php';
if (isset($_POST['update_category'])) {
    $category_id = $_POST['category_id'];
    $category_title = $_POST['category_title'];
    $category_thumb_image = $_POST['category_thumb_image'];
}
$updateCategoryObj = new Category();
$updateCategoryObj->setCategoryID($category_id);
$updateCategoryObj->setCategoryTitle($category_title);
$updateCategoryObj->setCategoryThumbImage($category_thumb_image);
$flag = $updateCategoryObj->updateCategory();
/*echo '<pre>';
print_r($flag);
echo '</pre>';
exit;
*/
if ($flag) {
    $_SESSION['update_category'] = "The category successfully updated";
    new Locate('../index.php?page=category&action=view');
} else {
    $_SESSION['update_not_category'] = "The category couldn't be updated";
    new Locate('../index.php?page=category&action=view');
}
<?php

session_start();
require_once '../classes/connection.class.php';
require_once '../classes/category.class.php';
require_once '../classes/locate.class.php';
$category_id = isset($_GET['category_id']) ? (int) $_GET['category_id'] : '';
$deleteCategoryObj = new Category();
$deleteCategoryObj->setCategoryID($category_id);
$flag = $deleteCategoryObj->deleteCategory();
/*echo '<pre>';
print_r($deleteBlogObj);
echo '</pre>';
exit;*/
if ($flag) {
    header('location:../index.php?page=category&action=view');
    $_SESSION['category_deleted'] = $deleteCategoryObj->msg = "The category successfully deleted";
} else {
    header('location:../index.php?page=category&action=view');
    $_SESSION['category_not_deleted'] = $deleteCategoryObj->msg = "The category couldn't be successfully deleted";
}
Example #5
0
 /**
  * Populate category object 
  *
  * @param array $category
  * @return object Category
  */
 protected function getCategory($category)
 {
     if (empty($category)) {
         throw new BuyatException('Malformed response from server');
     }
     $categoryObject = new Category();
     $categoryObject->setCategoryID($category['category_id']);
     $categoryObject->setLevel($category['level']);
     $categoryObject->setCategoryName($category['category_name']);
     if (isset($category['subcategories'])) {
         $vSubCategories = array();
         foreach ($category['subcategories'] as $vSubCategory) {
             $vSubCategories[] = $this->getCategory($vSubCategory['value']);
         }
         $categoryObject->setSubcategories($vSubCategories);
     }
     if (isset($category['parent_category_id'])) {
         $categoryObject->setParentCategoryID($category['parent_category_id']);
     }
     if (isset($category['parent_category_name'])) {
         $categoryObject->setParentCategoryName($category['parent_category_name']);
     }
     return $categoryObject;
 }