Viewing file:      mo_rg_fstatusinps.php (1.68 KB)      -rwxr-xr-x Select action/file-type:    (+) |   (+) |   (+) | Code (+) | Session (+) |   (+) | SDB (+) |   (+) |   (+) |   (+) |   (+) |   (+) |
 
<?php
 
 include_once("da_rg_FStatusInPs.php");
 
 class Mo_rg_fstatusinps extends Da_rg_FStatusInPs {
 
     /*
      * aOrderBy = array('fieldname' => 'ASC|DESC', ... )
      */
     function get_all($aOrderBy=""){
         $orderBy = "";
         if ( is_array($aOrderBy) ) {
             $orderBy.= "ORDER BY "; 
             foreach ($aOrderBy as $key => $value) {
                 $orderBy.= "$key $value, ";
             }
             $orderBy = substr($orderBy, 0, strlen($orderBy)-2);
         }
         $sql = "SELECT * 
                 FROM rg_FStatusInPs 
                 $orderBy";
         $query = $this->db->query($sql);
         return $query;
     }
     
     /*
      * create array of pk field and value for generate select list in view, must edit PK_FIELD and FIELD_NAME manually
      * the first line of select list is '-----เลือก-----' by default.
      * if you do not need the first list of select list is '-----เลือก-----', please pass $optional parameter to other values. 
      * you can delete this function if it not necessary.
      */
     function get_options($optional='y') {
         $qry = $this->get_all();
         if ($optional=='y') $opt[''] = '';
         foreach ($qry->result() as $row) {
             $opt[$row->fipFStatus] = $row->fipFStatusName;
         }
         return $opt;
     }
     
     // add your functions here
 
     function getPs() {
         $sql = "SELECT MIN(fipFStatus) AS fipFStatus, ps.* 
                 FROM $this->rg_dbname.rg_FStatusInPs 
                 INNER JOIN $this->rg_dbname.rg_PersonStatus ps ON fipPsId = psId 
                 GROUP BY psId";
         $query = $this->db->query($sql);
         return $query;
     }
 
     function get_optionsPs($optional='y') {
         $qry = $this->getPs();
         if ($optional=='y') $opt[''] = '';
         foreach ($qry->result() as $row) {
             $opt[$row->fipFStatus] = $row->psName;
         }
         return $opt;
     }
 
 } // end class M_rg_fstatusinps
 ?> 
  |