Page 1 of 1

Sales Order

Posted: 2018-04-17 13:38
by Marcelo Vitoria
Hello friends

I have a sales order with 2 tables, the main and the items.
I need to create a field, where if the manager group changes this field to "billed" the other group of vendors can no longer make any changes to the order and items.

How can I do this?

greetings

Re: Sales Order

Posted: 2018-04-17 21:01
by pbottcher
Hi Marcelo,

not sure if I understand this completely, but I would think that you could use the hooks/TABLENAME-dv.js to check the current user (you can try var current_user=$j('a[href="membership_profile.php"]')["0"].innerText;) and the specific field content. If the content id "billed" you would change all fields to read-only ($j('#YOURFIELD1, #YOURFIELD2,....').prop('readonly', true);

If you need to do this for a table where you have no access to the field containing the "billed" information you would need to use ajax to retrieve the field-value and do the according setting of the readonly property to the fields.
Hope that helps

Re: Sales Order

Posted: 2018-04-23 16:11
by Marcelo Vitoria
Hello pböttcher

Thank you for your help.

My English is not very good, but I'll try to explain what I need,

The intent is that a user with more administrator privileges (not the Admin) in a group can change a Billed field and then all other sales order fields and child tables become read-only.
I'm a beginner in PHP, and could you give me a slightly more simplified example?

Thanks again for the help.

Re: Sales Order

Posted: 2018-04-23 21:40
by pbottcher
Hi Marcelo,

I'll try to make an example. Assuming you have a table called SALES which contains a field called "STATUS". This field has been set to "BILLED" by your user with the rights to do so.
Now if a user calls that page you want to display the fields "UNITS" and "PRICE" as readonly.

In the AppGini Application you find the subdirectory named hooks. Within this subdirectory you create a file that is called SALES-dv.js
This will contain you javascript code to be executed when the detailview is being loaded.

In this file you put the code like:

Code: Select all

$j(function () {

var current_user=$j('a[href="membership_profile.php"]')["0"].innerText;   // get the name of the actual user
var actual_status=$j('#STATUS').val();                                                  // get the actual status of the field called STATUS

 // check if the current user is not the administrative user and the status eq. BILLED
  if ($current_user != "YOUR_ADMIN_USER"  && actual_status == "BILLED") {    
    $j('#UNITS, #PRICE').prop('readonly', true);                                       // set the fields UNITS and PRICE to readonly
  }
}
Replace the words SALES with your tablename, STATUS with the fieldname you have, BILLED with the status you use, UNITS and PRICE with the fields you want to make readonly and YOUR_ADMIN_USER with the name of the user who can set the field to the status billed.

Hope that makes it clear. If you have more questions, it might be helpful if you name your fields if possible.

Re: Sales Order

Posted: 2018-04-24 19:52
by Marcelo Vitoria
Hello
Thank you very much for the help!
I will try to implement and warn you when I can

Thank you !