require_once 'Users.php'; if (check_cookie($_SERVER['PHP_SELF'], 2)) { $row_size = '1'; if (!empty($_POST)) { // Update the 'approved' property $req = new Request(); $approved = empty($_POST['approved']) ? 'false' : 'true'; $query = 'UPDATE request SET approved=' . $approved . ' WHERE id=' . $_POST['rid']; $req->query($query); // What's the id of the person this job is assigned to? $user = new Users(); $user->fullname = $_POST['assign_to']; $user->find(); $aid = $user->uid; // Insert the new assignment $asn = new Assign(); $asn->rid = $_POST['rid']; $asn->hours = $_POST['hours']; $asn->cost = str_replace('$', '', $_POST['cost']); $asn->complete = parse_date($_POST); $asn->aid = $aid; $asn->insert(); header('Location: index.php'); } // Initialize values! $name = ''; $phone = ''; $year = ''; $month = ''; $day = ''; $desc = '';
$req = new Request(); $req->id = $id; $req->find(); $name = $req->name; $phone = parse_phone($req->phone); $y = substr($req->deadline, 0, 4); $m = substr($req->deadline, 5, 2); $d = substr($req->deadline, 8, 2); $time = strtotime("{$y}/{$m}/{$d}"); $year = '<option>' . date('Y', $time) . '</option>'; $month = '<option>' . date('F', $time) . '</option>'; $day = '<option>' . date('j', $time) . '</option>'; $desc = $req->description; $checked = $req->approved ? 'checked="checked"' : ''; // Get estimate information $asn = new Assign(); $asn->rid = $id; $asn->find(); $est_hours = $asn->hours; $est_cost = $asn->cost; // Get actual spending information $rec = new Record(); // FIX THIS!!! $rec->uid = $asn->rid; $rec->find(false); // Sum spending information together while ($rec->rows()) { $act_hours += $rec->hours; $act_cost += $rec->cost; } }