1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27: 28: 29: 30: 31: 32: 33:
34:
35: class Mage_Adminhtml_Block_Review_Add extends Mage_Adminhtml_Block_Widget_Form_Container
36: {
37: public function __construct()
38: {
39: parent::__construct();
40:
41: $this->_controller = 'review';
42: $this->_mode = 'add';
43:
44: $this->_updateButton('save', 'label', Mage::helper('review')->__('Save Review'));
45: $this->_updateButton('save', 'id', 'save_button');
46:
47: $this->_updateButton('reset', 'id', 'reset_button');
48:
49: $this->_formScripts[] = '
50: toggleParentVis("add_review_form");
51: toggleVis("save_button");
52: toggleVis("reset_button");
53: ';
54:
55: $this->_formInitScripts[] = '
56: //<![CDATA[
57: var review = function() {
58: return {
59: productInfoUrl : null,
60: formHidden : true,
61:
62: gridRowClick : function(data, click) {
63: if(Event.findElement(click,\'TR\').title){
64: review.productInfoUrl = Event.findElement(click,\'TR\').title;
65: review.loadProductData();
66: review.showForm();
67: review.formHidden = false;
68: }
69: },
70:
71: loadProductData : function() {
72: var con = new Ext.lib.Ajax.request(\'POST\', review.productInfoUrl, {success:review.reqSuccess,failure:review.reqFailure}, {form_key:FORM_KEY});
73: },
74:
75: showForm : function() {
76: toggleParentVis("add_review_form");
77: toggleVis("productGrid");
78: toggleVis("save_button");
79: toggleVis("reset_button");
80: },
81:
82: updateRating: function() {
83: elements = [$("select_stores"), $("rating_detail").getElementsBySelector("input[type=\'radio\']")].flatten();
84: $(\'save_button\').disabled = true;
85: var params = Form.serializeElements(elements);
86: if (!params.isAjax) {
87: params.isAjax = "true";
88: }
89: if (!params.form_key) {
90: params.form_key = FORM_KEY;
91: }
92: new Ajax.Updater("rating_detail", "'.$this->getUrl('*/*/ratingItems').'", {parameters:params, evalScripts: true, onComplete:function(){ $(\'save_button\').disabled = false; } });
93: },
94:
95: reqSuccess :function(o) {
96: var response = Ext.util.JSON.decode(o.responseText);
97: if( response.error ) {
98: alert(response.message);
99: } else if( response.id ){
100: $("product_id").value = response.id;
101:
102: $("product_name").innerHTML = \'<a href="' . $this->getUrl('*/catalog_product/edit') . 'id/\' + response.id + \'" target="_blank">\' + response.name + \'</a>\';
103: } else if( response.message ) {
104: alert(response.message);
105: }
106: }
107: }
108: }();
109:
110: Event.observe(window, \'load\', function(){
111: if ($("select_stores")) {
112: Event.observe($("select_stores"), \'change\', review.updateRating);
113: }
114: });
115: //]]>
116: ';
117: }
118:
119: public function ()
120: {
121: return Mage::helper('review')->__('Add New Review');
122: }
123: }
124: