phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] old/ccs/inc hook_admin.inc.php, 1.1 functions.php, 1


From: skwashd
Subject: [Phpgroupware-cvs] old/ccs/inc hook_admin.inc.php, 1.1 functions.php, 1.1 ccsDb.php, 1.1 class.boActions.inc.php, 1.1 class.boPersonnel.inc.php, 1.1 class.boDepartments.inc.php, 1.1 class.boCCS.inc.php, 1.1 class.boStatuses.inc.php, 1.1 class.boTimecards.inc.php, 1.1 class.htmlStatuses.inc.php, 1.1 class.htmlPersonnel.inc.php, 1.1 class.htmlDepartments.inc.php, 1.1 class.htmlTimeCardForm.inc.php, 1.1 class.htmlTimeCards.inc.php, 1.1 functions.inc.php, 1.1 dcl_vars.php, 1.1 datefunctions.php, 1.1 class.htmlCCSForm.inc.php, 1.1 class.htmlCCSDetail.inc.php, 1.1 class.dbDepartments.inc.php, 1.1 class.dbCCS.inc.php, 1.1 class.dbActions.inc.php, 1.1 class.dbPersonnel.inc.php, 1.1 class.dbStatuses.inc.php, 1.1 class.htmlActions.inc.php, 1.1 class.dbTimeCards.inc.php, 1.1 class.htmlCCS.inc.php, 1.1
Date: Thu, 5 May 2005 02:56:00 +0200

Update of old/ccs/inc

Added Files:
     Branch: MAIN
            hook_admin.inc.php 
            functions.php 
            ccsDb.php 
            class.boActions.inc.php 
            class.boPersonnel.inc.php 
            class.boDepartments.inc.php 
            class.boCCS.inc.php 
            class.boStatuses.inc.php 
            class.boTimecards.inc.php 
            class.htmlStatuses.inc.php 
            class.htmlPersonnel.inc.php 
            class.htmlDepartments.inc.php 
            class.htmlTimeCardForm.inc.php 
            class.htmlTimeCards.inc.php 
            functions.inc.php 
            dcl_vars.php 
            datefunctions.php 
            class.htmlCCSForm.inc.php 
            class.htmlCCSDetail.inc.php 
            class.dbDepartments.inc.php 
            class.dbCCS.inc.php 
            class.dbActions.inc.php 
            class.dbPersonnel.inc.php 
            class.dbStatuses.inc.php 
            class.htmlActions.inc.php 
            class.dbTimeCards.inc.php 
            class.htmlCCS.inc.php 

Log Message:
cvs clean up

====================================================
Index: hook_admin.inc.php
<?php
        
/**************************************************************************\
        * phpGroupWare - skel                                                   
   *
        * http://www.phpgroupware.org                                           
   *
        * -----------------------------------------------                       
   *
        *  This program is free software; you can redistribute it and/or modify 
it *
        *  under the terms of the GNU General Public License as published by 
the   *
        *  Free Software Foundation; either version 2 of the License, or (at 
your  *
        *  option) any later version.                                           
   *
        
\**************************************************************************/
        /* $Id: hook_admin.inc.php,v 1.1 2005/05/05 00:56:39 skwashd Exp $ */

// Only Modify the $file and $title variables.....
        $file = Array
        (
                        'Personnel'             => 
$GLOBALS['phpgw']->link('/ccs/personnel.php'),
                        'Departments'   => 
$GLOBALS['phpgw']->link('/ccs/departments.php'),
        );
        $GLOBALS['phpgw']->common->display_mainscreen($appname,$file);
?>

====================================================
Index: functions.php
<?php

// from html common in dcl http://dcl.sf.net Thanks Mike

function GetHiddenVar($var, $val)
{
        return '<input type="hidden" name="' . $var . '" value="' . $val . '">';
}

function GetJSDateFormat()
{
        global $dcl_info;

        $calDateFormat = str_replace('m', 'MM', $dcl_info['DCL_DATE_FORMAT']);
        $calDateFormat = str_replace('d', 'DD', $calDateFormat);
        return str_replace('Y', 'yyyy', $calDateFormat);
}

function BeginChocoTable($lightColor = true, $width = '100%', $cellSpacing = 0, 
$printable = false)
{
        global $dcl_info;

        if ($printable)
        {
                $lc = '#ffffff';
                $dc = '#000000';
        }
        else
        {
                $lc = $dcl_info['DCL_COLOR_LIGHT'];
                $dc = $dcl_info['DCL_COLOR_DARK'];
        }
        if ($lightColor == true)
                $bgColor = $lc;
        else
                $bgColor = $dc;

        print("<table border=\"0\" bgcolor=\"$bgColor\" ");
        if ($width != 0)
                print("width=\"$width\" ");
        print("cellspacing=\"$cellSpacing\" cellpadding=\"2\">");
}

function EndTable()
{
        print('</table>');
}

function PrintLink($linkName, $rollover, $linkURL, $dark = false, $printable = 
false)
{
        $class = $dark == false ? 'alight' : 'adark';
        print("<a class=\"$class\" href=\"$linkURL\" title=\"$rollover\">" );
        print($linkName) ;
        print('</a>&nbsp;');
}

function PrintLinkSet($linkArray, $rolloverArray, $enclose = true, $dark = 
false, $printable = false)
{
        print(GetLinkSet($linkArray, $rolloverArray, $enclose, $dark, 
$printable));
}

function GetLink($linkName, $rollover, $linkURL, $dark = false, $printable = 
false)
{
        $class = $dark == false ? 'alight' : 'adark';
        $link = "<a class=\"$class\" href=\"$linkURL\" title=\"$rollover\">";
        $link .= $linkName;
        $link .= '</a>&nbsp;';

        return $link;
}

function GetLinkSet($linkArray, $rolloverArray, $enclose = true, $dark = false, 
$printable = false)
{
        global $dcl_info;

        if (!is_array($linkArray) || !is_array($rolloverArray) || 
count($linkArray) < 1)
        {
                        // Output _something_ in case we need to allow a TD or 
TH to background
                        // fill properly.
                return '&nbsp';
        }

        $linkset = '';
        if ($enclose)
                $linkset .= '<font color="' . $dcl_info['DCL_COLOR_LIGHT'] . 
'">[</font>&nbsp;';

        while (list($linkName, $linkURL) = each($linkArray))
                $linkset .= GetLink($linkName, $rolloverArray[$linkName], 
$linkURL, $dark, $printable);

        if ($enclose)
                $linkset .= '<font color="' . $dcl_info['DCL_COLOR_LIGHT'] . 
'">]</font>';

        return $linkset;
}

function BeginChocoFont($dark = false, $printable = false)
{
        global $dcl_info;

        if ($printable)
        {
                $lc = '#ffffff';
                $dc = '#000000';
        }
        else
        {
                $lc = $dcl_info['DCL_COLOR_LIGHT'];
                $dc = $dcl_info['DCL_COLOR_DARK'];
        }
        if ($dark == true)
                $fontColor = $dc;
        else
                $fontColor = $lc;

        print("<font color=\"$fontColor\">");
}

function EndFont()
{
        print('</font>');
}

function PrintWithChocoFont($thisString, $printable = false)
{
        print("<span class=\"highlight\">$thisString</span>");
}

function PrintArrayAsChocoTable($nameArray, $fieldArray, $title, $footer = '', 
$titleLinks = '', $printable=false)
{
        if (count($nameArray) < 1 || count($fieldArray) < 1 || 
!is_array($nameArray) || !is_array($fieldArray))
        {
                print('<center>');
                PrintWithChocoFont("STR_CMMN_ARRAYTABLEERR");
                printf("STR_CMMN_ARRAYTABLEERRHELP", $title);
                print('</center>');
                return;
        }
        print('<center>');
        BeginChocoTable(false, 0);
        print('<tr><th');
        if ($titleLinks != '')
                print(' align="left"');
        print('>');
        BeginChocoFont();
        print($title);
        if ($titleLinks != '')
                print('</th><th align="right">' . $titleLinks);
        EndFont();
        print('</th></tr><tr><td');
        if ($titleLinks != '')
                print(' colspan="2"');
        print('>');
        BeginChocoTable(false, '100%', 2);

        print('<tr>');
        for ($i = 0; $i < count($nameArray); $i++)
                PrintTH($nameArray[$i], true, $printable);
        print('</tr>');

        for ($i = 0; $i < count($fieldArray); $i++)
        {
                print('<tr>');
                for ($j = 0; $j < count($fieldArray[$i]); $j++)
                {
                        $k = $fieldArray[$i][$j];
                        $align = '';
                // Right justify all numbers (looks really swell)
                        if (is_double($k) || is_long($k))
                                $align = 'right';
                        PrintTD($k, true, $align, $printable);
                }
                print('</tr>');
        }
        EndTable();
        print('</td></tr>');
        if ($footer != '')
        {
                print('<tr><th>');
                BeginChocoFont();
                print($footer);
                EndFont();
                print('</th></tr>');
        }
        EndTable();
        print('</center>');
}

function PrintTH($thisString, $choco = false, $printable = false)
{
        global $dcl_info;

        if ($printable)
        {
                $lc = '#ffffff';
                $dc = '#000000';
        }
        else
        {
                $lc = $dcl_info['DCL_COLOR_LIGHT'];
                $dc = $dcl_info['DCL_COLOR_DARK'];
        }

        print('<th');
        if ($choco)
                print(" bgcolor=\"$lc\"");
        print('>');
        if ($choco)
                print("<font color=\"$dc\">");
        if (trim($thisString) == '')
                print('&nbsp;');
        else
                print($thisString);
        if ($choco)
                EndFont();
        print('</th>');
}

function PrintTD($thisString, $choco = false, $align = '', $printable = false)
{
        global $dcl_info;

        if ($printable)
        {
                $lc = '#ffffff';
                $dc = '#000000';
        }
        else
        {
                $lc = $dcl_info['DCL_COLOR_LIGHT'];
                $dc = $dcl_info['DCL_COLOR_DARK'];
        }

        print('<td');
        if ($choco)
                print(" bgcolor=\"$lc\"");
        if ($align != '')
                print(' align="' . $align . '"');
        print('>');
        if (trim($thisString) == '')
                print('&nbsp;');
        else
                print($thisString);
        print('</td>');
}

function FormatPhone($phone)
{
        $retVal = trim($phone);
        if (strlen($retVal) == 7)
        {
                $retVal = substr($phone, 0, 3) . '-' . substr($phone, 3);
        }
        if (strlen($retVal) == 10)
        {
                $retVal = '(' . substr($phone, 0, 3) . ') ' . substr($phone, 3, 
3) . '-' . substr($phone, 6);
        }

        return $retVal;
}

function GetCalendarLink($linkTo)
{
        $link = '<a href="javascript:doNothing()" ';
        $link .= 'onclick="setDateField(' . $linkTo . '); ';
        $link .= 'top.newWin = 
window.open(\'calendar.html\',\'cal\',\'dependent=yes,width=210,height=230,screenX=200,screenY=300,titlebar=yes\')">';
        $link .= '<img src="img/calendar.gif" border="0"></a>';

        return $link;
}

function CreateCalendarLink($linkTo)
{
        print(GetCalendarLink($linkTo));
}

function ShowDeleteYesNo($title, $action, $id, $name, $canBeDeactivated = true, 
$idfield = 'id')
{
        global $dcl_info;

        print('<center>');
        BeginChocoTable(false, 0);
        print('<tr><th>');
        BeginChocoFont();
        printf("STR_CMMN_DELETEITEM", $title);
        EndFont();
        print('</th></tr><tr><td>');
        BeginChocoTable();
        print('<tr><td bgcolor="' . $dcl_info['DCL_COLOR_LIGHT'] . '">');
        print('<form method="post" action="index.php">');
        print("<input type=\"hidden\" name=\"menuAction\" value=\"$action\">");
        print("<input type=\"hidden\" name=\"$idfield\" value=\"$id\">");
        printf("STR_CMMN_DELETECONFIRM", $title, $name);
        if ($canBeDeactivated)
                print('<br>' . "STR_CMMN_DEACTIVATENOTE");
        print('<br></td></tr><tr><td align="center" bgcolor="' . 
$dcl_info['DCL_COLOR_LIGHT'] . '">');
        printf('<input type="submit" value="%s">', "STR_CMMN_YES");
        printf('<input type="button" value="%s" onclick="history.back();">', 
"STR_CMMN_NO");
        print('</form>');
        print('</td></tr>');
        EndTable();
        print('</td></tr>');
        EndTable();
        print('</center>');
}

function GetYesNoCombo($default = 'Y', $cbName = 'active', $size = 0, 
$noneOption = true)
{
        $str = "<select name=\"$cbName";
        if ($size > 0)
                $str .= '[]" multiple size=' . $size;
        else
                $str .= '"';
        $str .= '>';
        if ($size == 0 && $noneOption == true)
                $str .= sprintf('<option value="?">%s', "STR_CMMN_SELECTONE");

        $str .= '<option value="Y"';
        if ('Y' == $default)
                $str .= ' selected';
        $str .= sprintf('>%s</option>', "STR_CMMN_YES");

        $str .= '<option value="N"';
        if ('N' == $default)
                $str .= ' selected';
        $str .= sprintf('>%s</option>', "STR_CMMN_NO");

        $str .= '</select>';

        return $str;
}

function CreateYesNoCombo($default = 'Y', $cbName = 'active', $size = 0, 
$noneOption = true)
{
        print GetYesNoCombo($default, $cbName, $size, $noneOption);
}


?>

====================================================
Index: ccsDb.php
<?php
include('inc/datefunctions.php');
class ccsDb
{
        var $fieldArray;
        var $objTimestamp;
        var $objDate;
        var $emptyTimestamp;
        var $res;

        function ccsDb()
        {

                $this->objTimestamp = new Timestamp;
                $this->objDate = new Date;
                $this->res = 0;

                $this->emptyTimestamp = 'null';
        }

                // function stolen shamelessly from DCL
        function InitFromGlobals()
        {
                reset($this->fieldArray);
                while (list($key, $field) = each($this->fieldArray))
                {
                        if (IsSet($GLOBALS[$field]))
                        {
                                $this->$field = 
$this->GPCStripSlashes($GLOBALS[$field]);
                        }
                }
        }
                // function stolen shamelessly from DCL
        function GPCStripSlashes($thisString)
        {
                if (get_magic_quotes_gpc() == 0)
                        return $thisString;

                return stripslashes($thisString);
        }

                // function stolen shamelessly from DCL
        function DBAddSlashes($thisString)
        {
                if (!IsSet($thisString) || $thisString == '')
                        return '';

                return addslashes($thisString);
        }


        function DisplayToSQL($thisDate)
        {
                global $dcl_info;

                $eregStr = str_replace('m', '([0-9]{2})', 
$dcl_info['DCL_DATE_FORMAT']);
                $eregStr = str_replace('d', '([0-9]{2})', $eregStr);
                $eregStr = str_replace('Y', '([0-9]{4})', $eregStr);
                if(ereg('^' . $eregStr . ' ([0-9]{2}).([0-9]{2}).([0-9]{2})$', 
$thisDate))
                        return "'" . 
$this->ArrangeTimeStampForInsert($thisDate) . "'";
                else
                        return "'" . $this->ArrangeDateForInsert($thisDate) . 
"'";
        }

        function ArrangeDateForInsert($thisDate)
        {
                $this->objDate->SetFromDisplay($thisDate);
                return $this->objDate->ToDB();
        }

        function ArrangeTimeStampForInsert($thisStamp)
        {
                global $dcl_domain_info, $dcl_domain;

                /* if ($dcl_domain_info[$dcl_domain]['dbVersionMjr'] < 7)
                        return $thisStamp; */

                $this->objTimestamp->SetFromDisplay($thisStamp);
                return $this->objTimestamp->ToDB();
        }

        function FormatDateForDisplay($thisDate)
        {
                if ($thisDate == '')
                        return '';

                $this->objDate->SetFromDB($thisDate);
                return $this->objDate->ToDisplay();
        }

        function FormatTimeStampForDisplay($thisStamp)
        {
                global $dcl_domain_info, $dcl_domain;

                if ($thisStamp == '')
                        return '';

                /*      if ($dcl_domain_info[$dcl_domain]['dbVersionMjr'] < 7)
                        return $thisStamp; */

                $this->objTimestamp->SetFromDB($thisStamp);
                return $this->objTimestamp->ToDisplay();
        }

        function GetDateSQL()
        {
            // From Urmet Janes for MSSQL support
                return 'now()';
        }

        function FetchAllRows()
        {
                if ($this->db->num_rows() > 0 && $this->db->num_fields() > 0)
                {
                        $retVal = array();
                        for ($i = 0; $i < $this->db->num_rows(); $i++)
                        {
                                for ($j = 0; $j < $this->db->num_fields(); $j++)
                                {
                        // Explicitly set array to use integer indexing and
                        // don't trust the cursor member.  We just want to
                        // return an array.
                                        $retVal[$i][$j] = 
pg_Result($this->db->Query_ID,  $i, $j);
                        // Attempt to set the correct type if this field not a 
string
                                        if 
(!pg_FieldIsNULL($this->db->Query_ID, $i, $j))
                                        {
                                                
switch(pg_FieldType($this->db->Query_ID, $j))
                                                {
                                                        case 'int4':
                                                                {
                                                                        
settype($retVal[$i][$j], 'integer');
                                                                }
                                                                break;
                                                        case 'float':
                                                        case 'float8':
                                                                {
                                                                        
settype($retVal[$i][$j], 'double');
                                                                }
                                                                break;
                                                }
                                        }
                                }
                        }
                        return $retVal;
                }
                else
                        return NULL;
        }

}
?>

====================================================
Index: class.boActions.inc.php
<?php
/*
 * $Id: class.boActions.inc.php,v 1.1 2005/05/05 00:56:39 skwashd Exp $
 *
 * Double Choco Latte - Source Configuration Management System
 * Copyright (C) 1999  Michael L. Dean & Tim R. Norman
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * Select License Info from the Help menu to view the terms and conditions of 
this license.
 */



class boActions
{
        function showall()
        {

                $obj = CreateObject('ccs.htmlActions');
                $obj->PrintAll();
        }

        function add()
        {

                $obj = CreateObject('ccs.htmlActions');
                $obj->ShowEntryForm();
                print('<p>');
                $obj->PrintAll();
        }

        function dbadd()
        {
                $obj = CreateObject('ccs.dbActions');
                $obj->Connect();
                $obj->InitFromGlobals();
                $obj->Add();

                $objHTML = CreateObject('ccs.htmlActions');
                $objHTML->PrintAll();
        }

        function modify()
        {

                $obj = CreateObject('ccs.dbActions');
                $obj->Load($GLOBALS['id']);

                $objHTML = CreateObject('ccs.htmlActions');
                $objHTML->ShowEntryForm($obj);
        }

        function dbmodify()
        {

                $obj = CreateObject('ccs.dbActions');
                $obj->InitFromGlobals();
                $obj->Edit();
                $objHTML = CreateObject('ccs.htmlActions');
                $objHTML->PrintAll();
        }

        function delete()
        {
                $obj = CreateObject('ccs.dbActions');
                $obj->Load($GLOBALS['id']);
                ShowDeleteYesNo('Action', 'ccs.boActions.dbdelete', $obj->id, 
$obj->name);
        }

        function dbdelete()
        {
                $classSubName = 'Actions';

                commonHeader();
                $obj = CreateObject('db' . $classSubName);
                $obj->connect();
                $obj->Load($GLOBALS['id']);

                $objKey = new dclDB; // Don't really need anything fancy, 
'spose...
                $noref = true;
                $objKey->connect($obj->conn);
                while ((list($table, $field) = each($obj->foreignKeys)) && 
$noref)
                {
                        if (is_array($field)) // More than one field in here 
references this key
                        {
                                while ((list($dummykey, $onefield) = 
each($field)) && $noref)
                                {
                                        $obj->Query("SELECT $onefield FROM 
$table WHERE $onefield=" . $GLOBALS['id']);
                                        if ($obj->NumRows() > 0)
                                                $noref = false;
                                }
                        }
                        else
                        {
                                $obj->Query("SELECT $field FROM $table WHERE 
$field=" . $GLOBALS['id']);
                                if ($obj->NumRows() > 0)
                                        $noref = false;
                        }
                }

                if ($noref)
                {
                        $obj->Delete();
                        print(STR_BO_DELETED);
                }
                else
                {
                        $obj->SetActive(false);
                        print(STR_BO_DEACTIVATED);
                }

                $objHTML = CreateObject('html' . $classSubName);
                $objHTML->PrintAll();
        }
}

?>

====================================================
Index: class.boPersonnel.inc.php
<?php
/*
 * $Id: class.boPersonnel.inc.php,v 1.1 2005/05/05 00:56:39 skwashd Exp $
 * Based on :
 * Double Choco Latte - Source Configuration Management System
 * Copyright (C) 1999  Michael L. Dean & Tim R. Norman
 *
 * Modified for osims project (C) 2001 Darryl VanDorp
 *
 *
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * Select License Info from the Help menu to view the terms and conditions of 
this license.
 */



class boPersonnel
{
        function add()
        {

                $obj = CreateObject('ccs.htmlPersonnel');
                $obj->ShowEntryForm();
                print('<p>');
                $obj->PrintAll();
        }

        function dbadd()
        {

                $obj = CreateObject('ccs.dbPersonnel');
                $obj->InitFromGlobals();
                //$obj->Encrypt();
                $obj->Add();

                $objHTML = CreateObject('ccs.htmlPersonnel');
                $objHTML->PrintAll();
        }

        function modify()
        {

                $obj = CreateObject('ccs.dbPersonnel');
                $obj->Load($GLOBALS['id']);
                $objHTML = CreateObject('ccs.htmlPersonnel');
                $objHTML->ShowEntryForm($obj);
        }

        function dbmodify()
        {

                $obj = CreateObject('ccs.dbPersonnel');
                $obj->InitFromGlobals();
                $obj->Edit();
                $objHTML = CreateObject('ccs.htmlPersonnel');
                $objHTML->PrintAll();
        }

        function delete()
        {
                $obj = CreateObject('ccs.dbPersonnel');
                $obj->Load($GLOBALS['id']);
                ShowDeleteYesNo('User', 'ccs.boPersonnel.dbdelete', $obj->id, 
$obj->short);
        }

        function dbdelete()
        {
                $classSubName = 'Personnel';

                $obj = CreateObject('ccs.db' . $classSubName);
                $obj->Load($GLOBALS['id']);

                $objKey = new ccsDb; // Don't really need anything fancy, 
'spose...
                $noref = true;
                while ((list($table, $field) = each($obj->foreignKeys)) && 
$noref)
                {
                        if (is_array($field)) // More than one field in here 
references this key
                        {
                                while ((list($dummykey, $onefield) = 
each($field)) && $noref)
                                {
                                        $obj->db->query("SELECT $onefield FROM 
$table WHERE $onefield=" . $GLOBALS['id']);
                                        if ($obj->db->nf() > 0)
                                                $noref = false;
                                }
                        }
                        else
                        {
                                $obj->db->query("SELECT $field FROM $table 
WHERE $field=" . $GLOBALS['id']);
                                if ($obj->db->nf() > 0)
                                        $noref = false;
                        }
                }

                if ($noref)
                {
                        $obj->Delete();
                        print('Deleted');
                }
                else
                {
                        $obj->SetActive(false);
                        print('Deactivated');
                }

                $objHTML = CreateObject('ccs.html' . $classSubName);
                $objHTML->PrintAll();
        }

        function passwd()
        {
                commonHeader();
                $objPersonnel = CreateObject('ccs.htmlPersonnel');
                $objPersonnel->DisplayPasswdForm();
        }

        function dbpasswd()
        {
                if ($GLOBALS['confirm'] != $GLOBALS['new'] || $GLOBALS['new'] 
== '')
                {
                        print('<center>');
                        PrintWithChocoFont(STR_BO_PASSWORDERR);
                        print('</center><br>');
                        $objPersonnel = CreateObject('ccs.htmlPersonnel');
                        $objPersonnel->DisplayPasswdForm();
                }
                else
                {
                        $objDBPersonnel = CreateObject('ccs.dbPersonnel');
                        $objDBPersonnel->ChangePassword($GLOBALS['userid'], 
$GLOBALS['original'], $GLOBALS['new'], $GLOBALS['confirm']);
                }
        }

        function showall()
        {

                $obj = CreateObject('ccs.htmlPersonnel');
                $obj->PrintAll();
        }
}

?>

====================================================
Index: class.boDepartments.inc.php
<?php
/*
 * $Id: class.boDepartments.inc.php,v 1.1 2005/05/05 00:56:39 skwashd Exp $
 *
 * Double Choco Latte - Source Configuration Management System
 * Copyright (C) 1999  Michael L. Dean & Tim R. Norman
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * Select License Info from the Help menu to view the terms and conditions of 
this license.
 */



class boDepartments
{
        function showall()
        {

                $obj = CreateObject('ccs.htmlDepartments');
                $obj->PrintAll();
        }

        function add()
        {

                $obj = CreateObject('ccs.htmlDepartments');
                $obj->ShowEntryForm();
                print('<p>');
                $obj->PrintAll();
        }

        function dbadd()
        {
                $obj = CreateObject('ccs.dbDepartments');
                $obj->InitFromGlobals();
                $obj->Add();

                $objHTML = CreateObject('ccs.htmlDepartments');
                $objHTML->PrintAll();
        }

        function modify()
        {
                $obj = CreateObject('ccs.dbDepartments');
                $obj->Load($GLOBALS['id']);
                $objHTML = CreateObject('ccs.htmlDepartments');
                $objHTML->ShowEntryForm($obj);
        }

        function dbmodify()
        {


                $obj = CreateObject('ccs.dbDepartments');
                $obj->InitFromGlobals();
                $obj->Edit();
                $objHTML = CreateObject('ccs.htmlDepartments');
                $objHTML->PrintAll();
        }

        function delete()
        {


                $obj = CreateObject('ccs.dbDepartments');
                $obj->Load($GLOBALS['id']);
                echo $obj->id;
                ShowDeleteYesNo('Department', 'ccs.boDepartments.dbdelete', 
$obj->id, $obj->name);
        }

        function dbdelete()  // needs some work here
        {
                $classSubName = 'Departments';

                $obj = CreateObject('ccs.db' . $classSubName);
                $obj->Load($GLOBALS['id']);

                $objKey = new ccsDb; // Don't really need anything fancy, 
'spose...
                $noref = true;
                while ((list($table, $field) = each($obj->foreignKeys)) && 
$noref)
                {
                        if (is_array($field)) // More than one field in here 
references this key
                        {
                                while ((list($dummykey, $onefield) = 
each($field)) && $noref)
                                {
                                        $obj->db->query("SELECT $onefield FROM 
$table WHERE $onefield=" . $GLOBALS['id'],__LINE__,__FILE__);
                                        if ($obj->db->num_rows() > 0)
                                                $noref = false;
                                }
                        }
                        else
                        {
                                $obj->db->query("SELECT $field FROM $table 
WHERE $field=" . $GLOBALS['id'],__LINE__,__FILE__);
                                if ($obj->db->num_rows() > 0)
                                        $noref = false;
                        }
                }

                if ($noref)
                {
                        $obj->Delete();
                        print('Deleted');
                }
                else
                {
                        $obj->SetActive(false);
                        print('Deactivated');
                }

                $objHTML = CreateObject('ccs.html' . $classSubName);
                $objHTML->PrintAll();
        }
}

?>

====================================================
Index: class.boCCS.inc.php
<?php

class boCCS
{
        function show()
        {
                global $phpgw, $phpgw_info;
                $obj = CreateObject('ccs.htmlCCS');
                $obj->ShowMainPage($GLOBALS['start']);
        }

        function newcc()
        {
                global $phpgw, $phpgw_info;
                $obj = CreateObject('ccs.htmlCCSForm');
                $obj->Show();
        }


        function dbnew()
        {
                global $phpgw, $phpgw_info;
                $objdb = CreateObject('ccs.dbCCS');
                $objdb->InitFromGlobals();

                $objdb-> Add();
                $this->show();
        }

        function delete()
        {
                $objdb=CreateObject('ccs.dbCCS');
                $objdb->Load($GLOBALS['ccs']);

                $obj = CreateObject('ccs.htmlCCSDetail');
                $obj->Show($GLOBALS['ccs'],0,true);

        }

        function dbdelete()
        {
                $objdb = CreateObject('ccs.dbCCS');
                $objdb->Delete($GLOBALS['ccs']);
                $this->show();
        }

        function viewcc()
        {
                $objdb=CreateObject('ccs.dbCCS');
                $objdb->Load($GLOBALS['ccs']);

                $obj = CreateObject('ccs.htmlCCSDetail');
                $obj->Show($GLOBALS['ccs'],0,false);
        }

        function modifycc()
        {
                $objCCS = CreateObject('ccs.dbCCS');
                $objCCS->Load($GLOBALS['ccs']);

                $obj = CreateObject('ccs.htmlCCSForm');
                $obj->Show($GLOBALS['ccs'],$objCCS);
        }

        function dbmodify()
        {
                $objDb=CreateObject('ccs.dbCCS');
                $objDb->Load($GLOBALS['ccs']);

                $objDb->ccs = $GLOBALS['ccs'];
                $objDb->subject = $objDb->GPCStripSlashes($GLOBALS['subject']);
                $objDb->detail = $objDb->GPCStripSlashes($GLOBALS['detail']);
                $objDb->status = $GLOBALS['status'];
                $objDb->lastactionon = $objDb->lastactionon;
                $objDb->openedon = $objDb->openedon;
                $objDb->Edit();
                $this->show();
        }
}
?>

====================================================
Index: class.boStatuses.inc.php
<?php
/*
 * $Id: class.boStatuses.inc.php,v 1.1 2005/05/05 00:56:39 skwashd Exp $
 *
 * Double Choco Latte - Source Configuration Management System
 * Copyright (C) 1999  Michael L. Dean & Tim R. Norman
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * Select License Info from the Help menu to view the terms and conditions of 
this license.
 */



class boStatuses
{
        function showall()
        {
                $obj = CreateObject('ccs.htmlStatuses');
                $obj->PrintAll();
        }

        function add()
        {
                $obj = CreateObject('ccs.htmlStatuses');
                $obj->ShowEntryForm();
                print('<p>');
                $obj->PrintAll();
        }

        function dbadd()
        {
                $obj = CreateObject('ccs.dbStatuses');
                $obj->InitFromGlobals();
                $obj->Add();

                $objHTML = CreateObject('ccs.htmlStatuses');
                $objHTML->PrintAll();
        }

        function modify()
        {
                $obj = CreateObject('ccs.dbStatuses');
                $obj->Load($GLOBALS['id']);
                $objHTML = CreateObject('ccs.htmlStatuses');
                $objHTML->ShowEntryForm($obj);
        }

        function dbmodify()
        {
                $obj = CreateObject('ccs.dbStatuses');
                $obj->InitFromGlobals();
                $obj->Edit();
                $objHTML = CreateObject('ccs.htmlStatuses');
                $objHTML->PrintAll();
        }
        function delete()
        {
                $obj = CreateObject('dbStatuses');
                $obj->Load($GLOBALS['id']);
                ShowDeleteYesNo('Status', 'ccs.boStatuses.dbdelete', $obj->id, 
$obj->name);
        }

        function dbdelete()
        {
                $classSubName = 'Statuses';

                $obj = CreateObject('db' . $classSubName);
                $obj->Load($GLOBALS['id']);

                $objKey = new dclDB; // Don't really need anything fancy, 
'spose...
                $noref = true;
                $objKey->connect($obj->conn);
                while ((list($table, $field) = each($obj->foreignKeys)) && 
$noref)
                {
                        if (is_array($field)) // More than one field in here 
references this key
                        {
                                while ((list($dummykey, $onefield) = 
each($field)) && $noref)
                                {
                                        $obj->Query("SELECT $onefield FROM 
$table WHERE $onefield=" . $GLOBALS['id']);
                                        if ($obj->NumRows() > 0)
                                                $noref = false;
                                }
                        }
                        else
                        {
                                $obj->Query("SELECT $field FROM $table WHERE 
$field=" . $GLOBALS['id']);
                                if ($obj->NumRows() > 0)
                                        $noref = false;
                        }
                }

                if ($noref)
                {
                        $obj->Delete();
                        print(STR_BO_DELETED);
                }
                else
                {
                        $obj->SetActive(false);
                        print(STR_BO_DEACTIVATED);
                }

                $objHTML = CreateObject('html' . $classSubName);
                $objHTML->PrintAll();
        }
}

?>

====================================================
Index: class.boTimecards.inc.php
<?php
/*
 * $Id: class.boTimecards.inc.php,v 1.1 2005/05/05 00:56:39 skwashd Exp $
 *
 * borrowed from:
 * Double Choco Latte - Source Configuration Management System
 * Copyright (C) 1999  Michael L. Dean & Tim R. Norman
 *
 * -------------------------------------------------------------
 * adapted for ccs Copyright (C) 2001 Darryl VanDorp
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 *
 */


class boTimecards
{
        function add()
        {
                $obj = CreateObject('ccs.htmlTimeCardForm');
                $obj->Show($GLOBALS['ccs']);

                $objWO = CreateObject('ccs.htmlCCSDetail');
                $objWO->Show($GLOBALS['ccs']);
        }

        function dbadd()
        {
                $objTimecard = CreateObject('ccs.dbTimeCards');
                $objTimecard->InitFromGlobals();
                $objdbCCS = CreateObject('ccs.dbCCS');
                $objdbCCS->Load($objTimecard->id);
                $status = $objdbCCS->status;
                $objTimecard->Add();
                //      $notify = '4';
                //      if ($status != $objTimecard->status)
                //      {
                //      $notify .= ',3';
                //if ($objTimecard->status == 2)
                //$notify .= ',2';
                //if ($objTimecard->status == 1)
                //$notify .= ',1';
                //}

                //      $objWtch = CreateObject('boWatches');
                        // Reload before sending since time card modifies the 
work order
                //$objWorkorder->Load($objTimecard->jcn, $objTimecard->seq);
                //$objWtch->sendNotification($objWorkorder, $notify);

                $objCCS = CreateObject('ccs.htmlCCSDetail');
                $objCCS->Show($objTimecard->ccs);
        }

        function modify()
        {

                $objTC = CreateObject('ccs.dbTimeCards');
                $objTC->Load($GLOBALS['id']);

                $obj = CreateObject('ccs.htmlCCSDetail');
                $obj->Show($objTC->ccs, $objTC->id);
        }

        function dbmodify()
        { // Rewrite this whole function ----------------------------  Darryl
                global $dcl_info;


                $objTC = CreateObject('ccs.dbTimeCards');
                $objOldTC = CreateObject('ccs.dbTimeCards');
                $objTC->InitFromGlobals();
                $objOldTC->Load($objTC->id);

            // If the hours change, we'll need to adjust the workorder
                //      $hoursDiff = $objTC->hours - $objOldTC->hours;

                $objWO = CreateObject('ccs.dbWorkorders');
                $objWO->Load($objTC->ccs);
                $woChanged = false;
                $lastWO = false;

            // See if any time cards were issued after this one.  If not, assume
            // that this time card was the last one entered and affected the 
work order
            // status when input.  In other words, adjust as needed.
                $objQueryTC = CreateObject('ccs.dbTimeCards');
                $objQueryTC->Connect($objTC->conn);
                if ($objQueryTC->Query(sprintf('SELECT id FROM osims_timecards 
WHERE id > %d AND ccs=%d', $objTC->id, $objTC->ccs)) != -1)
                {
                        if ($objQueryTC->db->num_rows() < 1)
                        {
                                $lastWO = true;
                        }
                }

                $notify = '4';

                if ($objTC->status != $objOldTC->status)
                {
                        $notify .= ',3';

                        if ($lastWO)
                        {
                    // We're the last one!  This does (of course) assume that 
time cards
                    // are entered sequentially in correct chronological order.
                                if ($objTC->status != $objWO->status)
                                {
                                        $objWO->status = $objTC->status;
                                        $objWO->statuson = 
date($dcl_info['DCL_TIMESTAMP_FORMAT']);
                                        $woChanged = true;
                                        if ($objTC->status == 2)
                                        {
                                                $objWO->closedby = 
$objTC->actionby;
                                                $objWO->closedon = 
$objTC->actionon;
                                                $objWO->etchours = 0.0;

                                                $notify .= ',2';
                                        }
                                }
                        }
                        else
                        {
                    // Don't allow status change if more are left.  Last time 
card controls status of WO
                                $objTC->status = $objOldTC->status;
                        }
                }

                if ($hoursDiff != 0)
                {
                        $objWO->totalhours += $hoursDiff;
                        $woChanged = true;
                }

            // Only look at it if it is the last time card.  The last time card 
controls etc for the WO
                if ($lastWO && $objWO->etchours != $GLOBALS['etchours'])
                {
                        $woChanged = true;
                        if ($objWO->status != 2) // Only change it if it is not 
closed
                                $objWO->etchours = $GLOBALS['etchours'];
                        else
                                $objWO->etchours = 0.0;
                }

                if ($woChanged)
                        $objTC->BeginTransaction();

                $objTC->Edit();

                if ($woChanged)
                {
                        $objWO->edit();
                        $objTC->EndTransaction();
                }

                $objWtch = CreateObject('boWatches');
                $objWtch->sendNotification($objWO, $notify);

                $obj = CreateObject('htmlWorkOrderDetail');
                $obj->Show($objTC->jcn, $objTC->seq);
        }

        function delete()
        {

                $objTC = CreateObject('ccs.dbTimeCards');
                $objTC->Load($GLOBALS['id']);

                $obj = CreateObject('ccs.htmlCCSDetail');
                $obj->Show($objTC->ccs, $objTC->id, true);
        }

        function dbdelete()
        {
                // just re-write this whole function - Darryl
                global $dcl_info;


                $objTC = CreateObject('ccs.dbTimeCards');
                $objTC->Load($GLOBALS['id']);

                $objCCS = CreateObject('ccs.dbCCS');
                $objCCS->Load($objTC->ccs);

            // Get the next time card issued after this one.  If not, assume
            // that this time card was the last one entered and affected the 
work order
            // status when input.

                $objQueryTC=CreateObject('ccs.dbTimeCards');
                $query = sprintf('SELECT min(id) FROM osims_timecards WHERE id 
> %d AND ccs=%d',$objTC->id, $obTC->ccs);
                $objQueryTC->db->query($query);
                $ojbQueryTC->db->next_record();
                if(($objQueryTC->db->f('id') == '') || 
($objQueryTC->db->f('id') < 1))
                {
                                // theory is we're the last timecard. We 
control status.
                                // now check to see if there are any prior 
timecards. If so we revert to their status

                                $query = sprintf('SELECT max(id) FROM 
osims_timecards WHERE id < %d AND ccs=%d', $ojbTC->id, $objTC->ccs);
                                $objQueryTC->db->query($query);
                                $ojbQueryTC->db->next_record();

                                if ($ojbQueryTC->db->f('id') == false && 
$ojbQueryTC->db->f('id') > 0)
                                {
                                                // ok so prior timecard exists
                                                
$objQueryTC->Load($objQueryTC->db->f('id'));
                                                if ($ojbQueryTC->status != 
$ojbCCS->status)
                                                {
                                                                
$ojbCCS->statuson = date($dcl_info['DCL_TIMESTAMP_FORMAT']);
                                                                if 
($objQueryTC->status == 2 && $ojbCCS->status != 2)
                                                                {
                                                                                
$ojbCCS->closedby = $ojbQueryTC->actionby;
                                                                                
$ojbCCS->closedon = $objQueryTC->actionon;
                                                                } // if
                                                                else if 
($ojbCCS->status ==2 )
                                                                                
{
                                                                                
                $objCCS->closedby = 0;
                                                                                
                $ojbCCS->closedon='';
                                                                                
}  else
                                                                $objCCS->status 
= $objQueryTC->status;
                                                } //if
                                }
                                else
                                {
                                                $objCCS->status= 1; // open it
                                                $ojbCCS->statuson = 
date($dcl_info['DCL_TIMESTAMP_FORMAT']);
                                                $ojbCCS->closedby=0;
                                                $ojbCCS->closedon='';
                                                $ojbCCS->lastactionon='';
                                }
                }
                else
                 {
                                $objQueryTC->Load($objQueryTC->db->f('id'));
                                $ojbCCS->starton = $ojbQueryTC->actionon;
                 }


        }
}

?>

====================================================
Index: class.htmlStatuses.inc.php
<?php
/*
 * $Id: class.htmlStatuses.inc.php,v 1.1 2005/05/05 00:56:39 skwashd Exp $
 *
 * Double Choco Latte - Source Configuration Management System
 * Copyright (C) 1999  Michael L. Dean & Tim R. Norman
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * Select License Info from the Help menu to view the terms and conditions of 
this license.
 */



class htmlStatuses
{
        function createCombo($default = 0, $cbName = 'status', $longShort = 
'name', $size = 0, $activeOnly = true, $setid = 0)
        {
                print $this->GetCombo($default, $cbName, $longShort, $size, 
$activeOnly, $setid);
        }

        function GetCombo($default = 0, $cbName = 'status', $longShort = 
'name', $size = 0, $activeOnly = true, $setid = 0)
        {
                $objDBStatuses = CreateObject('ccs.dbStatuses');

                $query = "SELECT a.id,a.$longShort FROM osims_statuses a ";

                /*
// we'll nuke attribute support for now
                if ($setid > 0)
                {
                        $query .= ",attributesetsmap b WHERE a.id=b.keyid AND 
b.typeid=4 AND b.setid=$setid ";
                        if ($activeOnly)
                                $query .= ' AND a.active=\'Y\' ';
                }
                else
                {
                        if ($activeOnly)
                                $query .= 'WHERE a.active=\'Y\' ';
                } */

                $query .= "ORDER BY $longShort";
                $objDBStatuses->db->query($query);

                $str = "<select name=\"$cbName";
                if ($size > 0)
                        $str .= '[]" multiple size="' . $size;

                $str .= '">';
                if ($size == 0)
                        $str .= sprintf('<option value="0">%s</option>', 
"whooandwhat?");

                while ($objDBStatuses->db->next_record() )
                {
                        $id = $objDBStatuses->db->f(0);
                        $text = $objDBStatuses->db->f(1);
                        $str .= "<option value=\"$id\"";
                        if ($id == $default)
                                $str .= ' selected';
                        $str .= '>' . $text . '</option>';
                        //      if ($objDBStatuses->db->next_record() == -1)
                        //break;
                }

                $str .= '</select>';

                return $str;
        }

        function PrintAll($orderBy = 'name')
        {
                // global $dcl_info;

                $objDBStatus = CreateObject('ccs.dbStatuses');
                $objDBStatus->Connect();

                $objDBStatus->Query("SELECT id,active,short,name FROM 
osims_statuses ORDER BY $orderBy");
                $allRecs = $objDBStatus->FetchAllRows();

                //      if ($GLOBALS['SEC'] >= $dcl_info['DCL_ADD_USER'])
                $titleLink = '<a class="alight" 
href="index.php?menuAction=ccs.boStatuses.add">[ ' . STR_CMMN_NEW . ' ]</a>';
                //      else
                //      $titleLink = '';

                if (is_array($allRecs))
                {
                        $allName = array(
                                        0 => STR_STAT_ID,
                                        1 => STR_STAT_ACTIVEABB,
                                        2 => STR_STAT_SHORT,
                                        3 => STR_STAT_NAME);

                        if (count($allRecs) > 0) // && $GLOBALS['SEC'] >= 
$dcl_info['DCL_ADD_USER'])
                        {
                                $allName[] = 'Options';
                                for ($i = 0; $i < count($allRecs); $i++)
                                {
                                        $options = '<a class="adark" 
href="index.php?menuAction=boStatuses.modify&id=' . $allRecs[$i][0] . '">' . 
"edit". '</a>';
                                        $options .= '&nbsp;';
                                        $options .= '<a class="adark" 
href="index.php?menuAction=boStatuses.delete&id=' . $allRecs[$i][0] . '">' . 
"delete" . '</a>';
                                        $allRecs[$i][] = $options;
                                }
                        }
                        PrintArrayAsChocoTable($allName, $allRecs, 
sprintf("Select Status", $orderBy), '', $titleLink);
                }
                else
                {
                        print('<center>');
                        PrintWithChocoFont(STR_STAT_NOSTATS . '&nbsp;&nbsp;' . 
$titleLink);
                        print('</center>');
                }
        }

        function ShowEntryForm($obj = '')
        {
                global $dcl_info;

                $isEdit = is_object($obj);

                $Template = 
CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('ccs'));
                // $Template = CreateTemplate(array('hForm' => 
'htmlStatusesForm.tpl'));
                $Template->set_file(array('hForm' => 'htmlStatusesForm.tpl'));
                $Template->set_var('COLOR_DARK', $dcl_info['DCL_COLOR_DARK']);
                $Template->set_var('COLOR_LIGHT', $dcl_info['DCL_COLOR_LIGHT']);

                $hidden_vars = '';
                if ($isEdit)
                {
                        $Template->set_var('TXT_FUNCTION', "Edit");
                        $hidden_vars .= '<input type="hidden" name="menuAction" 
value="ccs.boStatuses.dbmodify">';
                        $hidden_vars .= '<input type="hidden" name="id" 
value="' . $GLOBALS['id'] . '">';
                }
                else
                {
                        $Template->set_var('TXT_FUNCTION', "Add");
                        $hidden_vars .= '<input type="hidden" name="menuAction" 
value="ccs.boStatuses.dbadd">';
                }

                $Template->set_var('HIDDEN_VARS', $hidden_vars);

                        // Labels
                $Template->set_var('TXT_ACTIVE', "Active");
                $Template->set_var('TXT_SHORT', "Short");
                $Template->set_var('TXT_NAME', "Name");
                $Template->set_var('BTN_OK', "Ok");
                $Template->set_var('BTN_RESET', "reset");
                $Template->set_var('TXT_HIGHLIGHTEDNOTE', "eh?");
                $Template->set_var('TXT_ATTRIBUTESNOTE', "What?");

                        // Data
                if ($isEdit)
                {
                        $Template->set_var('CMB_ACTIVE', 
GetYesNoCombo($obj->active, 'active', 0, false));
                        $Template->set_var('VAL_SHORT', $obj->short);
                        $Template->set_var('VAL_NAME', $obj->name);
                }
                else
                {
                        $Template->set_var('CMB_ACTIVE', GetYesNoCombo('Y', 
'active', 0, false));
                        $Template->set_var('VAL_SHORT', '');
                        $Template->set_var('VAL_NAME', '');
                }

                $Template->pparse('out', 'hForm');
        }
}
?>

====================================================
Index: class.htmlPersonnel.inc.php
<?php
/*
 * $Id: class.htmlPersonnel.inc.php,v 1.1 2005/05/05 00:56:39 skwashd Exp $
 *
 * Double Choco Latte - Source Configuration Management System
 * Copyright (C) 1999  Michael L. Dean & Tim R. Norman
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * Select License Info from the Help menu to view the terms and conditions of 
this license.
 */



class htmlPersonnel
{
        function createCombo($default = 0, $cbName = 'responsible', $longShort 
= 'lastfirst', $size = 0, $activeOnly = true, $minsec = 0, $projectid = 0)
        {
                print $this->GetCombo($default, $cbName, $longShort, $size, 
$activeOnly, $minsec, $projectid);
        }

        function GetCombo($default = 0, $cbName = 'responsible', $longShort = 
'lastfirst', $size = 0, $activeOnly = true, $minsec = 0, $projectid = 0)
        {
                $objDBPersonnel = CreateObject('ccs.dbPersonnel');
                $objAccount = CreateObject('phpgwapi.accounts');

                // $objDBPersonnel->cacheEnabled = false;

                //if ($longShort == 'lastfirst')
                //$orderBy = 'lastname, firstname';
                //else if ($longShort == 'firstlast' || $longShort == 'name')
                //$orderBy = 'firstname, lastname';
                //else
                $orderBy = 'id';
                $activeOnly = false; //should play with this some day

                if ($projectid > 0)
                {
                                // Show people in the project only
                        $query = "SELECT DISTINCT osims_personnel.* FROM 
personnel ";
                        $query .= ', workorders a, projectmap b WHERE ';
                        $query .= "a.jcn=b.jcn AND (b.seq=0 OR a.seq=b.seq) AND 
b.projectid=$projectid ";
                        $query .= 'AND id=a.responsible ';
                }
                else
                {
                        $query = "SELECT * FROM osims_personnel ";
                        if ($activeOnly)
                                $query .= 'WHERE active=\'Y\' ';

                        if ($minsec > 0)
                        {
                                if ($activeOnly)
                                        $query .= 'AND';
                                else
                                        $query .= 'WHERE';

                                $query .= " security>=$minsec ";
                        }
                }

                $query .= "ORDER BY $orderBy";
                $objDBPersonnel->db->query($query);

                $str = "<select name=\"$cbName";

                if ($size > 0)
                        $str .= '[]" multiple size="' . $size . '"';
                else
                        $str .= '"';

                $str .= '>';
                if ($size == 0)
                        $str .= sprintf('<option value="0">%s</option>', 
'Select User');

                while ($objDBPersonnel->db->next_record() )
                {
                        //$objDBPersonnel->GetRow();
                        $str .= '<option value="'. $objDBPersonnel->db->f('id') 
. '"';
                        if ($objDBPersonnel->db->f('id') == $default)
                                $str .= ' selected';
                        $str .= '>';

                        //      if ($longShort == 'lastfirst')
                        //$str .= $objDBPersonnel->lastNameFirst;
                        //else if ($longShort == 'firstlast' || $longShort == 
'name')
                        //$str .= $objDBPersonnel->firstNameLast;
                        //else
                        $name = 
$objAccount->id2name($objDBPersonnel->db->f('phpgwid'));
                        $str .= $name;

                        $str .= '</option>';

                        //      if ($objDBPersonnel->next_record() == -1)
                        //break;
                }

                $str .= '</select>';

                return $str;
        }

        function displayPasswdForm()
        {
                global $dcl_info;

                $Template = 
CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('ccs'));
                $Template->set_file(array('hForm' => 
'htmlPersonnelPasswdForm.tpl'));
                $Template->set_block('hForm', 'sa', 'hSa');
                $Template->set_block('hForm', 'notsa', 'hNotSa');
                $Template->set_var('hSa', '');
                $Template->set_var('hNotSa', '');
                $Template->set_var('COLOR_DARK', $dcl_info['DCL_COLOR_DARK']);
                $Template->set_var('COLOR_LIGHT', $dcl_info['DCL_COLOR_LIGHT']);
                $Template->set_var('TXT_CHGPWD', STR_USR_CHGPWD);

                $hidden_vars = '<input type="hidden" name="menuAction" 
value="ccs.boPersonnel.dbpasswd">';
                if ($GLOBALS['DCLID'] > 1)
                {
                        $hidden_vars .= sprintf('<input type="hidden" 
name="userid" value="%d">', $GLOBALS['DCLID']);
                        $Template->set_var('TXT_CURRPWD', STR_USR_CURRPWD);
                        $Template->parse('hNotSa', 'notsa');
                }
                else
                {
                        $Template->set_var('TXT_USER', STR_USR_USER);
                        $Template->set_var('CMB_USERID', 
$this->GetCombo($GLOBALS['DCLID'], 'userid'));
                        $Template->parse('hSa', 'sa');
                }

                $Template->set_var('HIDDEN_VARS', $hidden_vars);
                $Template->set_var('TXT_NEWPWD', STR_USR_NEWPWD);
                $Template->set_var('TXT_CONFIRMPWD', STR_USR_CONFIRMPWD);
                $Template->set_var('BTN_CHANGE', STR_USR_CHANGE);
                $Template->set_var('BTN_CLEAR', STR_USR_CLEAR);

                $Template->pparse('out', 'hForm');
        }

        function ShowEntryForm($obj = '')
        {
                global $dcl_info,$phpgw;
                $accounts = CreateObject('phpgwapi.accounts');
                $isEdit = is_object($obj);
                $Template = 
CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('ccs'));
                $Template->set_file(array('hForm' => 'htmlPersonnelForm.tpl'));
                $Template->set_block('hForm', 'add', 'hAdd');
                $Template->set_block('hForm', 'edit', 'hEdit');
                $Template->set_block('hForm', 'list', 'hList');
                $Template->set_var('hAdd', '');
                $Template->set_var('hEdit', '');
                $Template->set_var('hList', '');
                $Template->set_var('COLOR_DARK', $dcl_info['DCL_COLOR_DARK']);
                $Template->set_var('COLOR_LIGHT', $dcl_info['DCL_COLOR_LIGHT']);

                if ($isEdit)
                {
                        $Template->set_var('TXT_FUNCTION', 'Edit User');
                        $hidden_vars = '<input type="hidden" name="menuAction" 
value="ccs.boPersonnel.dbmodify">' .
                                '<input type="hidden" name="id" value="' . 
$GLOBALS['id'] . '">';
                }
                else
                {
                        $Template->set_var('TXT_FUNCTION', 'Add User');
                        $hidden_vars = '<input type="hidden" name="menuAction" 
value="ccs.boPersonnel.dbadd">';
                }

                $Template->set_var('HIDDEN_VARS', $hidden_vars);

                        // Labels
                $Template->set_var('TXT_LOGIN', 'phpGW login Name');
                $Template->set_var('TXT_ACTIVE', 'Active');
                //      $Template->set_var('TXT_FIRSTNAME', STR_USR_FIRSTNAME);
                //      $Template->set_var('TXT_LASTNAME', STR_USR_LASTNAME);
                $Template->set_var('TXT_REPORTTO', 'Reports To');
                $Template->set_var('TXT_DEPARTMENT', 'Department');
                //      $Template->set_var('TXT_PASSWORD', STR_USR_PASSWORD);
                $Template->set_var('TXT_SECLVL', 'Security Level');
                //      $Template->set_var('TXT_CONFIRMPWD', 
STR_USR_CONFIRMPWD);
                //$Template->set_var('TXT_EMAIL', STR_USR_EMAIL);
                $Template->set_var('BTN_SAVE', 'Save');
                $Template->set_var('BTN_RESET', 'Reset');
                $Template->set_var('TXT_HIGHLIGHTEDNOTE', 
STR_USR_HIGHLIGHTEDNOTE);

                        // Security Info
                $Template->set_var('TXT_MINLVL', STR_USR_MINLVL);
                $Template->set_var('TXT_TODOTHIS', STR_USR_TODOTHIS);

                $Template->set_var('TXT_LVL', $dcl_info['DCL_ADD_USER']);
                $Template->set_var('TXT_DESC', STR_USR_ADMIN);
                $Template->parse('hList', 'list', true);
                $Template->set_var('TXT_LVL', $dcl_info['DCL_DEL_WO']);
                $Template->set_var('TXT_DESC', STR_USR_DELWO);
                $Template->parse('hList', 'list', true);
                $Template->set_var('TXT_LVL', $dcl_info['DCL_MOD_WO']);
                $Template->set_var('TXT_DESC', STR_USR_MODWO);
                $Template->parse('hList', 'list', true);
                $Template->set_var('TXT_LVL', $dcl_info['DCL_ASSIGN_WO']);
                $Template->set_var('TXT_DESC', STR_USR_ADDASSGN);
                $Template->parse('hList', 'list', true);
                $Template->set_var('TXT_LVL', $dcl_info['DCL_HAVE_WO']);
                $Template->set_var('TXT_DESC', STR_USR_RESPONSIBLE);
                $Template->parse('hList', 'list', true);
                $Template->set_var('TXT_LVL', $dcl_info['DCL_CHG_PWD']);
                $Template->set_var('TXT_DESC', STR_USR_CANCHGPWD);
                $Template->parse('hList', 'list', true);
                $Template->set_var('TXT_LVL', $dcl_info['DCL_ADD_WO']);
                $Template->set_var('TXT_DESC', STR_USR_ADDWO);
                $Template->parse('hList', 'list', true);

                $objHTMLDepartments = CreateObject('ccs.htmlDepartments');

                        // Data
                if ($isEdit)
                {
                        $phpgwid = $obj->phpgwid;
                        $Template->set_var('VAL_SHORT', 
$accounts->id2name($phpgwid));
                        $Template->set_var('CMB_ACTIVE', 
GetYesNoCombo($obj->active, 'active', 0, false));
                        $Template->set_var('VAL_FIRSTNAME', $obj->firstname);
                        $Template->set_var('VAL_LASTNAME', $obj->lastname);
                        $Template->set_var('CMB_REPORTTO', 
$this->GetCombo($obj->reportto, 'reportto'));
                        $Template->set_var('CMB_DEPARTMENT', 
$objHTMLDepartments->GetCombo($obj->department));
                        $Template->set_var('VAL_SECURITY', $obj->security);
                        $Template->set_var('VAL_EMAIL', $obj->email);
                        $Template->parse('hEdit', 'edit');
                }
                else
                {
                        $Template->set_var('CMB_ACTIVE', GetYesNoCombo('Y', 
'active', 0, false));
                        $Template->set_var('CMB_REPORTTO', 
$this->GetCombo($GLOBALS['DCLID'], 'reportto'));
                        $Template->set_var('CMB_DEPARTMENT', 
$objHTMLDepartments->GetCombo());
                        $Template->set_var('VAL_SHORT', '');
                        $Template->set_var('VAL_FIRSTNAME', '');
                        $Template->set_var('VAL_LASTNAME', '');
                        $Template->set_var('VAL_SECURITY', '');
                        $Template->set_var('VAL_EMAIL', '');
                        $Template->parse('hAdd', 'add');
                }

                $Template->pparse('out', 'hForm');
        }

        function PrintAll($orderBy = 'id')
        {
                global $dcl_info;

                $objDBPersonnel = CreateObject('ccs.dbPersonnel');

                $objDBPersonnel->db->query("SELECT 
id,active,phpgwid,reportto,department,security FROM osims_personnel ORDER BY 
$orderBy");
                $allRecs = $objDBPersonnel->FetchAllRows();

                if ($GLOBALS['SEC'] >= $dcl_info['DCL_ADD_USER'])
                        $titleLink = '<a class="alight" 
href="index.php?menuAction=ccs.boPersonnel.add">[ ' . 'New' . ' ]</a>';
                else
                        $titleLink = '';

                if (is_array($allRecs))
                {
                // Replace all the id fields with meaningful text
                        $objDBDept = CreateObject('ccs.dbDepartments');
                        //      $objDBDept->Connect($objDBPersonnel->conn);
                        /*      for ($i = 0; $i < count($allRecs); $i++)
                        {
                                $objDBPersonnel->Load($allRecs[$i][5]);
                                $objDBDept->Load($allRecs[$i][6]);
                                $allRecs[$i][5] = $objDBPersonnel->short;
                                $allRecs[$i][6] = $objDBDept->name;
                                if (IsSet($allRecs[$i][8]) && $allRecs[$i][8] 
!= '')
                                        $allRecs[$i][8] = '<a class="adark" 
href="mailto:' . $allRecs[$i][8] . '">' . $allRecs[$i][8] . '</a>';
                        } */

                        $allName = array(
                                        0 => 'ID',
                                        1 => 'Active',
                                        2 => 'phpgwID',
                                        //      3 => STR_USR_LASTNAME,
                                        //      4 => STR_USR_FIRSTNAME,
                                        3=> 'Report To',
                                        4=> 'Department',
                                        5=>  'Security Level');
                                        // 8 => STR_USR_EMAIL);

                        if (count($allRecs) > 0 && $GLOBALS['SEC'] >= 
$dcl_info['DCL_ADD_USER'])
                        {
                                $allName[] = 'Options';
                                for ($i = 0; $i < count($allRecs); $i++)
                                {
                                        $options = '<a class="adark" 
href="index.php?menuAction=ccs.boPersonnel.modify&id=' . $allRecs[$i][0] . '">' 
. Edit . '</a>';
                                        $options .= "&nbsp;";
                                        $options .= '<a class="adark" 
href="index.php?menuAction=ccs.boPersonnel.delete&id=' . $allRecs[$i][0] . '">' 
. Delete . '</a>';
                                        $allRecs[$i][] = $options;
                                }
                        }
                        PrintArrayAsChocoTable($allName, $allRecs, 
sprintf('Personnel', $orderBy), '', $titleLink);
                }
                else
                {
                        print('<center>');
                        PrintWithChocoFont(STR_USR_NOUSERS . '&nbsp;&nbsp;' . 
$titleLink);
                        print('</center>');
                }
        }
}
?>

====================================================
Index: class.htmlDepartments.inc.php
<?php
/*
 * $Id: class.htmlDepartments.inc.php,v 1.1 2005/05/05 00:56:39 skwashd Exp $
 *
 * Double Choco Latte - Source Configuration Management System
 * Copyright (C) 1999  Michael L. Dean & Tim R. Norman
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * Select License Info from the Help menu to view the terms and conditions of 
this license.
 */



class htmlDepartments
{
        function createCombo($default = 0, $cbName = 'department', $longShort = 
'name', $size = 0, $activeOnly = true)
        {
                print $this->GetCombo($default, $cbName, $longShort, $size, 
$activeOnly);
        }

        function GetCombo($default = 0, $cbName = 'department', $longShort = 
'name', $size = 0, $activeOnly = true)
        {
                $objDBDept = CreateObject('ccs.dbDepartments');

                $query = "SELECT id,$longShort FROM osims_departments ";

                if ($activeOnly)
                        $query .= 'WHERE active=\'Y\' ';

                $query .= "ORDER BY $longShort";
                $objDBDept->db->query($query);
                //      $objDBDept->db->next_record;
                $str = "<select name=\"$cbName";
                if ($size > 0)
                        $str .= '[]" multiple size=' . $size;
                else
                        $str .= '"';
                $str .= '>';
                if ($size == 0)
                        $str .= sprintf('<option value="0">%s</option>', 
'Select Department');

                while ($objDBDept->db->next_record())
                {
                        $id = $objDBDept->db->f('id');
                        $name = $objDBDept->db->f('name');
                        $str .= '<option value="'. $id . '"';
                        if ($id == $default)
                                $str .= ' selected';
                        $str .= '>' . $name . '</option>';

                        //if ($objDBDept->db->next_record() == -1)
                        //break;
                }

                $str .= '</select>';

                return $str;
        }

        function PrintAll($orderBy = 'name')
        {
                global $dcl_info;

                $objDBDepts = CreateObject('ccs.dbDepartments');


                $objDBDepts->db->query("SELECT id,active,short,name FROM 
osims_departments ORDER BY $orderBy");
                $allRecs = $objDBDepts->FetchAllRows();

                if ($GLOBALS['SEC'] >= $dcl_info['DCL_ADD_USER'])
                        $titleLink = '<a class="alight" 
href="index.php?menuAction=ccs.boDepartments.add">[ New ]</a>';
                else
                        $titleLink = '';

                if (is_array($allRecs))
                {
                        $allName = array(
                                        0 => 'Department ID',
                                        1 => 'Active',
                                        2 => 'Short',
                                        3 => 'Department Name');

                        if (count($allRecs) > 0 && $GLOBALS['SEC'] >= 
$dcl_info['DCL_ADD_USER'])
                        {
                                $allName[] = 'Options';
                                for ($i = 0; $i < count($allRecs); $i++)
                                {
                                        $options = '<a class="adark" 
href="index.php?menuAction=ccs.boDepartments.modify&id=' . $allRecs[$i][0] . 
'">' . Edit . '</a>';
                                        $options .= "&nbsp;";
                                        $options .= '<a class="adark" 
href="index.php?menuAction=ccs.boDepartments.delete&id=' . $allRecs[$i][0] . 
'">' . Delete . '</a>';
                                        $allRecs[$i][] = $options;
                                }
                        }
                        PrintArrayAsChocoTable($allName, $allRecs, 
sprintf('Departments', $orderBy), '', $titleLink);
                }
                else
                {
                        print('<CENTER>');
                        PrintWithChocoFont(STR_DEPT_NODEPTS . '&nbsp;&nbsp;' . 
$titleLink);
                        print('</CENTER>');
                }
        }

        function ShowEntryForm($obj = '')
        {
                global $dcl_info,$phpgw;

                $isEdit = is_object($obj);
                $Template = 
CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('ccs'));
                $Template->set_file(array('hForm' => 
'htmlDepartmentsForm.tpl'));
                $Template->set_var('COLOR_DARK', $dcl_info['DCL_COLOR_DARK']);
                $Template->set_var('COLOR_LIGHT', $dcl_info['DCL_COLOR_LIGHT']);

                $hidden_vars = '';
                if ($isEdit)
                {
                        $Template->set_var('TXT_FUNCTION', STR_DEPT_EDIT);
                        $hidden_vars .= '<input type="hidden" name="menuAction" 
value="ccs.boDepartments.dbmodify">';
                        $hidden_vars .= '<input type="hidden" name="id" 
value="' . $GLOBALS['id'] . '">';
                }
                else
                {
                        $Template->set_var('TXT_FUNCTION', STR_DEPT_ADD);
                        $hidden_vars .= '<input type="hidden" name="menuAction" 
value="ccs.boDepartments.dbadd">';
                }

                $Template->set_var('HIDDEN_VARS', $hidden_vars);

                        // Labels
                $Template->set_var('TXT_ACTIVE', STR_DEPT_ACTIVE);
                $Template->set_var('TXT_SHORT', STR_DEPT_SHORT);
                $Template->set_var('TXT_NAME', STR_DEPT_NAME);
                $Template->set_var('BTN_OK', STR_CMMN_SAVE);
                $Template->set_var('BTN_RESET', STR_CMMN_RESET);
                $Template->set_var('TXT_HIGHLIGHTEDNOTE', 
STR_DEPT_HIGHLIGHTEDNOTE);

                        // Data
                if ($isEdit)
                {
                        $Template->set_var('CMB_ACTIVE', 
GetYesNoCombo($obj->active, 'active', 0, false));
                        $Template->set_var('VAL_SHORT', $obj->short);
                        $Template->set_var('VAL_NAME', $obj->name);
                }
                else
                {
                        $Template->set_var('CMB_ACTIVE', GetYesNoCombo('Y', 
'active', 0, false));
                        $Template->set_var('VAL_SHORT', '');
                        $Template->set_var('VAL_NAME', '');
                }

                $Template->pparse('out', 'hForm');
        }
}

?>

====================================================
Index: class.htmlTimeCardForm.inc.php
<?php
/*
 * $Id: class.htmlTimeCardForm.inc.php,v 1.1 2005/05/05 00:56:39 skwashd Exp $
 *
 * Double Choco Latte - Source Configuration Management System
 * Copyright (C) 1999  Michael L. Dean & Tim R. Norman
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * Select License Info from the Help menu to view the terms and conditions of 
this license.
 */



class htmlTimeCardForm
{
        function Show($ccs, $obj = '', $selected = '')
        {
                echo $this->GetForm($ccs, $obj, $selected);

        }

        function GetForm($ccs, $obj = '', $selected = '')
        {
                global $dcl_info,$phpgw,$phpgw_info;
                $isBatch = is_array($selected) && count($selected) > 0;
                $isEdit = is_object($obj) && !$isBatch; // Don't allow batch 
updates for now...

                if (!$isBatch)
                {
                        $objWorkorder = CreateObject('ccs.dbCCS');
                        //$objWorkorder->Connect();
                        $objWorkorder->Load($ccs);

                        //      $objProduct = CreateObject('dbProducts');
                        //$objProduct->Connect();
                        //$objProduct->Query('SELECT wosetid FROM products 
WHERE id=' . $objWorkorder->product);
                        //$setid = $objProduct->GetField(0);
                }
                else
                        $setid = 0;

                $setid = 0; //avoid attribute maps for now


                $Template = 
CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('ccs'));
                $Template->set_file(array('hForm' => 'htmlTimeCardForm.tpl'));
                $Template->set_block('hForm', 'modify', 'hModify');
                $Template->set_block('hForm', 'batch', 'hBatch');
                $Template->set_var('hModify', '');
                $Template->set_var('hBatch', '');

                $Template->set_var('COLOR_DARK', $dcl_info['DCL_COLOR_DARK']);
                $Template->set_var('COLOR_LIGHT', $dcl_info['DCL_COLOR_LIGHT']);

            // if editing, we go 100%
                if ($isEdit)
                        $Template->set_var('VAL_OUTERTABLEWIDTH', '100%');
                else
                        $Template->set_var('VAL_OUTERTABLEWIDTH', '');

                $title = '';
                if ($isEdit)
                        $title .= sprintf('%s&nbsp;', "Edit TimeCard");

                if ($isBatch)
                        $title .= "STR_TC_BATCHUPDATE" . '&nbsp;';
                else
        //              $title .= sprintf("%s: $ccs &nbsp;&nbsp; %s: $seq", 
"Customer Complaint Number", "STR_TC_SEQ");
                        $title .= sprintf("%s:$ccs", "Customer Complaint 
Number");
                if (!$isEdit)
                        $title .= " (Detail Below)";

                if (!$isBatch)
                        $title .= sprintf('<br>%s:&nbsp;%s', "Complaint 
Subject", htmlspecialchars($objWorkorder->subject));

                $Template->set_var('TXT_TITLE', $title);

                $hiddenvars = '';
                if ($isBatch)
                {
                        $hiddenvars .= GetHiddenVar('menuAction', 
'boTimecards.dbbatchadd');
                }
                elseif ($isEdit)
                {
                        $hiddenvars .= GetHiddenVar('menuAction', 
'ccs.boTimecards.dbmodify');
                        $hiddenvars .= GetHiddenVar('id', $obj->id);
                }
                else
                        $hiddenvars .= GetHiddenVar('menuAction', 
'ccs.boTimecards.dbadd');


                /*              if ($isBatch){
                        $objView = CreateObject('boView');
                        $objView->SetFromURL();
                        $hiddenvars .= $objView->GetForm();
                        reset($selected);
                        while (list($key, $val) = each($selected))
                                $hiddenvars .= GetHiddenVar('selected[]', $val);
                }
                 else */
                {
                        $hiddenvars .= GetHiddenVar('ccs', $ccs);
                        //      $hiddenvars .= GetHiddenVar('seq', $seq);
                }

                $Template->set_var('HIDDEN_VARS', $hiddenvars);

                $objStatuses = CreateObject('ccs.htmlStatuses');
                $objActions = CreateObject('ccs.htmlActions');
                $objPersonnel = CreateObject('ccs.htmlPersonnel');

                $Template->set_var('VAL_JSDATEFORMAT', GetJSDateFormat());
                $Template->set_var('TXT_DATE', "Date");
                $Template->set_var('TXT_BY', "TimeCard By");
                $Template->set_var('TXT_STATUS', "Status");
                $Template->set_var('TXT_ACTION', "Action");
                // $Template->set_var('TXT_HOURS', "STR_TC_HOURS");
                // $Template->set_var('TXT_ETC', "STR_TC_ETC");
                // $Template->set_var('TXT_VERSION', "STR_TC_VERSION");
                $Template->set_var('TXT_SUMMARY', "Summary");
                $Template->set_var('TXT_DESCRIPTION', "Description");
                $Template->set_var('TXT_HIGHLIGHTEDNOTE', "Highlighted Fields 
are Required");
                $Template->set_var('TXT_MODIFYNOTE', "STR_TC_MODIFYNOTE");
                $Template->set_var('TXT_ATTRIBUTENOTE', '');
                $Template->set_var('BTN_SAVE', "Save");
                $Template->set_var('BTN_RESET', "Reset");

                $Template->set_var('VAL_ETCHOURS', '');

                if ($isEdit)
                {
                        $Template->set_var('VAL_ACTIONON', $obj->actionon);
                        //$Template->set_var('VAL_HOURS', $obj->hours);
                        //$Template->set_var('VAL_REVISION', 
htmlspecialchars($obj->revision));
                        $Template->set_var('VAL_SUMMARY', 
htmlspecialchars($obj->summary));
                        $Template->set_var('VAL_DESCRIPTION', 
htmlspecialchars($obj->description));
                        $Template->set_var('CMB_ACTIONBY', 
$objPersonnel->GetCombo($obj->actionby, 'actionby', 'lastfirst', 0, false, 
$dcl_info['DCL_HAVE_WO']));
                        $Template->set_var('CMB_STATUS', 
$objStatuses->GetCombo($obj->status, 'status', 'name', 0, false, $setid));
                        $Template->set_var('CMB_ACTION', 
$objActions->GetCombo($obj->action, 'action', 'name', 0, false, $setid));

                        $Template->parse('hModify', 'modify');
                }
                else
                {
                        $Template->set_var('VAL_ACTIONON', 
date($dcl_info['DCL_DATE_FORMAT']));
                        $Template->set_var('VAL_HOURS', '');
                        $Template->set_var('VAL_REVISION', '');
                        $Template->set_var('VAL_SUMMARY', '');
                        $Template->set_var('VAL_DESCRIPTION', '');
                        $Template->set_var('CMB_ACTIONBY', 
$objPersonnel->GetCombo($GLOBALS['DCLID'], 'actionby', 'lastfirst', 0, true, 
$dcl_info['DCL_HAVE_WO']));
                        //for now default to current user dbtimecards will use 
current user as well any change here make there too!!!
                        
//$Template->set_var('CMB_ACTIONBY',$phpgw_info['user']['account_id']);
                        $Template->set_var('CMB_ACTION', 
$objActions->GetCombo(0, 'action', 'name', 0, true, $setid));


                        /*      if ($isBatch)
                        {
                                $Template->set_var('CMB_STATUS', 
$objStatuses->GetCombo(1, 'status', 'name', 0, true, $setid));
                                $Template->parse('hBatch', 'batch');
                        }
                         else */
                        $Template->set_var('CMB_STATUS', 
$objStatuses->GetCombo($objWorkorder->status, 'status', 'name', 0, true, 
$setid));
                }

                return $Template->parse('out', 'hForm');
        }
}

?>

====================================================
Index: class.htmlTimeCards.inc.php
<?php
/*
 * $Id: class.htmlTimeCards.inc.php,v 1.1 2005/05/05 00:56:39 skwashd Exp $
 *
 * Double Choco Latte - Source Configuration Management System
 * Copyright (C) 1999  Michael L. Dean & Tim R. Norman
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * Select License Info from the Help menu to view the terms and conditions of 
this license.
 */



class htmlTimeCards
{
        function PopulateActionLinks($include, $enclose, $id, $dark, 
&$linkArray, &$rolloverArray)
        {
                global $dcl_info;

                if ($GLOBALS['SEC'] >= $dcl_info['DCL_MOD_WO'] && ereg('m', 
$include))
                {
                        $linkName = 'M';

                        $linkArray[$linkName] = 
"index.php?menuAction=ccs.boTimecards.modify&id=$id";
                        $rolloverArray[$linkName] = 'Modify';
                }

                if ($GLOBALS['SEC'] >= $dcl_info['DCL_DEL_WO'] && ereg('x', 
$include))
                {
                        $linkName = 'X';

                        $linkArray[$linkName] = 
"index.php?menuAction=ccs.boTimecards.delete&id=$id";
                        $rolloverArray[$linkName] = 'Delete';
                }
        }

        function GetActionLinks($include, $enclose, $id, $dark)
        {
                $linkArray = array();
                $rolloverArray = array();
                $this->PopulateActionLinks($include, $enclose, $id, $dark, 
$linkArray, $rolloverArray);

                return GetLinkSet($linkArray, $rolloverArray, $enclose, $dark);
        }

        function PrintActionLinks($include, $enclose, $id, $dark)
        {
                $linkArray = array();
                $rolloverArray = array();
                $this->PopulateActionLinks($include, $enclose, $id, $dark, 
$linkArray, $rolloverArray);

                PrintLinkSet($linkArray, $rolloverArray, $enclose, $dark);
        }


        function GetTimeCards($ccs,  $editID = 0, $forDelete = false)
        {
                global $dcl_info,$phpgw, $phpgw_info;

                $retVal = '';
                $objTimeCard = CreateObject('ccs.dbTimeCards');
                if ($objTimeCard->GetTimeCards($ccs) != -1)
                {
                        $objPersonnel = CreateObject('ccs.dbPersonnel');
                        $objStatus = CreateObject('ccs.dbStatuses');
                        $objAction = CreateObject('ccs.dbActions');

                        $Template = 
CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('ccs'));
                        $Template->set_file(array('hForm' => 
'htmlTimeCardDetail.tpl'));
                        $Template->set_block('hForm', 'nodelete', 'hNodelete');
                        $Template->set_block('hForm', 'delete', 'hDelete');

                        $Template->set_var('hNodelete', '');
                        $Template->set_var('hDelete', '');
                        $Template->set_var('COLOR_DARK', 
$dcl_info['DCL_COLOR_DARK']);
                        $Template->set_var('COLOR_LIGHT', 
$dcl_info['DCL_COLOR_LIGHT']);
                        $Template->set_var('BTN_DELETE', 'Delete');
                        $Template->set_var('BTN_CANCEL', 'Cancel');

                        $Template->set_var('TXT_STATUS', 'Status');
                        $Template->set_var('TXT_VERSION', 'Version');
                        $Template->set_var('TXT_ACTION', 'Action');
                        $Template->set_var('TXT_HOURS', 'Hours');
                        $Template->set_var('TXT_DESCRIPTION', 'Description');

                        for ($i = 0; $i < $objTimeCard->db->num_rows(); $i++)
                        //while ($objTimeCard->db->next_record())
                        {
                                if (!$forDelete && $editID == $objTimeCard->id)
                                {
                                        $retVal .= '<tr><th align="left" 
colspan="2">';
                                        $oTCF = 
CreateObject('ccs.htmlTimeCardForm');
                                        $retVal .= 
$oTCF->GetForm($objTimeCard->ccs, $objTimeCard);
                                        $retVal .= '</th></tr>';
                                }
                                else
                                {
                                        
$objAccount=CreateObject('phpgwapi.accounts');
                                        
$objPersonnel->Load($objTimeCard->actionby);
                                        
$actionby=htmlspecialchars($objAccount->id2name($objPersonnel->phpgwid));

                                        $Template->set_var('TXT_TITLE', 'Action 
'.'('.$actionby .' '.$objTimeCard->actionon .') '.
                                                
htmlspecialchars($objTimeCard->summary));


                                        $Template->set_var('VAL_TIMECARDID', 
$objTimeCard->id);
                                        if (!$forDelete || $editID == 0)
                                        {
                                                
$Template->set_var('LNK_OPTIONS', $this->GetActionLinks('mx', true, 
$objTimeCard->id, false));
                                                $Template->parse('hNodelete', 
'nodelete');
                                        }
                                        else
                                                $Template->parse('hDelete', 
'delete');

                                        $objStatus->Load($objTimeCard->status);
                                        $objAction->Load($objTimeCard->action);

                                        $Template->set_var('VAL_STATUS', 
htmlspecialchars($objStatus->name));
                                        $Template->set_var('VAL_REVISION','');
                                        $Template->set_var('VAL_ACTION', 
htmlspecialchars($objAction->name));
                                        $Template->set_var('VAL_HOURS', '');
                                        $Template->set_var('VAL_DESCRIPTION', 
nl2br(htmlspecialchars($objTimeCard->description)));

                                        $retVal .= $Template->parse('out', 
'hForm');
                                }

                                $objTimeCard->db->next_record();
                                $objTimeCard->GetRow();
                        }
                }

                return $retVal;
        }
}

?>

====================================================
Index: functions.inc.php
<?php
include 'inc/dcl_vars.php';
include 'inc/functions.php';
include 'inc/ccsDb.php';
?>

====================================================
Index: dcl_vars.php
<?php
/*! set some variables so i can make use of DCL stuff until they
 have an API worked out
*/
$dcl_info['DCL_TIMESTAMP_FORMAT_DB'] = 'Y-m-d H:i:s';
$dcl_info['DCL_TIMESTAMP_FORMAT'] = 'Y/m/d H:i:s';
$dcl_info['DCL_DATE_FORMAT_DB'] = 'Y-m-d';
$dcl_info['DCL_DATE_FORMAT'] = 'd/m/Y';
$dcl_info['DCL_COLOR_DARK'] = '#737b9c';
$dcl_info['DCL_COLOR_LIGHT'] = '#eeeef8';
$dcl_info['DCL_TIME_CARD_ORDER'] = 'ASC';

?>

====================================================
Index: datefunctions.php
<?php

class Timestamp
{
        var $time;
        var $dbFormat;
        var $dbFormatEx;

        function Timestamp()
        {
                global $dcl_info;

                $this->time = 0;
                $this->SetDBFormat($dcl_info['DCL_TIMESTAMP_FORMAT_DB']);
        }

        function SetDBFormat($fmtString)
        {
                $this->dbFormat = $fmtString;
                $this->dbFormatEx = str_replace('m', 'MM', $this->dbFormat);
                $this->dbFormatEx = str_replace('d', 'DD', $this->dbFormatEx);
                $this->dbFormatEx = str_replace('Y', 'YYYY', $this->dbFormatEx);
                $this->dbFormatEx = str_replace('H', 'HH', $this->dbFormatEx);
                $this->dbFormatEx = str_replace('i', 'II', $this->dbFormatEx);
                $this->dbFormatEx = str_replace('s', 'SS', $this->dbFormatEx);
        }

        // Returns the database representation of the timestamp
        function ToDB()
        {
                return date($this->dbFormat, $this->time);
        }

        // Returns the display representation of the timestamp
        function ToDisplay()
        {
                global $dcl_info;

                return date($dcl_info['DCL_TIMESTAMP_FORMAT'], $this->time);
        }

        // Returns the timestamp as UNIX time
        function ToInt()
        {
                return $this->time;
        }

        //sets the timestamp from database string
        function SetFromDB($s)
        {
                $this->time = mktime(
                                substr($s, strpos($this->dbFormatEx, 'H'), 2),  
// hour
                                substr($s, strpos($this->dbFormatEx, 'I'), 2),  
// minute
                                substr($s, strpos($this->dbFormatEx, 'S'), 2),  
// second
                                substr($s, strpos($this->dbFormatEx, 'M'), 2),  
// month
                                substr($s, strpos($this->dbFormatEx, 'D'), 2),  
// day
                                substr($s, strpos($this->dbFormatEx, 'Y'), 4)); 
// year

        }

        // sets the timestamp from display/web string
        // Date order is based on the date format string,
        // single separators (any character goes!) are ignored
        function SetFromDisplay($s)
        {
                global $dcl_info;

                        // Create ereg string for date based on DCL_DATE_FORMAT
                $eregStr = str_replace('m', '([0-9]{2})', 
$dcl_info['DCL_DATE_FORMAT']);
                $eregStr = str_replace('d', '([0-9]{2})', $eregStr);
                $eregStr = str_replace('Y', '([0-9]{4})', $eregStr);
            // Check for full timestamp
                if(ereg('^' . $eregStr . ' ([0-9]{2}).([0-9]{2}).([0-9]{2})$', 
$s, $dateParts))
                {
                // Got full timestamp
                // Processing will be performed
                }
                else if(ereg('^' . $eregStr . '$', $s, $dateParts))
                        {
                        // Got just a date
                    // Initialize time values to zeroes
                                $dateParts[6] = $dateParts[5] = $dateParts[4] = 
0;
                        }
                        else
                        {
                                        // Date will be unchanged if the 
parsing didn't succeed
                                return;
                }

                        // Parse input string based on format string
                $configFmt = $dcl_info['DCL_DATE_FORMAT'];
                for($i = 0, $j = 1; $i < strlen($configFmt); $i++)
                {
                        switch($configFmt[$i])
                        {
                                case 'Y':
                                        $year = $dateParts[$j];
                                        $j++;
                                        break;
                                case 'm':
                                        $month = $dateParts[$j];
                                        $j++;
                                        break;
                                case 'd':
                                        $day = $dateParts[$j];
                                        $j++;
                                        break;
                                default:
                                        break;
                        }
                }

                $this->time = mktime($dateParts[4], $dateParts[5], 
$dateParts[6], $month, $day, $year);
        }

        // sets the timestamp from UNIX time
        function SetFromInt($timestamp)
        {
                $this->time = $timestamp;
        }
}

class Date extends Timestamp
{
        function Date()
        {
                global $dcl_info;

                $this->time = 0;
                $this->SetDBFormat($dcl_info['DCL_DATE_FORMAT_DB']);
        }

        function ToDisplay()
        {
                global $dcl_info;
                return date($dcl_info['DCL_DATE_FORMAT'], $this->time);
        }

        function ToDB()
        {
                return date($this->dbFormat, $this->time);
        }

        function SetFromDB($s)
        {
                $this->time = mktime(
                                0,
                                0,
                                0,
                                substr($s, strpos($this->dbFormatEx, 'M'), 2),
                                substr($s, strpos($this->dbFormatEx, 'D'), 2),
                                substr($s, strpos($this->dbFormatEx, 'Y'), 4));
        }
}
?>

====================================================
Index: class.htmlCCSForm.inc.php
<?php

class htmlCCSForm
{
        function Show($id = 0, $objccs='')
        {
                global $phpgw;

                $isEdit = is_object($objccs);  // maybe dont' need this just 
check if $id=0

                $t = 
CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('ccs'));
                $t->set_file(array('form_t' => 'form.tpl'));
                if ($id == 0 )
                {
                        $t->set_var('FORM_TITLE','Add new document 
information');
                        $hiddenvars = '<input type="hidden" name="menuAction" 
value="ccs.boCCS.dbnew">';
                        $t->set_var('SUBJECT','');
                        $t->set_var('DETAIL','');
                        //      $t->set_var('ISSUEDATE','');
                }  //if
                else
                {
                        $t->set_var('FORM_TITLE','Modify document information');
                        $hiddenvars = '<input type="hidden" name="menuAction" 
value="ccs.boCCS.dbmodify">'. "\n";
                        $hiddenvars .= '<input type="hidden" name="id" value="' 
. $objccs->id . '">' . "\n";
                        $t->set_var('SUBJECT',$objccs->subject);
                        $t->set_var('DETAIL',$objccs->detail);
                        $t->set_var('ID',$objccs->id);
                        // $t->set_var('ISSUEDATE',$objccs->issuedate);
                }

                $t->set_var('ACTION_URL',$phpgw->link('/ccs/index.php'));
                $t->set_var('HIDDEN_VARS',$hiddenvars);
                $t->set_var('VAL_JSDATEFORMAT',GetJSDateFormat());
                $t->set_var('SAVE_BTN','Save');
                $t->parse('out','form_t');
                $t->p('out');
        }
}



?>

====================================================
Index: class.htmlCCSDetail.inc.php
<?php

class htmlCCSDetail
{
        function Show($ccs, $editTimeCardID=0, $forDelete=false)
        {
                global $phpgw,$dcl_info, $phpgw_info;

                $objDb = CreateObject('ccs.dbCCS');
                $objDb->Load($ccs);

                $Template = 
CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('ccs'));
                $Template->set_file(array('hForm' => 'htmlCCSDetail.tpl'));
                $Template->set_block('hForm', 'delete', 'hDelete');
                $Template->set_block('hForm', 'action', 'hAction');
                $Template->set_var('hAction', '');
                $Template->set_var('hNotes', '');
                $Template->set_var('hDelete', '');

                // Labels

                $Template->set_var('TXT_DETAILTITLE',"Customer Complaint 
Detail");
                $Template->set_var('COLOR_DARK', $dcl_info['DCL_COLOR_DARK']);
                $Template->set_var('COLOR_LIGHT', $dcl_info['DCL_COLOR_LIGHT']);
                $Template->set_var('ACTION_URL', 
$phpgw->link('/ccs/index.php'));
                $Template->set_var('TXT_DELETE', 'Delete');
                $Template->set_var('TXT_CANCEL', 'Cancel');
                $Template->set_var('ID', $objDb->ccs);

                if ($forDelete && $editTimeCardID == 0)
                        $Template->parse('hDelete', 'delete');
                else
                {

                        // Action
                        $obj = CreateObject('ccs.htmlCCS');
                        $Template->set_var('CMB_ACTION',
                                $obj->GetActionCombo('xet', $objDb->ccs)); //  
$objWorkOrder->jcn, $objWorkOrder->seq, false));
                        $Template->set_var('TXT_GO', "GO");
                        $Template->parse('hAction', 'action');
                }

                // Data

                $Template->set_var('VAL_ID', $objDb->ccs);
                $Template->set_var('VAL_OWNER', 
$phpgw->common->grab_owner_name($objDb->owner));
                $Template->set_var('VAL_OPENEDON', $objDb->openedon);
                $Template->set_var('VAL_STATUS',$objDb->status);
                
$Template->set_var('VAL_SUBJECT',htmlspecialchars($objDb->subject));
                
$Template->set_var('VAL_DETAIL',htmlspecialchars($objDb->detail));

                // Add any timecards into the mix

                $objTimeCards = CreateObject('ccs.htmlTimeCards');
                $Template->set_var('VAL_TIMECARDS', 
$objTimeCards->GetTimeCards($objDb->ccs, $editTimeCardID, $forDelete));




                $Template->pparse('out', 'hForm');
        }
}








?>

====================================================
Index: class.dbDepartments.inc.php
<?php
/*
 * $Id: class.dbDepartments.inc.php,v 1.1 2005/05/05 00:56:39 skwashd Exp $
 *
 * Double Choco Latte - Source Configuration Management System
 * Copyright (C) 1999  Michael L. Dean & Tim R. Norman
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * Select License Info from the Help menu to view the terms and conditions of 
this license.
 */

class dbDepartments extends ccsDb
{
        var $id;
        var $short;
        var $name;
        var $active;
        var $db;

        function dbDepartments()
        {
                global $phpgw;
            // Table Fields
                $this->fieldArray = array('id', 'short', 'name', 'active');

            // Foreign keys
                $this->foreignKeys = array('osims_personnel' => 'department');

                $this->cache = array();
                $this->cacheEnabled = true;

                $this->ccsDb();
                $this->db=$phpgw->db;
        }

        function Add()
        {
                $query = 'INSERT INTO osims_departments (';
                $query .= 'short,name,active)';
                $query .= ' VALUES (';
                $query .= '\'' . $this->DBAddSlashes($this->short) . '\',';
                $query .= '\'' . $this->DBAddSlashes($this->name) . '\',\'Y\')';

                if ($this->db->query($query) == -1)
                {
                        echo '<BR>' . sprintf(STR_DB_DEPTINSERTERR, $query) . 
'<BR>';
                }
        }

        function Edit()
        {
                $query = 'UPDATE osims_departments SET ';
                $query .= 'short=\'' . $this->DBAddSlashes($this->short) . 
'\',';
                $query .= 'name=\'' . $this->DBAddSlashes($this->name) . '\',';
                $query .= 'active=\'' . $this->active . '\'';
                $query .= ' WHERE id=' . $this->id;

                $this->db->query($query);
        }

        function Delete()
        {
                $query = 'DELETE FROM osims_departments WHERE id=' . $this->id;
                return $this->db->query($query);
        }

        function SetActive($active)
        {
                $isActive = 'N';
                if ($active)
                        $isActive = 'Y';

                $query = 'UPDATE osims_departments SET ';
                $query .= "active='$isActive'";
                $query .= ' WHERE id=' . $this->id;

                return $this->db->query($query);
        }

        function GetRow()
        {
                $this->id = $this->db->f('id');
                $this->short = trim($this->db->f('short'));
                $this->name = trim($this->db->f('name'));
                $this->active = $this->db->f('active');
        }

        function Load($id)
        {
                $this->Clear();
                $sql = "SELECT * FROM osims_departments WHERE id=$id";
                $this->db->query($sql,__LINE__,__FILE__);
                $this->db->next_record();
                return $this->GetRow();
        }

        function Clear()
        {
                $this->id = 0;
                $this->short = '';
                $this->name = '';
                $this->active = '';
        }
}

?>

====================================================
Index: class.dbCCS.inc.php
<?php


class dbCCS extends ccsDb
{
        var $ccs;
        var $owner;
        var $subject;
        var $detail;
        var $openedon;
        var $status;
        var $lastactionon;
        var $db;

        function dbCCS()
        {
                global $phpgw;
                $this->fieldArray = 
array('ccs','owner','subject','detail','openedon','status','lastactionon');
                $this->db=$phpgw->db;
                $this->ccsDb();
        }

        function Add()
        {
                global  $phpgw_info;
                $status=1; //has to be open
                $owner = $phpgw_info['user']['account_id'];
                $subject = $this->DBAddSlashes($this->subject);
                $detail = $this->DBAddSlashes($this->detail);
                $openedon = $this->GetDateSQL();
                $assignedto =   $status=1; //has to be open
                $owner = $phpgw_info['user']['account_id']; // default to 
person opening for now
                //      $issuedate = $this->DisplayToSQL($this->issuedate);
                $query .= "INSERT INTO osims_ccs 
(owner,subject,detail,openedon,status,assignedto) values 
('$owner','$subject','$detail','$openedon','$status','$assignedto')";
                $this->db->query($query,__LINE__,__FILE__);
        }

        function Delete($ccs)
        {
                 $this->db->transaction_begin();
                // nuke timecards first
                $query  ="DELETE FROM osims_timecards where ccs='$ccs'";
                $this->db->query($query,__LINE__,__FILE__);

                // Then fry the customer complaint records
                $query = "DELETE FROM osims_ccs where ccs='$ccs'";
                $this->db->query($query,__LINE__,__FILE__);

                 $this->db->transaction_commit();
        }

        function Load($ccs)
        {
                $sql = "SELECT * FROM osims_ccs WHERE ccs='$ccs'";
                $this->db->query($sql,__LINE__,__FILE__);
                $this->db->next_record();
                return $this->GetRow();
        }

        function GetRow()
        {
                $this->ccs = $this->db->f('ccs');
                $this->owner = $this->db->f('owner');
                $this->subject = $this->db->f('subject');
                $this->detail = $this->db->f('detail');
                $this->openedon = 
$this->FormatDateForDisplay($this->db->f('openedon'));
                $this->status = $this->db->f('status');
                $this->lastactionon = 
$this->FormatDateForDisplay($this->db->f('lastactionon'));
                //      
$this->issuedate=$this->FormatDateForDisplay($this->db->f('issuedate'));
        }

        function Edit()
        {       $ccs = $this->ccs;
                $detail = $this->DBAddSlashes($this->detail);
                $subject = $this->DBAddSlashes($this->subject);
                $status = $this->status;
                $lastactionon = $this->DisplayToSQL($this->lastactionon);
                $openedon = $this->DisplayToSQL($this->openedon);
                $query = "UPDATE osims_ccs SET 
subject='$subject',detail='$detail',status='$status', 
lastactionon=$lastactionon, openedon=$openedon WHERE ccs='$ccs'";
                $this->db->query($query,__LINE__,FILE__);
        }
}
?>

====================================================
Index: class.dbActions.inc.php
<?php
/*
 * $Id: class.dbActions.inc.php,v 1.1 2005/05/05 00:56:39 skwashd Exp $
 *
 * Double Choco Latte - Source Configuration Management System
 * Copyright (C) 1999  Michael L. Dean & Tim R. Norman
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * Select License Info from the Help menu to view the terms and conditions of 
this license.
 */


class dbActions extends ccsDb
{
        var $id;
        var $short;
        var $name;
        var $active;
        var $db;

        function dbActions()
        {
                global $phpgw;
            // Table Fields
                $this->fieldArray = array('id', 'short', 'name', 'active');

            // Foreign keys
                // $this->foreignKeys = array('timecards' => 'action');

                //      $this->cache = array();
                //$this->cacheEnabled = true;

                $this->db=$phpgw->db;
                $this->ccsDb();
        }

        function Add()
        {
                // $idSQL = $this->GetNewIDSQLForTable('actions');
                $query = 'INSERT INTO osims_actions (';
                $query .= 'short,name,active)';
                $query .= ' VALUES (';
                $query .= '\'' . $this->DBAddSlashes($this->short) . '\',';
                $query .= '\'' . $this->DBAddSlashes($this->name) . '\',\'Y\')';

                if ($this->db->query($query) == -1)
                {
                        echo '<BR>' . sprintf(STR_DB_ACTIONINSERTERR, $query) . 
'<BR>';
                }
        }

        function Edit()
        {
                $query = 'UPDATE osims_actions SET ';
                $query .= 'short=\'' . $this->DBAddSlashes($this->short) . 
'\',';
                $query .= 'name=\'' . $this->DBAddSlashes($this->name) . '\',';
                $query .= 'active=\'' . $this->active . '\'';
                $query .= ' WHERE id=' . $this->id;

                $this->db->query($query);
        }

        function Delete()
        {
                $query = 'DELETE FROM osims_actions WHERE id=' . $this->id;
                return $this->db->query($query);
        }

        function SetActive($active)
        {
                $isActive = 'N';
                if ($active)
                        $isActive = 'Y';

                $query = 'UPDATE osims_actions SET ';
                $query .= "active='$isActive'";
                $query .= ' WHERE id=' . $this->id;

                return $this->db->query($query);
        }

        function GetRow()
        {


                $this->id = $this->db->f('id');
                $this->short = trim($this->db->f('short'));
                $this->name = trim($this->db->f('name'));
                $this->active = $this->db->f('active');


        }

        function Load($id)
        {
                $this->Clear();


                $sql = "SELECT * FROM osims_actions WHERE id=$id";
                $this->db->query($sql);
                $this->db->next_record();
                return $this->GetRow();
        }

        function Clear()
        {
                $this->id = 0;
                $this->short = '';
                $this->name = '';
                $this->active = '';
        }
}

?>

====================================================
Index: class.dbPersonnel.inc.php
<?php
/*
 * $Id: class.dbPersonnel.inc.php,v 1.1 2005/05/05 00:56:39 skwashd Exp $
 *
 * Double Choco Latte - Source Configuration Management System
 * Copyright (C) 1999  Michael L. Dean & Tim R. Norman
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * Select License Info from the Help menu to view the terms and conditions of 
this license.
 */



class dbPersonnel extends ccsDb
{
        var $id;
        var $phpgwid;
        var $reportto;
        var $department;
        var $security;
        var $active;
        var $db;

        // Not real fields, but handy!
        var $lastNameFirst;
        var $firstNameLast;

        function dbPersonnel()
        {
                global $phpgw;
            // Table Fields
                $this->fieldArray = array('id', 'phpgwid',  'reportto',
                                'department',  'security', 'active','short');

            // Foreign Keys
                $this->foreignKeys = array(
                                'osims_timecards' => 'actionby',
                                //'osims_tickets' => array('responsible', 
'createdby', 'closedby'),
                                //'projects' => 'reportto',
                                'osims_personnel' => 'reportto');

                //$this->cache = array();
                // $this->cacheEnabled = true;
                $this->db=$phpgw->db;
                $this->ccsDb();
        }

        function Add()
        {
                $objAccount = CreateObject('phpgwapi.accounts');
                $this->phpgwid=$objAccount->name2id($GLOBALS['short']);
                $query = 'INSERT INTO osims_personnel (';
                $query .= 'phpgwid,reportto,department,security,active)';
                $query .= ' VALUES (';
                $query .= $this->phpgwid . ',';
                $query .= $this->reportto . ',';
                $query .= $this->department . ',';
                $query .= $this->security . ',';
                $query .= '\'Y\')';

                if ($this->db->query($query) == -1)
                {
                        echo '<BR>' . sprintf(STR_DB_USERINSERTERR, $query) . 
'<BR>';
                }
        }

        function Edit()
        {
                // NOTE: pwd should not be edited from here.
                $objAccount=CreateObject('phpgwapi.accounts');
                $this->phpgwid=$objAccount->name2id($GLOBALS['short']);
                $query = 'UPDATE osims_personnel SET ';
                $query .= 'phpgwid=' . $this->phpgwid . ',';
                $query .= 'reportto=' . $this->reportto . ',';
                $query .= 'department=' . $this->department . ',';
                $query .= 'security=' . $this->security . ',';
                $query .= 'active=\'' . $this->active . '\'';
                $query .= ' WHERE id=' . $this->id;

                $this->db->query($query);
        }

        function Delete()
        {
                $query = 'DELETE FROM osims_personnel WHERE id=' . $this->id;
                return $this->db->query($query);
        }

        function SetActive($active)
        {
                $isActive = 'N';
                if ($active)
                        $isActive = 'Y';

                $query = 'UPDATE osims_personnel SET ';
                $query .= "active='$isActive'";
                $query .= ' WHERE id=' . $this->id;

                return $this->db->query($query);
        }

        function InitFromGlobals()
        {
                while (list($key, $field) = each($this->fieldArray))
                {
                        if (IsSet($GLOBALS[$field]))
                                $this->$field = 
$this->GPCStripSlashes($GLOBALS[$field]);
                }

            // Fill in our convenience fields

        }

        function GetRow()
        {

                while($this->db->next_record() )
                {
                        $this->id = $this->db->f('id');
                        $this->phpgwid = $this->db->f('phpgwid');
                        $this->reportto = $this->db->f('reportto');
                        $this->department = $this->db->f('department');
                        $this->security = $this->db->f('security');
                        $this->active = $this->db->f('active');

                // Fill in our convenience fields

                        //      if ($this->cacheEnabled)
                        //$this->CacheRow($this->id);
                        //      }
                        //else
                        //$this->Clear();
                }
        }

        function Load($id)
        {
                $this->Clear();

                        //      if ($this->cacheEnabled && 
$this->LoadCache($id) != -1)
                        //      {
                // Fill in our convenience fields
                        //$this->lastNameFirst = $this->lastname . ', ' . 
$this->firstname;
                        //$this->firstNameLast = $this->firstname . ' ' . 
$this->lastname;

                        //      return 0;
                        //}



                $sql = "SELECT * FROM osims_personnel WHERE id=$id";
                if (!$this->db->query($sql))
                        return -1;

                return $this->GetRow();
        }

        function Clear()
        {
                $this->id = 0;
                $this->phpgwid = '0';
                $this->reportto = 0;
                $this->department = 0;
                $this->security = 0;
                $this->active = '';
        }

        function IsPasswordOK($userID, $password)
        {
                $this->Load($userID);
                if (md5($password) == $this->pwd)
                        return true;
                else
                        return false;
        }

        function ChangePassword($userID, $oldPassword, $newPassword, 
$confirmPassword)
        {

                if ($GLOBALS['DCLID'] > 1)
                {
                        if ($this->IsPasswordOK($userID, $oldPassword) == false)
                        {
                                print(STR_DB_WRONGPWD);
                                $objPersonnel = 
CreateObject('ccs.htmlPersonnel');
                                $objPersonnel->DisplayPasswdForm();
                                return;
                        }
                }

                $query = 'UPDATE osims_personnel SET pwd=\'' . 
md5($newPassword) . '\' WHERE id=' . $userID;
                $this->Execute($query);
                echo '<CENTER>' . STR_DB_PWDCHGSUCCESS . '</CENTER>';
        }

        function Encrypt()
        {
                $this->pwd = md5($this->pwd);
        }
}
?>

====================================================
Index: class.dbStatuses.inc.php
<?php
/*
 * $Id: class.dbStatuses.inc.php,v 1.1 2005/05/05 00:56:39 skwashd Exp $
 *
 * Double Choco Latte - Source Configuration Management System
 * Copyright (C) 1999  Michael L. Dean & Tim R. Norman
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * Select License Info from the Help menu to view the terms and conditions of 
this license.
 */


class dbStatuses extends ccsDb
{
        var $id;
        var $short;
        var $name;
        var $active;
        var $db;

        function dbStatuses()
        {
                global $phpgw;
            //Table Fields
                $this->fieldArray = array('id', 'short', 'name', 'active');

            // Foreign keys
                $this->foreignKeys = array(
                                'workorders' => 'status',
                                'timecards' => 'status',
                                'projects' => 'status',
                                'tickets' => 'status',
                                'ticketresolutions' => 'status');

                // $this->cache = array();
                // $this->cacheEnabled = true;
                $this->db=$phpgw->db;
                $this->ccsDb();
        }

        function Add()
        {
                $query = 'INSERT INTO osims_statuses (';
                $query .= 'short,name,active)';
                $query .= ' VALUES (';
                $query .= '\'' . $this->DBAddSlashes($this->short) . '\',';
                $query .= '\'' . $this->DBAddSlashes($this->name) . '\',\'Y\')';

                $this->db->query($query);


        }

        function Edit()
        {
                $query = 'UPDATE osims_statuses SET ';
                $query .= 'short=\'' . $this->DBAddSlashes($this->short) . 
'\',';
                $query .= 'name=\'' . $this->DBAddSlashes($this->name) . '\',';
                $query .= 'active=\'' . $this->active . '\'';
                $query .= ' WHERE id=' . $this->id;

                $this->db->query($query);
        }

        function Delete()
        {
                $query = 'DELETE FROM osims_statuses WHERE id=' . $this->id;
                return $this->db->query($query);
        }

        function SetActive($active)
        {
                $isActive = 'N';
                if ($active)
                        $isActive = 'Y';

                $query = 'UPDATE osims_statuses SET ';
                $query .= "active='$isActive'";
                $query .= ' WHERE id=' . $this->id;

                return $this->db->query($query);
        }

        function GetRow()
        {
                $this->id = $this->db->f('id');
                $this->short = trim($this->db->f('short'));
                $this->name = trim($this->db->f('name'));
                $this->active = $this->db->f('active');
        }



        function Load($id)
        {
                $this->Clear();

                $sql = "SELECT * FROM osims_statuses WHERE id=$id";
                $this->db->query($sql,__LINE__,__FILE__);
                $this->db->next_record();
                return $this->GetRow();

        }

        function Clear()
        {
                $this->id = 0;
                $this->short = '';
                $this->name = '';
                $this->active = '';
        }
}

?>

====================================================
Index: class.htmlActions.inc.php
<?php
/*
 * $Id: class.htmlActions.inc.php,v 1.1 2005/05/05 00:56:39 skwashd Exp $
 *
 * Double Choco Latte - Source Configuration Management System
 * Copyright (C) 1999  Michael L. Dean & Tim R. Norman
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * Select License Info from the Help menu to view the terms and conditions of 
this license.
 */



class htmlActions
{
        function createCombo($default = 0, $cbName = 'action', $longShort = 
'name', $size = 0, $activeOnly = true, $setid = 0)
        {
                print $this->GetCombo($default, $cbName, $longShort, $size, 
$activeOnly, $setid);
        }

        function GetCombo($default = 0, $cbName = 'action', $longShort = 
'name', $size = 0, $activeOnly = true, $setid = 0)
        {
                $objDBActions = CreateObject('ccs.dbActions');
                // $objDBActions->Connect();
                // $objDBActions->cacheEnabled = false;

                $query = "SELECT a.id,a.$longShort FROM osims_actions a ";

                /*      if ($setid > 0)
                {
                        $query .= ",attributesetsmap b WHERE a.id=b.keyid AND 
b.typeid=1 AND b.setid=$setid ";
                        if ($activeOnly)
                                $query .= ' AND a.active=\'Y\' ';
                }
                else
                {
                        if ($activeOnly)
                                $query .= 'WHERE a.active=\'Y\' ';
                }*/

                $query .= "ORDER BY $longShort";
                $objDBActions->db->query($query);

                $str = "<select name=\"$cbName";
                if ($size > 0)
                        $str .= '[]" multiple size="' . $size;

                $str .= '">';
                if ($size == 0)
                        $str .= '<option value="0"> Select One </option>';

                while ($objDBActions->db->next_record() )
                {
                        $id = $objDBActions->db->f('id');
                        $text = $objDBActions->db->f('name');
                        $str .= "<option value=\"$id\"";
                        if ($id == $default)
                                $str .= ' selected';
                        $str .= '>' . $text . '</option>';
                //if ($objDBActions->db->next_record() == -1)
                // break;
                }

                $str .= '</select>';

                return $str;
        }

        function PrintAll($orderBy = 'name')
        {
                global $dcl_info;

                $objDBActions = CreateObject('ccs.dbActions');
                // $objDBActions->Connect();

                $objDBActions->Query("SELECT id,active,short,name FROM 
osims_actions ORDER BY $orderBy");
                $allRecs = $objDBActions->FetchAllRows();

                if ($GLOBALS['SEC'] >= $dcl_info['DCL_ADD_USER'])
                        $titleLink = '<a class="alight" 
href="index.php?menuAction=boActions.add">[ New ]</a>';
                else
                        $titleLink = '';

                if (is_array($allRecs))
                {
                        $allName = array(
                                        0 => STR_ACTN_ID,
                                        1 => STR_ACTN_ACTIVEABB,
                                        2 => STR_ACTN_SHORT,
                                        3 => STR_ACTN_NAME);

                        if (count($allRecs) > 0 && $GLOBALS['SEC'] >= 
$dcl_info['DCL_ADD_USER'])
                        {
                                $allName[] = STR_ACTN_OPTIONS;
                                for ($i = 0; $i < count($allRecs); $i++)
                                {
                                        $options = '<a class="adark" 
href="index.php?menuAction=boActions.modify&id=' . $allRecs[$i][0] . '">' . 
STR_CMMN_EDIT . '</a>';
                                        $options .= '&nbsp;';
                                        $options .= '<a class="adark" 
href="index.php?menuAction=boActions.delete&id=' . $allRecs[$i][0] . '">' . 
STR_CMMN_DELETE . '</a>';
                                        $allRecs[$i][] = $options;
                                }
                        }
                        PrintArrayAsChocoTable($allName, $allRecs, 
sprintf(STR_ACTN_TABLETITLE, $orderBy), '', $titleLink);
                }
                else
                {
                        print('<CENTER>');
                        PrintWithChocoFont(STR_ACTN_NOACTIONS . '&nbsp;&nbsp;' 
. $titleLink);
                        print('</CENTER>');
                }
        }

        function ShowEntryForm($obj = '')
        {
                global $dcl_info;

                $isEdit = is_object($obj);
                $Template = CreateTemplate(array('hForm' => 
'htmlActionsForm.tpl'));
                $Template->set_var('COLOR_DARK', $dcl_info['DCL_COLOR_DARK']);
                $Template->set_var('COLOR_LIGHT', $dcl_info['DCL_COLOR_LIGHT']);

                $hidden_vars = '';
                if ($isEdit)
                {
                        $Template->set_var('TXT_FUNCTION', STR_ACTN_EDIT);
                        $hidden_vars .= '<input type="hidden" name="menuAction" 
value="ccs.boActions.dbmodify">';
                        $hidden_vars .= '<input type="hidden" name="id" 
value="' . $GLOBALS['id'] . '">';
                }
                else
                {
                        $Template->set_var('TXT_FUNCTION', STR_ACTN_ADD);
                        $hidden_vars .= '<input type="hidden" name="menuAction" 
value="ccs.boActions.dbadd">';
                }

                $Template->set_var('HIDDEN_VARS', $hidden_vars);

                        // Labels
                $Template->set_var('TXT_ACTIVE', STR_ACTN_ACTIVE);
                $Template->set_var('TXT_SHORT', STR_ACTN_SHORT);
                $Template->set_var('TXT_NAME', STR_ACTN_NAME);
                $Template->set_var('BTN_OK', STR_CMMN_SAVE);
                $Template->set_var('BTN_RESET', STR_CMMN_RESET);
                $Template->set_var('TXT_HIGHLIGHTEDNOTE', 
STR_ACTN_HIGHLIGHTEDNOTE);
                $Template->set_var('TXT_ATTRIBUTESNOTE', 
STR_ACTN_ATTRIBUTENOTE);

                        // Data
                if ($isEdit)
                {
                        $Template->set_var('CMB_ACTIVE', 
GetYesNoCombo($obj->active, 'active', 0, false));
                        $Template->set_var('VAL_SHORT', $obj->short);
                        $Template->set_var('VAL_NAME', $obj->name);
                }
                else
                {
                        $Template->set_var('CMB_ACTIVE', GetYesNoCombo('Y', 
'active', 0, false));
                        $Template->set_var('VAL_SHORT', '');
                        $Template->set_var('VAL_NAME', '');
                }

                $Template->pparse('out', 'hForm');
        }
}

?>

====================================================
Index: class.dbTimeCards.inc.php
<?php
/*
 * $Id: class.dbTimeCards.inc.php,v 1.1 2005/05/05 00:56:39 skwashd Exp $
 *
 * Double Choco Latte - Source Configuration Management System
 * Copyright (C) 1999  Michael L. Dean & Tim R. Norman
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * Select License Info from the Help menu to view the terms and conditions of 
this license.
 */



class dbTimeCards extends ccsDb
{
        var $id;
        var $ccs;
        var $actionon;
        var $inputon;
        var $actionby;
        var $status;
        var $action;
        var $summary;
        var $description;
        var $revision;
        var $db;

        function dbTimeCards()
        {       global $phpgw;
                        // Table Fields
                $this->fieldArray = array('id', 'ccs', 'actionon', 'inputon', 
'actionby',
                                'status', 'action', 'summary', 'description');

                        // Foreign Keys
                //      $this->foreignKeys = array();

                //$this->cacheEnabled = false;
                $this->db=$phpgw->db;
                $this->ccsDb();
        }

        function Add()
        {
                global $dcl_info, $phpgw_info;


                $objCCS = CreateObject('ccs.dbCCS');
                $objCCS->Load($this->ccs);


        // who needs error checking ???

                        //if ($objWO->Load($this->ccs) == -1)
                        //      {
                        //printf(STR_DB_WORKORDERLOADERR, $this->jcn, 
$this->seq);
                        //return;
                        //      }

                $currstatus = $objCCS->status;

                $justStarted = $objCCS->db->f('starton')==NULL;

                // init some variables

                $ccs = $this->ccs;
                $actionon = $this->DisplayToSQL($this->actionon);
                $inputon = $this->GetDateSQL();
                $actionby = $this->actionby;
                $status = $this->status;
                $action = $this->action;
                $summary = $this->DBAddSlashes($this->summary);
                $description = $this->DBAddSlashes($this->description);


                $query = "INSERT INTO osims_timecards (";
                $query .="ccs,actionon,inputon,actionby,";
                $query .="status,action,summary,description";
                $query .=") VALUES (";
                $query 
.="'$ccs',$actionon,'$inputon','$actionby','$status','$action','$summary','$description'";
                $query .= ")";
                $objCCS->lastactionon = date($dcl_info['DCL_TIMESTAMP_FORMAT']);

                if ($currstatus != $this->status)
                {
                        $objCCS->status = $this->status;
                        $objCCS->statuson = 
date($dcl_info['DCL_TIMESTAMP_FORMAT']);
                        if ($this->status == 2 && $currstatus != 2)
                        {
                                $objCSS->closedby = $this->actionby;
                                $objCCS->closedon = $this->actionon;
                        }
                        else if ($currstatus == 2)
                                {
                                        $objCCS->closedby = 0;
                                        $objCCS->closedon = '';
                                }
                }
                        // ensure the etc hours do not get anything but zero 
when closed
                //if ($objWO->status == 2)
                //$objWO->etchours = 0.0;
                if ($justStarted == 1)
                        $objCCS->starton = $this->actionon;

                //      $this->BeginTransaction();
                $this->db->query($query,__LINE__,__FILE__);
                $objCCS->Edit();
                // $this->EndTransaction();
        }

        function Edit()
        {
                $query = 'UPDATE osims_timecards SET actionon=' . 
$this->DisplayToSQL($this->actionon);
                $query .= ',actionby=' . $this->actionby . ',status=' . 
$this->status . ',action=';
                $query .= $this->action .  ',summary=\'' . 
$this->DBAddSlashes($this->summary);
                $query .= '\',description=\'' . 
$this->DBAddSlashes($this->description) . '\' ';
                $query .= ' WHERE id=' . $this->id;

                $this->db->query($query);
        }

        function Delete()
        {
                $query = sprintf('DELETE FROM osims_timecards WHERE id=%d', 
$this->id);
                $this->db->query($query);
        }

        function GetRow()
        {


                $this->id = $this->db->f('id');
                $this->ccs = $this->db->f('ccs');
                $this->actionon = 
$this->FormatDateForDisplay($this->db->f('actionon'));
                $this->inputon = 
$this->FormatTimeStampForDisplay($this->db->f('inputon'));
                $this->actionby = $this->db->f('actionby');
                $this->status = $this->db->f('status');
                $this->action = $this->db->f('action');
                $this->summary = $this->db->f('summary');
                $this->description = $this->db->f('description');

                return 0;
        }

        function Load($id)
        {
                $this->Clear();



                $sql = "SELECT * FROM osims_timecards WHERE id=$id";
                //if (!$this->db->query($sql))
                //return -1;
                $this->db->query($sql);
                $this->db->next_record();
                return $this->GetRow();
        }

        function Clear()
        {
                $this->id = 0;
                $this->ccs = 0;
                $this->actionon = '';
                $this->inputon = '';
                $this->actionby = 0;
                $this->status = 0;
                $this->action = 0;
                $this->summary = '';
                $this->description = '';
        }

        function GetTimeCards($ccs)
        {
                global $dcl_info;

                $this->Clear();


                $sql = "SELECT * FROM osims_timecards WHERE ccs=$ccs  ORDER BY 
id " . $dcl_info['DCL_TIME_CARD_ORDER'];

                if (!$this->db->query($sql))
                        return -1;
                $this->db->next_record();
                return $this->GetRow();
        }
}
?>

====================================================
Index: class.htmlCCS.inc.php
<?php


class htmlCCS
{
        function GetActionCombo($include, $ccs)
        {
                global $dcl_info;

                $cmbText = '<select name="menuAction">';
                $options = array();
                if (ereg('d', $include))
                        $options['ccs.boCCS.viewcc'] = "View";

                if  (ereg('x', $include))
                        $options['ccs.boCCS.delete'] = "Delete";

                if (ereg('e', $include))
                        $options['ccs.boCCS.modifycc']= "Edit";

                if (ereg('t', $include))
                        $options['ccs.boTimecards.add'] = "Add TimeCard";


                asort($options);
                reset($options);
                while (list($value, $text) = each($options))
                        $cmbText .= sprintf('<option value="%s">%s</option>', 
$value, $text);

                $cmbText .= '</select>';
                return $cmbText;
        }

        function ShowMainPage($start)
        {
                global $phpgw;
                $db=$phpgw->db;

                $t = 
CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('ccs'));
                $t->set_file(array('ccs_t' => 'list.tpl'));
                $t->set_block('ccs_t','ccs','list');
                $t->set_var('WELCOME','Customer Compaint System');

                if (! $start) { $start = 0; }

                $objccs = CreateObject('ccs.dbCCS');
                $sql = "SELECT * FROM osims_ccs"; // must build proper query 
here
                $objccs->db->query($sql,__LINE__,__FILE__);
                $total_records = $objccs->db->num_rows();
                $objccs->db->query($sql. " " . 
$objccs->db->limit($start),__LINE__,__FILE__);
                while ($objccs->db->next_record())
                {
                        $t->set_var('ID',$objccs->db->f('ccs'));
                        $t->set_var('SUBJECT',$objccs->db->f('subject'));
                        
$t->set_var('OWNER',$phpgw->common->grab_owner_name($objccs->db->f('owner')));
                        //      
$t->set_var('EDIT',$phpgw->link('/ccs/index.php','menuAction=ccs.boCCS.modifycc'.'&ccs='
 . $objccs->db->f('id')));
                        
$t->set_var('VIEW',$phpgw->link('/ccs/index.php','menuAction=ccs.boCCS.viewcc'.'&ccs='
 . $objccs->db->f('ccs')));
                        //      
$t->set_var('DELETE',$phpgw->link('/ccs/index.php','menuAction=ccs.boCCS.dbdelete'.'&ccs='
 . $objccs->db->f('id')));
                        $tr_color = 
$phpgw->nextmatchs->alternate_row_color($tr_color);
                        $t->set_var('TR_COLOR',$tr_color);
                        $t->parse('list','ccs',True);
                }; //while

                //  nextmatchs stuff this gives the neat little arrows
                $left = 
$phpgw->nextmatchs->left('/ccs/index.php',$start,$total_records);
                $right = 
$phpgw->nextmatchs->right('/ccs/index.php',$start,$total_records);
                $t->set_var('LEFT',$left);
                $t->set_var('RIGHT',$right);
                // end nextmatchs

                $t->set_var('ADD_BTN','Add');
                $t->set_var('ACTION_URL',$phpgw->link('/ccs/index.php'));

                $hiddenvars = '<input type="hidden" name="menuAction" 
value="ccs.boCCS.newcc">';
                $t->set_var('HIDDEN_VARS',$hiddenvars);

                $t->parse('out','ccs_t',True);
                $t->p('out');
        }
}
?>






reply via email to

[Prev in Thread] Current Thread [Next in Thread]