Adding new funcionality to a button (calling another script)

17 views
Skip to first unread message

Ivan Bašić

unread,
May 17, 2021, 11:16:30 AM5/17/21
to PartKeepr Users
Hello everyone, I am looking for guidance where to find a file/function/piece of code which handles stock add/removal.

My idea was this: when I press a "Add Stock" or "Remove Stock" button and insert data, and then when I click "OK" button, I want that click to trigger a script which is written in Python. I also want to pass the "Quantity", "Price" and "Comment" as arguments to the Python script. Furthermore, but not necessarily, I want to pass current user name.

I am not familiar with PHP, but I found this code (Stackoverflow link):

<?php
$command = escapeshellcmd('/usr/custom/test.py');
$output = shell_exec($command);
echo $output;
?>

This looks promising, as I could, I guess, without problems pass arguments as well.

What I actually need guidance with is finding where exactly should I add this piece of code! Of course, I also need to somehow pass the "Quantity", "Price" and "Comment" parameters, so any help with that would be helpful, but I am willing to learn that on my own.

I think that .php scripts I am looking for should be in folder
\partkeepr-1.4.0\src\PartKeepr\PartBundle\Action

but I am still unable to get myself through all of that.

Any help would be appreciated.

Jurica Grcic

unread,
May 17, 2021, 3:45:17 PM5/17/21
to Ivan Bašić, PartKeepr Users
Check out the folowing files/functions:

PartBundle/Action/PartPutAction.php  /  public function __invoke(Request $request, $id)
PartBundle/Action/PartPostAction.php /  public function __invoke(Request $request)

As far as I am aware these two functions will be called when you change existing or add new parts.
You can add your custom code in these two functions.

--
You received this message because you are subscribed to the Google Groups "PartKeepr Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to partkeepr-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/partkeepr-users/21650dff-f524-422a-a7f6-9c3746e3c5ffn%40googlegroups.com.

Daniel Calcoen

unread,
May 18, 2021, 5:44:13 AM5/18/21
to PartKeepr Users
Dear Ivan

I found the mention of a Python library


Regards
Daniel

Ivan Bašić

unread,
May 18, 2021, 1:05:16 PM5/18/21
to PartKeepr Users
Hvala Jurica, thank you Daniel.

I will try what you recommended. It will take me some time until I find free time to implement ideas, but I will write a feedback here when I get to do something.

Thank you once again.
Reply all
Reply to author
Forward
0 new messages