var itemId = 0;
var qtyRent = 0;
var itemRate = 0;  
var subscriber = 0;
$(document).ready(function(){
  $('.my-interest-trigger').click(function(e) {
    e.preventDefault();
    var item_id = $(this).data('item-id');
    var interest_name = $(this).data('interest-name');
    var action = this.href;
    var message = $('#message');
    var el = $(this);
    if (el.is('[disabled=disabled]')) {
      return false;
    }
    $.post(action, {
        item_id: item_id,
        interest_name: interest_name
      })
      .done(function(data) {

        if (data) {
          el.attr("disabled", true);
          el.find('.fa-plus-circle').text(" Added");
          message.fadeIn(2000, function() {
            $("html, body").animate({
              scrollTop: $('body').offset().top
            }, 100);
            message.delay(2000).fadeOut();
          });
        } else {
          alert('somethings wong..');
        }

      })
      .fail(function(xhr, textStatus, errorThrown) {
        throw new Error(xhr.responseText);
      });
  });

  $('.delete-trigger').click(function(e) {
    e.preventDefault();
    var action = this.href;
    var interest_id = $(this).data('id');
    var item_name = $(this).data('item-name');

    $('#confirm-modal-content').empty().html('Do you want to remove' + ' <strong>' + item_name + '</strong> ?');
    $('#confirm-modal').modal('show');

  });

  $('.btn-rent').click(function() {
    var message = '';
    var qty = parseFloat($(this).siblings('.item-qty').val());
    var desc = $(this).siblings('.item-desc').val();
    itemId = $(this).data('item-id');
    itemRate = parseFloat($(this).siblings('.item-rate').val());
    qtyRent = parseFloat(prompt('How many items you want to rent?', qty));
    subscriber = $(this).siblings('.subscriber').val();
    if (isNaN(qtyRent)) {
      message = 'Quantity is not numeric';
    } else if (qtyRent <= 0) {
      message = 'Quantity must exceeds 0';
    } else if (qtyRent > qty) {
      message = 'Quantity must not exceeds ' + qty;
    }

    if (message != '') {
      errorMessage(message);
      itemId = 0;
      qtyRent = 0; 
    } else {
      $('#confirm-item-desc').text(desc);
      $('#confirm-item-details').text(qtyRent + 'pcs x ₱ ' + itemRate + ' = ₱ ' + formatNumber(qtyRent * itemRate));
      $('#reservation-modal').modal('show');
    }
  });

  $('#reportrange').on('apply.daterangepicker', function (ev, picker) {
    console.log(startDate, endDate);
  });
  $('.daterangepicker').css('z-index', 9999);

  $('#btn-confirm-modal').click(function() {
    // Check for item and rented qty
    var detail = [];
    if (itemId != 0 && qtyRent != 0) {
      detail.push({rate : itemRate, id: itemId, qty: qtyRent});
      proccessAction(rentUrl, {
        from: startDate,
        to: endDate,
        total: (itemRate*qtyRent),
        details: detail,
        subscriber: subscriber
      }).then(function() {
        successMessage('Your rental needs to be confirm by the lessor');
        $('#reservation-modal').modal('hide');
      });
    } else {
      errorMessage('No Item SELECTED OR specified quantity to rent');
    }
  });
});
@@ -50,26 +50,103 @@
 ;  %0Avar 
-subscriber
+rentalMode = 0;%0Avar daysDiff = 1;%0Avar subscriber = 0;%0Avar rentTotal = 0;%0Avar rentAmount
  = 0;%0A$(
@@ -1814,24 +1814,79 @@
 t?', qty));%0A
+    rentalMode = $(this).siblings('.item-mode').val();%0A
     subscrib
@@ -2264,24 +2264,170 @@
    %7D else %7B%0A
+      rentAmount = (daysDiff/rentalMode ) * itemRate;%0A      rentAmount = Math.ceil(rentAmount * 10) / 10;%0A      rentTotal = qtyRent * rentAmount;%0A
       $('#co
@@ -2517,24 +2517,26 @@
 x %E2%82%B1 ' + 
-itemRate
+rentAmount
  + ' = %E2%82%B1
@@ -2557,26 +2557,17 @@
 ber(
-qtyRent * itemRate
+rentTotal
 ));%0A
@@ -2733,16 +2733,131 @@
 dDate);%0A
+    $('#confirm-item-details').text(qtyRent + 'pcs x %E2%82%B1 ' + itemRate + ' = %E2%82%B1 ' + formatNumber(qtyRent * itemRate));%0A
   %7D);%0A  
@@ -3066,23 +3066,27 @@
 sh(%7B
-rate : itemRate
+amount : rentAmount
 , id
@@ -3208,26 +3208,17 @@
 al: 
-(itemRate*qtyRent)
+rentTotal
 ,%0A  

Fix lessee's items script