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

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

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

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

      for ($i=0; $i < count($dataList); $i++) {
         $p = array(
            $dataList[$i]['id_negara'],
            $dataList[$i]['nm_negara'],
            $dataList[$i]['a_ln'],
            $dataList[$i]['nm_negara'],
            $dataList[$i]['a_ln']
         );
         $proses = $this->ExecuteUpdateQuery($this->mSqlQueries['syncDataNegara'], $p);
         if($proses == FALSE) $prosesInsertUpdate = FALSE;
      }

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

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

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