I have my first serious project and that is to build a web based attendance log within my organizations Drupal site.

My first thought was to use a webform with an input field that will accept a scanned ID. This scanned ID will be searched in an external SQL database(not Drupal) and return the ID along with the attached person's name. The ID, the date it was scanned, and the person's name will recorded in Drupal as a type of log of some sort that if necessary, can be viewed later.

I have been advised that using a webform may not be the way to do this. I am also doubting using a webform, because the field to scan the ID should always just be available and do nothing but accept the scanned ID and display back to the user, their ID, time they scanned in, and their name. So, in this since it works like an employee clocking in and out of work. It should always just be available.

As I wrote before "I saw some attempts to create something similar with a Drupal Course module or Sign Up module. I can't risk using these modules that someone has done, but have not kept up with. So, I am trying to do it myself with limited expertise :-(, but with the Drupal community support :-). I know that there must be others out there still trying to get something like this integrated into their Drupal sites."

So, please advise me on how to do this.
1.) is it possible to do this in Drupal 7
2.) if possible, can a beginner in PHP and Drupal do something like this or will it take a more seasoned Drupal developer
3.) should it be a webform, a custom module or what else?

Comments

mattc321’s picture

1. Yes (D7 should always be your first pick over d6 or d8)
2. Yes
3. No

Also, don't be afraid to install critical modules. That is the whole point of Drupal is to be extensible. Especially the ones I have listed. They are mature, and your site will not outlive them, I guarantee it. They are extensions of Drupal's core.

Your on to something here, but no, you definitely would not want to use a webform. It sounds like you are perhaps unfamiliar with what drupal core is capable of. For multiple reasons a webform is unnecessary. Drupal core, along with the Views module, is more than capable of doing this for you in a very professional way (as far as tracking and viewing attendance goes). When it comes to looking up data in an external database, you will undoubtedly need to create some custom code using some 3rd party drivers in order to accomplish. However, if this is out of your reach, there are easier ways of referencing this external data.

First: Create a new content type in Drupal core, call it "Attendance". Add all of the fields you want to add. Call the title field "employee name", maybe a text field to hold a date...Any other fields you may want or need. After you finish creating the content type, go to your admin menu and click on Content > Add New Content > Attendance...This will bring you to a new blank form that has all of the fields you created. When you fill out these fields and click save, it will create a new record inside the Attendance content type. Think of a content type as a database table... It is a table of fields that holds records.

Now you can create a link on your Main Menu, that points to the Add New Content form. The url is probably yourdomain.com/?q=node/add/attendance

Everytime someone clicks on this link, they can fill out the form, and create a new attendance record.

Second: Download and install the Views module. Enable the module, as well as Views UI (they all come together). Now go through a short tutorial on creating a new basic view. This will help you create a simple page that displays your Attendance records in a nice table like format. Basically, a view is like a query. Show choose which content type it is filtered by, then you should what fields you want to see, and voila you have a nice recordset displaying all of the records in Attendance. You may then give the View a url path. Then, anytime you go to this url path, you will see your view.

Third: You want to be able to scan in ID's and have them pull back employees names. But you need to do it in a crafty way that doesnt involve moderate coding. Create a new content type called "Employees"...Add the fields you want to it, such as Name, ID#, hire date, etc.

Now, download and install the Feeds module. Feeds, will allow you to import data into a content type. So what you can do is...export the employee data from your external database. Export whatever fields you want. Now go to your Drupal site, and create a new Feeds import. Basically an importer will allow you to upload a csv file containing your information and put it into your Employees content type. You map the fields just like any other program.

Import your export data into the Employees content type you made. This will have multiple steps, but I assure you it is a million times easier than creating a custom module securely.

NOW, here is the best part. When you are done importing the data, you can go back to your Feeds configuration, and you can change the settings to be "Periodic Import"...This means the feeds module will re-import the data as a scheduled task. It will look to a particular folder, and it will import the records however often you want. Meaning, all you have to do, is export the data from your other database, and drop it in this folder. Then feeds will import it, and refresh your Drupal site.

If you do make it through this entire process, download and install Entity Reference, and Inline Entity Display modules.

Then go back to your Attendance content type, and create a new entity reference field that points to your Employees content type. Now, your attendance form will be able to lookup employees bases on whatever you want. Their name, their scanned ID Badge, etc.

If you do all of that, anyone can go to this form, scan in their badge, it will automatically look them up, and they can save the record.

I know that is a lot of information, but its better to give you the whole entire thing, than just bits and pieces. Hope this helps buddy!

Matt

fuzzbuzz’s picture

Yes, yes, yes I can do this! Yes users will still need to click on a button to scan, but this is enough to get a working system that I can then build on in the future when I get more experience.

Thanks Matt. I am not sure where World Fallz will put this post, but I will be back. Time to get started.

Update: I have recently been told that this pilot will be tested in a library. So, students will be logged in under a librarians Drupal account. She will then be able to keep track of the students in her area.

WorldFallz’s picture

ok, i give up on this topic, lol. Feeds is what I suggested in the previous post.

fuzzbuzz’s picture

Hi Matt. Below is an example of what my drafted attendance log looks like right now. This is based on a view that I created. I believe I have completed parts 1 and 2 of your instructions, however, part 3 (working with entity references), I cannot seem to figure out.

How this is working: A user clicks on the attendance log content type and must enter a title and an ID number to log in. Those 2 values are shown to the user on submit(Eventually I want to show the name and ID number of the person associated with the log in ID). The log ins can be viewed, by navigating to the view that I created (again this is displayed below). The bold section comes from the input from the attendance log in, the unbold section is suppose to come from a content type that I called "Student". The content type student, is pulling data from the feed that I created from a CSV file.

The problem: What the user inputs as an ID on the attendance log in, is not linking to the "Student" content type that I created. What I was hoping to accomplish is that when the user submits the attendance log in(they log in), the Attendance Log View can pick up the Student ID and Student Name associated with the ID the user inputted(from the Students content type.

My Question: I thought the student ID and student name fields on the attendance view could be auto populated by the "Student" content type that holds data on the students such as ID,name, school etc. Is this what the entity reference suppose to do or am I missing a step somewhere?

Attendance Log

Title Author Uid Datetime ID Student ID Student Name
Library 88 Tuesday, Oct 15 449099
Room 310 89 Tuesday, Oct 14 883990

bander2’s picture

What is a "scanned ID"?

So, in this since it works like an employee clocking in and out of work. It should always just be available.

What does it mean to "always just be available"?

- Brendan

fuzzbuzz’s picture

I need to rewrite my post with better English grammar.

By scanned in I mean: Accept an ID number off an ID card as input (ID will be scanned in by a scanner).

By always available, I mean: That with a webform, the user must click on the webform to use it and then hit submit to submit the data. With the attendance log I want to create, I want to eliminate both of those additional steps if possible. So no clicking on the form to scan their ID and no hitting a submit button. I want the user to put their ID underneath the scanner, the scanner scans it into the drupal field, and then their ID number is displayed along with their name and the time they scanned in. Then I want it to be ready to scan the next individual.

jaypan’s picture

I built something like this one time in my old company, on D6. We used an RFID reader, and as employees came in they tapped their card to it to register arrival and departure.

In the RFID scanner unit we had, we were able to set a URL to which the scanned data was sent when the card was scanned. So I set the following:

1) I had to set up a 'register' button in user's account profiles. When this button was pushed, a flag was set in the system to register the next scanned card to the current profile.

2) I set up a system path that we used as the URL that the RFID reader sent the data to.

3) In that system path, I checked if the flag from #1 had been set, and if it had, to save the card data to the profile in question.

4) If the flag from #1 was not set, the page searched the db for a user who had registered the current card data, and if found, it either checked them in, or out, depending on whether or not they were in the office or not.

Contact me to contract me for D7 -> D10/11 migrations.

fuzzbuzz’s picture

Hey, Jaypan.

I will go with Matt's first, because I can literally do it now. Yours will require more custom code, so I will probably try it out towards the end of the this year after I complete my course in PHP. By then I should have a much better feel for Drupal and can really turn it up over here at my job.

The only down-side for going with your approach, is that I will eventually need to add students to this attendance log. Student's do not have accounts on our Drupal site. The students will be logged-in under an employees account. I have recently been told that this pilot will be tested in a library. So, students will be logged in under a librarians Drupal account. She will then be able to keep track of the students in her area.

WorldFallz’s picture

For context, see https://www.drupal.org/node/2569115. Also, since this is not a programming post, i've moved it to the correct forum.

fuzzbuzz’s picture

Sooooo, where did you move it?

Update: Nevermind World Fallz. I see it is posted in "Post Installation".

mattc321’s picture

A normal Drupal "Add New Content" form will be just as available as any webform would be. In your case they are essentially the same thing. So there would be no need for a webform unless that was your preference.

As far as high availability goes - you were talking about being able to scan a badge and immediately have it be ready for the next?

Well, there are a couple of ways you could do this. The first would be using a small amount of code that we could help you with. When you are on the "Add New Content" form for attendance ( a blank attendance form), you can add some code that runs as soon as the badge ID field is updated. The code could save the node and reload the page back to a new fresh form, all automatically.

The second thing you could do, and probably the easiest, would be to create a Rule that goes back to a new blank form anytime an attendance record is saved. This would be very easy to setup, and would not require code.

The third and hardest option would be to create and editable view. This would display all of your attendance records in a table like format, almost like excel. Then add some custom code to allow new records to be created in that view. The user would never have to save or reload the page. They would just scan someones info into the blank field at the bottom of the table and it would save that record inline with the rest.

Drupal's best purpose is for making management applications like this. If you put your mind to it you can have an awesome system in no time.