<?php
/*
Author : Nikolius
Email : n1colius.lau@gmail.com
Date : 20-Jul-2015 03:51 PM
*/
require_once $cfg->mValue['docroot'] . "module/sia_setting/business/sia_setting.class.php";
class Kelas_kuliah extends SiaSetting {

   function Kelas_kuliah(&$configObject, $dataProceed) {
      SiaSetting::SiaSetting($configObject, $dataProceed);
      $this->AppendSqlQueries("module/kelas_kuliah/business/kelas_kuliah.sql.php");
   }

   function GetDataListForInsertSync(){
      return $this->GetAllDataAsArray($this->mSqlQueries['GetDataListForInsertSync'], array());
   }

   function SyncData(){
      $dataList = $this->GetProperty("DataProceed");

      $this->StartTransaction();
      $prosesInsertUpdate = TRUE;

      for ($i=0; $i < count($dataList); $i++) {
         //proses untuk gt_id nya diisi dengan kls_id
         $p = array(
            $dataList[$i]['id_smt'],
            $dataList[$i]['id_mk']
         );
         $dataId = $this->GetAllDataAsArray($this->mSqlQueries['getDataIdKelasKuliah'], $p);
         $klsId = $dataId[0]['klsId'];

         $p = array(
            $dataList[$i]['id_kls'],
            $dataList[$i]['id_sms'],
            $dataList[$i]['id_smt'],
            $dataList[$i]['id_mk'],
            $dataList[$i]['nm_kls'],
            $dataList[$i]['sks_mk'],
            $dataList[$i]['sks_tm'],
            $dataList[$i]['sks_prak'],
            $dataList[$i]['sks_prak_lap'],
            $dataList[$i]['sks_sim'],
            $dataList[$i]['bahasan_case'],
            $dataList[$i]['tgl_mulai_koas'],
            $dataList[$i]['tgl_selesai_koas'],
            $dataList[$i]['id_mou'],
            $dataList[$i]['a_selenggara_pditt'],
            $dataList[$i]['kuota_pditt'],
            $dataList[$i]['a_pengguna_pditt'],
            $dataList[$i]['id_kls_pditt'],
            $klsId,
            $dataList[$i]['id_sms'], //update
            $dataList[$i]['id_smt'],
            $dataList[$i]['id_mk'],
            $dataList[$i]['nm_kls'],
            $dataList[$i]['sks_mk'],
            $dataList[$i]['sks_tm'],
            $dataList[$i]['sks_prak'],
            $dataList[$i]['sks_prak_lap'],
            $dataList[$i]['sks_sim'],
            $dataList[$i]['bahasan_case'],
            $dataList[$i]['tgl_mulai_koas'],
            $dataList[$i]['tgl_selesai_koas'],
            $dataList[$i]['id_mou'],
            $dataList[$i]['a_selenggara_pditt'],
            $dataList[$i]['kuota_pditt'],
            $dataList[$i]['a_pengguna_pditt'],
            $dataList[$i]['id_kls_pditt'],
            $klsId
         );
         $proses = $this->ExecuteUpdateQuery($this->mSqlQueries['syncData'], $p);
         if($proses == FALSE) $prosesInsertUpdate = FALSE;
      }

      $this->CompleteTransaction($prosesInsertUpdate);
      return $prosesInsertUpdate;
   }
}
?>