/** * store contact us * * @return view */ public function emailus() { //1. Get input detail $customer = Input::only('message', 'name', 'email'); //2. Post contact mail $infos = []; foreach ($this->balin['info'] as $key => $value) { $infos[$value['type']] = $value['value']; } $mail = new APISendMail(); $result = $mail->contact($customer, $infos); if (isset($result['message'])) { $this->errors = $result['message']; } $this->page_attributes->success = "Pesan Anda sudah disampaikan pada customer service kami."; return $this->generateRedirectRoute('balin.contact.us'); }
/** * function to sign up by invitation * * @param object view */ public function post($code = "", $link = "") { if (preg_match("/(android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\\.browser|up\\.link|webos|wos)/i", $_SERVER["HTTP_USER_AGENT"])) { $dob = Carbon::createFromFormat('Y-m-d', Input::get('date_of_birth'))->format('Y-m-d H:i:s'); } else { $dob = Carbon::createFromFormat('d-m-Y', Input::get('date_of_birth'))->format('Y-m-d H:i:s'); } $data = ['id' => '', 'name' => Input::get('name'), 'email' => Input::get('email'), 'password' => Input::get('password'), 'date_of_birth' => $dob, 'gender' => Input::get('gender'), 'role' => 'customer', 'reference_code' => $code, 'invitation_link' => $link]; if (Input::has('password')) { $validator = Validator::make(Input::only('password', 'password_confirmation'), ['password' => 'required|min:8|confirmed']); if (!$validator->passes()) { $this->errors = $validator->errors(); $type = 'signup'; } } Session::set('API_token', Session::get('API_token_public')); // API User $API_user = new APIUser(); $user = $API_user->postDataSignUp($data); if ($user['status'] != 'success') { $this->errors = $user['message']; $type = 'signup'; } else { $infos = []; foreach ($this->balin['info'] as $key => $value) { $infos[$value['type']] = $value['value']; } $infos['action'] = route(env('ROUTE_BALIN_CLAIM_VOUCHER'), $user['data']['activation_link']); $mail = new APISendMail(); $result = $mail->welcomemail($user['data'], $infos); if (isset($result['message'])) { $this->errors = $result['message']; $type = 'signup'; } $type = 'login'; } $this->page_attributes->success = "Terima kasih sudah mendaftar, Balin telah mengirimkan hadiah selamat datang untuk Anda melalui email Anda."; return $this->generateRedirectRoute('balin.get.login', ['type' => $type]); }
/** * function to store invitation for others * * @param referral_code */ public function store() { /* get for redirect route to */ $APIUser = new APIUser(); $whoami = $APIUser->getMeDetail(['user_id' => Session::get('whoami')['id']]); $invitations = []; $emails = explode(',', Input::get('emails')); $rules = ['email' => 'required|email|max:255']; foreach ($emails as $key => $value) { $invitation['email'] = trim($value); $validator = Validator::make($invitation, $rules); if (!$validator->passes()) { $this->errors = ['Email "' . $invitation['email'] . '" tidak sah']; return $this->generateRedirectRoute('my.balin.redeem.index'); } $invitations[] = $invitation['email']; } /* array parameter to API */ $data = ['user_id' => Session::get('whoami')['id'], 'invitations' => $emails]; $result = $APIUser->postMeInvitation($data); if (isset($result['message'])) { $this->errors = $result['message']; } else { $infos = []; foreach ($this->balin['info'] as $key => $value) { $infos[$value['type']] = $value['value']; } $infos['action'] = route(env('ROUTE_BALIN_INVITATION_GET'), $whoami['data']['code_referral']); $mail = new APISendMail(); $result = $mail->invitation($whoami['data'], $emails, $infos); if (isset($result['message'])) { $this->errors = $result['message']; } $this->page_attributes->success = 'Anda telah mengirimkan ' . count($emails) . ' undangan kepada teman Anda'; } return $this->generateRedirectRoute('my.balin.redeem.index'); }
/** * resend sale * * @return redirect */ public function sale($id = 0, $status = '') { $APISale = new APISale(); $result = $APISale->getShow($id); if ($result['status'] != 'success') { $this->errors = $result['message']; } $type = 'Email'; $mail = new APISendMail(); switch ($status) { case 'wait': $mail->invoice($result['data'], $this->balininfo()); $type = 'Invoice'; break; case 'paid': $mail->paidorder($result['data'], $this->balininfo()); $type = 'Validasi Pembayaran'; break; case 'shipping': $mail->shippingorder($result['data'], $this->balininfo()); $type = 'Nota Pengiriman'; break; case 'delivered': $mail->deliveredorder($result['data'], $this->balininfo()); $type = 'Konfirmasi Pesanan Delivered'; break; case 'canceled': $mail->cancelorder($result['data'], $this->balininfo()); $type = 'Konfirmasi Pembatalan Pesanan'; break; case 'abandoned': $mail->abandoned($result['data'], $this->balininfo()); $type = 'Email Pengingat'; break; default: $this->errors = 'Status tidak valid'; break; } $this->page_attributes->success = $type . " sudah di kirim "; $from = Input::get('from'); if ($from != null) { return Redirect::to($from)->with('msg', 'Email pengingat berhasil dikirim.')->with('msg-type', 'success'); } return $this->generateRedirectRoute('report.product.sale', ['id' => $id]); }
/** * function to resend activation mail * * @return redirect */ public function activation() { //1. Get Me $APIUser = new APIUser(); $whoami = $APIUser->getMeDetail(['user_id' => Session::get('whoami')['id']]); //2. Whoami if (!$whoami['data']['is_active'] && $whoami['data']['activation_link'] != '') { $infos = []; foreach ($this->balin['info'] as $key => $value) { $infos[$value['type']] = $value['value']; } $infos['action'] = route(env('ROUTE_BALIN_CLAIM_VOUCHER'), $whoami['data']['activation_link']); $mail = new APISendMail(); $result = $mail->welcomemail($whoami['data'], $infos); if (isset($result['message'])) { $this->errors = $result['message']; } } else { $this->errors = 'Akun anda sudah di aktivasi.'; } $this->page_attributes->success = "Email aktivasi sudah dikirim."; return $this->generateRedirectRoute('my.balin.profile'); }
/** * Store a payment notes * * 1. Check transaction * 2. Check input * 3. Store Payment * 4. Check response * 5. Generate view * @param id * @return object view */ public function store($id = null) { //1. Check transaction if (Input::has('transaction_id')) { $saleid = Input::get('transaction_id'); } else { \App::abort(404); } $APISale = new APISale(); $prev_sale = $APISale->getShow($saleid); if ($prev_sale['status'] != 'success') { $this->errors = $prev_sale['message']; return $this->generateRedirectRoute('shop.pay.create'); } $sale = $prev_sale['data']; //2. Check input $inputPayment = Input::only('method', 'destination', 'account_name', 'account_number'); $inputPayment['id'] = ''; $inputPayment['amount'] = $sale['bills']; $inputPayment['ondate'] = date('Y-m-d H:i:s', strtotime(Input::get('ondate'))); $sale['payment'] = $inputPayment; $sale['status'] = 'paid'; //3. Store Payment $result = $APISale->postData($sale); //4. Check response if ($result['status'] != 'success') { $this->errors = $result['message']; } else { $mail = new APISendMail(); $mail->paidorder($result['data'], $this->balininfo()); } //5. Generate view $this->page_attributes->success = ['title' => 'Pesanan sudah divalidasi. ', 'action' => route('report.product.sale.detail', ['id' => $saleid]), 'actionTitle' => 'Klik disini untuk melihat Invoice barang.']; return $this->generateRedirectRoute('admin.dashboard', ['tab' => 'toko']); }
/** * function to resend invoice only order status 'wait' */ public function resend_invoice($id = null) { //1. Get order detail $APIUser = new APIUser(); $order = $APIUser->getMeOrderDetail(['user_id' => Session::get('whoami')['id'], 'order_id' => $id]); //2. Check order if ($order['status'] != 'success') { $this->errors = $order['message']; } else { $infos = []; foreach ($this->balin['info'] as $key => $value) { $infos[$value['type']] = $value['value']; } $mail = new APISendMail(); $result = $mail->invoice($order['data'], $infos); // if (isset($result['message'])) // { // $this->errors = $result['message']; // } } $this->page_attributes->success = "Resend invoice terkirim."; return $this->generateRedirectRoute('my.balin.profile'); }
/** * Store a delivered order * * 1. Check transaction * 2. Check input * 3. Store transaction * 4. Check response * 5. Generate view * @param id * @return object view */ public function store($id = null) { //1. Check transaction if (Input::has('transaction_id')) { $saleid = Input::get('transaction_id'); } else { \App::abort(404); } $APISale = new APISale(); $prev_sale = $APISale->getShow($saleid); if ($prev_sale['status'] != 'success') { $this->errors = $prev_sale['message']; return $this->generateRedirectRoute('shop.shipping.create'); } $sale = $prev_sale['data']; //2. Check input $sale['status'] = 'delivered'; $sale['notes'] = 'Diterima Oleh ' . Input::get('notes'); //3. Store Transction $result = $APISale->postData($sale); //4. Check response if ($result['status'] != 'success') { $this->errors = $result['message']; } else { $mail = new APISendMail(); $mail->deliveredorder($result['data'], $this->balininfo()); } //5. Generate view $this->page_attributes->success = ['title' => 'Pesanan sudah diterima pembeli. ', 'action' => route('report.product.sale.detail', ['id' => $saleid]), 'actionTitle' => 'Klik disini untuk melihat Invoice barang.']; return $this->generateRedirectRoute('admin.dashboard', ['tab' => 'toko']); }