Help with the COST field in line_items.js

Hello everybody i hope you’re fine.
i need to customize the line_items.js (that is already customized from our it/web provider). However i need to make the job by myself because the budget is over :silly: :silly:
When i insert a new service line in a commercial offer, i need to make the field COST similar to the field PRICE;
i explain you: the field PRICE takes the import from the default list price, but i can edit this (to make a different price to the customer). The cost instead is readonly and i can not edit anything.
I’ve to take off the ‘readonly’ and edit the value, but i really need that the js suggest me an initial cost (that then i can edit).
Write me if you need more info, and thank you so mutch!
I paste to you the js code when i insert the line and then when i calculate:


	var tipo = riga1.insertCell(0);
	tipo.innerHTML = '<label style="display: block;" for="service_j_um_c' + servln + '">' + SUGAR.language.get(module_sugar_grp1, 'LBL_J_UM') + '</label>' +
		'<select tabindex="116" name="service_j_um_c[' + servln + ']" id="service_j_um_c' + servln + '" class="product_discount_amount_select" onchange="calculateLine(' + servln + ', \'service_\');" />' + um_hidden + '</select>';

	var qty = riga1.insertCell(1);
	qty.innerHTML = '<label style="display: block;" for="service_product_qty' + servln + '">' + SUGAR.language.get(module_sugar_grp1, 'LBL_PRODUCT_QUANITY') + '</label>' +
		'<input type="text" name="service_product_qty[' + servln + ']" id="service_product_qty' + servln + '" value="" title="" tabindex="116" onblur="calculateLine(' + servln + ', \'service_\');" class="product_qty" />';

	var part_number = riga1.insertCell(2);
	part_number.innerHTML = '<label style="display: block;" for="service_part_number' + servln + '">' + SUGAR.language.get(module_sugar_grp1, 'LBL_PART_NUMBER') + '</label>' + 
		'<input class="sqsEnabled product_part_number" autocomplete="off" type="text" name="service_part_number[' + servln + ']" id="service_part_number' + servln + '" maxlength="50" value="" title="" tabindex="116" />';

	var button = riga1.insertCell(3);
	button.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 product_part_number_button" value="' + SUGAR.language.get('app_strings', 'LBL_SELECT_BUTTON_LABEL') + '" name="btn1" onclick="openAltraAttivitaPopup(' + servln + ');"><img src="custom/themes/' + SUGAR.themes.theme_name + '/images/id-ff-select.png" alt="' + SUGAR.language.get('app_strings', 'LBL_SELECT_BUTTON_LABEL') + '"></button>';

	var service_name = riga1.insertCell(4);
	service_name.innerHTML = '<label style="display: block;" for="service_name' + servln + '">' + SUGAR.language.get(module_sugar_grp1, 'LBL_SERVICE_NAME') + '</label>' +
		'<input class="sqsEnabled service_name" autocomplete="off" type="text" name="service_name[' + servln + ']" id="service_name' + servln + '" maxlength="255" title="" tabindex="116" />' +
		'<input type="hidden" name="service_product_id[' + servln + ']" id="service_product_id' + servln + '" value="0" />' +
		'<input type="hidden" name="service_j_stato_riga_c[' + servln + ']" id="service_j_stato_riga_c' + servln + '" />' +
		'<input type="hidden" name="service_j_service_type_c[' + servln + ']" id="service_j_service_type_c' + servln + '" value="INJ_altre_attivita" />' +
		'<input type="hidden" name="service_j_service_id_c[' + servln + ']" id="service_j_service_id_c' + servln + '" />' +
		'<input type="hidden" name="service_j_codice_c[' + servln + ']" id="service_j_codice_c' + servln + '" />' +
		'<input type="hidden" name="service_product_cost_price[' + servln + ']" id="service_product_cost_price' + servln + '" />' +
		'<input type="hidden" name="service_product_list_price[' + servln + ']" id="service_product_list_price' + servln + '" />';

	var list_price = riga1.insertCell(5);
	list_price.innerHTML = '<label style="display: block;" for="service_j_total_list_price_c' + servln + '">' + SUGAR.language.get(module_sugar_grp1, 'LBL_LIST_PRICE') + '</label>' +
		'<input type="text" readonly="readonly" name="service_j_total_list_price_c[' + servln + ']" id="service_j_total_list_price_c' + servln + '" maxlength="50" value="" title="" tabindex="116" class="product_list_price" />';

	var cost_price = riga1.insertCell(6);
	cost_price.innerHTML = '<label style="display: block;" for="service_j_total_cost_c' + servln + '">' + SUGAR.language.get(module_sugar_grp1, 'LBL_COST_PRICE') + '</label>' +
		'<input type="text" readonly="readonly" name="service_j_total_cost_c[' +servln + ']" id="service_j_total_cost_c' + servln + '" value="" class="product_list_price" />';

	var trasferta = riga1.insertCell(7);
	trasferta.vAlign = 'top';
	trasferta.innerHTML = '<label style="display: block;" for="service_j_trasferta_c' + servln + '">' + SUGAR.language.get(module_sugar_grp1, 'LBL_J_TRASFERTA') + '</label>' +
		'<input type="hidden" name="service_j_trasferta_c[' + servln + ']" id="service_j_trasferta_c' + servln + '_real" value="" />' +
		'<input type="checkbox" name="service_j_trasferta_c[' + servln + ']" id="service_j_trasferta_c' + servln + '" value="1" title="" tabindex="116" onclick="$(\'#service_j_costo_trasferta_c' + servln + '\').toggle(); calculateLine(' + servln + ', \'service_\');" style="vertical-align: top;" />' +
		'<input type="text" name="service_j_costo_trasferta_c[' + servln + ']" id="service_j_costo_trasferta_c' + servln + '" maxlength="50" value="" title="" tabindex="116" class="product_list_price" onblur="calculateLine(' + servln + ', \'service_\');" style="display: none;" />';

	var total = riga1.insertCell(8);
	total.innerHTML = '<label style="display: block;" for="service_product_total_price' + servln + '">' + SUGAR.language.get(module_sugar_grp1, 'LBL_TOTAL_PRICE') + '</label>' +
		'<input type="text" name="service_product_total_price[' + servln + ']" id="service_product_total_price' + servln + '" maxlength="50" value="" title="" tabindex="116" class="product_total_price" onblur="calculateLine(' + servln + ', \'service_\');" />' +
		'<input type="hidden" name="service_group_number[' + servln + ']" id="service_group_number' + servln + '" value="' + groupid + '" />';

	var margin = riga1.insertCell(9);
	margin.innerHTML = '<label style="display: block;" for="service_j_total_margin_c' + servln + '">' + SUGAR.language.get(module_sugar_grp1, 'LBL_J_TOTAL_MARGIN') + '</label>' +
		'<input type="text" readonly="readonly" name="service_j_total_margin_c[' + servln + ']" id="service_j_total_margin_c' + servln + '" value="" />';

else if (document.getElementById(key + 'j_service_type_c' + ln).value == 'INJ_altre_attivita') {	// Gestione ricalcolo altre attivita'
		var intOre = 1;
		if (document.getElementById(key + 'product_qty' + ln) !== null) {
			intOre = unformat2Number(document.getElementById(key + 'product_qty' + ln).value);
			document.getElementById(key + 'product_qty' + ln).value = intOre;
		}
		// Gestione UM
		var um = document.getElementById(key + 'j_um_c' + ln).value;
		if (um == 'DD')
			intOre = intOre * 8;
		else if (um == 'HD')
			intOre = intOre * 4;
		var total_cost = get_value(key + 'product_cost_price' + ln) * intOre;
		set_value(key + 'j_total_cost_c' + ln, total_cost);
		var old_total_list = get_value(key + 'j_total_list_price_c' + ln);
		var total_list = get_value(key + 'product_list_price' + ln) * intOre;
		set_value(key + 'j_total_list_price_c' + ln, total_list);
		var total_price = get_value(key + 'product_total_price' + ln);
		if (total_price == old_total_list)
			total_price = total_list;
		set_value(key + 'product_total_price' + ln, total_price);
		var total_margin = total_price - total_cost;
		if (document.getElementById(key + 'j_trasferta_c' + ln).checked) {
			var costo_trasferta = get_value(key + 'j_costo_trasferta_c' + ln);
			total_margin -= costo_trasferta;
		}
		else
			document.getElementById(key + 'j_costo_trasferta_c' + ln).value = '';
		set_value(key + 'j_total_margin_c' + ln, total_margin);
	}

I KEEP FINGERS CROSSED :cheer: