Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function InsertStudentStudyCard() {
- //set ksm yang lama menjadi invalid
- //tambahan dari bu fitri (19 feb 2013), ketika cetak lagi KSM, versi lama diset invalid
- $this->SetStudentStudyCardInvalid();
- //jika tidak ada ksm yg berlaku
- if(!$this->GetValidStudentStudyCard()) {
- //jika sudah finish melakukan registrasi
- if($dataFix = $this->GetFixRegistration()) {
- $studentStudyCardId = $this->NextStudentStudyCardId();
- $serialNumber = @substr("C$studentStudyCardId".@StrToDb(@md5(@microtime().$this->studentId.$this->schoolYear.$this->semester),'upper'),0,12);
- //get last print order ksm to build new print order
- $query = "select max(PRINTORDER) as LASTORDER from STUDENTSTUDYCARD ".
- " where STUDENTID='".$this->studentId."' and SEMESTER='".$this->semester."' and SCHOOLYEAR='".$this->schoolYear."' ";
- $q = $this->ExecuteQuery($query);
- ($r = $this->FetchArray($q))?$printOrder=@intval($r['LASTORDER'])+1:$printOrder=1;
- //update expired status if any
- $this->Update("STUDENTSTUDYCARD",array("EXPIREDSTATUS"=>"'YA'","EXPIREDDATE"=>"SYSDATE"),"STUDENTID='".$this->studentId."' and (EXPIREDSTATUS='TIDAK' or EXPIREDSTATUS is null)");
- foreach($dataFix as $key=>$val) {
- //insert into KSM
- $data = array (
- "STUDENTSTUDYCARDID"=>"'$studentStudyCardId'",
- "SERIALNUMBER"=>"'$serialNumber'",
- "STUDENTID"=>"'".$this->studentId."'",
- "SEMESTER"=>"'".$this->semester."'",
- "SCHOOLYEAR"=>"'".$this->schoolYear."'",
- "COURSEID"=>"'".$val['COURSEID']."'",
- "STATUS"=>"'BERLAKU'",
- "PRINTORDER"=>"'$printOrder'",
- "INPUTDATE"=>"SYSDATE",
- "INPUTBY"=>"'".$_SESSION['userid']."'",
- "EXPIREDSTATUS"=>"'TIDAK'",
- "EXPIREDDATE"=>"NULL"
- );
- $this->Insert("STUDENTSTUDYCARD",$data);
- //check di temporary point untuk mengambil nilai yang di titipkan, jika ada
- $scoreObj = new DBScore($this->config);
- if($dataTemporary = $scoreObj->GetUnmovedTemporaryPoint($this->studentId,$val['SUBJECTID'],$val['STUDYPROGRAMID'],$val['SUBJECTCODE'],$this->schoolYear,$this->semester)) {
- $scoreObj->ChangeIndexStudent($this->studentId,$dataTemporary[0]['INDEXPOINT'],$val['SUBJECTID'],$val['STUDYPROGRAMID'],$val['SUBJECTCODE'],$this->schoolYear,$this->semester,"","");
- $scoreObj->UpdateTemporaryPointStatus($this->studentId,$val['SUBJECTID'],$val['STUDYPROGRAMID'],$val['SUBJECTCODE'],$this->schoolYear,$this->semester,'MOVED');
- }
- }
- }
- else{
- $studentStudyCardId = $this->NextStudentStudyCardId();
- $serialNumber = @substr("C$studentStudyCardId".@StrToDb(@md5(@microtime().$this->studentId.$this->schoolYear.$this->semester),'upper'),0,12);
- //get last print order ksm to build new print order
- $query = "select max(PRINTORDER) as LASTORDER from STUDENTSTUDYCARD ".
- " where STUDENTID='".$this->studentId."' and SEMESTER='".$this->semester."' and SCHOOLYEAR='".$this->schoolYear."' ";
- $q = $this->ExecuteQuery($query);
- ($r = $this->FetchArray($q))?$printOrder=@intval($r['LASTORDER'])+1:$printOrder=1;
- //update expired status if any
- $this->Update("STUDENTSTUDYCARD",array("EXPIREDSTATUS"=>"'YA'","EXPIREDDATE"=>"SYSDATE"),"STUDENTID='".$this->studentId."' and (EXPIREDSTATUS='TIDAK' or EXPIREDSTATUS is null)");
- //insert into KSM
- $data = array (
- "STUDENTSTUDYCARDID"=>"'$studentStudyCardId'",
- "SERIALNUMBER"=>"'$serialNumber'",
- "STUDENTID"=>"'".$this->studentId."'",
- "SEMESTER"=>"'".$this->semester."'",
- "SCHOOLYEAR"=>"'".$this->schoolYear."'",
- "STATUS"=>"'BERLAKU'",
- "PRINTORDER"=>"'$printOrder'",
- "INPUTDATE"=>"SYSDATE",
- "INPUTBY"=>"'".$_SESSION['userid']."'",
- "EXPIREDSTATUS"=>"'TIDAK'",
- "EXPIREDDATE"=>"NULL"
- );
- $this->Insert("STUDENTSTUDYCARD",$data);
- }
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement