Hello,
i would like to add a custom field to the Line items, i already added the field in the studio. I tried to change the layout of the edit view, still didnāt work.
i would really appreciate any help you could give me
Hello,
i would like to add a custom field to the Line items, i already added the field in the studio. I tried to change the layout of the edit view, still didnāt work.
i would really appreciate any help you could give me
for fields to display on the line you would have manually add them to the JavaScript, in the file:-
modules/AOS_Products_Quotes/line_items.js
to be upgrade safe you would just overwrite what you need to by creating a custom file:-
custom/modules/AOS_Products_Quotes/line_items.js
OK. so I looked at the javascript. its for the edit view from what I can see. what if I want to change from listing āProduct Nameā to āPart Numberā on the detail view?
I found the line_Items.php but when I made changes (added text to verify I have the right file), quick repair rebuild, and reloaded page - nothing changed.
Tammy Lewis
I didnāt fully understand what you want to do. But if you change the Line_items.php you donāt need to run quick repair rebuild to see changes made over display_lines unless you created a new function.
When I look at the invoice line items - it displays the product name. I want to change that to display Part Number and maybe instead of Note maybe item_description.
I have tried to do it within Studio but nothing was working. couldnāt find the correct layout. Then I found this post. I am closer but from what I can tell the line_item.js is used for editing the line item. Not during display.
So can you tell me where to make my change so that if I want Part number listed on the invoice - it does.
THanks,
Tammy
if i did understand, what you want is to remove the product name and note textfield from the line items.
You have to change the line_items.js, as matt said, changed it over the custom folder. Studio wonāt work.
if you wish to display or not a field, you have to change the function insertProductLine, so if you wish to remove the note field comment out the lines 203 to 207 where the note field is displayed. As for the product name do the same over line 144 and 145. Be careful, if you commend this lines, you have to adjust columns. try this out
function insertProductLine(tableid, groupid) {
if(!enable_groups){
tableid = "product_group0";
}
if (document.getElementById(tableid + '_head') != null) {
document.getElementById(tableid + '_head').style.display = "";
}
var vat_hidden = document.getElementById("vathidden").value;
var discount_hidden = document.getElementById("discounthidden").value;
sqs_objects["product_name[" + prodln + "]"] = {
"form": "EditView",
"method": "query",
"modules": ["AOS_Products"],
"group": "or",
"field_list": ["name", "id","part_number", "cost", "price","description","currency_id"],
"populate_list": ["product_name[" + prodln + "]", "product_product_id[" + prodln + "]", "product_part_number[" + prodln + "]", "product_product_cost_price[" + prodln + "]", "product_product_list_price[" + prodln + "]", "product_item_description[" + prodln + "]", "product_currency[" + prodln + "]"],
"required_list": ["product_id[" + prodln + "]"],
"conditions": [{
"name": "name",
"op": "like_custom",
"end": "%",
"value": ""
}],
"order": "name",
"limit": "30",
"post_onblur_function": "formatListPrice(" + prodln + ");",
"no_match_text": "No Match"
};
sqs_objects["product_part_number[" + prodln + "]"] = {
"form": "EditView",
"method": "query",
"modules": ["AOS_Products"],
"group": "or",
"field_list": ["part_number", "name", "id","cost", "price","description","currency_id"],
"populate_list": ["product_part_number[" + prodln + "]", "product_name[" + prodln + "]", "product_product_id[" + prodln + "]", "product_product_cost_price[" + prodln + "]", "product_product_list_price[" + prodln + "]", "product_item_description[" + prodln + "]", "product_currency[" + prodln + "]"],
"required_list": ["product_id[" + prodln + "]"],
"conditions": [{
"name": "part_number",
"op": "like_custom",
"end": "%",
"value": ""
}],
"order": "name",
"limit": "30",
"post_onblur_function": "formatListPrice(" + prodln + ");",
"no_match_text": "No Match"
};
tablebody = document.createElement("tbody");
tablebody.id = "product_body" + prodln;
document.getElementById(tableid).appendChild(tablebody);
var x = tablebody.insertRow(-1);
x.id = 'product_line' + prodln;
var a = x.insertCell(0);
a.innerHTML = "<input type='text' style='width:73px;' name='product_product_qty[" + prodln + "]' id='product_product_qty" + prodln + "' size='5' value='' title='' tabindex='116' onblur='Quantity_format2Number(" + prodln + ");calculateLine(" + prodln + ",\"product_\");'>";
// var b = x.insertCell(1);
// b.innerHTML = "<input style='width:178px;' class='sqsEnabled' autocomplete='off' type='text' name='product_name[" + prodln + "]' id='product_name" + prodln + "' maxlength='50' value='' title='' tabindex='116' value=''><input type='hidden' name='product_product_id[" + prodln + "]' id='product_product_id" + prodln + "' size='20' maxlength='50' value=''>";
var b1 = x.insertCell(1);
b1.innerHTML = "<input style='width:178px;' class='sqsEnabled' autocomplete='off' type='text' name='product_part_number[" + prodln + "]' id='product_part_number" + prodln + "' maxlength='50' value='' title='' tabindex='116' value=''>";
var b2 = x.insertCell(2);
b2.innerHTML = "<button title='" + SUGAR.language.get('app_strings', 'LBL_SELECT_BUTTON_TITLE') + "' accessKey='" + SUGAR.language.get('app_strings', 'LBL_SELECT_BUTTON_KEY') + "' type='button' tabindex='116' class='button' value='" + SUGAR.language.get('app_strings', 'LBL_SELECT_BUTTON_LABEL') + "' name='btn1' onclick='openProductPopup(" + prodln + ");'><img src='themes/default/images/id-ff-select.png' alt='" + SUGAR.language.get('app_strings', 'LBL_SELECT_BUTTON_LABEL') + "'></button>";
var c = x.insertCell(3);
c.innerHTML = "<input style='text-align: right; width:115px;' type='text' name='product_product_list_price[" + prodln + "]' id='product_product_list_price" + prodln + "' size='11' maxlength='50' value='' title='' tabindex='116' onfocus='calculateLine(" + prodln + ",\"product_\");'><input type='hidden' name='product_product_cost_price[" + prodln + "]' id='product_product_cost_price" + prodln + "' value='' />";
if (typeof currencyFields !== 'undefined'){
currencyFields.push("product_product_list_price" + prodln);
currencyFields.push("product_product_cost_price" + prodln);
}
var d = x.insertCell(4);
d.innerHTML = "<input type='text' style='text-align: right; width:90px;' name='product_product_discount[" + prodln + "]' id='product_product_discount" + prodln + "' size='12' maxlength='50' value='' title='' tabindex='116' onfocus='calculateLine(" + prodln + ",\"product_\");' onblur='calculateLine(" + prodln + ",\"product_\");'><input type='hidden' name='product_product_discount_amount[" + prodln + "]' id='product_product_discount_amount" + prodln + "' value='' />";
d.innerHTML += "<select tabindex='116' name='product_discount[" + prodln + "]' id='product_discount" + prodln + "' onchange='calculateLine(" + prodln + ",\"product_\");'>" + discount_hidden + "</select>";
var e = x.insertCell(5);
e.innerHTML = "<input type='text' style='text-align: right; width:115px;' name='product_product_unit_price[" + prodln + "]' id='product_product_unit_price" + prodln + "' size='11' maxlength='50' value='' title='' tabindex='116' readonly='readonly' onfocus='calculateLine(" + prodln + ",\"product_\");' onblur='calculateLine(" + prodln + ",\"product_\");'>";
if (typeof currencyFields !== 'undefined'){
currencyFields.push("product_product_unit_price" + prodln);
}
var f = x.insertCell(6);
f.innerHTML = "<input type='text' style='text-align: right; width:90px;' name='product_vat_amt[" + prodln + "]' id='product_vat_amt" + prodln + "' size='11' maxlength='250' value='' title='' tabindex='116' readonly='readonly'>";
f.innerHTML += "<select tabindex='116' name='product_vat[" + prodln + "]' id='product_vat" + prodln + "' onchange='calculateLine(" + prodln + ",\"product_\");'>" + vat_hidden + "</select>";
if (typeof currencyFields !== 'undefined'){
currencyFields.push("product_vat_amt" + prodln);
}
var g = x.insertCell(7);
g.innerHTML = "<input type='text' style='text-align: right; width:115px;' name='product_product_total_price[" + prodln + "]' id='product_product_total_price" + prodln + "' size='11' maxlength='50' value='' title='' tabindex='116' readonly='readonly'><input type='hidden' name='product_group_number[" + prodln + "]' id='product_group_number" + prodln + "' value='"+groupid+"'>";
if (typeof currencyFields !== 'undefined'){
currencyFields.push("product_product_total_price" + prodln);
}
var h = x.insertCell(8);
h.innerHTML = "<input type='hidden' name='product_currency[" + prodln + "]' id='product_currency" + prodln + "' value=''><input type='hidden' name='product_deleted[" + prodln + "]' id='product_deleted" + prodln + "' value='0'><input type='hidden' name='product_id[" + prodln + "]' id='product_id" + prodln + "' value=''><button type='button' id='product_delete_line" + prodln + "' class='button' value='" + SUGAR.language.get(module_sugar_grp1, 'LBL_REMOVE_PRODUCT_LINE') + "' tabindex='116' onclick='markLineDeleted(" + prodln + ",\"product_\")'><img src='themes/default/images/id-ff-clear.png' alt='" + SUGAR.language.get(module_sugar_grp1, 'LBL_REMOVE_PRODUCT_LINE') + "'></button><br>";
enableQS(true);
//QSFieldsArray["EditView_product_name"+prodln].forceSelection = true;
var y = tablebody.insertRow(-1);
y.id = 'product_note_line' + prodln;
var h1 = y.insertCell(0);
h1.colSpan = "3";
h1.style.color = "rgb(68,68,68)";
h1.innerHTML = "<span style='vertical-align: top;'>" + SUGAR.language.get(module_sugar_grp1, 'LBL_PRODUCT_DESCRIPTION') + " : </span>";
h1.innerHTML += "<textarea tabindex='116' name='product_item_description[" + prodln + "]' id='product_item_description" + prodln + "' rows='2' cols='23'></textarea> ";
// var i = y.insertCell(1);
// i.colSpan = "3";
// i.style.color = "rgb(68,68,68)";
// i.innerHTML = "<span style='vertical-align: top;'>" + SUGAR.language.get(module_sugar_grp1, 'LBL_PRODUCT_NOTE') + " : </span>";
// i.innerHTML += "<textarea tabindex='116' name='product_description[" + prodln + "]' id='product_description" + prodln + "' rows='2' cols='23'></textarea> ";
addToValidate('EditView','product_product_id'+prodln,'id',true,"Please choose a product");
prodln++;
return prodln - 1;
}
Hope is what you want
Luis Cabarique
But isnāt that for the āeditā view? I want to add/change the layout in the display detail view.
tammy
if the detail view is what you want to change, you will have to edit Line_items.php, method display_lines(over the $view == āDetailViewā) over AOS_Products_Quotes module
Iāve managed to load a custom field within line_items.js function insertProductLine successfully. Iāve also managed to auto-populate this field from AOS_Product within the creation of quotes.
However Iām able to print the value out in a pdf-template. The only thing that isnāt working: When you edit the quote again, the custom-field is empty (thus the value is saved within the database and as mentioned will be printed out in a pdf-template). Iāve found the function insertLineItems (line 51 within line_items.js from AOS_Products_Quotes). There is a comment mentioning that this function is for āLoad Line Itemsā. Can anyone direct me in to the right way to load the value of my custom field from AOS_Product when editing a quote ? Iāve played around a bit but canāt get it to work (I think I would have to load the value within the āfor(var p in product){ā loop starting at line 78 but I canāt get it to work). Donāt need a complete example, just need a hint where to look at. Thx!
so the most likely reason why this would not work automatically is that the field you have added to the javascript is named incorrectly or doesnāt match what is being loaded from aos_products_quotes in the elements id
and/or name
e.g if your custom field was named āmy_custom_field_cā in aos_products_quotes then in the JS your fields name
and id
should begin with product_my_custom_field_c
Iām sry but I donāt get it to work.
Field was created as textarea āva_kunde_cā . Edits in custom/modules/AOS_Products_Quotes/line_items.js
:
"populate_list": ["product_name[" + prodln + "]", "product_product_id[" + prodln + "]", "product_part_number[" + prodln + "]", "product_product_cost_price[" + prodln + "]", "product_product_list_price[" + prodln + "]", "product_item_description[" + prodln + "]", "product_currency[" + prodln + "]", "product_va_kunde_c[" + prodln + "]"],
"populate_list": ["product_part_number[" + prodln + "]", "product_name[" + prodln + "]", "product_product_id[" + prodln + "]", "product_product_cost_price[" + prodln + "]", "product_product_list_price[" + prodln + "]", "product_item_description[" + prodln + "]", "product_currency[" + prodln + "]", "product_va_kunde_c[" + prodln + "]"],
i.colSpan = "5";
i.style.color = "rgb(68,68,68)";
i.innerHTML = "<span style='vertical-align: top;' class='product_description_label'>" + SUGAR.language.get(module_sugar_grp1, 'LBL_VA_KUNDE_C') + " : </span>";
i.innerHTML += "<textarea tabindex='116' name='product_va_kunde_c[" + prodln + "]' id='product_va_kunde_c" + prodln + "' rows='2' cols='23' class='product_description'></textarea> "
function openProductPopup(ln){
lineno=ln;
var popupRequestData = {
"call_back_function" : "setProductReturn",
"form_name" : "EditView",
"field_to_name_array" : {
"id" : "product_product_id" + ln,
"name" : "product_name" + ln,
"description" : "product_item_description" + ln,
"part_number" : "product_part_number" + ln,
"cost" : "product_product_cost_price" + ln,
"price" : "product_product_list_price" + ln,
"currency_id" : "product_currency" + ln,
"va_kunde_c" : "product_va_kunde_c" + ln
}
};
open_popup('AOS_Products', 800, 850, '', true, true, popupRequestData);
}
Beside that Iāve added the label string definition for āva_kunde_cā to AOS_Contracts/language and AOS_Quotes/language
.
Not sure if you have made any progress on this, but trying you code it seems fine,
the only thing I can think of is you havenāt added the custom field va_kunde_c
to line items (aos_products_quotes) in addition to products, as this is where it will store it and load it from on save
The way Line items work is they save to anther hidden module and loaded in dynamically to quotes/invoices, to add them to the parent module(quotes/invoices) change log, this would require customisation atm