<?php
include_once("_nemo.list.cls.php");

/*
*/

class UserCategory extends NemoList
{
   private $ID = 0;

   public function __construct($DataKey)
   {
      parent::__construct($DataKey);
   }

   public function getList()
   {
      $this->ListSQL("SELECT tblUserCategory.UserCategoryID,
                              tblUserCategory.strUserCategory AS 'User Category',
                              tblUserCategory.strRegistrationType AS 'Registration Type',
                              tblUserCategory.blnFinancialAdvisor AS 'Is Financial Advisor?',
                              tblUserCategory.blnOMStaff AS 'Is OM Staff?',
                              tblUserCategory.blnActive AS Active,
                              tblUserCategory.strLastUser AS 'Last User',
                              tblUserCategory.dtLastEdit AS 'Last Edit'
                     FROM tblUserCategory");

      return $this->renderTable("User Category List");
   }

   public static function Save(&$UserCategoryID)
   {
      global $xdb, $arrSys, $TR, $SP, $HR, $PHP_SELF, $DATABASE_SETTINGS, $SystemSettings;
      $db = new NemoDatabase("tblUserCategory", $UserCategoryID, null, 0);

      $xdb = nCopy($db);

      $db->SetValues($_POST);

      $db->Fields[strLastUser] = $_SESSION['USER']->USERNAME;

      $result = $db->Save();
      if($UserCategoryID == 0) $UserCategoryID = $db->ID[UserCategoryID];

      //print_rr($result);
      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 tblUserCategory WHERE UserCategoryID = ". $xdb->qs($key));
            $xdb->doQuery("UPDATE tblUserCategory SET blnActive = 0 WHERE UserCategoryID = ". $xdb->qs($key));
         }
         return "Records Deleted.";
      }
   }
}
?>