<?php
	// We check in which language we will work
	if (isset($_SESSION["DATAGLOBAL"][0]) && !empty($_SESSION["DATAGLOBAL"][0])) $C->LANGUAGE = $_SESSION["DATAGLOBAL"][0];

	$this->load_langfile('inside/dashboard.php');
	
	// We are here only if you're logged in
	if (!$this->user->is_logged) {
		echo('0: '.$this->lang('dashboard_no_session'));
		die();
	}
	
	$errored = 0;
	$txterror = '';

	$idcat = $idsubcat = 0;

	if (isset($_POST["idcat"]) && $_POST["idcat"] != '') $idcat = $this->db1->e($_POST["idcat"]);
	if (isset($_POST["idsubcat"]) && $_POST["idsubcat"] != '') $idsubcat = $this->db1->e($_POST["idsubcat"]);

	$r = $this->db1->query("SELECT idcategory, name FROM pages_cat WHERE idfather=".$idcat." ORDER BY name ASC");
	$txtsubcats='<option value="-1" select>'.$this->lang('dashboard_pages_txt_choosesubcategory').'</option>';
	
	while ($row=$this->db1->fetch_object($r)) {
		if ($row->idcategory == $idsubcat) $txtsubcats .= '<option value="'.$row->idcategory.'" selected="selected">'.$row->name.'</option>';
		else $txtsubcats .= '<option value="'.$row->idcategory.'">'.$row->name.'</option>';
	}
	echo("1: ".$txtsubcats);
?>