Viewing file: clsDepartment.php (5.45 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
//--Class department--------------------------
//--PK of department ::
// 1. departmentId
class Department extends clsDB{
var $result;
var $deptId;
var $deptName;
var $deptDesc;
var $deptCode;
var $deptParent;
var $deptYear;
var $deptDate;
var $deptRef;
var $pbriId;
var $depttypeId;
var $deptParentId;
var $deptLevel;
var $deptGroup;
function Department(&$c){
$this->c=$c->c;
$this->DB=$c->db;
}
function Save(){
if ($this->status==1){
//uncomment a line below if your table use ID as running number
$this->departmentId=$this->GetNextCode();
$sql = "insert into Department values(
'$this->deptId',
'$this->deptName',
'$this->deptDesc',
'$this->deptCode',
'$this->deptParent',
'$this->deptYear',
'$this->deptDate',
'$this->deptRef',
'$this->pbriId',
'$this->depttypeId',
'$this->deptParentId',
'$this->deptLevel',
'$this->deptGroup')";
}else {
$sql = "update Department set
deptName='$this->deptName',
deptDesc='$this->deptDesc',
deptCode='$this->deptCode',
deptParent='$this->deptParent',
deptYear='$this->deptYear',
deptDate='$this->deptDate',
deptRef='$this->deptRef',
pbriId='$this->pbriId',
depttypeId='$this->depttypeId',
deptParentId='$this->deptParentId',
deptLevel='$this->deptLevel',
deptGroup='$this->deptGroup'
where deptId='$this->deptId'";
}
return $this->Dml($sql);
}
function Delete(){
return $this->Dml("delete from Department where deptId='$this->deptId'");
}
function GetNextCode(){
$this->SetQuery("select max(deptId) as num from Department");
if ($result=$this->GetResult()) {
return $result['num']+1;
}
}
function RSdepartment(){
$this->SetQuery("select * from Department order by deptId");
}
function GetRecord(){
$numFields = $this->NumField();
$row = $this->GetResult();
if ($row){
for ($i=0; $i<$numFields; $i++){
eval("\$this->".mysql_field_name($this->rs, $i)."=\$row['".mysql_field_name($this->rs, $i)."'];");
}
return true;
}else{ // clear value of Member;
for ($i=0; $i<$numFields; $i++){
eval("\$this->".mysql_field_name($this->rs, $i)."='';");
}
return false;
}
}
function SearchByKey($xKey){
if ($this->SetQuery("select * from Department where deptId= '$xKey'")){
return 1;
}else {
return 0;
}
}
//****************** You can add new functions below **********************//
function RSDeptByMaxdeptDate2(){
$maxdate = $this->MaxDate();
$this->SetQuery("select * from Department where deptDate = '$maxdate' order by deptId asc");
}
function RSDeptByMaxdeptDate3(){
$maxdate = $this->MaxDate();
$this->SetQuery("select deptName,deptId from Department where deptDate = '$maxdate' order by deptId asc");
}
function MaxDate(){
$this->SetQuery("select max(deptDate) as num from Department");
if ($result=$this->GetResult()) {
return $result['num'];
}
}
function RSmenuByDeptParent($dId){
$maxdate = $this->MaxDate();
$sql = "select * from Department where deptParentId=$dId and deptDate = '$maxdate' order by deptId";
$this->SetQuery($sql);
}
function RSmenuByDeptParentdeptDate($dId,$deptDate){
$sql = "select * from Department where deptParentId=$dId and deptDate = '$deptDate' order by deptId";
$this->SetQuery($sql);
}
function RSmenuByDeptParent2deptdate0($dId){
$sql = "select deptId from Department where deptParentId=$dId and deptDate = '0000-00-00' order by deptId";
$this->SetQuery($sql);
}
function RSMainDepartment(){
$maxdate = $this->MaxDate();
$sql = "select * from Department where deptParentId=0 and deptDate = '$maxdate' order by deptParentId";
$this->SetQuery($sql);
}
function SearchByName(){
$maxdate = $this->MaxDate();
$sql = "select * from Department where deptName = 'ผู้อำนวยการสถาบันพระบรมราชชนก' and deptDate = '$maxdate' ";
//echo $sql;
$this->SetQuery($sql);
}
function RSdepthavedeptParentId($xKey){
$sql = "select * from Department where deptParentId ='$xKey'";
$this->SetQuery($sql);
}
function RSdeptGroupBydeptDate($xKey){
$sql = "select deptDate from Department group by deptDate order by deptDate desc";
$this->SetQuery($sql);
}
function searchdeptDate($xKey){
$this->SetQuery("select * from Department where deptDate='$xKey' order by deptId asc");
}
function searchdeptDate2($xKey){
$this->SetQuery("select * from Department where deptParentId=0 and deptDate='$xKey' order by deptParentId asc , deptId asc");
}
function RSMainDepartmentdeptDate0(){
$sql = "select * from Department where deptDate='0000-00-00' order by deptParentId";
$this->SetQuery($sql);
}
function RSMainDepartment2($xKey,$yKey){
$sql = "select deptId from Department where deptParentId=0 and deptDate='0000-00-00' order by deptParentId asc , deptId asc";
$this->SetQuery($sql);
}
function SearchNewdept($xKey){
$sql = "select * from Department where deptParent ='$xKey'";
$this->SetQuery($sql);
}
function RSdeptSetgroupHeaddeptDate0(){
$sql = "select * from Department where depttypeId < '3' and deptDate='0000-00-00'";
$this->SetQuery($sql);
}
function RSMainDepartmentdeptDate($xKey){
$sql = "select deptId from Department where deptParentId=0 and deptDate='$xKey' order by deptParentId asc , deptId asc";
$this->SetQuery($sql);
}
function RSmenuByDeptParent2deptdate0deptDate($dId,$xKey){
$sql = "select deptId from Department where deptParentId=$dId and deptDate='$xKey' order by deptId";
$this->SetQuery($sql);
}
} //--End class department--
?>
|