Viewing file: sa_detail_project_model.php (5.43 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
include_once("da_sa_detail_project.php");
class Sa_detail_project_model extends Da_sa_detail_project {
/* * 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 $this->sa_dbname.sa_detail_project $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->PK_FIELD] = $row->FIELD_NAME; } return $opt; } // add your functions here function get_detail() { $sql = "SELECT * FROM $this->sa_dbname.sa_detail_project LEFT JOIN $this->ppc_dbname.Person ON dpj_adviser = personId WHERE dpj_mpj_id=? AND dpj_status = 2"; //สถานะอนุมัติแล้ว $query = $this->db->query($sql, array($this->dpj_mpj_id)); return $query; } function getByOwner(){ $sql = "SELECT * FROM $this->sa_dbname.sa_detail_project WHERE dpj_owner=?"; $query = $this->db->query($sql, array($this->dpj_owner)); return $query; }
function get_data_relation() { $sql = " SELECT * FROM (
SELECT dpj_id, dpj_mpj_id, dpj_sub_name, dpj_manager ,dpj_seq ,dpj_year,dpj_bgY,dpj_code, dpj_status, dpj_date_offer, dpj_date_approve FROM `sa_detail_project` WHERE dpj_mpj_id =0 AND dpj_bgY = ? ORDER BY dpj_id ) AS dp1 LEFT JOIN (
SELECT dpj_id AS dpj2_id, dpj_mpj_id AS dpj2_mpj_id, dpj_sub_name AS dpj2_sub_name, dpj_manager AS dpj2_manager ,dpj_seq as dpj2_seq,dpj_year as dpj2_year,dpj_bgY as dpj2_bgY,dpj_code as dpj2_code, dpj_status as dpj2_status, dpj_date_offer as dpj2_date_offer, dpj_date_approve as dpj2_date_approve FROM `sa_detail_project` WHERE dpj_mpj_id !=0 ORDER BY dpj_id ) AS dp2 ON dp1.dpj_id = dp2.dpj2_mpj_id "; $query = $this->db->query($sql,array($this->dpj_bgY)); return $query; } function getByMpj() { $sql = "SELECT * FROM $this->sa_dbname.sa_detail_project WHERE dpj_mpj_id=? ORDER BY dpj_seq"; $query = $this->db->query($sql, array($this->dpj_mpj_id)); return $query; }
function offer_dpj() { $sql = "UPDATE $this->sa_dbname.sa_detail_project SET dpj_status = ?, dpj_us_offer = ?, dpj_date_offer = ? WHERE dpj_id=?"; $this->db->query($sql, array($this->dpj_status, $this->dpj_us_offer, $this->dpj_date_offer, $this->dpj_id)); }
function approve_dpj() { $sql = "UPDATE $this->sa_dbname.sa_detail_project SET dpj_status = ?, dpj_us_approve = ?, dpj_date_approve = ? WHERE dpj_id=?"; $this->db->query($sql, array($this->dpj_status, $this->dpj_us_approve, $this->dpj_date_approve, $this->dpj_id)); }
function get_join_by_key() { $sql = "SELECT * FROM $this->sa_dbname.sa_detail_project LEFT JOIN $this->sa_dbname.sa_smo_club ON sc_id = dpj_owner WHERE dpj_id=?"; $query = $this->db->query($sql, array($this->dpj_id)); return $query; }
function conclude_dpj() { $sql = "UPDATE $this->sa_dbname.sa_detail_project SET dpj_conclude = ? WHERE dpj_id=?"; $this->db->query($sql, array($this->dpj_conclude, $this->dpj_id));
}
function search_project_con() { $con = ''; if ($this->dpj_bgY != '') { $con .= " AND dpj_bgY = ".$this->dpj_bgY; } if ($this->dpj_owner != '') { $con .= " AND dpj_owner = ".$this->dpj_owner; } if ($this->dpj_attribute != '') { $con .= " AND dpj_attribute = ".$this->dpj_attribute; }
$sql = "SELECT * FROM $this->sa_dbname.sa_detail_project WHERE 1=1 $con ORDER BY dpj_bgY"; $query = $this->db->query($sql, array()); return $query; }
function search_project() { $sql = "select p.itg_id as p_itg_id, p.itg_name as p_itg_name,p.itg_parentId as p_itg_parentId,c.* ,sa_integration_project.*, dp.* from ( SELECT * FROM $this->sa_dbname.sa_integration where itg_parentId=0 )p left join ( SELECT * FROM $this->sa_dbname.sa_integration where itg_parentId!=0 )c on p.itg_id = c.itg_parentId LEFT JOIN $this->sa_dbname.sa_integration_project ON igp_itg_id = p.itg_id LEFT JOIN $this->sa_dbname.sa_detail_project as dp ON igp_mjp_id=dpj_mpj_id group by igp_itg_id order by p_itg_id, itg_id"; $query = $this->db->query($sql); return $query; } function get_detail2($year,$type) { $cond = ''; if ($type == 1) { $cond .= " AND dpj_mpj_id = 0"; } else { $cond .= " AND dpj_mpj_id <> 0"; } $cond.=($year != '')? " AND dpj_year = ".$year:''; $sql = "SELECT * FROM $this->sa_dbname.sa_detail_project WHERE 1=1 $cond ORDER BY dpj_code"; //สถานะอนุมัติแล้ว $query = $this->db->query($sql); return $query; } } // end class Sa_detail_project_model ?>
|