private function editCategory()
 {
     if (isset($_POST['editcategory'])) {
         $ctg = new Category($_GET["id"]);
         $ctg->edit($_POST['name'], $_POST['image']);
         header("Location: home.php");
     }
     $ctg = new Category($_GET["id"]);
     $data = array('category' => $ctg->getInfos());
     $this->loadView('cm_editcategory', $data);
 }
 public function process()
 {
     // check if session is active
     $session = new Session($this->sessionId);
     if ($session->sessionId > 0) {
         // update session
         $session->update();
         // process restricted functions
         switch ($this->f) {
             case 'checkLogin':
                 return Login::checkLogin($session->sessionId);
             case 'getSession':
                 return $session;
             case 'getWarehouse':
                 if (isset($this->data->update)) {
                     $warehouse = new Warehouse($session->warehouseId, $this->data->update);
                 } else {
                     $warehouse = new Warehouse($session->warehouseId);
                 }
                 $warehouse->dMail = $warehouse->getMail();
                 $warehouse->dDisableLocationLess = $warehouse->isLocationLessDisabled();
                 $warehouse->dDisablePaletteLess = $warehouse->isPaletteLessDisabled();
                 return $warehouse;
             case 'editWarehouse':
                 if (!$session->restricted) {
                     $data = $this->data;
                     $warehouse = new Warehouse($session->warehouseId);
                     // update warehouse data
                     if (isset($data->name)) {
                         $warehouse->name = $data->name;
                     }
                     if (isset($data->description)) {
                         $warehouse->description = $data->description;
                     }
                     if (isset($data->country)) {
                         $warehouse->country = $data->country;
                     }
                     if (isset($data->city)) {
                         $warehouse->city = $data->city;
                     }
                     if (isset($data->password)) {
                         $warehouse->setPassword($data->password);
                     }
                     if (isset($data->passwordRestricted)) {
                         $warehouse->setPasswordRestricted($data->passwordRestricted);
                     }
                     if (isset($data->mail)) {
                         $warehouse->setMail($data->mail);
                     }
                     if (isset($data->disableLocationLess)) {
                         $warehouse->setDisableLocationLess($data->disableLocationLess);
                     }
                     if (isset($data->disablePaletteLess)) {
                         $warehouse->setDisablePaletteLess($data->disablePaletteLess);
                     }
                     // update database entry
                     return $warehouse->edit();
                 }
                 break;
             case 'deleteWarehouse':
                 if (!$session->restricted) {
                     $warehouse = new Warehouse($session->warehouseId);
                     if ($warehouse->id > 0 && $warehouse->delete()) {
                         return $session->destroy();
                     }
                 }
                 break;
             case 'addCategory':
                 if (!$session->restricted && isset($this->data->name)) {
                     $category = new Category(null, $session->warehouseId);
                     $category->name = $this->data->name;
                     if (isset($this->data->parent)) {
                         $category->parent = $this->data->parent;
                     }
                     if ($category->edit()) {
                         return $category->id;
                     }
                 }
                 break;
             case 'getCategory':
                 if (isset($this->data->id) && isset($this->data->update)) {
                     return new Category($this->data->id, $session->warehouseId, $this->data->update);
                 } elseif (isset($this->data->id)) {
                     return new Category($this->data->id, $session->warehouseId);
                 }
                 break;
             case 'deleteCategory':
                 if (!$session->restricted && isset($this->data->id)) {
                     $category = new Category($this->data->id, $session->warehouseId);
                     return $category->delete();
                 }
                 break;
             case 'editCategory':
                 if (isset($this->data->id)) {
                     $data = $this->data;
                     $category = new Category($this->data->id, $session->warehouseId);
                     if (!$session->restricted) {
                         if (isset($data->name)) {
                             $category->name = $data->name;
                         }
                         if (isset($data->parent)) {
                             $category->parent = $data->parent;
                         }
                         if (isset($data->male)) {
                             $category->male = $data->male;
                         }
                         if (isset($data->female)) {
                             $category->female = $data->female;
                         }
                         if (isset($data->children)) {
                             $category->children = $data->children;
                         }
                         if (isset($data->baby)) {
                             $category->baby = $data->baby;
                         }
                         if (isset($data->summer)) {
                             $category->summer = $data->summer;
                         }
                         if (isset($data->winter)) {
                             $category->winter = $data->winter;
                         }
                     }
                     if (isset($data->demand)) {
                         $category->demand = $data->demand;
                     }
                     if (isset($data->weight)) {
                         $category->weight = $data->weight;
                     }
                     return $category->edit();
                 }
                 break;
             case 'getCategories':
                 if (isset($this->data->parent)) {
                     return Category::getCategories($session->warehouseId, $this->data->parent);
                 } else {
                     return Category::getCategories($session->warehouseId);
                 }
             case 'addLocation':
                 if (!$session->restricted && isset($this->data->name)) {
                     $location = new Location(null, $session->warehouseId);
                     $location->name = $this->data->name;
                     if ($location->edit()) {
                         return $location->id;
                     }
                     return true;
                 }
                 break;
             case 'getLocation':
                 if (isset($this->data->id) && isset($this->data->update)) {
                     return new Location($this->data->id, $session->warehouseId, $this->data->update);
                 } elseif (isset($this->data->id)) {
                     return new Location($this->data->id, $session->warehouseId);
                 }
                 break;
             case 'deleteLocation':
                 if (!$session->restricted && isset($this->data->id)) {
                     $location = new Location($this->data->id, $session->warehouseId);
                     return $location->delete();
                 }
                 break;
             case 'editLocation':
                 if (!$session->restricted && isset($this->data->id) && isset($this->data->name)) {
                     $location = new Location($this->data->id, $session->warehouseId);
                     $location->name = $this->data->name;
                     return $location->edit();
                 }
                 break;
             case 'getLocations':
                 return Location::getLocations($session->warehouseId);
             case 'addPalette':
                 $palette = new Palette(null, $session->warehouseId);
                 if (isset($this->data->locationId)) {
                     $palette->locationId = $this->data->locationId;
                 }
                 if ($palette->edit()) {
                     return $palette->id;
                 }
                 break;
             case 'getPalette':
                 if (isset($this->data->id) && isset($this->data->update)) {
                     return new Palette($this->data->id, $session->warehouseId, $this->data->update);
                 } elseif (isset($this->data->id)) {
                     return new Palette($this->data->id, $session->warehouseId);
                 }
                 break;
             case 'deletePalette':
                 if (isset($this->data->id)) {
                     $palette = new Palette($this->data->id, $session->warehouseId);
                     return $palette->delete();
                 }
                 break;
             case 'editPalette':
                 if (isset($this->data->id)) {
                     $palette = new Palette($this->data->id, $session->warehouseId);
                     if (isset($this->data->locationId)) {
                         $palette->locationId = $this->data->locationId;
                     }
                     return $palette->edit();
                 }
                 break;
             case 'getPalettes':
                 return Palette::getPalettes($session->warehouseId);
             case 'getCarton':
                 if (isset($this->data->id) && isset($this->data->update)) {
                     return new Carton($this->data->id, $session->warehouseId, null, null, $this->data->update);
                 } elseif (isset($this->data->id)) {
                     return new Carton($this->data->id, $session->warehouseId);
                 }
                 break;
             case 'addCarton':
                 $locationId = null;
                 $paletteId = null;
                 if (isset($this->data->location)) {
                     $locationId = $this->data->location;
                 }
                 if (isset($this->data->palette)) {
                     $paletteId = $this->data->palette;
                 }
                 $carton = new Carton(null, $session->warehouseId, $locationId, $paletteId);
                 return $carton->id;
             case 'deleteCarton':
                 if (isset($this->data->id)) {
                     $carton = new Carton($this->data->id, $session->warehouseId);
                     return $carton->delete();
                 }
                 break;
             case 'editCarton':
                 if (isset($this->data->id)) {
                     $carton = new Carton($this->data->id, $session->warehouseId);
                     if (isset($this->data->location)) {
                         $carton->locationId = $this->data->location;
                     } else {
                         $carton->locationId = null;
                     }
                     if (isset($this->data->palette)) {
                         $carton->paletteId = $this->data->palette;
                     } else {
                         $carton->paletteId = null;
                     }
                     return $carton->edit();
                 }
                 break;
             case 'addArticle':
                 if (isset($this->data->carton) && isset($this->data->category) && isset($this->data->amount)) {
                     return Stock::addArticle($this->data->carton, $this->data->category, isset($this->data->male) ? $this->data->male : false, isset($this->data->female) ? $this->data->female : false, isset($this->data->children) ? $this->data->children : false, isset($this->data->baby) ? $this->data->baby : false, isset($this->data->winter) ? $this->data->winter : false, isset($this->data->summer) ? $this->data->summer : false, $this->data->amount >= 0 ? $this->data->amount : 0, $this->data->amount < 0 ? $this->data->amount : 0);
                 }
                 break;
             case 'getStock':
                 return Stock::getStock($session->warehouseId, isset($this->data->carton) ? $this->data->carton : null, isset($this->data->category) ? $this->data->category : null, isset($this->data->palette) ? $this->data->palette : null, isset($this->data->location) ? $this->data->location : null, isset($this->data->male) ? $this->data->male : false, isset($this->data->female) ? $this->data->female : false, isset($this->data->children) ? $this->data->children : false, isset($this->data->baby) ? $this->data->male : false, isset($this->data->summer) ? $this->data->male : false, isset($this->data->winter) ? $this->data->male : false, isset($this->data->details) ? $this->data->details : false);
             case 'getBarcodeUri':
                 if (isset($this->data->text)) {
                     // create barcode object
                     $bc = new Barcode39($this->data->text);
                     if (isset($this->data->textSize)) {
                         $bc->barcode_text_size = $this->data->textSize;
                     }
                     if (isset($this->data->barThin)) {
                         $bc->barcode_bar_thin = $this->data->barThin;
                     }
                     if (isset($this->data->barThick)) {
                         $bc->barcode_bar_thick = $this->data->barThick;
                     }
                     // generate barcode image
                     $img = "barcode_" . mt_rand(0, 100) . ".png";
                     $bc->draw($img);
                     // get data uri
                     $uri = Barcode39::getDataURI($img);
                     unlink($img);
                     return $uri;
                 }
                 break;
         }
     } else {
         // process unrestricted function
         switch ($this->f) {
             case 'getActiveSessions':
                 return Session::getActiveSessionsNumber();
             case 'getWarehouses':
                 return Warehouse::getWarehouses();
             case 'addWarehouse':
                 $data = $this->data;
                 if (isset($data->name) && isset($data->description) && isset($data->country) && isset($data->city) && isset($data->password) && isset($data->mail)) {
                     $warehouse = new Warehouse();
                     Log::debug('new warehouse' . $warehouse->id);
                     $warehouse->name = $data->name;
                     $warehouse->description = $data->description;
                     $warehouse->country = $data->country;
                     $warehouse->city = $data->city;
                     $warehouse->setPassword($data->password);
                     $warehouse->setMail($data->mail);
                     return $warehouse->edit();
                 }
                 break;
             case 'getCountries':
                 return getCountries();
                 break;
             case 'getCountryCode':
                 $data = $this->data;
                 if (isset($data->name)) {
                     return getCountryCode(null, $data->name);
                 }
                 return false;
         }
     }
     return false;
 }
Example #3
0
 function category_edit_handler()
 {
     $this->check_login();
     $params = $this->input->post();
     if (isset($params['save'])) {
         Category::edit($params);
     }
     redirect('admin/categories');
 }
Example #4
0
     $cat_id = POST('cat_id');
     ossim_valid($cat_id, OSS_DIGIT, 'illegal:' . _('Category'));
     if (ossim_error()) {
         $data['status'] = 'error';
         $data['data'] = _('Error! Category ID not allowed');
     }
 } elseif ($action == 'rename_category') {
     $cat_id = POST('cat_id');
     $c_name = POST('c_name');
     ossim_valid($c_name, OSS_SCORE, OSS_ALPHA, OSS_NULLABLE, 'illegal:' . _('Category Name'));
     ossim_valid($cat_id, OSS_DIGIT, 'illegal:' . _('Category'));
     $data['status'] = 'error';
     $data['data'] = _('Error! Category not renamed');
     if (!ossim_error()) {
         if (!Category::exist($conn, $c_name)) {
             if (Category::edit($conn, $cat_id, $c_name)) {
                 $data['status'] = 'OK';
                 $data['data'] = _('Category renamed successfully');
             }
         } else {
             $data['data'] = _('Error! This category already exists');
         }
     } else {
         $data['data'] = ossim_get_error_clean();
     }
 } elseif ($action == 'rename_subcategory') {
     $cat_id = POST('cat_id');
     $subcat_id = POST('subcat_id');
     $sc_name = POST('sc_name');
     ossim_valid($sc_name, OSS_SCORE, OSS_ALPHA, OSS_NULLABLE, 'illegal:' . _('Subcategory Name'));
     ossim_valid($cat_id, OSS_DIGIT, 'illegal:' . _('Category'));
Example #5
0
        // insert ok
        $msg = 'Ok! Delete Subcategory';
    } else {
        // fail insert
        $msg = 'Error no delete Subcategory';
    }
    //Header('Location: category.php?action=expand&id='.$idCategory);
} elseif ($action == 'expand') {
    $idCategory = POST('id');
    ossim_valid($idCategory, OSS_ALPHA, 'illegal:' . _("Category"));
} elseif ($action == 'renameCategory') {
    $idCategory = POST('id');
    ossim_valid($idCategory, OSS_ALPHA, 'illegal:' . _("Category"));
    $nameCategory = POST('nameCategory');
    ossim_valid($nameCategory, OSS_SCORE, OSS_ALPHA, OSS_NULLABLE, 'illegal:' . _("Name Category"));
    if (Category::edit($conn, $idCategory, $nameCategory)) {
        // insert ok
        $msg = 'Ok! Rename Category';
    } else {
        // fail insert
        $msg = 'Error no rename Category';
    }
} elseif ($action == 'renameSubcategory') {
    $idSubcategory = POST('id');
    ossim_valid($idSubcategory, OSS_ALPHA, 'illegal:' . _("Subcategory"));
    $nameSubCategory = POST('nameSubCategory');
    ossim_valid($nameSubCategory, OSS_SCORE, OSS_ALPHA, OSS_NULLABLE, 'illegal:' . _("Name Subcategory"));
    if (Subcategory::edit($conn, $idSubcategory, $nameSubCategory)) {
        // insert ok
        $msg = 'Ok! Rename Subcategory';
    } else {
 public function update($f3, $params)
 {
     $obj = new Category($this->db);
     echo json_encode($obj->edit($params["CategoryID"], $this->f3->get("POST.postdata")));
 }
Example #7
0
	requireStrictRoute();

	$response = array();
	$response['error'] = 0;
	$response['message'] = '';
	
	$id = $_POST['id'];
	$name = $_POST['name'];
	$filter = isset($_POST['filter'])?$_POST['filter']:'';

	if(empty($id) || empty($name)) {
			$response['error'] = -1;
			$response['message'] = _t('잘못된 접근입니다.');
	} else {
		if (!isAdmin()) {
			$response['error'] = 1;
			$response['message'] = _t('관리자만이 이 기능을 사용할 수 있습니다.');
		} else {
			requireComponent('Bloglounge.Data.Category');
			if(!Category::edit($id, $name, $filter)) {
				$response['error'] = 2;
				$response['message'] = _t('분류수정을 실패하였습니다.');
			} else {
				$response['message'] = $name;
			}
		}
	}

	func::printRespond($response);
?>
Example #8
0
 * Trang chỉnh sửa danh mục sản phẩm
 */
//Khởi động session
session_start();
//Kiểm tra nếu chưa đăng nhập thì quay về trang đăng nhập
if (!isset($_SESSION['user'])) {
    header('location:../user/login.php');
}
require '../../config/Config.php';
require '../../models/Category.php';
date_default_timezone_set('Asia/Ho_Chi_Minh');
//Lấy category_id từ URL
$category_id = $_GET['category_id'];
//Khởi tạo đối tượng danh mục sản phẩm
$categoryModel = new Category();
//Nếu có POST dữ liệu lên thì xử lý cập nhật
if ($_POST) {
    //Nhận dữ liệu từ form và gán vào một mãng
    $data = array('name' => $_POST['name'], 'status' => isset($_POST['status']) ? 1 : 0, 'modified' => date('Y-m-d H:i:s'));
    if ($categoryModel->edit($data, $category_id)) {
        //Tạo session để lưu cờ thông báo thành công
        $_SESSION['success'] = true;
        //Tải lại trang (Mục đích là để tải lại thông tin mới)
        header('location:list.php');
    }
    exit;
}
//Lấy thông tin danh mục sản phẩm để trình bày trên form
$category = $categoryModel->getById($category_id);
//Giao diện
require '../../views/category/v_edit.php';