Viewing file: processdept.php (5.06 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
include_once("../../class/clsConnection.php");
include_once("../../class/clsDB.php");
include_once "../global.php";
include_once "../class/clsDepartment.php";
include_once "../link/function.php";
include_once "../class/clsPerson.php";
$oC = new clsConnection($GLOBALS['DBHOST'], $GLOBALS['DBNAME_EPERSON'], $GLOBALS['DBUSER_EPERSON'], $GLOBALS['DBPASS_EPERSON']);
$obj = new Department($oC);
$obj1 = new Department($oC);
$oDp= new Department($oC);
$oDp2= new Department($oC);
$oPS = new Person($oC);
if($method=="add"){
$obj->AddNew();
$obj->deptId=$obj->GetNextCode();
$obj->deptName=$deptName;
$obj->depttypeId=$depttypeId;
$obj->deptParentId=$deptParentId;
$obj->deptLevel=$deptLevel;
$obj->deptstartyear=$startyear;
$obj->deptendyear=$endyear;
$obj->deptgroup=$deptgroup;
$obj->Save();
// ?????????????????????????????????????????????????? ?????? ??????????????????????
// ??????? 3 ???????????????????????????
// $FileDocument : ???? Input ??????? Show ??????????? File
// $GLOBALS["FileLocation"] : ?????????????????????
// $obj->Xxxxx : attribute ??? object ??????????????path ???????
// if($_FILES['FileDocument']['name'] != "") {
// $tmpFFilename = $_FILES['TxtFileDocument']['name'];
// $ = "$GLOBALS['FileLocation']/".$tmpFFilename;
// if(!move_uploaded_file($_FILES['TxtFileDocument']['tmp_name'],$Txt)) {
// echo "Can't Attach ->",$php_errormsg;
// }
// }
// $obj->Xxxxx = $tmpFFilename;
//??????????????????
$obj->Save();
}else if($method=="edit"){
$obj->SearchByKey($deptId);
$obj->GetRecord();
$obj->Edit();
$obj->deptId=$deptId;
$obj->deptName=$deptName;
$obj->depttypeId=$depttypeId;
$obj->deptParentId=$obj->deptParentId;
$obj->deptLevel=$obj->deptLevel;
$obj->deptstartyear=$obj->deptstartyear;
$obj->deptendyear=$obj->deptendyear;
$obj->deptgroup=$obj->deptgroup;
$obj->Save();
$obj->Save();
}else if($method=="confirmdeptdate"){
$oDp->RSMainDepartmentdeptDate0();
while($oDp->GetRecord()){
$oDp->Edit();
$oDp->deptId=$oDp->deptId;
$oDp->deptName=$oDp->deptName;
$oDp->deptDesc=$oDp->deptDesc;
$oDp->deptCode=$oDp->deptCode;
$oDp->deptParent=$oDp->deptParent;
$oDp->deptYear=$oDp->deptYear;
$oDp->deptDate=splitDateForm($DocDate,"/");
$oDp->deptRef=$oDp->deptRef;
$oDp->pbriId=$oDp->pbriId;
$oDp->depttypeId=$oDp->depttypeId;
$oDp->deptParentId=$oDp->deptParentId;
$oDp->deptLevel=$oDp->deptLevel;
$oDp->deptgroup=$oDp->deptgroup;
$oDp->Save();
}
//---update person move dept
$oPS->RSPersonf1();
while($oPS->GetRecord()){
$oPS->Edit();
$oPS->personId=$oPS->personId;
//echo "personId=".$oPS->personId."<br>";
$oDp2->SearchNewdept($oPS->deptId);
if($oDp2->GetRecord()==1){
$oPS->deptId=$oDp2->deptId;
//echo "deptIdnew=".$oPS->deptId."<br>";
}else{
$oPS->deptId=$oPS->deptId;
//echo "deptIdold=".$oPS->deptId."<br>";
}
$oPS->workGpId=$oPS->workGpId;
$oPS->prefixId=$oPS->prefixId;
$oPS->fName=$oPS->fName;
$oPS->lName=$oPS->lName;
$oPS->fStatus=$oPS->fStatus;
$oPS->adminId=$oPS->adminId;
$oPS->fRetire=$oPS->fRetire;
$oPS->hireId=$oPS->hireId;
//echo "เจอ=update=".$oPS->fName."".$oPS->lName."fstatus=".$oPS->fStatus."<br>";
$oPS->Save();
//echo "-----------------<br>";
}
echo "<meta http-equiv='refresh' content='0; URL=showdept.php'>";
}else if($method=="delete"){
$obj->SearchByKey($deptId);
$obj->GetRecord();
$obj->Delete();
DelDeptParent($deptId);
echo "<meta http-equiv='refresh' content='0; URL=deptstructure.php'>";
}else if($method=="deleteyear"){
$obj->RSyear($startyear,$endyear);
while($obj->GetRecord()){
$obj1->SearchByKey($obj->deptId);
$obj1->GetRecord();
$obj1->Delete();
}
// ????????????????????????????????????????? ?????? ??????????????????????
// ??????? 2 ???????????????????????????
// $GLOBALS["FileLocation"] : ?????????????????????
// $obj->Xxxxx : attribute ??? object ???????path ???????
//unlink("$GLOBALS['FileLocation']/".$obj->Xxxxx);
//???????????????????????
}else if($method=="deletedept"){
$obj->searchdeptDate($deptDate);
while($obj->GetRecord()){
$obj->Delete();
}
echo "<meta http-equiv='refresh' content='0; URL=showdept.php'>";
}
function DelDeptParent($p){
include_once("../../class/clsConnection.php");
include_once("../../class/clsDB.php");
include_once "../global.php";
include_once "../class/clsDepartment.php";
$oC = new clsConnection($GLOBALS['DBHOST'], $GLOBALS['DBNAME_EPERSON'], $GLOBALS['DBUSER_EPERSON'], $GLOBALS['DBPASS_EPERSON']);
$obj1 = new Department($oC);
$obj1->RSdepthavedeptParentId($p);
while($obj1->GetRecord()){
if($obj1->deptId!=""){
//echo $obj1->deptId."<br>";
$p=$obj1->deptId;
$obj1->Delete();
DelDeptParent($p);
}
}
}
$obj1->Close();
$obj->Close();
$oC->Disconnect();
?>
|