示例#1
0
文件: Category.php 项目: piwik/piwik
 public function addSubcategory(Subcategory $subcategory)
 {
     $subcategoryId = $subcategory->getId();
     if ($this->hasSubcategory($subcategoryId)) {
         throw new \Exception(sprintf('Subcategory %s already exists', $subcategoryId));
     }
     $this->subcategories[$subcategoryId] = $subcategory;
 }
示例#2
0
 public function insert(Category $category, Subcategory $subcategory, Brand $brand, Item $item)
 {
     //        $sql = "INSERT INTO item values (null, 'aalluu', 'asdfasd',true,true, '2015-10-10','asdfasf', 'asdfasd', 1, 1 ,1, 1)";
     $sql = "INSERT INTO item values (null, '" . $item->getTitle() . "','" . $item->getDetail() . "',true,false, '" . $item->getDate() . "', '" . $item->getLocation() . "','asfasf'," . $category->getId() . "," . $subcategory->getId() . ", 1 ," . $brand->getId() . ")";
     echo $sql;
     if ($this->conn->query($sql) === TRUE) {
         echo "Insert operation successful";
     } else {
         echo "Error inserting: ";
     }
 }
 /**
  * @param $id
  * @return string
  */
 public function getByBusiness($business_id)
 {
     $sql = "SELECT DISTINCT reuse_and_repair_db.Subcategory.subcategory_id, reuse_and_repair_db.Subcategory.subcategory_name FROM reuse_and_repair_db.Business\n          INNER JOIN reuse_and_repair_db.Business_Subcategory ON reuse_and_repair_db.Business.business_id = reuse_and_repair_db.Business_Subcategory.fk_business_id\n        \tINNER JOIN reuse_and_repair_db.Subcategory ON reuse_and_repair_db.Business_Subcategory.fk_subcategory_id = reuse_and_repair_db.Subcategory.subcategory_id\n          WHERE reuse_and_repair_db.Business.business_id = ?\n        \tORDER BY reuse_and_repair_db.Subcategory.subcategory_name;";
     $prepared = $this->db->link->prepare($sql);
     $prepared->bindParam(1, $business_id);
     $success = $prepared->execute();
     $all = $prepared->fetchAll();
     foreach ($all as $row) {
         $subcategory = new Subcategory($row['subcategory_id'], $row['subcategory_name']);
         $this->results[] = $subcategory->jsonSerialize();
     }
     return $this->getJSON();
 }
function get_filters_names($conn)
{
    $filter = array();
    //Reputation Activities
    $filter['act'] = Reputation::get_reputation_activities($conn);
    //Product types
    $product_types = Product_type::get_list($conn);
    $filter['ptype'][0] = _('ANY');
    foreach ($product_types as $ptype) {
        $filter['ptype'][$ptype->get_id()] = $ptype->get_name();
    }
    //Subcategories
    $subcategories = Subcategory::get_list($conn);
    $filter['subcat'][0] = _('ANY');
    foreach ($subcategories as $subc) {
        $filter['subcat'][$subc->get_id()] = $subc->get_name();
    }
    //Categories
    $categories = Category::get_list($conn);
    $filter['cat'][0] = _('ANY');
    foreach ($categories as $cat) {
        $filter['cat'][$cat->get_id()] = $cat->get_name();
    }
    return $filter;
}
示例#5
0
 function __construct($id = -1)
 {
     if (self::$conn == Null) {
         self::$conn = mysqli_connect('localhost', 'root', 'iti', 'eShop');
     }
     if ($id != -1) {
         $query = "select * from subcategories where scID={$id} limit 1";
         $result = mysqli_query(self::$conn, $query);
         $subcategory = mysqli_fetch_assoc($result);
         $this->scID = $subcategory['scID'];
         $this->scName = $subcategory['scName'];
         $this->cID = $subcategory['cID'];
     }
 }
示例#6
0
if (ossim_error()) {
    die(ossim_error());
}
$db = new ossim_db();
$conn = $db->connect();
// translate category id
$category_name = '';
if ($category_id != "") {
    if ($category_list = Category::get_list($conn, "WHERE id = '{$category_id}'")) {
        $category_name = $category_list[0]->get_name();
    }
}
//Subcategory
$subcategory_name = '';
if ($subcategory_id != "") {
    if ($subcategory_list = Subcategory::get_list($conn, "WHERE id = '{$subcategory_id}'")) {
        $subcategory_name = $subcategory_list[0]->get_name();
    }
}
$category_filter = $subcategory_name != "" ? "{$category_name} - {$subcategory_name}" : $category_name;
$dt_url = "getpluginsid.php?plugin_id={$plugin_id}";
if ($category_id != "") {
    $dt_url .= "&category_id={$category_id}";
}
if ($subcategory_id != "") {
    $dt_url .= "&subcategory_id={$subcategory_id}";
}
$back_url = urlencode(preg_replace('/([&|\\?]msg\\=)(\\w+)/', '\\1', $_SERVER["REQUEST_URI"]));
?>

示例#7
0
   </form>
   <!-- ............................. delete subcategories ....................................... -->
   <form method="post" action="">
     <fieldset>
       <legend>DELETE</legend>
       <table class='table table-hover'>
         <tr>
           <thead>
             <th>Category</th>
             <th>Subcategory</th>
             <th>Action</th>
           </thead>
         </tr>
         <?php 
 include '../../classes/subcategory.php';
 $subcategory = new Subcategory();
 foreach ($cData as $key => $cate) {
     $scData = $subcategory->getSubcategories($cate['cID']);
     $scCount = count($scData);
     echo "<tr>";
     echo "<td class='cNameCol' value='" . $cate['cID'] . "' rowspan='" . $scCount . "'>" . $cate['cName'] . "</td>";
     if ($scCount == 0) {
         echo "<td colspan='2'> --------- This Category is EMPTY --------- </td>";
         echo "</tr>";
     } else {
         echo "<td class='scNameCol'>" . $scData[0]['scName'] . "</td>";
         echo "<td class='actCol danger'><a href='' class='deleteSC' value='" . $scData[0]['scID'] . "'>delete</a></td>";
         echo "</tr>";
         // echo "</section>";
         // echo "</tbody>";
     }
示例#8
0
		    <td class="nobborder"> <?php 
    echo gettext("Subcategory");
    ?>
: </td>
		    <td class="nobborder left">
			<div id="ajaxSubCategory">
				<select name="subcategory">
				<?php 
    if ($plugin->get_subcategory_id() == '') {
        ?>
					<option value='NULL' SELECTED>&nbsp;</option>
				<?php 
    } else {
        // Subcategory
        require_once 'classes/Subcategory.inc';
        $list_subcategories = Subcategory::get_list($conn, 'WHERE cat_id=' . $plugin->get_category_id() . ' ORDER BY name');
        foreach ($list_subcategories as $subcategory) {
            ?>
					<option value='<?php 
            echo $subcategory->get_id();
            ?>
'<?php 
            if ($plugin->get_subcategory_id() == $subcategory->get_id()) {
                echo ' SELECTED';
            }
            ?>
><?php 
            echo str_replace('_', ' ', $subcategory->get_name());
            ?>
</option>
				<?php 
 /**
  * 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 = Subcategory::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 /**
  * @param Subcategory $subcategory
  * @return bool
  */
 public function setSubcategory(Subcategory $subcategory)
 {
     $this->subcategory = $subcategory;
     $this->id_subcategory = $subcategory->getId();
     return true;
 }
示例#11
0
function get_doc_info($conn, $rel)
{
    $name = '';
    $url = '';
    $url_links['host'] = Menu::get_menu_url('/ossim/av_asset/common/views/detail.php?asset_id=KKKK', 'environment', 'assets', 'assets');
    $url_links['net'] = Menu::get_menu_url('/ossim/av_asset/network/view/list.php', 'environment', 'assets', 'networks');
    $url_links['host_group'] = Menu::get_menu_url('/ossim/av_asset/group/view/list.php', 'environment', 'assets', 'asset_groups');
    $url_links['net_group'] = Menu::get_menu_url('/ossim/netgroup/netgroup.php', 'environment', 'assets', 'network_groups');
    $url_links['incident'] = Menu::get_menu_url('/ossim/incidents/incident.php?id=KKKK', 'analysis', 'tickets', 'tickets');
    $url_links['directive'] = Menu::get_menu_url('/ossim/directives/index.php?toggled_dir=KKKK&dir_info=1', 'configuration', 'threat_intelligence', 'directives');
    $url_links['plugin_sid'] = Menu::get_menu_url('/ossim/forensics/base_qry_main.php?clear_allcriteria=1&search=1&sensor=&sip=&plugin=&ossim_risk_a=+&submit=Signature&search_str=KKKK', 'analysis', 'security_events', 'security_events');
    $url_links['taxonomy'] = "";
    $key = $rel['key'];
    switch ($rel['type']) {
        case 'directive':
            $name = $rel['key'];
            break;
        case 'incident':
            $sql = "SELECT title from incident where id=?";
            $params = array($rel['key']);
            $rs = $conn->Execute($sql, $params);
            if (!$rs) {
                $name = _('Unknown');
            } elseif (!$rs->EOF) {
                $name = $rs->fields["title"];
            }
            break;
        case 'plugin_sid':
            $plugin = explode('##', $rel['key']);
            $pid = $plugin[1];
            $sid = $plugin[0];
            if ($pid != '' && $sid != '') {
                $name = Plugin_sid::get_name_by_idsid($conn, $pid, $sid);
                if (!preg_match('/:/', $name)) {
                    $name = Plugin::get_name_by_id($conn, $pid) . ": " . $name;
                }
                $key = $name;
            } else {
                $name = _('Unknown, Please edit this relationship');
                $key = '';
            }
            break;
        case 'host':
        case 'host_group':
        case 'net':
        case 'net_group':
            $field = $rel['type'] == 'host' ? 'hostname' : 'name';
            $sql = "SELECT {$field} as name from " . $rel['type'] . " where id=UNHEX(?)";
            $params = array($rel['key']);
            $rs = $conn->Execute($sql, $params);
            if (!$rs) {
                $name = _('Unknown');
            } elseif (!$rs->EOF) {
                $name = $rs->fields["name"];
            }
            break;
        case 'taxonomy':
            $tax = explode('##', $rel['key']);
            $ptype = intval($tax[0]) != 0 ? Product_type::get_name_by_id($conn, $tax[0]) : _('ANY');
            $cat = intval($tax[1]) != 0 ? Category::get_name_by_id($conn, $tax[1]) : _('ANY');
            $subcat = intval($tax[2]) != 0 ? Subcategory::get_name_by_id($conn, $tax[2]) : _('ANY');
            $name = _('Product Type') . ': ' . $ptype . ', ' . _('Category') . ': ' . $cat . ', ' . _('Subcategory') . ': ' . $subcat;
            break;
        default:
            $name = _('Unknown');
    }
    $url = $url_links[$rel['type']];
    $url = $url != '' ? str_replace('KKKK', $key, $url) : 'javascript:;';
    return array($name, $url);
}
 public function hotsite($id, $url_name)
 {
     $user = User::find($id);
     if ($user->typeuser_id < 5) {
         $subcategories = SubCategory::where('category_id', 1)->get();
     } else {
         $subcategories = Subcategory::where('category_id', 2)->get();
     }
     $advertUser = Advert::where('user_id', $id)->where('status', '>', '0')->orderByRaw("RAND()")->paginate(18);
     $marcas = VeiculoMarca::get();
     $advertAluga = Advert::where('user_id', $id)->where('tipo_anuncio', '=', 'aluga')->where('status', '>', '0')->count();
     $advertVenda = Advert::where('user_id', $id)->where('tipo_anuncio', '=', 'venda')->where('status', '>', '0')->count();
     if (empty($advertUser)) {
         return view('error.error404');
     } else {
         return view('site.pages.hotsite', compact('advertUser', 'user', 'advertAluga', 'advertVenda', 'subcategories', 'marcas'));
     }
 }
示例#13
0
 /**
  *
  * @param $action string
  * @param $subcategoryId int
  * @return nothing
  * @author Tremor
  */
 public function subcategoryAction($action, $subcategoryId = 0)
 {
     if (isset($subcategoryId) && !empty($subcategoryId) && !is_numeric($subcategoryId)) {
         return Redirect::to('admin/subcategory');
     }
     switch ($action) {
         case 'add':
             $subcategory = new Subcategory();
             $subcategory->save();
             $newId = $subcategory->id;
             return Redirect::to('admin/subcategory/' . $newId);
             break;
         case 'edit':
             $post = Input::except('_token');
             $subcategory = Subcategory::find($subcategoryId);
             foreach ($post as $key => $val) {
                 if (isset($subcategory->{$key})) {
                     $subcategory->{$key} = $key == 'alias' ? camel_case($val) : $val;
                 }
             }
             $subcategory->save();
             return Redirect::to('admin/subcategory/' . $subcategoryId);
             break;
         case 'delete':
             $category = Subcategory::find($subcategoryId);
             $category->delete();
             break;
         default:
             break;
     }
     return Redirect::to('admin/subcategory');
 }
示例#14
0
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/
Route::get('invoice/outgoing/print/{num}', function ($num) {
    return $num;
});
Route::get('invoice/incoming/print/{num}', function ($num) {
    return $num;
});
Route::get('hash/{pass?}', function ($pass) {
    return Hash::make('pass');
});
Route::get('subcat/{id}', function ($id) {
    $subcategories = Subcategory::where('category_id', '=', $id)->get();
    return $subcategories;
});
Route::controller('admin', 'AdminController');
Route::controller('titles', 'TitlesController');
Route::controller('users', 'UsersController');
Route::controller('invoice', 'InvoiceController');
Route::controller('categories', 'CategoryController');
Route::controller('subcategories', 'SubcategoryController');
Route::controller('brands', 'BrandsController');
Route::controller('products', 'ProductsController');
示例#15
0
if (isset($_GET['catID']) && isset($_GET['scatID']) && isset($_GET['newName'])) {
    if (!empty($_GET['catID']) && !empty($_GET['scatID']) && !empty($_GET['newName'])) {
        $subcategory = new Subcategory();
        $subcategory->cID = $_GET['catID'];
        $subcategory->scID = $_GET['scatID'];
        $subcategory->scName = $_GET['newName'];
        $subcategory->update();
        $responce = 'done';
    } else {
        $responce = 'all data are required';
    }
}
//-------------------------------- get subcategories of a specific category --------------------------------
if (isset($_GET['selected_cID'])) {
    if (!empty($_GET['selected_cID'])) {
        $subcategory = new Subcategory();
        $responce = $subcategory->getSubcategories($_GET['selected_cID']);
        $responce = json_encode($responce);
    }
}
//-------------------------------------------- draw table ----------------------------------------------
if (isset($_GET['op'])) {
    if (!empty($_GET['op'])) {
        if ($_GET['op'] == 'drawTable') {
            $subcategory = new Subcategory();
            $data = $subcategory->getCorrespondingCat();
            $responce = json_encode($data);
        }
    }
}
echo $responce;
示例#16
0
 public function testPopulate()
 {
     $subCategory = new Subcategory();
     $subCategory->setId(1234);
     $subCategory->setName("Self Service");
     $category = new Category();
     $category->setId(12);
     $category->setName("Restaurantes");
     $category->setSubCategory($subCategory);
     $city = new City();
     $city->setCountry("Brasil");
     $city->setState("SP");
     $city->setName("São Paulo");
     $address = new Address();
     $address->setCity($city);
     $address->setComplement("1 Andar");
     $address->setDistrict("Vila Olímpia");
     $address->setNumber("129");
     $address->setStreet("Rua Funchal");
     $address->setZipcode("04551-069");
     $gasStation = new GasStation(array('price_gas' => 1, 23, 'price_vodka' => 23, 45));
     $placeInfo = new PlaceInfo();
     $placeInfo->setGasStation($gasStation);
     $data = new \stdClass();
     $data->id = 123;
     $data->name = "Chegamos!";
     $data->average_rating = 4;
     $data->review_count = 3;
     $data->category = $category;
     $data->subcategory = $subCategory;
     $data->address = $address;
     $data->point->lat = "-23.529366";
     $data->point->lng = "-47.467117";
     $data->main_url = "http://chegamos.com/";
     $data->other_url = "http://chegamos.com.br/";
     $data->icon_url = "http://chegamos.com/img/icon.png";
     $data->description = "Description";
     $data->created = "01/12/2010 16:19";
     $data->phone = "11 2222-3333";
     $data->extended = $placeInfo;
     $data->num_visitors = 1024;
     $data->num_photos = 5;
     $this->object->populate($data);
     $this->assertEquals(123, $this->object->getId());
     $this->assertEquals("Chegamos!", $this->object->getName());
     $this->assertEquals(4, $this->object->getAverageRating());
     $this->assertEquals("Bom", $this->object->getAverageRatingString());
     $this->assertEquals(3, $this->object->getReviewCount());
     $this->assertEquals("app\\models\\Category", \get_class((object) $this->object->getCategory()));
     $this->assertEquals("Restaurantes - Self Service", (string) $this->object->getCategory());
     $this->assertEquals("app\\models\\Address", \get_class((object) $this->object->getAddress()));
     $this->assertEquals("Rua Funchal, 129 - Vila Olímpia<br/>São Paulo - SP", (string) $this->object->getAddress());
     $this->assertEquals("-23.529366,-47.467117", (string) $this->object->getPoint());
     $this->assertEquals("http://chegamos.com/", $this->object->getMainUrl());
     $this->assertEquals("http://chegamos.com.br/", $this->object->getOtherUrl());
     $this->assertEquals("http://chegamos.com/img/icon.png", $this->object->getIconUrl());
     $this->assertEquals("Description", $this->object->getDescription());
     $this->assertEquals("01/12/2010 16:19", $this->object->getCreated());
     $this->assertEquals("11 2222-3333", $this->object->getPhone());
     $this->assertEquals("app\\models\\PlaceInfo", \get_class((object) $this->object->getPlaceInfo()));
     $this->assertEquals(1024, $this->object->getNumVisitors());
     $this->assertEquals(5, $this->object->getNumPhotos());
 }
 /**
  * @param Subcategory $subcategory
  * @param $name
  * @param $descr
  * @param $short_descr
  * @param $price
  * @param $stock
  * @return array
  * @throws Exception
  */
 public function create(Subcategory $subcategory, $name, $descr, $short_descr, $price, $stock)
 {
     $errors = array();
     $item = new Item($this->db);
     try {
         $item->setName($name);
         $item->setDescription($descr);
         $item->setShortDescription($short_descr);
         $item->setPrice($price);
         $item->setStock($stock);
     } catch (Exception $e) {
         $errors[] = $e->getMessage();
     }
     if (count($errors) == 0) {
         $name = $this->db->quote($item->getName());
         $description = $this->db->quote($item->getDescription());
         $shortDescription = $this->db->quote($item->getShortDescription());
         $price = $this->db->quote($item->getPrice());
         $stock = $this->db->quote($item->getStock());
         $query = "  INSERT INTO item(id_subcategory, name, descr, short_descr, price, stock)\n                               VALUES(" . $subcategory->getId() . ", " . $name . ", " . $description . ", " . $shortDescription . ", " . $price . ", " . $stock . ")";
         $data = $this->db->exec($query);
         if ($data) {
             $id = $this->db->lastInsertId();
             if ($id) {
                 try {
                     return $this->findById($id);
                 } catch (Exception $e) {
                     $errors[] = $e->getMessage();
                     return $errors;
                 }
             } else {
                 throw new Exception('Last insert error');
             }
         } else {
             throw new Exception('Db error');
         }
     } else {
         return $errors;
     }
 }
示例#18
0
           <span class="current">subcategory</span>   
        </div>

        <div class="left_content">
          <?php 
include 'categoriesBox.php';
include 'login.php';
include 'specialProductsBox.php';
?>
        </div><!-- end of left content -->
      
        <div class="center_content">
          <div class="center_title_bar">Search result</div>
          <?php 
include "../../classes/subcategory.php";
$subcat = new Subcategory();
$id = $_GET['id'];
$data = $subcat->getSubcategories($id);
if (empty($data)) {
    echo "<h2 style='margin-top:70px;margin-left:200px;'> No result to show </h2>";
}
foreach ($data as $key => $row) {
    foreach ($row as $key => $value) {
        $name = $row["scName"];
        $id = $row["scID"];
    }
    echo "<div class='container' style='font-size:15px; width:500px;'>";
    echo "<table class='table table-hover'>";
    echo "<tr>";
    //echo "<th>";
    echo "<th> <a href='showprod.php?id={$id}'> {$name} </a></th>";
示例#19
0
    echo _("Select a category");
    ?>
 -- </option>
	</select>
	<?php 
    exit;
}
$db = new ossim_db();
$conn = $db->connect();
?>

<select class='vfield' name="subcategory" id="subcategory">
	<?php 
// Subcategory
require_once 'classes/Subcategory.inc';
$list_subcategories = Subcategory::get_list($conn, 'WHERE cat_id=' . $category_id . ' ORDER BY name');
foreach ($list_subcategories as $subcategory) {
    $selected = $category_id == $subcategory->get_id() ? ' selected="selected"' : '';
    ?>
		<option value='<?php 
    echo $subcategory->get_id();
    ?>
'<?php 
    echo $selected;
    ?>
><?php 
    echo str_replace('_', ' ', $subcategory->get_name());
    ?>
</option>
		<?php 
}
 public function getRemove($id)
 {
     $subcategory = Subcategory::find($id);
     $subcategory->delete();
     return Redirect::back()->with('success', 'Subcategory deleted successfully.');
 }