<?php
//Aworks.org/licence.html.
// Produced by Webdiscount Technologies(Kenya) under Contract
// No. KSL/CONSULT.GEN/1 with the The Kenya National Federation of Agricultural Producers(KENFAP) and in collaboration with Food and Agriculture Organization
// of the United Nations (FAO), Agriculturathe Ministry of
// Co-operative Development and Marketing (Kenya) and piloted at Wamunyu Dairy Cooperative Society(Kenya) and Ololaiser Dairy Farmers Cooperative Society(Kenya).
//Include Common Files @1-CCAFBE82
define("RelativePath", ".");
define("PathToCurrentPage", "/");
define("FileName", "CA_CashPayment_Fee.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 clsRecordCashFees { //CashFees Class @50-D370BC4B
//Variables @50-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 @50-90AE2146
function clsRecordCashFees($RelativePath, & $Parent)
{
global $FileName;
global $CCSLocales;
global $DefaultDateFormat;
$this->Visible = true;
$this->Parent = & $Parent;
$this->RelativePath = $RelativePath;
$this->Errors = new clsErrors();
$this->ErrorBlock = "Record CashFees/Error";
$this->DataSource = new clsCashFeesDataSource($this);
$this->ds = & $this->DataSource;
$this->ReadAllowed = true;
$this->Visible = (CCSecurityAccessCheck("1;2;3") == "success");
if($this->Visible)
{
$this->ReadAllowed = $this->ReadAllowed && CCUserInGroups(CCGetGroupID(), "1;2;3");
$this->ComponentName = "CashFees";
$this->Attributes = new clsAttributes($this->ComponentName . ":");
$CCSForm = split(":", CCGetFromGet("ccsForm", ""), 2);
if(sizeof($CCSForm) == 1)
$CCSForm[1] = "";
list($FormName, $FormMethod) = $CCSForm;
$this->EditMode = ($FormMethod == "Edit");
$this->FormEnctype = "application/x-www-form-urlencoded";
$this->FormSubmitted = ($FormName == $this->ComponentName);
$Method = $this->FormSubmitted ? ccsPost : ccsGet;
$this->xmonth = & new clsControl(ccsTextBox, "xmonth", "xmonth", ccsText, "", CCGetRequestParam("xmonth", $Method, NULL), $this);
$this->xyear = & new clsControl(ccsTextBox, "xyear", "xyear", ccsText, "", CCGetRequestParam("xyear", $Method, NULL), $this);
$this->TranDate = & new clsControl(ccsTextBox, "TranDate", "TranDate", ccsText, "", CCGetRequestParam("TranDate", $Method, NULL), $this);
$this->Button1 = & new clsButton("Button1", $Method, $this);
$this->Button_Cancel = & new clsButton("Button_Cancel", $Method, $this);
$this->DatePicker_TranDate1 = & new clsDatePicker("DatePicker_TranDate1", "CashFees", "TranDate", $this);
}
}
//End Class_Initialize Event
//Initialize Method @50-5D060BAC
function Initialize()
{
if(!$this->Visible)
return;
}
//End Initialize Method
//Validate Method @50-BAC5AD1A
function Validate()
{
global $CCSLocales;
$Validation = true;
$Where = "";
$Validation = ($this->xmonth->Validate() && $Validation);
$Validation = ($this->xyear->Validate() && $Validation);
$Validation = ($this->TranDate->Validate() && $Validation);
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "OnValidate", $this);
$Validation = $Validation && ($this->xmonth->Errors->Count() == 0);
$Validation = $Validation && ($this->xyear->Errors->Count() == 0);
$Validation = $Validation && ($this->TranDate->Errors->Count() == 0);
return (($this->Errors->Count() == 0) && $Validation);
}
//End Validate Method
//CheckErrors Method @50-D510DF9B
function CheckErrors()
{
$errors = false;
$errors = ($errors || $this->xmonth->Errors->Count());
$errors = ($errors || $this->xyear->Errors->Count());
$errors = ($errors || $this->TranDate->Errors->Count());
$errors = ($errors || $this->DatePicker_TranDate1->Errors->Count());
$errors = ($errors || $this->Errors->Count());
$errors = ($errors || $this->DataSource->Errors->Count());
return $errors;
}
//End CheckErrors Method
//MasterDetail @50-ED598703
function SetPrimaryKeys($keyArray)
{
$this->PrimaryKeys = $keyArray;
}
function GetPrimaryKeys()
{
return $this->PrimaryKeys;
}
function GetPrimaryKey($keyName)
{
return $this->PrimaryKeys[$keyName];
}
//End MasterDetail
//Operation Method @50-87DB0986
function Operation()
{
if(!$this->Visible)
return;
global $Redirect;
global $FileName;
$this->DataSource->Prepare();
if(!$this->FormSubmitted) {
$this->EditMode = true;
return;
}
if($this->FormSubmitted) {
$this->PressedButton = "Button1";
if($this->Button1->Pressed) {
$this->PressedButton = "Button1";
} else if($this->Button_Cancel->Pressed) {
$this->PressedButton = "Button_Cancel";
}
}
$Redirect = $FileName . "?" . CCGetQueryString("All", array("ccsForm"));
if($this->PressedButton == "Button_Cancel") {
$Redirect = $FileName . "?" . CCGetQueryString("All", array("ccsForm", "xmonth", "xyear", "TranDate"));
if(!CCGetEvent($this->Button_Cancel->CCSEvents, "OnClick", $this->Button_Cancel)) {
$Redirect = "";
}
} else if($this->Validate()) {
if($this->PressedButton == "Button1") {
if(!CCGetEvent($this->Button1->CCSEvents, "OnClick", $this->Button1)) {
$Redirect = "";
}
}
} else {
$Redirect = "";
}
if ($Redirect)
$this->DataSource->close();
}
//End Operation Method
//Show Method @50-21BA682E
function Show()
{
global $CCSUseAmp;
global $Tpl;
global $FileName;
global $CCSLocales;
$Error = "";
if(!$this->Visible)
return;
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeSelect", $this);
$RecordBlock = "Record " . $this->ComponentName;
$ParentPath = $Tpl->block_path;
$Tpl->block_path = $ParentPath . "/" . $RecordBlock;
$this->EditMode = $this->EditMode && $this->ReadAllowed;
if($this->EditMode) {
if($this->DataSource->Errors->Count()){
$this->Errors->AddErrors($this->DataSource->Errors);
$this->DataSource->Errors->clear();
}
$this->DataSource->Open();
if($this->DataSource->Errors->Count() == 0 && $this->DataSource->next_record()) {
$this->DataSource->SetValues();
} else {
$this->EditMode = false;
}
}
if (!$this->FormSubmitted) {
}
if($this->FormSubmitted || $this->CheckErrors()) {
$Error = "";
$Error = ComposeStrings($Error, $this->xmonth->Errors->ToString());
$Error = ComposeStrings($Error, $this->xyear->Errors->ToString());
$Error = ComposeStrings($Error, $this->TranDate->Errors->ToString());
$Error = ComposeStrings($Error, $this->DatePicker_TranDate1->Errors->ToString());
$Error = ComposeStrings($Error, $this->Errors->ToString());
$Error = ComposeStrings($Error, $this->DataSource->Errors->ToString());
$Tpl->SetVar("Error", $Error);
$Tpl->Parse("Error", false);
}
$CCSForm = $this->EditMode ? $this->ComponentName . ":" . "Edit" : $this->ComponentName;
if($this->FormSubmitted || CCGetFromGet("ccsForm")) {
$this->HTMLFormAction = $FileName . "?" . CCAddParam(CCGetQueryString("QueryString", ""), "ccsForm", $CCSForm);
} else {
$this->HTMLFormAction = $FileName . "?" . CCAddParam(CCGetQueryString("All", ""), "ccsForm", $CCSForm);
}
$Tpl->SetVar("Action", !$CCSUseAmp ? $this->HTMLFormAction : str_replace("&", "&", $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->xmonth->Show();
$this->xyear->Show();
$this->TranDate->Show();
$this->Button1->Show();
$this->Button_Cancel->Show();
$this->DatePicker_TranDate1->Show();
$Tpl->parse();
$Tpl->block_path = $ParentPath;
$this->DataSource->close();
}
//End Show Method
} //End CashFees Class @50-FCB6E20C
class clsCashFeesDataSource extends clsDBCoopWorksConn { //CashFeesDataSource Class @50-ACF89918
//DataSource Variables @50-75664F71
var $Parent = "";
var $CCSEvents = "";
var $CCSEventResult;
var $ErrorBlock;
var $CmdExecution;
var $wp;
var $AllParametersSet;
// Datasource fields
var $xmonth;
var $xyear;
var $TranDate;
//End DataSource Variables
//DataSourceClass_Initialize Event @50-0CEAEC3B
function clsCashFeesDataSource(& $Parent)
{
$this->Parent = & $Parent;
$this->ErrorBlock = "Record CashFees/Error";
$this->Initialize();
$this->xmonth = new clsField("xmonth", ccsText, "");
$this->xyear = new clsField("xyear", ccsText, "");
$this->TranDate = new clsField("TranDate", ccsText, "");
}
//End DataSourceClass_Initialize Event
//Prepare Method @50-14D6CD9D
function Prepare()
{
global $CCSLocales;
global $DefaultDateFormat;
}
//End Prepare Method
//Open Method @50-E02EF820
function Open()
{
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeBuildSelect", $this->Parent);
$this->SQL = "SELECT * \n\n" .
"FROM casetup {SQL_Where} {SQL_OrderBy}";
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeExecuteSelect", $this->Parent);
$this->PageSize = 1;
$this->query($this->OptimizeSQL(CCBuildSQL($this->SQL, $this->Where, $this->Order)));
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterExecuteSelect", $this->Parent);
}
//End Open Method
//SetValues Method @50-BAF0975B
function SetValues()
{
}
//End SetValues Method
} //End CashFeesDataSource Class @50-FCB6E20C
class clsEditableGridEditableGrid1 { //EditableGrid1 Class @69-6C37505C
//Variables @69-2F047983
// 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 $Sorter3;
var $Sorter1;
var $Sorter2;
var $Sorter4;
var $Sorter5;
//End Variables
//Class_Initialize Event @69-3E442807
function clsEditableGridEditableGrid1($RelativePath, & $Parent)
{
global $FileName;
global $CCSLocales;
global $DefaultDateFormat;
$this->Visible = true;
$this->Parent = & $Parent;
$this->RelativePath = $RelativePath;
$this->Errors = new clsErrors();
$this->ErrorBlock = "EditableGrid EditableGrid1/Error";
$this->ControlsErrors = array();
$this->ComponentName = "EditableGrid1";
$this->Attributes = new clsAttributes($this->ComponentName . ":");
$this->CachedColumns["memberid"][0] = "memberid";
$this->DataSource = new clsEditableGrid1DataSource($this);
$this->ds = & $this->DataSource;
$this->PageSize = CCGetParam($this->ComponentName . "PageSize", "");
if(!is_numeric($this->PageSize) || !strlen($this->PageSize))
$this->PageSize = 100;
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->UpdateAllowed = true;
$this->ReadAllowed = true;
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("EditableGrid1Order", "");
$this->SorterDirection = CCGetParam("EditableGrid1Dir", "");
$this->memberid = & new clsControl(ccsLabel, "memberid", $CCSLocales->GetText("memberid"), ccsFloat, "", NULL, $this);
$this->firstname = & new clsControl(ccsLabel, "firstname", $CCSLocales->GetText("firstname"), ccsText, "", NULL, $this);
$this->middlename = & new clsControl(ccsLabel, "middlename", $CCSLocales->GetText("middlename"), ccsText, "", NULL, $this);
$this->lastname = & new clsControl(ccsLabel, "lastname", $CCSLocales->GetText("lastname"), ccsText, "", NULL, $this);
$this->AmountPaid = & new clsControl(ccsLabel, "AmountPaid", $CCSLocales->GetText("AmountPaid"), ccsFloat, array(False, 2, Null, Null, False, "", "", 1, True, ""), NULL, $this);
$this->selected = & new clsControl(ccsCheckBox, "selected", "selected", ccsBoolean, $CCSLocales->GetFormatInfo("BooleanFormat"), NULL, $this);
$this->selected->CheckedValue = true;
$this->selected->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->Sorter3 = & new clsSorter($this->ComponentName, "Sorter3", $FileName, $this);
$this->Sorter1 = & new clsSorter($this->ComponentName, "Sorter1", $FileName, $this);
$this->Sorter2 = & new clsSorter($this->ComponentName, "Sorter2", $FileName, $this);
$this->Sorter4 = & new clsSorter($this->ComponentName, "Sorter4", $FileName, $this);
$this->Sorter5 = & new clsSorter($this->ComponentName, "Sorter5", $FileName, $this);
}
//End Class_Initialize Event
//Initialize Method @69-7BA170A7
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["urlxmonth"] = CCGetFromGet("xmonth", NULL);
$this->DataSource->Parameters["urlxyear"] = CCGetFromGet("xyear", NULL);
}
//End Initialize Method
//SetPrimaryKeys Method @69-EBC3F86C
function SetPrimaryKeys($PrimaryKeys) {
$this->PrimaryKeys = $PrimaryKeys;
return $this->PrimaryKeys;
}
//End SetPrimaryKeys Method
//GetPrimaryKeys Method @69-74F9A772
function GetPrimaryKeys() {
return $this->PrimaryKeys;
}
//End GetPrimaryKeys Method
//GetFormParameters Method @69-9550F326
function GetFormParameters()
{
for($RowNumber = 1; $RowNumber <= $this->TotalRows; $RowNumber++)
{
$this->FormParameters["selected"][$RowNumber] = CCGetFromPost("selected_" . $RowNumber, NULL);
}
}
//End GetFormParameters Method
//Validate Method @69-5E1ABBBB
function Validate()
{
$Validation = true;
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "OnValidate", $this);
for($this->RowNumber = 1; $this->RowNumber <= $this->TotalRows; $this->RowNumber++)
{
$this->DataSource->CachedColumns["memberid"] = $this->CachedColumns["memberid"][$this->RowNumber];
$this->DataSource->CurrentRow = $this->RowNumber;
$this->selected->SetText($this->FormParameters["selected"][$this->RowNumber], $this->RowNumber);
if ($this->UpdatedRows >= $this->RowNumber) {
$Validation = ($this->ValidateRow($this->RowNumber) && $Validation);
}
else if($this->CheckInsert())
{
$Validation = ($this->ValidateRow() && $Validation);
}
}
return (($this->Errors->Count() == 0) && $Validation);
}
//End Validate Method
//ValidateRow Method @69-0223FA80
function ValidateRow()
{
global $CCSLocales;
$this->selected->Validate();
$this->RowErrors = new clsErrors();
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "OnValidateRow", $this);
$errors = "";
$errors = ComposeStrings($errors, $this->selected->Errors->ToString());
$this->selected->Errors->Clear();
$errors = ComposeStrings($errors, $this->RowErrors->ToString());
$this->RowsErrors[$this->RowNumber] = $errors;
return $errors != "" ? 0 : 1;
}
//End ValidateRow Method
//CheckInsert Method @69-11CCC4D8
function CheckInsert()
{
$filed = false;
$filed = ($filed || (is_array($this->FormParameters["selected"][$this->RowNumber]) && count($this->FormParameters["selected"][$this->RowNumber])) || strlen($this->FormParameters["selected"][$this->RowNumber]));
return $filed;
}
//End CheckInsert Method
//CheckErrors Method @69-F5A3B433
function CheckErrors()
{
$errors = false;
$errors = ($errors || $this->Errors->Count());
$errors = ($errors || $this->DataSource->Errors->Count());
return $errors;
}
//End CheckErrors Method
//Operation Method @69-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 @69-1A9811EA
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["memberid"] = $this->CachedColumns["memberid"][$this->RowNumber];
$this->DataSource->CurrentRow = $this->RowNumber;
$this->selected->SetText($this->FormParameters["selected"][$this->RowNumber], $this->RowNumber);
if ($this->UpdatedRows >= $this->RowNumber) {
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 @69-DA79C520
function UpdateRow()
{
if(!$this->UpdateAllowed) return false;
$this->DataSource->selected->SetValue($this->selected->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
//FormScript Method @69-197AC823
function FormScript($TotalRows)
{
$script = "";
$script .= "\n<script language=\"JavaScript\" type=\"text/javascript\">\n<!--\n";
$script .= "var EditableGrid1Elements;\n";
$script .= "var EditableGrid1EmptyRows = 0;\n";
$script .= "var " . $this->ComponentName . "selectedID = 0;\n";
$script .= "\nfunction initEditableGrid1Elements() {\n";
$script .= "\tvar ED = document.forms[\"EditableGrid1\"];\n";
$script .= "\tEditableGrid1Elements = new Array (\n";
for($i = 1; $i <= $TotalRows; $i++) {
$script .= "\t\tnew Array(" . "ED.selected_" . $i . ")";
if($i != $TotalRows) $script .= ",\n";
}
$script .= ");\n";
$script .= "}\n";
$script .= "\n//-->\n</script>";
return $script;
}
//End FormScript Method
//SetFormState Method @69-D638CD61
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["memberid"][$RowNumber] = $piece;
$RowNumber++;
}
if(!$RowNumber) { $RowNumber = 1; }
for($i = 1; $i <= $this->EmptyRows; $i++) {
$this->CachedColumns["memberid"][$RowNumber] = "";
$RowNumber++;
}
}
}
//End SetFormState Method
//GetFormState Method @69-12433DFB
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["memberid"][$i]));
}
}
}
return $this->FormState;
}
//End GetFormState Method
//Show Method @69-0FC4FC35
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["memberid"] = $this->memberid->Visible;
$this->ControlsVisible["firstname"] = $this->firstname->Visible;
$this->ControlsVisible["middlename"] = $this->middlename->Visible;
$this->ControlsVisible["lastname"] = $this->lastname->Visible;
$this->ControlsVisible["AmountPaid"] = $this->AmountPaid->Visible;
$this->ControlsVisible["selected"] = $this->selected->Visible;
if ($is_next_record || ($EmptyRowsLeft && $this->InsertAllowed)) {
do {
$this->RowNumber++;
if($is_next_record) {
$NonEmptyRows++;
$this->DataSource->SetValues();
}
if (!($this->FormSubmitted) && $is_next_record) {
$this->CachedColumns["memberid"][$this->RowNumber] = $this->DataSource->CachedColumns["memberid"];
$this->selected->SetValue(true);
$this->memberid->SetValue($this->DataSource->memberid->GetValue());
$this->firstname->SetValue($this->DataSource->firstname->GetValue());
$this->middlename->SetValue($this->DataSource->middlename->GetValue());
$this->lastname->SetValue($this->DataSource->lastname->GetValue());
$this->AmountPaid->SetValue($this->DataSource->AmountPaid->GetValue());
} elseif ($this->FormSubmitted && $is_next_record) {
$this->memberid->SetText("");
$this->firstname->SetText("");
$this->middlename->SetText("");
$this->lastname->SetText("");
$this->AmountPaid->SetText("");
$this->memberid->SetValue($this->DataSource->memberid->GetValue());
$this->firstname->SetValue($this->DataSource->firstname->GetValue());
$this->middlename->SetValue($this->DataSource->middlename->GetValue());
$this->lastname->SetValue($this->DataSource->lastname->GetValue());
$this->AmountPaid->SetValue($this->DataSource->AmountPaid->GetValue());
$this->selected->SetText($this->FormParameters["selected"][$this->RowNumber], $this->RowNumber);
} elseif (!$this->FormSubmitted) {
$this->CachedColumns["memberid"][$this->RowNumber] = "";
$this->memberid->SetText("");
$this->firstname->SetText("");
$this->middlename->SetText("");
$this->lastname->SetText("");
$this->AmountPaid->SetText("");
$this->selected->SetValue(true);
} else {
$this->memberid->SetText("");
$this->firstname->SetText("");
$this->middlename->SetText("");
$this->lastname->SetText("");
$this->AmountPaid->SetText("");
$this->selected->SetText($this->FormParameters["selected"][$this->RowNumber], $this->RowNumber);
}
$this->Attributes->SetValue("rowNumber", $this->RowNumber);
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeShowRow", $this);
$this->Attributes->Show();
$this->memberid->Show($this->RowNumber);
$this->firstname->Show($this->RowNumber);
$this->middlename->Show($this->RowNumber);
$this->lastname->Show($this->RowNumber);
$this->AmountPaid->Show($this->RowNumber);
$this->selected->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["memberid"] == $this->CachedColumns["memberid"][$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->Sorter3->Show();
$this->Sorter1->Show();
$this->Sorter2->Show();
$this->Sorter4->Show();
$this->Sorter5->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("&", "&", $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("&", "&", $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 EditableGrid1 Class @69-FCB6E20C
class clsEditableGrid1DataSource extends clsDBCoopWorksConn { //EditableGrid1DataSource Class @69-52A1E72C
//DataSource Variables @69-0196EFC7
var $Parent = "";
var $CCSEvents = "";
var $CCSEventResult;
var $ErrorBlock;
var $CmdExecution;
var $UpdateParameters;
var $CountSQL;
var $AllParametersSet;
var $CachedColumns;
var $CurrentRow;
// Datasource fields
var $memberid;
var $firstname;
var $middlename;
var $lastname;
var $AmountPaid;
var $selected;
//End DataSource Variables
//DataSourceClass_Initialize Event @69-EB4C319B
function clsEditableGrid1DataSource(& $Parent)
{
$this->Parent = & $Parent;
$this->ErrorBlock = "EditableGrid EditableGrid1/Error";
$this->Initialize();
$this->memberid = new clsField("memberid", ccsFloat, "");
$this->firstname = new clsField("firstname", ccsText, "");
$this->middlename = new clsField("middlename", ccsText, "");
$this->lastname = new clsField("lastname", ccsText, "");
$this->AmountPaid = new clsField("AmountPaid", ccsFloat, "");
$this->selected = new clsField("selected", ccsBoolean, $this->BooleanFormat);
}
//End DataSourceClass_Initialize Event
//SetOrder Method @69-2420E412
function SetOrder($SorterName, $SorterDirection)
{
$this->Order = CCGetOrder($this->Order, $SorterName, $SorterDirection,
array("Sorter3" => array("memberid", ""),
"Sorter1" => array("firstname", ""),
"Sorter2" => array("middlename", ""),
"Sorter4" => array("lastname", ""),
"Sorter5" => array("AmountPaid", "")));
}
//End SetOrder Method
//Prepare Method @69-5632A397
function Prepare()
{
global $CCSLocales;
global $DefaultDateFormat;
$this->AllParametersSet = true;
}
//End Prepare Method
//Open Method @69-BAFDC21D
function Open()
{
$this->cp["month1"] = new clsSQLParameter("urlxmonth", ccsInteger, "", "", CCGetFromGet("xmonth", NULL), "", false, $this->ErrorBlock);
$this->cp["year2"] = new clsSQLParameter("urlxyear", ccsInteger, "", "", CCGetFromGet("xyear", NULL), "", false, $this->ErrorBlock);
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeBuildSelect", $this->Parent);
$this->SQL = "CALL CA_fee_processing (" . $this->ToSQL($this->cp["month1"]->GetDBValue(), $this->cp["month1"]->DataType) . ", "
. $this->ToSQL($this->cp["year2"]->GetDBValue(), $this->cp["year2"]->DataType) . ");";
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeExecuteSelect", $this->Parent);
$this->query($this->SQL);
$this->RecordsCount = "CCS not counted";
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterExecuteSelect", $this->Parent);
if ($this->Errors->count()) return false;
$this->MoveToPage($this->AbsolutePage);
}
//End Open Method
//SetValues Method @69-67CF2292
function SetValues()
{
$this->CachedColumns["memberid"] = $this->f("memberid");
$this->memberid->SetDBValue(trim($this->f("memberid")));
$this->firstname->SetDBValue($this->f("firstname"));
$this->middlename->SetDBValue($this->f("middlename"));
$this->lastname->SetDBValue($this->f("lastname"));
$this->AmountPaid->SetDBValue(trim($this->f("AmountPaid")));
}
//End SetValues Method
//Update Method @69-A954F21E
function Update()
{
global $CCSLocales;
global $DefaultDateFormat;
$this->CmdExecution = true;
$this->cp["xtrandate"] = new clsSQLParameter("urlTranDate", ccsDate, $DefaultDateFormat, $this->DateFormat, CCGetFromGet("TranDate", NULL), "", false, $this->ErrorBlock);
$this->cp["xmonth"] = new clsSQLParameter("urlxmonth", ccsFloat, "", "", CCGetFromGet("xmonth", NULL), "", false, $this->ErrorBlock);
$this->cp["xyear"] = new clsSQLParameter("urlxyear", ccsInteger, "", "", CCGetFromGet("xyear", NULL), "", false, $this->ErrorBlock);
$this->cp["selected"] = new clsSQLParameter("ctrlselected", ccsInteger, "", "", $this->selected->GetValue(true), "", false, $this->ErrorBlock);
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeBuildUpdate", $this->Parent);
if (!is_null($this->cp["xtrandate"]->GetValue()) and !strlen($this->cp["xtrandate"]->GetText()) and !is_bool($this->cp["xtrandate"]->GetValue()))
$this->cp["xtrandate"]->SetText(CCGetFromGet("TranDate", NULL));
if (!is_null($this->cp["xmonth"]->GetValue()) and !strlen($this->cp["xmonth"]->GetText()) and !is_bool($this->cp["xmonth"]->GetValue()))
$this->cp["xmonth"]->SetText(CCGetFromGet("xmonth", NULL));
if (!is_null($this->cp["xyear"]->GetValue()) and !strlen($this->cp["xyear"]->GetText()) and !is_bool($this->cp["xyear"]->GetValue()))
$this->cp["xyear"]->SetText(CCGetFromGet("xyear", NULL));
if (!is_null($this->cp["selected"]->GetValue()) and !strlen($this->cp["selected"]->GetText()) and !is_bool($this->cp["selected"]->GetValue()))
$this->cp["selected"]->SetValue($this->selected->GetValue(true));
$this->SQL = "CALL CA_CashPayment_Fee_Update (" . $this->ToSQL($this->cp["xtrandate"]->GetDBValue(), $this->cp["xtrandate"]->DataType) . ", "
. $this->ToSQL($this->cp["xmonth"]->GetDBValue(), $this->cp["xmonth"]->DataType) . ", "
. $this->ToSQL($this->cp["xyear"]->GetDBValue(), $this->cp["xyear"]->DataType) . ", "
. $this->ToSQL($this->cp["selected"]->GetDBValue(), $this->cp["selected"]->DataType) . ");";
$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);
}
}
//End Update Method
} //End EditableGrid1DataSource Class @69-FCB6E20C
//Initialize Page @1-DF894FAF
// Variables
$FileName = "";
$Redirect = "";
$Tpl = "";
$TemplateFileName = "";
$BlockToParse = "";
$ComponentName = "";
$Attributes = "";
// Events;
$CCSEvents = "";
$CCSEventResult = "";
$FileName = FileName;
$Redirect = "";
$TemplateFileName = "CA_CashPayment_Fee.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-B1296759
$DBCoopWorksConn = new clsDBCoopWorksConn();
$MainPage->Connections["CoopWorksConn"] = & $DBCoopWorksConn;
$Attributes = new clsAttributes("page:");
$MainPage->Attributes = & $Attributes;
// Controls
$CashFees = & new clsRecordCashFees("", $MainPage);
$EditableGrid1 = & new clsEditableGridEditableGrid1("", $MainPage);
$MainPage->CashFees = & $CashFees;
$MainPage->EditableGrid1 = & $EditableGrid1;
$CashFees->Initialize();
$EditableGrid1->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-19780B88
$CashFees->Operation();
$EditableGrid1->Operation();
//End Execute Components
//Go to destination page @1-0AEC3ECF
if($Redirect)
{
$CCSEventResult = CCGetEvent($CCSEvents, "BeforeUnload", $MainPage);
$DBCoopWorksConn->close();
header("Location: " . $Redirect);
unset($CashFees);
unset($EditableGrid1);
unset($Tpl);
exit;
}
//End Go to destination page
//Show Page @1-7E593443
$CashFees->Show();
$EditableGrid1->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-850F514E
$CCSEventResult = CCGetEvent($CCSEvents, "BeforeUnload", $MainPage);
$DBCoopWorksConn->close();
unset($CashFees);
unset($EditableGrid1);
unset($Tpl);
//End Unload Page
?>