ive a project in which a user can add record but that can published in the front end end only after it is verified and approved by admin. Please help me with the workflow and php code for this
here is a thought , because this is what i have implemented in my system
we have bunch of data entry guys , they add data . Then asks administrator to review once it done administrator publishes.
i have created one extra field flag and by default flag is 0 for newly entaied data.
once admin review the work he then updates the table setting flag to 1
That is not a problem. What you need to do is very simple.
First of all
You need to create a table in database which store all the data you want.
You need to create 1 more field which store any variable. Example ('0' or 'pending' as default ). Or you can store by using INSERT sql. What I mean is when you doing your form using php and then you insert the particular field as 0 or pending.
INSERT INTO table ('name', 'contact', 'field')VALUES ('$name','$contact','0/pending')
Create an admin site which use to verify and approve manually for the new user.
Do a transaction which can change the status of the field.
Update the field if admin approve to 1 or approved.
PS* if do not approve just let the field remain 0 or change the value to rejected.
Select the result by calling the specific value which according to the value you set in the field. For example you set the value is approved. Then what you should do is :
SELECT * FROM table WHERE field = approve
This should be what you want.
I can give you some raw steps.
Create a flag (column) is_published in you users table.
Set this flag default value as 0
Provide an option in the admin panel with approve or publish button.
On click of the above mentioned buttons run an ajax request update that particular column with value 1.
In the front end part list only those records where is_published = 1 or is_published != 0
Hope this can solve your problem.
Related
I have website login system and after logging in, users can withdraw amount that is stored in database, the problem is when someone login using multiple devices and submit withdraw form at the same time he/she will recieve the amount multiple times. How to prevent users submitting at the same time ?
Make a field in the users table LOCKED with default value of zero and when its value is 1 disallow the transaction and every time a transaction takes place toggle it to 1 and back to zero when finished.
In order to answer your questions, I'll assume that:
1. You are using mysql database.
2. A user is allowed ONLY one withdrawal.
In your database, create a table named withdrawal.
Then, add fields like:
id INT PRIMARY KEY
user_id INT UNIQUE
withdraw_amount DECIMAL(10,2)
In this case, the user can only submit ONE record to withdrawal table since the user_id field is UNIQUE.
But, if my assumptions don't match with exactly what you require, then provide more information about what you need.
I am working on the CI in this project i need to implement user activity tracking for logged in user like if any user see any records i can save that to the database and if any record is updated then i need show get only that particular updated filed value and show in the log table like this user 'xyz' has updated the phone number from '123456' to '546789'. like this if any recorded is updated, added, deleted, or viewed then i want to able to track that, i hope that make sense.
Any help is appreciated....
You can maintain a column in your table which will store the activity. when your required event is triggered.e.g.Updating Employee No. 1 to 100 will Store Activity as an Update and you can add one more column to store the ID of the updated Entry. hope this helps.
I am working on PHP YII (Version 1.15) User management application.
My Scenario: A user can be assigned as supervisor and there are 'n' numbers of subordinates can assign to the user. Likewise, there are many supervisor available in the application. All users details falls in one table.
Objective: I want to give access to the supervisor to Edit and Delete only to the assigned subordinates. Other users data, he can't able to modify.
What I Tried: I am validating the call everytime before the supervisor clicks the edit button of the subordinates. (I have many forms, so have to use the code many places repeatedly)
Please help me to solve this issue.
Is it possible for you to add some column to your user table?
If it's possible, you should add one column in your user table that indicates the user's supervisor. It can contain the supervisor ID. Supervisors have null value for this column, so this column should be nullable. You can use the value of this column to validate supervisor's access to Edit and Delete by matching the ID of supervisor with this column's value.
I know I can extract Sales Order data in OpenCart database, in table shop_order and shop_order_product.
Is it possible to differentiate which user creates the sales order?
I don't think there's an option to identify which admin user created the order. You may need to code it yourself. The below steps may help you.
Add 2 new fields created_user_id and updated_user_id in order table - with default value as 0.
Update the admin/model/sale/order.php to insert values to those fields as $this->user->getId(); (addOrder and editOrder functions ).
Add a new field user_id in order_history table - with default value as 0.
Update the admin/model/sale/order.php to insert value to that field as $this->user->getId(); (function: addOrderHistory).
You can do these by directly modifying the files or using vqmod. If it's done via vqmod then it'll be easier for you to make changes during opencart version upgrade.
Opencart: Vqmod tutorial
Have a nice day!!
By default, there's no way to know which admin an order is created by, or even that the order isn't created by the user (other than the IP would be that of the admin). You could in theory add the user_id to the shop_order table, and pass that to the manual order editor when it creates the orders
i created a table in the database (mysql),and i write a code for inserting data in the datbase using php.values are inserted properly.here i set the status column value as deactive.when user created in that time ,we send a mail to the user to active the link ,means my site and then status column has to changed as active.
my db table contains the following columns
name,email,pwd,status,lastlogin,security qun,ans
when user is created in that time i set the status as deactive.in that time i want to sent a mail(in this mail,i want to send the link to their account) to the user to active their account ,then only user goes to the next process.after that when user open the mail & click that link,the status column has to changed as active in the database.how can i do this,anyone help me..
one way to solve the problem is:
make the field 'status' as varchar not int.
when you are inserting user information for the first time, make a random string and insert it in the status field.
say your random string you have created is 'lka342lkjasd8234kl2324ljklj2'. send the link with the string as a parameter.
when the link is clicked in the script check the verification string matches the value in your status table.
if it matches then show message that his account is verified and change the value of the field to 1 (as 1 indicates a active account)
if the string doesn't matches then show message the verification link is wrong.
in another way you can make another table for storing verification string. and make the status fiend an integer. set 0 initially and make it 1 when verified, and check the verification with the new table.
You can create column called activation_code, send an email to user with link, which will contain this activation_code. Link like this www.example.com/active.php?activation_code=AABBCCDDEEFF, when user click this link you can get activation_code, find a user at database and change status. Also you can create column activation_expires which will contain a date when activation code will expire.