$$(document).on('page:init', '.page[data-name="inventory_add"]', function(e) {

  $(document).off("click", "#inventory_add_button").on("click", "#inventory_add_button", function(e) {

    e.preventDefault();

    let name = $('#i2_name').val();

    let brand = $('#i2_brand').val();

    let qty = $('#i2_qty').val();

    let unit = $('#i2_unit').val();

    let remark = $('#i2_remark').val();

    let position = $('#i2_position').val();

    let code = $('#i2_code').val();

    let price_per_unit = $('#i2_price_per_unit').val();

    let will_age = $('#i2_will_age').val();

    let purchase_date = $('#i2_purchase_date').val();

    let amount = $('#i2_amount').val();

    let img_url = $('#i2_img_url').val();

    let debit = $('input[name="i2_debit"]:checked').val();

    let credit = $('#i2_credit').val();



    let req = {

      name,brand,qty,unit,remark,position,code,price_per_unit,will_age,purchase_date,img_url,debit,credit

    }

    console.log(req)

    if (name && price_per_unit && debit && credit) {

      inventory_add(req);

    } else {

      app.dialog.alert("All fields are required", "Inventory Add Errors");

    }

  });

})