C
|
copper21 4/11/2025 |
Is the Add Invoice Button in Customer List Page grid? Send a screenshot of where the button is on the list page. |
G
|
GMO author 4/11/2025 |
PHPR 11 Version 43204 x64 Button opens add page in popup, the issue: Invoice not attaching or utilizing the client ID. Client table has field: "client_id" and Invoice Table has field "client_id"
|
C
|
copper21 4/11/2025 |
From the screenshots you have provided, the button is on the client add page. An invoice will not get the client_id becuase the client record has not been added yet. If you want to connect an invoice to a client, you must add an invoice to an already-existing client. I would put the invoice button on the list page (in the grid) or view page of a client that is already existing. The button should have access to the client_id this way. |
G
|
GMO author 4/12/2025 |
Thank you for your replies, I am seeking a method for adding the New Client in popup window, saving the new client data, window stays open, than proceed to click ADD New Invoice. The "Add Invoice" button captures the Client_ID of newly added client. "you must add an invoice to an already-existing client." It should be possible due to logical series of events. Thank you for your previous replies. |
D
|
druck281 4/12/2025 |
After your code runs to save your new Client, you can capture the newly created client_id using the Database API call (assuming it's an auto-increment data type)... $_SESSION["newclientid"] = DB::LastId(); When your Add Invoice page opens, you can assign the value from the SESSION variable to the control in your Add Invoice page. I am no expert so there may be a 'better' way to do this but check out the manual page on Database API and you can see how the DB::LastId works. I have used it a handful of times in my project and it works perfectly. In theory, I suppose you could probably skip assigning it to a SESSION variable and make the API call from one of the early events on the Add Invoice page but if multiple users are adding records, you run a risk of another record being added in the brief period between saving the new client and opening the Add Invoice page. I always try to capture that LastId() as soon as possible to avoid that chance. |