コード例 #1
0
 static function GetRecordById($id)
 {
     if (!self::$filter) {
         self::$filter = new CFilter($id, 0, 0, 0, 0, 0, 0, 0);
     }
     self::LoadData();
     $i = 0;
     while ($i < self::$count) {
         $record = self::$data[$i];
         if ($record->GetId() == $id) {
             return $record;
         }
         $i++;
     }
     return null;
 }
コード例 #2
0
ファイル: IDetail.php プロジェクト: NguyenThanhDung/Finance
function submit_delete_record($id)
{
    return CRecordManager::DeleteRecord($id);
}
コード例 #3
0
function show_edit_detail_form($id)
{
    $record = CRecordManager::GetRecordById($id);
    if ($record) {
        show_detail_form("edit", $record);
    } else {
        echo "<p>Error: Can't get detail that has id = {$id}</p>";
    }
}
コード例 #4
0
ファイル: install.php プロジェクト: NguyenThanhDung/Finance
} 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/>";
}
echo "</p>";
echo "<p>Finish.</p>";
?>

</body>
コード例 #5
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;
}