Advertisement
ma39isy

Untitled

Mar 18th, 2024
579
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.88 KB | None | 0 0
  1. function InsertStudentStudyCard() {
  2.         //set ksm yang lama menjadi invalid
  3.         //tambahan dari bu fitri (19 feb 2013), ketika cetak lagi KSM, versi lama diset invalid
  4.         $this->SetStudentStudyCardInvalid();
  5.         //jika tidak ada ksm yg berlaku
  6.         if(!$this->GetValidStudentStudyCard()) {
  7.             //jika sudah finish melakukan registrasi
  8.             if($dataFix = $this->GetFixRegistration()) {
  9.                 $studentStudyCardId = $this->NextStudentStudyCardId();
  10.                 $serialNumber = @substr("C$studentStudyCardId".@StrToDb(@md5(@microtime().$this->studentId.$this->schoolYear.$this->semester),'upper'),0,12);
  11.                 //get last print order ksm to build new print order
  12.                 $query = "select max(PRINTORDER) as LASTORDER from STUDENTSTUDYCARD ".
  13.                         " where STUDENTID='".$this->studentId."' and SEMESTER='".$this->semester."' and SCHOOLYEAR='".$this->schoolYear."' ";
  14.                 $q = $this->ExecuteQuery($query);
  15.                 ($r = $this->FetchArray($q))?$printOrder=@intval($r['LASTORDER'])+1:$printOrder=1;
  16.                 //update expired status if any             
  17.                 $this->Update("STUDENTSTUDYCARD",array("EXPIREDSTATUS"=>"'YA'","EXPIREDDATE"=>"SYSDATE"),"STUDENTID='".$this->studentId."' and (EXPIREDSTATUS='TIDAK' or EXPIREDSTATUS is null)");             
  18.                 foreach($dataFix as $key=>$val) {
  19.                     //insert into KSM
  20.                     $data = array (
  21.                                 "STUDENTSTUDYCARDID"=>"'$studentStudyCardId'",
  22.                                 "SERIALNUMBER"=>"'$serialNumber'",
  23.                                 "STUDENTID"=>"'".$this->studentId."'",
  24.                                 "SEMESTER"=>"'".$this->semester."'",
  25.                                 "SCHOOLYEAR"=>"'".$this->schoolYear."'",
  26.                                 "COURSEID"=>"'".$val['COURSEID']."'",
  27.                                 "STATUS"=>"'BERLAKU'",
  28.                                 "PRINTORDER"=>"'$printOrder'",
  29.                                 "INPUTDATE"=>"SYSDATE",
  30.                                 "INPUTBY"=>"'".$_SESSION['userid']."'",
  31.                                 "EXPIREDSTATUS"=>"'TIDAK'",
  32.                                 "EXPIREDDATE"=>"NULL"
  33.                             );
  34.                     $this->Insert("STUDENTSTUDYCARD",$data);
  35.                     //check di temporary point untuk mengambil nilai yang di titipkan, jika ada
  36.                     $scoreObj = new DBScore($this->config);
  37.                     if($dataTemporary = $scoreObj->GetUnmovedTemporaryPoint($this->studentId,$val['SUBJECTID'],$val['STUDYPROGRAMID'],$val['SUBJECTCODE'],$this->schoolYear,$this->semester)) {
  38.                         $scoreObj->ChangeIndexStudent($this->studentId,$dataTemporary[0]['INDEXPOINT'],$val['SUBJECTID'],$val['STUDYPROGRAMID'],$val['SUBJECTCODE'],$this->schoolYear,$this->semester,"","");
  39.                         $scoreObj->UpdateTemporaryPointStatus($this->studentId,$val['SUBJECTID'],$val['STUDYPROGRAMID'],$val['SUBJECTCODE'],$this->schoolYear,$this->semester,'MOVED');
  40.                     }
  41.                 }
  42.             }
  43.             else{
  44.                  $studentStudyCardId = $this->NextStudentStudyCardId();
  45.                 $serialNumber = @substr("C$studentStudyCardId".@StrToDb(@md5(@microtime().$this->studentId.$this->schoolYear.$this->semester),'upper'),0,12);
  46.                 //get last print order ksm to build new print order
  47.                 $query = "select max(PRINTORDER) as LASTORDER from STUDENTSTUDYCARD ".
  48.                         " where STUDENTID='".$this->studentId."' and SEMESTER='".$this->semester."' and SCHOOLYEAR='".$this->schoolYear."' ";
  49.                 $q = $this->ExecuteQuery($query);
  50.                 ($r = $this->FetchArray($q))?$printOrder=@intval($r['LASTORDER'])+1:$printOrder=1;
  51.                 //update expired status if any
  52.                 $this->Update("STUDENTSTUDYCARD",array("EXPIREDSTATUS"=>"'YA'","EXPIREDDATE"=>"SYSDATE"),"STUDENTID='".$this->studentId."' and (EXPIREDSTATUS='TIDAK' or EXPIREDSTATUS is null)");
  53.                 //insert into KSM
  54.                 $data = array (
  55.                                 "STUDENTSTUDYCARDID"=>"'$studentStudyCardId'",
  56.                                 "SERIALNUMBER"=>"'$serialNumber'",
  57.                                 "STUDENTID"=>"'".$this->studentId."'",
  58.                                 "SEMESTER"=>"'".$this->semester."'",
  59.                                 "SCHOOLYEAR"=>"'".$this->schoolYear."'",
  60.                                 "STATUS"=>"'BERLAKU'",
  61.                                 "PRINTORDER"=>"'$printOrder'",
  62.                                 "INPUTDATE"=>"SYSDATE",
  63.                                 "INPUTBY"=>"'".$_SESSION['userid']."'",
  64.                                 "EXPIREDSTATUS"=>"'TIDAK'",
  65.                                 "EXPIREDDATE"=>"NULL"
  66.                 );
  67.                 $this->Insert("STUDENTSTUDYCARD",$data);
  68.             }
  69.         }
  70.         return true;
  71.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement