<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Group_model extends CI_Model {

    private $HT;

    function __construct() {
        parent::__construct();
        $this->HT = $this->load->database('HT', TRUE);
    }
    public function update_ck_group_info($COLI_SN)
    {
        $group_sn_query = 
            "select COLI_GRI_SN from ConfirmLineInfo where COLI_SN=?
             union
             select COLI_GRI_SN from BIZ_ConfirmLineInfo where COLI_SN=?";
        $group_sn_row = $this->HT->query($group_sn_query, array($COLI_SN, $COLI_SN))->row();

        if (!empty($group_sn_row) && $group_sn_row->COLI_GRI_SN > 0) {            
            $group_sn = $group_sn_row->COLI_GRI_SN;

            $check_group_query = "select CGI_SN from CK_GroupInfo where CGI_GRI_SN=?";
            $check_group_row = $this->HT->query($check_group_query, array($group_sn))->row();
            if (!empty($check_group_row)) {
                $update_group_query = "exec SP_CheckGroup_UpdateCKGroupInfo ?, 29, 0";
                $update_group_row = $this->HT->select_stored_procedure($update_group_query, array($group_sn));
            }
        }
    }

}
