Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2018
397
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.07 KB | None | 0 0
  1. <?php
  2. date_default_timezone_set('Asia/Jakarta');
  3. if (!defined('BASEPATH'))
  4. exit('No direct script access allowed');
  5.  
  6. class Order extends CI_Controller
  7. {
  8.  
  9. /*
  10. * Developed by: Active IT zone
  11. * Date : 14 July, 2015
  12. * Active Supershop eCommerce CMS
  13. * http://codecanyon.net/user/activeitezone
  14. */
  15.  
  16.  
  17. function __construct()
  18. {
  19. parent::__construct();
  20. //$this->output->enable_profiler(TRUE);
  21. $this->load->database();
  22. //echo $_COOKIE['lang'];
  23. }
  24.  
  25. function checkdatapost(){
  26. $data = $this->input->post();
  27. var_dump($data);
  28. }
  29. function create_order(){
  30. //var_dump($this->input->post());
  31. $emailConfig = [
  32. 'protocol' => 'smtp',
  33. 'smtp_host' => 'ssl://smtp.googlemail.com',
  34. 'smtp_port' => 465,
  35. 'smtp_user' => 'order.unimaxx@gmail.com',
  36. 'smtp_pass' => 'tahubulat500',
  37. 'mailtype' => 'html',
  38. 'charset' => 'iso-8859-1'
  39. ];
  40. // Set SMTP Configuration
  41. // Set your email information
  42. if (isset($_GET['createorder'])) {
  43. $from = [
  44. 'email' => 'order_system@unimaxx.id',
  45. 'name' => 'UNIMAXX Customer ORDER'
  46. ];
  47.  
  48. $to = array('order@unimaxx.id');
  49. $subject = 'UNIMAXX Customer ORDER';
  50. }else{
  51. $from = [
  52. 'email' => 'order_system@unimaxx.id',
  53. 'name' => 'UNIMAXX Daftar Mitra'
  54. ];
  55.  
  56. $to = array('cs.mitra@unimaxx.id');
  57. $subject = 'UNIMAXX Daftar Mitra';
  58.  
  59. }
  60. $bcc = array('henrylamsihar@gmail.com','yogapermana.s12@gmail.com');
  61. //$to = array('bernhard.gurning@unikas.co.id','bernhard.gurning@gmail.com');
  62. //$message = 'Type your gmail message here'; // use this line to send text email.
  63. // load view file called "welcome_message" in to a $message variable as a html string.
  64.  
  65. $data = $this->input->post();
  66. $buyerdata= array_slice($data,2,13);
  67. $temp2['Json'] = json_encode($buyerdata);
  68. $productdata= array_slice($data,0,2);
  69. $temp3['Json'] = json_encode($productdata);
  70. $password = substr($data['email'], 0, strpos($data['email'], '@'));
  71. $randomstring = substr(str_shuffle(str_repeat($x='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil(3/strlen($x)) )),1,3);
  72. $password = "$password$randomstring";
  73. $lat1 = $data['lat'];
  74. $lon1 = $data['lon'];
  75. $latlon = "$lat1/$lon1";
  76. $dataemailpass = array (
  77. 'name' => $data['name'],
  78. 'email' => $data['email'],
  79. 'password' => $password
  80. );
  81.  
  82. //var_dump($password);
  83. $datasale = array(
  84. 'sale_code' => '0',
  85. 'buyer' => $temp2['Json'],
  86. 'shipping_address' => $data['alamat'],
  87. 'sale_datetime' => date('Y-m-d H:i:s T'),
  88. 'product_details' => $temp3['Json'],
  89. 'vat' => '0',
  90. 'vat_percent' => '0',
  91. 'shipping' => '0',
  92. 'payment_type' => '0',
  93. 'payment_status' => '0',
  94. 'payment_details' => '0',
  95. 'payment_timestamp' => '0',
  96. 'grand_total' => '0',
  97. 'delivary_datetime' => '0',
  98. 'delivery_status' => 'belum dikirim',
  99. 'viewed' => '0'
  100. );
  101.  
  102. $datauser = array(
  103. 'user_id' => '0',
  104. 'username' => $data['email'],
  105. 'surname ' => $data['name'],
  106. 'email' => $data['email'],
  107. 'phone' => $data['telp'],
  108. 'address1' => $data['alamat'],
  109. 'address2' => '0',
  110. 'city' => '0',
  111. 'zip' => '0',
  112. 'langlat' => "$latlon",
  113. 'password' => sha1($password),
  114. 'fb_id' => '0',
  115. 'g_id' => '0',
  116. 'g_photo' => '0',
  117. 'creation_date' => '0',
  118. 'google_plus' => '0',
  119. 'skype' => '0',
  120. 'facebook' => '0',
  121. 'wishlist' => '0',
  122. 'last_login' => '0',
  123. 'user_type' => '0',
  124. 'user_type_till' => '0',
  125. 'left_product_type' => '0',
  126. 'downloads' => '0',
  127. 'country'=> '0',
  128. 'state'=> '0',
  129. );
  130.  
  131. //var_dump($data);
  132. $message = $this->load->view('email_template/billing',$data,TRUE);
  133. // Load CodeIgniter Email library
  134. $this->load->library('email', $emailConfig);
  135. // Sometimes you have to set the new line character for better result
  136. $this->email->set_newline("\r\n");
  137. // Set email preferences
  138. $this->email->from($from['email'], $from['name']);
  139. $this->email->to($to);
  140. if($data['email'] != "nharits74@gmail.com"){
  141. $this->email->bcc($bcc);
  142. }
  143. $this->email->subject($subject);
  144. $this->email->message($message);
  145. // Ready to send email and check whether the email was successfully sent
  146. $mailStatus = "";
  147. $temp = [];
  148. $temp['Json'] = json_encode($data);
  149. $this->crud_model->insertOrderTemp($temp);
  150.  
  151. if (!$this->email->send()) {
  152. // Raise error message
  153. $mailStatus = "error => ".substr($this->email->print_debugger(), 0, 240);
  154. $data['EmailStatus']= $mailStatus;
  155. $this->crud_model->insertOrder($datasale);
  156. $this->crud_model->insertUserFromOrder($datauser);
  157. // show_error($this->email->print_debugger());
  158. } else {
  159. // Show success notification or other things here
  160.  
  161. $mailStatus = "Ok";
  162. $data['EmailStatus']= $mailStatus;
  163. if (!isset($_GET['createorder'])) {
  164. $this->crud_model->insertOrder($datasale);
  165. $this->crud_model->insertUserFromOrder($datauser);
  166. $this->emailUser(isset($_GET['createorder']),$data,$emailConfig);
  167. $this->akunUser(isset($_GET['createorder']),$dataemailpass,$emailConfig);
  168. echo "Terima kasih sudah mendaftar menjadi Mitra UNIMAXX. Staff kami akan segera menghubungi Anda.";
  169. }else{
  170. $this->crud_model->insertOrder($datasale);
  171. $this->crud_model->insertUserFromOrder($datauser);
  172. if ($this->session->userdata('user_login')=='yes') {
  173. echo "Terima kasih Anda telah memesan produk Unimaxx. Staff kami akan segera menghubungi Anda";
  174. }else{
  175. $this->emailUser(isset($_GET['createorder']),$data,$emailConfig);
  176. $this->akunUser(isset($_GET['createorder']),$dataemailpass,$emailConfig);
  177. echo "Terima kasih Anda telah memesan produk Unimaxx. Staff kami akan segera menghubungi Anda";
  178. }
  179. }
  180. }
  181. //var_dump($data);
  182. }
  183.  
  184. function emailUser($createorder,$data,$emailConfig){
  185. if (isset($_GET['createorder'])) {
  186. $from = [
  187. 'email' => 'order_system@unimaxx.id',
  188. 'name' => 'UNIMAXX Customer ORDER'
  189. ];
  190.  
  191. $to = array($data['email']);
  192. $subject = 'Konfirmasi Pemesanan Barang Unimaxx';
  193. $message = $this->load->view('email_template/emailuserproduk',$data,TRUE);
  194. }else{
  195. $from = [
  196. 'email' => 'order_system@unimaxx.id',
  197. 'name' => 'UNIMAXX Daftar Mitra'
  198. ];
  199.  
  200. $to = array($data['email']);
  201. $subject = 'Konfirmasi Pendaftaran Mitra Unimaxx';
  202. $message = $this->load->view('email_template/emailusermitra',$data,TRUE);
  203. }
  204.  
  205. // $to = array('bernhard.gurning@unikas.co.id','bernhard.gurning@gmail.com');
  206. // $message = 'Type your gmail message here'; // use this line to send text email.
  207. // load view file called "welcome_message" in to a $message variable as a html string.
  208. $bcc = array('henrylamsihar@gmail.com','yogapermana.s12@gmail.com');
  209.  
  210.  
  211.  
  212. //var_dump($data);
  213. // Load CodeIgniter Email library
  214. $this->load->library('email', $emailConfig);
  215. // Sometimes you have to set the new line character for better result
  216. $this->email->set_newline("\r\n");
  217. // Set email preferences
  218. $this->email->from($from['email'], $from['name']);
  219. $this->email->to($to);
  220. if($data['email'] != "nharits74@gmail.com"){
  221. $this->email->bcc($bcc);
  222. }
  223. $this->email->subject($subject);
  224. $this->email->message($message);
  225. // Ready to send email and check whether the email was successfully sent
  226. $mailStatus = "";
  227. if (!$this->email->send()) {
  228. // Raise error message
  229. $mailStatus = "error => ".substr($this->email->print_debugger(), 0, 240);
  230. // show_error($this->email->print_debugger());
  231. } else {
  232. // Show success notification or other things here
  233. // echo '<div style="left:0;right:0;display:block;">Pesanan anda sedang di proses oleh pihak kami. Staff kami akan segera menghubungi anda </br> halaman akan kembali ke beranda setelah 2 detik ,jika tidak kembali <a href="'.base_url().'">tekan di sini</a></div>';
  234. $mailStatus = "Ok";
  235. }
  236. $data['EmailStatus']= $mailStatus;
  237. }
  238.  
  239. //kirim password user
  240. function akunUser($createorder,$data,$emailConfig){
  241. if (isset($_GET['createorder'])) {
  242. $from = [
  243. 'email' => 'order_system@unimaxx.id',
  244. 'name' => 'UNIMAXX Customer ACCOUNT'
  245. ];
  246.  
  247. $to = array($data['email']);
  248. $subject = 'Username dan Password Akun Untuk Login Website onoMart';
  249. $message = $this->load->view('email_template/emailpassworduser',$data,TRUE);
  250. }else{
  251. $from = [
  252. 'email' => 'order_system@unimaxx.id',
  253. 'name' => 'UNIMAXX Daftar Mitra'
  254. ];
  255.  
  256. $to = array($data['email']);
  257. $subject = 'Konfirmasi Pendaftaran Mitra Unimaxx';
  258. $message = $this->load->view('email_template/emailusermitra',$data,TRUE);
  259.  
  260. }
  261.  
  262. // $to = array('bernhard.gurning@unikas.co.id','bernhard.gurning@gmail.com');
  263. // $message = 'Type your gmail message here'; // use this line to send text email.
  264. // load view file called "welcome_message" in to a $message variable as a html string.
  265. $bcc = array('henrylamsihar@gmail.com','yogapermana.s12@gmail.com');
  266.  
  267. //var_dump($data);
  268. // Load CodeIgniter Email library
  269. $this->load->library('email', $emailConfig);
  270. // Sometimes you have to set the new line character for better result
  271. $this->email->set_newline("\r\n");
  272. // Set email preferences
  273. $this->email->from($from['email'], $from['name']);
  274. $this->email->to($to);
  275. if($data['email'] != "nharits74@gmail.com"){
  276. $this->email->bcc($bcc);
  277. }
  278. $this->email->subject($subject);
  279. $this->email->message($message);
  280. // Ready to send email and check whether the email was successfully sent
  281. $mailStatus = "";
  282. if (!$this->email->send()) {
  283. // Raise error message
  284. $mailStatus = "error => ".substr($this->email->print_debugger(), 0, 240);
  285. // show_error($this->email->print_debugger());
  286. } else {
  287. // Show success notification or other things here
  288. // echo '<div style="left:0;right:0;display:block;">Pesanan anda sedang di proses oleh pihak kami. Staff kami akan segera menghubungi anda </br> halaman akan kembali ke beranda setelah 2 detik ,jika tidak kembali <a href="'.base_url().'">tekan di sini</a></div>';
  289. $mailStatus = "Ok";
  290. }
  291. $data['EmailStatus']= $mailStatus;
  292. }
  293.  
  294.  
  295. function alertconfirm(){
  296. $data['massage'] = "Terima kasih sudah mendaftar menjadi Mitra UNIMAXX. Staff kami akan segera menghubungi Anda.";
  297. $this->load->view('front/components/order/alert',$data,false);
  298. }
  299.  
  300. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement