Hack for virtuemart, allowing display of the field to edit the list price of the goods. The tab of goods, products table in the column header prices there are 2 icons - edit and save. When you click the edit icon displayed before the invisible text boxes with the prices. When you click the save data from these fields using ajax sent to the server
administrator / components / com_virtuemart / html / product.product_list.phpPp. 42
Add she_edit_price - shows / hides the text edit field at the price you click on Edit in the column of prices she_save_price - Ajax-saving function of prices. Data from all fields are selected and sent prices to the server (the file processed) administrator / com / virtuemart / html / product.ajax_tools.php (case 'shesaveprices':)
$ Doc = & JFactory:: getDocument ();
$ Script = "
var SHE_HIDE_INPUTS = 1;
function she_edit_price () {
display = (SHE_HIDE_INPUTS)? 'Block': 'none';
Ext.get (Ext.query ('. She_input')). SetStyle ('display', display);
SHE_HIDE_INPUTS = 1-SHE_HIDE_INPUTS;
}
function she_save_price () {
var params = {};
var she_inputs = Ext.query ('. she_input');
Ext.each (she_inputs, function (item, index) {
params ['params [' + item.getAttribute ('rel')+']'] = item.value;
});
var callback = {
success: function (o) {
Ext.Msg.alert ('Rates are stored', o.responseText);
}
failure: function (o) {
Ext.Msg.alert ('Error!', 'The prices have not been saved');
}
};
Ext.Ajax.request ({method: 'POST', url: success: callback.success, failure: callback.failure, params: params});
} ";
$ Doc-> addScriptDeclaration ($ script);
$ Doc-> addScriptDeclaration ($ script); Pp. 295
Replace
/ / These are the columns in the table
$ Columns = Array ('#' =>'',
"" => ""
$ VM_LANG-> _ ('PHPSHOP_PRODUCT_LIST_NAME') => "width = " 30% ""
$ VM_LANG-> _ ('VM_PRODUCT_LIST_MEDIA') => 'width = "5%"'
$ VM_LANG-> _ ('PHPSHOP_PRODUCT_LIST_SKU') => "width = " 15% ""
$ VM_LANG-> _ ('PHPSHOP_PRODUCT_PRICE_TITLE') => "width = " 10% ""
$ VM_LANG-> _ ('PHPSHOP_CATEGORY') => "width = " 15% "");
To: header in the table with the prices to add two icons - to save and edit
$ Price_adds = '> a href = "javascript:: void (null)" onclick = "she_edit_price ()"> <img src = "'. JURI:: root (). 'Images / M_images / edit.png" alt = "edit" /> </ a>
<a href="javascript::void(null)" onclick="she_save_price()"> <img style = "width: 16px" alt = "Save" src = "'. JURI:: root ().' images / save_f2.png "/> </ a> ';
/ / These are the columns in the table
$ Columns = Array ('#' =>'',
"<input Type="checkbox" name="toggle" value="" onclick="checkAll(".$num_rows.")" />" => "",
$ VM_LANG-> _ ('PHPSHOP_PRODUCT_LIST_NAME') => "width = " 30% ""
$ VM_LANG-> _ ('VM_PRODUCT_LIST_MEDIA') => 'width = "5%"'
$ VM_LANG-> _ ('PHPSHOP_PRODUCT_LIST_SKU') => "width = " 15% ""
$ VM_LANG-> _ ('PHPSHOP_PRODUCT_PRICE_TITLE'). $ Price_adds => "width = " 10% ""
$ VM_LANG-> _ ('PHPSHOP_CATEGORY') => "width = " 15% "");
Pp. 330
Replace
$ Tmp_cell = '<span class="editable priceform">'. $ GLOBALS ['CURRENCY_DISPLAY'] -> getValue ($ price ['product_price']).' '. $ Price [' product_currency '];
$ Tmp_cell .= '</ span>';
$ ListObj-<addCell( $tmp_cell,'id="'.$db-> f ('product_id').'" onclick = "showPriceForm (this.id)" title ="'.$ VM_LANG-> _ (' PHPSHOP_PRICE_FORM_LBL').'"');
To:
in a cell with prices added text box with the price hidden by default editable field
$ Tmp_cell = '<span onclick="showPriceForm('.$db-> f (' product_id').')" class = "editable priceform ">'.$ GLOBALS ['CURRENCY_DISPLAY'] -> getValue ($ price [ 'product_price']).' '. $ Price [' product_currency '];
$ Tmp_cell .= '</ span>
<div class="she_div">
<input value="'.$price['product_price'].'" id="she_input'.$db-> f ('product_id').'" rel ="'.$ db-> f (' product_id ' ). '"class =" she_input "style =" display: none "/>
</ Div> ';
$ ListObj-> addCell ($ tmp_cell, 'id ="'.$ db-> f (' product_id').'" title ="'.$ VM_LANG-> _ ('PHPSHOP_PRICE_FORM_LBL').'"');
administrator / components / com_virtuemart / html / product.product_list.php
After line 155 (break) add:
of all text fields with the prices of the data is transferred to an associative array of params (key - value of the field "product_id", value - the value of the field 'product_price' table # __ {vm} _product_price)
case 'shesaveprices':
$ Params = vmGet ($ _REQUEST, 'params');
$ Db = new ps_DB;
foreach ($ params as $ product_id => $ price) {
$ Q = "UPDATE # __ {vm} _product_price SET product_price ='".$ price." 'WHERE product_id ='".$ product_id ."'";
$ Db-> query ($ q);
}
echo 'The prices have been successfully saved ";
break;