Hi, I’m now trying to customize Module ‘aop_case_update’ in SuiteCRM 7.5.3.
add the ‘ts_minute’, ‘ts_second’ and ‘ts_bill_type’ field , was also added to the html form.
However, ‘update_text’ and ‘internal’ of the original field are stored in the DB ,
but the data of the additional fields are not saved to DB.
(fig1
,fig2
)
The MySQL query log , did not include the additional field.
697 Query INSERT INTO aop_case_updates (id,name,date_entered,date_modified,modified_user_id,created_by,description,deleted,assigned_user_id,case_id,internal)
VALUES (‘59ee0625-6618-eb35-41c7-570c52c99caa’,‘This is TEST\n’,‘2016-04-12 01:41:35’,‘2016-04-12 01:41:35’,‘1’,‘1’,‘This is TEST\n’,0,‘1’,‘af0cb9c7-e824-737e-ba62-57074f8e936f’,0)
The column of additional fields to aop_case_update table of DB has been added ,
and manually set a value for the record , will be displayed .
(fig3
,fig4
)
When the saveUpdate () function code of CaseUpdatesHook.php to change in this way , it contains additional fields to the MySQL query log ,
It will be displayed in the ‘Case Updates Threaded’.
(fig5
)
$case_update->description = $text;
$case_update->ts_minute = 99;
$case_update->ts_second = 99;
$case_update->ts_bill_type = 'second TEST';
$case_update->case_id = $bean->id;
$case_update->save();
736 Query INSERT INTO aop_case_updates (id,name,date_entered,date_modified,modified_user_id,created_by,description,deleted,assigned_user_id,case_id,[color=#bb0044]ts_minute,ts_second,ts_bill_type,internal[/color])
VALUES (‘94218575-fb5d-b198-540d-570c54959244’,‘This is second Test’,‘2016-04-12 01:50:14’,‘2016-04-12 01:50:14’,‘1’,‘1’,‘This is second Test’,0,‘1’,‘af0cb9c7-e824-737e-ba62-57074f8e936f’,[color=#bb0044]99,99,‘second TEST[/color]’,0)
I think that because $ts_minute, $ts_second, $ts_bill_type does not include $bean variable.
How will can be stored in the DB the value entered in the form.
Thanks for any Help.
Regards
sato
/modules/AOP_Case_Updates/
vardefs.php (Additional item ‘ts_minute’,‘ts_second’ and ‘ts_bill_type’)
'ts_minute' => array (
'name' => 'ts_minute',
'vname' => 'LBL_TS_MINUTE',
'type' => 'int',
'len' => '255',
),
'ts_second' => array (
'name' => 'ts_second',
'vname' => 'LBL_TS_SECOND',
'type' => 'int',
'len' => '255',
),
'ts_bill_type' => array (
'name' => 'ts_bill_type',
'vname' => 'LBL_TS_BILL_TYPE',
'type' => 'text',
'len' => '255',
),
AOP_Case_Updates_sugar.php (Add Variable ‘ts_minute’,‘ts_second’ and ‘ts_bill_type’)
var $ts_minute;
var $ts_second;
var $ts_bill_type;
Case_Updates.php (Change code)
function caseUpdates(record){
loadingMessgPanl = new YAHOO.widget.SimpleDialog(‘loading’, {
width: ‘200px’,
close: true,
modal: true,
visible: true,
fixedcenter: true,
constraintoviewport: true,
draggable: false
});
loadingMessgPanl.setHeader(SUGAR.language.get(‘app_strings’, ‘LBL_EMAIL_PERFORMING_TASK’));
loadingMessgPanl.setBody(SUGAR.language.get(‘app_strings’, ‘LBL_EMAIL_ONE_MOMENT’));
loadingMessgPanl.render(document.body);
loadingMessgPanl.show();
var update_data = encodeURIComponent(document.getElementById('update_text').value);
[color=#bb0044]var ts_minute = document.getElementById('ts_minute').value;
var ts_second = document.getElementById('ts_second').value;
var ts_bill_type = encodeURIComponent(document.getElementById('ts_bill_type').value);[/color]
var checkbox = document.getElementById('internal').checked;
var internal = "";
if(checkbox){
internal=1;
}
//Post parameters
var params =
"record="+record+"&module=Cases&return_module=Cases&action=Save&return_id="+record+"&return_action=DetailView&relate_to=Cases&relate_id="+record+"&offset=1&update_text="
+ update_data + "&internal=" + internal [color=#bb0044]+ "&ts_minute=" + ts_minute + "&ts_second=" + ts_second + "&ts_bill_type=" + ts_bill_type[/color];
<form id='case_updates' enctype="multipart/form-data">
<textarea id="update_text" name="update_text" cols="120" rows="16"></textarea>
<input id='internal' type='checkbox' name='internal' tabindex=0 title='' value='1' $internalChecked > Internal</input>
</br>
[color=#bb0044]Bill type<select id='ts_bill_type' name='ts_bill_type'>
<option value='cel_phone'>cel_phone</option>
<option value='land-line'>land-line</option>
<option value='other'>othe</option>
</select>
<input id='ts_minute' name='ts_minute' size='3'> minute. <input id='ts_second' name='ts_second' size='3'> second.
</br>[/color]
<input type='button' value='Save' onclick="caseUpdates('$record')" title="Save" name="button"> </input>
</br>
</form>
function display_single_update(AOP_Case_Updates $update){
/*if assigned user*/
if($update->assigned_user_id){
/*if internal update*/
if ($update->internal){
$html = "<div id='caseStyleInternal'>".getUpdateDisplayHead($update);
$html .= "<div id='caseUpdate".$update->id."' class='caseUpdate'>";
$html .= nl2br(html_entity_decode($update->description));
$html .= "</div>";
[color=#bb0044] if ($update->ts_minute && $update->ts_second){
$html .= "<div style='margin-left: 20px; margin-top: 20px;'>";
$html .= $update->ts_minute . " minute. " . $update->ts_second . " second. Bill type: " . $update->ts_bill_type;
$html .= "</div>";
}[/color]
$html .= "</div>";
return $html;
}
/*if standard update*/
else {
$html = "<div id='lessmargin'><div id='caseStyleUser'>".getUpdateDisplayHead($update);
$html .= "<div id='caseUpdate".$update->id."' class='caseUpdate'>";
$html .= nl2br(html_entity_decode($update->description));
$html .= "</div>";
[color=#bb0044] if ($update->ts_minute && $update->ts_second){
$html .= "<div style='margin-left: 20px; margin-top: 20px;'>";
$html .= $update->ts_minute . " minute. " . $update->ts_second . " second. Bill type: " . $update->ts_bill_type;
$html .= "</div>";
}[/color]
$html .= "</div></div>";
return $html;
}
}
CaseUpdatesHook.php (Change code)
public function saveUpdate($bean, $event, $arguments){
if(!isAOPEnabled()){
return;
}
global $current_user, $app_list_strings;
if(empty($bean->fetched_row) || !$bean->id){
if(!$bean->state){
$bean->state = $app_list_strings['case_state_default_key'];
}
if($bean->status == "New"){
$bean->status = $app_list_strings['case_status_default_key'];
}
//New case - assign
if(!$bean->assigned_user_id){
$userId = $this->getAssignToUser();
$bean->assigned_user_id = $userId;
$bean->notify_inworkflow = true;
}
return;
}
if($_REQUEST['module'] == 'Import'){
return;
}
//Grab the update field and create a new update with it.
$text = $bean->update_text;
if(!$text && empty($_FILES['case_update_file'])){
//No text or files, so nothing really to save.
return;
}
$bean->update_text = "";
$case_update = new AOP_Case_Updates();
$case_update->name = $text;
$case_update->internal = $bean->internal;
$bean->internal = false;
$case_update->assigned_user_id = $current_user->id;
if(strlen($text) > $this->slug_size){
$case_update->name = substr($text,0,$this->slug_size)."...";
}
$case_update->description = $text;
[color=#bb0044] $case_update->ts_minute = $bean->ts_minute;
$case_update->ts_second = $bean->ts_second;
$case_update->ts_bill_type = $bean->ts_bill_type;
[/color]
$case_update->case_id = $bean->id;
$case_update->save();