Viewing file: poslanici_maint.php (25.35 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
//Include Common Files @1-5471E0F2
define("RelativePath", ".");
include(RelativePath . "/Common.php");
include(RelativePath . "/Template.php");
include(RelativePath . "/Sorter.php");
include(RelativePath . "/Navigator.php");
//End Include Common Files
//Include Page implementation @20-39DC296A
include_once("./Header.php");
//End Include Page implementation
Class clsRecordposlanici { //poslanici Class @2-F6EAFFD9
//Variables @2-4A82E0A3
// Public variables
var $ComponentName;
var $HTMLFormAction;
var $PressedButton;
var $Errors;
var $ErrorBlock;
var $FormSubmitted;
var $FormEnctype;
var $Visible;
var $Recordset;
var $CCSEvents = "";
var $CCSEventResult;
var $InsertAllowed;
var $UpdateAllowed;
var $DeleteAllowed;
var $ds;
var $EditMode;
var $ValidatingControls;
var $Controls;
// Class variables
//End Variables
//Class_Initialize Event @2-EA88D09B
function clsRecordposlanici()
{
global $FileName;
$this->Visible = true;
$this->Errors = new clsErrors();
$this->ErrorBlock = "Record poslanici/Error";
$this->ds = new clsposlaniciDataSource();
$this->InsertAllowed = true;
$this->UpdateAllowed = true;
$this->DeleteAllowed = true;
if($this->Visible)
{
$this->ComponentName = "poslanici";
$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->emp_name = new clsControl(ccsTextBox, "emp_name", "Emp Name", ccsText, "", CCGetRequestParam("emp_name", $Method));
$this->title = new clsControl(ccsTextBox, "title", "Title", ccsText, "", CCGetRequestParam("title", $Method));
$this->group_id = new clsControl(ccsTextBox, "group_id", "Group Id", ccsInteger, "", CCGetRequestParam("group_id", $Method));
$this->department_id = new clsControl(ccsTextBox, "department_id", "Department Id", ccsInteger, "", CCGetRequestParam("department_id", $Method));
$this->phone_home = new clsControl(ccsTextBox, "phone_home", "Phone Home", ccsText, "", CCGetRequestParam("phone_home", $Method));
$this->phone_work = new clsControl(ccsTextArea, "phone_work", "Phone Work", ccsMemo, "", CCGetRequestParam("phone_work", $Method));
$this->fax = new clsControl(ccsTextBox, "fax", "Fax", ccsText, "", CCGetRequestParam("fax", $Method));
$this->email = new clsControl(ccsTextBox, "email", "Email", ccsText, "", CCGetRequestParam("email", $Method));
$this->city = new clsControl(ccsTextBox, "city", "City", ccsText, "", CCGetRequestParam("city", $Method));
$this->zip = new clsControl(ccsTextBox, "zip", "Zip", ccsText, "", CCGetRequestParam("zip", $Method));
$this->address = new clsControl(ccsTextBox, "address", "Address", ccsText, "", CCGetRequestParam("address", $Method));
$this->picture = new clsControl(ccsTextBox, "picture", "Picture", ccsText, "", CCGetRequestParam("picture", $Method));
$this->Button_Insert = new clsButton("Button_Insert");
$this->Button_Update = new clsButton("Button_Update");
$this->Button_Delete = new clsButton("Button_Delete");
}
}
//End Class_Initialize Event
//Initialize Method @2-42165130
function Initialize()
{
if(!$this->Visible)
return;
$this->ds->Parameters["urlemp_id"] = CCGetFromGet("emp_id", "");
}
//End Initialize Method
//Validate Method @2-1B2A24FE
function Validate()
{
$Validation = true;
$Where = "";
$Validation = ($this->emp_name->Validate() && $Validation);
$Validation = ($this->title->Validate() && $Validation);
$Validation = ($this->group_id->Validate() && $Validation);
$Validation = ($this->department_id->Validate() && $Validation);
$Validation = ($this->phone_home->Validate() && $Validation);
$Validation = ($this->phone_work->Validate() && $Validation);
$Validation = ($this->fax->Validate() && $Validation);
$Validation = ($this->email->Validate() && $Validation);
$Validation = ($this->city->Validate() && $Validation);
$Validation = ($this->zip->Validate() && $Validation);
$Validation = ($this->address->Validate() && $Validation);
$Validation = ($this->picture->Validate() && $Validation);
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "OnValidate");
return (($this->Errors->Count() == 0) && $Validation);
}
//End Validate Method
//CheckErrors Method @2-2D40EE63
function CheckErrors()
{
$errors = false;
$errors = ($errors || $this->emp_name->Errors->Count());
$errors = ($errors || $this->title->Errors->Count());
$errors = ($errors || $this->group_id->Errors->Count());
$errors = ($errors || $this->department_id->Errors->Count());
$errors = ($errors || $this->phone_home->Errors->Count());
$errors = ($errors || $this->phone_work->Errors->Count());
$errors = ($errors || $this->fax->Errors->Count());
$errors = ($errors || $this->email->Errors->Count());
$errors = ($errors || $this->city->Errors->Count());
$errors = ($errors || $this->zip->Errors->Count());
$errors = ($errors || $this->address->Errors->Count());
$errors = ($errors || $this->picture->Errors->Count());
$errors = ($errors || $this->Errors->Count());
$errors = ($errors || $this->ds->Errors->Count());
return $errors;
}
//End CheckErrors Method
//Operation Method @2-10E713FC
function Operation()
{
if(!$this->Visible)
return;
global $Redirect;
global $FileName;
$this->ds->Prepare();
$this->EditMode = $this->ds->AllParametersSet;
if(!$this->FormSubmitted)
return;
if($this->FormSubmitted) {
$this->PressedButton = $this->EditMode ? "Button_Update" : "Button_Insert";
if(strlen(CCGetParam("Button_Insert", ""))) {
$this->PressedButton = "Button_Insert";
} else if(strlen(CCGetParam("Button_Update", ""))) {
$this->PressedButton = "Button_Update";
} else if(strlen(CCGetParam("Button_Delete", ""))) {
$this->PressedButton = "Button_Delete";
}
}
$Redirect = "poslanici_list.php" . "?" . CCGetQueryString("QueryString", Array("ccsForm"));
if($this->PressedButton == "Button_Delete") {
if(!CCGetEvent($this->Button_Delete->CCSEvents, "OnClick") || !$this->DeleteRow()) {
$Redirect = "";
}
} else if($this->Validate()) {
if($this->PressedButton == "Button_Insert") {
if(!CCGetEvent($this->Button_Insert->CCSEvents, "OnClick") || !$this->InsertRow()) {
$Redirect = "";
}
} else if($this->PressedButton == "Button_Update") {
if(!CCGetEvent($this->Button_Update->CCSEvents, "OnClick") || !$this->UpdateRow()) {
$Redirect = "";
}
}
} else {
$Redirect = "";
}
}
//End Operation Method
//InsertRow Method @2-D45B30FC
function InsertRow()
{
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeInsert");
if(!$this->InsertAllowed) return false;
$this->ds->emp_name->SetValue($this->emp_name->GetValue());
$this->ds->title->SetValue($this->title->GetValue());
$this->ds->group_id->SetValue($this->group_id->GetValue());
$this->ds->department_id->SetValue($this->department_id->GetValue());
$this->ds->phone_home->SetValue($this->phone_home->GetValue());
$this->ds->phone_work->SetValue($this->phone_work->GetValue());
$this->ds->fax->SetValue($this->fax->GetValue());
$this->ds->email->SetValue($this->email->GetValue());
$this->ds->city->SetValue($this->city->GetValue());
$this->ds->zip->SetValue($this->zip->GetValue());
$this->ds->address->SetValue($this->address->GetValue());
$this->ds->picture->SetValue($this->picture->GetValue());
$this->ds->Insert();
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterInsert");
if($this->ds->Errors->Count() > 0) {
echo "Error in Record " . $this->ComponentName . " / Insert Operation";
$this->ds->Errors->Clear();
$this->Errors->AddError("Database command error.");
}
return (!$this->CheckErrors());
}
//End InsertRow Method
//UpdateRow Method @2-AD8BD8A2
function UpdateRow()
{
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeUpdate");
if(!$this->UpdateAllowed) return false;
$this->ds->emp_name->SetValue($this->emp_name->GetValue());
$this->ds->title->SetValue($this->title->GetValue());
$this->ds->group_id->SetValue($this->group_id->GetValue());
$this->ds->department_id->SetValue($this->department_id->GetValue());
$this->ds->phone_home->SetValue($this->phone_home->GetValue());
$this->ds->phone_work->SetValue($this->phone_work->GetValue());
$this->ds->fax->SetValue($this->fax->GetValue());
$this->ds->email->SetValue($this->email->GetValue());
$this->ds->city->SetValue($this->city->GetValue());
$this->ds->zip->SetValue($this->zip->GetValue());
$this->ds->address->SetValue($this->address->GetValue());
$this->ds->picture->SetValue($this->picture->GetValue());
$this->ds->Update();
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterUpdate");
if($this->ds->Errors->Count() > 0) {
echo "Error in Record " . $this->ComponentName . " / Update Operation";
$this->ds->Errors->Clear();
$this->Errors->AddError("Database command error.");
}
return (!$this->CheckErrors());
}
//End UpdateRow Method
//DeleteRow Method @2-EA88835F
function DeleteRow()
{
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeDelete");
if(!$this->DeleteAllowed) return false;
$this->ds->Delete();
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterDelete");
if($this->ds->Errors->Count() > 0) {
echo "Error in Record " . ComponentName . " / Delete Operation";
$this->ds->Errors->Clear();
$this->Errors->AddError("Database command error.");
}
return (!$this->CheckErrors());
}
//End DeleteRow Method
//Show Method @2-FAD58435
function Show()
{
global $Tpl;
global $FileName;
$Error = "";
if(!$this->Visible)
return;
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeSelect");
$this->ds->open();
$RecordBlock = "Record " . $this->ComponentName;
$ParentPath = $Tpl->block_path;
$Tpl->block_path = $ParentPath . "/" . $RecordBlock;
if($this->EditMode)
{
if($this->Errors->Count() == 0)
{
if($this->ds->Errors->Count() > 0)
{
echo "Error in Record poslanici";
}
else if($this->ds->next_record())
{
$this->ds->SetValues();
if(!$this->FormSubmitted)
{
$this->emp_name->SetValue($this->ds->emp_name->GetValue());
$this->title->SetValue($this->ds->title->GetValue());
$this->group_id->SetValue($this->ds->group_id->GetValue());
$this->department_id->SetValue($this->ds->department_id->GetValue());
$this->phone_home->SetValue($this->ds->phone_home->GetValue());
$this->phone_work->SetValue($this->ds->phone_work->GetValue());
$this->fax->SetValue($this->ds->fax->GetValue());
$this->email->SetValue($this->ds->email->GetValue());
$this->city->SetValue($this->ds->city->GetValue());
$this->zip->SetValue($this->ds->zip->GetValue());
$this->address->SetValue($this->ds->address->GetValue());
$this->picture->SetValue($this->ds->picture->GetValue());
}
}
else
{
$this->EditMode = false;
}
}
}
if(!$this->FormSubmitted)
{
}
if($this->FormSubmitted || $this->CheckErrors()) {
$Error .= $this->emp_name->Errors->ToString();
$Error .= $this->title->Errors->ToString();
$Error .= $this->group_id->Errors->ToString();
$Error .= $this->department_id->Errors->ToString();
$Error .= $this->phone_home->Errors->ToString();
$Error .= $this->phone_work->Errors->ToString();
$Error .= $this->fax->Errors->ToString();
$Error .= $this->email->Errors->ToString();
$Error .= $this->city->Errors->ToString();
$Error .= $this->zip->Errors->ToString();
$Error .= $this->address->Errors->ToString();
$Error .= $this->picture->Errors->ToString();
$Error .= $this->Errors->ToString();
$Error .= $this->ds->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", $this->HTMLFormAction);
$Tpl->SetVar("HTMLFormName", $this->ComponentName);
$Tpl->SetVar("HTMLFormEnctype", $this->FormEnctype);
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeShow");
if(!$this->Visible) {
$Tpl->block_path = $ParentPath;
return;
}
$this->Button_Insert->Visible = !$this->EditMode && $this->InsertAllowed;
$this->Button_Update->Visible = $this->EditMode && $this->UpdateAllowed;
$this->Button_Delete->Visible = $this->EditMode && $this->DeleteAllowed;
$this->emp_name->Show();
$this->title->Show();
$this->group_id->Show();
$this->department_id->Show();
$this->phone_home->Show();
$this->phone_work->Show();
$this->fax->Show();
$this->email->Show();
$this->city->Show();
$this->zip->Show();
$this->address->Show();
$this->picture->Show();
$this->Button_Insert->Show();
$this->Button_Update->Show();
$this->Button_Delete->Show();
$Tpl->parse();
$Tpl->block_path = $ParentPath;
$this->ds->close();
}
//End Show Method
} //End poslanici Class @2-FCB6E20C
class clsposlaniciDataSource extends clsDBConnection1 { //poslaniciDataSource Class @2-31BC14E9
//DataSource Variables @2-91342501
var $CCSEvents = "";
var $CCSEventResult;
var $ErrorBlock;
var $InsertParameters;
var $UpdateParameters;
var $DeleteParameters;
var $wp;
var $AllParametersSet;
// Datasource fields
var $emp_name;
var $title;
var $group_id;
var $department_id;
var $phone_home;
var $phone_work;
var $fax;
var $email;
var $city;
var $zip;
var $address;
var $picture;
//End DataSource Variables
//Class_Initialize Event @2-52E389AD
function clsposlaniciDataSource()
{
$this->ErrorBlock = "Record poslanici/Error";
$this->Initialize();
$this->emp_name = new clsField("emp_name", ccsText, "");
$this->title = new clsField("title", ccsText, "");
$this->group_id = new clsField("group_id", ccsInteger, "");
$this->department_id = new clsField("department_id", ccsInteger, "");
$this->phone_home = new clsField("phone_home", ccsText, "");
$this->phone_work = new clsField("phone_work", ccsMemo, "");
$this->fax = new clsField("fax", ccsText, "");
$this->email = new clsField("email", ccsText, "");
$this->city = new clsField("city", ccsText, "");
$this->zip = new clsField("zip", ccsText, "");
$this->address = new clsField("address", ccsText, "");
$this->picture = new clsField("picture", ccsText, "");
}
//End Class_Initialize Event
//Prepare Method @2-B9EF2B06
function Prepare()
{
$this->wp = new clsSQLParameters($this->ErrorBlock);
$this->wp->AddParameter("1", "urlemp_id", ccsInteger, "", "", $this->Parameters["urlemp_id"], "", false);
$this->AllParametersSet = $this->wp->AllParamsSet();
$this->wp->Criterion[1] = $this->wp->Operation(opEqual, "emp_id", $this->wp->GetDBValue("1"), $this->ToSQL($this->wp->GetDBValue("1"), ccsInteger),false);
$this->Where = $this->wp->Criterion[1];
}
//End Prepare Method
//Open Method @2-54F8D4FD
function Open()
{
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeBuildSelect");
$this->SQL = "SELECT * " .
"FROM poslanici";
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeExecuteSelect");
$this->query(CCBuildSQL($this->SQL, $this->Where, $this->Order));
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterExecuteSelect");
$this->MoveToPage($this->AbsolutePage);
}
//End Open Method
//SetValues Method @2-99B95205
function SetValues()
{
$this->emp_name->SetDBValue($this->f("emp_name"));
$this->title->SetDBValue($this->f("title"));
$this->group_id->SetDBValue(trim($this->f("group_id")));
$this->department_id->SetDBValue(trim($this->f("department_id")));
$this->phone_home->SetDBValue($this->f("phone_home"));
$this->phone_work->SetDBValue($this->f("phone_work"));
$this->fax->SetDBValue($this->f("fax"));
$this->email->SetDBValue($this->f("email"));
$this->city->SetDBValue($this->f("city"));
$this->zip->SetDBValue($this->f("zip"));
$this->address->SetDBValue($this->f("address"));
$this->picture->SetDBValue($this->f("picture"));
}
//End SetValues Method
//Insert Method @2-DEF01E68
function Insert()
{
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeBuildInsert");
$this->SQL = "INSERT INTO poslanici ("
. "emp_name, "
. "title, "
. "group_id, "
. "department_id, "
. "phone_home, "
. "phone_work, "
. "fax, "
. "email, "
. "city, "
. "zip, "
. "address, "
. "picture"
. ") VALUES ("
. $this->ToSQL($this->emp_name->GetDBValue(), $this->emp_name->DataType) . ", "
. $this->ToSQL($this->title->GetDBValue(), $this->title->DataType) . ", "
. $this->ToSQL($this->group_id->GetDBValue(), $this->group_id->DataType) . ", "
. $this->ToSQL($this->department_id->GetDBValue(), $this->department_id->DataType) . ", "
. $this->ToSQL($this->phone_home->GetDBValue(), $this->phone_home->DataType) . ", "
. $this->ToSQL($this->phone_work->GetDBValue(), $this->phone_work->DataType) . ", "
. $this->ToSQL($this->fax->GetDBValue(), $this->fax->DataType) . ", "
. $this->ToSQL($this->email->GetDBValue(), $this->email->DataType) . ", "
. $this->ToSQL($this->city->GetDBValue(), $this->city->DataType) . ", "
. $this->ToSQL($this->zip->GetDBValue(), $this->zip->DataType) . ", "
. $this->ToSQL($this->address->GetDBValue(), $this->address->DataType) . ", "
. $this->ToSQL($this->picture->GetDBValue(), $this->picture->DataType)
. ")";
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeExecuteInsert");
$this->query($this->SQL);
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterExecuteInsert");
if($this->Errors->Count() > 0)
$this->Errors->AddError($this->Errors->ToString());
$this->close();
}
//End Insert Method
//Update Method @2-D488B61F
function Update()
{
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeBuildUpdate");
$this->SQL = "UPDATE poslanici SET "
. "emp_name=" . $this->ToSQL($this->emp_name->GetDBValue(), $this->emp_name->DataType) . ", "
. "title=" . $this->ToSQL($this->title->GetDBValue(), $this->title->DataType) . ", "
. "group_id=" . $this->ToSQL($this->group_id->GetDBValue(), $this->group_id->DataType) . ", "
. "department_id=" . $this->ToSQL($this->department_id->GetDBValue(), $this->department_id->DataType) . ", "
. "phone_home=" . $this->ToSQL($this->phone_home->GetDBValue(), $this->phone_home->DataType) . ", "
. "phone_work=" . $this->ToSQL($this->phone_work->GetDBValue(), $this->phone_work->DataType) . ", "
. "fax=" . $this->ToSQL($this->fax->GetDBValue(), $this->fax->DataType) . ", "
. "email=" . $this->ToSQL($this->email->GetDBValue(), $this->email->DataType) . ", "
. "city=" . $this->ToSQL($this->city->GetDBValue(), $this->city->DataType) . ", "
. "zip=" . $this->ToSQL($this->zip->GetDBValue(), $this->zip->DataType) . ", "
. "address=" . $this->ToSQL($this->address->GetDBValue(), $this->address->DataType) . ", "
. "picture=" . $this->ToSQL($this->picture->GetDBValue(), $this->picture->DataType);
$this->SQL = CCBuildSQL($this->SQL, $this->Where, "");
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeExecuteUpdate");
$this->query($this->SQL);
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterExecuteUpdate");
if($this->Errors->Count() > 0)
$this->Errors->AddError($this->Errors->ToString());
$this->close();
}
//End Update Method
//Delete Method @2-BBEF7951
function Delete()
{
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeBuildDelete");
$this->SQL = "DELETE FROM poslanici";
$this->SQL = CCBuildSQL($this->SQL, $this->Where, "");
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeExecuteDelete");
$this->query($this->SQL);
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterExecuteDelete");
if($this->Errors->Count() > 0)
$this->Errors->AddError($this->Errors->ToString());
$this->close();
}
//End Delete Method
} //End poslaniciDataSource Class @2-FCB6E20C
//Include Page implementation @21-5CD56755
include_once("./Footer.php");
//End Include Page implementation
//Initialize Page @1-8051B154
// Variables
$FileName = "";
$Redirect = "";
$Tpl = "";
$TemplateFileName = "";
$BlockToParse = "";
$ComponentName = "";
// Events;
$CCSEvents = "";
$CCSEventResult = "";
$FileName = "poslanici_maint.php";
$Redirect = "";
$TemplateFileName = "poslanici_maint.html";
$BlockToParse = "main";
$PathToRoot = "./";
//End Initialize Page
//Authenticate User @1-DC94A87D
CCSecurityRedirect("1", "");
//End Authenticate User
//Initialize Objects @1-8333ED02
$DBConnection1 = new clsDBConnection1();
// Controls
$Header = new clsHeader();
$Header->BindEvents();
$Header->TemplatePath = "./";
$Header->Initialize();
$poslanici = new clsRecordposlanici();
$Footer = new clsFooter();
$Footer->BindEvents();
$Footer->TemplatePath = "./";
$Footer->Initialize();
$poslanici->Initialize();
$CCSEventResult = CCGetEvent($CCSEvents, "AfterInitialize");
//End Initialize Objects
//Initialize HTML Template @1-A0111C9D
$CCSEventResult = CCGetEvent($CCSEvents, "OnInitializeView");
$Tpl = new clsTemplate();
$Tpl->LoadTemplate(TemplatePath . $TemplateFileName, "main");
$CCSEventResult = CCGetEvent($CCSEvents, "BeforeShow");
//End Initialize HTML Template
//Execute Components @1-0931069A
$Header->Operations();
$poslanici->Operation();
$Footer->Operations();
//End Execute Components
//Go to destination page @1-6F9FD7CC
if($Redirect)
{
$CCSEventResult = CCGetEvent($CCSEvents, "BeforeUnload");
$DBConnection1->close();
header("Location: " . $Redirect);
exit;
}
//End Go to destination page
//Show Page @1-7E70C80F
$Header->Show("Header");
$poslanici->Show();
$Footer->Show("Footer");
$Tpl->PParse("main", false);
//End Show Page
//Unload Page @1-A4D34ABE
$CCSEventResult = CCGetEvent($CCSEvents, "BeforeUnload");
$DBConnection1->close();
unset($Tpl);
//End Unload Page
?>
|