Hi,
I have built an Invoicing System with Appgini. Basically I have two database tables namely "Customers" and "Invoices".
I was wondering if there's a way to add the new customer automatically to the "membership_users" table as soon as I add a new customer to the "Customers" table.
Also whenever I add a new invoice for a customer to the "Invoices" table, it should automatically assign the customer as the owner of the record. So that whenever he logs in to the system, he should be able to view his own invoices.
I'll be very grateful if anyone help me out with my query.
Thanks!
Link membership_users table with Customers table
Re: Link membership_users table with Customers table
Can you post your ccode and how you did that?
-
- Posts: 1
- Joined: 2017-02-02 13:51
- Location: Ghzira, Malta
- Contact:
Re: Link membership_users table with Customers table
amlan1995 could I ask you to post the code here? I'd really love to use it. Thanks
Spela på casino dino eller varför inte testa dagens casino när du ändå är i farten?
-
- Posts: 28
- Joined: 2017-03-12 09:26
- Contact:
Re: Link membership_users table with Customers table
I want it also. Can you share the code if you succeeded ?
Thank you
Thank you
Best Regards,
Ionut Bocanet
Ionut Bocanet
Re: Link membership_users table with Customers table
Hi,
I will not supply any clean and easy to copy code, but I think a way to do this.
You create a new customer. Then, use the /hooks/TABLE_NAME_OF_CUSTOMER.php file and add php code in the function _after_insert. Something like this:
Remember: This code needs to be adjusted and corrected.
PS: This seems the wrong sub-forum. Would this be better in 'Getting Started'?
Olaf
I will not supply any clean and easy to copy code, but I think a way to do this.
You create a new customer. Then, use the /hooks/TABLE_NAME_OF_CUSTOMER.php file and add php code in the function _after_insert. Something like this:
Code: Select all
function TABLE_NAME_OF_CUSTOMER_after_insert($data, $memberInfo, &$args){
// we assume only one record is not in the membership_users yet, otherwise you will need to use the appgini SQL function
$_result_sql = sqlvalue ("SELECT customer_name
FROM customer_table
LEFT JOIN membership_users ON customer_table.customer_name = membership_users.memberID
WHERE membership_users.memberID IS NULL");
//now you have the name, that is not in the membership_users table yet - simply write it to the membership_users table, add password etc. and you are ready to go. something like this:
$sql="update membership_users set memberID='".$_result_sql."', passMD5 ='some MD5 of PW', otherfield=......";
$_result_sql = sql($sql, $eo);
}
PS: This seems the wrong sub-forum. Would this be better in 'Getting Started'?
Olaf
Some postings I was involved, you might find useful:
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view