Пример #1
0
function submit_add_category($name, $receipt, $description)
{
    $category = new CCategory(0, $name, $receipt, $description);
    return CCategoryManager::AddCategory($category);
}
Пример #2
0
function import_category($filename)
{
    if (!isset($filename)) {
        header('Location: xls_importer.php');
    }
    $file = fopen($filename, "r") or exit("Unable to open file " . $filename);
    $categories = array();
    $count = 0;
    while (!feof($file)) {
        $line = fgets($file);
        $cells = parse_line_to_array($line);
        if ($cells) {
            $i = 0;
            while ($i < $count) {
                if ($cells[1] == $categories[$i]) {
                    break;
                }
                $i++;
            }
            if ($i == $count) {
                $categories[$count] = $cells[1];
                $count++;
            }
        }
    }
    fclose($file);
    echo "count = " . $count . "<br/>";
    for ($i = 0; $i < $count; $i++) {
        $category = new CCategory(0, $categories[$i], 0, null);
        CCategoryManager::AddCategory($category);
        echo $i + 1 . ". " . $categories[$i] . "<br/>";
    }
}