I just got an interesting question from an AppGini user:
Is there an SQL query that I can run manually in PhpMyAdmin that will show me a list of all users that haven’t logged into AppGini for the last 6 months please? Even if it is using one of the date fields in the membership_users table to show me a list of all users that haven’t added or changed a record for the last 6 months, that would suffice.
Well, AppGini doesn’t currently (until AppGini 5.72) store the login date/time of users (but we plan to add this in future releases). So, what we can do is run a query to retrieve non-active users (with no insert/edit activity in the last 6 months).
First, we need to create a new view in MySQL to list users’ last activity:
Now, you can use the view ‘members_activity’ that we defined above like you use any table (except it’s not actually a table, but it makes our life easier when performing complex queries). So, to retrieve all users who have no insert/update activity or whose last insert/update activity is more than 6 months old:
But the above query might retrieve new users who joined less than 6 months ago … to exclude those, we should add another condition:
In many cases, your application might have a child table, like this:
Let’s say we want to hide the Company and Open columns from that child table. You can add a CSS rule to hide specific columns from the child table. In the generated hooks/footer-extras.php, add code similar to this:
Many users wonder which files should they upload to their web server after adding a new table to AppGini and generating the app. Of course, you could just upload everything and you’d be on the safe side. But sometimes you might be working over a slow network or a metered data connection and don’t have the luxury of uploading everything. In that case, you could just upload only the changed files.
So, here is a list of all files changed when you add a new table to your AppGini project.
resources/table_icons/*.png (normally only one new file exists in this folder, which is the icon of the new table)
all files beginning with the new table name in the main application folder and in templates folder.
Let’s say you have a numeric field, maybe a price, a score or some other field that should contain numbers only. If you set the data type of the field in AppGini (or in your database) to be numeric (INT, DECIMAL, FLOAT … etc) that would allow only numbers to be stored in the database.
First, you should place this code in the hooks/footer-extras.php file:
Next, also in the hooks folder, create a file named tablename-dv.js (where tablename is the name of the concerned table) if it’s not already there, and add this code to it:
Change field1 and field2 in the above code to the actual names of the fields that you want to set to accept only numeric values. Add more lines if you have more fields or remove a line if you have only one numeric field.
The above code would remove any non-numeric characters that the user types, on the fly. And it would still allow negative sign and decimal point.
If you have a time field in your AppGini application, it displays a time picker in the detail view like this one:
The timepicker includes seconds. If you wish to hide the seconds part, you could do so by editing the tablename_dv hook. Open the generated hooks/tablename_dv.php file in a text editor (where tablename is the name of the concerned table) and look for the dv function, then add this line inside it:
An AppGini customer told me recently that he has a table containing only one field, a barcode field, that he uses a barcode scanner to populate. He has thousands of items to enter, and wanted to know if there is someway to expedite his workflow, maybe by avoiding to click ‘Save as copy’ everytime he scans a new barcode.
I suggested the following code to him, to be placed in the hooks/tablename-dv.js (where tablename is the name of the concerned table — create that file if it doesn’t already exist).
Change fieldname in line 2 above to the actual name of the barcode field. The above code checks if the concerned barcode field has been changed. If it has been, the ‘Save as copy’ button (using the #insert selector) is clicked.
But if your field is an image field, the above code won’t work. Try this instead:
In some projects that I work on, I need a quick way of adding some cool-looking user-friendly on/off switch. Checkboxes are ugly! And I don’t want to add a new component/plugin to the already loaded pages. So, I wrote some quick code snippet for a switch based on Bootstrap 3 and jQuery. Here is the HTML code: