Pop up messaging for forbidden entry

Firekenny

New member

Your current DaDaBIK version​

You are using DaDaBIK version 11.8-Elba platinum, installed on 25-04-2023 (installation code: 18803644779e343e6d), the latest version of DaDaBIK is 11.9-Elba released on 23-03-2023

You are not running the last release of DaDaBIK, the release you are running might have bugs and security holes, see the official change log for further information. You can upgrade DaDaBIK here.

In case you want to upgrade to a more powerful edition (from Pro to Enterprise/Platinum, from Enterprise to Platinum) please contact us.

System info​

PHP Version: 8.1.18

mysql version: 10.5.19-MariaDB-cll-lve

Web server: Apache

Client: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36
______________________________________________________________________________________________________________________

Hello all,
I have created a basic inventory/stock management app where i have forms to allow users to creat inbound/outbound entries for items in stock.
However, at this stage, when an entry is made, there is no "live" calculated way to stop an entry to release quantities that are higher than the remaining balance of a given item in stock. Is there a way to either block or just to have a "warning message" when this may happen?
In addition, when an item is selected in the "release form", how to ensure the user selects the right item if one given item may be existing with same description in my warehouse but with another info that distinct them one another (single field linked to another table to select item description but with an extra field that show the additional distinct value to ensure the right selection of item to release).
Thanks
 

eugenio

Administrator
Staff member
Hi,
about the first question, you can add a custom validation function that check the quantity before insertion.

About the second one: if I have well understood, you could just add an additional linked filed to your select_single.

Best,
 

Firekenny

New member
Hi Eugenio,
Thanks for the feedback. For the second, i realized I could add this 2nd linked field and it is working now.
For the first, could you support by providing more details with the following information?
For upating the stock balance, I have followed your guide through your youtube video (create an inventory management system in 90mn) explaining that the stock remaining balance could directly be calculated into a SQL query when creating a "view" where the formula is built into the query for the "remaining qty" calculated field.
So at this stage, I would need the "check" validation/verification to be done within the query (if it is possible, with a function/query that check the remaining balance from another table's field before doing the substract calculated "sum" from the "movement" table)

Best.
 

Firekenny

New member
I am trying to create a hook function in operational_hook.php with the following code, and it does not work (i get a blank screen after the form submission):

// Define the hook
$hooks['dni_release']['insert']['before'][] = 'dadabik_before_insert_dni_release';

// Define the function
function dadabik_before_insert_dni_release($parameters_ar) {

// Get the product ID from the dni_product field
$product_id = $parameters_ar['data']['dni_product'];

// Get the quantity of the product from the dni_products table
$sql = "SELECT dni_qty FROM dni_products WHERE id_dnipro = :product_id";
$stmt = $GLOBALS['db']->prepare($sql);
$stmt->bindParam(':product_id', $product_id);
$stmt->execute();
$row = $stmt->fetch();

// Get the quantity that the user entered
$qty_release = min($parameters_ar['data']['dni_qty_release'], $row['dni_qty']);

// If the user entered a quantity that is higher than the quantity in the dni_products table, then show an error message
if ($qty_release > $row['dni_qty']) {
$message = "The quantity that you entered is higher than the quantity in the database. Please enter a lower quantity.";
$GLOBALS['dadabik']->addError($message); } }
 
Top