Exemplo n.º 1
0
function show_edit_record_form($id)
{
    $categories = CCategoryManager::GetAllCategories();
    $record = CRecordManager::GetRecordById($id);
    if ($record) {
        $editRecordForm = new EditRecordForm("image/edit_btn.png", "Edit Record", "editting_record.php", "Save", $categories, $record);
        $editRecordForm->Show();
        return 1;
    } else {
        return 0;
    }
}
Exemplo n.º 2
0
 static function LoadData()
 {
     self::$data = 0;
     self::$count = 0;
     $sql = "SELECT * FROM category ORDER BY Name";
     $categories = CDataManager::ExercuseQuery($sql);
     // Fetch data
     while ($row = mysql_fetch_array($categories)) {
         if (!self::$data) {
             self::$data = array();
         }
         self::$data[self::$count] = new CCategory($row['Id'], $row['Name'], $row['Receipt'], $row['Description']);
         self::$count++;
     }
 }
Exemplo n.º 3
0
function show_filter_form()
{
    DLOG("show_filter_form()");
    $filters = isset($_SESSION['filters']) ? $_SESSION['filters'] : null;
    ?>
<h4>Filter</h4>
<form action="detail.php" method="post">
<input type="hidden" name="action_type" value="filter"/>
<table width="600" border="0" cellspacing="0">
	<!-- CATEGORY -->
	<tr>		
		<td>
			<input type="checkbox" name="enable_filter[]" value="category"
				<?php 
    if (isset($filters['categories'])) {
        echo "checked='checked'";
    }
    ?>
			>Category</input>
		</td>
		<td>
			<?php 
    $categories = CCategoryManager::GetAllCategories();
    foreach ($categories as $category) {
        echo "<input type='checkbox' name='category_filter[]' ";
        echo "value='" . $category->GetId() . "' ";
        if (isset($filters['categories'])) {
            foreach ($filters['categories'] as $cate_filter) {
                if ($category->GetId() == $cate_filter) {
                    echo "checked='checked'";
                    break;
                }
            }
        }
        echo "/>" . $category->GetName() . " ";
    }
    ?>
		</td>
	</tr>
	
	<!-- DETAIL -->
	<tr>
		<td width="130">
			<input type="checkbox" name="enable_filter[]" value="detail"
				<?php 
    if (isset($filters['detail'])) {
        echo "checked='checked'";
    }
    ?>
			>Detail</input>
		</td>
		<td>
			<input type="text" name="detail_text"
				<?php 
    if (isset($filters['detail'])) {
        echo "value='" . $filters['detail'] . "'";
    }
    ?>
			/>
		</td>
	</tr>
	
	<!-- FROM DATE -->
	<tr>
		<td>
			<input type="checkbox" name="enable_filter[]" value="from_date"
				<?php 
    if (isset($filters['from_date'])) {
        echo "checked='checked'";
    }
    ?>
			>From date</input>
		</td>
		<td>
			<?php 
    if (isset($filters['from_date'])) {
        showTimeBox("filter_detail_from_date", $filters['from_date']);
    } else {
        showTimeBox("filter_detail_from_date", 0);
    }
    ?>
		</td>
	</tr>	
	
	<!-- TO DATE -->
	<tr>
		<td>
			<input type="checkbox" name="enable_filter[]" value="to_date"
				<?php 
    if (isset($filters['to_date'])) {
        echo "checked='checked'";
    }
    ?>
			>To date</input>
		</td>
		<td>
			<?php 
    if (isset($filters['to_date'])) {
        showTimeBox("filter_detail_to_date", $filters['to_date']);
    } else {
        showTimeBox("filter_detail_to_date", 0);
    }
    ?>
		</td>
	</tr>
	
	<!-- FROM AMOUNT -->
	<tr>
		<td>
			<input type="checkbox" name="enable_filter[]" value="from_amount"
				<?php 
    if (isset($filters['from_amount'])) {
        echo "checked='checked'";
    }
    ?>
			>From amount</input>
		</td>
		<td>
			<input type="text" name="amount_from_filter"
				<?php 
    if (isset($filters['from_amount'])) {
        echo "value='" . $filters['from_amount'] . "'";
    }
    ?>
			/>
		</td>
	</tr>
	
	<!-- TO AMOUNT -->
	<tr>
		<td>
			<input type="checkbox" name="enable_filter[]" value="to_amount"
				<?php 
    if (isset($filters['to_amount'])) {
        echo "checked='checked'";
    }
    ?>
			>To amount</input>
		</td>
		<td>
			<input type="text" name="amount_to_filter"
				<?php 
    if (isset($filters['to_amount'])) {
        echo "value='" . $filters['to_amount'] . "'";
    }
    ?>
			/>
		</td>
	</tr>
	
	<!-- DESCRIPTION -->
	<tr>
		<td>
			<input type="checkbox" name="enable_filter[]" value="description"
				<?php 
    if (isset($filters['description'])) {
        echo "checked='checked'";
    }
    ?>
			>Description</input>
		</td>
		<td>
			<input type="text" name="desc_text"
				<?php 
    if (isset($filters['description'])) {
        echo "value='" . $filters['description'] . "'";
    }
    ?>
			/>
		</td>
	</tr>
	<tr>
		<td>&nbsp;</td>
		<td>
			<input type="submit" value="Filter" />
		</td>
	</tr>
</table>
</form>
<?php 
}
Exemplo n.º 4
0
 function GetCategory()
 {
     return CCategoryManager::GetCategoryById($this->category_id);
 }
Exemplo n.º 5
0
    echo "Error has occured while drop table Record</p>";
}
// Drop Setting table
echo "<p>Drop table Setting if exist<br/>";
if (CSettingManager::DropTable()) {
    echo "Table Setting is droped</p>";
} else {
    echo "Error has occured while drop table Setting</p>";
}
//*********************
// CREATE TABLE
//*********************
echo "<p>Creating table...</p>";
echo "<p>";
// Create Category table
if (CCategoryManager::CreateTable()) {
    echo "Created <b>Category</b> table<br/>";
} else {
    echo "Error has occured while create table Category<br/>";
}
// Create Detail table
if (CRecordManager::CreateTable()) {
    echo "Created <b>Record</b> table<br/>";
} else {
    echo "Error has occured while create table Record<br/>";
}
// Create Setting table
if (CSettingManager::CreateTable()) {
    echo "Created <b>Setting</b> table<br/>";
} else {
    echo "Error has occured while create table Setting<br/>";
Exemplo n.º 6
0
function submit_delete_category($id)
{
    return CCategoryManager::DeleteCategory($id);
}
Exemplo n.º 7
0
function import_record($filename, $added_row_count, $last_time, $duplicated_time_count)
{
    if (!isset($filename)) {
        header('Location: xls_importer.php');
    }
    $file = fopen($filename, "r") or exit("Unable to open file " . $filename);
    echo "<table border='1' cellspacing='0'>";
    $count = 0;
    while (!feof($file)) {
        $line = fgets($file);
        $count++;
        if ($count <= $added_row_count) {
            continue;
        }
        if ($count - $added_row_count > 200) {
            $count--;
            break;
        }
        echo "<tr>";
        $cells = parse_line_to_array($line);
        if ($cells) {
            $category = CCategoryManager::GetCategoryByName($cells[1]);
            $category_id = $category->GetId();
            $detail = $cells[3];
            $time = $cells[0];
            if ($time == $last_time) {
                $duplicated_time_count++;
                $time += $duplicated_time_count * 60 * 60;
            } else {
                $last_time = $time;
                $duplicated_time_count = 0;
            }
            $amount = $cells[2];
            $record = new CRecord(0, $category_id, $detail, $time, $amount, null);
            CRecordManager::AddRecord($record);
            echo "<td>{$category_id}</td>";
            echo "<td>" . $category->GetName() . "</td>";
            echo "<td>{$detail}&nbsp;</td>";
            echo "<td>" . date("d-m-Y H:i:s", $time) . "</td>";
            echo "<td>{$amount}</td>";
        }
        echo "</tr>";
    }
    fclose($file);
    echo "</table>";
    $result = array();
    $result[0] = $count;
    $result[1] = $last_time;
    $result[2] = $duplicated_time_count;
    return $result;
}