00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 class Mage_Adminhtml_Block_Review_Add extends Mage_Adminhtml_Block_Widget_Form_Container
00036 {
00037 public function __construct()
00038 {
00039 parent::__construct();
00040
00041 $this->_controller = 'review';
00042 $this->_mode = 'add';
00043
00044 $this->_updateButton('save', 'label', Mage::helper('review')->__('Save Review'));
00045 $this->_updateButton('save', 'id', 'save_button');
00046
00047 $this->_updateButton('reset', 'id', 'reset_button');
00048
00049 $this->_formScripts[] = '
00050 toggleParentVis("add_review_form");
00051 toggleVis("save_button");
00052 toggleVis("reset_button");
00053 ';
00054
00055 $this->_formInitScripts[] = '
00056 var review = function() {
00057 return {
00058 productInfoUrl : null,
00059 formHidden : true,
00060
00061 gridRowClick : function(data, click) {
00062 if(Event.findElement(click,\'TR\').title){
00063 review.productInfoUrl = Event.findElement(click,\'TR\').title;
00064 review.loadProductData();
00065 review.showForm();
00066 review.formHidden = false;
00067 }
00068 },
00069
00070 loadProductData : function() {
00071 var con = new Ext.lib.Ajax.request(\'POST\', review.productInfoUrl, {success:review.reqSuccess,failure:review.reqFailure}, {form_key:FORM_KEY});
00072 },
00073
00074 showForm : function() {
00075 toggleParentVis("add_review_form");
00076 toggleVis("productGrid");
00077 toggleVis("save_button");
00078 toggleVis("reset_button");
00079 },
00080
00081 updateRating: function() {
00082 elements = [$("select_stores"), $("rating_detail").getElementsBySelector("input[type=\'radio\']")].flatten();
00083 $(\'save_button\').disabled = true;
00084 var params = Form.serializeElements(elements);
00085 if (!params.isAjax) {
00086 params.isAjax = "true";
00087 }
00088 if (!params.form_key) {
00089 params.form_key = FORM_KEY;
00090 }
00091 new Ajax.Updater("rating_detail", "'.$this->getUrl('*/*/ratingItems').'", {parameters:params, evalScripts: true, onComplete:function(){ $(\'save_button\').disabled = false; } });
00092 },
00093
00094 reqSuccess :function(o) {
00095 var response = Ext.util.JSON.decode(o.responseText);
00096 if( response.error ) {
00097 alert(response.message);
00098 } else if( response.id ){
00099 $("product_id").value = response.id;
00100
00101 $("product_name").innerHTML = \'<a href="' . $this->getUrl('*/catalog_product/edit') . 'id/\' + response.id + \'" target="_blank">\' + response.name + \'</a>\';
00102 } else if( response.message ) {
00103 alert(response.message);
00104 }
00105 }
00106 }
00107 }();
00108
00109 Event.observe(window, \'load\', function(){
00110 if ($("select_stores")) {
00111 Event.observe($("select_stores"), \'change\', review.updateRating);
00112 }
00113 });
00114 ';
00115 }
00116
00117 public function getHeaderText()
00118 {
00119 return Mage::helper('review')->__('Add New Review');
00120 }
00121 }