tampilan view
<?php
echo "<div class='col-md-12'>
<div class='box box-info'>
<div class='box-header with-border'>
<h3 class='box-title'>Data pesanan</h3>
</div>
<div class='box-body'>";
$attributes = array('class'=>'form-horizontal','role'=>'form'); echo form_open_multipart('Keuangan/tampil_save',$attributes);
echo "<div class='col-md-12'>
<table class='table table-condensed table-bordered'>
<tbody>
<tr>
<th width='120px' scope='row'>Nama Paket </th>
<td>
<input type='text' name='id_' class='form-control' value='$rows[nama_paket]' readonly></td>
</tr>
<tr>
<th width='120px' scope='row'>Peminjaman hari </th>
<td><input type='text' name='program_hari' class='form-control' value='$rows[program_hari]' readonly></td>
</tr>
<tr>
<th width='250px' scope='row'>Keberangkatan tanggal </th>
<td><input type='text' name='keberangkatan_tanggal' class='form-control' value='$rows[keberangkatan_tanggal]' readonly></td>
</tr>
<tr>
<th width='120px' scope='row'>Nama Depan</th>
<td><input type='text' name='nama_depan' class='form-control'></td>
<th width='120px' scope='row'>Nama Tengah</th>
<td><input type='text' name='nama_tengah' class='form-control'></td>
</tr>
<tr>
<th width='120px' scope='row'>Nama Belakang</th>
<td><input type='text' name='nama_belakang' class='form-control'></td>
<th width='120px' scope='row'>Alamat</th>
<td><textarea type='text' name='alamat' class='form-control'></textarea></td>
</tr>
<tr>
<th width='120px' scope='row'>Tanggal lahir</th>
<td><input type='text' name='tgl_lahir' id='tgl_lahir' class='form-control'></td>
<th width='120px' scope='row'>Tempat lahir lahir</th>
<td><input type='text' name='tempat_lahir' class='form-control'></td>
</tr>
<tr>
<th width='120px' scope='row'>No HP</th>
<td><input type='text' name='no_hp' class='form-control'></td>
<th width='120px' scope='row'>No tlp</th>
<td><input type='text' name='no_tlp' class='form-control'></td>
</tr>
<tr>
<th width='120px' scope='row'>Email</th>
<td><input type='email' name='email' class='form-control'></td>
<th width='120px' scope='row'>Virtual account</th>
<td><input type='text' name='no_virtual_account' class='form-control'></td>
</tr>
<tr>
<th width='120px' scope='row'>Tgl Peminjaman</th>
<td><input type='email' name='tgl_issued' id='tgl_issued' class='form-control'></td>
<th width='120px' scope='row'>Tgl expired</th>
<td><input type='text' name='tgl_expired' id='tgl_expired' class='form-control'></td>
</tr>
<tr>
<th width='120px' scope='row'>Nama karyawan</th>
<td>
<select name='marketing_agent' class='form-control'>
<option value='0'>--pilih refrensi marketing --</option>";
foreach ($agentcabang->result_array() as $row){
if ($rows['id_agent'] == $row['id_agent']){
echo "<option value='$row[id_agent]' selected>$row[nama_agent_cabang]</option>";
}else{
echo "<option value='$row[id_agent]'>$row[nama_agent_cabang]</option>";
}
}
echo "</td></tr>
</tbody>
</table>
</div>
</div>
<div class='box-footer'>
<button type='submit' name='submit' class='btn btn-primary'>Save</button>
<a href='../listbranch'><button type='button' class='btn btn-default pull-right'>Cancel</button></a>
</div>
</div>";
controllers
function tampil_save(){
cek_session_admin();
$id = $this->uri->segment(3);
if (isset($_POST['submit'])){
$this->model_main->updatedata();
$this->id_ = $this->session->userdata('id_');
//$data['rows'] = $this->model_main->tampil_save($id)->row_array();
$this->session->set_flashdata("pesan", "<div class=\"col-md-12\"><div class=\"alert alert-success\" id=\"alert\">Data berhasil diupdate!! </div></div>");
redirect('Keuangan/tampil_save');
}else{
$data['rows'] = $this->model_main->tampil_save($id)->row_array();
$data['agentcabang'] = $this->model_main->joincabang();
$this->session->set_flashdata("pesan", "<div class=\"col-md-12\"><div class=\"alert alert-danger\" id=\"alert\">Gagal!!</div></div>");
$this->template->load('Cpanelweb/template','Cpanelweb/mod_cabang/view_tampil_save',$data);
}
}
model
function updatedata(){
$datadb = array('id_'=>$this->db->escape_str(trim($this->input->post('id_paket'))), 'nama_depan'=>$this->db->escape_str(trim($this->input->post('nama_depan'))), 'nama_tengah'=>$this->db->escape_str(trim($this->input->post('nama_tengah'))), 'nama_belakang'=>$this->db->escape_str(trim($this->input->post('nama_belakang'))), 'alamat'=>$this->db->escape_str(trim($this->input->post('alamat'))), 'tgl_lahir'=>$this->db->escape_str(trim($this->input->post('tgl_lahir'))), 'tempat_lahir'=>$this->db->escape_str(trim($this->input->post('tempat_lahir'))), 'email'=>$this->db->escape_str(trim($this->input->post('email'))), 'no_hp'=>$this->db->escape_str(trim($this->input->post('no_hp'))), 'no_telp'=>$this->db->escape_str(trim($this->input->post('no_telp'))), 'no_virtual_account'=>$this->db->escape_str(trim($this->input->post('no_virtual_account'))) //'id'=>$this->db->escape_str($this->input->post('nama_bank'))
);
//$this->db->where('id_',$this->input->get('id_'));
$this->db->insert('tbl_customer',$datadb);
}