db = $this->load->database("onedev", true); } function index() { echo "API"; } function fix($mouID,$testID) { $sql = "select M_CompanyName, M_MouName from m_mou join m_company on M_MouM_CompanyID = M_CompanyID where M_MouID = ?"; $qry = $this->db->query($sql, array($mouID)); if ($qry) { $rows = $qry->result_array(); if (count($rows) > 0 ) { echo $rows[0]["M_CompanyName"] . "\t" . $rows[0]["M_MouName"] . "\n"; $sql = "select t.T_TestID, T_TestSasCode, t.T_TestName, t.T_TestIsActive, child_test from ss_price_mou s join t_test t on s.T_TestID = t.T_TestID where Ss_PriceMouM_MouID = ? and t.T_TestID = ? and px_type = 'PXR'"; $qry = $this->db->query($sql,array($mouID,$testID)); if ($qry) { $rows = $qry->result_array(); foreach($rows as $r) { echo $r["T_TestID"] . "\t" . $r["T_TestSasCode"] . "\t" . $r["T_TestName"] . "\t" . $r["T_TestIsActive"] . "\n"; echo "----\n"; $child_test = json_decode($r["child_test"],true); foreach($child_test as $ct) { //print_r($ct); $sql = "select T_PriceAmount, T_PriceDisc, T_PriceDiscRp, T_PriceSubTotal, T_PriceTotal from t_price where T_PriceM_MouID = ? and T_PriceT_TestID = ? "; //echo "$mouID : " . $ct["T_TestID"] . "\n"; $qry = $this->db->query($sql, array($mouID,$ct["T_TestID"])); if ($qry) { $xrows = $qry->result_array(); if (count($xrows)>0 ) { echo $ct["T_TestName"] . " exists \n"; $r = $xrows[0]; $amount = $ct["T_PriceAmount"]; $disc = $ct["T_PriceDisc"]; $discRp = $ct["T_PriceDiscRp"]; $subTotal = $ct["T_PriceSubTotal"]; $total = $ct["T_PriceTotal"]; $r_amount = $r["T_PriceAmount"]; $r_disc = $r["T_PriceDisc"]; $r_discRp = $r["T_PriceDiscRp"]; $r_subTotal = $r["T_PriceSubTotal"]; $r_total = $r["T_PriceTotal"]; echo "amount : $amount : $r_amount \n"; echo "disc : $disc : $r_disc \n"; echo "disc Rp : $discRp : $r_discRp \n"; echo "sub Tot : $subTotal : $r_subTotal \n"; echo "total : $total : $r_total \n"; } } } } } } } } function check($mouID) { $sql = "select M_CompanyName, M_MouName from m_mou join m_company on M_MouM_CompanyID = M_CompanyID where M_MouID = ?"; $qry = $this->db->query($sql, array($mouID)); if ($qry) { $rows = $qry->result_array(); if (count($rows) > 0 ) { echo $rows[0]["M_CompanyName"] . "\t" . $rows[0]["M_MouName"] . "\n"; $sql = "select t.T_TestID, T_TestSasCode, t.T_TestName, t.T_TestIsActive from ss_price_mou s join t_test t on s.T_TestID = t.T_TestID where Ss_PriceMouM_MouID = ? and px_type = 'PXR'"; $qry = $this->db->query($sql,array($mouID)); if ($qry) { $rows = $qry->result_array(); foreach($rows as $r) { echo $r["T_TestID"] . "\t" . $r["T_TestSasCode"] . "\t" . $r["T_TestName"] . "\t" . $r["T_TestIsActive"] . "\n"; } } } } } }