In my project we have more than one branch, and they have same Test but, but they have different Price rating. m_fran_id is branch id, m_test_id is the branch test id and m_updated_test_price is the test Price for specific brunch.
Recommended update_batch for update the Branch price. But update_batch function is not working.
Table name: fran_test_pricemaster
Controller
public function masterPrice_update($m_fran_id = null)
{
$data['title'] = display('branch_test_dept_add');
$sID = $this->input->post('m_test_id');
$sAmt = $this->input->post('m_updated_test_price');
$sFranId = $this->input->post('m_fran_id');
$edited_test = array();
for ($i=0; $i < sizeof($sID); $i++)
{
if(!empty($sID[$i]))
$edited_test[$i] = array(
'm_test_id' => $sID[$i],
'm_updated_test_price' => $sAmt[$i],
'm_fran_id' => $sFranId
);
}
#-------------------------------#
if ($this->form_validation->run() === true) {
$this->franchise_price_model->singlebatch_Test_updt($edited_test);
$this->session->set_flashdata('message', display('save_successfully'));
redirect('branch/franchise_price/masterPrice_update');
} else {
$data['franceschi_list'] = $this->franceschi_model->franceschi_list();
$data['test_Masterlist'] = $this->franchise_price_model->readTest_fromMasterPrice($m_fran_id);
$data['content'] = $this->load->view('branch/fran_pricemasterEdit',$data,true);
$this->load->view('layout/main_wrapper',$data);
}
}
Model
public function singlebatch_Test_updt($edited_test = [])
{
$this->db
->update_batch($this->fran_test_pricemaster, $edited_test , 'm_fran_id');
}
View
<tbody>
<tr class="<?php echo ($sl & 1)?"odd gradeX":"even gradeC" ?>">
<td><?php echo $sl; ?></td>
<td>
<input type="text" name="test_name[]" class="form-control" placeholder="" value="<?php echo $subject->test_name; ?>" disabled>
<input type="hidden" name="m_test_id[]" class="form-control" placeholder="" value="<?php echo $subject->m_test_id; ?>">
</td>
<td>
<input type="text" name="test_price[]" class="form-control" placeholder="" value="<?php echo $subject->test_price; ?>" disabled>
</td>
<td>
<input type="text" name="m_updated_test_price[]" class="form-control" placeholder="" value="<?php echo $subject->m_updated_test_price; ?>" id="test_priceEdt">
</td>
</tr>
</tbody>