Untitled
unknown
php
3 years ago
7.1 kB
9
Indexable
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Funnel extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->library('form_validation');
}
public function kursus_digital_marketing_autopilot()
{
$this->load->view('pages/funnel/kursus_digital_marketing_autopilot');
}
public function seminar_business_online_autopilot()
{
$this->load->view('pages/funnel/seminar_business_online_autopilot');
}
public function webinar_bangun_bisnis_autopilot()
{
$this->load->view('pages/funnel/webinar_bangun_bisnis_autopilot');
}
public function workshop_bangun_bisnis_autopilot()
{
$this->load->view('pages/funnel/workshop_bangun_bisnis_autopilot');
}
public function workshop_digital_marketing_autopilot()
{
$this->load->view('pages/funnel/workshop_digital_marketing_autopilot');
}
public function custom()
{
$this->load->view('pages/funnel/custom');
}
public function register_member_event()
{
$output['hasil'] = 0;
$name = anti_injection($this->input->post("name"));
$email = anti_injection($this->input->post("email"));
$phoneNumber = anti_injection($this->input->post("phone"));
$phoneNumbers = anti_injection($this->input->post("phonenumbers"));
$refferal = anti_injection($this->input->post("refferal"));
$funnelId = anti_injection($this->input->post("funnel_id"));
$decodedFunnelId = base64_decode($funnelId);
if ($this->form_validation->run('funnel/register') == FALSE) {
$output['error'] = $this->form_validation->error_array();
} elseif ($funnelId >= 1 && $funnelId <= 5) {
$this->db->select('tanggal')->from('landing_page')->where('funnel_id =' . $decodedFunnelId);
$tanggal1 = $this->db->get()->row_array();
$tanggal = $tanggal1['tanggal'];
$data = [
'funnel_id' => $decodedFunnelId,
'refferal_code' => trim($refferal),
// 'phonenumbers' => trim($phoneNumbers),
'name' => trim($name),
'email' => trim($email),
'phone_number' => trim($phoneNumber),
'tanggal' => trim($tanggal),
];
} else {
$this->db->select('tanggal')->from('landingpage_custom')->where('ref', $refferal);
$tanggal1 = $this->db->get()->row_array();
$tanggal = $tanggal1['tanggal'];
$data = [
'funnel_id' => $decodedFunnelId,
'refferal_code' => trim($refferal),
// 'phonenumbers' => trim($phoneNumbers),
'name' => trim($name),
'email' => trim($email),
'phone_number' => trim($phoneNumber),
'tanggal' => trim($tanggal),
];
// if ($this->db->insert('event_member', $data)) {
if ($this->db->insert('event_member', $data) && $data['funnel_id'] >= 1 && $data['funnel_id'] <= 5) {
// $this->db->insert('table', $data)
$output['hasil'] = 1;
$output['pesan'] = 'Registrasi Anda berhasil';
// Event
$this->db->select('nama')->from('landing_page')->where('funnel_id =' . $decodedFunnelId);
$event1 = $this->db->get()->row_array();
$event = $event1['nama'];
// Tanggal
$this->db->select('tanggal')->from('landing_page')->where('funnel_id =' . $decodedFunnelId);
$tanggal1 = $this->db->get()->row_array();
$tanggal = $tanggal1['tanggal'];
// Jam
$this->db->select('jam')->from('landing_page')->where('funnel_id =' . $decodedFunnelId);
$jam1 = $this->db->get()->row_array();
$jam = $jam1['jam'];
// Tempat
$this->db->select('tempat')->from('landing_page')->where('funnel_id =' . $decodedFunnelId);
$tempat1 = $this->db->get()->row_array();
$tempat = $tempat1['tempat'];
// Pengundang
$this->db->select('fullname')->from('member')->where('phone_number =' . $phoneNumber);
$pengundang1 = $this->db->get()->row_array();
$pengundang = $pengundang1['fullname'];
$text = "Selamat " . $name . " 👋\nAnda telah berhasil mendaftar *" . $event . "*\nDetail event pada:\n\n🗓️ *: " . $tanggal . "*\n⏰ *: " . $jam . "*\n📍 *: " . $tempat . "*\n\nInformasi selanjutkan akan segera disampaikan oleh tim kami🙏";
$text2 = "Selamat " . $pengundang . " 👋\nAnda telah berhasil mengundang " . $name . " ke dalam *" . $event . "*. Harap segera difollow up ya\n\nKontak: *" . $phoneNumber . "*";
$this->_sendToWa($phoneNumber, $text);
$this->_sendToWaS($phoneNumbers, $text2);
} elseif ($this->db->insert('event_member', $data) && $data['funnel_id'] = 6) {
$output['hasil'] = 1;
$output['pesan'] = 'Registrasi Anda berhasil';
// Event
$this->db->select('event')->from('landingpage_custom')->where('ref', $refferal);
$event1 = $this->db->get()->row_array();
$event2 = $event1['event'];
// Tanggal
$this->db->select('tanggal')->from('landingpage_custom')->where('ref', $refferal);
$tanggal1 = $this->db->get()->row_array();
$tanggal2 = $tanggal1['tanggal'];
// Jam
$this->db->select('jam')->from('landingpage_custom')->where('ref', $refferal);
$jam1 = $this->db->get()->row_array();
$jam2 = $jam1['jam'];
// Tempat
$this->db->select('tempat')->from('landingpage_custom')->where('ref', $refferal);
$tempat1 = $this->db->get()->row_array();
$tempat2 = $tempat1['tempat'];
// Pengundang
$this->db->select('fullname')->from('member')->where('phone_number =' . $phoneNumber);
$pengundang1 = $this->db->get()->row_array();
$pengundang2 = $pengundang1['fullname'];
$text = "Selamat " . $name . " 👋\nAnda telah berhasil mendaftar *" . $event2 . "*\nDetail event pada:\n\n🗓️ *: " . $tanggal2 . "*\n⏰ *: " . $jam2 . "*\n📍 *: " . $tempat2 . "*\n\nInformasi selanjutkan akan segera disampaikan oleh tim kami🙏";
$text2 = "Selamat " . $pengundang2 . " 👋\nAnda telah berhasil mengundang " . $name . " ke dalam *" . $event2 . "*. Harap segera difollow up ya\n\nKontak: *" . $phoneNumber . "*";
$this->_sendToWa($phoneNumber, $text);
$this->_sendToWaS($phoneNumbers, $text2);
} else {
$output['pesan'] = 'Registrasi akun gagal, mohon coba kembali.';
}
}
echo json_encode($output);
}
private function _sendToWa($phone, $text)
{
$url = 'https://starsender.online/api/sendText';
$ch = curl_init($url);
$wa_no = $phone;
$wa_text = $text;
$data = array(
'apikey' => '0821ac66e37c835d360edc8f7a2ad2e5e7010e2e',
'tujuan' => $wa_no,
'message' => $wa_text,
);
$payload = $data;
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
}
private function _sendToWaS($phone, $text)
{
$url = 'https://starsender.online/api/sendText';
$ch = curl_init($url);
$wa_no = $phone;
$wa_text = $text;
$data = array(
'apikey' => '0821ac66e37c835d360edc8f7a2ad2e5e7010e2e',
'tujuan' => $wa_no,
'message' => $wa_text,
);
$payload = $data;
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
}
}
Editor is loading...