Location: PHPKode > projects > CoopWorks Farmers Association Management > CoopWorks 3.1/SM_screens_edit.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-F92D39BC
define("RelativePath", ".");
define("PathToCurrentPage", "/");
define("FileName", "SM_screens_edit.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 clsRecordNewRecord1 { //NewRecord1 Class @23-D7EDAFB1

//Variables @23-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 @23-8DDDD9E8
    function clsRecordNewRecord1($RelativePath, & $Parent)
    {

        global $FileName;
        global $CCSLocales;
        global $DefaultDateFormat;
        $this->Visible = true;
        $this->Parent = & $Parent;
        $this->RelativePath = $RelativePath;
        $this->Errors = new clsErrors();
        $this->ErrorBlock = "Record NewRecord1/Error";
        $this->ReadAllowed = true;
        $this->Visible = (CCSecurityAccessCheck("") == "success");
        if($this->Visible)
        {
            $this->ComponentName = "NewRecord1";
            $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->Module = & new clsControl(ccsListBox, "Module", "Module", ccsText, "", CCGetRequestParam("Module", $Method, NULL), $this);
            $this->Module->DSType = dsTable;
            $this->Module->DataSource = new clsDBCoopWorksConn();
            $this->Module->ds = & $this->Module->DataSource;
            $this->Module->DataSource->SQL = "SELECT * \n" .
"FROM modules {SQL_Where} {SQL_OrderBy}";
            list($this->Module->BoundColumn, $this->Module->TextColumn, $this->Module->DBFormat) = array("ModuleId", "Descr", "");
            $this->ClassID = & new clsControl(ccsListBox, "ClassID", "ClassID", ccsText, "", CCGetRequestParam("ClassID", $Method, NULL), $this);
            $this->ClassID->DSType = dsSQL;
            $this->ClassID->DataSource = new clsDBCoopWorksConn();
            $this->ClassID->ds = & $this->ClassID->DataSource;
            list($this->ClassID->BoundColumn, $this->ClassID->TextColumn, $this->ClassID->DBFormat) = array("classid", "classid", "");
            $this->ClassID->DataSource->SQL = "select distinct classid from menucontrol";
            $this->ClassID->DataSource->Order = "";
            $this->Button_DoSearch = & new clsButton("Button_DoSearch", $Method, $this);
        }
    }
//End Class_Initialize Event

//Validate Method @23-DA29ED2B
    function Validate()
    {
        global $CCSLocales;
        $Validation = true;
        $Where = "";
        $Validation = ($this->Module->Validate() && $Validation);
        $Validation = ($this->ClassID->Validate() && $Validation);
        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "OnValidate", $this);
        $Validation =  $Validation && ($this->Module->Errors->Count() == 0);
        $Validation =  $Validation && ($this->ClassID->Errors->Count() == 0);
        return (($this->Errors->Count() == 0) && $Validation);
    }
//End Validate Method

//CheckErrors Method @23-205FEA21
    function CheckErrors()
    {
        $errors = false;
        $errors = ($errors || $this->Module->Errors->Count());
        $errors = ($errors || $this->ClassID->Errors->Count());
        $errors = ($errors || $this->Errors->Count());
        return $errors;
    }
//End CheckErrors Method

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

//Operation Method @23-DD94EE4C
    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 = $FileName;
        if($this->Validate()) {
            if($this->PressedButton == "Button_DoSearch") {
                $Redirect = $FileName . "?" . 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 @23-CA9899F8
    function Show()
    {
        global $CCSUseAmp;
        global $Tpl;
        global $FileName;
        global $CCSLocales;
        $Error = "";

        if(!$this->Visible)
            return;

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

        $this->Module->Prepare();
        $this->ClassID->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->Module->Errors->ToString());
            $Error = ComposeStrings($Error, $this->ClassID->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->Module->Show();
        $this->ClassID->Show();
        $this->Button_DoSearch->Show();
        $Tpl->parse();
        $Tpl->block_path = $ParentPath;
    }
//End Show Method

} //End NewRecord1 Class @23-FCB6E20C

class clsEditableGridmenucontrol { //menucontrol Class @2-F4066788

//Variables @2-F667987F

    // 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
//End Variables

//Class_Initialize Event @2-57007137
    function clsEditableGridmenucontrol($RelativePath, & $Parent)
    {

        global $FileName;
        global $CCSLocales;
        global $DefaultDateFormat;
        $this->Visible = true;
        $this->Parent = & $Parent;
        $this->RelativePath = $RelativePath;
        $this->Errors = new clsErrors();
        $this->ErrorBlock = "EditableGrid menucontrol/Error";
        $this->ControlsErrors = array();
        $this->ComponentName = "menucontrol";
        $this->Attributes = new clsAttributes($this->ComponentName . ":");
        $this->CachedColumns["recid"][0] = "recid";
        $this->DataSource = new clsmenucontrolDataSource($this);
        $this->ds = & $this->DataSource;
        $this->PageSize = CCGetParam($this->ComponentName . "PageSize", "");
        if(!is_numeric($this->PageSize) || !strlen($this->PageSize))
            $this->PageSize = 30;
        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 = 0;
        $this->ReadAllowed = true;
        $this->Visible = (CCSecurityAccessCheck("1;2;3") == "success");
        if(!$this->Visible) return;

        $this->ReadAllowed = $this->ReadAllowed && CCUserInGroups(CCGetGroupID(), "1;2;3");
        $this->UpdateAllowed = CCUserInGroups(CCGetGroupID(), "1;3");
        $this->DeleteAllowed = CCUserInGroups(CCGetGroupID(), "2;3");
        $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->MenuID = & new clsControl(ccsHidden, "MenuID", "Menu ID", ccsText, "", NULL, $this);
        $this->MenuID->Required = true;
        $this->Label1 = & new clsControl(ccsLabel, "Label1", "Label1", ccsText, "", NULL, $this);
        $this->Module = & new clsControl(ccsListBox, "Module", "Module", ccsText, "", NULL, $this);
        $this->Module->DSType = dsTable;
        $this->Module->DataSource = new clsDBCoopWorksConn();
        $this->Module->ds = & $this->Module->DataSource;
        $this->Module->DataSource->SQL = "SELECT * \n" .
"FROM menucontrol {SQL_Where} {SQL_OrderBy}";
        list($this->Module->BoundColumn, $this->Module->TextColumn, $this->Module->DBFormat) = array("Module", "Module", "");
        $this->Module->Required = true;
        $this->ClassID = & new clsControl(ccsListBox, "ClassID", "Class ID", ccsText, "", NULL, $this);
        $this->ClassID->DSType = dsTable;
        $this->ClassID->DataSource = new clsDBCoopWorksConn();
        $this->ClassID->ds = & $this->ClassID->DataSource;
        $this->ClassID->DataSource->SQL = "SELECT * \n" .
"FROM menucontrol {SQL_Where} {SQL_OrderBy}";
        list($this->ClassID->BoundColumn, $this->ClassID->TextColumn, $this->ClassID->DBFormat) = array("ClassID", "ClassID", "");
        $this->Type = & new clsControl(ccsListBox, "Type", "Type", ccsText, "", NULL, $this);
        $this->Type->DSType = dsTable;
        $this->Type->DataSource = new clsDBCoopWorksConn();
        $this->Type->ds = & $this->Type->DataSource;
        $this->Type->DataSource->SQL = "SELECT * \n" .
"FROM menucontrol {SQL_Where} {SQL_OrderBy}";
        list($this->Type->BoundColumn, $this->Type->TextColumn, $this->Type->DBFormat) = array("Type", "Type", "");
        $this->DisplayText = & new clsControl(ccsTextBox, "DisplayText", "Display Text", ccsText, "", NULL, $this);
        $this->Link = & new clsControl(ccsTextBox, "Link", "Link", ccsText, "", 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->Navigator1 = & new clsNavigator($this->ComponentName, "Navigator1", $FileName, 10, tpCentered, $this);
        $this->Navigator1->PageSizes = array("1", "5", "10", "25", "50");
        $this->Button_Submit = & new clsButton("Button_Submit", $Method, $this);
        $this->Cancel = & new clsButton("Cancel", $Method, $this);
    }
//End Class_Initialize Event

//Initialize Method @2-5423343E
    function Initialize()
    {
        if(!$this->Visible) return;

        $this->DataSource->PageSize = & $this->PageSize;
        $this->DataSource->AbsolutePage = & $this->PageNumber;
        $this->DataSource->SetOrder($this->SorterName, $this->SorterDirection);

        $this->DataSource->Parameters["urlModule"] = CCGetFromGet("Module", NULL);
        $this->DataSource->Parameters["urlClassID"] = CCGetFromGet("ClassID", NULL);
    }
//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-69B7C698
    function GetFormParameters()
    {
        for($RowNumber = 1; $RowNumber <= $this->TotalRows; $RowNumber++)
        {
            $this->FormParameters["MenuID"][$RowNumber] = CCGetFromPost("MenuID_" . $RowNumber, NULL);
            $this->FormParameters["Module"][$RowNumber] = CCGetFromPost("Module_" . $RowNumber, NULL);
            $this->FormParameters["ClassID"][$RowNumber] = CCGetFromPost("ClassID_" . $RowNumber, NULL);
            $this->FormParameters["Type"][$RowNumber] = CCGetFromPost("Type_" . $RowNumber, NULL);
            $this->FormParameters["DisplayText"][$RowNumber] = CCGetFromPost("DisplayText_" . $RowNumber, NULL);
            $this->FormParameters["Link"][$RowNumber] = CCGetFromPost("Link_" . $RowNumber, NULL);
            $this->FormParameters["CheckBox_Delete"][$RowNumber] = CCGetFromPost("CheckBox_Delete_" . $RowNumber, NULL);
        }
    }
//End GetFormParameters Method

//Validate Method @2-54B63E6D
    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->CurrentRow = $this->RowNumber;
            $this->MenuID->SetText($this->FormParameters["MenuID"][$this->RowNumber], $this->RowNumber);
            $this->Module->SetText($this->FormParameters["Module"][$this->RowNumber], $this->RowNumber);
            $this->ClassID->SetText($this->FormParameters["ClassID"][$this->RowNumber], $this->RowNumber);
            $this->Type->SetText($this->FormParameters["Type"][$this->RowNumber], $this->RowNumber);
            $this->DisplayText->SetText($this->FormParameters["DisplayText"][$this->RowNumber], $this->RowNumber);
            $this->Link->SetText($this->FormParameters["Link"][$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-B1F73F6F
    function ValidateRow()
    {
        global $CCSLocales;
        $this->MenuID->Validate();
        $this->Module->Validate();
        $this->ClassID->Validate();
        $this->Type->Validate();
        $this->DisplayText->Validate();
        $this->Link->Validate();
        $this->CheckBox_Delete->Validate();
        $this->RowErrors = new clsErrors();
        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "OnValidateRow", $this);
        $errors = "";
        $errors = ComposeStrings($errors, $this->MenuID->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Module->Errors->ToString());
        $errors = ComposeStrings($errors, $this->ClassID->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Type->Errors->ToString());
        $errors = ComposeStrings($errors, $this->DisplayText->Errors->ToString());
        $errors = ComposeStrings($errors, $this->Link->Errors->ToString());
        $errors = ComposeStrings($errors, $this->CheckBox_Delete->Errors->ToString());
        $this->MenuID->Errors->Clear();
        $this->Module->Errors->Clear();
        $this->ClassID->Errors->Clear();
        $this->Type->Errors->Clear();
        $this->DisplayText->Errors->Clear();
        $this->Link->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-408532DA
    function CheckInsert()
    {
        $filed = false;
        $filed = ($filed || (is_array($this->FormParameters["MenuID"][$this->RowNumber]) && count($this->FormParameters["MenuID"][$this->RowNumber])) || strlen($this->FormParameters["MenuID"][$this->RowNumber]));
        $filed = ($filed || (is_array($this->FormParameters["Module"][$this->RowNumber]) && count($this->FormParameters["Module"][$this->RowNumber])) || strlen($this->FormParameters["Module"][$this->RowNumber]));
        $filed = ($filed || (is_array($this->FormParameters["ClassID"][$this->RowNumber]) && count($this->FormParameters["ClassID"][$this->RowNumber])) || strlen($this->FormParameters["ClassID"][$this->RowNumber]));
        $filed = ($filed || (is_array($this->FormParameters["Type"][$this->RowNumber]) && count($this->FormParameters["Type"][$this->RowNumber])) || strlen($this->FormParameters["Type"][$this->RowNumber]));
        $filed = ($filed || (is_array($this->FormParameters["DisplayText"][$this->RowNumber]) && count($this->FormParameters["DisplayText"][$this->RowNumber])) || strlen($this->FormParameters["DisplayText"][$this->RowNumber]));
        $filed = ($filed || (is_array($this->FormParameters["Link"][$this->RowNumber]) && count($this->FormParameters["Link"][$this->RowNumber])) || strlen($this->FormParameters["Link"][$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-47ABDCA7
    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->CurrentRow = $this->RowNumber;
            $this->MenuID->SetText($this->FormParameters["MenuID"][$this->RowNumber], $this->RowNumber);
            $this->Module->SetText($this->FormParameters["Module"][$this->RowNumber], $this->RowNumber);
            $this->ClassID->SetText($this->FormParameters["ClassID"][$this->RowNumber], $this->RowNumber);
            $this->Type->SetText($this->FormParameters["Type"][$this->RowNumber], $this->RowNumber);
            $this->DisplayText->SetText($this->FormParameters["DisplayText"][$this->RowNumber], $this->RowNumber);
            $this->Link->SetText($this->FormParameters["Link"][$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

//UpdateRow Method @2-1430899F
    function UpdateRow()
    {
        if(!$this->UpdateAllowed) return false;
        $this->DataSource->MenuID->SetValue($this->MenuID->GetValue(true));
        $this->DataSource->Label1->SetValue($this->Label1->GetValue(true));
        $this->DataSource->Module->SetValue($this->Module->GetValue(true));
        $this->DataSource->ClassID->SetValue($this->ClassID->GetValue(true));
        $this->DataSource->Type->SetValue($this->Type->GetValue(true));
        $this->DataSource->DisplayText->SetValue($this->DisplayText->GetValue(true));
        $this->DataSource->Link->SetValue($this->Link->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-5C99B905
    function FormScript($TotalRows)
    {
        $script = "";
        $script .= "\n<script language=\"JavaScript\" type=\"text/javascript\">\n<!--\n";
        $script .= "var menucontrolElements;\n";
        $script .= "var menucontrolEmptyRows = 0;\n";
        $script .= "var " . $this->ComponentName . "MenuIDID = 0;\n";
        $script .= "var " . $this->ComponentName . "ModuleID = 1;\n";
        $script .= "var " . $this->ComponentName . "ClassIDID = 2;\n";
        $script .= "var " . $this->ComponentName . "TypeID = 3;\n";
        $script .= "var " . $this->ComponentName . "DisplayTextID = 4;\n";
        $script .= "var " . $this->ComponentName . "LinkID = 5;\n";
        $script .= "var " . $this->ComponentName . "DeleteControl = 6;\n";
        $script .= "\nfunction initmenucontrolElements() {\n";
        $script .= "\tvar ED = document.forms[\"menucontrol\"];\n";
        $script .= "\tmenucontrolElements = new Array (\n";
        for($i = 1; $i <= $TotalRows; $i++) {
            $script .= "\t\tnew Array(" . "ED.MenuID_" . $i . ", " . "ED.Module_" . $i . ", " . "ED.ClassID_" . $i . ", " . "ED.Type_" . $i . ", " . "ED.DisplayText_" . $i . ", " . "ED.Link_" . $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-6BBEAF21
    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 + 1)  {
                $piece = $pieces[$i + 0];
                $piece = str_replace("\\" . ord("\\"), "\\", $piece);
                $piece = str_replace("\\" . ord(";"), ";", $piece);
                $this->CachedColumns["recid"][$RowNumber] = $piece;
                $RowNumber++;
            }

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

//GetFormState Method @2-6D0F1130
    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]));
                }
            }
        }
        return $this->FormState;
    }
//End GetFormState Method

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

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

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

        $this->Module->Prepare();
        $this->ClassID->Prepare();
        $this->Type->Prepare();

        $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["MenuID"] = $this->MenuID->Visible;
        $this->ControlsVisible["Label1"] = $this->Label1->Visible;
        $this->ControlsVisible["Module"] = $this->Module->Visible;
        $this->ControlsVisible["ClassID"] = $this->ClassID->Visible;
        $this->ControlsVisible["Type"] = $this->Type->Visible;
        $this->ControlsVisible["DisplayText"] = $this->DisplayText->Visible;
        $this->ControlsVisible["Link"] = $this->Link->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->CheckBox_Delete->SetValue("");
                    $this->MenuID->SetValue($this->DataSource->MenuID->GetValue());
                    $this->Label1->SetValue($this->DataSource->Label1->GetValue());
                    $this->Module->SetValue($this->DataSource->Module->GetValue());
                    $this->ClassID->SetValue($this->DataSource->ClassID->GetValue());
                    $this->Type->SetValue($this->DataSource->Type->GetValue());
                    $this->DisplayText->SetValue($this->DataSource->DisplayText->GetValue());
                    $this->Link->SetValue($this->DataSource->Link->GetValue());
                } elseif ($this->FormSubmitted && $is_next_record) {
                    $this->Label1->SetText("");
                    $this->Label1->SetValue($this->DataSource->Label1->GetValue());
                    $this->MenuID->SetText($this->FormParameters["MenuID"][$this->RowNumber], $this->RowNumber);
                    $this->Module->SetText($this->FormParameters["Module"][$this->RowNumber], $this->RowNumber);
                    $this->ClassID->SetText($this->FormParameters["ClassID"][$this->RowNumber], $this->RowNumber);
                    $this->Type->SetText($this->FormParameters["Type"][$this->RowNumber], $this->RowNumber);
                    $this->DisplayText->SetText($this->FormParameters["DisplayText"][$this->RowNumber], $this->RowNumber);
                    $this->Link->SetText($this->FormParameters["Link"][$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->MenuID->SetText("");
                    $this->Label1->SetText("");
                    $this->Module->SetText("");
                    $this->ClassID->SetText("");
                    $this->Type->SetText("");
                    $this->DisplayText->SetText("");
                    $this->Link->SetText("");
                } else {
                    $this->Label1->SetText("");
                    $this->MenuID->SetText($this->FormParameters["MenuID"][$this->RowNumber], $this->RowNumber);
                    $this->Module->SetText($this->FormParameters["Module"][$this->RowNumber], $this->RowNumber);
                    $this->ClassID->SetText($this->FormParameters["ClassID"][$this->RowNumber], $this->RowNumber);
                    $this->Type->SetText($this->FormParameters["Type"][$this->RowNumber], $this->RowNumber);
                    $this->DisplayText->SetText($this->FormParameters["DisplayText"][$this->RowNumber], $this->RowNumber);
                    $this->Link->SetText($this->FormParameters["Link"][$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->MenuID->Show($this->RowNumber);
                $this->Label1->Show($this->RowNumber);
                $this->Module->Show($this->RowNumber);
                $this->ClassID->Show($this->RowNumber);
                $this->Type->Show($this->RowNumber);
                $this->DisplayText->Show($this->RowNumber);
                $this->Link->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])) {
                            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->Navigator1->PageNumber = $this->DataSource->AbsolutePage;
        $this->Navigator1->PageSize = $this->PageSize;
        if ($this->DataSource->RecordsCount == "CCS not counted")
            $this->Navigator1->TotalPages = $this->DataSource->AbsolutePage + ($this->DataSource->next_record() ? 1 : 0);
        else
            $this->Navigator1->TotalPages = $this->DataSource->PageCount();
        if ($this->Navigator1->TotalPages <= 1) {
            $this->Navigator1->Visible = false;
        }
        $this->Navigator1->Show();
        $this->Button_Submit->Show();
        $this->Cancel->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 menucontrol Class @2-FCB6E20C

class clsmenucontrolDataSource extends clsDBCoopWorksConn {  //menucontrolDataSource Class @2-67D623AB

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

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

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

    // Datasource fields
    var $MenuID;
    var $Label1;
    var $Module;
    var $ClassID;
    var $Type;
    var $DisplayText;
    var $Link;
    var $CheckBox_Delete;
//End DataSource Variables

//DataSourceClass_Initialize Event @2-FD56BFB0
    function clsmenucontrolDataSource(& $Parent)
    {
        $this->Parent = & $Parent;
        $this->ErrorBlock = "EditableGrid menucontrol/Error";
        $this->Initialize();
        $this->MenuID = new clsField("MenuID", ccsText, "");
        
        $this->Label1 = new clsField("Label1", ccsText, "");
        
        $this->Module = new clsField("Module", ccsText, "");
        
        $this->ClassID = new clsField("ClassID", ccsText, "");
        
        $this->Type = new clsField("Type", ccsText, "");
        
        $this->DisplayText = new clsField("DisplayText", ccsText, "");
        
        $this->Link = new clsField("Link", ccsText, "");
        
        $this->CheckBox_Delete = new clsField("CheckBox_Delete", ccsBoolean, $this->BooleanFormat);
        

        $this->UpdateFields["MenuID"] = array("Name" => "MenuID", "Value" => "", "DataType" => ccsText, "OmitIfEmpty" => 1);
        $this->UpdateFields["Module"] = array("Name" => "Module", "Value" => "", "DataType" => ccsText, "OmitIfEmpty" => 1);
        $this->UpdateFields["ClassID"] = array("Name" => "ClassID", "Value" => "", "DataType" => ccsText, "OmitIfEmpty" => 1);
        $this->UpdateFields["Type"] = array("Name" => "Type", "Value" => "", "DataType" => ccsText, "OmitIfEmpty" => 1);
        $this->UpdateFields["DisplayText"] = array("Name" => "DisplayText", "Value" => "", "DataType" => ccsText, "OmitIfEmpty" => 1);
        $this->UpdateFields["Link"] = array("Name" => "Link", "Value" => "", "DataType" => ccsText, "OmitIfEmpty" => 1);
    }
//End DataSourceClass_Initialize Event

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

//Prepare Method @2-23B4B056
    function Prepare()
    {
        global $CCSLocales;
        global $DefaultDateFormat;
        $this->wp = new clsSQLParameters($this->ErrorBlock);
        $this->wp->AddParameter("1", "urlModule", ccsText, "", "", $this->Parameters["urlModule"], "", false);
        $this->wp->AddParameter("2", "urlClassID", ccsText, "", "", $this->Parameters["urlClassID"], 0, false);
        $this->AllParametersSet = $this->wp->AllParamsSet();
        $this->wp->Criterion[1] = $this->wp->Operation(opEqual, "Module", $this->wp->GetDBValue("1"), $this->ToSQL($this->wp->GetDBValue("1"), ccsText),false);
        $this->wp->Criterion[2] = $this->wp->Operation(opContains, "ClassID", $this->wp->GetDBValue("2"), $this->ToSQL($this->wp->GetDBValue("2"), ccsText),false);
        $this->Where = $this->wp->opAND(
             false, 
             $this->wp->Criterion[1], 
             $this->wp->Criterion[2]);
    }
//End Prepare Method

//Open Method @2-AFAB720A
    function Open()
    {
        $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeBuildSelect", $this->Parent);
        $this->CountSQL = "SELECT COUNT(*)\n\n" .
        "FROM menucontrol";
        $this->SQL = "SELECT * \n\n" .
        "FROM menucontrol {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-DE16EC4B
    function SetValues()
    {
        $this->CachedColumns["recid"] = $this->f("recid");
        $this->MenuID->SetDBValue($this->f("MenuID"));
        $this->Label1->SetDBValue($this->f("MenuID"));
        $this->Module->SetDBValue($this->f("Module"));
        $this->ClassID->SetDBValue($this->f("ClassID"));
        $this->Type->SetDBValue($this->f("Type"));
        $this->DisplayText->SetDBValue($this->f("DisplayText"));
        $this->Link->SetDBValue($this->f("Link"));
    }
//End SetValues Method

//Update Method @2-9C8806D1
    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"], ccsFloat);
        $this->UpdateFields["MenuID"]["Value"] = $this->MenuID->GetDBValue(true);
        $this->UpdateFields["Module"]["Value"] = $this->Module->GetDBValue(true);
        $this->UpdateFields["ClassID"]["Value"] = $this->ClassID->GetDBValue(true);
        $this->UpdateFields["Type"]["Value"] = $this->Type->GetDBValue(true);
        $this->UpdateFields["DisplayText"]["Value"] = $this->DisplayText->GetDBValue(true);
        $this->UpdateFields["Link"]["Value"] = $this->Link->GetDBValue(true);
        $this->SQL = CCBuildUpdate("menucontrol", $this->UpdateFields, $this);
        $this->SQL = CCBuildSQL($this->SQL, $this->Where, "");
        if (!strlen($this->Where) && $this->Errors->Count() == 0) 
            $this->Errors->addError($CCSLocales->GetText("CCS_CustomOperationError_MissingParameters"));
        $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-0CF0C7E4
    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"], ccsFloat);
        $this->SQL = "DELETE FROM menucontrol";
        $this->SQL = CCBuildSQL($this->SQL, $this->Where, "");
        if (!strlen($this->Where) && $this->Errors->Count() == 0) 
            $this->Errors->addError($CCSLocales->GetText("CCS_CustomOperationError_MissingParameters"));
        $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 menucontrolDataSource Class @2-FCB6E20C

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

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

$FileName = FileName;
$Redirect = "";
$TemplateFileName = "SM_screens_edit.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

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

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

// Controls
$NewRecord1 = & new clsRecordNewRecord1("", $MainPage);
$menucontrol = & new clsEditableGridmenucontrol("", $MainPage);
$MainPage->NewRecord1 = & $NewRecord1;
$MainPage->menucontrol = & $menucontrol;
$menucontrol->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-EB8D7E1C
$NewRecord1->Operation();
$menucontrol->Operation();
//End Execute Components

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

//Show Page @1-41D831A7
$NewRecord1->Show();
$menucontrol->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-6F5A2E6F
$CCSEventResult = CCGetEvent($CCSEvents, "BeforeUnload", $MainPage);
$DBCoopWorksConn->close();
unset($NewRecord1);
unset($menucontrol);
unset($Tpl);
//End Unload Page


?>
Return current item: CoopWorks Farmers Association Management