diff --git a/api/application/config/customconfig_one.php b/api/application/config/customconfig_one.php index fa009ba..387abe6 100644 --- a/api/application/config/customconfig_one.php +++ b/api/application/config/customconfig_one.php @@ -49,7 +49,7 @@ else if(ENVIRONMENT == 'production') $config['txn_initiate_url'] = 'https://www.iobnet.co.in/iobpay/apitxninit.do'; $config['txn_status_url'] = 'https://www.iobnet.co.in/iobpay/iobpayRESTService/apitxnstatusservice/gettxnstatus/'; $config['merchant_reply_url'] = 'https://contribute.tnschools.gov.in/csrb/api/receiveIOBPAYResponse'; - $config['referer_url'] = 'https://testapp.iobnet.org'; + $config['referer_url'] = 'https://www.iobnet.co.in'; $config['success_url'] = 'https://contribute.tnschools.gov.in/csr/#/payment-status/success'; $config['failure_url'] = 'https://contribute.tnschools.gov.in/csr/#/payment-status/failure'; diff --git a/api/application/controllers/Iobpay.php b/api/application/controllers/Iobpay.php index 6e3a09e..b72e7fa 100644 --- a/api/application/controllers/Iobpay.php +++ b/api/application/controllers/Iobpay.php @@ -180,9 +180,12 @@ class iobpay extends REST_Controller { if($txnstatus=="SUCCESS") { - $temp_array['msg'] = 'Txn Sucessfull!'; + $temp_array['msg'] = 'Txn Successfull!'; // update FUNS_RECEIVED status against contribute id - $updated = $this->user_management_model->updateRecords(array('status' => 'FUNDS_RECEIVED'),CSR_CONTRIBUTION_DETAILS,array('cont_id' => $contribution_id[0]['con_id'])); + $updated = $this->user_management_model->updateRecords(array('status' => 'FUNDS_RECEIVED'),CSR_CONTRIBUTIONS,array('id' => $contribution_id[0]['con_id'])); + + //update child + $updated = $this->user_management_model->updateRecords(array('status' => 'FUNDS_RECEIVED'),CSR_CONTRIBUTION_DETAILS,array('cont_id' => $contribution_id[0]['con_id'])); header('Location: '.$this->config->item('success_url')); exit; @@ -241,7 +244,8 @@ class iobpay extends REST_Controller if($flag == 'STATUS_CHECK') { - $txn_details = $this->user_management_model->selectCustomRecords(array('trackid','token','amount'),array('merchant_txn_id' => $merchant_txn_id),CSR_TXN_DETAILS); + $txn_details = $this->user_management_model->selectCustomRecords(array('trackid','token','amount','con_id'),array('merchant_txn_id' => $merchant_txn_id),CSR_TXN_DETAILS); + } else if($flag == 'PDF') { @@ -264,6 +268,7 @@ class iobpay extends REST_Controller $totalamt = $txn_details[ (count($txn_details) - 1) ]['amount']; $tokenid = $txn_details[ (count($txn_details) - 1) ]['token']; $trackid = $txn_details[ (count($txn_details) - 1) ]['trackid']; + $con_id = $txn_details[ (count($txn_details) - 1) ]['con_id']; $txn_staus = IOBPAY_UTILITY::checkTxnStatus($this->config->item('txn_status_url'),$merchant_id,$merchant_sub_id,$action,$feetype,$totalamt,$tokenid,$trackid,$sign_key,$encryption_key,$encryption_iv); @@ -285,6 +290,15 @@ class iobpay extends REST_Controller $merchanttxnid = $txn_staus->merchanttxnid; $updated = $this->user_management_model->updateRecords(array('trackid' => $trackid,'txnstatus' => $txnstatus),CSR_TXN_DETAILS,array('merchant_txn_id' => $merchanttxnid)); + if($txnstatus == 'SUCCESS') + { + + //update parent + $updated = $this->user_management_model->updateRecords(array('status' => 'FUNDS_RECEIVED'),CSR_CONTRIBUTIONS,array('id' => $con_id)); + //update child + $updated = $this->user_management_model->updateRecords(array('status' => 'FUNDS_RECEIVED'),CSR_CONTRIBUTION_DETAILS,array('cont_id' => $con_id)); + + } } $result_array = array('ref_id' => $trackid,'txnstatus' => $txnstatus,'amt' => $txn_staus->totalamt,'merchanttxnid' => $merchanttxnid); diff --git a/api/application/models/School_requirement_model.php b/api/application/models/School_requirement_model.php index b1f6782..f907ae7 100644 --- a/api/application/models/School_requirement_model.php +++ b/api/application/models/School_requirement_model.php @@ -163,8 +163,9 @@ class school_requirement_model extends Custom_Model { // echo $no_of_schools_posted; // echo $total_amount_required; - $query = "SELECT count(distinct user_id) as supporters,sum(amount) as contributed_amount,(SELECT count(distinct school_id) FROM ".CSR_SCHOOL_REQUIREMENTS.") as no_of_schools_posted,(SELECT sum((qty * CSR_MATERIAL_MASTER.cost_per_unit)) as required_amount FROM ".CSR_SCHOOL_REQUIREMENTS." as CSR_SCHOOL_REQUIREMENTS LEFT JOIN ".CSR_MATERIAL_MASTER." as CSR_MATERIAL_MASTER on CSR_SCHOOL_REQUIREMENTS.mat_id = CSR_MATERIAL_MASTER.id) as total_amount_required FROM ".CSR_CONTRIBUTIONS.""; + $query = "SELECT count(distinct user_id) as supporters,ifnull(sum(amount),0) as contributed_amount,(SELECT count(distinct school_id) FROM ".CSR_SCHOOL_REQUIREMENTS.") as no_of_schools_posted,(SELECT sum((qty * CSR_MATERIAL_MASTER.cost_per_unit)) as required_amount FROM ".CSR_SCHOOL_REQUIREMENTS." as CSR_SCHOOL_REQUIREMENTS LEFT JOIN ".CSR_MATERIAL_MASTER." as CSR_MATERIAL_MASTER on CSR_SCHOOL_REQUIREMENTS.mat_id = CSR_MATERIAL_MASTER.id WHERE CSR_SCHOOL_REQUIREMENTS.isactive = 1) as total_amount_required FROM ".CSR_CONTRIBUTIONS." as CSR_CONTRIBUTIONS WHERE CSR_CONTRIBUTIONS.status= 'FUNDS_RECEIVED'OR CSR_CONTRIBUTIONS.status= 'MAT_RECEIVED'"; return $this->db->query($query)->result_array()[0]; + print_r($this->db->last_query()); } diff --git a/api/application/models/User_management_model.php b/api/application/models/User_management_model.php index 18dcda2..a2dab25 100644 --- a/api/application/models/User_management_model.php +++ b/api/application/models/User_management_model.php @@ -16,7 +16,7 @@ class user_management_model extends Custom_Model { //$contributions = $this->user_management_model->selectCustomRecords(array('id', 'user_id', 'cont_type', 'cont_towards', 'amount', 'payment_mode', 'payment_ref','gen_dev_fund_remarks', 'mat_delivery_point', 'mat_delivery_date','DATE_FORMAT(timestamp,"%d-%m-%Y %h:%i %p") as contribute_date'),array('user_id' => $userid),CSR_CONTRIBUTIONS); - $this->db->SELECT('CSR_CONTRIBUTIONS.id, CSR_CONTRIBUTIONS.user_id, CSR_CONTRIBUTIONS.cont_type, CSR_CONTRIBUTIONS.cont_towards, CSR_CONTRIBUTIONS.amount, CSR_CONTRIBUTIONS.amount, CSR_CONTRIBUTIONS.payment_mode,CSR_CONTRIBUTIONS.payment_ref,CSR_CONTRIBUTIONS.gen_dev_fund_remarks,CSR_CONTRIBUTIONS.mat_delivery_point,CSR_CONTRIBUTIONS.mat_delivery_date,DATE_FORMAT(convert_tz(CSR_CONTRIBUTIONS.timestamp,"+00:00","+05:30"),"%d-%m-%Y %h:%i %p") as contribute_date,CSR_TXN_DETAILS.merchant_txn_id,CSR_TXN_DETAILS.txnstatus,concat(DATE_FORMAT(convert_tz(CSR_CONTRIBUTIONS.timestamp,"+00:00","+05:30"),"%Y%m%d"),CSR_TXN_DETAILS.merchant_txn_id) as ref_id,CSR_TXN_DETAILS.trackid'); + $this->db->SELECT('CSR_CONTRIBUTIONS.id, CSR_CONTRIBUTIONS.user_id, CSR_CONTRIBUTIONS.cont_type, CSR_CONTRIBUTIONS.cont_towards, CSR_CONTRIBUTIONS.amount, CSR_CONTRIBUTIONS.amount, CSR_CONTRIBUTIONS.payment_mode,CSR_CONTRIBUTIONS.payment_ref,CSR_CONTRIBUTIONS.gen_dev_fund_remarks,CSR_CONTRIBUTIONS.mat_delivery_point,CSR_CONTRIBUTIONS.mat_delivery_date,DATE_FORMAT(convert_tz(CSR_CONTRIBUTIONS.timestamp,"+00:00","+05:30"),"%d-%m-%Y %h:%i %p") as contribute_date,CSR_TXN_DETAILS.merchant_txn_id,CSR_TXN_DETAILS.txnstatus,concat(DATE_FORMAT(convert_tz(CSR_CONTRIBUTIONS.timestamp,"+00:00","+05:30"),"%Y%m%d"),CSR_TXN_DETAILS.merchant_txn_id) as ref_id,CSR_TXN_DETAILS.trackid,CSR_CONTRIBUTIONS.payment_type,CSR_CONTRIBUTIONS.payment_date,CSR_CONTRIBUTIONS.bank_branch,CSR_CONTRIBUTIONS.mode_of_deposit,CSR_CONTRIBUTIONS.cheque_drop_address'); $this->db->FROM(CSR_CONTRIBUTIONS.' as CSR_CONTRIBUTIONS'); $this->db->JOIN(CSR_TXN_DETAILS.' as CSR_TXN_DETAILS','CSR_CONTRIBUTIONS.id = CSR_TXN_DETAILS.con_id','LEFT'); $this->db->WHERE('CSR_CONTRIBUTIONS.user_id',$userid);