I had created a function that allow user to edit /update certain data based on below condition:
This is my view for Linked Product
This is controller
And this image show what had happen after user edit the data
- If the records has been approved, user can edit all the data except the data for 'Linked Product', which mean it data will remain the existing one.
- If the records has not yet been approved, user can edit all the data include the data for 'Linked Product'
$isaproved=='1' means the records has been approved$isapproved=='0' means the records has not been approvedMy problem is, when I set {if $isapproved=='1'}disabled{/if}user can edit the Linked Product, but if the user want to edit other data except the Linked Product when the records has been approved, then click on Update product Spec button, the existing data for 'Linked Product' will automatically missing.How can I solve this??
This is my model
Code:
<?php
// Model for the supplier code
class pack_model extends CI_Model {
// Constructor
function pack_model()
{
// Call the Model constructor
parent::__construct();
$this -> load -> model('global_model');
$this -> load -> model('supp_model');
}
function UpdatePacking($header,$idpacking){
$this->db->trans_begin();
$packarr = array(
'idpacking' => $idpacking,
);
$this -> global_model -> update($header,'sindi_packing','idpacking',$idpacking);
}
}
?>This is my view for Linked Product
Code:
<div class="control-group">
<label for="proid" class="control-label">Linked Product</label>
<div class="controls">
<select class="chosen-select" id="SelectPro" name="selectpro[]" onchange="generateArticle();" multiple="multiple" {if $isapproved=='1'}disabled{/if}>
</select>
<br>
<input type="hidden" name="txtItems" id="txtItems" value="{if $msg == 'Edit'}{$articleno}{/if}">
<span id="imageloader"></span>
</div>
</div>This is controller
Code:
// Update the Item
function editspec() {
if ($_POST) {
$arr = $this -> global_model ->printallpost(2);
date_default_timezone_set('Asia/Kuala_Lumpur');
$selectpro = $this -> global_model -> Displaydata('selectpro');
$packdesc = $this -> input -> post('packdesc');
$ccust = $this -> global_model -> Displaydata('cCust');
//$value = explode("-",$selectpro);
$promeasure = $this -> input -> post('promeasure');
$oldarticle = $this -> input -> post('articleno');
$remark = $this -> input -> post('remark');
$dateissue = $this -> global_model -> ConverttoDate('dateissue');
// File Upload
$user = $this -> session -> userdata('user_name');
$department = $this -> session -> userdata('department');
// Header Array
//$article = $value[0] . '-' . $value[1] . '-' . $value[2];
$packcode = $this -> input -> post('txtid');
$header = array(
'pro_desc' => htmlspecialchars($packdesc),
'customer' => $ccust,
//'articleno'=> $selectpro,
'pro_measure' => htmlspecialchars($promeasure),
'date' => $dateissue,
'oldarticle' => $oldarticle,
'remark' => $remark,
'logo' => $Logo,
'front' => $filename2,
'back' => $filename3,
'file' => $filename,
'updateby' => $user
);
$uploadmessage = "";
$data = $this -> global_model -> decodedata('data');
$no = 1;
$this -> pack_model -> UpdatePacking($header,$packcode);
$msg = array('status' => 'Complete', 'msg' => 'Packing Specs has been Updated Completed !' . '<br>' . $uploadmessage, 'packid' => $packcode);
echo json_encode($msg);
}
}And this image show what had happen after user edit the data