Skip to content

Instantly share code, notes, and snippets.

@bonaxcrimo
Created January 7, 2020 09:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bonaxcrimo/a33f1194385077a1ef763c25335d51c3 to your computer and use it in GitHub Desktop.
Save bonaxcrimo/a33f1194385077a1ef763c25335d51c3 to your computer and use it in GitHub Desktop.
Pesan editor di controller Penulis
public function pesaneditor($id,$paket){
$user= ambilData('users',['id_user'=>$id]);
$data['paket'] = $paket==0?'Standar':'Express';
$editor= ambilData('editor',['user_id'=>$id]);
$data['editor'] = $editor;
$data['harga'] = $paket==0?$editor->hargabiasa:$editor->hargaexpres;
$data['user'] = $user;
$data['cerpen'] = $this->db->query("select * from cerpen where id_penulis = ".$_SESSION['id'])->result();
if(!empty($_POST)){
$check = ambilData('users',['id_user'=>$_SESSION['id']]);
if($check->saldo<$_POST['total']){
$this->session->set_flashdata('pesan','Saldo tidak cukup');
redirect('penulis/history');
exit();
}
$_POST['id_user'] = $_SESSION['id'];
$_POST['id_editor'] = $id;
$this->db->insert('pesananeditor',$_POST);
$this->db->where('user_id',$_SESSION['id']);
$this->db->set('saldo','saldo-'.$_POST['total'],FALSE);
$this->db->update('penulis');
$this->session->set_flashdata('pesan','Berhasil memesan.Jika editor tidak merespon maka dalam 3 hari uang dikembalikan');
redirect('penulis/history');
}
$this->load->view('include/header.php');
$this->load->view('penulis/pesaneditor',$data);
$this->load->view('include/footer.php');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment