Exemplo n.º 1
0
 public function testDeleteCategory()
 {
     $cat = ItemCategory::FindByName('Test Category 2');
     ItemCategory::Delete($cat->id);
     $cat = ItemCategory::FindObject($cat->id);
     $this->assertTrue($cat == null);
 }
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 5) as $index) {
         ItemCategory::create(['name' => $faker->word]);
     }
 }
Exemplo n.º 3
0
 public function run()
 {
     /*$faker = Faker::create();
     
     		foreach(range(1, 10) as $index)
     		{*/
     ItemCategory::create(['name' => '男装', 'description' => '男装系列', 'parent_id' => 0, 'sort' => 0]);
     ItemCategory::create(['name' => '女装', 'description' => '女装系列', 'parent_id' => 0, 'sort' => 0]);
     ItemCategory::create(['name' => '童装', 'description' => '童装系列', 'parent_id' => 0, 'sort' => 0]);
     ItemCategory::create(['name' => '箱包', 'description' => '箱包系列', 'parent_id' => 0, 'sort' => 0]);
     /*}*/
 }
Exemplo n.º 4
0
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        Eloquent::unguard();
        DB::table('companies')->delete();
        DB::table('items')->delete();
        DB::table('categories')->delete();
        $territory = Territory::where('name', 'Stockholms län')->where('county', '01')->first();
        $company1 = Company::create(array('id' => 1, 'name' => '北欧工作室', 'description' => 'chenyipingsheng: 如何设计api,应该先按模块拆分原则进行初步划分。(4) api返回数据文章中所说的对null的看法...
app后端设计(10)--数据增量更新
chenyipingsheng: 文章中update_time的时间粒度选择的是分钟,如果某个时间段内新增的条数/分钟,超过了单页si...', 'territory_id' => $territory->id, 'url' => 'http://www.google.com', 'address' => '啊发扩大浪费大斗进发觉啦地方', 'established_year' => '2011'));
        $company2 = Company::create(array('id' => 2, 'name' => '阿呆姆斯工作室', 'description' => 'chenyipingsheng: 如何设计api,应该先按模块拆分原则进行初步划分。(4) api返回数据文章中所说的对null的看法...
app后端设计(10)--数据增量更新
chenyipingsheng: 文章中update_time的时间粒度选择的是分钟,如果某个时间段内新增的条数/分钟,超过了单页si...', 'territory_id' => $territory->id, 'url' => 'http://www.google.com', 'address' => '饿我热哦我iooewpp', 'established_year' => '2013'));
        $item1 = Item::create(array('id' => 1, 'company_id' => 1, 'name' => 'Kayala投资项目', 'description' => '做了3年app相关的系统架构,api设计,先后在3个创业公司中工作,经历过手机网页端,android客户端,iphone客户端,现就职于app云后端平台bmob(想了解bmob点击这里)。其中的乐与苦,得与失,仰首问天有谁知?我觉得是时候来个总结,把相关的技术和心得记录下来。', 'territory_id' => $territory->id, 'url' => 'http://www.google.com', 'min_investment' => 20000000));
        $item2 = Item::create(array('id' => 2, 'company_id' => 1, 'name' => '棕熊城堡出售', 'description' => '做了3年app相关的系统架构,api设计,先后在3个创业公司中工作,经历过手机网页端,android客户端,iphone客户端,现就职于app云后端平台bmob(想了解bmob点击这里)。其中的乐与苦,得与失,仰首问天有谁知?我觉得是时候来个总结,把相关的技术和心得记录下来。', 'territory_id' => $territory->id, 'url' => 'http://www.google.com', 'min_investment' => 30000000, 'max_investment' => 30000000));
        $item3 = Item::create(array('id' => 3, 'company_id' => 2, 'name' => '布鲁艾尔空气净化器', 'description' => '做了3年app相关的系统架构,api设计,先后在3个创业公司中工作,经历过手机网页端,android客户端,iphone客户端,现就职于app云后端平台bmob(想了解bmob点击这里)。其中的乐与苦,得与失,仰首问天有谁知?我觉得是时候来个总结,把相关的技术和心得记录下来。', 'territory_id' => $territory->id, 'url' => 'http://www.google.com', 'min_investment' => 10000000, 'max_investment' => 10000000));
        $item4 = Item::create(array('id' => 4, 'company_id' => 2, 'name' => 'volvo公司转让', 'description' => '做了3年app相关的系统架构,api设计,先后在3个创业公司中工作,经历过手机网页端,android客户端,iphone客户端,现就职于app云后端平台bmob(想了解bmob点击这里)。其中的乐与苦,得与失,仰首问天有谁知?我觉得是时候来个总结,把相关的技术和心得记录下来。', 'territory_id' => $territory->id, 'url' => 'http://www.google.com', 'min_investment' => 250000000, 'max_investment' => 250000000));
        Category::create(array('id' => 1, 'name' => '融资项目'));
        Category::create(array('id' => 2, 'name' => '房产出售'));
        Category::create(array('id' => 3, 'name' => '产品推广'));
        Category::create(array('id' => 4, 'name' => '公司转让'));
        Category::create(array('id' => 5, 'name' => '技术出售'));
        Category::create(array('id' => 6, 'name' => '文化, 媒体, 旅游'));
        CompanyCategory::create(array('id' => 1, 'company_id' => 1, 'category_id' => 6));
        CompanyCategory::create(array('id' => 2, 'company_id' => 2, 'category_id' => 6));
        ItemCategory::create(array('id' => 1, 'item_id' => 1, 'category_id' => 1));
        ItemCategory::create(array('id' => 2, 'item_id' => 1, 'category_id' => 2));
        ItemCategory::create(array('id' => 3, 'item_id' => 2, 'category_id' => 2));
        ItemCategory::create(array('id' => 4, 'item_id' => 3, 'category_id' => 4));
        ItemCategory::create(array('id' => 5, 'item_id' => 3, 'category_id' => 5));
        ItemCategory::create(array('id' => 6, 'item_id' => 3, 'category_id' => 6));
        ItemCategory::create(array('id' => 7, 'item_id' => 4, 'category_id' => 3));
        ItemCategory::create(array('id' => 8, 'item_id' => 4, 'category_id' => 5));
        Tag::create(array('id' => 1, 'name' => '回报率高'));
        Tag::create(array('id' => 2, 'name' => '绿色环保'));
        Tag::create(array('id' => 3, 'name' => '市场巨大'));
        Tag::create(array('id' => 4, 'name' => '用途广'));
        Tag::create(array('id' => 5, 'name' => '历史悠久'));
        Tag::create(array('id' => 6, 'name' => '可自雇'));
        Tag::create(array('id' => 7, 'name' => 'PM2.5'));
        ItemTag::create(array('id' => 1, 'tag_id' => 1, 'item_id' => 1));
        ItemTag::create(array('id' => 2, 'tag_id' => 2, 'item_id' => 1));
        ItemTag::create(array('id' => 3, 'tag_id' => 3, 'item_id' => 1));
        ItemTag::create(array('id' => 4, 'tag_id' => 2, 'item_id' => 2));
        ItemTag::create(array('id' => 5, 'tag_id' => 3, 'item_id' => 2));
        ItemTag::create(array('id' => 6, 'tag_id' => 4, 'item_id' => 2));
        ItemTag::create(array('id' => 7, 'tag_id' => 5, 'item_id' => 3));
        ItemTag::create(array('id' => 8, 'tag_id' => 6, 'item_id' => 3));
        ItemTag::create(array('id' => 9, 'tag_id' => 7, 'item_id' => 3));
        ItemTag::create(array('id' => 10, 'tag_id' => 3, 'item_id' => 4));
        ItemTag::create(array('id' => 11, 'tag_id' => 6, 'item_id' => 4));
    }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = ItemCategory::model()->findByPk((int) $id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Exemplo n.º 6
0
            if (75000 < $FileSize) {
                // Too Big
            } elseif ($FileType != "image/png" && $FileType != "image/jpg" && $FileType != "image/jpeg") {
                // Bad Type
            } elseif ($FileExtension != "png" && $FileExtension != "jpg" && $FileExtension != "jpeg") {
                // Bad Extension
            } else {
                $ImageURLName = md5(rand());
                move_uploaded_file($File["tmp_name"], "includes/images/uploaded/" . $ImageURLName . "." . $FileExtension);
            }
        }
        Database::Insert("gmd_items", array("Category" => intval($_POST["catID"]), "Name" => $_POST["itemName"], "Description" => $_POST["itemDesc"], "Cost" => floatval($_POST["itemCost"]), "Image" => $ImageURLName, "ShowImage" => !empty($_POST["showImage"]) ? 1 : 0, "Status" => ItemStatus::ACTIVE));
        echo "<h4>You are being redirected..</h4>";
        KERNEL::HardNavigate("admin", "&area=items");
    } else {
        $CatObj = ItemCategory::GetByField("ItemCategory", "ID", $_GET["catid"]);
        ?>

<h4>Add Item</h4>

<form enctype="multipart/form-data" method="POST" action="?page=admin&area=items&newitem=1">
	<input type="hidden" name="addItem" value="1" />
	<input type="hidden" name="catID" value="<?php 
        echo $CatObj->GetValue("ID");
        ?>
" />
	<input type="hidden" id="itemDesc" name="itemDesc" value="No Description Available" />
	
	<div class="row">
		<div class="row">
			<div class="col-sm-6 col-md-4" style="text-align: right;line-height: 34px;">
Exemplo n.º 7
0
	/**
	* Generate array for dropdown list to use in child form.
	* @return array $_items
	*/
	public static function items()
	{
	    self::$_items = CHtml::listData(self::model()->findAll(), 'id', 'cat_name');
	    return self::$_items;
	}
Exemplo n.º 8
0
KERNEL::LoadModule("Action");
KERNEL::LoadModule("ItemAction");
KERNEL::LoadModule("UserAction");
KERNEL::LoadModule("Servers");
KERNEL::LoadModule("License");
KERNEL::AddPage("home", "Home", true);
KERNEL::AddPage("store", "Store", true, null, function () {
    $btnHtm = '
			<li class="dropdown closed">
				<a class="dropdown-toggle" data-toggle="dropdown" href="#">
				  Store <span class="caret"></span>
				</a>
				
				<ul class="dropdown-menu">
		';
    foreach (ItemCategory::GetCachedResults("ItemCategory") as $ItemCat) {
        $btnHtm .= '<li><a href="?page=store&cat=' . $ItemCat->GetValue("ID") . '">' . $ItemCat->GetValue("Name") . '</a></li>';
    }
    return $btnHtm . '
				</ul>
			</li>
			
			<script>
				$( ".dropdown-toggle" ).dropdown();
			</script>
		';
});
KERNEL::AddPage("account", "Your Account", true, User::AccessCheck_LoggedIn());
KERNEL::AddPage("donate", "Donate", true, User::AccessCheck_LoggedIn());
KERNEL::AddPage("admin", "Admin", true, User::AccessCheck_Admin());
KERNEL::AddPage("login", "Login", false);
Exemplo n.º 9
0
<?php

$ItemCategories = ItemCategory::GetCachedResults("ItemCategory");
if (count($ItemCategories) == 0) {
    KERNEL::OnError("You must add an item category before accessing this page.", false);
} else {
    foreach ($ItemCategories as $ItemCat) {
        echo '
				<div class="panel panel-default">
					<div class="panel-heading">
						<a href="?page=admin&area=items&newitem=1&catid=' . $ItemCat->GetValue("ID") . '" style="float: right;"><span class="btn btn-xs btn-success">Add Item</span></a>
						<b>' . $ItemCat->GetValue("Name") . ' Items</b>
					</div>
					
					<table class="table">
						<thead style="font-size: 12px;">
							<th style="width: 50%;">Name</th>
							<th style="width: 25%;">Cost</th>
							<th style="width: 25%;text-align: right;">Actions</th>
						</thead>
						
						<tbody>
			';
        $Items = Item::SearchCachedResults("Item", "Category", $ItemCat->GetValue("ID"));
        if (count($Items) == 0) {
            echo '<tr><td colspan=3 style="text-align: center;padding: 16px;font-size: 12px;"><i>No items to display!</i></td></tr>';
        } else {
            foreach ($Items as $ItemObj) {
                echo '
						<tr style="font-size: 12px;">
							<td>' . $ItemObj->GetValue("Name") . ' 
Exemplo n.º 10
0
            $this->ChangeValue("Image", $ImageURLName);
        }
    }
    public function DeleteImage()
    {
        if (!empty($this->Data["Image"]) && $this->Data["Image"] != "item_default.png") {
            @unlink("includes/images/uploaded/" . $this->Data["Image"]);
        }
    }
    public function Delete()
    {
        $ItemActions = ItemAction::GetAllByField("ItemAction", "ItemID", $this->GetValue("ID"));
        // Delete all actions related to this item
        foreach ($ItemActions as $ItemAction) {
            // Delete all of the user actions using this Item Action
            $UserActions = UserAction::GetAllByField("UserAction", "ItemAction", $ItemAction->GetValue("ID"));
            foreach ($UserActions as $UserAction) {
                $UserAction->Delete();
            }
            // Delete the actual item action
            $ItemAction->Delete();
        }
        // Delete the saved image (we warned them)
        $this->DeleteImage();
        // Literally delete the item itself
        Database::Query("DELETE FROM `%s` WHERE `ID` = %s;", static::$TableName, $this->Data["ID"]);
        DB_Accessor::FlushMemCache(get_class($this));
    }
}
ItemCategory::PrecacheAll("Item");
Exemplo n.º 11
0
<?php

$ItemObj = Item::GetByField("Item", "ID", intval($_GET["item"]));
$CatObj = ItemCategory::GetByField("ItemCategory", "ID", $ItemObj->GetValue("Category"));
if (isset($_POST["editItem"])) {
    $ImageURLName = "item_default.png";
    if (isset($_FILES["itemImage"])) {
        $ItemObj->SetImageFromInput("itemImage");
    }
    $ItemObj->ChangeValue("Name", $_POST["itemName"]);
    $ItemObj->ChangeValue("Cost", floatval($_POST["itemCost"]));
    $ItemObj->ChangeValue("ShowImage", !empty($_POST["showImage"]) ? 1 : 0);
    $ItemObj->ChangeValue("Description", $_POST["itemDesc"]);
    $ItemObj->ChangeValue("Status", intval($_POST["itemStatus"]));
    echo '<div class="alert alert-success" role="alert">Product has been updated successfully.</div>';
}
?>

<h4>Edit Item</h4>

<form enctype="multipart/form-data"  method="POST" action="?page=admin&area=items&edit=1&item=<?php 
echo $ItemObj->GetValue("ID");
?>
">
	<input type="hidden" name="editItem" value="1" />
	<input type="hidden" id="itemDesc" name="itemDesc" value="<?php 
echo $ItemObj->GetValue("Description");
?>
" />
	
	<div class="row">
Exemplo n.º 12
0
 public function itemCategories()
 {
     echo json_encode(ItemCategory::FindAll());
 }
Exemplo n.º 13
0
 public function getCategoriesList()
 {
     $db = $this->db;
     $categories = array();
     if (!($stmt = $db->query("SELECT `id` FROM {$this->TABLE_NAME_CATEGORY} ORDER BY -id DESC"))) {
         echo '<h2>Ошибка поддключения к базе данных!</h2>';
         die;
     } else {
         while ($row = $stmt->fetch_assoc()) {
             $item = new ItemCategory();
             $item->queryCategory($db, $row['id']);
             array_push($categories, $category);
         }
     }
     return $categories;
 }
Exemplo n.º 14
0
 public function deleteCategory($id)
 {
     $db = $this->db;
     $deleted = new ItemCategory();
     $deleted->delete($db, $id);
 }
Exemplo n.º 15
0
<?php

if (isset($_POST["addItemCat"])) {
    ItemCategory::MakeCategory($_POST["itemCatName"]);
} elseif (isset($_GET["delete"])) {
    $CatObj = ItemCategory::GetByField("ItemCategory", "ID", intval($_GET["delete"]));
    $ItemsInCat = Item::GetAllByField("Item", "Category", $CatObj->GetValue("ID"));
    if (count($ItemsInCat) > 0) {
        echo '
				<div class="alert alert-danger" role="alert">
					<b>Error</b> The category "' . $CatObj->GetValue("Name") . '" because it still contains items.
				</div>
			';
    } else {
        $CatObj->Delete();
        echo '
				<div class="alert alert-success" role="alert">
					<b>Success</b> The category "' . $CatObj->GetValue("Name") . '" has been deleted.
				</div>
			';
    }
}