Sales Order

The recommended method of customizing your AppGini-generated application is through hooks. But sometimes you might need to add functionality not accessible through hooks. You can discuss this here.
Post Reply
User avatar
Marcelo Vitoria
Veteran Member
Posts: 60
Joined: 2016-10-11 12:08

Sales Order

Post by Marcelo Vitoria » 2018-04-17 13:38

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
Marcelo Vitoria
Coding since 1984 Basic Sinclair!
Clipper Summer´87 - Visual Foxpro - VB6 - PHP
AppGini 24.11 - AdminLTE
https://www.workspaceservices.com.br

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Sales Order

Post by pbottcher » 2018-04-17 21:01

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
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

User avatar
Marcelo Vitoria
Veteran Member
Posts: 60
Joined: 2016-10-11 12:08

Re: Sales Order

Post by Marcelo Vitoria » 2018-04-23 16:11

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.
Marcelo Vitoria
Coding since 1984 Basic Sinclair!
Clipper Summer´87 - Visual Foxpro - VB6 - PHP
AppGini 24.11 - AdminLTE
https://www.workspaceservices.com.br

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Sales Order

Post by pbottcher » 2018-04-23 21:40

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.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

User avatar
Marcelo Vitoria
Veteran Member
Posts: 60
Joined: 2016-10-11 12:08

Re: Sales Order

Post by Marcelo Vitoria » 2018-04-24 19:52

Hello
Thank you very much for the help!
I will try to implement and warn you when I can

Thank you !
Marcelo Vitoria
Coding since 1984 Basic Sinclair!
Clipper Summer´87 - Visual Foxpro - VB6 - PHP
AppGini 24.11 - AdminLTE
https://www.workspaceservices.com.br

Post Reply