Location: PHPKode > projects > CoopWorks Farmers Association Management > CoopWorks 3.1/PRRateTable.php
<?php
//Include Common Files @1-BCE1F609
define("RelativePath", ".");
define("PathToCurrentPage", "/");
define("FileName", "PRRateTable.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 clsEditableGridprratetable { //prratetable Class @2-761C2435

//Variables @2-2FB0F171

    // Public variables
    var $ComponentType = "EditableGrid";
    var $ComponentName;
    var $HTMLFormAction;
    var $PressedButton;
    var $Errors;
    var $ErrorBlock;
    var $FormSubmitted;
    var $FormParameters;
    var $FormState;
    var $FormEnctype;
    var $CachedColumns;
    var $TotalRows;
    var $UpdatedRows;
    var $EmptyRows;
    var $Visible;
    var $RowsErrors;
    var $ds;
    var $DataSource;
    var $PageSize;
    var $IsEmpty;
    var $SorterName = "";
    var $SorterDirection = "";
    var $PageNumber;
    var $ControlsVisible = array();

    var $CCSEvents = "";
    var $CCSEventResult;

    var $RelativePath = "";

    var $InsertAllowed = false;
    var $UpdateAllowed = false;
    var $DeleteAllowed = false;
    var $ReadAllowed   = false;
    var $EditMode;
    var $ValidatingControls;
    var $Controls;
    var $ControlsErrors;
    var $RowNumber;
    var $Attributes;
    var $PrimaryKeys;

    // Class variables
    var $Sorter1;
//End Variables

//Class_Initialize Event @2-9E27DD61
    function clsEditableGridprratetable($RelativePath, & $Parent)
    {

        global $FileName;
        global $CCSLocales;
        global $DefaultDateFormat;
        $this->Visible = true;
        $this->Parent = & $Parent;
        $this->RelativePath = $RelativePath;
        $this->Errors = new clsErrors();
        $this->ErrorBlock = "EditableGrid prratetable/Error";
        $this->ControlsErrors = array();
        $this->ComponentName = "prratetable";
        $this->Attributes = new clsAttributes($this->ComponentName . ":");
        $this->CachedColumns["recid"][0] = "recid";
        $this->CachedColumns["AmtFrom"][0] = "AmtFrom";
        $this->DataSource = new clsprratetableDataSource($this);
        $this->ds = & $this->DataSource;
        $this->PageSize = CCGetParam($this->ComponentName . "PageSize", "");
        if(!is_numeric($this->PageSize) || !strlen($this->PageSize))
            $this->PageSize = 10;
        else
            $this->PageSize = intval($this->PageSize);
        if ($this->PageSize > 100)
            $this->PageSize = 100;
        if($this->PageSize == 0)
            $this->Errors->addError("<p>Form: EditableGrid " . $this->ComponentName . "<br>Error: (CCS06) Invalid page size.</p>");
        $this->PageNumber = intval(CCGetParam($this->ComponentName . "Page", 1));
        if ($this->PageNumber <= 0) $this->PageNumber = 1;

        $this->EmptyRows = 3;
        $this->InsertAllowed = true;
        $this->UpdateAllowed = true;
        $this->DeleteAllowed = true;
        $this->ReadAllowed = true;
        $this->Visible = (CCSecurityAccessCheck("") == "success");
        if(!$this->Visible) return;

        $CCSForm = CCGetFromGet("ccsForm", "");
        $this->FormEnctype = "application/x-www-form-urlencoded";
        $this->FormSubmitted = ($CCSForm == $this->ComponentName);
        if($this->FormSubmitted) {
            $this->FormState = CCGetFromPost("FormState", "");
            $this->SetFormState($this->FormState);
        } else {
            $this->FormState = "";
        }
        $Method = $this->FormSubmitted ? ccsPost : ccsGet;

        $this->SorterName = CCGetParam("prratetableOrder", "");
        $this->SorterDirection = CCGetParam("prratetableDir", "");

        $this->AmtFrom = & new clsControl(ccsTextBox, "AmtFrom", "Amt From", ccsFloat, "", NULL, $this);
        $this->AmtFrom->Required = true;
        $this->AmtTo = & new clsControl(ccsTextBox, "AmtTo", "Amt To", ccsFloat, "", NULL, $this);
        $this->Rate = & new clsControl(ccsTextBox, "Rate", "Rate", ccsFloat, "", NULL, $this);
        $this->WithHseFactor = & new clsControl(ccsTextBox, "WithHseFactor", "With Hse Factor", ccsFloat, "", NULL, $this);
        $this->WithoutHseFactor = & new clsControl(ccsTextBox, "WithoutHseFactor", "Without Hse Factor", ccsFloat, "", NULL, $this);
        $this->BasePAYE = & new clsControl(ccsTextBox, "BasePAYE", "Base PAYE", ccsFloat, "", NULL, $this);
        $this->Cat_Amt = & new clsControl(ccsTextBox, "Cat_Amt", "Cat Amt", ccsFloat, "", NULL, $this);
        $this->Cat_Tax = & new clsControl(ccsTextBox, "Cat_Tax", "Cat Tax", ccsFloat, "", NULL, $this);
        $this->Cat_Min_Tax = & new clsControl(ccsTextBox, "Cat_Min_Tax", "Cat Min Tax", ccsFloat, "", NULL, $this);
        $this->CheckBox_Delete = & new clsControl(ccsCheckBox, "CheckBox_Delete", "CheckBox_Delete", ccsBoolean, $CCSLocales->GetFormatInfo("BooleanFormat"), NULL, $this);
        $this->CheckBox_Delete->CheckedValue = true;
        $this->CheckBox_Delete->UncheckedValue = false;
        $this->Navigator = & new clsNavigator($this->ComponentName, "Navigator", $FileName, 10, tpCentered, $this);
        $this->Navigator->PageSizes = array("1", "5", "10", "25", "50");
        $this->Button_Submit = & new clsButton("Button_Submit", $Method, $this);
        $this->Cancel = & new clsButton("Cancel", $Method, $this);
        $this->Sorter1 = & new clsSorter($this->ComponentName, "Sorter1", $FileName, $this);
    }
//End Class_Initialize Event

//Initialize Method @2-90E704C5
    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

//SetPrimaryKeys Method @2-EBC3F86C
    function SetPrimaryKeys($PrimaryKeys) {
        $this->PrimaryKeys = $PrimaryKeys;
        return $this->PrimaryKeys;
    }
//End SetPrimaryKeys Method

//GetPrimaryKeys Method @2-74F9A772
    function GetPrimaryKeys() {
        return $this->PrimaryKeys;
    }
//End GetPrimaryKeys Method

//GetFormParameters Method @2-68F9E0DA
    function GetFormParameters()
    {
        for($RowNumber = 1; $RowNumber <= $this->TotalRows; $RowNumber++)
        {
            $this->FormParameters["AmtFrom"][$RowNumber] = CCGetFromPost("AmtFrom_" . $RowNumber, NULL);
            $this->FormParameters["AmtTo"][$RowNumber] = CCGetFromPost("AmtTo_" . $RowNumber, NULL);
            $this->FormParameters["Rate"][$RowNumber] = CCGetFromPost("Rate_" . $RowNumber, NULL);
            $this->FormParameters["WithHseFactor"][$RowNumber] = CCGetFromPost("WithHseFactor_" . $RowNumber, NULL);
            $this->FormParameters["WithoutHseFactor"][$RowNumber] = CCGetFromPost("WithoutHseFactor_" . $RowNumber, NULL);
            $this->FormParameters["BasePAYE"][$RowNumber] = CCGetFromPost("BasePAYE_" . $RowNumber, NULL);
            $this->FormParameters["Cat_Amt"][$RowNumber] = CCGetFromPost("Cat_Amt_" . $RowNumber, NULL);
            $this->FormParameters["Cat_Tax"][$RowNumber] = CCGetFromPost("Cat_Tax_" . $RowNumber, NULL);
            $this->FormParameters["Cat_Min_Tax"][$RowNumber] = CCGetFromPost("Cat_Min_Tax_" . $RowNumber, NULL);
            $this->FormParameters["CheckBox_Delete"][$RowNumber] = CCGetFromPost("CheckBox_Delete_" . $RowNumber, NULL);
        }
    }
//End GetFormParameters Method

//Validate Method @2-19E99363
    function Validate()
    {
        $Validation = true;
        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "OnValidate", $this);

        for($this->RowNumber = 1; $this->RowNumber <= $this->TotalRows; $this->RowNumber++)
        {
            $this->DataSource->CachedColumns["recid"] = $this->CachedColumns["recid"][$this->RowNumber];
            $this->DataSource->CachedColumns["AmtFrom"] = $this->CachedColumns["AmtFrom"][$this->RowNumber];
            $this->DataSource->CurrentRow = $this->RowNumber;
            $this->AmtFrom->SetText($this->FormParameters["AmtFrom"][$this->RowNumber], $this->RowNumber);
            $this->AmtTo->SetText($this->FormParameters["AmtTo"][$this->RowNumber], $this->RowNumber);
            $this->Rate->SetText($this->FormParameters["Rate"][$this->RowNumber], $this->RowNumber);
            $this->WithHseFactor->SetText($this->FormParameters["WithHseFactor"][$this->RowNumber], $this->RowNumber);
            $this->WithoutHseFactor->SetText($this->FormParameters["WithoutHseFactor"][$this->RowNumber], $this->RowNumber);
            $this->BasePAYE->SetText($this->FormParameters["BasePAYE"][$this->RowNumber], $this->RowNumber);
            $this->Cat_Amt->SetText($this->FormParameters["Cat_Amt"][$this->RowNumber], $this->RowNumber);
            $this->Cat_Tax->SetText($this->FormParameters["Cat_Tax"][$this->RowNumber], $this->RowNumber);
            $this->Cat_Min_Tax->SetText($this->FormParameters["Cat_Min_Tax"][$this->RowNumber], $this->RowNumber);
            $this->CheckBox_Delete->SetText($this->FormParameters["CheckBox_Delete"][$this->RowNumber], $this->RowNumber);
            if ($this->UpdatedRows >= $this->RowNumber) {
                if(!$this->CheckBox_Delete->Value)
                    $Validation = ($this->ValidateRow() && $Validation);
            }
            else if($this->CheckInsert())
            {
                $Validation = ($this->ValidateRow() && $Validation);
            }
        }
        return (($this->Errors->Count() == 0) && $Validation);
    }
//End Validate Method

//ValidateRow Method @2-3AAF70FB
    function ValidateRow()
    {
        global $CCSLocales;
        $this->AmtFrom->Validate();
        $this->AmtTo->Validate();
        $this->Rate->Validate();
        $this->WithHseFactor->Validate();
        $this->WithoutHseFactor->Validate();
        $this->BasePAYE->Validate();
        $this->Cat_Amt->Validate();
        $this->Cat_Tax->Validate();
        $this->Cat_Min_Tax->Validate();
        $this->CheckBox_Delete->Validate();
        $this->RowErrors = new clsErrors();
        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "OnValidateRow", $this);
        $errors = "";
        $errors = ComposeStrings($errors, $this->AmtFrom->Errors->ToString());
        $errors = ComposeStrings($errors, $this->AmtTo->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Rate->Errors->ToString());
        $errors = ComposeStrings($errors, $this->WithHseFactor->Errors->ToString());
        $errors = ComposeStrings($errors, $this->WithoutHseFactor->Errors->ToString());
        $errors = ComposeStrings($errors, $this->BasePAYE->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Cat_Amt->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Cat_Tax->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Cat_Min_Tax->Errors->ToString());
        $errors = ComposeStrings($errors, $this->CheckBox_Delete->Errors->ToString());
        $this->AmtFrom->Errors->Clear();
        $this->AmtTo->Errors->Clear();
        $this->Rate->Errors->Clear();
        $this->WithHseFactor->Errors->Clear();
        $this->WithoutHseFactor->Errors->Clear();
        $this->BasePAYE->Errors->Clear();
        $this->Cat_Amt->Errors->Clear();
        $this->Cat_Tax->Errors->Clear();
        $this->Cat_Min_Tax->Errors->Clear();
        $this->CheckBox_Delete->Errors->Clear();
        $errors = ComposeStrings($errors, $this->RowErrors->ToString());
        $this->RowsErrors[$this->RowNumber] = $errors;
        return $errors != "" ? 0 : 1;
    }
//End ValidateRow Method

//CheckInsert Method @2-2C290753
    function CheckInsert()
    {
        $filed = false;
        $filed = ($filed || (is_array($this->FormParameters["AmtFrom"][$this->RowNumber]) && count($this->FormParameters["AmtFrom"][$this->RowNumber])) || strlen($this->FormParameters["AmtFrom"][$this->RowNumber]));
        $filed = ($filed || (is_array($this->FormParameters["AmtTo"][$this->RowNumber]) && count($this->FormParameters["AmtTo"][$this->RowNumber])) || strlen($this->FormParameters["AmtTo"][$this->RowNumber]));
        $filed = ($filed || (is_array($this->FormParameters["Rate"][$this->RowNumber]) && count($this->FormParameters["Rate"][$this->RowNumber])) || strlen($this->FormParameters["Rate"][$this->RowNumber]));
        $filed = ($filed || (is_array($this->FormParameters["WithHseFactor"][$this->RowNumber]) && count($this->FormParameters["WithHseFactor"][$this->RowNumber])) || strlen($this->FormParameters["WithHseFactor"][$this->RowNumber]));
        $filed = ($filed || (is_array($this->FormParameters["WithoutHseFactor"][$this->RowNumber]) && count($this->FormParameters["WithoutHseFactor"][$this->RowNumber])) || strlen($this->FormParameters["WithoutHseFactor"][$this->RowNumber]));
        $filed = ($filed || (is_array($this->FormParameters["BasePAYE"][$this->RowNumber]) && count($this->FormParameters["BasePAYE"][$this->RowNumber])) || strlen($this->FormParameters["BasePAYE"][$this->RowNumber]));
        $filed = ($filed || (is_array($this->FormParameters["Cat_Amt"][$this->RowNumber]) && count($this->FormParameters["Cat_Amt"][$this->RowNumber])) || strlen($this->FormParameters["Cat_Amt"][$this->RowNumber]));
        $filed = ($filed || (is_array($this->FormParameters["Cat_Tax"][$this->RowNumber]) && count($this->FormParameters["Cat_Tax"][$this->RowNumber])) || strlen($this->FormParameters["Cat_Tax"][$this->RowNumber]));
        $filed = ($filed || (is_array($this->FormParameters["Cat_Min_Tax"][$this->RowNumber]) && count($this->FormParameters["Cat_Min_Tax"][$this->RowNumber])) || strlen($this->FormParameters["Cat_Min_Tax"][$this->RowNumber]));
        return $filed;
    }
//End CheckInsert Method

//CheckErrors Method @2-F5A3B433
    function CheckErrors()
    {
        $errors = false;
        $errors = ($errors || $this->Errors->Count());
        $errors = ($errors || $this->DataSource->Errors->Count());
        return $errors;
    }
//End CheckErrors Method

//Operation Method @2-6B923CC2
    function Operation()
    {
        if(!$this->Visible)
            return;

        global $Redirect;
        global $FileName;

        $this->DataSource->Prepare();
        if(!$this->FormSubmitted)
            return;

        $this->GetFormParameters();
        $this->PressedButton = "Button_Submit";
        if($this->Button_Submit->Pressed) {
            $this->PressedButton = "Button_Submit";
        } else if($this->Cancel->Pressed) {
            $this->PressedButton = "Cancel";
        }

        $Redirect = $FileName . "?" . CCGetQueryString("QueryString", array("ccsForm"));
        if($this->PressedButton == "Button_Submit") {
            if(!CCGetEvent($this->Button_Submit->CCSEvents, "OnClick", $this->Button_Submit) || !$this->UpdateGrid()) {
                $Redirect = "";
            }
        } else if($this->PressedButton == "Cancel") {
            if(!CCGetEvent($this->Cancel->CCSEvents, "OnClick", $this->Cancel)) {
                $Redirect = "";
            }
        } else {
            $Redirect = "";
        }
        if ($Redirect)
            $this->DataSource->close();
    }
//End Operation Method

//UpdateGrid Method @2-A4FC16FB
    function UpdateGrid()
    {
        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeSubmit", $this);
        if(!$this->Validate()) return;
        $Validation = true;
        for($this->RowNumber = 1; $this->RowNumber <= $this->TotalRows; $this->RowNumber++)
        {
            $this->DataSource->CachedColumns["recid"] = $this->CachedColumns["recid"][$this->RowNumber];
            $this->DataSource->CachedColumns["AmtFrom"] = $this->CachedColumns["AmtFrom"][$this->RowNumber];
            $this->DataSource->CurrentRow = $this->RowNumber;
            $this->AmtFrom->SetText($this->FormParameters["AmtFrom"][$this->RowNumber], $this->RowNumber);
            $this->AmtTo->SetText($this->FormParameters["AmtTo"][$this->RowNumber], $this->RowNumber);
            $this->Rate->SetText($this->FormParameters["Rate"][$this->RowNumber], $this->RowNumber);
            $this->WithHseFactor->SetText($this->FormParameters["WithHseFactor"][$this->RowNumber], $this->RowNumber);
            $this->WithoutHseFactor->SetText($this->FormParameters["WithoutHseFactor"][$this->RowNumber], $this->RowNumber);
            $this->BasePAYE->SetText($this->FormParameters["BasePAYE"][$this->RowNumber], $this->RowNumber);
            $this->Cat_Amt->SetText($this->FormParameters["Cat_Amt"][$this->RowNumber], $this->RowNumber);
            $this->Cat_Tax->SetText($this->FormParameters["Cat_Tax"][$this->RowNumber], $this->RowNumber);
            $this->Cat_Min_Tax->SetText($this->FormParameters["Cat_Min_Tax"][$this->RowNumber], $this->RowNumber);
            $this->CheckBox_Delete->SetText($this->FormParameters["CheckBox_Delete"][$this->RowNumber], $this->RowNumber);
            if ($this->UpdatedRows >= $this->RowNumber) {
                if($this->CheckBox_Delete->Value) {
                    if($this->DeleteAllowed) { $Validation = ($this->DeleteRow() && $Validation); }
                } else if($this->UpdateAllowed) {
                    $Validation = ($this->UpdateRow() && $Validation);
                }
            }
            else if($this->CheckInsert() && $this->InsertAllowed)
            {
                $Validation = ($Validation && $this->InsertRow());
            }
        }
        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterSubmit", $this);
        if ($this->Errors->Count() == 0 && $Validation){
            $this->DataSource->close();
            return true;
        }
        return false;
    }
//End UpdateGrid Method

//InsertRow Method @2-9C122642
    function InsertRow()
    {
        if(!$this->InsertAllowed) return false;
        $this->DataSource->AmtFrom->SetValue($this->AmtFrom->GetValue(true));
        $this->DataSource->AmtTo->SetValue($this->AmtTo->GetValue(true));
        $this->DataSource->Rate->SetValue($this->Rate->GetValue(true));
        $this->DataSource->WithHseFactor->SetValue($this->WithHseFactor->GetValue(true));
        $this->DataSource->WithoutHseFactor->SetValue($this->WithoutHseFactor->GetValue(true));
        $this->DataSource->BasePAYE->SetValue($this->BasePAYE->GetValue(true));
        $this->DataSource->Cat_Amt->SetValue($this->Cat_Amt->GetValue(true));
        $this->DataSource->Cat_Tax->SetValue($this->Cat_Tax->GetValue(true));
        $this->DataSource->Cat_Min_Tax->SetValue($this->Cat_Min_Tax->GetValue(true));
        $this->DataSource->Insert();
        $errors = "";
        if($this->DataSource->Errors->Count() > 0) {
            $errors = $this->DataSource->Errors->ToString();
            $this->RowsErrors[$this->RowNumber] = $errors;
            $this->DataSource->Errors->Clear();
        }
        return (($this->Errors->Count() == 0) && !strlen($errors));
    }
//End InsertRow Method

//UpdateRow Method @2-8C822AA4
    function UpdateRow()
    {
        if(!$this->UpdateAllowed) return false;
        $this->DataSource->AmtFrom->SetValue($this->AmtFrom->GetValue(true));
        $this->DataSource->AmtTo->SetValue($this->AmtTo->GetValue(true));
        $this->DataSource->Rate->SetValue($this->Rate->GetValue(true));
        $this->DataSource->WithHseFactor->SetValue($this->WithHseFactor->GetValue(true));
        $this->DataSource->WithoutHseFactor->SetValue($this->WithoutHseFactor->GetValue(true));
        $this->DataSource->BasePAYE->SetValue($this->BasePAYE->GetValue(true));
        $this->DataSource->Cat_Amt->SetValue($this->Cat_Amt->GetValue(true));
        $this->DataSource->Cat_Tax->SetValue($this->Cat_Tax->GetValue(true));
        $this->DataSource->Cat_Min_Tax->SetValue($this->Cat_Min_Tax->GetValue(true));
        $this->DataSource->Update();
        $errors = "";
        if($this->DataSource->Errors->Count() > 0) {
            $errors = $this->DataSource->Errors->ToString();
            $this->RowsErrors[$this->RowNumber] = $errors;
            $this->DataSource->Errors->Clear();
        }
        return (($this->Errors->Count() == 0) && !strlen($errors));
    }
//End UpdateRow Method

//DeleteRow Method @2-A4A656F6
    function DeleteRow()
    {
        if(!$this->DeleteAllowed) return false;
        $this->DataSource->Delete();
        $errors = "";
        if($this->DataSource->Errors->Count() > 0) {
            $errors = $this->DataSource->Errors->ToString();
            $this->RowsErrors[$this->RowNumber] = $errors;
            $this->DataSource->Errors->Clear();
        }
        return (($this->Errors->Count() == 0) && !strlen($errors));
    }
//End DeleteRow Method

//FormScript Method @2-3F2F1346
    function FormScript($TotalRows)
    {
        $script = "";
        $script .= "\n<script language=\"JavaScript\" type=\"text/javascript\">\n<!--\n";
        $script .= "var prratetableElements;\n";
        $script .= "var prratetableEmptyRows = 3;\n";
        $script .= "var " . $this->ComponentName . "AmtFromID = 0;\n";
        $script .= "var " . $this->ComponentName . "AmtToID = 1;\n";
        $script .= "var " . $this->ComponentName . "RateID = 2;\n";
        $script .= "var " . $this->ComponentName . "WithHseFactorID = 3;\n";
        $script .= "var " . $this->ComponentName . "WithoutHseFactorID = 4;\n";
        $script .= "var " . $this->ComponentName . "BasePAYEID = 5;\n";
        $script .= "var " . $this->ComponentName . "Cat_AmtID = 6;\n";
        $script .= "var " . $this->ComponentName . "Cat_TaxID = 7;\n";
        $script .= "var " . $this->ComponentName . "Cat_Min_TaxID = 8;\n";
        $script .= "var " . $this->ComponentName . "DeleteControl = 9;\n";
        $script .= "\nfunction initprratetableElements() {\n";
        $script .= "\tvar ED = document.forms[\"prratetable\"];\n";
        $script .= "\tprratetableElements = new Array (\n";
        for($i = 1; $i <= $TotalRows; $i++) {
            $script .= "\t\tnew Array(" . "ED.AmtFrom_" . $i . ", " . "ED.AmtTo_" . $i . ", " . "ED.Rate_" . $i . ", " . "ED.WithHseFactor_" . $i . ", " . "ED.WithoutHseFactor_" . $i . ", " . "ED.BasePAYE_" . $i . ", " . "ED.Cat_Amt_" . $i . ", " . "ED.Cat_Tax_" . $i . ", " . "ED.Cat_Min_Tax_" . $i . ", " . "ED.CheckBox_Delete_" . $i . ")";
            if($i != $TotalRows) $script .= ",\n";
        }
        $script .= ");\n";
        $script .= "}\n";
        $script .= "\n//-->\n</script>";
        return $script;
    }
//End FormScript Method

//SetFormState Method @2-5C7025CD
    function SetFormState($FormState)
    {
        if(strlen($FormState)) {
            $FormState = str_replace("\\\\", "\\" . ord("\\"), $FormState);
            $FormState = str_replace("\\;", "\\" . ord(";"), $FormState);
            $pieces = explode(";", $FormState);
            $this->UpdatedRows = $pieces[0];
            $this->EmptyRows   = $pieces[1];
            $this->TotalRows = $this->UpdatedRows + $this->EmptyRows;
            $RowNumber = 0;
            for($i = 2; $i < sizeof($pieces); $i = $i + 2)  {
                $piece = $pieces[$i + 0];
                $piece = str_replace("\\" . ord("\\"), "\\", $piece);
                $piece = str_replace("\\" . ord(";"), ";", $piece);
                $this->CachedColumns["recid"][$RowNumber] = $piece;
                $piece = $pieces[$i + 1];
                $piece = str_replace("\\" . ord("\\"), "\\", $piece);
                $piece = str_replace("\\" . ord(";"), ";", $piece);
                $this->CachedColumns["AmtFrom"][$RowNumber] = $piece;
                $RowNumber++;
            }

            if(!$RowNumber) { $RowNumber = 1; }
            for($i = 1; $i <= $this->EmptyRows; $i++) {
                $this->CachedColumns["recid"][$RowNumber] = "";
                $this->CachedColumns["AmtFrom"][$RowNumber] = "";
                $RowNumber++;
            }
        }
    }
//End SetFormState Method

//GetFormState Method @2-644A480A
    function GetFormState($NonEmptyRows)
    {
        if(!$this->FormSubmitted) {
            $this->FormState  = $NonEmptyRows . ";";
            $this->FormState .= $this->InsertAllowed ? $this->EmptyRows : "0";
            if($NonEmptyRows) {
                for($i = 0; $i <= $NonEmptyRows; $i++) {
                    $this->FormState .= ";" . str_replace(";", "\\;", str_replace("\\", "\\\\", $this->CachedColumns["recid"][$i]));
                    $this->FormState .= ";" . str_replace(";", "\\;", str_replace("\\", "\\\\", $this->CachedColumns["AmtFrom"][$i]));
                }
            }
        }
        return $this->FormState;
    }
//End GetFormState Method

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

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

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


        $this->DataSource->open();
        $is_next_record = ($this->ReadAllowed && $this->DataSource->next_record());
        $this->IsEmpty = ! $is_next_record;

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

        $this->Attributes->Show();
        $this->Button_Submit->Visible = $this->Button_Submit->Visible && ($this->InsertAllowed || $this->UpdateAllowed || $this->DeleteAllowed);
        $ParentPath = $Tpl->block_path;
        $EditableGridPath = $ParentPath . "/EditableGrid " . $this->ComponentName;
        $EditableGridRowPath = $ParentPath . "/EditableGrid " . $this->ComponentName . "/Row";
        $Tpl->block_path = $EditableGridRowPath;
        $this->RowNumber = 0;
        $NonEmptyRows = 0;
        $EmptyRowsLeft = $this->EmptyRows;
        $this->ControlsVisible["AmtFrom"] = $this->AmtFrom->Visible;
        $this->ControlsVisible["AmtTo"] = $this->AmtTo->Visible;
        $this->ControlsVisible["Rate"] = $this->Rate->Visible;
        $this->ControlsVisible["WithHseFactor"] = $this->WithHseFactor->Visible;
        $this->ControlsVisible["WithoutHseFactor"] = $this->WithoutHseFactor->Visible;
        $this->ControlsVisible["BasePAYE"] = $this->BasePAYE->Visible;
        $this->ControlsVisible["Cat_Amt"] = $this->Cat_Amt->Visible;
        $this->ControlsVisible["Cat_Tax"] = $this->Cat_Tax->Visible;
        $this->ControlsVisible["Cat_Min_Tax"] = $this->Cat_Min_Tax->Visible;
        $this->ControlsVisible["CheckBox_Delete"] = $this->CheckBox_Delete->Visible;
        if ($is_next_record || ($EmptyRowsLeft && $this->InsertAllowed)) {
            do {
                $this->RowNumber++;
                if($is_next_record) {
                    $NonEmptyRows++;
                    $this->DataSource->SetValues();
                }
                if (!($is_next_record) || !($this->DeleteAllowed)) {
                    $this->CheckBox_Delete->Visible = false;
                }
                if (!($this->FormSubmitted) && $is_next_record) {
                    $this->CachedColumns["recid"][$this->RowNumber] = $this->DataSource->CachedColumns["recid"];
                    $this->CachedColumns["AmtFrom"][$this->RowNumber] = $this->DataSource->CachedColumns["AmtFrom"];
                    $this->CheckBox_Delete->SetValue("");
                    $this->AmtFrom->SetValue($this->DataSource->AmtFrom->GetValue());
                    $this->AmtTo->SetValue($this->DataSource->AmtTo->GetValue());
                    $this->Rate->SetValue($this->DataSource->Rate->GetValue());
                    $this->WithHseFactor->SetValue($this->DataSource->WithHseFactor->GetValue());
                    $this->WithoutHseFactor->SetValue($this->DataSource->WithoutHseFactor->GetValue());
                    $this->BasePAYE->SetValue($this->DataSource->BasePAYE->GetValue());
                    $this->Cat_Amt->SetValue($this->DataSource->Cat_Amt->GetValue());
                    $this->Cat_Tax->SetValue($this->DataSource->Cat_Tax->GetValue());
                    $this->Cat_Min_Tax->SetValue($this->DataSource->Cat_Min_Tax->GetValue());
                } elseif ($this->FormSubmitted && $is_next_record) {
                    $this->AmtFrom->SetText($this->FormParameters["AmtFrom"][$this->RowNumber], $this->RowNumber);
                    $this->AmtTo->SetText($this->FormParameters["AmtTo"][$this->RowNumber], $this->RowNumber);
                    $this->Rate->SetText($this->FormParameters["Rate"][$this->RowNumber], $this->RowNumber);
                    $this->WithHseFactor->SetText($this->FormParameters["WithHseFactor"][$this->RowNumber], $this->RowNumber);
                    $this->WithoutHseFactor->SetText($this->FormParameters["WithoutHseFactor"][$this->RowNumber], $this->RowNumber);
                    $this->BasePAYE->SetText($this->FormParameters["BasePAYE"][$this->RowNumber], $this->RowNumber);
                    $this->Cat_Amt->SetText($this->FormParameters["Cat_Amt"][$this->RowNumber], $this->RowNumber);
                    $this->Cat_Tax->SetText($this->FormParameters["Cat_Tax"][$this->RowNumber], $this->RowNumber);
                    $this->Cat_Min_Tax->SetText($this->FormParameters["Cat_Min_Tax"][$this->RowNumber], $this->RowNumber);
                    $this->CheckBox_Delete->SetText($this->FormParameters["CheckBox_Delete"][$this->RowNumber], $this->RowNumber);
                } elseif (!$this->FormSubmitted) {
                    $this->CachedColumns["recid"][$this->RowNumber] = "";
                    $this->CachedColumns["AmtFrom"][$this->RowNumber] = "";
                    $this->AmtFrom->SetText("");
                    $this->AmtTo->SetText("");
                    $this->Rate->SetText("");
                    $this->WithHseFactor->SetText("");
                    $this->WithoutHseFactor->SetText("");
                    $this->BasePAYE->SetText("");
                    $this->Cat_Amt->SetText("");
                    $this->Cat_Tax->SetText("");
                    $this->Cat_Min_Tax->SetText("");
                } else {
                    $this->AmtFrom->SetText($this->FormParameters["AmtFrom"][$this->RowNumber], $this->RowNumber);
                    $this->AmtTo->SetText($this->FormParameters["AmtTo"][$this->RowNumber], $this->RowNumber);
                    $this->Rate->SetText($this->FormParameters["Rate"][$this->RowNumber], $this->RowNumber);
                    $this->WithHseFactor->SetText($this->FormParameters["WithHseFactor"][$this->RowNumber], $this->RowNumber);
                    $this->WithoutHseFactor->SetText($this->FormParameters["WithoutHseFactor"][$this->RowNumber], $this->RowNumber);
                    $this->BasePAYE->SetText($this->FormParameters["BasePAYE"][$this->RowNumber], $this->RowNumber);
                    $this->Cat_Amt->SetText($this->FormParameters["Cat_Amt"][$this->RowNumber], $this->RowNumber);
                    $this->Cat_Tax->SetText($this->FormParameters["Cat_Tax"][$this->RowNumber], $this->RowNumber);
                    $this->Cat_Min_Tax->SetText($this->FormParameters["Cat_Min_Tax"][$this->RowNumber], $this->RowNumber);
                    $this->CheckBox_Delete->SetText($this->FormParameters["CheckBox_Delete"][$this->RowNumber], $this->RowNumber);
                }
                $this->Attributes->SetValue("rowNumber", $this->RowNumber);
                $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeShowRow", $this);
                $this->Attributes->Show();
                $this->AmtFrom->Show($this->RowNumber);
                $this->AmtTo->Show($this->RowNumber);
                $this->Rate->Show($this->RowNumber);
                $this->WithHseFactor->Show($this->RowNumber);
                $this->WithoutHseFactor->Show($this->RowNumber);
                $this->BasePAYE->Show($this->RowNumber);
                $this->Cat_Amt->Show($this->RowNumber);
                $this->Cat_Tax->Show($this->RowNumber);
                $this->Cat_Min_Tax->Show($this->RowNumber);
                $this->CheckBox_Delete->Show($this->RowNumber);
                if (isset($this->RowsErrors[$this->RowNumber]) && ($this->RowsErrors[$this->RowNumber] != "")) {
                    $Tpl->setblockvar("RowError", "");
                    $Tpl->setvar("Error", $this->RowsErrors[$this->RowNumber]);
                    $this->Attributes->Show();
                    $Tpl->parse("RowError", false);
                } else {
                    $Tpl->setblockvar("RowError", "");
                }
                $Tpl->setvar("FormScript", $this->FormScript($this->RowNumber));
                $Tpl->parse();
                if ($is_next_record) {
                    if ($this->FormSubmitted) {
                        $is_next_record = $this->RowNumber < $this->UpdatedRows;
                        if (($this->DataSource->CachedColumns["recid"] == $this->CachedColumns["recid"][$this->RowNumber]) && ($this->DataSource->CachedColumns["AmtFrom"] == $this->CachedColumns["AmtFrom"][$this->RowNumber])) {
                            if ($this->ReadAllowed) $this->DataSource->next_record();
                        }
                    }else{
                        $is_next_record = ($this->RowNumber < $this->PageSize) &&  $this->ReadAllowed && $this->DataSource->next_record();
                    }
                } else { 
                    $EmptyRowsLeft--;
                }
            } while($is_next_record || ($EmptyRowsLeft && $this->InsertAllowed));
        } else {
            $Tpl->block_path = $EditableGridPath;
            $this->Attributes->Show();
            $Tpl->parse("NoRecords", false);
        }

        $Tpl->block_path = $EditableGridPath;
        $this->Navigator->PageNumber = $this->DataSource->AbsolutePage;
        $this->Navigator->PageSize = $this->PageSize;
        if ($this->DataSource->RecordsCount == "CCS not counted")
            $this->Navigator->TotalPages = $this->DataSource->AbsolutePage + ($this->DataSource->next_record() ? 1 : 0);
        else
            $this->Navigator->TotalPages = $this->DataSource->PageCount();
        if ($this->Navigator->TotalPages <= 1) {
            $this->Navigator->Visible = false;
        }
        $this->Navigator->Show();
        $this->Button_Submit->Show();
        $this->Cancel->Show();
        $this->Sorter1->Show();

        if($this->CheckErrors()) {
            $Error = ComposeStrings($Error, $this->Errors->ToString());
            $Error = ComposeStrings($Error, $this->DataSource->Errors->ToString());
            $Tpl->SetVar("Error", $Error);
            $Tpl->Parse("Error", false);
        }
        $CCSForm = $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);
        if (!$CCSUseAmp) {
            $Tpl->SetVar("HTMLFormProperties", "method=\"POST\" action=\"" . $this->HTMLFormAction . "\" name=\"" . $this->ComponentName . "\"");
        } else {
            $Tpl->SetVar("HTMLFormProperties", "method=\"post\" action=\"" . str_replace("&", "&amp;", $this->HTMLFormAction) . "\" id=\"" . $this->ComponentName . "\"");
        }
        $Tpl->SetVar("FormState", CCToHTML($this->GetFormState($NonEmptyRows)));
        $Tpl->parse();
        $Tpl->block_path = $ParentPath;
        $this->DataSource->close();
    }
//End Show Method

} //End prratetable Class @2-FCB6E20C

class clsprratetableDataSource extends clsDBCoopWorksConn {  //prratetableDataSource Class @2-D9436E84

//DataSource Variables @2-3F55963B
    var $Parent = "";
    var $CCSEvents = "";
    var $CCSEventResult;
    var $ErrorBlock;
    var $CmdExecution;

    var $InsertParameters;
    var $UpdateParameters;
    var $DeleteParameters;
    var $CountSQL;
    var $wp;
    var $AllParametersSet;

    var $CachedColumns;
    var $CurrentRow;
    var $InsertFields = array();
    var $UpdateFields = array();

    // Datasource fields
    var $AmtFrom;
    var $AmtTo;
    var $Rate;
    var $WithHseFactor;
    var $WithoutHseFactor;
    var $BasePAYE;
    var $Cat_Amt;
    var $Cat_Tax;
    var $Cat_Min_Tax;
    var $CheckBox_Delete;
//End DataSource Variables

//DataSourceClass_Initialize Event @2-B98429B2
    function clsprratetableDataSource(& $Parent)
    {
        $this->Parent = & $Parent;
        $this->ErrorBlock = "EditableGrid prratetable/Error";
        $this->Initialize();
        $this->AmtFrom = new clsField("AmtFrom", ccsFloat, "");
        
        $this->AmtTo = new clsField("AmtTo", ccsFloat, "");
        
        $this->Rate = new clsField("Rate", ccsFloat, "");
        
        $this->WithHseFactor = new clsField("WithHseFactor", ccsFloat, "");
        
        $this->WithoutHseFactor = new clsField("WithoutHseFactor", ccsFloat, "");
        
        $this->BasePAYE = new clsField("BasePAYE", ccsFloat, "");
        
        $this->Cat_Amt = new clsField("Cat_Amt", ccsFloat, "");
        
        $this->Cat_Tax = new clsField("Cat_Tax", ccsFloat, "");
        
        $this->Cat_Min_Tax = new clsField("Cat_Min_Tax", ccsFloat, "");
        
        $this->CheckBox_Delete = new clsField("CheckBox_Delete", ccsBoolean, $this->BooleanFormat);
        

        $this->InsertFields["AmtFrom"] = array("Name" => "AmtFrom", "Value" => "", "DataType" => ccsFloat, "OmitIfEmpty" => 1);
        $this->InsertFields["AmtTo"] = array("Name" => "AmtTo", "Value" => "", "DataType" => ccsFloat, "OmitIfEmpty" => 1);
        $this->InsertFields["Rate"] = array("Name" => "Rate", "Value" => "", "DataType" => ccsFloat, "OmitIfEmpty" => 1);
        $this->InsertFields["WithHseFactor"] = array("Name" => "WithHseFactor", "Value" => "", "DataType" => ccsFloat, "OmitIfEmpty" => 1);
        $this->InsertFields["WithoutHseFactor"] = array("Name" => "WithoutHseFactor", "Value" => "", "DataType" => ccsFloat, "OmitIfEmpty" => 1);
        $this->InsertFields["BasePAYE"] = array("Name" => "BasePAYE", "Value" => "", "DataType" => ccsFloat, "OmitIfEmpty" => 1);
        $this->InsertFields["Cat_Amt"] = array("Name" => "Cat_Amt", "Value" => "", "DataType" => ccsFloat, "OmitIfEmpty" => 1);
        $this->InsertFields["Cat_Tax"] = array("Name" => "Cat_Tax", "Value" => "", "DataType" => ccsFloat, "OmitIfEmpty" => 1);
        $this->InsertFields["Cat_Min_Tax"] = array("Name" => "Cat_Min_Tax", "Value" => "", "DataType" => ccsFloat, "OmitIfEmpty" => 1);
        $this->UpdateFields["AmtFrom"] = array("Name" => "AmtFrom", "Value" => "", "DataType" => ccsFloat, "OmitIfEmpty" => 1);
        $this->UpdateFields["AmtTo"] = array("Name" => "AmtTo", "Value" => "", "DataType" => ccsFloat, "OmitIfEmpty" => 1);
        $this->UpdateFields["Rate"] = array("Name" => "Rate", "Value" => "", "DataType" => ccsFloat, "OmitIfEmpty" => 1);
        $this->UpdateFields["WithHseFactor"] = array("Name" => "WithHseFactor", "Value" => "", "DataType" => ccsFloat, "OmitIfEmpty" => 1);
        $this->UpdateFields["WithoutHseFactor"] = array("Name" => "WithoutHseFactor", "Value" => "", "DataType" => ccsFloat, "OmitIfEmpty" => 1);
        $this->UpdateFields["BasePAYE"] = array("Name" => "BasePAYE", "Value" => "", "DataType" => ccsFloat, "OmitIfEmpty" => 1);
        $this->UpdateFields["Cat_Amt"] = array("Name" => "Cat_Amt", "Value" => "", "DataType" => ccsFloat, "OmitIfEmpty" => 1);
        $this->UpdateFields["Cat_Tax"] = array("Name" => "Cat_Tax", "Value" => "", "DataType" => ccsFloat, "OmitIfEmpty" => 1);
        $this->UpdateFields["Cat_Min_Tax"] = array("Name" => "Cat_Min_Tax", "Value" => "", "DataType" => ccsFloat, "OmitIfEmpty" => 1);
    }
//End DataSourceClass_Initialize Event

//SetOrder Method @2-7F020960
    function SetOrder($SorterName, $SorterDirection)
    {
        $this->Order = "";
        $this->Order = CCGetOrder($this->Order, $SorterName, $SorterDirection, 
            array("Sorter1" => array("Rate", "")));
    }
//End SetOrder Method

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

//Open Method @2-1AE88B92
    function Open()
    {
        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeBuildSelect", $this->Parent);
        $this->CountSQL = "SELECT COUNT(*)\n\n" .
        "FROM prratetable";
        $this->SQL = "SELECT * \n\n" .
        "FROM prratetable {SQL_Where} {SQL_OrderBy}";
        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeExecuteSelect", $this->Parent);
        if ($this->CountSQL) 
            $this->RecordsCount = CCGetDBValue(CCBuildSQL($this->CountSQL, $this->Where, ""), $this);
        else
            $this->RecordsCount = "CCS not counted";
        $this->query($this->OptimizeSQL(CCBuildSQL($this->SQL, $this->Where, $this->Order)));
        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterExecuteSelect", $this->Parent);
    }
//End Open Method

//SetValues Method @2-4482134F
    function SetValues()
    {
        $this->CachedColumns["recid"] = $this->f("recid");
        $this->CachedColumns["AmtFrom"] = $this->f("AmtFrom");
        $this->AmtFrom->SetDBValue(trim($this->f("AmtFrom")));
        $this->AmtTo->SetDBValue(trim($this->f("AmtTo")));
        $this->Rate->SetDBValue(trim($this->f("Rate")));
        $this->WithHseFactor->SetDBValue(trim($this->f("WithHseFactor")));
        $this->WithoutHseFactor->SetDBValue(trim($this->f("WithoutHseFactor")));
        $this->BasePAYE->SetDBValue(trim($this->f("BasePAYE")));
        $this->Cat_Amt->SetDBValue(trim($this->f("Cat_Amt")));
        $this->Cat_Tax->SetDBValue(trim($this->f("Cat_Tax")));
        $this->Cat_Min_Tax->SetDBValue(trim($this->f("Cat_Min_Tax")));
    }
//End SetValues Method

//Insert Method @2-4DB54253
    function Insert()
    {
        global $CCSLocales;
        global $DefaultDateFormat;
        $this->CmdExecution = true;
        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeBuildInsert", $this->Parent);
        $this->InsertFields["AmtFrom"]["Value"] = $this->AmtFrom->GetDBValue(true);
        $this->InsertFields["AmtTo"]["Value"] = $this->AmtTo->GetDBValue(true);
        $this->InsertFields["Rate"]["Value"] = $this->Rate->GetDBValue(true);
        $this->InsertFields["WithHseFactor"]["Value"] = $this->WithHseFactor->GetDBValue(true);
        $this->InsertFields["WithoutHseFactor"]["Value"] = $this->WithoutHseFactor->GetDBValue(true);
        $this->InsertFields["BasePAYE"]["Value"] = $this->BasePAYE->GetDBValue(true);
        $this->InsertFields["Cat_Amt"]["Value"] = $this->Cat_Amt->GetDBValue(true);
        $this->InsertFields["Cat_Tax"]["Value"] = $this->Cat_Tax->GetDBValue(true);
        $this->InsertFields["Cat_Min_Tax"]["Value"] = $this->Cat_Min_Tax->GetDBValue(true);
        $this->SQL = CCBuildInsert("prratetable", $this->InsertFields, $this);
        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeExecuteInsert", $this->Parent);
        if($this->Errors->Count() == 0 && $this->CmdExecution) {
            $this->query($this->SQL);
            $this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterExecuteInsert", $this->Parent);
        }
    }
//End Insert Method

//Update Method @2-A7B3A93A
    function Update()
    {
        global $CCSLocales;
        global $DefaultDateFormat;
        $this->CmdExecution = true;
        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeBuildUpdate", $this->Parent);
        $SelectWhere = $this->Where;
        $this->Where = "recid=" . $this->ToSQL($this->CachedColumns["recid"], ccsInteger) . " AND AmtFrom=" . $this->ToSQL($this->CachedColumns["AmtFrom"], ccsFloat);
        $this->UpdateFields["AmtFrom"]["Value"] = $this->AmtFrom->GetDBValue(true);
        $this->UpdateFields["AmtTo"]["Value"] = $this->AmtTo->GetDBValue(true);
        $this->UpdateFields["Rate"]["Value"] = $this->Rate->GetDBValue(true);
        $this->UpdateFields["WithHseFactor"]["Value"] = $this->WithHseFactor->GetDBValue(true);
        $this->UpdateFields["WithoutHseFactor"]["Value"] = $this->WithoutHseFactor->GetDBValue(true);
        $this->UpdateFields["BasePAYE"]["Value"] = $this->BasePAYE->GetDBValue(true);
        $this->UpdateFields["Cat_Amt"]["Value"] = $this->Cat_Amt->GetDBValue(true);
        $this->UpdateFields["Cat_Tax"]["Value"] = $this->Cat_Tax->GetDBValue(true);
        $this->UpdateFields["Cat_Min_Tax"]["Value"] = $this->Cat_Min_Tax->GetDBValue(true);
        $this->SQL = CCBuildUpdate("prratetable", $this->UpdateFields, $this);
        $this->SQL = CCBuildSQL($this->SQL, $this->Where, "");
        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeExecuteUpdate", $this->Parent);
        if($this->Errors->Count() == 0 && $this->CmdExecution) {
            $this->query($this->SQL);
            $this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterExecuteUpdate", $this->Parent);
        }
        $this->Where = $SelectWhere;
    }
//End Update Method

//Delete Method @2-593FE533
    function Delete()
    {
        global $CCSLocales;
        global $DefaultDateFormat;
        $this->CmdExecution = true;
        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeBuildDelete", $this->Parent);
        $SelectWhere = $this->Where;
        $this->Where = "recid=" . $this->ToSQL($this->CachedColumns["recid"], ccsInteger) . " AND AmtFrom=" . $this->ToSQL($this->CachedColumns["AmtFrom"], ccsFloat);
        $this->SQL = "DELETE FROM prratetable";
        $this->SQL = CCBuildSQL($this->SQL, $this->Where, "");
        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeExecuteDelete", $this->Parent);
        if($this->Errors->Count() == 0 && $this->CmdExecution) {
            $this->query($this->SQL);
            $this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterExecuteDelete", $this->Parent);
        }
        $this->Where = $SelectWhere;
    }
//End Delete Method

} //End prratetableDataSource Class @2-FCB6E20C

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

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

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

//Authenticate User @1-872FD3D7
CCSecurityRedirect("", "");
//End Authenticate User

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

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

// Controls
$prratetable = & new clsEditableGridprratetable("", $MainPage);
$MainPage->prratetable = & $prratetable;
$prratetable->Initialize();

$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-8C0D1A68
$prratetable->Operation();
//End Execute Components

//Go to destination page @1-890269B8
if($Redirect)
{
    $CCSEventResult = CCGetEvent($CCSEvents, "BeforeUnload", $MainPage);
    $DBCoopWorksConn->close();
    header("Location: " . $Redirect);
    unset($prratetable);
    unset($Tpl);
    exit;
}
//End Go to destination page

//Show Page @1-C60C6E1A
$prratetable->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-A915E469
$CCSEventResult = CCGetEvent($CCSEvents, "BeforeUnload", $MainPage);
$DBCoopWorksConn->close();
unset($prratetable);
unset($Tpl);
//End Unload Page


?>
Return current item: CoopWorks Farmers Association Management