gowri Posted November 22, 2013 Share Posted November 22, 2013 (edited) Hi, i am creating a custom module for feedback and reply feedback. Controller file path given below. Path : modules/custommodule/controllers/admin/AdminCustomModuleController.php class AdminCustomModuleController extends ModuleAdminController { public function __construct() { $this->fields_list = array( 'replyfeedback' => array( 'title' => $this->l('Feedback Reply'), 'width' => 35, 'align' => 'center', 'callback' => 'CheckReplyFeedback', 'orderby' => true, 'search' => false, 'remove_onclick' => true) ); } public function CheckReplyFeedback($id_feedback, $tr) { $html = '<a href="javascript:;" onlclick="return replyFeedback(\''.$id_feedback.'\');" title="sample link"><img src="reply.gif" alt="reply" title="reply" /></a>'; return $html; } } I have listed the feedbacks from table, using fields_list in controller. when i click the reply image, i want to open a fancy box with a reply form (with old data if it is exist). If the feed back have old reply, we need to get the old details using Ajax. I wrote the member function to get the reply data for a feedback table in the same controller. i need to call that member function by ajax. I don't know how to make it in ajax. Please suggest me the solution. Thanks in advance. Edited November 29, 2013 by gowri (see edit history) Link to comment Share on other sites More sharing options...
gowri Posted November 28, 2013 Author Share Posted November 28, 2013 (edited) Hello, any one please help me to find the solution. Thanks in advance... Edited November 28, 2013 by gowri (see edit history) Link to comment Share on other sites More sharing options...
gowri Posted November 29, 2013 Author Share Posted November 29, 2013 (edited) Hello Thanks to all... here i found the solution and explained bellow in my module Path to module /custommodule/controllers/admin/AdminCustommoduleController.php contains the following class AdminCustomModuleController extends ModuleAdminController { public function __construct() { $this->fields_list = array( 'replyfeedback' => array( 'title' => $this->l('Feedback Reply'), 'width' => 35, 'align' => 'center', 'callback' => 'CheckReplyFeedback', 'orderby' => true, 'search' => false, 'remove_onclick' => true) ); } public function renderList() { $this->tpl_list_vars = array( 'datsimg_path' => _MODULE_DIR_.$this->module->name.'/img/admin/', 'ajax_CustomModuleController_path' => $this->context->link->getAdminLink('AdminCustomModule'), 'current_id_tab' => (int)$this->context->controller->id ); return parent::renderList(); } public function ajaxProcessGetFeedbackInfo() { $id_feedback = Tools::getValue('id_feedback'); $feedbackinfo = $this->getCustomerFeedbackReply($id_feedback )); if($feedbackinfo) die(Tools::jsonEncode(array( 'status' => htmlspecialchars($feedbackinfo['status']), 'details' => htmlspecialchars($feedbackinfo['reply_msg']) ))); } public function CheckReplyFeedback($id_feedback, $tr) { $html = '<a href="javascript:;" onlclick="return replyFeedback(\''.$id_feedback.'\');" title="sample link"><img src="reply.gif" alt="reply" title="reply" /></a>'; return $html; } public function getCustomerFeedbackReply($id_feedback) { /* here i get the customer feedback reply details from database */ } } Path to module /custommodule/views/templates/admin/custom_module/helpers/list/list_header.tpl contains the following {extends file="helpers/list/list_header.tpl"} {block name="override_header"} <script type="text/javascript"> function getPendingStatusInfo(feedback_id) { if (feedback_id > 0) { $.ajax({ type: 'POST', url: '{$ajax_CustomModuleController_path}', dataType: 'json', data: { controller : 'AdminCustomModule', action : 'getFeedbackInfo', ajax : true, id_feedback : feedback_id, id_tab : '{$current_id_tab}' }, success: function(jsonData) { if(jsonData) { $.fancybox({ fitToView: true, content : "<div id=\"inlineform\"><fieldset><legend><img src=\"{$datsimg_path}information.png\" alt=\"\" /> Feedback Details</legend><label for=\"feedback_status\">Status:</label><div class=\"margin-form\" style=\"text-align:left;\">"+jsonData.status+"</div><br /><label for=\"feedback_details\">Reply Details:</label><div class=\"margin-form\" style=\"text-align:left;\">"+jsonData.details+"</div></fieldset></div>" }); } } }); } } </script> {/block} Edited November 29, 2013 by gowri (see edit history) 1 Link to comment Share on other sites More sharing options...
Recommended Posts