Page MenuHomePhabricator

D17414.id41876.diff
No OneTemporary

D17414.id41876.diff

Index: template/js/medicine.js
===================================================================
--- template/js/medicine.js
+++ template/js/medicine.js
@@ -6,7 +6,7 @@
var _check_med_duplicacy_url = 'index.php?pharmacist/check_dupliate_medicine_sale';
var _generate_bill_url = 'index.php?pharmacist/generate_medicine_bill';
var _pop_up_timer = 5000;
-
+
function calculate_med_price()
{
var totalSellingMedCount = $("[id*='selling_med_detais']").length;
@@ -32,8 +32,8 @@
}
}
}
-
-
+
+
if ($.isNumeric(totalAmount) == true) {
var discount = $('#discount').val();
var totalDiscount = 0;
@@ -41,13 +41,13 @@
totalDiscount = ((totalAmount*discount)/100).toFixed(2);
totalAmount = totalAmount - totalDiscount;
}
-
+
$('#total_amount').val(totalAmount);
} else {
$('#total_amount').val(0);
}
}
-
+
function get_loose_item_derails()
{
if ($('#is_loose_item').is(":checked")) {
@@ -57,129 +57,130 @@
$('#loose_item_quantity').val('');
}
}
-
+
function add_medicine_container()
{
var labelCount = $("[id*='selling_med_detais']").length + 1;
// keep the medicine details count in the hidden parameter
$('#total_med_details').val(labelCount);
-
-
+
+
var seprator = $('<div>').attr({
class: 'seprator-dooted-lines'
});
-
+
// MEDICINE LIST ELEMENT
var mouterDiv = $('<div>').attr({
class: 'control-group',
id: 'sold_med_details' + labelCount
});
-
+
mouterDiv.append(seprator);
-
+
var mlabel = $('<label>').attr({
class: 'control-label',
id: 'selling_med_detais'
}).appendTo(mouterDiv);
-
+
mlabel.html('<span class="medicine_label">Medicine' + labelCount + '</span>');
-
+
var minnerDiv = $('<div>').attr({
class: 'controls'
}).appendTo(mouterDiv);
-
+
$('<select>').attr({
id: 'medicine_id' + labelCount,
name: 'medicine_id' + labelCount,
onchange: 'medicine.calculate_med_price(), medicine.can_sell_loose_item(' + labelCount +'), medicine.getMedicineBatchList(' + labelCount +');',
}).appendTo(minnerDiv);
-
+
mouterDiv.appendTo('#med_details_container');
-
+
$('<option>').val(0).text('--Select Medicine--').appendTo('#medicine_id' + labelCount);
-
+
$.each (medicineList, function( key, value ) {
if ('undefined' != typeof value && '' != value) {
$('<option>').val(key).text(value).appendTo('#medicine_id' + labelCount);
}
});
-
+
+
// BATCH LIST ELEMENT
var bOuterDiv = $('<div>').attr({
class: 'control-group',
id: 'sold_med_details' + labelCount
});
-
+
var bLabel = $('<label>').attr({
- class: 'control-label'
+ class: 'control-label'
}).appendTo(bOuterDiv);
-
+
bLabel.html('<span class="batch_label">Batch' + labelCount + '</span>');
-
+
var bInnerDiv = $('<div>').attr({
class: 'controls'
}).appendTo(bOuterDiv);
-
+
bOuterDiv.appendTo('#med_details_container');
-
+
$('<select>').attr({
id: 'batch_id' + labelCount,
name: 'batch_id' + labelCount
}).appendTo(bInnerDiv);
-
-
+
+
// OPTION TO REMOVE DETAILS
$('<div>').attr({
id: labelCount,
class: 'removeMedicine',
onclick: 'medicine.remove_medicine_container(' + labelCount +');'
}).appendTo(minnerDiv);
-
-
+
+
// LOOSE QUANTITY ELEMENT
var louterDiv = $('<div>').attr({
class: 'control-group , loose_med_option' + labelCount,
id: 'sold_med_details' + labelCount
});
-
+
var llabel = $('<label>').attr({
class: 'control-label'
}).appendTo(louterDiv);
-
+
llabel.html('<span class="loose_quant_label">Selling Loose Quantity' + labelCount + '</span>');
-
+
var linnerDiv = $('<div>').attr({
class: 'controls'
}).appendTo(louterDiv);
louterDiv.appendTo('#med_details_container');
-
+
$('<input>').attr({
type: 'checkbox',
id: 'selling_loose_quantity' + labelCount,
name: 'selling_loose_quantity' + labelCount,
onchange: 'medicine.calculate_med_price();'
}).appendTo(linnerDiv);
-
-
+
+
// QUANTITY ELEMENT
var outerDiv = $('<div>').attr({
class: 'control-group',
id: 'sold_med_details' + labelCount
});
-
+
var label = $('<label>').attr({
- class: 'control-label'
+ class: 'control-label'
}).appendTo(outerDiv);
-
+
label.html('<span class="quantity_label">Quantity' + labelCount + '</span>');
-
+
var innerDiv = $('<div>').attr({
class: 'controls'
}).appendTo(outerDiv);
-
+
outerDiv.appendTo('#med_details_container');
-
+
$('<input>').attr({
type: 'number',
id: 'med_quantity' + labelCount,
@@ -187,76 +188,76 @@
class: 'validate[required]',
onkeyup: 'medicine.calculate_med_price();'
}).appendTo(innerDiv);
-
-
+
+
// AMOUNT ELEMENT
var aouterDiv = $('<div>').attr({
class: 'control-group',
id: 'sold_med_details' + labelCount
});
-
+
var qlabel = $('<label>').attr({
- class: 'control-label'
+ class: 'control-label'
}).appendTo(aouterDiv);
-
+
qlabel.html('<span class="amount_label">Amount' + labelCount + '</span>');
-
+
var ainnerDiv = $('<div>').attr({
class: 'controls'
}).appendTo(aouterDiv);
-
+
$('<input>').attr({
type: 'text',
id: 'med_amount' + labelCount,
name: 'amount' + labelCount,
readonly: 'readonly'
}).appendTo(ainnerDiv);
-
+
aouterDiv.appendTo('#med_details_container');
-
+
}
-
+
function remove_medicine_container(id)
- {
+ {
$('*[id*=sold_med_details'+ id +']:visible').each(function() {
$(this).remove();
});
-
+
// keep the medicine details count in the hidden parameter
var labelCount = $("[id*='selling_med_detais']").length;
$('#total_med_details').val(labelCount);
-
-
+
+
// change the label of the medicine details which is being sold to patient
var medDetailCount = 2;
$('*[class*=medicine_label]:visible').each(function() {
$(this).html('Medicine' + medDetailCount);
medDetailCount++;
});
-
+
medDetailCount = 2;
$('*[class*=loose_quant_label]:visible').each(function() {
$(this).html('Selling Loose Quantity' + medDetailCount);
medDetailCount++;
});
-
+
medDetailCount = 2;
$('*[class*=quantity_label]:visible').each(function() {
$(this).html('Quantity' + medDetailCount);
medDetailCount++;
});
-
+
medDetailCount = 2;
$('*[class*=amount_label]:visible').each(function() {
$(this).html('Amount' + medDetailCount);
medDetailCount++;
});
}
-
+
function can_sell_loose_item(getPosition) {
var looseQuantityContainer = 'loose_quantity_element' + getPosition;
var getMedicineId = $('#medicine_id' + getPosition).val();
-
+
if ('undefined' != typeof medicine_loose_item_info[getMedicineId] && 0 == medicine_loose_item_info[getMedicineId]) {
$('#' + looseQuantityContainer).hide();
$('.loose_med_option' + getPosition).hide();
@@ -265,7 +266,7 @@
$('.loose_med_option' + getPosition).show();
}
}
-
+
function validate_medicine_sale_form() {
$('.loader').show();
var totalSellingMedCount = $("[id*='selling_med_detais']").length;
@@ -276,12 +277,12 @@
if (selectedMedValue == 0) {
erroMessage += 'Please select Medicine' + i + '.\n';
}
-
+
if (medQuantity <= 0) {
erroMessage += 'Please enter the Quantity' + i + '.\n';
}
}
-
+
if ('' != erroMessage) {
$('.loader').hide();
alert(erroMessage);
@@ -290,23 +291,23 @@
check_dupliate_medicine_sale();
}
}
-
+
function validate_medicine_stock_form()
{
var errorMessage = '';
-
+
if ($('#medicine_id').val() == 0) {
errorMessage += 'Please select the medicine' + '\n';
}
-
+
if ($('#manufacture_company_id').val() == 0) {
errorMessage += 'Please select the manufacturing company' + '\n';
}
-
+
if ($('#vendor_id').val() == 0) {
errorMessage += 'Please select the vendor name' + '\n';
}
-
+
if ($('#is_loose_item').is(":checked") && $('#loose_item_quantity').val() <= 0) {
errorMessage += 'Please mention the loose item quantity' + '\n';
}
@@ -316,11 +317,11 @@
return false;
}
}
-
+
function check_dupliate_medicine_sale()
{
var formDetails = $('#med_prescribed_form').serializeArray();
-
+
$.ajax({
type: 'POST',
url: _check_med_duplicacy_url,
@@ -349,11 +350,11 @@
}
});
}
-
+
function save_prescribed_details()
{
var formDetails = $('#med_prescribed_form').serializeArray();
-
+
$.ajax({
type: 'POST',
url: _sold_to_patient_url,
@@ -374,7 +375,7 @@
}
});
}
-
+
function generate_medicine_bill(id)
{
if ('undefined' != typeof id && '' != id && null != id) {
@@ -391,7 +392,7 @@
});
}
}
-
+
function get_medicine_batch_list(medicineOrder)
{
var medicineId = $('#medicine_id' + medicineOrder).val();
@@ -418,17 +419,17 @@
});
}
}
-
+
function get_med_distributor_details()
{
var medicineId = $('#medicine_id').val();
$('#manufacture_company_id option:not(:first)').remove();
$('#vendor_id option:not(:first)').remove();
-
+
if (medicineId > 0) {
var postdata = {};
postdata['medicine_id'] = medicineId;
-
+
$.ajax({
type: 'POST',
url: _med_distributor_url,
@@ -445,7 +446,7 @@
}
});
}
-
+
if ('undefined' != typeof response.content.vendor_list && '' != response.content.vendor_list) {
$.each(response.content.vendor_list, function( index, value ) {
if (value.id > 0) {
@@ -465,45 +466,45 @@
calculate_med_price : function() {
calculate_med_price();
},
-
+
get_loose_item_derails : function() {
get_loose_item_derails();
},
-
+
add_medicine_container : function() {
add_medicine_container();
},
-
+
remove_medicine_container : function(id) {
remove_medicine_container(id);
},
-
+
can_sell_loose_item : function(id) {
can_sell_loose_item(id);
},
-
+
validate_medicine_sale_form : function() {
validate_medicine_sale_form();
},
-
+
validate_medicine_stock_form : function() {
return validate_medicine_stock_form();
},
-
+
generate_medicine_bill : function(id) {
generate_medicine_bill(id);
},
-
+
getMedicineBatchList : function(medicineOrder) {
get_medicine_batch_list(medicineOrder);
},
-
+
get_med_distributor_details: function() {
get_med_distributor_details();
},
-
+
printPage: function() {
window.print();
}
}
-}();
\ No newline at end of file
+}();

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 6, 6:37 AM (2 h, 29 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
17393829
Default Alt Text
D17414.id41876.diff (12 KB)

Event Timeline