Exemplo n.º 1
0
 public function body_content()
 {
     global $FANNIE_URL;
     $sql = WfcHtLib::hours_dbconnect();
     ob_start();
     echo "<style type=text/css>\n#payperiods {\n    margin-top: 50px;\n}\n\ntr.one td {\n    background: #ffffcc;\n}\ntr.one th {\n    background: #ffffcc;\n    text-align: right;\n}\n\ntr.two td {\n    background: #ffffff;\n}\ntr.two th {\n    background: #ffffff;\n    text-align: right;\n}\na {\n    color: blue;\n}\n\n#temptable th {\n    text-align: left;\n}\n#temptable td {\n    text-align: right;\n    padding-left: 2em;\n}\n\n#temptable {\n    font-size: 125%;\n}\n\n#newtable th{\n    text-align: left;\n}\n#newtable td{\n    text-align: right;\n}\n\n</style>";
     echo "<h3>Salary Employee PTO Status</h3>";
     $infoQ = $sql->prepare_statement("select e.name,e.adpID,\n            s.totalTaken as daysTaken\n            from employees as e left join\n            salarypto_ytd as s on e.empID=s.empID\n            where e.empID=?");
     $infoR = $sql->exec_statement($infoQ, array($this->empID));
     $infoW = $sql->fetch_row($infoR);
     echo "<h2>{$infoW['name']} [ <a href={$FANNIE_URL}auth/ui/loginform.php?logout=yes>Logout</a> ]</h2>";
     echo "<table class=\"table\" id=newtable>";
     echo "<tr class=one><th>PTO Allocation</th><td>{$infoW['adpID']}</td></tr>";
     echo "<tr class=two><th>PTO Taken, YTD</th><td>{$infoW['daysTaken']}</td></tr>";
     echo "<tr class=one><th>PTO Remaining</th><td>" . ($infoW['adpID'] - $infoW['daysTaken']) . "</td></tr>";
     echo "</tr></table>";
     $periodsQ = $sql->prepare_statement("select daysUsed,month(dstamp),year(dstamp) \n                from salaryHours where empID=? order by dstamp DESC");
     $periodsR = $sql->exec_statement($periodsQ, array($this->empID));
     $class = array("one", "two");
     $c = 0;
     echo "<table id=payperiods class=\"table\">";
     echo "<tr><th>Month</th><th>PTO Taken</th></tr>";
     while ($row = $sql->fetch_row($periodsR)) {
         echo "<tr class=\"{$class[$c]}\">";
         $dstr = date("F Y", mktime(0, 0, 0, $row[1], 1, $row[2]));
         echo "<td>{$dstr}</td>";
         echo "<td>{$row['0']}</td>";
         echo "</tr>";
         $c = ($c + 1) % 2;
     }
     echo "</table>";
     echo "<div class=\"well\">\n        <u>Please Note</u>: This web-base PTO Access Page is new. If you notice any problems,\n        please contact Colleen or Andy.\n        </div>";
     echo "</body></html>";
     return ob_get_clean();
 }
Exemplo n.º 2
0
 public function fetch_report_data()
 {
     $sql = WfcHtLib::hours_dbconnect();
     $fetchQ = "select e.name,e.adpID,e.PTOLevel,\n            h.totalHours,c.cusp,e.empID,\n            p.ptoremaining,u.hours\n            from employees as e left join hoursalltime as h on e.empID=h.empID\n            left join cusping as c on e.empID=c.empID\n            left join pto as p on e.empID=p.empID\n            left join uto as u on e.empID=u.empID\n            where deleted=0\n            order by e.name";
     $fetchP = $sql->prepare_statement($fetchQ);
     $fetchR = $sql->exec_statement($fetchP);
     $report = array();
     while ($fetchW = $sql->fetch_row($fetchR)) {
         $record = array($fetchW['name'], $fetchW['adpID'], $fetchW['PTOLevel'], $fetchW['ptoremaining'], $fetchW['hours'], $fetchW['totalHours']);
         $report[] = $record;
     }
     return $report;
 }
Exemplo n.º 3
0
 public function fetch_report_data()
 {
     $sql = WfcHtLib::hours_dbconnect();
     $query = '
         SELECT e.name,
             e.adpID,
             e.PTOLevel,
             p.PTORemaining,
             \'\' AS spacer,
             l.LevelID,
             l.PTOHours,
             l.HoursWorked,
             h.totalHours,
             h.totalHours - c.HoursWorked AS hoursAtCurrentLevel,
             l.HoursWorked - c.HoursWorked AS levelspan,
             ((h.totalHours-c.HoursWorked) / (l.HoursWorked-c.HoursWorked)) * 100 as percentProgress,
             ((h.totalHours-c.HoursWorked) / (l.HoursWorked-c.HoursWorked)) * l.PTOHours as prorated,
             \'\' AS spacer2,
             p.PTORemaining + ((h.totalHours-c.HoursWorked) / (l.HoursWorked-c.HoursWorked)) * l.PTOHours as ttl
         FROM employees AS e
             LEFT JOIN pto AS p ON e.empID=p.empID
             LEFT JOIN PTOLevels AS l ON e.PTOLevel+1=l.LevelID
             LEFT JOIN PTOLevels AS c ON e.PTOLevel=c.LevelID
             LEFT JOIN hoursalltime AS h ON e.empID=h.empID
         WHERE e.deleted=0
             AND e.department < 900
         ORDER BY e.name';
     $result = $sql->query($query);
     $report = array();
     while ($row = $sql->fetch_row($result)) {
         $record = array();
         for ($i = 0; $i < $sql->num_fields($result); $i++) {
             if (is_numeric($row[$i]) && $row[$i] != (int) $row[$i]) {
                 $row[$i] = number_format($row[$i], 2);
             }
             $record[] = $row[$i];
         }
         $report[] = $record;
     }
     return $report;
 }
Exemplo n.º 4
0
 public function body_content()
 {
     $db = WfcHtLib::hours_dbconnect();
     $empID = FormLib::get('id');
     if (!is_numeric($empID)) {
         return '<div class="alert alert-error">Error: no employee ID specified</div>';
     }
     $fetchQ = $db->prepare_statement("select adpid,name,department from employees where empID=?");
     $fetchR = $db->exec_statement($fetchQ, array($empID));
     $fetchW = $db->fetch_row($fetchR);
     $ret = "<form action=WfcHtListPage.php method=post>";
     $ret .= "<input type=hidden name=action value=update />";
     $ret .= "<input type=hidden name=id value={$empID} />";
     $ret .= '<div class="form-group">';
     $ret .= "<label>ADP ID#</label>\n            <input class=\"form-control\" type=text name=adpid value=\"{$fetchW['adpid']}\" />";
     $ret .= '</div>';
     $ret .= '<div class="form-group">';
     $ret .= "<label>Name</label>\n            <input class=\"form-control\" type=text name=name value=\"{$fetchW['name']}\" />";
     $ret .= '</div>';
     $ret .= '<div class="form-group">';
     $ret .= "<label>Department</label>";
     $deptsQ = "select name,deptID from Departments order by name";
     $deptsR = $db->query($deptsQ);
     $ret .= "<select name=dept class=\"form-control\">";
     $ret .= "<option value=\"\"></option>";
     while ($deptsW = $db->fetch_row($deptsR)) {
         if ($deptsW['deptID'] == $fetchW['department']) {
             $ret .= "<option value={$deptsW['deptID']} selected>{$deptsW['name']}</option>";
         } else {
             $ret .= "<option value={$deptsW['deptID']}>{$deptsW['name']}</option>";
         }
     }
     $ret .= "</select>";
     $ret .= "</div>";
     $ret .= "<p><button type=submit class=\"btn btn-default\">Save Changes</button>";
     $ret .= ' <a href="WfcHtListPage.php" class="btn btn-default">Cancel</a>';
     $ret .= "</p>";
     $ret .= "</form>";
     return $ret;
 }
Exemplo n.º 5
0
 public function body_content()
 {
     $sql = WfcHtLib::hours_dbconnect();
     if (FormLib::get('month') !== '') {
         $ids = FormLib::get('ids', array());
         $days = FormLib::get('days');
         $datestamp = FormLib::get('year') . "-" . str_pad(FormLib::get('month'), 2, '0', STR_PAD_LEFT) . "-01";
         $insQ = $sql->prepare_statement("INSERT INTO salaryHours VALUES (?, ?, ?)");
         for ($i = 0; $i < count($ids); $i++) {
             $sql->exec_statement($insQ, array($ids[$i], $datestamp, $days[$i]));
         }
         return '<div class="alert alert-success">Salary PTO added</div>';
     } else {
         $ret = "<form action=\"{$_SERVER['PHP_SELF']}\" method=post>";
         $fetchQ = "select empID,name from employees where department >= 998 \n                and deleted=0 order by name";
         $fetchR = $sql->query($fetchQ);
         $ret .= '<div class="row"><div class="col-sm-5">';
         $ret .= "<table class=\"table\">";
         $ret .= "<tr><th>Employee</th><th>Days taken</th></tr>";
         while ($fetchW = $sql->fetch_row($fetchR)) {
             $ret .= "<tr><td>{$fetchW['name']}</td>";
             $ret .= "<td><input type=number name=days[] class=\"form-control\" required value=0 /></td>";
             $ret .= "<input type=hidden name=ids[] value={$fetchW['empID']} /></tr>";
         }
         $ret .= "<tr><th>Month</th><th>Year</th></tr>";
         $ret .= "<tr><td><select name=month class=\"form-control\">";
         for ($i = 1; $i <= 12; $i++) {
             $stamp = mktime(0, 0, 0, $i, 1);
             $mname = date('F', $stamp);
             $ret .= "<option value={$i}>{$mname}</option>";
         }
         $ret .= "</select></td><td>";
         $ret .= "<input type=number class=\"form-control\" required name=year value=" . date("Y") . " /></td></tr>";
         $ret .= "</table>";
         $ret .= "</div></div>";
         $ret .= '<p><button type="submit" class="btn btn-default">Submit</button></p>';
         $ret .= "</form>";
         return $ret;
     }
 }
Exemplo n.º 6
0
    public function form_content()
    {
        $sql = WfcHtLib::hours_dbconnect();
        $periods = "";
        $periodQ = "SELECT periodID,dateStr from PayPeriods ORDER BY periodID desc";
        $periodR = $sql->query($periodQ);
        while ($periodW = $sql->fetch_row($periodR)) {
            $periods .= "<option value={$periodW['0']}>{$periodW['1']}</option>";
        }
        ob_start();
        ?>
<form method=get action="<?php 
        echo $_SERVER['PHP_SELF'];
        ?>
">
<table><tr>
<td>
<b>Starting pay period</b>:
</td><td>
<select name=startPeriod><?php 
        echo $periods;
        ?>
</select>
</td></tr>
<tr><td>
<b>Ending pay period</b>:
</td><td>
<select name=endPeriod><?php 
        echo $periods;
        ?>
</select>
</td></tr>
</table>
<input type=submit value=Submit />
</form>
        <?php 
        return ob_get_clean();
    }
Exemplo n.º 7
0
 public function get_view()
 {
     $db = WfcHtLib::hours_dbconnect();
     $model = new WfcHtEmployeesModel($db);
     $model->deleted(1);
     $ret = '<form action="' . $_SERVER['PHP_SELF'] . '" method="post">
         <div class="form-group">
             <label>Employee</label>
             <select name="oldID" class="form-control">';
     foreach ($model->find('name') as $e) {
         $ret .= sprintf('<option value="%d">%s (%d)</option>', $e->empID(), $e->name(), $e->empID());
     }
     $ret .= '</select>
         </div>
         <div class="form-group">
             <label>New ID#</label>
             <input type="number" name="newID" class="form-control" />
         </div>
         <p>
             <button type="submit" class="btn btn-default">Change ID</button>
         </p>
         </form>';
     return $ret;
 }
Exemplo n.º 8
0
 public function body_content()
 {
     global $FANNIE_OP_DB;
     $EXCLUDE_EMAILS = array('root' => True, 'finance' => True, 'pop' => True, 'quickbooks' => True, 'testuser' => True, 'printer' => True, 'games' => True, 'csc' => True, 'ldap' => True, 'relfvin' => True, 'jkresha' => True);
     $new_accounts = array();
     $ret = '';
     $db = WfcHtLib::hours_dbconnect();
     $chkQ = $db->prepare_statement("SELECT empID, name FROM employees WHERE empID=?");
     $insQ = $db->prepare_statement("INSERT INTO employees VALUES (?,?,NULL,0,8,NULL,0)");
     exec('getent passwd', $users, $exit_code);
     foreach ($users as $line) {
         // extract users with group 100 from unix passwd file
         $fields = explode(":", $line);
         $uid = $fields[2];
         $group = $fields[3];
         if ($group != "100") {
             continue;
         }
         $shortname = $fields[0];
         if (isset($EXCLUDE_EMAILS[$shortname])) {
             continue;
         }
         // reformat name as "last, first"
         $tmp = explode(" ", $fields[4]);
         $name = "";
         for ($i = 1; $i < count($tmp); $i++) {
             $name .= $tmp[$i] . " ";
         }
         if (count($tmp) > 1) {
             $name = trim($name) . ", ";
         }
         if (count($tmp) == 0) {
             $name = $shortname;
         } else {
             $name .= $tmp[0];
         }
         // create entry in hours database
         $chkR = $db->exec_statement($chkQ, array($uid));
         if ($db->num_rows($chkR) == 0) {
             $new_accounts[$uid] = $shortname;
             $db->exec_statement($insQ, array($uid, $name));
             $ret .= "Added ADP entry for {$name}<br />";
         } else {
             $w = $db->fetch_row($chkR);
             if ($name != $w['name']) {
                 echo '<span class="glpyhicon glyphicon-exclamation-sign"></span>';
             }
             echo "{$name} exists as ";
             echo $w['name'] . '<br />';
         }
     }
     echo '<hr />';
     /**
       Create corresponding POS user accounts
     */
     $dbc = FannieDB::get($FANNIE_OP_DB);
     $chkQ = $dbc->prepare_statement("SELECT uid FROM Users WHERE uid=?");
     $insQ = $dbc->prepare_statement("INSERT INTO Users VALUES (?,'','',?,'','')");
     foreach ($new_accounts as $uid => $uname) {
         $uid = str_pad($uid, 4, '0', STR_PAD_LEFT);
         $chkR = $dbc->exec_statement($chkQ, array($uid));
         if ($dbc->num_rows($chkR) == 0) {
             $dbc->exec_statement($insQ, array($uname, $uid));
             $ret .= "Added user account for {$uname}<br />";
         }
     }
     if (count($new_accounts) == 0) {
         $ret .= '<i>No new employees found</i><br />';
     }
     $ret .= '<p />
         <a href="WfcHtMenuPage.php">Main Menu</a>';
     return $ret;
 }
Exemplo n.º 9
0
 public function body_content()
 {
     $db = WfcHtLib::hours_dbconnect();
     $ppID = -1;
     if (FormLib::get('id') !== '') {
         $ppID = FormLib::get('id');
     }
     $order = "e.name";
     if (isset($_GET["order"])) {
         switch (strtolower($_GET['order'])) {
             case 'name':
                 $order = 'e.name';
                 break;
             case 'adpid':
                 $order = 'e.adpid';
                 break;
             case 'hours':
                 $order = 'i.hours';
                 break;
             case 'othours':
                 $order = 'i.othours';
                 break;
             case 'ptohours':
                 $order = 'i.ptohours';
                 break;
             case 'emergencyhours':
                 $order = 'i.emergencyhours';
                 break;
             case 'secondratehours':
                 $order = 'i.secondratehours';
                 break;
         }
     }
     $dir = "asc";
     if (isset($_GET["dir"])) {
         switch (strtolower($_GET['dir'])) {
             case 'asc':
                 $dir = 'asc';
                 break;
             case 'desc':
                 $dir = 'desc';
                 break;
         }
     }
     $otherdir = "desc";
     if ($dir == "desc") {
         $otherdir = "asc";
     }
     $ret = "<select class=\"form-control\" onchange=\"top.location='{$_SERVER['PHP_SELF']}?id='+this.value;\">";
     $ppQ = "select periodID,dateStr from PayPeriods order by periodID desc";
     $ppR = $db->query($ppQ);
     while ($ppW = $db->fetch_row($ppR)) {
         $ret .= "<option value={$ppW['0']}";
         if ($ppW[0] == $ppID) {
             $ret .= " selected";
         }
         if ($ppID == -1) {
             $ppID = $ppW[0];
         }
         $ret .= ">{$ppW['1']}</option>";
     }
     $ret .= "</select>";
     $ret .= "<table class=\"table\">";
     $ret .= "<tr>";
     if ($order == "e.name") {
         $ret .= "<th><a href={$_SERVER['PHP_SELF']}?id={$ppID}&order=name&dir={$otherdir}>Name</a></th>";
     } else {
         $ret .= "<th><a href={$_SERVER['PHP_SELF']}?id={$ppID}&order=name&dir=asc>Name</a></th>";
     }
     if ($order == "e.adpid") {
         $ret .= "<th><a href={$_SERVER['PHP_SELF']}?id={$ppID}&order=adpid&dir={$otherdir}>ADP ID</a></th>";
     } else {
         $ret .= "<th><a href={$_SERVER['PHP_SELF']}?id={$ppID}&order=adpid&dir=asc>ADP ID</a></th>";
     }
     if ($order == "i.hours") {
         $ret .= "<th><a href={$_SERVER['PHP_SELF']}?id={$ppID}&order=hours&dir={$otherdir}>Reg. Hours</a></th>";
     } else {
         $ret .= "<th><a href={$_SERVER['PHP_SELF']}?id={$ppID}&order=hours&dir=asc>Reg. Hours</a></th>";
     }
     if ($order == "i.othours") {
         $ret .= "<th><a href={$_SERVER['PHP_SELF']}?id={$ppID}&order=othours&dir={$otherdir}>OT Hours</a></th>";
     } else {
         $ret .= "<th><a href={$_SERVER['PHP_SELF']}?id={$ppID}&order=othours&dir=asc>OT Hours</a></th>";
     }
     if ($order == "i.ptohours") {
         $ret .= "<th><a href={$_SERVER['PHP_SELF']}?id={$ppID}&order=ptohours&dir={$otherdir}>PTO Hours</a></th>";
     } else {
         $ret .= "<th><a href={$_SERVER['PHP_SELF']}?id={$ppID}&order=ptohours&dir=asc>PTO Hours</a></th>";
     }
     if ($order == "i.emergencyhours") {
         $ret .= "<th><a href={$_SERVER['PHP_SELF']}?id={$ppID}&order=emergencyhours&dir={$otherdir}>Emerg. Hours</a></th>";
     } else {
         $ret .= "<th><a href={$_SERVER['PHP_SELF']}?id={$ppID}&order=emergencyhours&dir=asc>Emerg. Hours</a></th>";
     }
     if ($order == "i.secondratehours") {
         $ret .= "<th><a href={$_SERVER['PHP_SELF']}?id={$ppID}&order=secondratehours&dir={$otherdir}>Alt. Hours</a></th>";
     } else {
         $ret .= "<th><a href={$_SERVER['PHP_SELF']}?id={$ppID}&order=secondratehours&dir=asc>Alt. Hours</a></th>";
     }
     $ret .= "</tr>";
     $dataQ = "select e.name,e.adpid,i.hours,i.othours,i.ptohours,i.emergencyhours,i.secondratehours\n            from ImportedHoursData as i left join employees as e on i.empID=e.empID\n            where periodID=?\n            order by {$order} {$dir}";
     $dataP = $db->prepare_statement($dataQ);
     $dataR = $db->exec_statement($dataQ, array($ppID));
     $class = array("one", "two");
     $c = 1;
     while ($dataW = $db->fetch_row($dataR)) {
         $ret .= "<tr class={$class[$c]}>";
         $ret .= "<td>" . $dataW['name'] . "</td>";
         $ret .= "<td>" . $dataW['adpid'] . "</td>";
         $ret .= "<td>" . $dataW['hours'] . "</td>";
         $ret .= "<td>" . $dataW['othours'] . "</td>";
         $ret .= "<td>" . $dataW['ptohours'] . "</td>";
         $ret .= "<td>" . $dataW['emergencyhours'] . "</td>";
         $ret .= "<td>" . $dataW['secondratehours'] . "</td>";
         $ret .= "</tr>";
         $c = ($c + 1) % 2;
     }
     $ret .= "</table>";
     return $ret;
 }
Exemplo n.º 10
0
 public function body_content()
 {
     $edit = FannieAuth::validateUserQuiet('edit_employees');
     $sort = "e.name";
     if (FormLib::get('sort') !== '') {
         switch (strtolower(FormLib::get('sort'))) {
             case 'name':
                 $sort = 'e.name';
                 break;
             case 'adpid':
                 $sort = 'e.adpid';
                 break;
             case 'ptolevel':
                 $sort = 'e.ptolevel';
                 break;
             case 'ptoremaining':
                 $sort = 'p.ptoremaining';
                 break;
             case 'hours':
                 $sort = 'u.hours';
                 break;
             case 'totalhours':
                 $sort = 'h.totalhours';
                 break;
         }
     }
     $dir = "asc";
     if (FormLib::get('dir') !== '') {
         switch (strtolower(FormLib::get('dir'))) {
             case 'asc':
                 $dir = 'asc';
                 break;
             case 'desc':
                 $dir = 'desc';
                 break;
         }
     }
     $otherdir = "desc";
     if ($dir == "desc") {
         $otherdir = "asc";
     }
     $sql = WfcHtLib::hours_dbconnect();
     $fetchQ = "select e.name,e.adpID,\n            case when e.department>=998 then 'Salary' else e.PTOLevel end as PTOLevel,\n            case when e.department>=998 then '&nbsp;' else h.totalHours end as totalHours,\n            c.cusp,e.empID,\n            case when s.totalTaken is null then p.ptoremaining else e.adpID-s.totalTaken end as ptoremaining,\n            case when e.department>=998 then '&nbsp;' else u.hours end as hours\n            from employees as e left join hoursalltime as h on e.empID=h.empID\n            left join cusping as c on e.empID=c.empID\n            left join pto as p on e.empID=p.empID\n            left join uto as u on e.empID=u.empID\n            left join salarypto_ytd s on e.empID=s.empID\n            {$this->dept_restrict}\n            order by {$sort} {$dir}";
     $fetchP = $sql->prepare_statement($fetchQ);
     $fetchR = $sql->exec_statement($fetchP, $this->dept_args);
     ob_start();
     if (FannieAuth::validateUserQuiet('view_all_hours')) {
         $sql = WfcHtLib::hours_dbconnect();
         $deptsQ = "select name,deptID from Departments order by name";
         $deptsR = $sql->query($deptsQ);
         echo "Show Department: ";
         echo "<select class=\"form-control\" onchange=\"top.location='{$_SERVER['PHP_SELF']}?showdept='+this.value;\">";
         echo "<option value=\"\">All</option>";
         while ($deptsW = $sql->fetch_row($deptsR)) {
             if ($this->selected_dept == $deptsW[1]) {
                 echo "<option value={$deptsW['1']} selected>{$deptsW['0']}</option>";
             } else {
                 echo "<option value={$deptsW['1']}>{$deptsW['0']}</option>";
             }
         }
         if ($this->selected_dept == -1) {
             echo "<option selected value=\"-1\">DELETED</option>";
         } else {
             echo "<option value=\"-1\">DELETED</option>";
         }
         echo "</select>";
     } else {
         if (strlen($this->dept_list) > 4) {
             $sql = WfcHtLib::hours_dbconnect();
             $deptsQ = "select name,deptID from Departments WHERE deptID IN {$this->dept_list} order by name";
             $deptsP = $sql->prepare_statement($deptsQ);
             $deptsR = $sql->exec_statement($deptsP, $this->list_args);
             echo "Show Department: ";
             echo "<select class=\"form-control\" onchange=\"top.location='{$_SERVER['PHP_SELF']}?showdept='+this.value;\">";
             echo "<option value=\"\">All</option>";
             while ($deptsW = $sql->fetch_row($deptsR)) {
                 if ($this->selected_dept == $deptsW[1]) {
                     echo "<option value={$deptsW['1']} selected>{$deptsW['0']}</option>";
                 } else {
                     echo "<option value={$deptsW['1']}>{$deptsW['0']}</option>";
                 }
             }
             echo "</select>";
         }
     }
     echo "<table class=\"table\"><tr>";
     if ($sort == "e.name") {
         echo "<th><a href={$_SERVER['PHP_SELF']}?sort=name&dir={$otherdir}&showdept={$this->selected_dept}>Name</a></th>";
     } else {
         echo "<th><a href={$_SERVER['PHP_SELF']}?sort=name&dir=asc&showdept={$this->selected_dept}>Name</a></th>";
     }
     if ($sort == "e.adpid") {
         echo "<th><a href={$_SERVER['PHP_SELF']}?sort=adpid&dir={$otherdir}&showdept={$this->selected_dept}>ADP ID</a></th>";
     } else {
         echo "<th><a href={$_SERVER['PHP_SELF']}?sort=adpid&dir=asc&showdept={$this->selected_dept}>ADP ID</a></th>";
     }
     if ($sort == "e.ptolevel") {
         echo "<th><a href={$_SERVER['PHP_SELF']}?sort=ptolevel&dir={$otherdir}&showdept={$this->selected_dept}>PTO Level</a></th>";
     } else {
         echo "<th><a href={$_SERVER['PHP_SELF']}?sort=ptolevel&dir=asc&showdept={$this->selected_dept}>PTO Level</a></th>";
     }
     if ($sort == "p.ptoremaining") {
         echo "<th><a href={$_SERVER['PHP_SELF']}?sort=ptoremaining&dir={$otherdir}&showdept={$this->selected_dept}>Avail. PTO</a></th>";
     } else {
         echo "<th><a href={$_SERVER['PHP_SELF']}?sort=ptoremaining&dir=desc&showdept={$this->selected_dept}>Avail. PTO</a></th>";
     }
     if ($sort == "u.hours") {
         echo "<th><a href={$_SERVER['PHP_SELF']}?sort=hours&dir={$otherdir}&showdept={$this->selected_dept}>Avail. UTO</a></th>";
     } else {
         echo "<th><a href={$_SERVER['PHP_SELF']}?sort=hours&dir=desc&showdept={$this->selected_dept}>Avail. UTO</a></th>";
     }
     if ($sort == "u.hours") {
         echo "<th><a href={$_SERVER['PHP_SELF']}?sort=totalhours&dir={$otherdir}&showdept={$this->selected_dept}>Total Hours</a></th>";
     } else {
         echo "<th><a href={$_SERVER['PHP_SELF']}?sort=totalhours&dir=desc&showdept={$this->selected_dept}>Total Hours</a></th>";
     }
     echo "</tr>";
     while ($fetchW = $sql->fetch_row($fetchR)) {
         if ($fetchW[4] == "PRE") {
             echo "<tr class=\"pre\">";
         } elseif ($fetchW[4] == "POST") {
             echo "<tr class=\"post\">";
         } elseif ($fetchW[4] == "!!!") {
             echo "<tr class=\"earned\">";
         } else {
             echo "<tr>";
         }
         echo "<td><a href=WfcHtViewEmpPage.php?id={$fetchW['5']}>{$fetchW['0']}</a>";
         echo "</td>";
         echo "<td>{$fetchW['1']}</td>";
         echo "<td align=center>{$fetchW['2']}</td>";
         echo "<td align=right>" . (is_numeric($fetchW[6]) ? sprintf("%.2f", $fetchW[6]) : $fetchW[6]) . "</td>";
         echo "<td align=right>" . (is_numeric($fetchW[7]) ? sprintf("%.2f", $fetchW[7]) : $fetchW[7]) . "</td>";
         echo "<td align=right>" . (is_numeric($fetchW[3]) ? sprintf("%.2f", $fetchW[3]) : $fetchW[3]) . "</td>";
         if ($edit) {
             echo "<td><a href=WfcHtEditPage.php?id={$fetchW['5']}>Edit</a></td>";
             if ($this->selected_dept == "-1") {
                 echo "<td><a href={$_SERVER['PHP_SELF']}?action=undelete&id={$fetchW['5']}>Undelete</a></td>";
             } else {
                 echo "<td><a href={$_SERVER['PHP_SELF']}?action=delete&id={$fetchW['5']}>Delete</a></td>";
             }
         }
         echo "</tr>";
     }
     echo '</table>';
     return ob_get_clean();
 }
Exemplo n.º 11
0
 private function import_content()
 {
     $db = WfcHtLib::hours_dbconnect();
     $datalines = FormLib::get('data');
     $start = FormLib::get('start');
     $end = FormLib::get('end');
     $dateStr = date('n/j/Y', strtotime($start)) . ' - ' . date('n/j/Y', strtotime($end));
     $year = date('Y', strtotime($start));
     $ppIDQ = "select max(periodID)+1 from PayPeriods";
     $ppIDR = $db->query($ppIDQ);
     $ppIDW = $db->fetch_row($ppIDR);
     $ppID = $ppIDW[0];
     $ppQ = $db->prepare_statement("INSERT INTO PayPeriods (periodID, dateStr, year, startDate, endDate) \n                                    VALUES (?,?,?,?,?)");
     $ppR = $db->exec_statement($ppQ, array($ppID, $dateStr, $year, $start, $end));
     $eIDQ = $db->prepare_statement("select empID from employees where adpID=?");
     $insQ = $db->prepare_statement("INSERT INTO ImportedHoursData \n                    VALUES (?,?,?,?,?,?,0,?,?,?)");
     foreach ($datalines as $line) {
         $fields = explode(",", $line);
         $eIDR = $db->exec_statement($eIDQ, array($fields[0]));
         if ($db->num_rows($eIDR) < 1) {
             continue;
         }
         $eIDW = $db->fetch_row($eIDR);
         $empID = $eIDW['empID'];
         $insR = $db->exec_statement($insQ, array($empID, $ppID, $year, $fields[1], $fields[2], $fields[3], $fields[5], $fields[6], $fields[4]));
     }
     $cuspQ = $db->prepare_statement("UPDATE cusping as c \n            left join employees as e\n            on c.empID = e.empID\n            SET e.PTOLevel=e.PTOLevel+1, e.PTOCutoff=?\n            where c.cusp = '!!!'");
     $cuspR = $db->exec_statement($cuspQ, array($ppID));
     $ret = "<p>ADP data import complete!<br />";
     $ret .= "<a href=WfcHtListPage.php>View Employees</a><br />";
     $ret .= "<a href=WfcHtPayPeriodsPage.php>View Pay Periods</a></p>";
     return $ret;
 }