|
|
|
รบกวนช่วยหน่อยครับ จะเพิ่ม code สีลง database แต่มันไม่ลงไม่แน่ใจว่าส่งค่าถูกไหม (เขียนด้วย CI ครับ) |
|
|
|
|
|
|
|
หน้า view
Code (PHP)
<td class="text-center"><input type="color" id="oetClrIdCode" name="oetClrIdCode" value="<?=$aValue['rtClrIdColor']?>"></td>
หน้า Controller
Code (PHP)
public function FSoCCLRAddEvent(){
try{
$aDataPdtColor = array(
'FTClrCode' => $this->input->post('oetClrCode'),
//'FTClrRefValue' => $input->input->post('oetClrIdCode'),
'FTClrName' => $this->input->post('oetClrName'),
'FTClrRmk' => $this->input->post('otaClrRmk'),
'FDLastUpdOn' => date('Y-m-d'),
'FDCreateOn' => date('Y-m-d'),
// 'FTTimeIns' => date('h:i:s'),
// 'FTTimeUpd' => date('h:i:s'),
'FTCreateBy' => $this->session->userdata('tSesUsername'),
'FTLastUpdBy' => $this->session->userdata('tSesUsername'),
'FNLngID' => $this->session->userdata("tLangEdit")
);
$oCountDup = $this->mPdtColor->FSnMCLRCheckDuplicate($aDataPdtColor['FTClrCode']);
$nStaDup = $oCountDup['counts'];
if($oCountDup !== FALSE && $nStaDup == 0){
$this->db->trans_begin();
$aStaClrMaster = $this->mPdtColor->FSaMCLRAddUpdateMaster($aDataPdtColor);
$aStaClrLang = $this->mPdtColor->FSaMCLRAddUpdateLang($aDataPdtColor);
if($this->db->trans_status() === false){
$this->db->trans_rollback();
$aReturn = array(
'nStaEvent' => '900',
'tStaMessg' => "Unsucess Add Product Color"
);
}else{
$this->db->trans_commit();
$aReturn = array(
'nStaCallBack' => $this->session->userdata('tBtnSaveStaActive'),
'tCodeReturn' => $aDataPdtColor['FTClrCode'],
'nStaEvent' => '1',
'tStaMessg' => 'Success Add Product Color'
);
}
}else{
$aReturn = array(
'nStaEvent' => '801',
'tStaMessg' => "Data Code Duplicate"
);
}
echo json_encode($aReturn);
}catch(Exception $Error){
echo $Error;
}
}
หน้า Model
Code (PHP)
public function FSaMCLRAddUpdateLang($paDataPdtColor){
try{
//Update Pdt Color Lang
$this->db->where('FNLngID', $paDataPdtColor['FNLngID']);
$this->db->where('FTClrCode', $paDataPdtColor['FTClrCode']);
$this->db->update('TCNMPdtColor_L',array(
'FTClrName' => $paDataPdtColor['FTClrName'],
'FTClrRmk' => $paDataPdtColor['FTClrRmk']
));
if($this->db->affected_rows() > 0){
$aStatus = array(
'rtCode' => '1',
'rtDesc' => 'Update Product Color Lang Success.',
);
}else{
//Add Pdt Color Lang
$this->db->insert('TCNMPdtColor_L', array(
//'FTClrRefValue'=> $paDataPdtColor['FTClrRefValue'],
'FTClrCode' => $paDataPdtColor['FTClrCode'],
'FNLngID' => $paDataPdtColor['FNLngID'],
'FTClrName' => $paDataPdtColor['FTClrName'],
'FTClrRmk' => $paDataPdtColor['FTClrRmk']
));
if($this->db->affected_rows() > 0){
$aStatus = array(
'rtCode' => '1',
'rtDesc' => 'Add Product Color Lang Success',
);
}else{
$aStatus = array(
'rtCode' => '905',
'rtDesc' => 'Error Cannot Add/Edit Product Color Lang.',
);
}
}
return $aStatus;
}catch(Exception $Error){
echo $Error;
}
}
Tag : PHP, HTML, CSS, JavaScript
|
|
|
|
|
|
Date :
2018-09-26 10:45:08 |
By :
witsarut_bell |
View :
751 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Controller บรรทัดที่ 5 ไปคอมเม้นมันใว้นี่ ครับ
|
|
|
|
|
Date :
2018-09-26 12:33:37 |
By :
DK |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|