<?php
class AppNimFormula extends Database {
	protected $mSqlFile= 'module/nim_formula/business/appnimformula.sql.php';

	function __construct($connectionNumber=0) {
		parent::__construct($connectionNumber);
	}
   
   function GetCountNimFormula(){
      $result=$this->Open($this->mSqlQueries['get_count_nim_formula'],array());
      
	   if (!$result) {
			return 0;
		} else {
			return $result[0]['total'];
		}
   }
   
   function GetNimFormula(){
      $result=$this->Open($this->mSqlQueries['get_nim_formula'],array());
      return $result;
   }
   
   function GetNimKomponen(){
      $result=$this->Open($this->mSqlQueries['get_nim_komponen'],array());
      return $result;
   }
   
   function GetNimFormulaById($formulaId){
      $result=$this->Open($this->mSqlQueries['get_nim_formula_by_id'],array($formulaId));
      return $result;
   }
   
	function GetTahun($id) {
   
      $awalTahunAjaran = $id;
      $tahun = date("Y");
      $tahunAjaran = $tahun;
      $cnt = 0;
      
      while ($tahunAjaran >= $awalTahunAjaran) {
         $result_array[$cnt][id] = $tahunAjaran;
         $result_array[$cnt][name] = $tahunAjaran;
         $tahunAjaran--;
         $cnt++;
      }
      return $result_array;
   } 
   
   function DoAddNimFormula($formula,$formulaFormat){
      $result=$this->Execute($this->mSqlQueries['do_add_nim_formula'],array($formula,$formulaFormat));
      return $result;
   }   
   
   function DoUpdateNimFormula($formula,$formulaFormat,$dataId){
      $result=$this->Execute($this->mSqlQueries['do_update_nim_formula'],array($formula,$formulaFormat,$dataId));

      return $result;
   }
   
   function DoDeleteNimFormulaById($idDelete){
      $result=$this->Execute($this->mSqlQueries['do_delete_nim_formula_by_id'],array($idDelete));
      return $result;
   }
   
   function DoDeleteNimFormulaByArrayId($arrIdDelete){
      $idDelete=implode("', '", $arrIdDelete);
      $result=$this->Execute($this->mSqlQueries['do_delete_nim_formula_by_array_id'],array($idDelete));
      return $result;
   }
   
   function DoNonAktifAllNimFormula(){
      $result=$this->Execute($this->mSqlQueries['do_non_aktif_all_nim_formula'],array());  
      return $result;
   }
   
   function DoAktifNimFormulaById($idNimFormula){
      $result=$this->Execute($this->mSqlQueries['do_aktif_nim_formula'],array($idNimFormula));
      return $result;
   }
   

}
?>