Location: PHPKode > projects > CoopWorks Farmers Association Management > CoopWorks 3.1/GL_YTD_TrialBalance.php
<?php
//Aworks.org/licence.html.  
// Produced by Webdiscount Technologies(Kenya) under Contract 
// No. KSL/CONSULT.GEN/1 with the The Kenya National Federation of Agricultural Producers(KENFAP) and in collaboration with Food and Agriculture Organization 
// of the United Nations (FAO),  Agriculturathe Ministry of 
// Co-operative Development and Marketing (Kenya) and piloted at Wamunyu Dairy Cooperative Society(Kenya) and Ololaiser Dairy Farmers Cooperative Society(Kenya).

//Include Common Files @1-CCAFBE82
define("RelativePath", ".");
define("PathToCurrentPage", "/");
define("FileName", "GL_YTD_TrialBalance.php");
include(RelativePath . "/Common.php");
include(RelativePath . "/Template.php");
include(RelativePath . "/Sorter.php");
include(RelativePath . "/Navigator.php");
include(RelativePath . "/sm_submenucontrol.php");
//End Include Common Files



class clsRecordglytdtbwrkSearch { //glytdtbwrkSearch Class @9-06B12C5C

//Variables @9-D6FF3E86

    // Public variables
    var $ComponentType = "Record";
    var $ComponentName;
    var $Parent;
    var $HTMLFormAction;
    var $PressedButton;
    var $Errors;
    var $ErrorBlock;
    var $FormSubmitted;
    var $FormEnctype;
    var $Visible;
    var $IsEmpty;

    var $CCSEvents = "";
    var $CCSEventResult;

    var $RelativePath = "";

    var $InsertAllowed = false;
    var $UpdateAllowed = false;
    var $DeleteAllowed = false;
    var $ReadAllowed   = false;
    var $EditMode      = false;
    var $ds;
    var $DataSource;
    var $ValidatingControls;
    var $Controls;
    var $Attributes;

    // Class variables
//End Variables

//Class_Initialize Event @9-7DF28A63
    function clsRecordglytdtbwrkSearch($RelativePath, & $Parent)
    {

        global $FileName;
        global $CCSLocales;
        global $DefaultDateFormat;
        $this->Visible = true;
        $this->Parent = & $Parent;
        $this->RelativePath = $RelativePath;
        $this->Errors = new clsErrors();
        $this->ErrorBlock = "Record glytdtbwrkSearch/Error";
        $this->ReadAllowed = true;
        if($this->Visible)
        {
            $this->ComponentName = "glytdtbwrkSearch";
            $this->Attributes = new clsAttributes($this->ComponentName . ":");
            $CCSForm = split(":", CCGetFromGet("ccsForm", ""), 2);
            if(sizeof($CCSForm) == 1)
                $CCSForm[1] = "";
            list($FormName, $FormMethod) = $CCSForm;
            $this->FormEnctype = "application/x-www-form-urlencoded";
            $this->FormSubmitted = ($FormName == $this->ComponentName);
            $Method = $this->FormSubmitted ? ccsPost : ccsGet;
            $this->Activity = & new clsControl(ccsListBox, "Activity", "Activity", ccsText, "", CCGetRequestParam("Activity", $Method, NULL), $this);
            $this->Activity->DSType = dsProcedure;
            $this->Activity->DataSource = new clsDBCoopWorksConn();
            $this->Activity->ds = & $this->Activity->DataSource;
            list($this->Activity->BoundColumn, $this->Activity->TextColumn, $this->Activity->DBFormat) = array("Sub", "description", "");
            $this->Activity->DataSource->SQL = "CALL SM_SubAcctList (" . ");";
            $this->rptformat = & new clsControl(ccsHidden, "rptformat", "rptformat", ccsText, "", CCGetRequestParam("rptformat", $Method, NULL), $this);
            $this->s_FiscalYear = & new clsControl(ccsTextBox, "s_FiscalYear", "s_FiscalYear", ccsInteger, "", CCGetRequestParam("s_FiscalYear", $Method, NULL), $this);
            $this->s_Period = & new clsControl(ccsListBox, "s_Period", "s_Period", ccsInteger, "", CCGetRequestParam("s_Period", $Method, NULL), $this);
            $this->s_Period->DSType = dsTable;
            $this->s_Period->DataSource = new clsDBCoopWorksConn();
            $this->s_Period->ds = & $this->s_Period->DataSource;
            $this->s_Period->DataSource->SQL = "SELECT * \n" .
"FROM months {SQL_Where} {SQL_OrderBy}";
            list($this->s_Period->BoundColumn, $this->s_Period->TextColumn, $this->s_Period->DBFormat) = array("MonthCode", "Descr", "");
            $this->Button_DoSearch = & new clsButton("Button_DoSearch", $Method, $this);
            if(!$this->FormSubmitted) {
                if(!is_array($this->rptformat->Value) && !strlen($this->rptformat->Value) && $this->rptformat->Value !== false)
                    $this->rptformat->SetText(TB);
                if(!is_array($this->s_FiscalYear->Value) && !strlen($this->s_FiscalYear->Value) && $this->s_FiscalYear->Value !== false)
                    $this->s_FiscalYear->SetText(2007);
            }
        }
    }
//End Class_Initialize Event

//Validate Method @9-47BB9E6C
    function Validate()
    {
        global $CCSLocales;
        $Validation = true;
        $Where = "";
        $Validation = ($this->Activity->Validate() && $Validation);
        $Validation = ($this->rptformat->Validate() && $Validation);
        $Validation = ($this->s_FiscalYear->Validate() && $Validation);
        $Validation = ($this->s_Period->Validate() && $Validation);
        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "OnValidate", $this);
        $Validation =  $Validation && ($this->Activity->Errors->Count() == 0);
        $Validation =  $Validation && ($this->rptformat->Errors->Count() == 0);
        $Validation =  $Validation && ($this->s_FiscalYear->Errors->Count() == 0);
        $Validation =  $Validation && ($this->s_Period->Errors->Count() == 0);
        return (($this->Errors->Count() == 0) && $Validation);
    }
//End Validate Method

//CheckErrors Method @9-590583B4
    function CheckErrors()
    {
        $errors = false;
        $errors = ($errors || $this->Activity->Errors->Count());
        $errors = ($errors || $this->rptformat->Errors->Count());
        $errors = ($errors || $this->s_FiscalYear->Errors->Count());
        $errors = ($errors || $this->s_Period->Errors->Count());
        $errors = ($errors || $this->Errors->Count());
        return $errors;
    }
//End CheckErrors Method

//MasterDetail @9-ED598703
function SetPrimaryKeys($keyArray)
{
    $this->PrimaryKeys = $keyArray;
}
function GetPrimaryKeys()
{
    return $this->PrimaryKeys;
}
function GetPrimaryKey($keyName)
{
    return $this->PrimaryKeys[$keyName];
}
//End MasterDetail

//Operation Method @9-E3EBCC66
    function Operation()
    {
        if(!$this->Visible)
            return;

        global $Redirect;
        global $FileName;

        if(!$this->FormSubmitted) {
            return;
        }

        if($this->FormSubmitted) {
            $this->PressedButton = "Button_DoSearch";
            if($this->Button_DoSearch->Pressed) {
                $this->PressedButton = "Button_DoSearch";
            }
        }
        $Redirect = "GL_YTD_TrialBalance.php";
        if($this->Validate()) {
            if($this->PressedButton == "Button_DoSearch") {
                $Redirect = "GL_YTD_TrialBalance.php" . "?" . CCMergeQueryStrings(CCGetQueryString("Form", array("Button_DoSearch", "Button_DoSearch_x", "Button_DoSearch_y")));
                if(!CCGetEvent($this->Button_DoSearch->CCSEvents, "OnClick", $this->Button_DoSearch)) {
                    $Redirect = "";
                }
            }
        } else {
            $Redirect = "";
        }
    }
//End Operation Method

//Show Method @9-75B33057
    function Show()
    {
        global $CCSUseAmp;
        global $Tpl;
        global $FileName;
        global $CCSLocales;
        $Error = "";

        if(!$this->Visible)
            return;

        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeSelect", $this);

        $this->Activity->Prepare();
        $this->s_Period->Prepare();

        $RecordBlock = "Record " . $this->ComponentName;
        $ParentPath = $Tpl->block_path;
        $Tpl->block_path = $ParentPath . "/" . $RecordBlock;
        $this->EditMode = $this->EditMode && $this->ReadAllowed;
        if (!$this->FormSubmitted) {
        }

        if($this->FormSubmitted || $this->CheckErrors()) {
            $Error = "";
            $Error = ComposeStrings($Error, $this->Activity->Errors->ToString());
            $Error = ComposeStrings($Error, $this->rptformat->Errors->ToString());
            $Error = ComposeStrings($Error, $this->s_FiscalYear->Errors->ToString());
            $Error = ComposeStrings($Error, $this->s_Period->Errors->ToString());
            $Error = ComposeStrings($Error, $this->Errors->ToString());
            $Tpl->SetVar("Error", $Error);
            $Tpl->Parse("Error", false);
        }
        $CCSForm = $this->EditMode ? $this->ComponentName . ":" . "Edit" : $this->ComponentName;
        $this->HTMLFormAction = $FileName . "?" . CCAddParam(CCGetQueryString("QueryString", ""), "ccsForm", $CCSForm);
        $Tpl->SetVar("Action", !$CCSUseAmp ? $this->HTMLFormAction : str_replace("&", "&amp;", $this->HTMLFormAction));
        $Tpl->SetVar("HTMLFormName", $this->ComponentName);
        $Tpl->SetVar("HTMLFormEnctype", $this->FormEnctype);

        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeShow", $this);
        $this->Attributes->Show();
        if(!$this->Visible) {
            $Tpl->block_path = $ParentPath;
            return;
        }

        $this->Activity->Show();
        $this->rptformat->Show();
        $this->s_FiscalYear->Show();
        $this->s_Period->Show();
        $this->Button_DoSearch->Show();
        $Tpl->parse();
        $Tpl->block_path = $ParentPath;
    }
//End Show Method

} //End glytdtbwrkSearch Class @9-FCB6E20C

//DEL  class clsGroupsCollectionReport1 {
//DEL      public $Groups;
//DEL      public $mPageCurrentHeaderIndex;
//DEL      public $mAcctCurrentHeaderIndex;
//DEL      public $PageSize;
//DEL      public $TotalPages = 0;
//DEL      public $TotalRows = 0;
//DEL      public $CurrentPageSize = 0;
//DEL      public $Pages;
//DEL      public $Parent;
//DEL      public $LastDetailIndex;
//DEL  
//DEL      function clsGroupsCollectionReport1(& $parent) {
//DEL          $this->Parent = & $parent;
//DEL          $this->Groups = array();
//DEL          $this->Pages  = array();
//DEL          $this->mAcctCurrentHeaderIndex = 1;
//DEL          $this->mReportTotalIndex = 0;
//DEL          $this->mPageTotalIndex = 1;
//DEL      }
//DEL  
//DEL      function & InitGroup() {
//DEL          $group = new clsReportGroupReport1($this->Parent);
//DEL          $group->RowNumber = $this->TotalRows + 1;
//DEL          $group->PageNumber = $this->TotalPages;
//DEL          $group->PageTotalIndex = $this->mPageCurrentHeaderIndex;
//DEL          $group->AcctTotalIndex = $this->mAcctCurrentHeaderIndex;
//DEL          return $group;
//DEL      }
//DEL  
//DEL      function RestoreValues() {
//DEL          $this->Parent->Acct->Value = $this->Parent->Acct->initialValue;
//DEL          $this->Parent->Accttype->Value = $this->Parent->Accttype->initialValue;
//DEL          $this->Parent->Sub->Value = $this->Parent->Sub->initialValue;
//DEL          $this->Parent->Descr->Value = $this->Parent->Descr->initialValue;
//DEL          $this->Parent->Opening->Value = $this->Parent->Opening->initialValue;
//DEL          $this->Parent->Dr->Value = $this->Parent->Dr->initialValue;
//DEL          $this->Parent->Cr->Value = $this->Parent->Cr->initialValue;
//DEL          $this->Parent->ClosingVal->Value = $this->Parent->ClosingVal->initialValue;
//DEL          $this->Parent->Sum_Opening->Value = $this->Parent->Sum_Opening->initialValue;
//DEL          $this->Parent->Sum_Dr->Value = $this->Parent->Sum_Dr->initialValue;
//DEL          $this->Parent->Sum_Cr->Value = $this->Parent->Sum_Cr->initialValue;
//DEL          $this->Parent->Sum_ClosingVal->Value = $this->Parent->Sum_ClosingVal->initialValue;
//DEL          $this->Parent->TotalSum_Opening->Value = $this->Parent->TotalSum_Opening->initialValue;
//DEL          $this->Parent->TotalSum_Dr->Value = $this->Parent->TotalSum_Dr->initialValue;
//DEL          $this->Parent->TotalSum_Cr->Value = $this->Parent->TotalSum_Cr->initialValue;
//DEL          $this->Parent->TotalSum_ClosingVal->Value = $this->Parent->TotalSum_ClosingVal->initialValue;
//DEL      }
//DEL  
//DEL      function OpenPage() {
//DEL          $this->TotalPages++;
//DEL          $Group = & $this->InitGroup();
//DEL          $this->Parent->Page_Header->CCSEventResult = CCGetEvent($this->Parent->Page_Header->CCSEvents, "OnInitialize", $this->Parent->Page_Header);
//DEL          if ($this->Parent->Page_Header->Visible)
//DEL              $this->CurrentPageSize = $this->CurrentPageSize + $this->Parent->Page_Header->Height;
//DEL          $Group->SetTotalControls("GetNextValue");
//DEL          $this->Parent->Page_Header->CCSEventResult = CCGetEvent($this->Parent->Page_Header->CCSEvents, "OnCalculate", $this->Parent->Page_Header);
//DEL          $Group->SetControls();
//DEL          $Group->Mode = 1;
//DEL          $Group->GroupType = "Page";
//DEL          $Group->PageTotalIndex = count($this->Groups);
//DEL          $this->mPageCurrentHeaderIndex = count($this->Groups);
//DEL          $this->Groups[] =  & $Group;
//DEL          $this->Pages[] =  count($this->Groups) == 2 ? 0 : count($this->Groups) - 1;
//DEL      }
//DEL  
//DEL      function OpenGroup($groupName) {
//DEL          $Group = "";
//DEL          $OpenFlag = false;
//DEL          if ($groupName == "Report") {
//DEL              $Group = & $this->InitGroup(true);
//DEL              $this->Parent->Report_Header->CCSEventResult = CCGetEvent($this->Parent->Report_Header->CCSEvents, "OnInitialize", $this->Parent->Report_Header);
//DEL              if ($this->Parent->Report_Header->Visible) 
//DEL                  $this->CurrentPageSize = $this->CurrentPageSize + $this->Parent->Report_Header->Height;
//DEL                  $Group->SetTotalControls("GetNextValue");
//DEL              $this->Parent->Report_Header->CCSEventResult = CCGetEvent($this->Parent->Report_Header->CCSEvents, "OnCalculate", $this->Parent->Report_Header);
//DEL              $Group->SetControls();
//DEL              $Group->Mode = 1;
//DEL              $Group->GroupType = "Report";
//DEL              $this->Groups[] = & $Group;
//DEL              $this->OpenPage();
//DEL          }
//DEL          if ($groupName == "Accttype") {
//DEL              $GroupAcct = & $this->InitGroup(true);
//DEL              $this->Parent->Acct_Header->CCSEventResult = CCGetEvent($this->Parent->Acct_Header->CCSEvents, "OnInitialize", $this->Parent->Acct_Header);
//DEL              if ($this->Parent->Page_Footer->Visible) 
//DEL                  $OverSize = $this->Parent->Acct_Header->Height + $this->Parent->Page_Footer->Height;
//DEL              else
//DEL                  $OverSize = $this->Parent->Acct_Header->Height;
//DEL              if (($this->PageSize > 0) and $this->Parent->Acct_Header->Visible and ($this->CurrentPageSize + $OverSize > $this->PageSize)) {
//DEL                  $this->ClosePage();
//DEL                  $this->OpenPage();
//DEL              }
//DEL              if ($this->Parent->Acct_Header->Visible)
//DEL                  $this->CurrentPageSize = $this->CurrentPageSize + $this->Parent->Acct_Header->Height;
//DEL                  $GroupAcct->SetTotalControls("GetNextValue");
//DEL              $this->Parent->Acct_Header->CCSEventResult = CCGetEvent($this->Parent->Acct_Header->CCSEvents, "OnCalculate", $this->Parent->Acct_Header);
//DEL              $GroupAcct->SetControls();
//DEL              $GroupAcct->Mode = 1;
//DEL              $GroupAcct->GroupType = "Acct";
//DEL              $this->mAcctCurrentHeaderIndex = count($this->Groups);
//DEL              $this->Groups[] = & $GroupAcct;
//DEL              $this->Parent->Sum_Opening->Reset();
//DEL              $this->Parent->Sum_Dr->Reset();
//DEL              $this->Parent->Sum_Cr->Reset();
//DEL              $this->Parent->Sum_ClosingVal->Reset();
//DEL          }
//DEL      }
//DEL  
//DEL      function ClosePage() {
//DEL          $Group = & $this->InitGroup();
//DEL          $this->Parent->Page_Footer->CCSEventResult = CCGetEvent($this->Parent->Page_Footer->CCSEvents, "OnInitialize", $this->Parent->Page_Footer);
//DEL          $Group->SetTotalControls("GetPrevValue");
//DEL          $Group->SyncWithHeader($this->Groups[$this->mPageCurrentHeaderIndex]);
//DEL          $this->Parent->Page_Footer->CCSEventResult = CCGetEvent($this->Parent->Page_Footer->CCSEvents, "OnCalculate", $this->Parent->Page_Footer);
//DEL          $Group->SetControls();
//DEL          $this->RestoreValues();
//DEL          $this->CurrentPageSize = 0;
//DEL          $Group->Mode = 2;
//DEL          $Group->GroupType = "Page";
//DEL          $this->Groups[] = & $Group;
//DEL      }
//DEL  
//DEL      function CloseGroup($groupName)
//DEL      {
//DEL          $Group = "";
//DEL          if ($groupName == "Report") {
//DEL              $Group = & $this->InitGroup(true);
//DEL              $this->Parent->Report_Footer->CCSEventResult = CCGetEvent($this->Parent->Report_Footer->CCSEvents, "OnInitialize", $this->Parent->Report_Footer);
//DEL              if ($this->Parent->Page_Footer->Visible) 
//DEL                  $OverSize = $this->Parent->Report_Footer->Height + $this->Parent->Page_Footer->Height;
//DEL              else
//DEL                  $OverSize = $this->Parent->Report_Footer->Height;
//DEL              if (($this->PageSize > 0) and $this->Parent->Report_Footer->Visible and ($this->CurrentPageSize + $OverSize > $this->PageSize)) {
//DEL                  $this->ClosePage();
//DEL                  $this->OpenPage();
//DEL              }
//DEL              $Group->SetTotalControls("GetPrevValue");
//DEL              $Group->SyncWithHeader($this->Groups[0]);
//DEL              if ($this->Parent->Report_Footer->Visible)
//DEL                  $this->CurrentPageSize = $this->CurrentPageSize + $this->Parent->Report_Footer->Height;
//DEL              $this->Parent->Report_Footer->CCSEventResult = CCGetEvent($this->Parent->Report_Footer->CCSEvents, "OnCalculate", $this->Parent->Report_Footer);
//DEL              $Group->SetControls();
//DEL              $this->RestoreValues();
//DEL              $Group->Mode = 2;
//DEL              $Group->GroupType = "Report";
//DEL              $this->Groups[] = & $Group;
//DEL              $this->ClosePage();
//DEL              return;
//DEL          }
//DEL          $GroupAcct = & $this->InitGroup(true);
//DEL          $this->Parent->Acct_Footer->CCSEventResult = CCGetEvent($this->Parent->Acct_Footer->CCSEvents, "OnInitialize", $this->Parent->Acct_Footer);
//DEL          if ($this->Parent->Page_Footer->Visible) 
//DEL              $OverSize = $this->Parent->Acct_Footer->Height + $this->Parent->Page_Footer->Height;
//DEL          else
//DEL              $OverSize = $this->Parent->Acct_Footer->Height;
//DEL          if (($this->PageSize > 0) and $this->Parent->Acct_Footer->Visible and ($this->CurrentPageSize + $OverSize > $this->PageSize)) {
//DEL              $this->ClosePage();
//DEL              $this->OpenPage();
//DEL          }
//DEL          $GroupAcct->SetTotalControls("GetPrevValue");
//DEL          $GroupAcct->SyncWithHeader($this->Groups[$this->mAcctCurrentHeaderIndex]);
//DEL          if ($this->Parent->Acct_Footer->Visible)
//DEL              $this->CurrentPageSize = $this->CurrentPageSize + $this->Parent->Acct_Footer->Height;
//DEL          $this->Parent->Acct_Footer->CCSEventResult = CCGetEvent($this->Parent->Acct_Footer->CCSEvents, "OnCalculate", $this->Parent->Acct_Footer);
//DEL          $GroupAcct->SetControls();
//DEL          $this->Parent->Sum_Opening->Reset();
//DEL          $this->Parent->Sum_Dr->Reset();
//DEL          $this->Parent->Sum_Cr->Reset();
//DEL          $this->Parent->Sum_ClosingVal->Reset();
//DEL          $this->RestoreValues();
//DEL          $GroupAcct->Mode = 2;
//DEL          $GroupAcct->GroupType ="Acct";
//DEL          $this->Groups[] = & $GroupAcct;
//DEL      }
//DEL  
//DEL      function AddItem()
//DEL      {
//DEL          $Group = & $this->InitGroup(true);
//DEL          $this->Parent->Detail->CCSEventResult = CCGetEvent($this->Parent->Detail->CCSEvents, "OnInitialize", $this->Parent->Detail);
//DEL          if ($this->Parent->Page_Footer->Visible) 
//DEL              $OverSize = $this->Parent->Detail->Height + $this->Parent->Page_Footer->Height;
//DEL          else
//DEL              $OverSize = $this->Parent->Detail->Height;
//DEL          if (($this->PageSize > 0) and $this->Parent->Detail->Visible and ($this->CurrentPageSize + $OverSize > $this->PageSize)) {
//DEL              $this->ClosePage();
//DEL              $this->OpenPage();
//DEL          }
//DEL          $this->TotalRows++;
//DEL          if ($this->LastDetailIndex)
//DEL              $PrevGroup = & $this->Groups[$this->LastDetailIndex];
//DEL          else
//DEL              $PrevGroup = "";
//DEL          $Group->SetTotalControls("", $PrevGroup);
//DEL          if ($this->Parent->Detail->Visible)
//DEL              $this->CurrentPageSize = $this->CurrentPageSize + $this->Parent->Detail->Height;
//DEL          $this->Parent->Detail->CCSEventResult = CCGetEvent($this->Parent->Detail->CCSEvents, "OnCalculate", $this->Parent->Detail);
//DEL          $Group->SetControls($PrevGroup);
//DEL          $this->LastDetailIndex = count($this->Groups);
//DEL          $this->Groups[] = & $Group;
//DEL      }
//DEL  }

//Report1 ReportGroup class @58-309082F2
class clsReportGroupReport1 {
    var $GroupType;
    var $mode; //1 - open, 2 - close
    var $Accttype, $_AccttypeAttributes;
    var $Acct, $_AcctAttributes;
    var $Sub, $_SubAttributes;
    var $Descr, $_DescrAttributes;
    var $Opening, $_OpeningAttributes;
    var $Dr, $_DrAttributes;
    var $Cr, $_CrAttributes;
    var $ClosingVal, $_ClosingValAttributes;
    var $TotalSum_Opening, $_TotalSum_OpeningAttributes;
    var $TotalSum_Dr, $_TotalSum_DrAttributes;
    var $TotalSum_Cr, $_TotalSum_CrAttributes;
    var $TotalSum_ClosingVal, $_TotalSum_ClosingValAttributes;
    var $Report_CurrentDate, $_Report_CurrentDateAttributes;
    var $Report_CurrentPage, $_Report_CurrentPageAttributes;
    var $Report_TotalPages, $_Report_TotalPagesAttributes;
    var $Attributes;
    var $ReportTotalIndex = 0;
    var $PageTotalIndex;
    var $PageNumber;
    var $RowNumber;
    var $Parent;

    function clsReportGroupReport1(& $parent) {
        $this->Parent = & $parent;
        $this->Attributes = $this->Parent->Attributes->GetAsArray();
    }
    function SetControls($PrevGroup = "") {
        $this->Accttype = $this->Parent->Accttype->Value;
        $this->Acct = $this->Parent->Acct->Value;
        $this->Sub = $this->Parent->Sub->Value;
        $this->Descr = $this->Parent->Descr->Value;
        $this->Opening = $this->Parent->Opening->Value;
        $this->Dr = $this->Parent->Dr->Value;
        $this->Cr = $this->Parent->Cr->Value;
        $this->ClosingVal = $this->Parent->ClosingVal->Value;
    }

    function SetTotalControls($mode = "", $PrevGroup = "") {
        $this->TotalSum_Opening = $this->Parent->TotalSum_Opening->GetTotalValue($mode);
        $this->TotalSum_Dr = $this->Parent->TotalSum_Dr->GetTotalValue($mode);
        $this->TotalSum_Cr = $this->Parent->TotalSum_Cr->GetTotalValue($mode);
        $this->TotalSum_ClosingVal = $this->Parent->TotalSum_ClosingVal->GetTotalValue($mode);
        $this->_AccttypeAttributes = $this->Parent->Accttype->Attributes->GetAsArray();
        $this->_AcctAttributes = $this->Parent->Acct->Attributes->GetAsArray();
        $this->_SubAttributes = $this->Parent->Sub->Attributes->GetAsArray();
        $this->_DescrAttributes = $this->Parent->Descr->Attributes->GetAsArray();
        $this->_OpeningAttributes = $this->Parent->Opening->Attributes->GetAsArray();
        $this->_DrAttributes = $this->Parent->Dr->Attributes->GetAsArray();
        $this->_CrAttributes = $this->Parent->Cr->Attributes->GetAsArray();
        $this->_ClosingValAttributes = $this->Parent->ClosingVal->Attributes->GetAsArray();
        $this->_TotalSum_OpeningAttributes = $this->Parent->TotalSum_Opening->Attributes->GetAsArray();
        $this->_TotalSum_DrAttributes = $this->Parent->TotalSum_Dr->Attributes->GetAsArray();
        $this->_TotalSum_CrAttributes = $this->Parent->TotalSum_Cr->Attributes->GetAsArray();
        $this->_TotalSum_ClosingValAttributes = $this->Parent->TotalSum_ClosingVal->Attributes->GetAsArray();
        $this->_Report_CurrentDateAttributes = $this->Parent->Report_CurrentDate->Attributes->GetAsArray();
        $this->_Report_CurrentPageAttributes = $this->Parent->Report_CurrentPage->Attributes->GetAsArray();
        $this->_Report_TotalPagesAttributes = $this->Parent->Report_TotalPages->Attributes->GetAsArray();
        $this->_NavigatorAttributes = $this->Parent->Navigator->Attributes->GetAsArray();
    }
    function SyncWithHeader(& $Header) {
        $Header->TotalSum_Opening = $this->TotalSum_Opening;
        $Header->_TotalSum_OpeningAttributes = $this->_TotalSum_OpeningAttributes;
        $Header->TotalSum_Dr = $this->TotalSum_Dr;
        $Header->_TotalSum_DrAttributes = $this->_TotalSum_DrAttributes;
        $Header->TotalSum_Cr = $this->TotalSum_Cr;
        $Header->_TotalSum_CrAttributes = $this->_TotalSum_CrAttributes;
        $Header->TotalSum_ClosingVal = $this->TotalSum_ClosingVal;
        $Header->_TotalSum_ClosingValAttributes = $this->_TotalSum_ClosingValAttributes;
        $this->Accttype = $Header->Accttype;
        $Header->_AccttypeAttributes = $this->_AccttypeAttributes;
        $this->Parent->Accttype->Value = $Header->Accttype;
        $this->Parent->Accttype->Attributes->RestoreFromArray($Header->_AccttypeAttributes);
        $this->Acct = $Header->Acct;
        $Header->_AcctAttributes = $this->_AcctAttributes;
        $this->Parent->Acct->Value = $Header->Acct;
        $this->Parent->Acct->Attributes->RestoreFromArray($Header->_AcctAttributes);
        $this->Sub = $Header->Sub;
        $Header->_SubAttributes = $this->_SubAttributes;
        $this->Parent->Sub->Value = $Header->Sub;
        $this->Parent->Sub->Attributes->RestoreFromArray($Header->_SubAttributes);
        $this->Descr = $Header->Descr;
        $Header->_DescrAttributes = $this->_DescrAttributes;
        $this->Parent->Descr->Value = $Header->Descr;
        $this->Parent->Descr->Attributes->RestoreFromArray($Header->_DescrAttributes);
        $this->Opening = $Header->Opening;
        $Header->_OpeningAttributes = $this->_OpeningAttributes;
        $this->Parent->Opening->Value = $Header->Opening;
        $this->Parent->Opening->Attributes->RestoreFromArray($Header->_OpeningAttributes);
        $this->Dr = $Header->Dr;
        $Header->_DrAttributes = $this->_DrAttributes;
        $this->Parent->Dr->Value = $Header->Dr;
        $this->Parent->Dr->Attributes->RestoreFromArray($Header->_DrAttributes);
        $this->Cr = $Header->Cr;
        $Header->_CrAttributes = $this->_CrAttributes;
        $this->Parent->Cr->Value = $Header->Cr;
        $this->Parent->Cr->Attributes->RestoreFromArray($Header->_CrAttributes);
        $this->ClosingVal = $Header->ClosingVal;
        $Header->_ClosingValAttributes = $this->_ClosingValAttributes;
        $this->Parent->ClosingVal->Value = $Header->ClosingVal;
        $this->Parent->ClosingVal->Attributes->RestoreFromArray($Header->_ClosingValAttributes);
    }
    function ChangeTotalControls() {
        $this->TotalSum_Opening = $this->Parent->TotalSum_Opening->GetValue();
        $this->TotalSum_Dr = $this->Parent->TotalSum_Dr->GetValue();
        $this->TotalSum_Cr = $this->Parent->TotalSum_Cr->GetValue();
        $this->TotalSum_ClosingVal = $this->Parent->TotalSum_ClosingVal->GetValue();
    }
}
//End Report1 ReportGroup class

//Report1 GroupsCollection class @58-D1FAFA3D
class clsGroupsCollectionReport1 {
    var $Groups;
    var $mPageCurrentHeaderIndex;
    var $PageSize;
    var $TotalPages = 0;
    var $TotalRows = 0;
    var $CurrentPageSize = 0;
    var $Pages;
    var $Parent;
    var $LastDetailIndex;

    function clsGroupsCollectionReport1(& $parent) {
        $this->Parent = & $parent;
        $this->Groups = array();
        $this->Pages  = array();
        $this->mReportTotalIndex = 0;
        $this->mPageTotalIndex = 1;
    }

    function & InitGroup() {
        $group = new clsReportGroupReport1($this->Parent);
        $group->RowNumber = $this->TotalRows + 1;
        $group->PageNumber = $this->TotalPages;
        $group->PageTotalIndex = $this->mPageCurrentHeaderIndex;
        return $group;
    }

    function RestoreValues() {
        $this->Parent->Accttype->Value = $this->Parent->Accttype->initialValue;
        $this->Parent->Acct->Value = $this->Parent->Acct->initialValue;
        $this->Parent->Sub->Value = $this->Parent->Sub->initialValue;
        $this->Parent->Descr->Value = $this->Parent->Descr->initialValue;
        $this->Parent->Opening->Value = $this->Parent->Opening->initialValue;
        $this->Parent->Dr->Value = $this->Parent->Dr->initialValue;
        $this->Parent->Cr->Value = $this->Parent->Cr->initialValue;
        $this->Parent->ClosingVal->Value = $this->Parent->ClosingVal->initialValue;
        $this->Parent->TotalSum_Opening->Value = $this->Parent->TotalSum_Opening->initialValue;
        $this->Parent->TotalSum_Dr->Value = $this->Parent->TotalSum_Dr->initialValue;
        $this->Parent->TotalSum_Cr->Value = $this->Parent->TotalSum_Cr->initialValue;
        $this->Parent->TotalSum_ClosingVal->Value = $this->Parent->TotalSum_ClosingVal->initialValue;
    }

    function OpenPage() {
        $this->TotalPages++;
        $Group = & $this->InitGroup();
        $this->Parent->Page_Header->CCSEventResult = CCGetEvent($this->Parent->Page_Header->CCSEvents, "OnInitialize", $this->Parent->Page_Header);
        if ($this->Parent->Page_Header->Visible)
            $this->CurrentPageSize = $this->CurrentPageSize + $this->Parent->Page_Header->Height;
        $Group->SetTotalControls("GetNextValue");
        $this->Parent->Page_Header->CCSEventResult = CCGetEvent($this->Parent->Page_Header->CCSEvents, "OnCalculate", $this->Parent->Page_Header);
        $Group->SetControls();
        $Group->Mode = 1;
        $Group->GroupType = "Page";
        $Group->PageTotalIndex = count($this->Groups);
        $this->mPageCurrentHeaderIndex = count($this->Groups);
        $this->Groups[] =  & $Group;
        $this->Pages[] =  count($this->Groups) == 2 ? 0 : count($this->Groups) - 1;
    }

    function OpenGroup($groupName) {
        $Group = "";
        $OpenFlag = false;
        if ($groupName == "Report") {
            $Group = & $this->InitGroup(true);
            $this->Parent->Report_Header->CCSEventResult = CCGetEvent($this->Parent->Report_Header->CCSEvents, "OnInitialize", $this->Parent->Report_Header);
            if ($this->Parent->Report_Header->Visible) 
                $this->CurrentPageSize = $this->CurrentPageSize + $this->Parent->Report_Header->Height;
                $Group->SetTotalControls("GetNextValue");
            $this->Parent->Report_Header->CCSEventResult = CCGetEvent($this->Parent->Report_Header->CCSEvents, "OnCalculate", $this->Parent->Report_Header);
            $Group->SetControls();
            $Group->Mode = 1;
            $Group->GroupType = "Report";
            $this->Groups[] = & $Group;
            $this->OpenPage();
        }
    }

    function ClosePage() {
        $Group = & $this->InitGroup();
        $this->Parent->Page_Footer->CCSEventResult = CCGetEvent($this->Parent->Page_Footer->CCSEvents, "OnInitialize", $this->Parent->Page_Footer);
        $Group->SetTotalControls("GetPrevValue");
        $Group->SyncWithHeader($this->Groups[$this->mPageCurrentHeaderIndex]);
        $this->Parent->Page_Footer->CCSEventResult = CCGetEvent($this->Parent->Page_Footer->CCSEvents, "OnCalculate", $this->Parent->Page_Footer);
        $Group->SetControls();
        $this->RestoreValues();
        $this->CurrentPageSize = 0;
        $Group->Mode = 2;
        $Group->GroupType = "Page";
        $this->Groups[] = & $Group;
    }

    function CloseGroup($groupName)
    {
        $Group = "";
        if ($groupName == "Report") {
            $Group = & $this->InitGroup(true);
            $this->Parent->Report_Footer->CCSEventResult = CCGetEvent($this->Parent->Report_Footer->CCSEvents, "OnInitialize", $this->Parent->Report_Footer);
            if ($this->Parent->Page_Footer->Visible) 
                $OverSize = $this->Parent->Report_Footer->Height + $this->Parent->Page_Footer->Height;
            else
                $OverSize = $this->Parent->Report_Footer->Height;
            if (($this->PageSize > 0) and $this->Parent->Report_Footer->Visible and ($this->CurrentPageSize + $OverSize > $this->PageSize)) {
                $this->ClosePage();
                $this->OpenPage();
            }
            $Group->SetTotalControls("GetPrevValue");
            $Group->SyncWithHeader($this->Groups[0]);
            if ($this->Parent->Report_Footer->Visible)
                $this->CurrentPageSize = $this->CurrentPageSize + $this->Parent->Report_Footer->Height;
            $this->Parent->Report_Footer->CCSEventResult = CCGetEvent($this->Parent->Report_Footer->CCSEvents, "OnCalculate", $this->Parent->Report_Footer);
            $Group->SetControls();
            $this->RestoreValues();
            $Group->Mode = 2;
            $Group->GroupType = "Report";
            $this->Groups[] = & $Group;
            $this->ClosePage();
            return;
        }
    }

    function AddItem()
    {
        $Group = & $this->InitGroup(true);
        $this->Parent->Detail->CCSEventResult = CCGetEvent($this->Parent->Detail->CCSEvents, "OnInitialize", $this->Parent->Detail);
        if ($this->Parent->Page_Footer->Visible) 
            $OverSize = $this->Parent->Detail->Height + $this->Parent->Page_Footer->Height;
        else
            $OverSize = $this->Parent->Detail->Height;
        if (($this->PageSize > 0) and $this->Parent->Detail->Visible and ($this->CurrentPageSize + $OverSize > $this->PageSize)) {
            $this->ClosePage();
            $this->OpenPage();
        }
        $this->TotalRows++;
        if ($this->LastDetailIndex)
            $PrevGroup = & $this->Groups[$this->LastDetailIndex];
        else
            $PrevGroup = "";
        $Group->SetTotalControls("", $PrevGroup);
        if ($this->Parent->Detail->Visible)
            $this->CurrentPageSize = $this->CurrentPageSize + $this->Parent->Detail->Height;
        $this->Parent->Detail->CCSEventResult = CCGetEvent($this->Parent->Detail->CCSEvents, "OnCalculate", $this->Parent->Detail);
        $Group->SetControls($PrevGroup);
        $this->LastDetailIndex = count($this->Groups);
        $this->Groups[] = & $Group;
    }
}
//End Report1 GroupsCollection class

class clsReportReport1 { //Report1 Class @58-BC2FB08C

//Report1 Variables @58-87F7EA53

    var $ComponentType = "Report";
    var $PageSize;
    var $ComponentName;
    var $Visible;
    var $Errors;
    var $CCSEvents = array();
    var $CCSEventResult;
    var $RelativePath = "";
    var $ViewMode = "Web";
    var $TemplateBlock;
    var $PageNumber;
    var $RowNumber;
    var $TotalRows;
    var $TotalPages;
    var $ControlsVisible = array();
    var $IsEmpty;
    var $Attributes;
    var $DetailBlock, $Detail;
    var $Report_FooterBlock, $Report_Footer;
    var $Report_HeaderBlock, $Report_Header;
    var $Page_FooterBlock, $Page_Footer;
    var $Page_HeaderBlock, $Page_Header;
    var $SorterName, $SorterDirection;

    var $ds;
    var $DataSource;
    var $UseClientPaging = false;

    //Report Controls
    var $StaticControls, $RowControls, $Report_FooterControls, $Report_HeaderControls;
    var $Page_FooterControls, $Page_HeaderControls;
//End Report1 Variables

//Class_Initialize Event @58-EF29E3E5
    function clsReportReport1($RelativePath = "", & $Parent)
    {
        global $FileName;
        global $CCSLocales;
        global $DefaultDateFormat;
        $this->ComponentName = "Report1";
        $this->Visible = True;
        $this->Parent = & $Parent;
        $this->RelativePath = $RelativePath;
        $this->Attributes = new clsAttributes($this->ComponentName . ":");
        $this->Detail = new clsSection($this);
        $MinPageSize = 0;
        $MaxSectionSize = 0;
        $this->Detail->Height = 1;
        $MaxSectionSize = max($MaxSectionSize, $this->Detail->Height);
        $this->Report_Footer = new clsSection($this);
        $this->Report_Footer->Height = 1;
        $MaxSectionSize = max($MaxSectionSize, $this->Report_Footer->Height);
        $this->Report_Header = new clsSection($this);
        $this->Page_Footer = new clsSection($this);
        $this->Page_Footer->Height = 1;
        $MinPageSize += $this->Page_Footer->Height;
        $this->Page_Header = new clsSection($this);
        $this->Page_Header->Height = 1;
        $MinPageSize += $this->Page_Header->Height;
        $this->Errors = new clsErrors();
        $this->DataSource = new clsReport1DataSource($this);
        $this->ds = & $this->DataSource;
        $PageSize = CCGetParam($this->ComponentName . "PageSize", "");
        if(is_numeric($PageSize) && $PageSize > 0) {
            $this->PageSize = $PageSize;
        } else {
            if (!is_numeric($PageSize) || $PageSize < 0)
                $this->PageSize = 40;
             else if ($PageSize == "0")
                $this->PageSize = 100;
             else 
                $this->PageSize = min(100, $PageSize);
        }
        $MinPageSize += $MaxSectionSize;
        if ($this->PageSize && $MinPageSize && $this->PageSize < $MinPageSize)
            $this->PageSize = $MinPageSize;
        $this->PageNumber = $this->ViewMode == "Print" ? 1 : intval(CCGetParam($this->ComponentName . "Page", 1));
        if ($this->PageNumber <= 0 ) {
            $this->PageNumber = 1;
        }

        $this->Accttype = & new clsControl(ccsReportLabel, "Accttype", "Accttype", ccsText, "", "", $this);
        $this->Acct = & new clsControl(ccsReportLabel, "Acct", "Acct", ccsText, "", "", $this);
        $this->Sub = & new clsControl(ccsReportLabel, "Sub", "Sub", ccsText, "", "", $this);
        $this->Descr = & new clsControl(ccsReportLabel, "Descr", "Descr", ccsText, "", "", $this);
        $this->Opening = & new clsControl(ccsReportLabel, "Opening", "Opening", ccsFloat, array(False, 2, Null, Null, False, "", "", 1, True, ""), "", $this);
        $this->Dr = & new clsControl(ccsReportLabel, "Dr", "Dr", ccsFloat, array(False, 2, Null, Null, False, "", "", 1, True, ""), "", $this);
        $this->Cr = & new clsControl(ccsReportLabel, "Cr", "Cr", ccsFloat, array(False, 2, Null, Null, False, "", "", 1, True, ""), "", $this);
        $this->ClosingVal = & new clsControl(ccsReportLabel, "ClosingVal", "ClosingVal", ccsFloat, array(False, 2, Null, Null, False, "", "", 1, True, ""), "", $this);
        $this->NoRecords = & new clsPanel("NoRecords", $this);
        $this->TotalSum_Opening = & new clsControl(ccsReportLabel, "TotalSum_Opening", "TotalSum_Opening", ccsFloat, array(False, 2, Null, Null, False, "", "", 1, True, ""), "", $this);
        $this->TotalSum_Opening->TotalFunction = "Sum";
        $this->TotalSum_Dr = & new clsControl(ccsReportLabel, "TotalSum_Dr", "TotalSum_Dr", ccsFloat, array(False, 2, Null, Null, False, "", "", 1, True, ""), "", $this);
        $this->TotalSum_Dr->TotalFunction = "Sum";
        $this->TotalSum_Cr = & new clsControl(ccsReportLabel, "TotalSum_Cr", "TotalSum_Cr", ccsFloat, array(False, 2, Null, Null, False, "", "", 1, True, ""), "", $this);
        $this->TotalSum_Cr->TotalFunction = "Sum";
        $this->TotalSum_ClosingVal = & new clsControl(ccsReportLabel, "TotalSum_ClosingVal", "TotalSum_ClosingVal", ccsFloat, array(False, 2, Null, Null, False, "", "", 1, True, ""), "", $this);
        $this->TotalSum_ClosingVal->TotalFunction = "Sum";
        $this->Report_CurrentDate = & new clsControl(ccsReportLabel, "Report_CurrentDate", "Report_CurrentDate", ccsText, array('ShortDate'), "", $this);
        $this->Report_CurrentPage = & new clsControl(ccsReportLabel, "Report_CurrentPage", "Report_CurrentPage", ccsInteger, "", "", $this);
        $this->Report_TotalPages = & new clsControl(ccsReportLabel, "Report_TotalPages", "Report_TotalPages", ccsInteger, "", "", $this);
        $this->Navigator = & new clsNavigator($this->ComponentName, "Navigator", $FileName, 10, tpCentered, $this);
        $this->Navigator->PageSizes = array("1", "5", "10", "25", "50");
    }
//End Class_Initialize Event

//Initialize Method @58-6C59EE65
    function Initialize()
    {
        if(!$this->Visible) return;

        $this->DataSource->PageSize = $this->PageSize;
        $this->DataSource->AbsolutePage = $this->PageNumber;
        $this->DataSource->SetOrder($this->SorterName, $this->SorterDirection);
    }
//End Initialize Method

//CheckErrors Method @58-B5D86920
    function CheckErrors()
    {
        $errors = false;
        $errors = ($errors || $this->Accttype->Errors->Count());
        $errors = ($errors || $this->Acct->Errors->Count());
        $errors = ($errors || $this->Sub->Errors->Count());
        $errors = ($errors || $this->Descr->Errors->Count());
        $errors = ($errors || $this->Opening->Errors->Count());
        $errors = ($errors || $this->Dr->Errors->Count());
        $errors = ($errors || $this->Cr->Errors->Count());
        $errors = ($errors || $this->ClosingVal->Errors->Count());
        $errors = ($errors || $this->TotalSum_Opening->Errors->Count());
        $errors = ($errors || $this->TotalSum_Dr->Errors->Count());
        $errors = ($errors || $this->TotalSum_Cr->Errors->Count());
        $errors = ($errors || $this->TotalSum_ClosingVal->Errors->Count());
        $errors = ($errors || $this->Report_CurrentDate->Errors->Count());
        $errors = ($errors || $this->Report_CurrentPage->Errors->Count());
        $errors = ($errors || $this->Report_TotalPages->Errors->Count());
        $errors = ($errors || $this->Errors->Count());
        $errors = ($errors || $this->DataSource->Errors->Count());
        return $errors;
    }
//End CheckErrors Method

//GetErrors Method @58-C82EE43B
    function GetErrors()
    {
        $errors = "";
        $errors = ComposeStrings($errors, $this->Accttype->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Acct->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Sub->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Descr->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Opening->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Dr->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Cr->Errors->ToString());
        $errors = ComposeStrings($errors, $this->ClosingVal->Errors->ToString());
        $errors = ComposeStrings($errors, $this->TotalSum_Opening->Errors->ToString());
        $errors = ComposeStrings($errors, $this->TotalSum_Dr->Errors->ToString());
        $errors = ComposeStrings($errors, $this->TotalSum_Cr->Errors->ToString());
        $errors = ComposeStrings($errors, $this->TotalSum_ClosingVal->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Report_CurrentDate->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Report_CurrentPage->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Report_TotalPages->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Errors->ToString());
        $errors = ComposeStrings($errors, $this->DataSource->Errors->ToString());
        return $errors;
    }
//End GetErrors Method

//Show Method @58-9996C567
    function Show()
    {
        global $Tpl;
        global $CCSLocales;
        if(!$this->Visible) return;

        $ShownRecords = 0;

        $this->DataSource->Parameters["urls_Period"] = CCGetFromGet("s_Period", NULL);
        $this->DataSource->Parameters["urls_FiscalYear"] = CCGetFromGet("s_FiscalYear", NULL);
        $this->DataSource->Parameters["urlActivity"] = CCGetFromGet("Activity", NULL);
        $this->DataSource->Parameters["urlrptformat"] = CCGetFromGet("rptformat", NULL);

        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeSelect", $this);


        $this->DataSource->Prepare();
        $this->DataSource->Open();

        $Groups = new clsGroupsCollectionReport1($this);
        $Groups->PageSize = $this->PageSize > 0 ? $this->PageSize : 0;

        $is_next_record = $this->DataSource->next_record();
        $this->IsEmpty = ! $is_next_record;
        while($is_next_record) {
            $this->DataSource->SetValues();
            $this->Accttype->SetValue($this->DataSource->Accttype->GetValue());
            $this->Acct->SetValue($this->DataSource->Acct->GetValue());
            $this->Sub->SetValue($this->DataSource->Sub->GetValue());
            $this->Descr->SetValue($this->DataSource->Descr->GetValue());
            $this->Opening->SetValue($this->DataSource->Opening->GetValue());
            $this->Dr->SetValue($this->DataSource->Dr->GetValue());
            $this->Cr->SetValue($this->DataSource->Cr->GetValue());
            $this->ClosingVal->SetValue($this->DataSource->ClosingVal->GetValue());
            $this->TotalSum_Opening->SetValue($this->DataSource->TotalSum_Opening->GetValue());
            $this->TotalSum_Dr->SetValue($this->DataSource->TotalSum_Dr->GetValue());
            $this->TotalSum_Cr->SetValue($this->DataSource->TotalSum_Cr->GetValue());
            $this->TotalSum_ClosingVal->SetValue($this->DataSource->TotalSum_ClosingVal->GetValue());
            if (count($Groups->Groups) == 0) $Groups->OpenGroup("Report");
            $Groups->AddItem();
            $is_next_record = $this->DataSource->next_record();
        }
        if (!count($Groups->Groups)) 
            $Groups->OpenGroup("Report");
        else
            $this->NoRecords->Visible = false;
        $Groups->CloseGroup("Report");
        $this->TotalPages = $Groups->TotalPages;
        $this->TotalRows = $Groups->TotalRows;

        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeShow", $this);
        if(!$this->Visible) return;

        $this->Attributes->Show();
        $ReportBlock = "Report " . $this->ComponentName;
        $ParentPath = $Tpl->block_path;
        $Tpl->block_path = $ParentPath . "/" . $ReportBlock;

        if($this->CheckErrors()) {
            $Tpl->replaceblock("", $this->GetErrors());
            $Tpl->block_path = $ParentPath;
            return;
        } else {
            $items = & $Groups->Groups;
            $i = $Groups->Pages[min($this->PageNumber, $Groups->TotalPages) - 1];
            $this->ControlsVisible["Accttype"] = $this->Accttype->Visible;
            $this->ControlsVisible["Acct"] = $this->Acct->Visible;
            $this->ControlsVisible["Sub"] = $this->Sub->Visible;
            $this->ControlsVisible["Descr"] = $this->Descr->Visible;
            $this->ControlsVisible["Opening"] = $this->Opening->Visible;
            $this->ControlsVisible["Dr"] = $this->Dr->Visible;
            $this->ControlsVisible["Cr"] = $this->Cr->Visible;
            $this->ControlsVisible["ClosingVal"] = $this->ClosingVal->Visible;
            do {
                $this->Attributes->RestoreFromArray($items[$i]->Attributes);
                $this->RowNumber = $items[$i]->RowNumber;
                switch ($items[$i]->GroupType) {
                    Case "":
                        $Tpl->block_path = $ParentPath . "/" . $ReportBlock . "/Section Detail";
                        $this->Accttype->SetValue($items[$i]->Accttype);
                        $this->Accttype->Attributes->RestoreFromArray($items[$i]->_AccttypeAttributes);
                        $this->Acct->SetValue($items[$i]->Acct);
                        $this->Acct->Attributes->RestoreFromArray($items[$i]->_AcctAttributes);
                        $this->Sub->SetValue($items[$i]->Sub);
                        $this->Sub->Attributes->RestoreFromArray($items[$i]->_SubAttributes);
                        $this->Descr->SetValue($items[$i]->Descr);
                        $this->Descr->Attributes->RestoreFromArray($items[$i]->_DescrAttributes);
                        $this->Opening->SetValue($items[$i]->Opening);
                        $this->Opening->Attributes->RestoreFromArray($items[$i]->_OpeningAttributes);
                        $this->Dr->SetValue($items[$i]->Dr);
                        $this->Dr->Attributes->RestoreFromArray($items[$i]->_DrAttributes);
                        $this->Cr->SetValue($items[$i]->Cr);
                        $this->Cr->Attributes->RestoreFromArray($items[$i]->_CrAttributes);
                        $this->ClosingVal->SetValue($items[$i]->ClosingVal);
                        $this->ClosingVal->Attributes->RestoreFromArray($items[$i]->_ClosingValAttributes);
                        $this->Detail->CCSEventResult = CCGetEvent($this->Detail->CCSEvents, "BeforeShow", $this->Detail);
                        $this->Attributes->Show();
                        $this->Accttype->Show();
                        $this->Acct->Show();
                        $this->Sub->Show();
                        $this->Descr->Show();
                        $this->Opening->Show();
                        $this->Dr->Show();
                        $this->Cr->Show();
                        $this->ClosingVal->Show();
                        $Tpl->block_path = $ParentPath . "/" . $ReportBlock;
                        if ($this->Detail->Visible)
                            $Tpl->parseto("Section Detail", true, "Section Detail");
                        break;
                    case "Report":
                        if ($items[$i]->Mode == 1) {
                            $this->Report_Header->CCSEventResult = CCGetEvent($this->Report_Header->CCSEvents, "BeforeShow", $this->Report_Header);
                            if ($this->Report_Header->Visible) {
                                $Tpl->block_path = $ParentPath . "/" . $ReportBlock . "/Section Report_Header";
                                $this->Attributes->Show();
                                $Tpl->block_path = $ParentPath . "/" . $ReportBlock;
                                $Tpl->parseto("Section Report_Header", true, "Section Detail");
                            }
                        }
                        if ($items[$i]->Mode == 2) {
                            $this->TotalSum_Opening->SetText(CCFormatNumber($items[$i]->TotalSum_Opening, array(False, 2, Null, Null, False, "", "", 1, True, "")), ccsFloat);
                            $this->TotalSum_Opening->Attributes->RestoreFromArray($items[$i]->_TotalSum_OpeningAttributes);
                            $this->TotalSum_Dr->SetText(CCFormatNumber($items[$i]->TotalSum_Dr, array(False, 2, Null, Null, False, "", "", 1, True, "")), ccsFloat);
                            $this->TotalSum_Dr->Attributes->RestoreFromArray($items[$i]->_TotalSum_DrAttributes);
                            $this->TotalSum_Cr->SetText(CCFormatNumber($items[$i]->TotalSum_Cr, array(False, 2, Null, Null, False, "", "", 1, True, "")), ccsFloat);
                            $this->TotalSum_Cr->Attributes->RestoreFromArray($items[$i]->_TotalSum_CrAttributes);
                            $this->TotalSum_ClosingVal->SetText(CCFormatNumber($items[$i]->TotalSum_ClosingVal, array(False, 2, Null, Null, False, "", "", 1, True, "")), ccsFloat);
                            $this->TotalSum_ClosingVal->Attributes->RestoreFromArray($items[$i]->_TotalSum_ClosingValAttributes);
                            $this->Report_Footer->CCSEventResult = CCGetEvent($this->Report_Footer->CCSEvents, "BeforeShow", $this->Report_Footer);
                            if ($this->Report_Footer->Visible) {
                                $Tpl->block_path = $ParentPath . "/" . $ReportBlock . "/Section Report_Footer";
                                $this->NoRecords->Show();
                                $this->TotalSum_Opening->Show();
                                $this->TotalSum_Dr->Show();
                                $this->TotalSum_Cr->Show();
                                $this->TotalSum_ClosingVal->Show();
                                $this->Attributes->Show();
                                $Tpl->block_path = $ParentPath . "/" . $ReportBlock;
                                $Tpl->parseto("Section Report_Footer", true, "Section Detail");
                            }
                        }
                        break;
                    case "Page":
                        if ($items[$i]->Mode == 1) {
                            $this->Page_Header->CCSEventResult = CCGetEvent($this->Page_Header->CCSEvents, "BeforeShow", $this->Page_Header);
                            if ($this->Page_Header->Visible) {
                                $Tpl->block_path = $ParentPath . "/" . $ReportBlock . "/Section Page_Header";
                                $this->Attributes->Show();
                                $Tpl->block_path = $ParentPath . "/" . $ReportBlock;
                                $Tpl->parseto("Section Page_Header", true, "Section Detail");
                            }
                        }
                        if ($items[$i]->Mode == 2 && !$this->UseClientPaging || $items[$i]->Mode == 1 && $this->UseClientPaging) {
                            $this->Report_CurrentDate->SetValue(CCFormatDate(CCGetDateArray(), $this->Report_CurrentDate->Format));
                            $this->Report_CurrentDate->Attributes->RestoreFromArray($items[$i]->_Report_CurrentDateAttributes);
                            $this->Report_CurrentPage->SetValue($items[$i]->PageNumber);
                            $this->Report_CurrentPage->Attributes->RestoreFromArray($items[$i]->_Report_CurrentPageAttributes);
                            $this->Report_TotalPages->SetValue($Groups->TotalPages);
                            $this->Report_TotalPages->Attributes->RestoreFromArray($items[$i]->_Report_TotalPagesAttributes);
                            $this->Navigator->PageNumber = $items[$i]->PageNumber;
                            $this->Navigator->TotalPages = $Groups->TotalPages;
                            $this->Navigator->Visible = ("Print" != $this->ViewMode);
                            $this->Page_Footer->CCSEventResult = CCGetEvent($this->Page_Footer->CCSEvents, "BeforeShow", $this->Page_Footer);
                            if ($this->Page_Footer->Visible) {
                                $Tpl->block_path = $ParentPath . "/" . $ReportBlock . "/Section Page_Footer";
                                $this->Report_CurrentDate->Show();
                                $this->Report_CurrentPage->Show();
                                $this->Report_TotalPages->Show();
                                $this->Navigator->Show();
                                $this->Attributes->Show();
                                $Tpl->block_path = $ParentPath . "/" . $ReportBlock;
                                $Tpl->parseto("Section Page_Footer", true, "Section Detail");
                            }
                        }
                        break;
                }
                $i++;
            } while ($i < count($items) && ($this->ViewMode == "Print" ||  !($i > 1 && $items[$i]->GroupType == 'Page' && $items[$i]->Mode == 1)));
            $Tpl->block_path = $ParentPath;
            $Tpl->parse($ReportBlock);
            $this->DataSource->close();
        }

    }
//End Show Method

} //End Report1 Class @58-FCB6E20C

class clsReport1DataSource extends clsDBCoopWorksConn {  //Report1DataSource Class @58-BCC4E5C8

//DataSource Variables @58-F026CC2C
    var $Parent = "";
    var $CCSEvents = "";
    var $CCSEventResult;
    var $ErrorBlock;
    var $CmdExecution;



    // Datasource fields
    var $Accttype;
    var $Acct;
    var $Sub;
    var $Descr;
    var $Opening;
    var $Dr;
    var $Cr;
    var $ClosingVal;
    var $TotalSum_Opening;
    var $TotalSum_Dr;
    var $TotalSum_Cr;
    var $TotalSum_ClosingVal;
//End DataSource Variables

//DataSourceClass_Initialize Event @58-88E04A3B
    function clsReport1DataSource(& $Parent)
    {
        $this->Parent = & $Parent;
        $this->ErrorBlock = "Report Report1";
        $this->Initialize();
        $this->Accttype = new clsField("Accttype", ccsText, "");
        
        $this->Acct = new clsField("Acct", ccsText, "");
        
        $this->Sub = new clsField("Sub", ccsText, "");
        
        $this->Descr = new clsField("Descr", ccsText, "");
        
        $this->Opening = new clsField("Opening", ccsFloat, "");
        
        $this->Dr = new clsField("Dr", ccsFloat, "");
        
        $this->Cr = new clsField("Cr", ccsFloat, "");
        
        $this->ClosingVal = new clsField("ClosingVal", ccsFloat, "");
        
        $this->TotalSum_Opening = new clsField("TotalSum_Opening", ccsFloat, "");
        
        $this->TotalSum_Dr = new clsField("TotalSum_Dr", ccsFloat, "");
        
        $this->TotalSum_Cr = new clsField("TotalSum_Cr", ccsFloat, "");
        
        $this->TotalSum_ClosingVal = new clsField("TotalSum_ClosingVal", ccsFloat, "");
        

    }
//End DataSourceClass_Initialize Event

//SetOrder Method @58-BF7F5B01
    function SetOrder($SorterName, $SorterDirection)
    {
        $this->Order = CCGetOrder($this->Order, $SorterName, $SorterDirection, 
            "");
    }
//End SetOrder Method

//Prepare Method @58-14D6CD9D
    function Prepare()
    {
        global $CCSLocales;
        global $DefaultDateFormat;
    }
//End Prepare Method

//Open Method @58-0E97BF41
    function Open()
    {
        $this->cp["period"] = new clsSQLParameter("urls_Period", ccsInteger, "", "", CCGetFromGet("s_Period", NULL), "", false, $this->ErrorBlock);
        $this->cp["year2"] = new clsSQLParameter("urls_FiscalYear", ccsText, "", "", CCGetFromGet("s_FiscalYear", NULL), "", false, $this->ErrorBlock);
        $this->cp["Activity"] = new clsSQLParameter("urlActivity", ccsText, "", "", CCGetFromGet("Activity", NULL), "", false, $this->ErrorBlock);
        $this->cp["rptformat"] = new clsSQLParameter("urlrptformat", ccsText, "", "", CCGetFromGet("rptformat", NULL), "", false, $this->ErrorBlock);
        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeBuildSelect", $this->Parent);
        $this->SQL = "CALL GL_YTD_TB_income (" . $this->ToSQL($this->cp["period"]->GetDBValue(), $this->cp["period"]->DataType) . ", "
             . $this->ToSQL($this->cp["year2"]->GetDBValue(), $this->cp["year2"]->DataType) . ", "
             . $this->ToSQL($this->cp["Activity"]->GetDBValue(), $this->cp["Activity"]->DataType) . ", "
             . $this->ToSQL($this->cp["rptformat"]->GetDBValue(), $this->cp["rptformat"]->DataType) . ");";
        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeExecuteSelect", $this->Parent);
        $this->query($this->SQL);
        $this->RecordsCount = "CCS not counted";
        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterExecuteSelect", $this->Parent);
        if ($this->Errors->count()) return false;
    }
//End Open Method

//SetValues Method @58-AD2BAFD9
    function SetValues()
    {
        $this->Accttype->SetDBValue($this->f("Accttype"));
        $this->Acct->SetDBValue($this->f("Acct"));
        $this->Sub->SetDBValue($this->f("Sub"));
        $this->Descr->SetDBValue($this->f("Descr"));
        $this->Opening->SetDBValue(trim($this->f("Opening")));
        $this->Dr->SetDBValue(trim($this->f("Dr")));
        $this->Cr->SetDBValue(trim($this->f("Cr")));
        $this->ClosingVal->SetDBValue(trim($this->f("ClosingVal")));
        $this->TotalSum_Opening->SetDBValue(trim($this->f("Opening")));
        $this->TotalSum_Dr->SetDBValue(trim($this->f("Dr")));
        $this->TotalSum_Cr->SetDBValue(trim($this->f("Cr")));
        $this->TotalSum_ClosingVal->SetDBValue(trim($this->f("ClosingVal")));
    }
//End SetValues Method

} //End Report1DataSource Class @58-FCB6E20C

//Report2 ReportGroup class @89-04EC3EAE
class clsReportGroupReport2 {
    var $GroupType;
    var $mode; //1 - open, 2 - close
    var $Accttype, $_AccttypeAttributes;
    var $Acct, $_AcctAttributes;
    var $Sub, $_SubAttributes;
    var $Descr, $_DescrAttributes;
    var $Opening, $_OpeningAttributes;
    var $Dr, $_DrAttributes;
    var $Cr, $_CrAttributes;
    var $ClosingVal, $_ClosingValAttributes;
    var $TotalSum_FiscalYear, $_TotalSum_FiscalYearAttributes;
    var $TotalSum_Dr, $_TotalSum_DrAttributes;
    var $TotalSum_Cr, $_TotalSum_CrAttributes;
    var $TotalSum_ClosingVal, $_TotalSum_ClosingValAttributes;
    var $Report_CurrentDate, $_Report_CurrentDateAttributes;
    var $Report_CurrentPage, $_Report_CurrentPageAttributes;
    var $Report_TotalPages, $_Report_TotalPagesAttributes;
    var $Attributes;
    var $ReportTotalIndex = 0;
    var $PageTotalIndex;
    var $PageNumber;
    var $RowNumber;
    var $Parent;

    function clsReportGroupReport2(& $parent) {
        $this->Parent = & $parent;
        $this->Attributes = $this->Parent->Attributes->GetAsArray();
    }
    function SetControls($PrevGroup = "") {
        $this->Accttype = $this->Parent->Accttype->Value;
        $this->Acct = $this->Parent->Acct->Value;
        $this->Sub = $this->Parent->Sub->Value;
        $this->Descr = $this->Parent->Descr->Value;
        $this->Opening = $this->Parent->Opening->Value;
        $this->Dr = $this->Parent->Dr->Value;
        $this->Cr = $this->Parent->Cr->Value;
        $this->ClosingVal = $this->Parent->ClosingVal->Value;
    }

    function SetTotalControls($mode = "", $PrevGroup = "") {
        $this->TotalSum_FiscalYear = $this->Parent->TotalSum_FiscalYear->GetTotalValue($mode);
        $this->TotalSum_Dr = $this->Parent->TotalSum_Dr->GetTotalValue($mode);
        $this->TotalSum_Cr = $this->Parent->TotalSum_Cr->GetTotalValue($mode);
        $this->TotalSum_ClosingVal = $this->Parent->TotalSum_ClosingVal->GetTotalValue($mode);
        $this->_AccttypeAttributes = $this->Parent->Accttype->Attributes->GetAsArray();
        $this->_AcctAttributes = $this->Parent->Acct->Attributes->GetAsArray();
        $this->_SubAttributes = $this->Parent->Sub->Attributes->GetAsArray();
        $this->_DescrAttributes = $this->Parent->Descr->Attributes->GetAsArray();
        $this->_OpeningAttributes = $this->Parent->Opening->Attributes->GetAsArray();
        $this->_DrAttributes = $this->Parent->Dr->Attributes->GetAsArray();
        $this->_CrAttributes = $this->Parent->Cr->Attributes->GetAsArray();
        $this->_ClosingValAttributes = $this->Parent->ClosingVal->Attributes->GetAsArray();
        $this->_TotalSum_FiscalYearAttributes = $this->Parent->TotalSum_FiscalYear->Attributes->GetAsArray();
        $this->_TotalSum_DrAttributes = $this->Parent->TotalSum_Dr->Attributes->GetAsArray();
        $this->_TotalSum_CrAttributes = $this->Parent->TotalSum_Cr->Attributes->GetAsArray();
        $this->_TotalSum_ClosingValAttributes = $this->Parent->TotalSum_ClosingVal->Attributes->GetAsArray();
        $this->_Report_CurrentDateAttributes = $this->Parent->Report_CurrentDate->Attributes->GetAsArray();
        $this->_Report_CurrentPageAttributes = $this->Parent->Report_CurrentPage->Attributes->GetAsArray();
        $this->_Report_TotalPagesAttributes = $this->Parent->Report_TotalPages->Attributes->GetAsArray();
        $this->_NavigatorAttributes = $this->Parent->Navigator->Attributes->GetAsArray();
    }
    function SyncWithHeader(& $Header) {
        $Header->TotalSum_FiscalYear = $this->TotalSum_FiscalYear;
        $Header->_TotalSum_FiscalYearAttributes = $this->_TotalSum_FiscalYearAttributes;
        $Header->TotalSum_Dr = $this->TotalSum_Dr;
        $Header->_TotalSum_DrAttributes = $this->_TotalSum_DrAttributes;
        $Header->TotalSum_Cr = $this->TotalSum_Cr;
        $Header->_TotalSum_CrAttributes = $this->_TotalSum_CrAttributes;
        $Header->TotalSum_ClosingVal = $this->TotalSum_ClosingVal;
        $Header->_TotalSum_ClosingValAttributes = $this->_TotalSum_ClosingValAttributes;
        $this->Accttype = $Header->Accttype;
        $Header->_AccttypeAttributes = $this->_AccttypeAttributes;
        $this->Parent->Accttype->Value = $Header->Accttype;
        $this->Parent->Accttype->Attributes->RestoreFromArray($Header->_AccttypeAttributes);
        $this->Acct = $Header->Acct;
        $Header->_AcctAttributes = $this->_AcctAttributes;
        $this->Parent->Acct->Value = $Header->Acct;
        $this->Parent->Acct->Attributes->RestoreFromArray($Header->_AcctAttributes);
        $this->Sub = $Header->Sub;
        $Header->_SubAttributes = $this->_SubAttributes;
        $this->Parent->Sub->Value = $Header->Sub;
        $this->Parent->Sub->Attributes->RestoreFromArray($Header->_SubAttributes);
        $this->Descr = $Header->Descr;
        $Header->_DescrAttributes = $this->_DescrAttributes;
        $this->Parent->Descr->Value = $Header->Descr;
        $this->Parent->Descr->Attributes->RestoreFromArray($Header->_DescrAttributes);
        $this->Opening = $Header->Opening;
        $Header->_OpeningAttributes = $this->_OpeningAttributes;
        $this->Parent->Opening->Value = $Header->Opening;
        $this->Parent->Opening->Attributes->RestoreFromArray($Header->_OpeningAttributes);
        $this->Dr = $Header->Dr;
        $Header->_DrAttributes = $this->_DrAttributes;
        $this->Parent->Dr->Value = $Header->Dr;
        $this->Parent->Dr->Attributes->RestoreFromArray($Header->_DrAttributes);
        $this->Cr = $Header->Cr;
        $Header->_CrAttributes = $this->_CrAttributes;
        $this->Parent->Cr->Value = $Header->Cr;
        $this->Parent->Cr->Attributes->RestoreFromArray($Header->_CrAttributes);
        $this->ClosingVal = $Header->ClosingVal;
        $Header->_ClosingValAttributes = $this->_ClosingValAttributes;
        $this->Parent->ClosingVal->Value = $Header->ClosingVal;
        $this->Parent->ClosingVal->Attributes->RestoreFromArray($Header->_ClosingValAttributes);
    }
    function ChangeTotalControls() {
        $this->TotalSum_FiscalYear = $this->Parent->TotalSum_FiscalYear->GetValue();
        $this->TotalSum_Dr = $this->Parent->TotalSum_Dr->GetValue();
        $this->TotalSum_Cr = $this->Parent->TotalSum_Cr->GetValue();
        $this->TotalSum_ClosingVal = $this->Parent->TotalSum_ClosingVal->GetValue();
    }
}
//End Report2 ReportGroup class

//Report2 GroupsCollection class @89-233F89D7
class clsGroupsCollectionReport2 {
    var $Groups;
    var $mPageCurrentHeaderIndex;
    var $PageSize;
    var $TotalPages = 0;
    var $TotalRows = 0;
    var $CurrentPageSize = 0;
    var $Pages;
    var $Parent;
    var $LastDetailIndex;

    function clsGroupsCollectionReport2(& $parent) {
        $this->Parent = & $parent;
        $this->Groups = array();
        $this->Pages  = array();
        $this->mReportTotalIndex = 0;
        $this->mPageTotalIndex = 1;
    }

    function & InitGroup() {
        $group = new clsReportGroupReport2($this->Parent);
        $group->RowNumber = $this->TotalRows + 1;
        $group->PageNumber = $this->TotalPages;
        $group->PageTotalIndex = $this->mPageCurrentHeaderIndex;
        return $group;
    }

    function RestoreValues() {
        $this->Parent->Accttype->Value = $this->Parent->Accttype->initialValue;
        $this->Parent->Acct->Value = $this->Parent->Acct->initialValue;
        $this->Parent->Sub->Value = $this->Parent->Sub->initialValue;
        $this->Parent->Descr->Value = $this->Parent->Descr->initialValue;
        $this->Parent->Opening->Value = $this->Parent->Opening->initialValue;
        $this->Parent->Dr->Value = $this->Parent->Dr->initialValue;
        $this->Parent->Cr->Value = $this->Parent->Cr->initialValue;
        $this->Parent->ClosingVal->Value = $this->Parent->ClosingVal->initialValue;
        $this->Parent->TotalSum_FiscalYear->Value = $this->Parent->TotalSum_FiscalYear->initialValue;
        $this->Parent->TotalSum_Dr->Value = $this->Parent->TotalSum_Dr->initialValue;
        $this->Parent->TotalSum_Cr->Value = $this->Parent->TotalSum_Cr->initialValue;
        $this->Parent->TotalSum_ClosingVal->Value = $this->Parent->TotalSum_ClosingVal->initialValue;
    }

    function OpenPage() {
        $this->TotalPages++;
        $Group = & $this->InitGroup();
        $this->Parent->Page_Header->CCSEventResult = CCGetEvent($this->Parent->Page_Header->CCSEvents, "OnInitialize", $this->Parent->Page_Header);
        if ($this->Parent->Page_Header->Visible)
            $this->CurrentPageSize = $this->CurrentPageSize + $this->Parent->Page_Header->Height;
        $Group->SetTotalControls("GetNextValue");
        $this->Parent->Page_Header->CCSEventResult = CCGetEvent($this->Parent->Page_Header->CCSEvents, "OnCalculate", $this->Parent->Page_Header);
        $Group->SetControls();
        $Group->Mode = 1;
        $Group->GroupType = "Page";
        $Group->PageTotalIndex = count($this->Groups);
        $this->mPageCurrentHeaderIndex = count($this->Groups);
        $this->Groups[] =  & $Group;
        $this->Pages[] =  count($this->Groups) == 2 ? 0 : count($this->Groups) - 1;
    }

    function OpenGroup($groupName) {
        $Group = "";
        $OpenFlag = false;
        if ($groupName == "Report") {
            $Group = & $this->InitGroup(true);
            $this->Parent->Report_Header->CCSEventResult = CCGetEvent($this->Parent->Report_Header->CCSEvents, "OnInitialize", $this->Parent->Report_Header);
            if ($this->Parent->Report_Header->Visible) 
                $this->CurrentPageSize = $this->CurrentPageSize + $this->Parent->Report_Header->Height;
                $Group->SetTotalControls("GetNextValue");
            $this->Parent->Report_Header->CCSEventResult = CCGetEvent($this->Parent->Report_Header->CCSEvents, "OnCalculate", $this->Parent->Report_Header);
            $Group->SetControls();
            $Group->Mode = 1;
            $Group->GroupType = "Report";
            $this->Groups[] = & $Group;
            $this->OpenPage();
        }
    }

    function ClosePage() {
        $Group = & $this->InitGroup();
        $this->Parent->Page_Footer->CCSEventResult = CCGetEvent($this->Parent->Page_Footer->CCSEvents, "OnInitialize", $this->Parent->Page_Footer);
        $Group->SetTotalControls("GetPrevValue");
        $Group->SyncWithHeader($this->Groups[$this->mPageCurrentHeaderIndex]);
        $this->Parent->Page_Footer->CCSEventResult = CCGetEvent($this->Parent->Page_Footer->CCSEvents, "OnCalculate", $this->Parent->Page_Footer);
        $Group->SetControls();
        $this->RestoreValues();
        $this->CurrentPageSize = 0;
        $Group->Mode = 2;
        $Group->GroupType = "Page";
        $this->Groups[] = & $Group;
    }

    function CloseGroup($groupName)
    {
        $Group = "";
        if ($groupName == "Report") {
            $Group = & $this->InitGroup(true);
            $this->Parent->Report_Footer->CCSEventResult = CCGetEvent($this->Parent->Report_Footer->CCSEvents, "OnInitialize", $this->Parent->Report_Footer);
            if ($this->Parent->Page_Footer->Visible) 
                $OverSize = $this->Parent->Report_Footer->Height + $this->Parent->Page_Footer->Height;
            else
                $OverSize = $this->Parent->Report_Footer->Height;
            if (($this->PageSize > 0) and $this->Parent->Report_Footer->Visible and ($this->CurrentPageSize + $OverSize > $this->PageSize)) {
                $this->ClosePage();
                $this->OpenPage();
            }
            $Group->SetTotalControls("GetPrevValue");
            $Group->SyncWithHeader($this->Groups[0]);
            if ($this->Parent->Report_Footer->Visible)
                $this->CurrentPageSize = $this->CurrentPageSize + $this->Parent->Report_Footer->Height;
            $this->Parent->Report_Footer->CCSEventResult = CCGetEvent($this->Parent->Report_Footer->CCSEvents, "OnCalculate", $this->Parent->Report_Footer);
            $Group->SetControls();
            $this->RestoreValues();
            $Group->Mode = 2;
            $Group->GroupType = "Report";
            $this->Groups[] = & $Group;
            $this->ClosePage();
            return;
        }
    }

    function AddItem()
    {
        $Group = & $this->InitGroup(true);
        $this->Parent->Detail->CCSEventResult = CCGetEvent($this->Parent->Detail->CCSEvents, "OnInitialize", $this->Parent->Detail);
        if ($this->Parent->Page_Footer->Visible) 
            $OverSize = $this->Parent->Detail->Height + $this->Parent->Page_Footer->Height;
        else
            $OverSize = $this->Parent->Detail->Height;
        if (($this->PageSize > 0) and $this->Parent->Detail->Visible and ($this->CurrentPageSize + $OverSize > $this->PageSize)) {
            $this->ClosePage();
            $this->OpenPage();
        }
        $this->TotalRows++;
        if ($this->LastDetailIndex)
            $PrevGroup = & $this->Groups[$this->LastDetailIndex];
        else
            $PrevGroup = "";
        $Group->SetTotalControls("", $PrevGroup);
        if ($this->Parent->Detail->Visible)
            $this->CurrentPageSize = $this->CurrentPageSize + $this->Parent->Detail->Height;
        $this->Parent->Detail->CCSEventResult = CCGetEvent($this->Parent->Detail->CCSEvents, "OnCalculate", $this->Parent->Detail);
        $Group->SetControls($PrevGroup);
        $this->LastDetailIndex = count($this->Groups);
        $this->Groups[] = & $Group;
    }
}
//End Report2 GroupsCollection class

class clsReportReport2 { //Report2 Class @89-9702E34F

//Report2 Variables @89-87F7EA53

    var $ComponentType = "Report";
    var $PageSize;
    var $ComponentName;
    var $Visible;
    var $Errors;
    var $CCSEvents = array();
    var $CCSEventResult;
    var $RelativePath = "";
    var $ViewMode = "Web";
    var $TemplateBlock;
    var $PageNumber;
    var $RowNumber;
    var $TotalRows;
    var $TotalPages;
    var $ControlsVisible = array();
    var $IsEmpty;
    var $Attributes;
    var $DetailBlock, $Detail;
    var $Report_FooterBlock, $Report_Footer;
    var $Report_HeaderBlock, $Report_Header;
    var $Page_FooterBlock, $Page_Footer;
    var $Page_HeaderBlock, $Page_Header;
    var $SorterName, $SorterDirection;

    var $ds;
    var $DataSource;
    var $UseClientPaging = false;

    //Report Controls
    var $StaticControls, $RowControls, $Report_FooterControls, $Report_HeaderControls;
    var $Page_FooterControls, $Page_HeaderControls;
//End Report2 Variables

//Class_Initialize Event @89-D36764A9
    function clsReportReport2($RelativePath = "", & $Parent)
    {
        global $FileName;
        global $CCSLocales;
        global $DefaultDateFormat;
        $this->ComponentName = "Report2";
        $this->Visible = True;
        $this->Parent = & $Parent;
        $this->RelativePath = $RelativePath;
        $this->Attributes = new clsAttributes($this->ComponentName . ":");
        $this->Detail = new clsSection($this);
        $MinPageSize = 0;
        $MaxSectionSize = 0;
        $this->Detail->Height = 1;
        $MaxSectionSize = max($MaxSectionSize, $this->Detail->Height);
        $this->Report_Footer = new clsSection($this);
        $this->Report_Footer->Height = 1;
        $MaxSectionSize = max($MaxSectionSize, $this->Report_Footer->Height);
        $this->Report_Header = new clsSection($this);
        $this->Page_Footer = new clsSection($this);
        $this->Page_Footer->Height = 1;
        $MinPageSize += $this->Page_Footer->Height;
        $this->Page_Header = new clsSection($this);
        $this->Page_Header->Height = 1;
        $MinPageSize += $this->Page_Header->Height;
        $this->Errors = new clsErrors();
        $this->DataSource = new clsReport2DataSource($this);
        $this->ds = & $this->DataSource;
        $PageSize = CCGetParam($this->ComponentName . "PageSize", "");
        if(is_numeric($PageSize) && $PageSize > 0) {
            $this->PageSize = $PageSize;
        } else {
            if (!is_numeric($PageSize) || $PageSize < 0)
                $this->PageSize = 40;
             else if ($PageSize == "0")
                $this->PageSize = 100;
             else 
                $this->PageSize = min(100, $PageSize);
        }
        $MinPageSize += $MaxSectionSize;
        if ($this->PageSize && $MinPageSize && $this->PageSize < $MinPageSize)
            $this->PageSize = $MinPageSize;
        $this->PageNumber = $this->ViewMode == "Print" ? 1 : intval(CCGetParam($this->ComponentName . "Page", 1));
        if ($this->PageNumber <= 0 ) {
            $this->PageNumber = 1;
        }

        $this->Accttype = & new clsControl(ccsReportLabel, "Accttype", "Accttype", ccsText, "", "", $this);
        $this->Acct = & new clsControl(ccsReportLabel, "Acct", "Acct", ccsText, "", "", $this);
        $this->Sub = & new clsControl(ccsReportLabel, "Sub", "Sub", ccsText, "", "", $this);
        $this->Descr = & new clsControl(ccsReportLabel, "Descr", "Descr", ccsText, "", "", $this);
        $this->Opening = & new clsControl(ccsReportLabel, "Opening", "Opening", ccsFloat, array(False, 2, Null, Null, False, "", "", 1, True, ""), "", $this);
        $this->Dr = & new clsControl(ccsReportLabel, "Dr", "Dr", ccsFloat, array(False, 2, Null, Null, False, "", "", 1, True, ""), "", $this);
        $this->Cr = & new clsControl(ccsReportLabel, "Cr", "Cr", ccsFloat, array(False, 2, Null, Null, False, "", "", 1, True, ""), "", $this);
        $this->ClosingVal = & new clsControl(ccsReportLabel, "ClosingVal", "ClosingVal", ccsFloat, array(False, 2, Null, Null, False, "", "", 1, True, ""), "", $this);
        $this->NoRecords = & new clsPanel("NoRecords", $this);
        $this->TotalSum_FiscalYear = & new clsControl(ccsReportLabel, "TotalSum_FiscalYear", "TotalSum_FiscalYear", ccsFloat, array(False, 2, Null, Null, False, "", "", 1, True, ""), "", $this);
        $this->TotalSum_FiscalYear->TotalFunction = "Sum";
        $this->TotalSum_Dr = & new clsControl(ccsReportLabel, "TotalSum_Dr", "TotalSum_Dr", ccsFloat, array(False, 2, Null, Null, False, "", "", 1, True, ""), "", $this);
        $this->TotalSum_Dr->TotalFunction = "Sum";
        $this->TotalSum_Cr = & new clsControl(ccsReportLabel, "TotalSum_Cr", "TotalSum_Cr", ccsFloat, array(False, 2, Null, Null, False, "", "", 1, True, ""), "", $this);
        $this->TotalSum_Cr->TotalFunction = "Sum";
        $this->TotalSum_ClosingVal = & new clsControl(ccsReportLabel, "TotalSum_ClosingVal", "TotalSum_ClosingVal", ccsFloat, array(False, 2, Null, Null, False, "", "", 1, True, ""), "", $this);
        $this->TotalSum_ClosingVal->TotalFunction = "Sum";
        $this->Report_CurrentDate = & new clsControl(ccsReportLabel, "Report_CurrentDate", "Report_CurrentDate", ccsText, array('ShortDate'), "", $this);
        $this->Report_CurrentPage = & new clsControl(ccsReportLabel, "Report_CurrentPage", "Report_CurrentPage", ccsInteger, "", "", $this);
        $this->Report_TotalPages = & new clsControl(ccsReportLabel, "Report_TotalPages", "Report_TotalPages", ccsInteger, "", "", $this);
        $this->Navigator = & new clsNavigator($this->ComponentName, "Navigator", $FileName, 10, tpCentered, $this);
        $this->Navigator->PageSizes = array("1", "5", "10", "25", "50");
    }
//End Class_Initialize Event

//Initialize Method @89-6C59EE65
    function Initialize()
    {
        if(!$this->Visible) return;

        $this->DataSource->PageSize = $this->PageSize;
        $this->DataSource->AbsolutePage = $this->PageNumber;
        $this->DataSource->SetOrder($this->SorterName, $this->SorterDirection);
    }
//End Initialize Method

//CheckErrors Method @89-C301144C
    function CheckErrors()
    {
        $errors = false;
        $errors = ($errors || $this->Accttype->Errors->Count());
        $errors = ($errors || $this->Acct->Errors->Count());
        $errors = ($errors || $this->Sub->Errors->Count());
        $errors = ($errors || $this->Descr->Errors->Count());
        $errors = ($errors || $this->Opening->Errors->Count());
        $errors = ($errors || $this->Dr->Errors->Count());
        $errors = ($errors || $this->Cr->Errors->Count());
        $errors = ($errors || $this->ClosingVal->Errors->Count());
        $errors = ($errors || $this->TotalSum_FiscalYear->Errors->Count());
        $errors = ($errors || $this->TotalSum_Dr->Errors->Count());
        $errors = ($errors || $this->TotalSum_Cr->Errors->Count());
        $errors = ($errors || $this->TotalSum_ClosingVal->Errors->Count());
        $errors = ($errors || $this->Report_CurrentDate->Errors->Count());
        $errors = ($errors || $this->Report_CurrentPage->Errors->Count());
        $errors = ($errors || $this->Report_TotalPages->Errors->Count());
        $errors = ($errors || $this->Errors->Count());
        $errors = ($errors || $this->DataSource->Errors->Count());
        return $errors;
    }
//End CheckErrors Method

//GetErrors Method @89-D4AE7402
    function GetErrors()
    {
        $errors = "";
        $errors = ComposeStrings($errors, $this->Accttype->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Acct->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Sub->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Descr->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Opening->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Dr->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Cr->Errors->ToString());
        $errors = ComposeStrings($errors, $this->ClosingVal->Errors->ToString());
        $errors = ComposeStrings($errors, $this->TotalSum_FiscalYear->Errors->ToString());
        $errors = ComposeStrings($errors, $this->TotalSum_Dr->Errors->ToString());
        $errors = ComposeStrings($errors, $this->TotalSum_Cr->Errors->ToString());
        $errors = ComposeStrings($errors, $this->TotalSum_ClosingVal->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Report_CurrentDate->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Report_CurrentPage->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Report_TotalPages->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Errors->ToString());
        $errors = ComposeStrings($errors, $this->DataSource->Errors->ToString());
        return $errors;
    }
//End GetErrors Method

//Show Method @89-CA07C3A0
    function Show()
    {
        global $Tpl;
        global $CCSLocales;
        if(!$this->Visible) return;

        $ShownRecords = 0;

        $this->DataSource->Parameters["urls_Period"] = CCGetFromGet("s_Period", NULL);
        $this->DataSource->Parameters["urls_FiscalYear"] = CCGetFromGet("s_FiscalYear", NULL);
        $this->DataSource->Parameters["urlActivity"] = CCGetFromGet("Activity", NULL);
        $this->DataSource->Parameters["urlrptformat"] = CCGetFromGet("rptformat", NULL);

        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeSelect", $this);


        $this->DataSource->Prepare();
        $this->DataSource->Open();

        $Groups = new clsGroupsCollectionReport2($this);
        $Groups->PageSize = $this->PageSize > 0 ? $this->PageSize : 0;

        $is_next_record = $this->DataSource->next_record();
        $this->IsEmpty = ! $is_next_record;
        while($is_next_record) {
            $this->DataSource->SetValues();
            $this->Accttype->SetValue($this->DataSource->Accttype->GetValue());
            $this->Acct->SetValue($this->DataSource->Acct->GetValue());
            $this->Sub->SetValue($this->DataSource->Sub->GetValue());
            $this->Descr->SetValue($this->DataSource->Descr->GetValue());
            $this->Opening->SetValue($this->DataSource->Opening->GetValue());
            $this->Dr->SetValue($this->DataSource->Dr->GetValue());
            $this->Cr->SetValue($this->DataSource->Cr->GetValue());
            $this->ClosingVal->SetValue($this->DataSource->ClosingVal->GetValue());
            $this->TotalSum_FiscalYear->SetValue($this->DataSource->TotalSum_FiscalYear->GetValue());
            $this->TotalSum_Dr->SetValue($this->DataSource->TotalSum_Dr->GetValue());
            $this->TotalSum_Cr->SetValue($this->DataSource->TotalSum_Cr->GetValue());
            $this->TotalSum_ClosingVal->SetValue($this->DataSource->TotalSum_ClosingVal->GetValue());
            if (count($Groups->Groups) == 0) $Groups->OpenGroup("Report");
            $Groups->AddItem();
            $is_next_record = $this->DataSource->next_record();
        }
        if (!count($Groups->Groups)) 
            $Groups->OpenGroup("Report");
        else
            $this->NoRecords->Visible = false;
        $Groups->CloseGroup("Report");
        $this->TotalPages = $Groups->TotalPages;
        $this->TotalRows = $Groups->TotalRows;

        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeShow", $this);
        if(!$this->Visible) return;

        $this->Attributes->Show();
        $ReportBlock = "Report " . $this->ComponentName;
        $ParentPath = $Tpl->block_path;
        $Tpl->block_path = $ParentPath . "/" . $ReportBlock;

        if($this->CheckErrors()) {
            $Tpl->replaceblock("", $this->GetErrors());
            $Tpl->block_path = $ParentPath;
            return;
        } else {
            $items = & $Groups->Groups;
            $i = $Groups->Pages[min($this->PageNumber, $Groups->TotalPages) - 1];
            $this->ControlsVisible["Accttype"] = $this->Accttype->Visible;
            $this->ControlsVisible["Acct"] = $this->Acct->Visible;
            $this->ControlsVisible["Sub"] = $this->Sub->Visible;
            $this->ControlsVisible["Descr"] = $this->Descr->Visible;
            $this->ControlsVisible["Opening"] = $this->Opening->Visible;
            $this->ControlsVisible["Dr"] = $this->Dr->Visible;
            $this->ControlsVisible["Cr"] = $this->Cr->Visible;
            $this->ControlsVisible["ClosingVal"] = $this->ClosingVal->Visible;
            do {
                $this->Attributes->RestoreFromArray($items[$i]->Attributes);
                $this->RowNumber = $items[$i]->RowNumber;
                switch ($items[$i]->GroupType) {
                    Case "":
                        $Tpl->block_path = $ParentPath . "/" . $ReportBlock . "/Section Detail";
                        $this->Accttype->SetValue($items[$i]->Accttype);
                        $this->Accttype->Attributes->RestoreFromArray($items[$i]->_AccttypeAttributes);
                        $this->Acct->SetValue($items[$i]->Acct);
                        $this->Acct->Attributes->RestoreFromArray($items[$i]->_AcctAttributes);
                        $this->Sub->SetValue($items[$i]->Sub);
                        $this->Sub->Attributes->RestoreFromArray($items[$i]->_SubAttributes);
                        $this->Descr->SetValue($items[$i]->Descr);
                        $this->Descr->Attributes->RestoreFromArray($items[$i]->_DescrAttributes);
                        $this->Opening->SetValue($items[$i]->Opening);
                        $this->Opening->Attributes->RestoreFromArray($items[$i]->_OpeningAttributes);
                        $this->Dr->SetValue($items[$i]->Dr);
                        $this->Dr->Attributes->RestoreFromArray($items[$i]->_DrAttributes);
                        $this->Cr->SetValue($items[$i]->Cr);
                        $this->Cr->Attributes->RestoreFromArray($items[$i]->_CrAttributes);
                        $this->ClosingVal->SetValue($items[$i]->ClosingVal);
                        $this->ClosingVal->Attributes->RestoreFromArray($items[$i]->_ClosingValAttributes);
                        $this->Detail->CCSEventResult = CCGetEvent($this->Detail->CCSEvents, "BeforeShow", $this->Detail);
                        $this->Attributes->Show();
                        $this->Accttype->Show();
                        $this->Acct->Show();
                        $this->Sub->Show();
                        $this->Descr->Show();
                        $this->Opening->Show();
                        $this->Dr->Show();
                        $this->Cr->Show();
                        $this->ClosingVal->Show();
                        $Tpl->block_path = $ParentPath . "/" . $ReportBlock;
                        if ($this->Detail->Visible)
                            $Tpl->parseto("Section Detail", true, "Section Detail");
                        break;
                    case "Report":
                        if ($items[$i]->Mode == 1) {
                            $this->Report_Header->CCSEventResult = CCGetEvent($this->Report_Header->CCSEvents, "BeforeShow", $this->Report_Header);
                            if ($this->Report_Header->Visible) {
                                $Tpl->block_path = $ParentPath . "/" . $ReportBlock . "/Section Report_Header";
                                $this->Attributes->Show();
                                $Tpl->block_path = $ParentPath . "/" . $ReportBlock;
                                $Tpl->parseto("Section Report_Header", true, "Section Detail");
                            }
                        }
                        if ($items[$i]->Mode == 2) {
                            $this->TotalSum_FiscalYear->SetText(CCFormatNumber($items[$i]->TotalSum_FiscalYear, array(False, 2, Null, Null, False, "", "", 1, True, "")), ccsFloat);
                            $this->TotalSum_FiscalYear->Attributes->RestoreFromArray($items[$i]->_TotalSum_FiscalYearAttributes);
                            $this->TotalSum_Dr->SetText(CCFormatNumber($items[$i]->TotalSum_Dr, array(False, 2, Null, Null, False, "", "", 1, True, "")), ccsFloat);
                            $this->TotalSum_Dr->Attributes->RestoreFromArray($items[$i]->_TotalSum_DrAttributes);
                            $this->TotalSum_Cr->SetText(CCFormatNumber($items[$i]->TotalSum_Cr, array(False, 2, Null, Null, False, "", "", 1, True, "")), ccsFloat);
                            $this->TotalSum_Cr->Attributes->RestoreFromArray($items[$i]->_TotalSum_CrAttributes);
                            $this->TotalSum_ClosingVal->SetText(CCFormatNumber($items[$i]->TotalSum_ClosingVal, array(False, 2, Null, Null, False, "", "", 1, True, "")), ccsFloat);
                            $this->TotalSum_ClosingVal->Attributes->RestoreFromArray($items[$i]->_TotalSum_ClosingValAttributes);
                            $this->Report_Footer->CCSEventResult = CCGetEvent($this->Report_Footer->CCSEvents, "BeforeShow", $this->Report_Footer);
                            if ($this->Report_Footer->Visible) {
                                $Tpl->block_path = $ParentPath . "/" . $ReportBlock . "/Section Report_Footer";
                                $this->NoRecords->Show();
                                $this->TotalSum_FiscalYear->Show();
                                $this->TotalSum_Dr->Show();
                                $this->TotalSum_Cr->Show();
                                $this->TotalSum_ClosingVal->Show();
                                $this->Attributes->Show();
                                $Tpl->block_path = $ParentPath . "/" . $ReportBlock;
                                $Tpl->parseto("Section Report_Footer", true, "Section Detail");
                            }
                        }
                        break;
                    case "Page":
                        if ($items[$i]->Mode == 1) {
                            $this->Page_Header->CCSEventResult = CCGetEvent($this->Page_Header->CCSEvents, "BeforeShow", $this->Page_Header);
                            if ($this->Page_Header->Visible) {
                                $Tpl->block_path = $ParentPath . "/" . $ReportBlock . "/Section Page_Header";
                                $this->Attributes->Show();
                                $Tpl->block_path = $ParentPath . "/" . $ReportBlock;
                                $Tpl->parseto("Section Page_Header", true, "Section Detail");
                            }
                        }
                        if ($items[$i]->Mode == 2 && !$this->UseClientPaging || $items[$i]->Mode == 1 && $this->UseClientPaging) {
                            $this->Report_CurrentDate->SetValue(CCFormatDate(CCGetDateArray(), $this->Report_CurrentDate->Format));
                            $this->Report_CurrentDate->Attributes->RestoreFromArray($items[$i]->_Report_CurrentDateAttributes);
                            $this->Report_CurrentPage->SetValue($items[$i]->PageNumber);
                            $this->Report_CurrentPage->Attributes->RestoreFromArray($items[$i]->_Report_CurrentPageAttributes);
                            $this->Report_TotalPages->SetValue($Groups->TotalPages);
                            $this->Report_TotalPages->Attributes->RestoreFromArray($items[$i]->_Report_TotalPagesAttributes);
                            $this->Navigator->PageNumber = $items[$i]->PageNumber;
                            $this->Navigator->TotalPages = $Groups->TotalPages;
                            $this->Navigator->Visible = ("Print" != $this->ViewMode);
                            $this->Page_Footer->CCSEventResult = CCGetEvent($this->Page_Footer->CCSEvents, "BeforeShow", $this->Page_Footer);
                            if ($this->Page_Footer->Visible) {
                                $Tpl->block_path = $ParentPath . "/" . $ReportBlock . "/Section Page_Footer";
                                $this->Report_CurrentDate->Show();
                                $this->Report_CurrentPage->Show();
                                $this->Report_TotalPages->Show();
                                $this->Navigator->Show();
                                $this->Attributes->Show();
                                $Tpl->block_path = $ParentPath . "/" . $ReportBlock;
                                $Tpl->parseto("Section Page_Footer", true, "Section Detail");
                            }
                        }
                        break;
                }
                $i++;
            } while ($i < count($items) && ($this->ViewMode == "Print" ||  !($i > 1 && $items[$i]->GroupType == 'Page' && $items[$i]->Mode == 1)));
            $Tpl->block_path = $ParentPath;
            $Tpl->parse($ReportBlock);
            $this->DataSource->close();
        }

    }
//End Show Method

} //End Report2 Class @89-FCB6E20C

class clsReport2DataSource extends clsDBCoopWorksConn {  //Report2DataSource Class @89-E6A5DAA8

//DataSource Variables @89-9270AE1D
    var $Parent = "";
    var $CCSEvents = "";
    var $CCSEventResult;
    var $ErrorBlock;
    var $CmdExecution;



    // Datasource fields
    var $Accttype;
    var $Acct;
    var $Sub;
    var $Descr;
    var $Opening;
    var $Dr;
    var $Cr;
    var $ClosingVal;
    var $TotalSum_FiscalYear;
    var $TotalSum_Dr;
    var $TotalSum_Cr;
    var $TotalSum_ClosingVal;
//End DataSource Variables

//DataSourceClass_Initialize Event @89-F388C84F
    function clsReport2DataSource(& $Parent)
    {
        $this->Parent = & $Parent;
        $this->ErrorBlock = "Report Report2";
        $this->Initialize();
        $this->Accttype = new clsField("Accttype", ccsText, "");
        
        $this->Acct = new clsField("Acct", ccsText, "");
        
        $this->Sub = new clsField("Sub", ccsText, "");
        
        $this->Descr = new clsField("Descr", ccsText, "");
        
        $this->Opening = new clsField("Opening", ccsFloat, "");
        
        $this->Dr = new clsField("Dr", ccsFloat, "");
        
        $this->Cr = new clsField("Cr", ccsFloat, "");
        
        $this->ClosingVal = new clsField("ClosingVal", ccsFloat, "");
        
        $this->TotalSum_FiscalYear = new clsField("TotalSum_FiscalYear", ccsFloat, "");
        
        $this->TotalSum_Dr = new clsField("TotalSum_Dr", ccsFloat, "");
        
        $this->TotalSum_Cr = new clsField("TotalSum_Cr", ccsFloat, "");
        
        $this->TotalSum_ClosingVal = new clsField("TotalSum_ClosingVal", ccsFloat, "");
        

    }
//End DataSourceClass_Initialize Event

//SetOrder Method @89-BF7F5B01
    function SetOrder($SorterName, $SorterDirection)
    {
        $this->Order = CCGetOrder($this->Order, $SorterName, $SorterDirection, 
            "");
    }
//End SetOrder Method

//Prepare Method @89-14D6CD9D
    function Prepare()
    {
        global $CCSLocales;
        global $DefaultDateFormat;
    }
//End Prepare Method

//Open Method @89-BA0CB28C
    function Open()
    {
        $this->cp["period"] = new clsSQLParameter("urls_Period", ccsText, "", "", CCGetFromGet("s_Period", NULL), "", false, $this->ErrorBlock);
        $this->cp["year2"] = new clsSQLParameter("urls_FiscalYear", ccsInteger, "", "", CCGetFromGet("s_FiscalYear", NULL), "", false, $this->ErrorBlock);
        $this->cp["Activity"] = new clsSQLParameter("urlActivity", ccsText, "", "", CCGetFromGet("Activity", NULL), "", false, $this->ErrorBlock);
        $this->cp["rptformat"] = new clsSQLParameter("urlrptformat", ccsText, "", "", CCGetFromGet("rptformat", NULL), "", false, $this->ErrorBlock);
        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeBuildSelect", $this->Parent);
        $this->SQL = "CALL GL_YTD_TB_EXPENSES (" . $this->ToSQL($this->cp["period"]->GetDBValue(), $this->cp["period"]->DataType) . ", "
             . $this->ToSQL($this->cp["year2"]->GetDBValue(), $this->cp["year2"]->DataType) . ", "
             . $this->ToSQL($this->cp["Activity"]->GetDBValue(), $this->cp["Activity"]->DataType) . ", "
             . $this->ToSQL($this->cp["rptformat"]->GetDBValue(), $this->cp["rptformat"]->DataType) . ");";
        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeExecuteSelect", $this->Parent);
        $this->query($this->SQL);
        $this->RecordsCount = "CCS not counted";
        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterExecuteSelect", $this->Parent);
        if ($this->Errors->count()) return false;
    }
//End Open Method

//SetValues Method @89-E5CEB394
    function SetValues()
    {
        $this->Accttype->SetDBValue($this->f("Accttype"));
        $this->Acct->SetDBValue($this->f("Acct"));
        $this->Sub->SetDBValue($this->f("Sub"));
        $this->Descr->SetDBValue($this->f("Descr"));
        $this->Opening->SetDBValue(trim($this->f("Opening")));
        $this->Dr->SetDBValue(trim($this->f("Dr")));
        $this->Cr->SetDBValue(trim($this->f("Cr")));
        $this->ClosingVal->SetDBValue(trim($this->f("ClosingVal")));
        $this->TotalSum_FiscalYear->SetDBValue(trim($this->f("Opening")));
        $this->TotalSum_Dr->SetDBValue(trim($this->f("Dr")));
        $this->TotalSum_Cr->SetDBValue(trim($this->f("Cr")));
        $this->TotalSum_ClosingVal->SetDBValue(trim($this->f("ClosingVal")));
    }
//End SetValues Method

} //End Report2DataSource Class @89-FCB6E20C

//Report3 ReportGroup class @182-09389E33
class clsReportGroupReport3 {
    var $GroupType;
    var $mode; //1 - open, 2 - close
    var $Accttype, $_AccttypeAttributes;
    var $Acct, $_AcctAttributes;
    var $Sub, $_SubAttributes;
    var $Descr, $_DescrAttributes;
    var $Opening, $_OpeningAttributes;
    var $Dr, $_DrAttributes;
    var $Cr, $_CrAttributes;
    var $ClosingVal, $_ClosingValAttributes;
    var $TotalSum_Opening, $_TotalSum_OpeningAttributes;
    var $TotalSum_Dr, $_TotalSum_DrAttributes;
    var $TotalSum_Cr, $_TotalSum_CrAttributes;
    var $TotalSum_ClosingVal, $_TotalSum_ClosingValAttributes;
    var $Report_CurrentDate, $_Report_CurrentDateAttributes;
    var $Report_CurrentPage, $_Report_CurrentPageAttributes;
    var $Report_TotalPages, $_Report_TotalPagesAttributes;
    var $Attributes;
    var $ReportTotalIndex = 0;
    var $PageTotalIndex;
    var $PageNumber;
    var $RowNumber;
    var $Parent;

    function clsReportGroupReport3(& $parent) {
        $this->Parent = & $parent;
        $this->Attributes = $this->Parent->Attributes->GetAsArray();
    }
    function SetControls($PrevGroup = "") {
        $this->Accttype = $this->Parent->Accttype->Value;
        $this->Acct = $this->Parent->Acct->Value;
        $this->Sub = $this->Parent->Sub->Value;
        $this->Descr = $this->Parent->Descr->Value;
        $this->Opening = $this->Parent->Opening->Value;
        $this->Dr = $this->Parent->Dr->Value;
        $this->Cr = $this->Parent->Cr->Value;
        $this->ClosingVal = $this->Parent->ClosingVal->Value;
    }

    function SetTotalControls($mode = "", $PrevGroup = "") {
        $this->TotalSum_Opening = $this->Parent->TotalSum_Opening->GetTotalValue($mode);
        $this->TotalSum_Dr = $this->Parent->TotalSum_Dr->GetTotalValue($mode);
        $this->TotalSum_Cr = $this->Parent->TotalSum_Cr->GetTotalValue($mode);
        $this->TotalSum_ClosingVal = $this->Parent->TotalSum_ClosingVal->GetTotalValue($mode);
        $this->_AccttypeAttributes = $this->Parent->Accttype->Attributes->GetAsArray();
        $this->_AcctAttributes = $this->Parent->Acct->Attributes->GetAsArray();
        $this->_SubAttributes = $this->Parent->Sub->Attributes->GetAsArray();
        $this->_DescrAttributes = $this->Parent->Descr->Attributes->GetAsArray();
        $this->_OpeningAttributes = $this->Parent->Opening->Attributes->GetAsArray();
        $this->_DrAttributes = $this->Parent->Dr->Attributes->GetAsArray();
        $this->_CrAttributes = $this->Parent->Cr->Attributes->GetAsArray();
        $this->_ClosingValAttributes = $this->Parent->ClosingVal->Attributes->GetAsArray();
        $this->_TotalSum_OpeningAttributes = $this->Parent->TotalSum_Opening->Attributes->GetAsArray();
        $this->_TotalSum_DrAttributes = $this->Parent->TotalSum_Dr->Attributes->GetAsArray();
        $this->_TotalSum_CrAttributes = $this->Parent->TotalSum_Cr->Attributes->GetAsArray();
        $this->_TotalSum_ClosingValAttributes = $this->Parent->TotalSum_ClosingVal->Attributes->GetAsArray();
        $this->_Report_CurrentDateAttributes = $this->Parent->Report_CurrentDate->Attributes->GetAsArray();
        $this->_Report_CurrentPageAttributes = $this->Parent->Report_CurrentPage->Attributes->GetAsArray();
        $this->_Report_TotalPagesAttributes = $this->Parent->Report_TotalPages->Attributes->GetAsArray();
        $this->_NavigatorAttributes = $this->Parent->Navigator->Attributes->GetAsArray();
    }
    function SyncWithHeader(& $Header) {
        $Header->TotalSum_Opening = $this->TotalSum_Opening;
        $Header->_TotalSum_OpeningAttributes = $this->_TotalSum_OpeningAttributes;
        $Header->TotalSum_Dr = $this->TotalSum_Dr;
        $Header->_TotalSum_DrAttributes = $this->_TotalSum_DrAttributes;
        $Header->TotalSum_Cr = $this->TotalSum_Cr;
        $Header->_TotalSum_CrAttributes = $this->_TotalSum_CrAttributes;
        $Header->TotalSum_ClosingVal = $this->TotalSum_ClosingVal;
        $Header->_TotalSum_ClosingValAttributes = $this->_TotalSum_ClosingValAttributes;
        $this->Accttype = $Header->Accttype;
        $Header->_AccttypeAttributes = $this->_AccttypeAttributes;
        $this->Parent->Accttype->Value = $Header->Accttype;
        $this->Parent->Accttype->Attributes->RestoreFromArray($Header->_AccttypeAttributes);
        $this->Acct = $Header->Acct;
        $Header->_AcctAttributes = $this->_AcctAttributes;
        $this->Parent->Acct->Value = $Header->Acct;
        $this->Parent->Acct->Attributes->RestoreFromArray($Header->_AcctAttributes);
        $this->Sub = $Header->Sub;
        $Header->_SubAttributes = $this->_SubAttributes;
        $this->Parent->Sub->Value = $Header->Sub;
        $this->Parent->Sub->Attributes->RestoreFromArray($Header->_SubAttributes);
        $this->Descr = $Header->Descr;
        $Header->_DescrAttributes = $this->_DescrAttributes;
        $this->Parent->Descr->Value = $Header->Descr;
        $this->Parent->Descr->Attributes->RestoreFromArray($Header->_DescrAttributes);
        $this->Opening = $Header->Opening;
        $Header->_OpeningAttributes = $this->_OpeningAttributes;
        $this->Parent->Opening->Value = $Header->Opening;
        $this->Parent->Opening->Attributes->RestoreFromArray($Header->_OpeningAttributes);
        $this->Dr = $Header->Dr;
        $Header->_DrAttributes = $this->_DrAttributes;
        $this->Parent->Dr->Value = $Header->Dr;
        $this->Parent->Dr->Attributes->RestoreFromArray($Header->_DrAttributes);
        $this->Cr = $Header->Cr;
        $Header->_CrAttributes = $this->_CrAttributes;
        $this->Parent->Cr->Value = $Header->Cr;
        $this->Parent->Cr->Attributes->RestoreFromArray($Header->_CrAttributes);
        $this->ClosingVal = $Header->ClosingVal;
        $Header->_ClosingValAttributes = $this->_ClosingValAttributes;
        $this->Parent->ClosingVal->Value = $Header->ClosingVal;
        $this->Parent->ClosingVal->Attributes->RestoreFromArray($Header->_ClosingValAttributes);
    }
    function ChangeTotalControls() {
        $this->TotalSum_Opening = $this->Parent->TotalSum_Opening->GetValue();
        $this->TotalSum_Dr = $this->Parent->TotalSum_Dr->GetValue();
        $this->TotalSum_Cr = $this->Parent->TotalSum_Cr->GetValue();
        $this->TotalSum_ClosingVal = $this->Parent->TotalSum_ClosingVal->GetValue();
    }
}
//End Report3 ReportGroup class

//Report3 GroupsCollection class @182-961D2C6A
class clsGroupsCollectionReport3 {
    var $Groups;
    var $mPageCurrentHeaderIndex;
    var $PageSize;
    var $TotalPages = 0;
    var $TotalRows = 0;
    var $CurrentPageSize = 0;
    var $Pages;
    var $Parent;
    var $LastDetailIndex;

    function clsGroupsCollectionReport3(& $parent) {
        $this->Parent = & $parent;
        $this->Groups = array();
        $this->Pages  = array();
        $this->mReportTotalIndex = 0;
        $this->mPageTotalIndex = 1;
    }

    function & InitGroup() {
        $group = new clsReportGroupReport3($this->Parent);
        $group->RowNumber = $this->TotalRows + 1;
        $group->PageNumber = $this->TotalPages;
        $group->PageTotalIndex = $this->mPageCurrentHeaderIndex;
        return $group;
    }

    function RestoreValues() {
        $this->Parent->Accttype->Value = $this->Parent->Accttype->initialValue;
        $this->Parent->Acct->Value = $this->Parent->Acct->initialValue;
        $this->Parent->Sub->Value = $this->Parent->Sub->initialValue;
        $this->Parent->Descr->Value = $this->Parent->Descr->initialValue;
        $this->Parent->Opening->Value = $this->Parent->Opening->initialValue;
        $this->Parent->Dr->Value = $this->Parent->Dr->initialValue;
        $this->Parent->Cr->Value = $this->Parent->Cr->initialValue;
        $this->Parent->ClosingVal->Value = $this->Parent->ClosingVal->initialValue;
        $this->Parent->TotalSum_Opening->Value = $this->Parent->TotalSum_Opening->initialValue;
        $this->Parent->TotalSum_Dr->Value = $this->Parent->TotalSum_Dr->initialValue;
        $this->Parent->TotalSum_Cr->Value = $this->Parent->TotalSum_Cr->initialValue;
        $this->Parent->TotalSum_ClosingVal->Value = $this->Parent->TotalSum_ClosingVal->initialValue;
    }

    function OpenPage() {
        $this->TotalPages++;
        $Group = & $this->InitGroup();
        $this->Parent->Page_Header->CCSEventResult = CCGetEvent($this->Parent->Page_Header->CCSEvents, "OnInitialize", $this->Parent->Page_Header);
        if ($this->Parent->Page_Header->Visible)
            $this->CurrentPageSize = $this->CurrentPageSize + $this->Parent->Page_Header->Height;
        $Group->SetTotalControls("GetNextValue");
        $this->Parent->Page_Header->CCSEventResult = CCGetEvent($this->Parent->Page_Header->CCSEvents, "OnCalculate", $this->Parent->Page_Header);
        $Group->SetControls();
        $Group->Mode = 1;
        $Group->GroupType = "Page";
        $Group->PageTotalIndex = count($this->Groups);
        $this->mPageCurrentHeaderIndex = count($this->Groups);
        $this->Groups[] =  & $Group;
        $this->Pages[] =  count($this->Groups) == 2 ? 0 : count($this->Groups) - 1;
    }

    function OpenGroup($groupName) {
        $Group = "";
        $OpenFlag = false;
        if ($groupName == "Report") {
            $Group = & $this->InitGroup(true);
            $this->Parent->Report_Header->CCSEventResult = CCGetEvent($this->Parent->Report_Header->CCSEvents, "OnInitialize", $this->Parent->Report_Header);
            if ($this->Parent->Report_Header->Visible) 
                $this->CurrentPageSize = $this->CurrentPageSize + $this->Parent->Report_Header->Height;
                $Group->SetTotalControls("GetNextValue");
            $this->Parent->Report_Header->CCSEventResult = CCGetEvent($this->Parent->Report_Header->CCSEvents, "OnCalculate", $this->Parent->Report_Header);
            $Group->SetControls();
            $Group->Mode = 1;
            $Group->GroupType = "Report";
            $this->Groups[] = & $Group;
            $this->OpenPage();
        }
    }

    function ClosePage() {
        $Group = & $this->InitGroup();
        $this->Parent->Page_Footer->CCSEventResult = CCGetEvent($this->Parent->Page_Footer->CCSEvents, "OnInitialize", $this->Parent->Page_Footer);
        $Group->SetTotalControls("GetPrevValue");
        $Group->SyncWithHeader($this->Groups[$this->mPageCurrentHeaderIndex]);
        $this->Parent->Page_Footer->CCSEventResult = CCGetEvent($this->Parent->Page_Footer->CCSEvents, "OnCalculate", $this->Parent->Page_Footer);
        $Group->SetControls();
        $this->RestoreValues();
        $this->CurrentPageSize = 0;
        $Group->Mode = 2;
        $Group->GroupType = "Page";
        $this->Groups[] = & $Group;
    }

    function CloseGroup($groupName)
    {
        $Group = "";
        if ($groupName == "Report") {
            $Group = & $this->InitGroup(true);
            $this->Parent->Report_Footer->CCSEventResult = CCGetEvent($this->Parent->Report_Footer->CCSEvents, "OnInitialize", $this->Parent->Report_Footer);
            if ($this->Parent->Page_Footer->Visible) 
                $OverSize = $this->Parent->Report_Footer->Height + $this->Parent->Page_Footer->Height;
            else
                $OverSize = $this->Parent->Report_Footer->Height;
            if (($this->PageSize > 0) and $this->Parent->Report_Footer->Visible and ($this->CurrentPageSize + $OverSize > $this->PageSize)) {
                $this->ClosePage();
                $this->OpenPage();
            }
            $Group->SetTotalControls("GetPrevValue");
            $Group->SyncWithHeader($this->Groups[0]);
            if ($this->Parent->Report_Footer->Visible)
                $this->CurrentPageSize = $this->CurrentPageSize + $this->Parent->Report_Footer->Height;
            $this->Parent->Report_Footer->CCSEventResult = CCGetEvent($this->Parent->Report_Footer->CCSEvents, "OnCalculate", $this->Parent->Report_Footer);
            $Group->SetControls();
            $this->RestoreValues();
            $Group->Mode = 2;
            $Group->GroupType = "Report";
            $this->Groups[] = & $Group;
            $this->ClosePage();
            return;
        }
    }

    function AddItem()
    {
        $Group = & $this->InitGroup(true);
        $this->Parent->Detail->CCSEventResult = CCGetEvent($this->Parent->Detail->CCSEvents, "OnInitialize", $this->Parent->Detail);
        if ($this->Parent->Page_Footer->Visible) 
            $OverSize = $this->Parent->Detail->Height + $this->Parent->Page_Footer->Height;
        else
            $OverSize = $this->Parent->Detail->Height;
        if (($this->PageSize > 0) and $this->Parent->Detail->Visible and ($this->CurrentPageSize + $OverSize > $this->PageSize)) {
            $this->ClosePage();
            $this->OpenPage();
        }
        $this->TotalRows++;
        if ($this->LastDetailIndex)
            $PrevGroup = & $this->Groups[$this->LastDetailIndex];
        else
            $PrevGroup = "";
        $Group->SetTotalControls("", $PrevGroup);
        if ($this->Parent->Detail->Visible)
            $this->CurrentPageSize = $this->CurrentPageSize + $this->Parent->Detail->Height;
        $this->Parent->Detail->CCSEventResult = CCGetEvent($this->Parent->Detail->CCSEvents, "OnCalculate", $this->Parent->Detail);
        $Group->SetControls($PrevGroup);
        $this->LastDetailIndex = count($this->Groups);
        $this->Groups[] = & $Group;
    }
}
//End Report3 GroupsCollection class

class clsReportReport3 { //Report3 Class @182-8E19D20E

//Report3 Variables @182-87F7EA53

    var $ComponentType = "Report";
    var $PageSize;
    var $ComponentName;
    var $Visible;
    var $Errors;
    var $CCSEvents = array();
    var $CCSEventResult;
    var $RelativePath = "";
    var $ViewMode = "Web";
    var $TemplateBlock;
    var $PageNumber;
    var $RowNumber;
    var $TotalRows;
    var $TotalPages;
    var $ControlsVisible = array();
    var $IsEmpty;
    var $Attributes;
    var $DetailBlock, $Detail;
    var $Report_FooterBlock, $Report_Footer;
    var $Report_HeaderBlock, $Report_Header;
    var $Page_FooterBlock, $Page_Footer;
    var $Page_HeaderBlock, $Page_Header;
    var $SorterName, $SorterDirection;

    var $ds;
    var $DataSource;
    var $UseClientPaging = false;

    //Report Controls
    var $StaticControls, $RowControls, $Report_FooterControls, $Report_HeaderControls;
    var $Page_FooterControls, $Page_HeaderControls;
//End Report3 Variables

//Class_Initialize Event @182-02A79FE3
    function clsReportReport3($RelativePath = "", & $Parent)
    {
        global $FileName;
        global $CCSLocales;
        global $DefaultDateFormat;
        $this->ComponentName = "Report3";
        $this->Visible = True;
        $this->Parent = & $Parent;
        $this->RelativePath = $RelativePath;
        $this->Attributes = new clsAttributes($this->ComponentName . ":");
        $this->Detail = new clsSection($this);
        $MinPageSize = 0;
        $MaxSectionSize = 0;
        $this->Detail->Height = 1;
        $MaxSectionSize = max($MaxSectionSize, $this->Detail->Height);
        $this->Report_Footer = new clsSection($this);
        $this->Report_Footer->Height = 1;
        $MaxSectionSize = max($MaxSectionSize, $this->Report_Footer->Height);
        $this->Report_Header = new clsSection($this);
        $this->Page_Footer = new clsSection($this);
        $this->Page_Footer->Height = 1;
        $MinPageSize += $this->Page_Footer->Height;
        $this->Page_Header = new clsSection($this);
        $this->Page_Header->Height = 1;
        $MinPageSize += $this->Page_Header->Height;
        $this->Errors = new clsErrors();
        $this->DataSource = new clsReport3DataSource($this);
        $this->ds = & $this->DataSource;
        $PageSize = CCGetParam($this->ComponentName . "PageSize", "");
        if(is_numeric($PageSize) && $PageSize > 0) {
            $this->PageSize = $PageSize;
        } else {
            if (!is_numeric($PageSize) || $PageSize < 0)
                $this->PageSize = 40;
             else if ($PageSize == "0")
                $this->PageSize = 100;
             else 
                $this->PageSize = min(100, $PageSize);
        }
        $MinPageSize += $MaxSectionSize;
        if ($this->PageSize && $MinPageSize && $this->PageSize < $MinPageSize)
            $this->PageSize = $MinPageSize;
        $this->PageNumber = $this->ViewMode == "Print" ? 1 : intval(CCGetParam($this->ComponentName . "Page", 1));
        if ($this->PageNumber <= 0 ) {
            $this->PageNumber = 1;
        }

        $this->Accttype = & new clsControl(ccsReportLabel, "Accttype", "Accttype", ccsText, "", "", $this);
        $this->Acct = & new clsControl(ccsReportLabel, "Acct", "Acct", ccsText, "", "", $this);
        $this->Sub = & new clsControl(ccsReportLabel, "Sub", "Sub", ccsText, "", "", $this);
        $this->Descr = & new clsControl(ccsReportLabel, "Descr", "Descr", ccsText, "", "", $this);
        $this->Opening = & new clsControl(ccsReportLabel, "Opening", "Opening", ccsFloat, array(False, 2, Null, Null, False, "", "", 1, True, ""), "", $this);
        $this->Dr = & new clsControl(ccsReportLabel, "Dr", "Dr", ccsFloat, array(False, 2, Null, Null, False, "", "", 1, True, ""), "", $this);
        $this->Cr = & new clsControl(ccsReportLabel, "Cr", "Cr", ccsFloat, array(False, 2, Null, Null, False, "", "", 1, True, ""), "", $this);
        $this->ClosingVal = & new clsControl(ccsReportLabel, "ClosingVal", "ClosingVal", ccsFloat, array(False, 2, Null, Null, False, "", "", 1, True, ""), "", $this);
        $this->NoRecords = & new clsPanel("NoRecords", $this);
        $this->TotalSum_Opening = & new clsControl(ccsReportLabel, "TotalSum_Opening", "TotalSum_Opening", ccsFloat, array(False, 2, Null, Null, False, "", "", 1, True, ""), "", $this);
        $this->TotalSum_Opening->TotalFunction = "Sum";
        $this->TotalSum_Dr = & new clsControl(ccsReportLabel, "TotalSum_Dr", "TotalSum_Dr", ccsFloat, array(False, 2, Null, Null, False, "", "", 1, True, ""), "", $this);
        $this->TotalSum_Dr->TotalFunction = "Sum";
        $this->TotalSum_Cr = & new clsControl(ccsReportLabel, "TotalSum_Cr", "TotalSum_Cr", ccsFloat, array(False, 2, Null, Null, False, "", "", 1, True, ""), "", $this);
        $this->TotalSum_Cr->TotalFunction = "Sum";
        $this->TotalSum_ClosingVal = & new clsControl(ccsReportLabel, "TotalSum_ClosingVal", "TotalSum_ClosingVal", ccsFloat, array(False, 2, Null, Null, False, "", "", 1, True, ""), "", $this);
        $this->TotalSum_ClosingVal->TotalFunction = "Sum";
        $this->Report_CurrentDate = & new clsControl(ccsReportLabel, "Report_CurrentDate", "Report_CurrentDate", ccsText, array('ShortDate'), "", $this);
        $this->Report_CurrentPage = & new clsControl(ccsReportLabel, "Report_CurrentPage", "Report_CurrentPage", ccsInteger, "", "", $this);
        $this->Report_TotalPages = & new clsControl(ccsReportLabel, "Report_TotalPages", "Report_TotalPages", ccsInteger, "", "", $this);
        $this->Navigator = & new clsNavigator($this->ComponentName, "Navigator", $FileName, 10, tpCentered, $this);
        $this->Navigator->PageSizes = array("1", "5", "10", "25", "50");
    }
//End Class_Initialize Event

//Initialize Method @182-6C59EE65
    function Initialize()
    {
        if(!$this->Visible) return;

        $this->DataSource->PageSize = $this->PageSize;
        $this->DataSource->AbsolutePage = $this->PageNumber;
        $this->DataSource->SetOrder($this->SorterName, $this->SorterDirection);
    }
//End Initialize Method

//CheckErrors Method @182-B5D86920
    function CheckErrors()
    {
        $errors = false;
        $errors = ($errors || $this->Accttype->Errors->Count());
        $errors = ($errors || $this->Acct->Errors->Count());
        $errors = ($errors || $this->Sub->Errors->Count());
        $errors = ($errors || $this->Descr->Errors->Count());
        $errors = ($errors || $this->Opening->Errors->Count());
        $errors = ($errors || $this->Dr->Errors->Count());
        $errors = ($errors || $this->Cr->Errors->Count());
        $errors = ($errors || $this->ClosingVal->Errors->Count());
        $errors = ($errors || $this->TotalSum_Opening->Errors->Count());
        $errors = ($errors || $this->TotalSum_Dr->Errors->Count());
        $errors = ($errors || $this->TotalSum_Cr->Errors->Count());
        $errors = ($errors || $this->TotalSum_ClosingVal->Errors->Count());
        $errors = ($errors || $this->Report_CurrentDate->Errors->Count());
        $errors = ($errors || $this->Report_CurrentPage->Errors->Count());
        $errors = ($errors || $this->Report_TotalPages->Errors->Count());
        $errors = ($errors || $this->Errors->Count());
        $errors = ($errors || $this->DataSource->Errors->Count());
        return $errors;
    }
//End CheckErrors Method

//GetErrors Method @182-C82EE43B
    function GetErrors()
    {
        $errors = "";
        $errors = ComposeStrings($errors, $this->Accttype->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Acct->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Sub->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Descr->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Opening->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Dr->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Cr->Errors->ToString());
        $errors = ComposeStrings($errors, $this->ClosingVal->Errors->ToString());
        $errors = ComposeStrings($errors, $this->TotalSum_Opening->Errors->ToString());
        $errors = ComposeStrings($errors, $this->TotalSum_Dr->Errors->ToString());
        $errors = ComposeStrings($errors, $this->TotalSum_Cr->Errors->ToString());
        $errors = ComposeStrings($errors, $this->TotalSum_ClosingVal->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Report_CurrentDate->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Report_CurrentPage->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Report_TotalPages->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Errors->ToString());
        $errors = ComposeStrings($errors, $this->DataSource->Errors->ToString());
        return $errors;
    }
//End GetErrors Method

//Show Method @182-188D2D17
    function Show()
    {
        global $Tpl;
        global $CCSLocales;
        if(!$this->Visible) return;

        $ShownRecords = 0;

        $this->DataSource->Parameters["urls_Period"] = CCGetFromGet("s_Period", NULL);
        $this->DataSource->Parameters["urls_FiscalYear"] = CCGetFromGet("s_FiscalYear", NULL);
        $this->DataSource->Parameters["urlActivity"] = CCGetFromGet("Activity", NULL);
        $this->DataSource->Parameters["urlrptformat"] = CCGetFromGet("rptformat", NULL);

        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeSelect", $this);


        $this->DataSource->Prepare();
        $this->DataSource->Open();

        $Groups = new clsGroupsCollectionReport3($this);
        $Groups->PageSize = $this->PageSize > 0 ? $this->PageSize : 0;

        $is_next_record = $this->DataSource->next_record();
        $this->IsEmpty = ! $is_next_record;
        while($is_next_record) {
            $this->DataSource->SetValues();
            $this->Accttype->SetValue($this->DataSource->Accttype->GetValue());
            $this->Acct->SetValue($this->DataSource->Acct->GetValue());
            $this->Sub->SetValue($this->DataSource->Sub->GetValue());
            $this->Descr->SetValue($this->DataSource->Descr->GetValue());
            $this->Opening->SetValue($this->DataSource->Opening->GetValue());
            $this->Dr->SetValue($this->DataSource->Dr->GetValue());
            $this->Cr->SetValue($this->DataSource->Cr->GetValue());
            $this->ClosingVal->SetValue($this->DataSource->ClosingVal->GetValue());
            $this->TotalSum_Opening->SetValue($this->DataSource->TotalSum_Opening->GetValue());
            $this->TotalSum_Dr->SetValue($this->DataSource->TotalSum_Dr->GetValue());
            $this->TotalSum_Cr->SetValue($this->DataSource->TotalSum_Cr->GetValue());
            $this->TotalSum_ClosingVal->SetValue($this->DataSource->TotalSum_ClosingVal->GetValue());
            if (count($Groups->Groups) == 0) $Groups->OpenGroup("Report");
            $Groups->AddItem();
            $is_next_record = $this->DataSource->next_record();
        }
        if (!count($Groups->Groups)) 
            $Groups->OpenGroup("Report");
        else
            $this->NoRecords->Visible = false;
        $Groups->CloseGroup("Report");
        $this->TotalPages = $Groups->TotalPages;
        $this->TotalRows = $Groups->TotalRows;

        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeShow", $this);
        if(!$this->Visible) return;

        $this->Attributes->Show();
        $ReportBlock = "Report " . $this->ComponentName;
        $ParentPath = $Tpl->block_path;
        $Tpl->block_path = $ParentPath . "/" . $ReportBlock;

        if($this->CheckErrors()) {
            $Tpl->replaceblock("", $this->GetErrors());
            $Tpl->block_path = $ParentPath;
            return;
        } else {
            $items = & $Groups->Groups;
            $i = $Groups->Pages[min($this->PageNumber, $Groups->TotalPages) - 1];
            $this->ControlsVisible["Accttype"] = $this->Accttype->Visible;
            $this->ControlsVisible["Acct"] = $this->Acct->Visible;
            $this->ControlsVisible["Sub"] = $this->Sub->Visible;
            $this->ControlsVisible["Descr"] = $this->Descr->Visible;
            $this->ControlsVisible["Opening"] = $this->Opening->Visible;
            $this->ControlsVisible["Dr"] = $this->Dr->Visible;
            $this->ControlsVisible["Cr"] = $this->Cr->Visible;
            $this->ControlsVisible["ClosingVal"] = $this->ClosingVal->Visible;
            do {
                $this->Attributes->RestoreFromArray($items[$i]->Attributes);
                $this->RowNumber = $items[$i]->RowNumber;
                switch ($items[$i]->GroupType) {
                    Case "":
                        $Tpl->block_path = $ParentPath . "/" . $ReportBlock . "/Section Detail";
                        $this->Accttype->SetValue($items[$i]->Accttype);
                        $this->Accttype->Attributes->RestoreFromArray($items[$i]->_AccttypeAttributes);
                        $this->Acct->SetValue($items[$i]->Acct);
                        $this->Acct->Attributes->RestoreFromArray($items[$i]->_AcctAttributes);
                        $this->Sub->SetValue($items[$i]->Sub);
                        $this->Sub->Attributes->RestoreFromArray($items[$i]->_SubAttributes);
                        $this->Descr->SetValue($items[$i]->Descr);
                        $this->Descr->Attributes->RestoreFromArray($items[$i]->_DescrAttributes);
                        $this->Opening->SetValue($items[$i]->Opening);
                        $this->Opening->Attributes->RestoreFromArray($items[$i]->_OpeningAttributes);
                        $this->Dr->SetValue($items[$i]->Dr);
                        $this->Dr->Attributes->RestoreFromArray($items[$i]->_DrAttributes);
                        $this->Cr->SetValue($items[$i]->Cr);
                        $this->Cr->Attributes->RestoreFromArray($items[$i]->_CrAttributes);
                        $this->ClosingVal->SetValue($items[$i]->ClosingVal);
                        $this->ClosingVal->Attributes->RestoreFromArray($items[$i]->_ClosingValAttributes);
                        $this->Detail->CCSEventResult = CCGetEvent($this->Detail->CCSEvents, "BeforeShow", $this->Detail);
                        $this->Attributes->Show();
                        $this->Accttype->Show();
                        $this->Acct->Show();
                        $this->Sub->Show();
                        $this->Descr->Show();
                        $this->Opening->Show();
                        $this->Dr->Show();
                        $this->Cr->Show();
                        $this->ClosingVal->Show();
                        $Tpl->block_path = $ParentPath . "/" . $ReportBlock;
                        if ($this->Detail->Visible)
                            $Tpl->parseto("Section Detail", true, "Section Detail");
                        break;
                    case "Report":
                        if ($items[$i]->Mode == 1) {
                            $this->Report_Header->CCSEventResult = CCGetEvent($this->Report_Header->CCSEvents, "BeforeShow", $this->Report_Header);
                            if ($this->Report_Header->Visible) {
                                $Tpl->block_path = $ParentPath . "/" . $ReportBlock . "/Section Report_Header";
                                $this->Attributes->Show();
                                $Tpl->block_path = $ParentPath . "/" . $ReportBlock;
                                $Tpl->parseto("Section Report_Header", true, "Section Detail");
                            }
                        }
                        if ($items[$i]->Mode == 2) {
                            $this->TotalSum_Opening->SetText(CCFormatNumber($items[$i]->TotalSum_Opening, array(False, 2, Null, Null, False, "", "", 1, True, "")), ccsFloat);
                            $this->TotalSum_Opening->Attributes->RestoreFromArray($items[$i]->_TotalSum_OpeningAttributes);
                            $this->TotalSum_Dr->SetText(CCFormatNumber($items[$i]->TotalSum_Dr, array(False, 2, Null, Null, False, "", "", 1, True, "")), ccsFloat);
                            $this->TotalSum_Dr->Attributes->RestoreFromArray($items[$i]->_TotalSum_DrAttributes);
                            $this->TotalSum_Cr->SetText(CCFormatNumber($items[$i]->TotalSum_Cr, array(False, 2, Null, Null, False, "", "", 1, True, "")), ccsFloat);
                            $this->TotalSum_Cr->Attributes->RestoreFromArray($items[$i]->_TotalSum_CrAttributes);
                            $this->TotalSum_ClosingVal->SetText(CCFormatNumber($items[$i]->TotalSum_ClosingVal, array(False, 2, Null, Null, False, "", "", 1, True, "")), ccsFloat);
                            $this->TotalSum_ClosingVal->Attributes->RestoreFromArray($items[$i]->_TotalSum_ClosingValAttributes);
                            $this->Report_Footer->CCSEventResult = CCGetEvent($this->Report_Footer->CCSEvents, "BeforeShow", $this->Report_Footer);
                            if ($this->Report_Footer->Visible) {
                                $Tpl->block_path = $ParentPath . "/" . $ReportBlock . "/Section Report_Footer";
                                $this->NoRecords->Show();
                                $this->TotalSum_Opening->Show();
                                $this->TotalSum_Dr->Show();
                                $this->TotalSum_Cr->Show();
                                $this->TotalSum_ClosingVal->Show();
                                $this->Attributes->Show();
                                $Tpl->block_path = $ParentPath . "/" . $ReportBlock;
                                $Tpl->parseto("Section Report_Footer", true, "Section Detail");
                            }
                        }
                        break;
                    case "Page":
                        if ($items[$i]->Mode == 1) {
                            $this->Page_Header->CCSEventResult = CCGetEvent($this->Page_Header->CCSEvents, "BeforeShow", $this->Page_Header);
                            if ($this->Page_Header->Visible) {
                                $Tpl->block_path = $ParentPath . "/" . $ReportBlock . "/Section Page_Header";
                                $this->Attributes->Show();
                                $Tpl->block_path = $ParentPath . "/" . $ReportBlock;
                                $Tpl->parseto("Section Page_Header", true, "Section Detail");
                            }
                        }
                        if ($items[$i]->Mode == 2 && !$this->UseClientPaging || $items[$i]->Mode == 1 && $this->UseClientPaging) {
                            $this->Report_CurrentDate->SetValue(CCFormatDate(CCGetDateArray(), $this->Report_CurrentDate->Format));
                            $this->Report_CurrentDate->Attributes->RestoreFromArray($items[$i]->_Report_CurrentDateAttributes);
                            $this->Report_CurrentPage->SetValue($items[$i]->PageNumber);
                            $this->Report_CurrentPage->Attributes->RestoreFromArray($items[$i]->_Report_CurrentPageAttributes);
                            $this->Report_TotalPages->SetValue($Groups->TotalPages);
                            $this->Report_TotalPages->Attributes->RestoreFromArray($items[$i]->_Report_TotalPagesAttributes);
                            $this->Navigator->PageNumber = $items[$i]->PageNumber;
                            $this->Navigator->TotalPages = $Groups->TotalPages;
                            $this->Navigator->Visible = ("Print" != $this->ViewMode);
                            $this->Page_Footer->CCSEventResult = CCGetEvent($this->Page_Footer->CCSEvents, "BeforeShow", $this->Page_Footer);
                            if ($this->Page_Footer->Visible) {
                                $Tpl->block_path = $ParentPath . "/" . $ReportBlock . "/Section Page_Footer";
                                $this->Report_CurrentDate->Show();
                                $this->Report_CurrentPage->Show();
                                $this->Report_TotalPages->Show();
                                $this->Navigator->Show();
                                $this->Attributes->Show();
                                $Tpl->block_path = $ParentPath . "/" . $ReportBlock;
                                $Tpl->parseto("Section Page_Footer", true, "Section Detail");
                            }
                        }
                        break;
                }
                $i++;
            } while ($i < count($items) && ($this->ViewMode == "Print" ||  !($i > 1 && $items[$i]->GroupType == 'Page' && $items[$i]->Mode == 1)));
            $Tpl->block_path = $ParentPath;
            $Tpl->parse($ReportBlock);
            $this->DataSource->close();
        }

    }
//End Show Method

} //End Report3 Class @182-FCB6E20C

class clsReport3DataSource extends clsDBCoopWorksConn {  //Report3DataSource Class @182-6655CDB7

//DataSource Variables @182-F026CC2C
    var $Parent = "";
    var $CCSEvents = "";
    var $CCSEventResult;
    var $ErrorBlock;
    var $CmdExecution;



    // Datasource fields
    var $Accttype;
    var $Acct;
    var $Sub;
    var $Descr;
    var $Opening;
    var $Dr;
    var $Cr;
    var $ClosingVal;
    var $TotalSum_Opening;
    var $TotalSum_Dr;
    var $TotalSum_Cr;
    var $TotalSum_ClosingVal;
//End DataSource Variables

//DataSourceClass_Initialize Event @182-82CC00C3
    function clsReport3DataSource(& $Parent)
    {
        $this->Parent = & $Parent;
        $this->ErrorBlock = "Report Report3";
        $this->Initialize();
        $this->Accttype = new clsField("Accttype", ccsText, "");
        
        $this->Acct = new clsField("Acct", ccsText, "");
        
        $this->Sub = new clsField("Sub", ccsText, "");
        
        $this->Descr = new clsField("Descr", ccsText, "");
        
        $this->Opening = new clsField("Opening", ccsFloat, "");
        
        $this->Dr = new clsField("Dr", ccsFloat, "");
        
        $this->Cr = new clsField("Cr", ccsFloat, "");
        
        $this->ClosingVal = new clsField("ClosingVal", ccsFloat, "");
        
        $this->TotalSum_Opening = new clsField("TotalSum_Opening", ccsFloat, "");
        
        $this->TotalSum_Dr = new clsField("TotalSum_Dr", ccsFloat, "");
        
        $this->TotalSum_Cr = new clsField("TotalSum_Cr", ccsFloat, "");
        
        $this->TotalSum_ClosingVal = new clsField("TotalSum_ClosingVal", ccsFloat, "");
        

    }
//End DataSourceClass_Initialize Event

//SetOrder Method @182-BF7F5B01
    function SetOrder($SorterName, $SorterDirection)
    {
        $this->Order = CCGetOrder($this->Order, $SorterName, $SorterDirection, 
            "");
    }
//End SetOrder Method

//Prepare Method @182-14D6CD9D
    function Prepare()
    {
        global $CCSLocales;
        global $DefaultDateFormat;
    }
//End Prepare Method

//Open Method @182-B073C80C
    function Open()
    {
        $this->cp["period"] = new clsSQLParameter("urls_Period", ccsInteger, "", "", CCGetFromGet("s_Period", NULL), "", false, $this->ErrorBlock);
        $this->cp["year2"] = new clsSQLParameter("urls_FiscalYear", ccsInteger, "", "", CCGetFromGet("s_FiscalYear", NULL), "", false, $this->ErrorBlock);
        $this->cp["Activity"] = new clsSQLParameter("urlActivity", ccsText, "", "", CCGetFromGet("Activity", NULL), "", false, $this->ErrorBlock);
        $this->cp["rptformat"] = new clsSQLParameter("urlrptformat", ccsText, "", "", CCGetFromGet("rptformat", NULL), "", false, $this->ErrorBlock);
        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeBuildSelect", $this->Parent);
        $this->SQL = "CALL GL_YTD_TB_ASSETS (" . $this->ToSQL($this->cp["period"]->GetDBValue(), $this->cp["period"]->DataType) . ", "
             . $this->ToSQL($this->cp["year2"]->GetDBValue(), $this->cp["year2"]->DataType) . ", "
             . $this->ToSQL($this->cp["Activity"]->GetDBValue(), $this->cp["Activity"]->DataType) . ", "
             . $this->ToSQL($this->cp["rptformat"]->GetDBValue(), $this->cp["rptformat"]->DataType) . ");";
        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeExecuteSelect", $this->Parent);
        $this->query($this->SQL);
        $this->RecordsCount = "CCS not counted";
        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterExecuteSelect", $this->Parent);
        if ($this->Errors->count()) return false;
    }
//End Open Method

//SetValues Method @182-AD2BAFD9
    function SetValues()
    {
        $this->Accttype->SetDBValue($this->f("Accttype"));
        $this->Acct->SetDBValue($this->f("Acct"));
        $this->Sub->SetDBValue($this->f("Sub"));
        $this->Descr->SetDBValue($this->f("Descr"));
        $this->Opening->SetDBValue(trim($this->f("Opening")));
        $this->Dr->SetDBValue(trim($this->f("Dr")));
        $this->Cr->SetDBValue(trim($this->f("Cr")));
        $this->ClosingVal->SetDBValue(trim($this->f("ClosingVal")));
        $this->TotalSum_Opening->SetDBValue(trim($this->f("Opening")));
        $this->TotalSum_Dr->SetDBValue(trim($this->f("Dr")));
        $this->TotalSum_Cr->SetDBValue(trim($this->f("Cr")));
        $this->TotalSum_ClosingVal->SetDBValue(trim($this->f("ClosingVal")));
    }
//End SetValues Method

} //End Report3DataSource Class @182-FCB6E20C

//Report4 ReportGroup class @151-B2AC3630
class clsReportGroupReport4 {
    var $GroupType;
    var $mode; //1 - open, 2 - close
    var $Accttype, $_AccttypeAttributes;
    var $Acct, $_AcctAttributes;
    var $Sub, $_SubAttributes;
    var $Descr, $_DescrAttributes;
    var $Opening, $_OpeningAttributes;
    var $Dr, $_DrAttributes;
    var $Cr, $_CrAttributes;
    var $ClosingVal, $_ClosingValAttributes;
    var $TotalSum_Opening, $_TotalSum_OpeningAttributes;
    var $TotalSum_Dr, $_TotalSum_DrAttributes;
    var $TotalSum_Cr, $_TotalSum_CrAttributes;
    var $TotalSum_ClosingVal, $_TotalSum_ClosingValAttributes;
    var $Report_CurrentDate, $_Report_CurrentDateAttributes;
    var $Report_CurrentPage, $_Report_CurrentPageAttributes;
    var $Report_TotalPages, $_Report_TotalPagesAttributes;
    var $Attributes;
    var $ReportTotalIndex = 0;
    var $PageTotalIndex;
    var $PageNumber;
    var $RowNumber;
    var $Parent;

    function clsReportGroupReport4(& $parent) {
        $this->Parent = & $parent;
        $this->Attributes = $this->Parent->Attributes->GetAsArray();
    }
    function SetControls($PrevGroup = "") {
        $this->Accttype = $this->Parent->Accttype->Value;
        $this->Acct = $this->Parent->Acct->Value;
        $this->Sub = $this->Parent->Sub->Value;
        $this->Descr = $this->Parent->Descr->Value;
        $this->Opening = $this->Parent->Opening->Value;
        $this->Dr = $this->Parent->Dr->Value;
        $this->Cr = $this->Parent->Cr->Value;
        $this->ClosingVal = $this->Parent->ClosingVal->Value;
    }

    function SetTotalControls($mode = "", $PrevGroup = "") {
        $this->TotalSum_Opening = $this->Parent->TotalSum_Opening->GetTotalValue($mode);
        $this->TotalSum_Dr = $this->Parent->TotalSum_Dr->GetTotalValue($mode);
        $this->TotalSum_Cr = $this->Parent->TotalSum_Cr->GetTotalValue($mode);
        $this->TotalSum_ClosingVal = $this->Parent->TotalSum_ClosingVal->GetTotalValue($mode);
        $this->_AccttypeAttributes = $this->Parent->Accttype->Attributes->GetAsArray();
        $this->_AcctAttributes = $this->Parent->Acct->Attributes->GetAsArray();
        $this->_SubAttributes = $this->Parent->Sub->Attributes->GetAsArray();
        $this->_DescrAttributes = $this->Parent->Descr->Attributes->GetAsArray();
        $this->_OpeningAttributes = $this->Parent->Opening->Attributes->GetAsArray();
        $this->_DrAttributes = $this->Parent->Dr->Attributes->GetAsArray();
        $this->_CrAttributes = $this->Parent->Cr->Attributes->GetAsArray();
        $this->_ClosingValAttributes = $this->Parent->ClosingVal->Attributes->GetAsArray();
        $this->_TotalSum_OpeningAttributes = $this->Parent->TotalSum_Opening->Attributes->GetAsArray();
        $this->_TotalSum_DrAttributes = $this->Parent->TotalSum_Dr->Attributes->GetAsArray();
        $this->_TotalSum_CrAttributes = $this->Parent->TotalSum_Cr->Attributes->GetAsArray();
        $this->_TotalSum_ClosingValAttributes = $this->Parent->TotalSum_ClosingVal->Attributes->GetAsArray();
        $this->_Report_CurrentDateAttributes = $this->Parent->Report_CurrentDate->Attributes->GetAsArray();
        $this->_Report_CurrentPageAttributes = $this->Parent->Report_CurrentPage->Attributes->GetAsArray();
        $this->_Report_TotalPagesAttributes = $this->Parent->Report_TotalPages->Attributes->GetAsArray();
        $this->_NavigatorAttributes = $this->Parent->Navigator->Attributes->GetAsArray();
    }
    function SyncWithHeader(& $Header) {
        $Header->TotalSum_Opening = $this->TotalSum_Opening;
        $Header->_TotalSum_OpeningAttributes = $this->_TotalSum_OpeningAttributes;
        $Header->TotalSum_Dr = $this->TotalSum_Dr;
        $Header->_TotalSum_DrAttributes = $this->_TotalSum_DrAttributes;
        $Header->TotalSum_Cr = $this->TotalSum_Cr;
        $Header->_TotalSum_CrAttributes = $this->_TotalSum_CrAttributes;
        $Header->TotalSum_ClosingVal = $this->TotalSum_ClosingVal;
        $Header->_TotalSum_ClosingValAttributes = $this->_TotalSum_ClosingValAttributes;
        $this->Accttype = $Header->Accttype;
        $Header->_AccttypeAttributes = $this->_AccttypeAttributes;
        $this->Parent->Accttype->Value = $Header->Accttype;
        $this->Parent->Accttype->Attributes->RestoreFromArray($Header->_AccttypeAttributes);
        $this->Acct = $Header->Acct;
        $Header->_AcctAttributes = $this->_AcctAttributes;
        $this->Parent->Acct->Value = $Header->Acct;
        $this->Parent->Acct->Attributes->RestoreFromArray($Header->_AcctAttributes);
        $this->Sub = $Header->Sub;
        $Header->_SubAttributes = $this->_SubAttributes;
        $this->Parent->Sub->Value = $Header->Sub;
        $this->Parent->Sub->Attributes->RestoreFromArray($Header->_SubAttributes);
        $this->Descr = $Header->Descr;
        $Header->_DescrAttributes = $this->_DescrAttributes;
        $this->Parent->Descr->Value = $Header->Descr;
        $this->Parent->Descr->Attributes->RestoreFromArray($Header->_DescrAttributes);
        $this->Opening = $Header->Opening;
        $Header->_OpeningAttributes = $this->_OpeningAttributes;
        $this->Parent->Opening->Value = $Header->Opening;
        $this->Parent->Opening->Attributes->RestoreFromArray($Header->_OpeningAttributes);
        $this->Dr = $Header->Dr;
        $Header->_DrAttributes = $this->_DrAttributes;
        $this->Parent->Dr->Value = $Header->Dr;
        $this->Parent->Dr->Attributes->RestoreFromArray($Header->_DrAttributes);
        $this->Cr = $Header->Cr;
        $Header->_CrAttributes = $this->_CrAttributes;
        $this->Parent->Cr->Value = $Header->Cr;
        $this->Parent->Cr->Attributes->RestoreFromArray($Header->_CrAttributes);
        $this->ClosingVal = $Header->ClosingVal;
        $Header->_ClosingValAttributes = $this->_ClosingValAttributes;
        $this->Parent->ClosingVal->Value = $Header->ClosingVal;
        $this->Parent->ClosingVal->Attributes->RestoreFromArray($Header->_ClosingValAttributes);
    }
    function ChangeTotalControls() {
        $this->TotalSum_Opening = $this->Parent->TotalSum_Opening->GetValue();
        $this->TotalSum_Dr = $this->Parent->TotalSum_Dr->GetValue();
        $this->TotalSum_Cr = $this->Parent->TotalSum_Cr->GetValue();
        $this->TotalSum_ClosingVal = $this->Parent->TotalSum_ClosingVal->GetValue();
    }
}
//End Report4 ReportGroup class

//Report4 GroupsCollection class @151-907E3E98
class clsGroupsCollectionReport4 {
    var $Groups;
    var $mPageCurrentHeaderIndex;
    var $PageSize;
    var $TotalPages = 0;
    var $TotalRows = 0;
    var $CurrentPageSize = 0;
    var $Pages;
    var $Parent;
    var $LastDetailIndex;

    function clsGroupsCollectionReport4(& $parent) {
        $this->Parent = & $parent;
        $this->Groups = array();
        $this->Pages  = array();
        $this->mReportTotalIndex = 0;
        $this->mPageTotalIndex = 1;
    }

    function & InitGroup() {
        $group = new clsReportGroupReport4($this->Parent);
        $group->RowNumber = $this->TotalRows + 1;
        $group->PageNumber = $this->TotalPages;
        $group->PageTotalIndex = $this->mPageCurrentHeaderIndex;
        return $group;
    }

    function RestoreValues() {
        $this->Parent->Accttype->Value = $this->Parent->Accttype->initialValue;
        $this->Parent->Acct->Value = $this->Parent->Acct->initialValue;
        $this->Parent->Sub->Value = $this->Parent->Sub->initialValue;
        $this->Parent->Descr->Value = $this->Parent->Descr->initialValue;
        $this->Parent->Opening->Value = $this->Parent->Opening->initialValue;
        $this->Parent->Dr->Value = $this->Parent->Dr->initialValue;
        $this->Parent->Cr->Value = $this->Parent->Cr->initialValue;
        $this->Parent->ClosingVal->Value = $this->Parent->ClosingVal->initialValue;
        $this->Parent->TotalSum_Opening->Value = $this->Parent->TotalSum_Opening->initialValue;
        $this->Parent->TotalSum_Dr->Value = $this->Parent->TotalSum_Dr->initialValue;
        $this->Parent->TotalSum_Cr->Value = $this->Parent->TotalSum_Cr->initialValue;
        $this->Parent->TotalSum_ClosingVal->Value = $this->Parent->TotalSum_ClosingVal->initialValue;
    }

    function OpenPage() {
        $this->TotalPages++;
        $Group = & $this->InitGroup();
        $this->Parent->Page_Header->CCSEventResult = CCGetEvent($this->Parent->Page_Header->CCSEvents, "OnInitialize", $this->Parent->Page_Header);
        if ($this->Parent->Page_Header->Visible)
            $this->CurrentPageSize = $this->CurrentPageSize + $this->Parent->Page_Header->Height;
        $Group->SetTotalControls("GetNextValue");
        $this->Parent->Page_Header->CCSEventResult = CCGetEvent($this->Parent->Page_Header->CCSEvents, "OnCalculate", $this->Parent->Page_Header);
        $Group->SetControls();
        $Group->Mode = 1;
        $Group->GroupType = "Page";
        $Group->PageTotalIndex = count($this->Groups);
        $this->mPageCurrentHeaderIndex = count($this->Groups);
        $this->Groups[] =  & $Group;
        $this->Pages[] =  count($this->Groups) == 2 ? 0 : count($this->Groups) - 1;
    }

    function OpenGroup($groupName) {
        $Group = "";
        $OpenFlag = false;
        if ($groupName == "Report") {
            $Group = & $this->InitGroup(true);
            $this->Parent->Report_Header->CCSEventResult = CCGetEvent($this->Parent->Report_Header->CCSEvents, "OnInitialize", $this->Parent->Report_Header);
            if ($this->Parent->Report_Header->Visible) 
                $this->CurrentPageSize = $this->CurrentPageSize + $this->Parent->Report_Header->Height;
                $Group->SetTotalControls("GetNextValue");
            $this->Parent->Report_Header->CCSEventResult = CCGetEvent($this->Parent->Report_Header->CCSEvents, "OnCalculate", $this->Parent->Report_Header);
            $Group->SetControls();
            $Group->Mode = 1;
            $Group->GroupType = "Report";
            $this->Groups[] = & $Group;
            $this->OpenPage();
        }
    }

    function ClosePage() {
        $Group = & $this->InitGroup();
        $this->Parent->Page_Footer->CCSEventResult = CCGetEvent($this->Parent->Page_Footer->CCSEvents, "OnInitialize", $this->Parent->Page_Footer);
        $Group->SetTotalControls("GetPrevValue");
        $Group->SyncWithHeader($this->Groups[$this->mPageCurrentHeaderIndex]);
        $this->Parent->Page_Footer->CCSEventResult = CCGetEvent($this->Parent->Page_Footer->CCSEvents, "OnCalculate", $this->Parent->Page_Footer);
        $Group->SetControls();
        $this->RestoreValues();
        $this->CurrentPageSize = 0;
        $Group->Mode = 2;
        $Group->GroupType = "Page";
        $this->Groups[] = & $Group;
    }

    function CloseGroup($groupName)
    {
        $Group = "";
        if ($groupName == "Report") {
            $Group = & $this->InitGroup(true);
            $this->Parent->Report_Footer->CCSEventResult = CCGetEvent($this->Parent->Report_Footer->CCSEvents, "OnInitialize", $this->Parent->Report_Footer);
            if ($this->Parent->Page_Footer->Visible) 
                $OverSize = $this->Parent->Report_Footer->Height + $this->Parent->Page_Footer->Height;
            else
                $OverSize = $this->Parent->Report_Footer->Height;
            if (($this->PageSize > 0) and $this->Parent->Report_Footer->Visible and ($this->CurrentPageSize + $OverSize > $this->PageSize)) {
                $this->ClosePage();
                $this->OpenPage();
            }
            $Group->SetTotalControls("GetPrevValue");
            $Group->SyncWithHeader($this->Groups[0]);
            if ($this->Parent->Report_Footer->Visible)
                $this->CurrentPageSize = $this->CurrentPageSize + $this->Parent->Report_Footer->Height;
            $this->Parent->Report_Footer->CCSEventResult = CCGetEvent($this->Parent->Report_Footer->CCSEvents, "OnCalculate", $this->Parent->Report_Footer);
            $Group->SetControls();
            $this->RestoreValues();
            $Group->Mode = 2;
            $Group->GroupType = "Report";
            $this->Groups[] = & $Group;
            $this->ClosePage();
            return;
        }
    }

    function AddItem()
    {
        $Group = & $this->InitGroup(true);
        $this->Parent->Detail->CCSEventResult = CCGetEvent($this->Parent->Detail->CCSEvents, "OnInitialize", $this->Parent->Detail);
        if ($this->Parent->Page_Footer->Visible) 
            $OverSize = $this->Parent->Detail->Height + $this->Parent->Page_Footer->Height;
        else
            $OverSize = $this->Parent->Detail->Height;
        if (($this->PageSize > 0) and $this->Parent->Detail->Visible and ($this->CurrentPageSize + $OverSize > $this->PageSize)) {
            $this->ClosePage();
            $this->OpenPage();
        }
        $this->TotalRows++;
        if ($this->LastDetailIndex)
            $PrevGroup = & $this->Groups[$this->LastDetailIndex];
        else
            $PrevGroup = "";
        $Group->SetTotalControls("", $PrevGroup);
        if ($this->Parent->Detail->Visible)
            $this->CurrentPageSize = $this->CurrentPageSize + $this->Parent->Detail->Height;
        $this->Parent->Detail->CCSEventResult = CCGetEvent($this->Parent->Detail->CCSEvents, "OnCalculate", $this->Parent->Detail);
        $Group->SetControls($PrevGroup);
        $this->LastDetailIndex = count($this->Groups);
        $this->Groups[] = & $Group;
    }
}
//End Report4 GroupsCollection class

class clsReportReport4 { //Report4 Class @151-C15844C9

//Report4 Variables @151-87F7EA53

    var $ComponentType = "Report";
    var $PageSize;
    var $ComponentName;
    var $Visible;
    var $Errors;
    var $CCSEvents = array();
    var $CCSEventResult;
    var $RelativePath = "";
    var $ViewMode = "Web";
    var $TemplateBlock;
    var $PageNumber;
    var $RowNumber;
    var $TotalRows;
    var $TotalPages;
    var $ControlsVisible = array();
    var $IsEmpty;
    var $Attributes;
    var $DetailBlock, $Detail;
    var $Report_FooterBlock, $Report_Footer;
    var $Report_HeaderBlock, $Report_Header;
    var $Page_FooterBlock, $Page_Footer;
    var $Page_HeaderBlock, $Page_Header;
    var $SorterName, $SorterDirection;

    var $ds;
    var $DataSource;
    var $UseClientPaging = false;

    //Report Controls
    var $StaticControls, $RowControls, $Report_FooterControls, $Report_HeaderControls;
    var $Page_FooterControls, $Page_HeaderControls;
//End Report4 Variables

//Class_Initialize Event @151-998323AB
    function clsReportReport4($RelativePath = "", & $Parent)
    {
        global $FileName;
        global $CCSLocales;
        global $DefaultDateFormat;
        $this->ComponentName = "Report4";
        $this->Visible = True;
        $this->Parent = & $Parent;
        $this->RelativePath = $RelativePath;
        $this->Attributes = new clsAttributes($this->ComponentName . ":");
        $this->Detail = new clsSection($this);
        $MinPageSize = 0;
        $MaxSectionSize = 0;
        $this->Detail->Height = 1;
        $MaxSectionSize = max($MaxSectionSize, $this->Detail->Height);
        $this->Report_Footer = new clsSection($this);
        $this->Report_Footer->Height = 1;
        $MaxSectionSize = max($MaxSectionSize, $this->Report_Footer->Height);
        $this->Report_Header = new clsSection($this);
        $this->Page_Footer = new clsSection($this);
        $this->Page_Footer->Height = 1;
        $MinPageSize += $this->Page_Footer->Height;
        $this->Page_Header = new clsSection($this);
        $this->Page_Header->Height = 1;
        $MinPageSize += $this->Page_Header->Height;
        $this->Errors = new clsErrors();
        $this->DataSource = new clsReport4DataSource($this);
        $this->ds = & $this->DataSource;
        $PageSize = CCGetParam($this->ComponentName . "PageSize", "");
        if(is_numeric($PageSize) && $PageSize > 0) {
            $this->PageSize = $PageSize;
        } else {
            if (!is_numeric($PageSize) || $PageSize < 0)
                $this->PageSize = 40;
             else if ($PageSize == "0")
                $this->PageSize = 100;
             else 
                $this->PageSize = min(100, $PageSize);
        }
        $MinPageSize += $MaxSectionSize;
        if ($this->PageSize && $MinPageSize && $this->PageSize < $MinPageSize)
            $this->PageSize = $MinPageSize;
        $this->PageNumber = $this->ViewMode == "Print" ? 1 : intval(CCGetParam($this->ComponentName . "Page", 1));
        if ($this->PageNumber <= 0 ) {
            $this->PageNumber = 1;
        }

        $this->Accttype = & new clsControl(ccsReportLabel, "Accttype", "Accttype", ccsText, "", "", $this);
        $this->Acct = & new clsControl(ccsReportLabel, "Acct", "Acct", ccsText, "", "", $this);
        $this->Sub = & new clsControl(ccsReportLabel, "Sub", "Sub", ccsText, "", "", $this);
        $this->Descr = & new clsControl(ccsReportLabel, "Descr", "Descr", ccsText, "", "", $this);
        $this->Opening = & new clsControl(ccsReportLabel, "Opening", "Opening", ccsFloat, array(False, 2, Null, Null, False, "", "", 1, True, ""), "", $this);
        $this->Dr = & new clsControl(ccsReportLabel, "Dr", "Dr", ccsFloat, array(False, 2, Null, Null, False, "", "", 1, True, ""), "", $this);
        $this->Cr = & new clsControl(ccsReportLabel, "Cr", "Cr", ccsFloat, array(False, 2, Null, Null, False, "", "", 1, True, ""), "", $this);
        $this->ClosingVal = & new clsControl(ccsReportLabel, "ClosingVal", "ClosingVal", ccsFloat, array(False, 2, Null, Null, False, "", "", 1, True, ""), "", $this);
        $this->NoRecords = & new clsPanel("NoRecords", $this);
        $this->TotalSum_Opening = & new clsControl(ccsReportLabel, "TotalSum_Opening", "TotalSum_Opening", ccsFloat, array(False, 2, Null, Null, False, "", "", 1, True, ""), "", $this);
        $this->TotalSum_Opening->TotalFunction = "Sum";
        $this->TotalSum_Dr = & new clsControl(ccsReportLabel, "TotalSum_Dr", "TotalSum_Dr", ccsFloat, array(False, 2, Null, Null, False, "", "", 1, True, ""), "", $this);
        $this->TotalSum_Dr->TotalFunction = "Sum";
        $this->TotalSum_Cr = & new clsControl(ccsReportLabel, "TotalSum_Cr", "TotalSum_Cr", ccsFloat, array(False, 2, Null, Null, False, "", "", 1, True, ""), "", $this);
        $this->TotalSum_Cr->TotalFunction = "Sum";
        $this->TotalSum_ClosingVal = & new clsControl(ccsReportLabel, "TotalSum_ClosingVal", "TotalSum_ClosingVal", ccsFloat, array(False, 2, Null, Null, False, "", "", 1, True, ""), "", $this);
        $this->TotalSum_ClosingVal->TotalFunction = "Sum";
        $this->Report_CurrentDate = & new clsControl(ccsReportLabel, "Report_CurrentDate", "Report_CurrentDate", ccsText, array('ShortDate'), "", $this);
        $this->Report_CurrentPage = & new clsControl(ccsReportLabel, "Report_CurrentPage", "Report_CurrentPage", ccsInteger, "", "", $this);
        $this->Report_TotalPages = & new clsControl(ccsReportLabel, "Report_TotalPages", "Report_TotalPages", ccsInteger, "", "", $this);
        $this->Navigator = & new clsNavigator($this->ComponentName, "Navigator", $FileName, 10, tpCentered, $this);
        $this->Navigator->PageSizes = array("1", "5", "10", "25", "50");
    }
//End Class_Initialize Event

//Initialize Method @151-6C59EE65
    function Initialize()
    {
        if(!$this->Visible) return;

        $this->DataSource->PageSize = $this->PageSize;
        $this->DataSource->AbsolutePage = $this->PageNumber;
        $this->DataSource->SetOrder($this->SorterName, $this->SorterDirection);
    }
//End Initialize Method

//CheckErrors Method @151-B5D86920
    function CheckErrors()
    {
        $errors = false;
        $errors = ($errors || $this->Accttype->Errors->Count());
        $errors = ($errors || $this->Acct->Errors->Count());
        $errors = ($errors || $this->Sub->Errors->Count());
        $errors = ($errors || $this->Descr->Errors->Count());
        $errors = ($errors || $this->Opening->Errors->Count());
        $errors = ($errors || $this->Dr->Errors->Count());
        $errors = ($errors || $this->Cr->Errors->Count());
        $errors = ($errors || $this->ClosingVal->Errors->Count());
        $errors = ($errors || $this->TotalSum_Opening->Errors->Count());
        $errors = ($errors || $this->TotalSum_Dr->Errors->Count());
        $errors = ($errors || $this->TotalSum_Cr->Errors->Count());
        $errors = ($errors || $this->TotalSum_ClosingVal->Errors->Count());
        $errors = ($errors || $this->Report_CurrentDate->Errors->Count());
        $errors = ($errors || $this->Report_CurrentPage->Errors->Count());
        $errors = ($errors || $this->Report_TotalPages->Errors->Count());
        $errors = ($errors || $this->Errors->Count());
        $errors = ($errors || $this->DataSource->Errors->Count());
        return $errors;
    }
//End CheckErrors Method

//GetErrors Method @151-C82EE43B
    function GetErrors()
    {
        $errors = "";
        $errors = ComposeStrings($errors, $this->Accttype->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Acct->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Sub->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Descr->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Opening->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Dr->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Cr->Errors->ToString());
        $errors = ComposeStrings($errors, $this->ClosingVal->Errors->ToString());
        $errors = ComposeStrings($errors, $this->TotalSum_Opening->Errors->ToString());
        $errors = ComposeStrings($errors, $this->TotalSum_Dr->Errors->ToString());
        $errors = ComposeStrings($errors, $this->TotalSum_Cr->Errors->ToString());
        $errors = ComposeStrings($errors, $this->TotalSum_ClosingVal->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Report_CurrentDate->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Report_CurrentPage->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Report_TotalPages->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Errors->ToString());
        $errors = ComposeStrings($errors, $this->DataSource->Errors->ToString());
        return $errors;
    }
//End GetErrors Method

//Show Method @151-005DE7FE
    function Show()
    {
        global $Tpl;
        global $CCSLocales;
        if(!$this->Visible) return;

        $ShownRecords = 0;

        $this->DataSource->Parameters["urls_Period"] = CCGetFromGet("s_Period", NULL);
        $this->DataSource->Parameters["urls_FiscalYear"] = CCGetFromGet("s_FiscalYear", NULL);
        $this->DataSource->Parameters["urlActivity"] = CCGetFromGet("Activity", NULL);
        $this->DataSource->Parameters["urlrptformat"] = CCGetFromGet("rptformat", NULL);

        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeSelect", $this);


        $this->DataSource->Prepare();
        $this->DataSource->Open();

        $Groups = new clsGroupsCollectionReport4($this);
        $Groups->PageSize = $this->PageSize > 0 ? $this->PageSize : 0;

        $is_next_record = $this->DataSource->next_record();
        $this->IsEmpty = ! $is_next_record;
        while($is_next_record) {
            $this->DataSource->SetValues();
            $this->Accttype->SetValue($this->DataSource->Accttype->GetValue());
            $this->Acct->SetValue($this->DataSource->Acct->GetValue());
            $this->Sub->SetValue($this->DataSource->Sub->GetValue());
            $this->Descr->SetValue($this->DataSource->Descr->GetValue());
            $this->Opening->SetValue($this->DataSource->Opening->GetValue());
            $this->Dr->SetValue($this->DataSource->Dr->GetValue());
            $this->Cr->SetValue($this->DataSource->Cr->GetValue());
            $this->ClosingVal->SetValue($this->DataSource->ClosingVal->GetValue());
            $this->TotalSum_Opening->SetValue($this->DataSource->TotalSum_Opening->GetValue());
            $this->TotalSum_Dr->SetValue($this->DataSource->TotalSum_Dr->GetValue());
            $this->TotalSum_Cr->SetValue($this->DataSource->TotalSum_Cr->GetValue());
            $this->TotalSum_ClosingVal->SetValue($this->DataSource->TotalSum_ClosingVal->GetValue());
            if (count($Groups->Groups) == 0) $Groups->OpenGroup("Report");
            $Groups->AddItem();
            $is_next_record = $this->DataSource->next_record();
        }
        if (!count($Groups->Groups)) 
            $Groups->OpenGroup("Report");
        else
            $this->NoRecords->Visible = false;
        $Groups->CloseGroup("Report");
        $this->TotalPages = $Groups->TotalPages;
        $this->TotalRows = $Groups->TotalRows;

        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeShow", $this);
        if(!$this->Visible) return;

        $this->Attributes->Show();
        $ReportBlock = "Report " . $this->ComponentName;
        $ParentPath = $Tpl->block_path;
        $Tpl->block_path = $ParentPath . "/" . $ReportBlock;

        if($this->CheckErrors()) {
            $Tpl->replaceblock("", $this->GetErrors());
            $Tpl->block_path = $ParentPath;
            return;
        } else {
            $items = & $Groups->Groups;
            $i = $Groups->Pages[min($this->PageNumber, $Groups->TotalPages) - 1];
            $this->ControlsVisible["Accttype"] = $this->Accttype->Visible;
            $this->ControlsVisible["Acct"] = $this->Acct->Visible;
            $this->ControlsVisible["Sub"] = $this->Sub->Visible;
            $this->ControlsVisible["Descr"] = $this->Descr->Visible;
            $this->ControlsVisible["Opening"] = $this->Opening->Visible;
            $this->ControlsVisible["Dr"] = $this->Dr->Visible;
            $this->ControlsVisible["Cr"] = $this->Cr->Visible;
            $this->ControlsVisible["ClosingVal"] = $this->ClosingVal->Visible;
            do {
                $this->Attributes->RestoreFromArray($items[$i]->Attributes);
                $this->RowNumber = $items[$i]->RowNumber;
                switch ($items[$i]->GroupType) {
                    Case "":
                        $Tpl->block_path = $ParentPath . "/" . $ReportBlock . "/Section Detail";
                        $this->Accttype->SetValue($items[$i]->Accttype);
                        $this->Accttype->Attributes->RestoreFromArray($items[$i]->_AccttypeAttributes);
                        $this->Acct->SetValue($items[$i]->Acct);
                        $this->Acct->Attributes->RestoreFromArray($items[$i]->_AcctAttributes);
                        $this->Sub->SetValue($items[$i]->Sub);
                        $this->Sub->Attributes->RestoreFromArray($items[$i]->_SubAttributes);
                        $this->Descr->SetValue($items[$i]->Descr);
                        $this->Descr->Attributes->RestoreFromArray($items[$i]->_DescrAttributes);
                        $this->Opening->SetValue($items[$i]->Opening);
                        $this->Opening->Attributes->RestoreFromArray($items[$i]->_OpeningAttributes);
                        $this->Dr->SetValue($items[$i]->Dr);
                        $this->Dr->Attributes->RestoreFromArray($items[$i]->_DrAttributes);
                        $this->Cr->SetValue($items[$i]->Cr);
                        $this->Cr->Attributes->RestoreFromArray($items[$i]->_CrAttributes);
                        $this->ClosingVal->SetValue($items[$i]->ClosingVal);
                        $this->ClosingVal->Attributes->RestoreFromArray($items[$i]->_ClosingValAttributes);
                        $this->Detail->CCSEventResult = CCGetEvent($this->Detail->CCSEvents, "BeforeShow", $this->Detail);
                        $this->Attributes->Show();
                        $this->Accttype->Show();
                        $this->Acct->Show();
                        $this->Sub->Show();
                        $this->Descr->Show();
                        $this->Opening->Show();
                        $this->Dr->Show();
                        $this->Cr->Show();
                        $this->ClosingVal->Show();
                        $Tpl->block_path = $ParentPath . "/" . $ReportBlock;
                        if ($this->Detail->Visible)
                            $Tpl->parseto("Section Detail", true, "Section Detail");
                        break;
                    case "Report":
                        if ($items[$i]->Mode == 1) {
                            $this->Report_Header->CCSEventResult = CCGetEvent($this->Report_Header->CCSEvents, "BeforeShow", $this->Report_Header);
                            if ($this->Report_Header->Visible) {
                                $Tpl->block_path = $ParentPath . "/" . $ReportBlock . "/Section Report_Header";
                                $this->Attributes->Show();
                                $Tpl->block_path = $ParentPath . "/" . $ReportBlock;
                                $Tpl->parseto("Section Report_Header", true, "Section Detail");
                            }
                        }
                        if ($items[$i]->Mode == 2) {
                            $this->TotalSum_Opening->SetText(CCFormatNumber($items[$i]->TotalSum_Opening, array(False, 2, Null, Null, False, "", "", 1, True, "")), ccsFloat);
                            $this->TotalSum_Opening->Attributes->RestoreFromArray($items[$i]->_TotalSum_OpeningAttributes);
                            $this->TotalSum_Dr->SetText(CCFormatNumber($items[$i]->TotalSum_Dr, array(False, 2, Null, Null, False, "", "", 1, True, "")), ccsFloat);
                            $this->TotalSum_Dr->Attributes->RestoreFromArray($items[$i]->_TotalSum_DrAttributes);
                            $this->TotalSum_Cr->SetText(CCFormatNumber($items[$i]->TotalSum_Cr, array(False, 2, Null, Null, False, "", "", 1, True, "")), ccsFloat);
                            $this->TotalSum_Cr->Attributes->RestoreFromArray($items[$i]->_TotalSum_CrAttributes);
                            $this->TotalSum_ClosingVal->SetText(CCFormatNumber($items[$i]->TotalSum_ClosingVal, array(False, 2, Null, Null, False, "", "", 1, True, "")), ccsFloat);
                            $this->TotalSum_ClosingVal->Attributes->RestoreFromArray($items[$i]->_TotalSum_ClosingValAttributes);
                            $this->Report_Footer->CCSEventResult = CCGetEvent($this->Report_Footer->CCSEvents, "BeforeShow", $this->Report_Footer);
                            if ($this->Report_Footer->Visible) {
                                $Tpl->block_path = $ParentPath . "/" . $ReportBlock . "/Section Report_Footer";
                                $this->NoRecords->Show();
                                $this->TotalSum_Opening->Show();
                                $this->TotalSum_Dr->Show();
                                $this->TotalSum_Cr->Show();
                                $this->TotalSum_ClosingVal->Show();
                                $this->Attributes->Show();
                                $Tpl->block_path = $ParentPath . "/" . $ReportBlock;
                                $Tpl->parseto("Section Report_Footer", true, "Section Detail");
                            }
                        }
                        break;
                    case "Page":
                        if ($items[$i]->Mode == 1) {
                            $this->Page_Header->CCSEventResult = CCGetEvent($this->Page_Header->CCSEvents, "BeforeShow", $this->Page_Header);
                            if ($this->Page_Header->Visible) {
                                $Tpl->block_path = $ParentPath . "/" . $ReportBlock . "/Section Page_Header";
                                $this->Attributes->Show();
                                $Tpl->block_path = $ParentPath . "/" . $ReportBlock;
                                $Tpl->parseto("Section Page_Header", true, "Section Detail");
                            }
                        }
                        if ($items[$i]->Mode == 2 && !$this->UseClientPaging || $items[$i]->Mode == 1 && $this->UseClientPaging) {
                            $this->Report_CurrentDate->SetValue(CCFormatDate(CCGetDateArray(), $this->Report_CurrentDate->Format));
                            $this->Report_CurrentDate->Attributes->RestoreFromArray($items[$i]->_Report_CurrentDateAttributes);
                            $this->Report_CurrentPage->SetValue($items[$i]->PageNumber);
                            $this->Report_CurrentPage->Attributes->RestoreFromArray($items[$i]->_Report_CurrentPageAttributes);
                            $this->Report_TotalPages->SetValue($Groups->TotalPages);
                            $this->Report_TotalPages->Attributes->RestoreFromArray($items[$i]->_Report_TotalPagesAttributes);
                            $this->Navigator->PageNumber = $items[$i]->PageNumber;
                            $this->Navigator->TotalPages = $Groups->TotalPages;
                            $this->Navigator->Visible = ("Print" != $this->ViewMode);
                            $this->Page_Footer->CCSEventResult = CCGetEvent($this->Page_Footer->CCSEvents, "BeforeShow", $this->Page_Footer);
                            if ($this->Page_Footer->Visible) {
                                $Tpl->block_path = $ParentPath . "/" . $ReportBlock . "/Section Page_Footer";
                                $this->Report_CurrentDate->Show();
                                $this->Report_CurrentPage->Show();
                                $this->Report_TotalPages->Show();
                                $this->Navigator->Show();
                                $this->Attributes->Show();
                                $Tpl->block_path = $ParentPath . "/" . $ReportBlock;
                                $Tpl->parseto("Section Page_Footer", true, "Section Detail");
                            }
                        }
                        break;
                }
                $i++;
            } while ($i < count($items) && ($this->ViewMode == "Print" ||  !($i > 1 && $items[$i]->GroupType == 'Page' && $items[$i]->Mode == 1)));
            $Tpl->block_path = $ParentPath;
            $Tpl->parse($ReportBlock);
            $this->DataSource->close();
        }

    }
//End Show Method

} //End Report4 Class @151-FCB6E20C

class clsReport4DataSource extends clsDBCoopWorksConn {  //Report4DataSource Class @151-5267A468

//DataSource Variables @151-F026CC2C
    var $Parent = "";
    var $CCSEvents = "";
    var $CCSEventResult;
    var $ErrorBlock;
    var $CmdExecution;



    // Datasource fields
    var $Accttype;
    var $Acct;
    var $Sub;
    var $Descr;
    var $Opening;
    var $Dr;
    var $Cr;
    var $ClosingVal;
    var $TotalSum_Opening;
    var $TotalSum_Dr;
    var $TotalSum_Cr;
    var $TotalSum_ClosingVal;
//End DataSource Variables

//DataSourceClass_Initialize Event @151-99AEFAB7
    function clsReport4DataSource(& $Parent)
    {
        $this->Parent = & $Parent;
        $this->ErrorBlock = "Report Report4";
        $this->Initialize();
        $this->Accttype = new clsField("Accttype", ccsText, "");
        
        $this->Acct = new clsField("Acct", ccsText, "");
        
        $this->Sub = new clsField("Sub", ccsText, "");
        
        $this->Descr = new clsField("Descr", ccsText, "");
        
        $this->Opening = new clsField("Opening", ccsFloat, "");
        
        $this->Dr = new clsField("Dr", ccsFloat, "");
        
        $this->Cr = new clsField("Cr", ccsFloat, "");
        
        $this->ClosingVal = new clsField("ClosingVal", ccsFloat, "");
        
        $this->TotalSum_Opening = new clsField("TotalSum_Opening", ccsFloat, "");
        
        $this->TotalSum_Dr = new clsField("TotalSum_Dr", ccsFloat, "");
        
        $this->TotalSum_Cr = new clsField("TotalSum_Cr", ccsFloat, "");
        
        $this->TotalSum_ClosingVal = new clsField("TotalSum_ClosingVal", ccsFloat, "");
        

    }
//End DataSourceClass_Initialize Event

//SetOrder Method @151-BF7F5B01
    function SetOrder($SorterName, $SorterDirection)
    {
        $this->Order = CCGetOrder($this->Order, $SorterName, $SorterDirection, 
            "");
    }
//End SetOrder Method

//Prepare Method @151-14D6CD9D
    function Prepare()
    {
        global $CCSLocales;
        global $DefaultDateFormat;
    }
//End Prepare Method

//Open Method @151-A1886490
    function Open()
    {
        $this->cp["period"] = new clsSQLParameter("urls_Period", ccsInteger, "", "", CCGetFromGet("s_Period", NULL), "", false, $this->ErrorBlock);
        $this->cp["year2 "] = new clsSQLParameter("urls_FiscalYear", ccsInteger, "", "", CCGetFromGet("s_FiscalYear", NULL), "", false, $this->ErrorBlock);
        $this->cp["Activity"] = new clsSQLParameter("urlActivity", ccsText, "", "", CCGetFromGet("Activity", NULL), "", false, $this->ErrorBlock);
        $this->cp["rptformat"] = new clsSQLParameter("urlrptformat", ccsText, "", "", CCGetFromGet("rptformat", NULL), "", false, $this->ErrorBlock);
        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeBuildSelect", $this->Parent);
        $this->SQL = "CALL GL_YTD_TB_LIABILITIES (" . $this->ToSQL($this->cp["period"]->GetDBValue(), $this->cp["period"]->DataType) . ", "
             . $this->ToSQL($this->cp["year2 "]->GetDBValue(), $this->cp["year2 "]->DataType) . ", "
             . $this->ToSQL($this->cp["Activity"]->GetDBValue(), $this->cp["Activity"]->DataType) . ", "
             . $this->ToSQL($this->cp["rptformat"]->GetDBValue(), $this->cp["rptformat"]->DataType) . ");";
        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeExecuteSelect", $this->Parent);
        $this->query($this->SQL);
        $this->RecordsCount = "CCS not counted";
        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterExecuteSelect", $this->Parent);
        if ($this->Errors->count()) return false;
    }
//End Open Method

//SetValues Method @151-AD2BAFD9
    function SetValues()
    {
        $this->Accttype->SetDBValue($this->f("Accttype"));
        $this->Acct->SetDBValue($this->f("Acct"));
        $this->Sub->SetDBValue($this->f("Sub"));
        $this->Descr->SetDBValue($this->f("Descr"));
        $this->Opening->SetDBValue(trim($this->f("Opening")));
        $this->Dr->SetDBValue(trim($this->f("Dr")));
        $this->Cr->SetDBValue(trim($this->f("Cr")));
        $this->ClosingVal->SetDBValue(trim($this->f("ClosingVal")));
        $this->TotalSum_Opening->SetDBValue(trim($this->f("Opening")));
        $this->TotalSum_Dr->SetDBValue(trim($this->f("Dr")));
        $this->TotalSum_Cr->SetDBValue(trim($this->f("Cr")));
        $this->TotalSum_ClosingVal->SetDBValue(trim($this->f("ClosingVal")));
    }
//End SetValues Method

} //End Report4DataSource Class @151-FCB6E20C



//Initialize Page @1-00E5963E
// Variables
$FileName = "";
$Redirect = "";
$Tpl = "";
$TemplateFileName = "";
$BlockToParse = "";
$ComponentName = "";
$Attributes = "";

// Events;
$CCSEvents = "";
$CCSEventResult = "";

$FileName = FileName;
$Redirect = "";
$TemplateFileName = "GL_YTD_TrialBalance.html";
$BlockToParse = "main";
$TemplateEncoding = "UTF-8";
$ContentType = "text/html";
$PathToRoot = "./";
$Charset = $Charset ? $Charset : "utf-8";
//End Initialize Page

//Authenticate User @1-946ECC7A
CCSecurityRedirect("1;2;3", "");
//End Authenticate User

//Include events file @1-1B290101
include_once("./GL_YTD_TrialBalance_events.php");
//End Include events file

//Before Initialize @1-E870CEBC
$CCSEventResult = CCGetEvent($CCSEvents, "BeforeInitialize", $MainPage);
//End Before Initialize

//Initialize Objects @1-F00BD147
$DBCoopWorksConn = new clsDBCoopWorksConn();
$MainPage->Connections["CoopWorksConn"] = & $DBCoopWorksConn;
$Attributes = new clsAttributes("page:");
$MainPage->Attributes = & $Attributes;

// Controls
$glytdtbwrkSearch = & new clsRecordglytdtbwrkSearch("", $MainPage);
$Report1 = & new clsReportReport1("", $MainPage);
$Report2 = & new clsReportReport2("", $MainPage);
$Report3 = & new clsReportReport3("", $MainPage);
$Report4 = & new clsReportReport4("", $MainPage);
$MainPage->glytdtbwrkSearch = & $glytdtbwrkSearch;
$MainPage->Report1 = & $Report1;
$MainPage->Report2 = & $Report2;
$MainPage->Report3 = & $Report3;
$MainPage->Report4 = & $Report4;
$Report1->Initialize();
$Report2->Initialize();
$Report3->Initialize();
$Report4->Initialize();

BindEvents();

$CCSEventResult = CCGetEvent($CCSEvents, "AfterInitialize", $MainPage);

if ($Charset) {
    header("Content-Type: " . $ContentType . "; charset=" . $Charset);
} else {
    header("Content-Type: " . $ContentType);
}
//End Initialize Objects

//Initialize HTML Template @1-A06E9207
$CCSEventResult = CCGetEvent($CCSEvents, "OnInitializeView", $MainPage);
$Tpl = new clsTemplate($FileEncoding, $TemplateEncoding);
$Tpl->LoadTemplate(PathToCurrentPage . $TemplateFileName, $BlockToParse, "UTF-8", "replace");
$Tpl->block_path = "/$BlockToParse";
$CCSEventResult = CCGetEvent($CCSEvents, "BeforeShow", $MainPage);
$Attributes->SetValue("pathToRoot", "");
$Attributes->Show();
//End Initialize HTML Template

//Execute Components @1-9D883ABC
$glytdtbwrkSearch->Operation();
//End Execute Components

//Go to destination page @1-43C5BEDC
if($Redirect)
{
    $CCSEventResult = CCGetEvent($CCSEvents, "BeforeUnload", $MainPage);
    $DBCoopWorksConn->close();
    header("Location: " . $Redirect);
    unset($glytdtbwrkSearch);
    unset($Report1);
    unset($Report2);
    unset($Report3);
    unset($Report4);
    unset($Tpl);
    exit;
}
//End Go to destination page

//Show Page @1-BCD1264C
$glytdtbwrkSearch->Show();
$Report1->Show();
$Report2->Show();
$Report3->Show();
$Report4->Show();
$Tpl->block_path = "";
$Tpl->Parse($BlockToParse, false);
if (!isset($main_block)) $main_block = $Tpl->GetVar($BlockToParse);
$CCSEventResult = CCGetEvent($CCSEvents, "BeforeOutput", $MainPage);
if ($CCSEventResult) echo $main_block;
//End Show Page

//Unload Page @1-49654604
$CCSEventResult = CCGetEvent($CCSEvents, "BeforeUnload", $MainPage);
$DBCoopWorksConn->close();
unset($glytdtbwrkSearch);
unset($Report1);
unset($Report2);
unset($Report3);
unset($Report4);
unset($Tpl);
//End Unload Page


?>
Return current item: CoopWorks Farmers Association Management