예제 #1
0
 if (!$new_time['diff'] && !$id) {
     // if this is an ADD record dialog it makes no sense to create the record
     // when it doesn't have any TIME attached ... so this stops the processing.
     // TODO: throw a warning message when this happens ...
     break;
 }
 // TIME WRONG - EDIT ENTRY
 if (!$new_time['diff']) {
     // obviously this is an edit of an existing record. but still it contains no correct timespan.
     // here somebody didn't mean to change the timespace like that. so we leave the timespan as is.
     // TODO: throw a warning message when this happens ...
     $data['in'] = 0;
     $data['out'] = 0;
     $data['diff'] = 0;
     // we send zeros instead of unix timestamps to the db-layer
     zef_edit_record($id, $data);
     break;
 } else {
     // TIME RIGHT !
     $data['in'] = $new_time['in'];
     $data['out'] = $new_time['out'];
     $data['diff'] = $new_time['diff'];
     if ($id) {
         // TIME RIGHT - NEW OR EDIT ?
         // TIME RIGHT - EDIT ENTRY
         logfile("zef_edit_record: " . $id);
         check_zef_data($id, $data);
     } else {
         // TIME RIGHT - NEW ENTRY
         logfile("zef_create_record");
         zef_create_record($kga['usr']['usr_ID'], $data);
예제 #2
0
/**
 * check if there are 0s (erroneuos entries) in the zef data while editing and prevent overwriting old data in this case
 *
 * @param int $id the id of the entry to be edited
 * @param array $zef_data
 * @return boolean the return value of the actual editing function
 *
 * @author Oleg
 */
function check_zef_data($id, $zef_data)
{
    if ($zef_data['in'] == 0 && $zef_data['out'] == 0 && $zef_data['diff'] == 0) {
        $zef_final_data['zef_pctID'] = $zef_data['pct_ID'];
        $zef_final_data['zef_evtID'] = $zef_data['evt_ID'];
        $zef_final_data['zef_location'] = $zef_data['zlocation'];
        $zef_final_data['zef_trackingnr'] = $zef_data['trackingnr'];
        $zef_final_data['zef_comment'] = $zef_data['comment'];
        $zef_final_data['zef_comment_type'] = $zef_data['comment_type'];
        $zef_final_data['zef_rate'] = $zef_data['rate'];
        $zef_final_data['zef_cleared'] = $zef_data['cleared'];
        return zef_edit_record($id, $zef_final_data);
    } else {
        $zef_final_data['zef_pctID'] = $zef_data['pct_ID'];
        $zef_final_data['zef_evtID'] = $zef_data['evt_ID'];
        $zef_final_data['zef_location'] = $zef_data['zlocation'];
        $zef_final_data['zef_trackingnr'] = $zef_data['trackingnr'];
        $zef_final_data['zef_comment'] = $zef_data['comment'];
        $zef_final_data['zef_comment_type'] = $zef_data['comment_type'];
        $zef_final_data['zef_in'] = $zef_data['in'];
        $zef_final_data['zef_out'] = $zef_data['out'];
        $zef_final_data['zef_time'] = $zef_data['diff'];
        $zef_final_data['zef_rate'] = $zef_data['rate'];
        $zef_final_data['zef_cleared'] = $zef_data['cleared'];
        return zef_edit_record($id, $zef_final_data);
    }
}