public function actionupdateComment() { $description = false; if (isset($_POST['id_comment'])) { $id_commment = $_POST['id_comment']; } if (isset($_POST['description'])) { $description = $_POST['description']; } $model = LbComment::model()->findByPk($id_commment); $model->lb_comment_description = $description; $date = date('Y-m-d'); $model->lb_comment_date = $date; if ($model->update()) { $response = array(); $response['success'] = YES; $response['lb_comment_description'] = nl2br($model->lb_comment_description); $response['lb_comment_date'] = $model->lb_comment_date; LBApplication::renderPlain($this, array('content' => CJSON::encode($response))); } }
function EditComment(id) { var descript = $('#description'+id).text(); html='<textarea type="text" style="width:100%;height:100px" id="description_comment'+id+'">'+descript+'</textarea>\n\ <div id=""><input type="submit" id="yt0" value="Save" onclick = updateComment('+id+');> <input type="submit" id="yt0" value="Cancel" name="yt0" onclick=cancelCommentUpdate('+id+',"'+descript+'")><br />'; $("#description"+id).html(html); } function updateComment(id) { var description = $("#description_comment"+id).val(); $.post("<?php echo LbComment::model()->getActionURLNormalized('updateComment', array()); ?> ", {description:description,model_name:'lbPaymentVoucher',id_comment:id}, function(response){ var responseJSON = jQuery.parseJSON(response); if(responseJSON.success == 1) { $('#description_comment'+id).hide(); $('#description'+id).html(responseJSON.lb_comment_description); $('#fotter'+id).html(responseJSON.lb_comment_date); // $('#comment-root'+id).remove(); } }
public function getComment($lb_module_name = false, $lb_item_module_id = false, $lb_parent_comment_id = false) { $model = LbComment::model()->findAll('lb_module_name = "' . $lb_module_name . '" AND lb_item_module_id = ' . $lb_item_module_id . ' AND lb_parent_comment_id = ' . $lb_parent_comment_id . ' ORDER BY lb_comment_date DESC'); return $model; }
} } echo '</div>'; ?> <script lang="Javascript"> function _form_comment() { $('#show_form_comment').show(); } function saveComment(item_id,module_name,date) { var comment = $('#pv_comment').val(); $.post("<?php echo LbComment::model()->getActionURLNormalized('insertComment', array()); ?> ", {item_id: item_id, module_name: module_name,date:date,comment:comment }, function(response){ var responseJSON = jQuery.parseJSON(response); if(responseJSON.success == 1) { html = '<div id="comment-root'+responseJSON.lb_record_primary_key+'" class="comment" style="width: 58%;">\n\ <div style = " padding:20px" id="comment-content-container'+responseJSON.lb_record_primary_key+'">\n\ <div id="comment-content'+responseJSON.lb_record_primary_key+'" style="display: table">\n\ <b>'+responseJSON.account_profile_given_name+' '+responseJSON.account_profile_surname+'</b>: \n\ <span id="description'+responseJSON.lb_record_primary_key+'">'+responseJSON.lb_comment_description+'</span><br /></div></div>\n\ <div class="footer-container" style="padding-left: 20px">\n\ <span id ="fotter'+responseJSON.lb_record_primary_key+'" >Posted on '+responseJSON.lb_comment_date+'</span><div style="float: right">\n\ <a href="#" onclick = EditComment('+responseJSON.lb_record_primary_key+')>Edit</a>   <a href="#" onclick = deleteComment('+responseJSON.lb_record_primary_key+')>Delete</a></div></div></div>';