Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Štvrtok, 28. marec 2024

Súbor: [Platon] / web-apps / task-manager / modules / Customer.php (stiahnutie)

Revízia 1.1, Thu Aug 19 09:11:49 2004 UTC (19 years, 7 months ago) by nepto

Task Manager added into repository.
It was a test project made for NUSTEP -- http://www.nustep.net/

<?php

/*
 * lib/Customer.php
 *
 * Developed by Ondrej Jombik <nepto@platon.sk>
 * Copyright (c) 2004 Platon SDG, http://platon.sk/
 * Licensed under terms of GNU General Public License.
 * All rights reserved.
 *
 * Changelog:
 * 2004-06-20 - created
 *
 */

/* $Platon$ */

require_once 'DB.php';

class Customer
{
    function getList() /* {{{ */
    {
        global $cfg, $dbh;
        $query = sprintf('SELECT * FROM %s', $cfg['tables']['customers']);
        return $dbh->getAll($query);
    } /* }}} */

    function getListExtended() /* {{{ */
    {
        global $cfg, $dbh;
        $ret_ar = Customer::getList();
        $query_total = sprintf('SELECT customer_id, COUNT(*)'
                .' FROM %s GROUP BY customer_id', $cfg['tables']['projects']);
        $query_opened = sprintf('SELECT customer_id, COUNT(*)'
                .' FROM %s WHERE state != "done" AND state != "abandoned"'
                .' GROUP BY customer_id', $cfg['tables']['projects']);
        $counts_total       = $dbh->getAssoc($query_total,  false, array(), DB_FETCHMODE_ORDERED);
        $counts_opened      = $dbh->getAssoc($query_opened, false, array(), DB_FETCHMODE_ORDERED);
        $counts_total_keys  = array_keys($counts_total);
        $counts_opened_keys = array_keys($counts_opened);
        foreach ($ret_ar as $key => $val) {
            if (in_array($val['id'], $counts_total_keys)) {
                $ret_ar[$key]['projects_total'] = $counts_total[$val['id']];
            } else {
                $ret_ar[$key]['projects_total'] = 0;
            }
            if (in_array($val['id'], $counts_opened_keys)) {
                $ret_ar[$key]['projects_opened'] = $counts_opened[$val['id']];
            } else {
                $ret_ar[$key]['projects_opened'] = 0;
            }
        }
        return $ret_ar;
    } /* }}} */
}

/* Modeline for ViM {{{
 * vim: set ts=4:
 * vim600: fdm=marker fdl=0 fdc=0:
 * }}} */

?>

Platon Group <platon@platon.sk> http://platon.sk/
Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok