<?php
/*
Author : Nikolius
Email : n1colius.lau@gmail.com
Date : 10-Jul-2015 10:59 AM
*/
require_once $cfg->mValue['docroot'] . "module/sia_setting/business/sia_setting.class.php";
class Ikatan_kerja_dosen extends SiaSetting {
   function Ikatan_kerja_dosen(&$configObject, $dataProceed) {
      SiaSetting::SiaSetting($configObject, $dataProceed);
      $this->AppendSqlQueries("module/ikatan_kerja_dosen/business/ikatan_kerja_dosen.sql.php");
   }

   function GetDataIkatanKerjaDosenForSync(){
      $dataList = $this->GetProperty("DataProceed");
      //echo '<pre>'; print_r($dataList); exit;
      $this->StartTransaction();
      $prosesInsertUpdate = TRUE;

      //update data terlebih dahulu
      for ($i=0; $i < count($dataList); $i++) {
         $p = array(
            $dataList[$i]['id_ikatan_kerja'],
            $dataList[$i]['nm_ikatan_kerja'],
            $dataList[$i]['ket_ikatan_kerja'],
            $dataList[$i]['nm_ikatan_kerja'],
            $dataList[$i]['ket_ikatan_kerja']
         );
         $proses = $this->ExecuteUpdateQuery($this->mSqlQueries['syncDataIkatanKerjaDosen'], $p);
         if($proses == FALSE) $prosesInsertUpdate = FALSE;
      }

      //cari datanya di tabel pg_status_ikatan_kerja_dosen dan update gt_id nya
      for ($i=0; $i < count($dataList); $i++) {
         $dataId = $this->GetAllDataAsArray($this->mSqlQueries['getDataId'], array($dataList[$i]['nm_ikatan_kerja']));
         $gt_id = $dataId[0]['sikjKode'];

         $proses = $this->ExecuteUpdateQuery($this->mSqlQueries['updateFeederIkatanKerjaDosenGtId'], array($gt_id,$dataList[$i]['id_ikatan_kerja']));
         if($proses == FALSE) $prosesInsertUpdate = FALSE;
      }

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

}
?>