<?php
include_once("_nemo.list.cls.php");

class Region extends NemoList
{
   private $ID = 0;

   public function __construct($DataKey)
   {
      parent::__construct($DataKey);

   }

   public function getList()
   {
      global $SystemSettings;
      $this->ListSQL("
         SELECT tblRegion.RegionID, tblRegion.strRegion AS Region, tblRegion.blnActive AS Active, tblRegion.strLastUser AS 'Last User', tblRegion.dtLastEdit AS 'Last Edit'
         FROM tblRegion
         ORDER BY tblRegion.strRegion Asc");

      return $this->renderTable("Region List");
   }

   public static function Save(&$RegionID)
   {
      $db = new NemoDatabase("tblRegion", $RegionID, null, 0);

      $db->SetValues($_POST);
      $db->Fields[blnActive] = ($_POST['blnActive'] != "" ? "1" : "0");
      $db->Fields[strLastUser] = $_SESSION['USER']->USERNAME;
      //$db->Fields[dtLastEdit] = date("YmdHi");
      $result = $db->Save();
      //print_rr($db->Fields);
      if($RegionID == 0) $RegionID = $db->ID[RegionID];

      if($result->Error == 1)
         return $result->Message;
      else
         return "Details Saved. ";
   }

   public static function Delete($chkSelect)
   {
      global $xdb;
      //print_rr($chkSelect);
      if(count($chkSelect) > 0){
      foreach($chkSelect as $key => $value)
      {
         $xdb->doQuery("DELETE FROM tblRegion WHERE RegionID = ". $xdb->qs($key));
      }
         return "Records Deleted.";
      }
   }
}
?>
