Viewing file: clsDepartment.php (7.01 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
//--Class department--------------------------
//--PK of department ::
// 1. departmentId
include_once "../link/keyThai.php";
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 $deptIsCenter;
var $receiveIn;
var $receiveOut;
var $sendIn;
var $sendOut;
var $deptNo;
var $docGroup;
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){
$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->deptIsCenter',
'$this->receiveIn',
'$this->receiveOut',
'$this->sendIn',
'$this->sendOut',
'".th2a($this->deptNo)."',
'$this->docGroup',
'$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',
deptIsCenter='$this->deptIsCenter',
receiveIn='$this->receiveIn',
receiveOut='$this->receiveOut',
sendIn='$this->sendIn',
sendOut='$this->sendOut',
deptNo='".th2a($this->deptNo)."',
docGroup='$this->docGroup',
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)."'];");
$this->deptName=a2th($this->deptName);
$this->deptDesc=a2th($this->deptDesc);
}
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 SearchByDeptRef($xKey){
if($this->SetQuery("select * from Department where deptRef = '$xKey'")){
return 1;
}else {
return 0;
}
}
function SearchBydeptParent(){ /////
$this->SetQuery("select deptName from Department");
}
function RSDeptByMaxdeptDate(){
$maxdate = $this->MaxDate();
$this->SetQuery("select * from Department where deptDate = '$maxdate' order by deptId asc");
}
function RSDeptBydeptParent1(){
$maxdate = $this->MaxDate();
$this->SetQuery("select * from Department order by deptId asc");
}
function MaxDate(){
$this->SetQuery("select max(deptDate) as num from Department");
if ($result=$this->GetResult()) {
return $result['num'];
}
}
function searchMaxDate($xKey){
if($this->SetQuery("select deptDate from Department where deptDate >'$xKey' order by deptDate asc limit 1")){
return 1;
}else {
return 0;
}
}
function SearchDeptByMaxdeptDate($xKey){
$maxdate = $this->MaxDate();
$this->SetQuery("select * from Department where deptId='$xKey' and deptDate = '$maxdate' order by deptId");
}
function SearchMaxDocGroup(){
$this->SetQuery("select max(docGroup) as num from Department");
if ($result=$this->GetResult()) {
return $result['num'];
}
}
function SearchBydeptDateDocGroup($xKey){
$this->SetQuery("select * from Department where docGroup='$xKey' order by deptId");
}
function SearchBydeptDateDocGroup2($xKey){
$this->SetQuery("select * from Department where docGroup='$xKey' order by deptId");
}
function SearchDeptParentByDeptRef($xKey){
$this->SetQuery("select * from Department where deptRef = '$xKey'");
}
function SearchByreceiveInMaxDocGroup($xKey){
$this->SetQuery("select * from Department where docGroup='$xKey' and receiveIn='Y' order by deptId asc");
}
function SearchBysendInMaxDocGroup($xKey){
$this->SetQuery("select * from Department where docGroup='$xKey' and sendIn='Y' order by deptId asc");
}
function SearchDeptName($xKey){
$this->SetQuery("select deptName as name from Department where deptId= '$xKey'");
if ($result=$this->GetResult()) {
return $result['name'];
}
}
function SearchBydeptDateDocGroupNoselectDept($xKey,$deptID){
$this->SetQuery("select * from Department where docGroup='$xKey' and deptId!='$deptID' order by deptId");
}
function SearchBydeptParentnot0($xKey){ /////
$this->SetQuery("select * from Department where deptDate!='$xKey' order by deptDate desc ,deptId asc");
}
function RSmenuByDeptParent($dId){
$sql = "select * from Department where deptParentId='$dId' order by deptId";
$this->SetQuery($sql);
}
function RSmenuByDeptParentMaxDate($dId){
$maxdate = $this->MaxDate();
$sql = "select * from Department where deptParentId='$dId' and deptDate = '$maxdate' 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 searchdeptDate2($xKey){
$this->SetQuery("select * from Department where deptParentId=0 and deptDate='$xKey' order by deptParentId asc , deptId asc");
}
function searchdeptDate($xKey){
$this->SetQuery("select deptId from Department where deptParentId=0 and deptDate='$xKey' order by deptParentId asc , deptId asc");
}
function RSmenuByDeptParent2($dId){
$maxdate = $this->MaxDate();
$sql = "select * from Department where deptParentId='$dId' and deptDate = '$maxdate' order by deptId";
$this->SetQuery($sql);
}
function RSmenuByDeptParent3($dId){
$maxdate = $this->MaxDate();
$sql = "select deptId from Department where deptParentId='$dId' and deptDate = '$maxdate' order by deptId";
$this->SetQuery($sql);
}
function RSDeptByMaxdeptDate2(){
$maxdate = $this->MaxDate();
$this->SetQuery("select * from Department where deptDate = '$maxdate' order by deptId asc");
}
function SearchBydeptDateDocGroup2deptlevel01($xKey){
$this->SetQuery("select * from Department where docGroup='$xKey' and (deptLevel=0 || deptLevel =1) order by deptId");
}
} //--End class department--
?>
|