Logo Search packages:      
Sourcecode: dcl version File versions  Download package

class.htmlStatuses.inc.php

<?php
/*
 * $Id: class.htmlStatuses.inc.php,v 1.3.2.1.2.2 2003/11/11 05:50:04 mdean 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.
 */

LoadStringResource('stat');

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)
      {
            $query = "SELECT a.id,a.$longShort FROM statuses a ";

            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";

            $oSelect = CreateObject('dcl.htmlSelect');
            $oSelect->vDefault = $default;
            $oSelect->sName = $cbName;
            $oSelect->iSize = $size;
            $oSelect->sZeroOption = STR_CMMN_SELECTONE;
            $oSelect->SetFromQuery($query);

            return $oSelect->GetHTML();
      }

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

            if (!$GLOBALS['g_oSec']->HasSecLvl($GLOBALS['dcl_info']['DCL_ADD_USER']))
                  return PrintPermissionDenied();

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

            $objDBStatus->Query("SELECT a.id,a.active,a.short,a.name,b.dcl_status_type_name FROM statuses a,dcl_status_type b WHERE b.dcl_status_type_id=a.dcl_status_type ORDER BY a.$orderBy");
            $allRecs = $objDBStatus->FetchAllRows();

            $titleLink = '<a class="adark" href="' . menuLink('', 'menuAction=boStatuses.add') . '">' . STR_CMMN_NEW . '</a>';
            $titleLink .= '&nbsp;|&nbsp;';
            $titleLink .= '<a class="adark" href="' . menuLink('', 'menuAction=boAdmin.ShowSystemConfig') . '">' . DCL_MENU_SYSTEMSETUP . '</a>';

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

                  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="' . menuLink('', 'menuAction=boStatuses.modify&id=' . $allRecs[$i][0]) . '">' . STR_CMMN_EDIT . '</a>';
                              $options .= '&nbsp;|&nbsp;';
                              $options .= '<a class="adark" href="' . menuLink('', 'menuAction=boStatuses.delete&id=' . $allRecs[$i][0]) . '">' . STR_CMMN_DELETE . '</a>';
                              $allRecs[$i][] = $options;
                        }
                  }
                  PrintArrayAsChocoTable($allName, $allRecs, sprintf(STR_STAT_TABLETITLE, $orderBy), '', $titleLink);
            }
            else
            {
                  print('<center>');
                  print(STR_STAT_NOSTATS . '&nbsp;&nbsp;' . $titleLink);
                  print('</center>');
            }
      }

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

            if (!$GLOBALS['g_oSec']->HasSecLvl($GLOBALS['dcl_info']['DCL_ADD_USER']))
                  return PrintPermissionDenied();

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

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

            $Template->set_var('HIDDEN_VARS', $hidden_vars);
            $oSelect = CreateObject('dcl.htmlSelect');
            $oSelect->SetOptionsFromDb('dcl_status_type', 'dcl_status_type_id', 'dcl_status_type_name', '', $order = 'dcl_status_type_id');
            $oSelect->vDefault = 0;
            $oSelect->sName = 'dcl_status_type';
            $oSelect->sZeroOption = STR_CMMN_SELECTONE;

            // Labels
            $Template->set_var('TXT_ACTIVE', STR_STAT_ACTIVE);
            $Template->set_var('TXT_SHORT', STR_STAT_SHORT);
            $Template->set_var('TXT_NAME', STR_STAT_NAME);
            $Template->set_var('TXT_TYPE', STR_STAT_TYPE);
            $Template->set_var('BTN_OK', STR_CMMN_SAVE);
            $Template->set_var('BTN_RESET', STR_CMMN_RESET);
            $Template->set_var('TXT_HIGHLIGHTEDNOTE', STR_CMMN_HIGHLIGHTEDNOTE);
            $Template->set_var('TXT_ATTRIBUTESNOTE', STR_CMMN_ATTRIBUTENOTE);
            $Template->set_var('BTN_CANCEL', STR_CMMN_CANCEL);
            $Template->set_var('LNK_CANCEL', menuLink('', 'menuAction=boStatuses.showall'));

            // 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);
                  $oSelect->vDefault = $obj->dcl_status_type;
            }
            else
            {
                  $Template->set_var('CMB_ACTIVE', GetYesNoCombo('Y', 'active', 0, false));
                  $Template->set_var('VAL_SHORT', '');
                  $Template->set_var('VAL_NAME', '');
            }

            $Template->set_var('CMB_TYPE', $oSelect->GetHtml());
            $Template->pparse('out', 'hForm');
      }
}
?>

Generated by  Doxygen 1.6.0   Back to index