Edit setiap model Produk yang ingin di Protek
Ganti isi kode setelah:
// General $this->load->model('order_model'); $this->order_model->set_rules(strtolower(class));
dengan kode berikut sesuai template yang digunakan:
// Ambil id pelanggan dari input $id_plgn = $this->input->post('id_plgn'); // Cek apakah id pelanggan sudah ada dalam cache (dipost dalam 5 menit terakhir) $cache_key = 'submitted_numbers_' . $id_plgn; $submitted_numbers = $this->cache->get($cache_key); if ($submitted_numbers && (time() - $submitted_numbers) < 300) { // id pelanggan sudah dipost dalam 5 menit terakhir, tampilkan pesan error $this->form_validation->set_rules('id_plgn', $id_label, array( 'check_cache', array('id_plgn', array($this->token_pln_model, 'check_cache')), // Wajib ganti nama 'token_pln_model' dengan nama model produk )); } if ($this->form_validation->run() != false) { // Jika validasi berhasil, id pelanggan dan waktu dalam cache $this->cache->save($cache_key, time(), 300); // 300 detik (5 menit) $values = array( 'tr_no_hp' => $this->input->post('nomor_hp'), 'tr_id_plgn' => $this->input->post('id_plgn'), ); // h2h center Qm, hapus ini jika tidak menggunakan h2h center qm $this->load->model('qm/h2h_center_model', 'h2h'); $values = $this->h2h->trx_h2h($values); // h2h center end return $this->order_model->insert($values); } return 0;
Script untuk template no_hp:
// Ambil nomor HP dari input $nomor_hp = $this->input->post('nomor_hp'); // Cek apakah nomor HP sudah ada dalam cache (dipost dalam 5 menit terakhir) $cache_key = 'submitted_numbers_' . $nomor_hp; $submitted_numbers = $this->cache->get($cache_key); if ($submitted_numbers && (time() - $submitted_numbers) < 300) { // Nomor HP sudah dipost dalam 5 menit terakhir, tampilkan pesan error $this->form_validation->set_rules('nomor_hp', 'Nomor HP', array( 'check_cache', array('hp', array($this->dana_model, 'check_cache')), // Wajib ganti nama 'dana_model' dengan nama model produk )); } if ($this->form_validation->run() != false) { // Jika validasi berhasil, simpan nomor HP dan waktu dalam cache $this->cache->save($cache_key, time(), 300); // 300 detik (5 menit) $values = array('tr_no_hp' => $nomor_hp); // h2h center Qm, hapus ini jika tidak menggunakan h2h center qm $this->load->model('qm/h2h_center_model', 'h2h'); $values = $this->h2h->trx_h2h($values); // h2h center end return $this->order_model->insert($values); } return 0;
public function create() { $this->load->library('form_validation'); // script driver cache $this->load->driver('cache', array('adapter' => 'memcached', 'backup' => 'memcached'));
Script pesan notif saat transaksi proses:
tambahkan kode ini pada application/language/indonesia/form_validation_lang.php // script notif trx menunggu $lang['form_validation_check_cache'] = 'ID Pelanggan sudah pernah di isi dalam 5 menit terakhir, silahkan tunggu '; Jika tidak ingin double notif pake script ini // script notif trx menunggu tanpa double $lang['form_validation_check_cache'] = ' ';