function Show() { $Tpl = CCGetTemplate($this); 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["code"] = $this->code->Visible; $this->ControlsVisible["company_name"] = $this->company_name->Visible; $this->ControlsVisible["description"] = $this->description->Visible; $this->ControlsVisible["creation_date"] = $this->creation_date->Visible; $this->ControlsVisible["created_by"] = $this->created_by->Visible; $this->ControlsVisible["updated_date"] = $this->updated_date->Visible; $this->ControlsVisible["updated_by"] = $this->updated_by->Visible; $this->ControlsVisible["CheckBox_Delete_Panel"] = $this->CheckBox_Delete_Panel->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; $this->CheckBox_Delete_Panel->Visible = false; } if (!$this->FormSubmitted && $is_next_record) { $this->CheckBox_Delete->SetValue(false); $this->code->SetValue($this->DataSource->code->GetValue()); $this->company_name->SetValue($this->DataSource->company_name->GetValue()); $this->description->SetValue($this->DataSource->description->GetValue()); $this->creation_date->SetValue($this->DataSource->creation_date->GetValue()); $this->created_by->SetValue($this->DataSource->created_by->GetValue()); $this->updated_date->SetValue($this->DataSource->updated_date->GetValue()); $this->updated_by->SetValue($this->DataSource->updated_by->GetValue()); } elseif ($this->FormSubmitted && $is_next_record) { $this->code->SetText($this->FormParameters["code"][$this->RowNumber], $this->RowNumber); $this->company_name->SetText($this->FormParameters["company_name"][$this->RowNumber], $this->RowNumber); $this->description->SetText($this->FormParameters["description"][$this->RowNumber], $this->RowNumber); $this->creation_date->SetText($this->FormParameters["creation_date"][$this->RowNumber], $this->RowNumber); $this->created_by->SetText($this->FormParameters["created_by"][$this->RowNumber], $this->RowNumber); $this->updated_date->SetText($this->FormParameters["updated_date"][$this->RowNumber], $this->RowNumber); $this->updated_by->SetText($this->FormParameters["updated_by"][$this->RowNumber], $this->RowNumber); $this->CheckBox_Delete->SetText($this->FormParameters["CheckBox_Delete"][$this->RowNumber], $this->RowNumber); } elseif (!$this->FormSubmitted) { $this->code->SetText(""); $this->company_name->SetText(""); $this->description->SetText(""); $this->creation_date->SetValue(time()); $this->created_by->SetText(ccGetSession("UserLogin")); $this->updated_date->SetValue(time()); $this->updated_by->SetText(ccGetSession("UserLogin")); } else { $this->code->SetText($this->FormParameters["code"][$this->RowNumber], $this->RowNumber); $this->company_name->SetText($this->FormParameters["company_name"][$this->RowNumber], $this->RowNumber); $this->description->SetText($this->FormParameters["description"][$this->RowNumber], $this->RowNumber); $this->creation_date->SetText($this->FormParameters["creation_date"][$this->RowNumber], $this->RowNumber); $this->created_by->SetText($this->FormParameters["created_by"][$this->RowNumber], $this->RowNumber); $this->updated_date->SetText($this->FormParameters["updated_date"][$this->RowNumber], $this->RowNumber); $this->updated_by->SetText($this->FormParameters["updated_by"][$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->code->Show($this->RowNumber); $this->company_name->Show($this->RowNumber); $this->description->Show($this->RowNumber); $this->creation_date->Show($this->RowNumber); $this->created_by->Show($this->RowNumber); $this->updated_date->Show($this->RowNumber); $this->updated_by->Show($this->RowNumber); $this->CheckBox_Delete_Panel->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->ReadAllowed && $this->DataSource->next_record() && $this->RowNumber < $this->UpdatedRows; } 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->PageNumber == 1 || $this->Navigator->PageSize == "") { $this->Navigator->Visible = false; } $this->Navigator->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("&", "&", $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(); }
function Insert() { global $CCSLocales; global $DefaultDateFormat; $this->CmdExecution = true; $this->cp["code"] = new clsSQLParameter("ctrlcode", ccsText, "", "", $this->code->GetValue(true), "", false, $this->ErrorBlock); $this->cp["company_name"] = new clsSQLParameter("ctrlcompany_name", ccsText, "", "", $this->company_name->GetValue(true), "", false, $this->ErrorBlock); $this->cp["p_client_id"] = new clsSQLParameter("urlp_client_id", ccsText, "", "", CCGetFromGet("p_client_id", NULL), "", false, $this->ErrorBlock); $this->cp["description"] = new clsSQLParameter("ctrldescription", ccsText, "", "", $this->description->GetValue(true), "", false, $this->ErrorBlock); $this->cp["created_by"] = new clsSQLParameter("expr95", ccsText, "", "", ccGetSession("UserLogin"), "", false, $this->ErrorBlock); $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeBuildInsert", $this->Parent); if (!is_null($this->cp["code"]->GetValue()) and !strlen($this->cp["code"]->GetText()) and !is_bool($this->cp["code"]->GetValue())) { $this->cp["code"]->SetValue($this->code->GetValue(true)); } if (!is_null($this->cp["company_name"]->GetValue()) and !strlen($this->cp["company_name"]->GetText()) and !is_bool($this->cp["company_name"]->GetValue())) { $this->cp["company_name"]->SetValue($this->company_name->GetValue(true)); } if (!is_null($this->cp["p_client_id"]->GetValue()) and !strlen($this->cp["p_client_id"]->GetText()) and !is_bool($this->cp["p_client_id"]->GetValue())) { $this->cp["p_client_id"]->SetText(CCGetFromGet("p_client_id", NULL)); } if (!is_null($this->cp["description"]->GetValue()) and !strlen($this->cp["description"]->GetText()) and !is_bool($this->cp["description"]->GetValue())) { $this->cp["description"]->SetValue($this->description->GetValue(true)); } if (!is_null($this->cp["created_by"]->GetValue()) and !strlen($this->cp["created_by"]->GetText()) and !is_bool($this->cp["created_by"]->GetValue())) { $this->cp["created_by"]->SetValue(ccGetSession("UserLogin")); } $this->SQL = "insert into p_company_client\n" . "(p_company_client_id,\n" . " code,\n" . " company_name,\n" . " p_client_id,\n" . " description,\n" . " creation_date,\n" . " created_by,\n" . " updated_date,\n" . " updated_by\n" . ")\n" . "values\n" . "(\n" . " generate_id('chumanis','p_company_client','p_company_client_id'),\n" . " '" . $this->SQLValue($this->cp["code"]->GetDBValue(), ccsText) . "',\n" . " '" . $this->SQLValue($this->cp["company_name"]->GetDBValue(), ccsText) . "',\n" . " '" . $this->SQLValue($this->cp["p_client_id"]->GetDBValue(), ccsText) . "',\n" . " '" . $this->SQLValue($this->cp["description"]->GetDBValue(), ccsText) . "',\n" . " current_date,\n" . " '" . $this->SQLValue($this->cp["created_by"]->GetDBValue(), ccsText) . "',\n" . "current_date,\n" . " '" . $this->SQLValue($this->cp["created_by"]->GetDBValue(), ccsText) . "'\n" . ")"; $this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeExecuteInsert", $this->Parent); if ($this->Errors->Count() == 0 && $this->CmdExecution) { $this->query($this->SQL); $this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterExecuteInsert", $this->Parent); } }