From 538b394d63b476d8af8f2bf7bebbee08ac59b64b Mon Sep 17 00:00:00 2001 From: Velz2020 Date: Mon, 17 Feb 2020 17:21:04 +0530 Subject: [PATCH] AUTO RECEIPT CALLED --- api/application/controllers/Iobpay.php | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/api/application/controllers/Iobpay.php b/api/application/controllers/Iobpay.php index 67df8a9..dccebe0 100644 --- a/api/application/controllers/Iobpay.php +++ b/api/application/controllers/Iobpay.php @@ -197,6 +197,9 @@ class iobpay extends REST_Controller //update child $updated = $this->user_management_model->updateRecords(array('status' => 'FUNDS_RECEIVED'),CSR_CONTRIBUTION_DETAILS,array('cont_id' => $contribution_id[0]['con_id'])); + + //prepare receipt + $this->prepareReceipt($merchanttxnid,false); //trigger mail $this->sendMail('SUCCESS',$merchanttxnid); @@ -429,7 +432,7 @@ class iobpay extends REST_Controller } - function prepareReceipt($merchant_txn_id) + function prepareReceipt($merchant_txn_id,$response = true) { $this->db->SELECT('CSR_TXN_DETAILS.trackid,ROUND(CSR_TXN_DETAILS.amount,0) as amount,CSR_TXN_DETAILS.txnstatus,CSR_USER.name,CSR_USER_ORG.org_pan,DATE_FORMAT(convert_tz(CSR_TXN_DETAILS.createdon,"+00:00","+05:30"),"%d-%m-%Y") as txn_date,concat(DATE_FORMAT(convert_tz(CSR_TXN_DETAILS.createdon,"+00:00","+05:30"),"%Y%m%d"),CSR_TXN_DETAILS.merchant_txn_id) as ref_id,CSR_TXN_DETAILS.is_receipt'); @@ -468,18 +471,25 @@ class iobpay extends REST_Controller { $singed_uri = $this->aws_s3->get_s3_url(SCHOOL_BUCKET_NAME,CSR_RECEIPT_FOLDERNAME.'/'.$merchant_txn_id.'.pdf'); $this->user_management_model->updateRecords(array('is_receipt ' => 1),CSR_TXN_DETAILS,array('merchant_txn_id' => $merchant_txn_id)); - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $singed_uri; - //$data['records'] = array('pdf_url' => $singed_uri,'zip_url' => $zip_file_uri); - $this->response($data,REST_Controller::HTTP_OK); + + if($response) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $singed_uri; + //$data['records'] = array('pdf_url' => $singed_uri,'zip_url' => $zip_file_uri); + $this->response($data,REST_Controller::HTTP_OK); + } } else { + if($response) + { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; $data['msg'] = 'Something Went Wrong..!Try later'; $this->response($data,REST_Controller::HTTP_OK); + } } } @@ -520,7 +530,7 @@ class iobpay extends REST_Controller $this->zip->archive(APPPATH.'/views/receipts.zip'); - $this->zip->download($filename); + $this->zip->download('receipts.zip'); // $response_data['dataStatus'] = true; // $response_data['status'] = REST_Controller::HTTP_OK;