Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.89 KB | None | 0 0
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: user
  5. * Date: 7/25/2018
  6. * Time: 3:56 PM
  7. */
  8.  
  9. class InvoiceConfirmationPublic extends CI_Controller
  10. {
  11. /**
  12. * InvoiceDetail constructor.
  13. */
  14. public function __construct()
  15. {
  16. parent::__construct();
  17. $this->load->model('invoice/InvoiceConfirmation_model', 'invoiceConfirmM');
  18. $this->load->model('invoice/Invoice_model', 'invoiceM');
  19. $this->load->model('core/Upload_model', 'uploadM');
  20. $this->load->model('mailing/FormEmail_model', 'emailForm');
  21. $this->load->model('core/Setting_model', 'settingM');
  22. //$this->load->library('recaptcha');
  23. }
  24.  
  25. /**
  26. * Payment confirmation form
  27. *
  28. * @param string $token
  29. */
  30. function index($token=""){
  31.  
  32. $data['token'] = $token;
  33. $this->db->where('token', $token);
  34. $cekConfirm = $this->db->get('invoice_confirmation');
  35. $data['cekConf'] = $cekConfirm->result();
  36.  
  37. if(!$token){
  38. redirect_error("confirmation-new","Mohon terlebih dahulu lengkapi data nomor invoice dan email");
  39. }
  40.  
  41. $data['invoice'] = "";
  42. if($token){
  43. $this->invoiceM->mydb->params = array('relation_description'=>$token);
  44. $invoiceDetail = $this->invoiceM->mydb->get()[0];
  45. $data['invoice'] = $invoiceDetail;
  46. }
  47.  
  48. $this->settingM->mydb->params = array(
  49. 'setting_group' => 'bank-tujuan'
  50. );
  51. $setting = $this->settingM->mydb->get();
  52. $data['bankTujuan'] = $setting;
  53.  
  54. $this->settingM->mydb->params = array(
  55. 'setting_key' => 'confirm-payment-bank-description'
  56. );
  57. $settingBankTujuaDesc = $this->settingM->mydb->get()[0]['setting_value'];
  58. $data['bankTujuanDesc'] = $settingBankTujuaDesc;
  59.  
  60.  
  61.  
  62. $this->load->view('core/header-public');
  63. $this->load->view('core/menu-public');
  64. $this->load->view('finance/invoice_confirmation_form',$data);
  65. $this->load->view('core/footer-challange');
  66.  
  67. }
  68.  
  69. /**
  70. * New confirmation form
  71. */
  72. function newForm(){
  73. $this->load->view('core/header-public');
  74. $this->load->view('core/menu-public');
  75. $this->load->view('finance/new_confirmation');
  76. $this->load->view('core/footer-challange');
  77. }
  78.  
  79. /**
  80. * New confirmation submit
  81. */
  82. function newSubmit(){
  83. $invoice_number=$this->input->post('invoice_number');
  84. $email=$this->input->post('email');
  85.  
  86. if($invoice_number && $email){
  87.  
  88. $invoice_number=str_replace("#","",$invoice_number);
  89. $invoice_number=intval($invoice_number);
  90.  
  91. if($invoice_number > 0){
  92. $this->invoiceM->mydb->params = array(
  93. 'invoice_id' => $invoice_number,
  94. 'to_subtitle' => $email
  95. );
  96. $invoiceGet = $this->invoiceM->mydb->get();
  97. }else{
  98. redirect_error("confirmation-new","Nomor invoice tidak ditemukan");
  99. }
  100.  
  101.  
  102.  
  103. if($invoiceGet){
  104. if($invoiceGet[0]['status']!="unpaid"){
  105. redirect_error("confirmation-new","Status invoice sudah terbayarkan/sudah dibatalkan.");
  106. }else{
  107. redirect_success("confirmation/".$invoiceGet[0]['relation_description'],"Silakan lengkapi data konfirmasi");
  108. }
  109. }else{
  110. redirect_error("confirmation-new","Data invoice tidak ditemukan");
  111. }
  112.  
  113. }else{
  114. redirect_error("confirmation-new","Data tidak lengkap");
  115. }
  116.  
  117. }
  118.  
  119. /**
  120. * Process the confirmation
  121. */
  122. function submit(){
  123.  
  124. $data = $this->input->post();
  125. $token="";
  126. if($data['token']){
  127. $token=$data['token'];
  128. }
  129.  
  130. //$verify = $this->recaptcha->verify($data);
  131.  
  132. // captcha
  133. // if(!$verify['success']){
  134. // redirect_error('confirmation','Captcha gagal. Coba lagi!');
  135. // }
  136.  
  137. //Upload file
  138. if($data['invoice_number']){
  139. if(!$_FILES['file']['name']){
  140. // $data['file'] = "";
  141.  
  142. redirect_error('confirmation/'.$token,'Upload file gagal, coba lagi !');
  143. }else{
  144. $dataUpload = $this->uploadM->uploadFileSingle('file',"resources/media");
  145. if($dataUpload['code']=="200"){
  146. $data['file'] = '/resources/media/'.$dataUpload['data']['file_name'];
  147. }else{
  148. $data['file'] = "";
  149. }
  150. }
  151. }
  152.  
  153. if(!$data['file']){
  154. redirect_error('confirmation/'.$token,'Upload file gagal, mohon coba dengan file lebih kecil');
  155. }
  156.  
  157. //We dont need this on database
  158. //unset($data['g-recaptcha-response']);
  159.  
  160. $confirmProcess = $this->invoiceConfirmM->mydb->add($data);
  161. if($confirmProcess){
  162.  
  163. //Send email that we've just received your confirmation
  164. //$dataEmail['email'] = $emailThis;
  165. //$dataEmail['invoice_number'] = $data['invoice_number'];
  166. //$this->emailForm->send($dataEmail);
  167.  
  168. if($data['token']){
  169. redirect_success('confirmation-done','Success submit payment confirmation');
  170.  
  171. }else{
  172. redirect_success('confirmation-done','Success submit payment confirmation');
  173. }
  174.  
  175. }else{
  176. redirect_error('finance/InvoiceConfirmationPublic/index/'.$data['token'],'Failed submit payment confirmation');
  177. }
  178.  
  179. }
  180.  
  181. function confirmDone(){
  182. $this->load->view('core/header-public');
  183. $this->load->view('core/menu-public');
  184. $this->load->view('finance/confirm_done');
  185. $this->load->view('core/footer-challange');
  186. }
  187.  
  188. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement