$tpl->assign('cleared', $zef_entry['zef_cleared'] != 0); $tpl->assign('edit_in_day', date("d.m.Y", $zef_entry['zef_in'])); $tpl->assign('edit_out_day', date("d.m.Y", $zef_entry['zef_out'])); $tpl->assign('edit_in_time', date("H:i:s", $zef_entry['zef_in'])); $tpl->assign('edit_out_time', date("H:i:s", $zef_entry['zef_out'])); // preselected $tpl->assign('pres_pct', $zef_entry['pct_ID']); $tpl->assign('pres_evt', $zef_entry['evt_ID']); $tpl->assign('comment_active', $zef_entry['zef_comment_type']); } else { $tpl->assign('id', 0); $tpl->assign('edit_in_day', date("d.m.Y")); $tpl->assign('edit_out_day', date("d.m.Y")); $tpl->assign('edit_in_time', date("H:i:s")); $tpl->assign('edit_out_time', date("H:i:s")); $tpl->assign('rate', get_best_fitting_rate($kga['usr']['usr_ID'], $selected[0], $selected[1])); } $tpl->assign('comment_types', $comment_types); $tpl->assign('comment_values', array('0', '1', '2')); // select for projects $sel = makeSelectBox("pct", $kga['usr']['usr_grp']); $tpl->assign('sel_pct_names', $sel[0]); $tpl->assign('sel_pct_IDs', $sel[1]); // select for events $sel = makeSelectBox("evt", $kga['usr']['usr_grp']); $tpl->assign('sel_evt_names', $sel[0]); $tpl->assign('sel_evt_IDs', $sel[1]); $tpl->display("add_edit_record.tpl"); break; } ?>
// ========================================= case 'quickdelete': zef_delete_record($id); echo 1; break; // =============================================== // = Get the best rate for the project and event = // =============================================== // =============================================== // = Get the best rate for the project and event = // =============================================== case 'bestFittingRate': if (isset($kga['customer'])) { die; } $rate = get_best_fitting_rate($kga['usr']['usr_ID'], $_REQUEST['project_id'], $_REQUEST['event_id']); if ($rate === false) { echo -1; } else { echo $rate; } break; // =============================================== // = Get the best rate for the project and event = // =============================================== // =============================================== // = Get the best rate for the project and event = // =============================================== case 'reload_evt_options': if (isset($kga['customer'])) { die;
function startRecorder($pct_ID, $evt_ID, $user) { global $kga, $conn; if (!$conn->TransactionBegin()) { $conn->Kill(); } $pct_ID = MySQL::SQLValue($pct_ID, MySQL::SQLVALUE_NUMBER); $evt_ID = MySQL::SQLValue($evt_ID, MySQL::SQLVALUE_NUMBER); $user = MySQL::SQLValue($user, MySQL::SQLVALUE_NUMBER); $values['zef_pctID'] = $pct_ID; $values['zef_evtID'] = $evt_ID; $values['zef_in'] = time(); $values['zef_usrID'] = $user; $rate = get_best_fitting_rate($user, $pct_ID, $evt_ID); if ($rate) { $values['zef_rate'] = $rate; } $table = $kga['server_prefix'] . "zef"; $result = $conn->InsertRow($table, $values); if (!$result) { return false; } unset($values); $values['lastRecord'] = $conn->GetLastInsertID(); $table = $kga['server_prefix'] . "usr"; $filter['usr_ID'] = $user; $query = MySQL::BuildSQLUpdate($table, $values, $filter); $success = true; if (!$conn->Query($query)) { $success = false; } if ($success) { if (!$conn->TransactionEnd()) { $conn->Kill(); } } else { if (!$conn->TransactionRollback()) { $conn->Kill(); } } }
/** * starts timesheet record * * @param integer $pct_ID ID of project to record * @global array $kga kimai-global-array * @author th */ function startRecorder($pct_ID, $evt_ID, $user) { global $kga, $pdo_conn; $p = $kga['server_prefix']; $pdo_query = $pdo_conn->prepare("INSERT INTO {$p}zef \n (zef_pctID,zef_evtID,zef_in,zef_usrID,zef_rate) VALUES \n (?, ?, ?, ?, ?);"); $pdo_query->execute(array($pct_ID, $evt_ID, time(), $user, get_best_fitting_rate($user, $pct_ID, $evt_ID))); $pdo_query = $pdo_conn->prepare("UPDATE {$p}usr SET lastRecord = LAST_INSERT_ID() WHERE usr_ID = ?;"); $pdo_query->execute(array($user)); }