[eluser]originalmmd[/eluser]
*EDIT: Please note, I am not a programmer. Therefore what is obvious for most of you might not be fore me. I really just need a helpin' hand / point in the right direction. Thank you in advance to anyone who can help.*
Hey all. This is one of those rewrite my program for me posts but I'm out of options here. We got this code from a programmer we hired and it's not working. Tried fiddling with it myself, tried oDesk (programmer didn't understand the problem) now I'm out of time on the project and over budget. Going to try and fix it myself, but i need some help with the logic.
The program does time and attendance per project for a small factor. Here's what it's supposed to do:
On page / controller index.php/employeeselect
The user their project and name and clocks in. The model checks if the user is already logged in, if not, it writes a punch to table punch. If user is logged in, the model selects the last logged in record, adds the times together and writes to table time, then writes a punch to table punch.
If an employee punches on the same job they are currently punched into, the system calculates time spent on the job and writes to the table time. Then the user is automatically punched into "waiting time".
All hours that are not clocked on a project, should be clocked to waiting time to make 8 hours for the day between 7am and 4:30pm.
index.php/reports
generates a report of the employee for all projects between start date and end date
index.php/reports2
generates a report of all employees working on a specified project between start date and end date
There are 4 cron jobs:
one that runs at 7:00 to clock everyone into waiting time.
one that runs at 12:30 to clock everyone into after hours.
on that runs at 13:00 to clock everyone back to waiting time.
and one that runs at 16:30 to clock everyone to after hours.
The problem that we have at the moment is that the logic is not working and the employees are being logged out and in of jobs and waiting time in the wrong order.
Here's the code for employeeselect:
Controller
Code:
<?php
class employeeselect extends CI_Controller {
// function index() {
// $this -> load -> model('employeeselect_model');
// $project = $this -> employeeselect_model -> get_project();
// $data['project'] = $project;
// $data['select_jobs'] = $this -> employeeselect_model -> get_project();
// $person = $this -> employeeselect_model -> get_person();
// $data['person'] = $person;
// $data['page_title'] = "Log your time!";
// $this -> load -> view('employeeselect_view', $data);
// }
function index() {
$data = array();
$this -> load -> model('employeeselect_model');
$data['select_options'] = $this -> employeeselect_model -> get_jobs();
$data['select_people'] = $this -> employeeselect_model -> get_people();
$this -> load -> view('employeeselect_view', $data);
}
function punch() {
$this -> load -> model('employeeselect_model');
$this -> employeeselect_model -> newtimespan($_POST);
$this -> employeeselect_model -> newpunch_in();
redirect('employeeselect', $data);
}
function punchout() {
$this -> load -> model('employeeselect_model');
//$this -> employeeselect_model -> timespans($_POST);
$this -> employeeselect_model -> logoff();
redirect('employeeselect', $data);
}
}
?>