예제 #1
0
     if (!mysql_query('insert into sample(sample_id,sample_receipt_time,patient_id) values (\'' . $_POST['sample_id'] . '\',\'' . strftime("%Y-%m-%d %H:%M:%S") . '\',\'SUR/12/\')', $link)) {
         echo mysql_error();
     } else {
         save_sample_FS($_POST['from_sample_id'], $_POST['sample_id']);
         edit_sample($_POST['sample_id'], 'new_request_FS.php	', '', '');
     }
 } elseif ($_POST['action'] == 'save_sample') {
     if (!save_sample($_POST)) {
         echo 'no sample saved<br>';
     } else {
         edit_sample($_POST['sample_id'], 'new_request_FS.php	', 'disabled', 'no');
         select_profile($_POST['sample_id'], 'new_request_FS.php	');
         select_examination($_POST['sample_id'], 'new_request_FS.php	', '');
     }
 } elseif ($_POST['action'] == 'profile') {
     insert_profile($_POST['sample_id'], $_POST['profile']);
     edit_sample($_POST['sample_id'], 'new_request_FS.php	', 'disabled', 'no');
     edit_examination($_POST['sample_id'], 'new_request_FS.php	', '');
     select_profile($_POST['sample_id'], 'new_request_FS.php	');
     select_examination($_POST['sample_id'], 'new_request_FS.php	', '');
 } elseif ($_POST['action'] == 'save_examination') {
     save_examination($_POST);
     edit_sample($_POST['sample_id'], 'new_request_FS.php	', 'disabled', 'no');
     edit_examination($_POST['sample_id'], 'new_request_FS.php	', 'disabled');
     select_profile($_POST['sample_id'], 'new_request_FS.php	');
     select_examination($_POST['sample_id'], 'new_request_FS.php	', '');
 } elseif ($_POST['action'] == 'select_examination') {
     insert_single_examination($_POST['sample_id'], $_POST['id']);
     edit_sample($_POST['sample_id'], 'new_request_FS.php	', 'disabled', 'no');
     edit_examination($_POST['sample_id'], 'new_request_FS.php	', '');
     select_profile($_POST['sample_id'], 'new_request_FS.php	');
예제 #2
0
function update_profile($idx, $value, $type = PROFILE_TYPE_UNKNOWN, $idx2 = null, $source = null)
{
    global $USER_DETAILS;
    if ($USER_DETAILS['alias'] == ZBX_GUEST_USER) {
        return false;
    }
    if (profile_type($type, 'unknown')) {
        $type = profile_type_by_value($value);
    } else {
        $value = profile_value_by_type($value, $type);
    }
    //if($idx == 'web.audit.filter.action') SDI('PROF: v='.$value.'  t='.$type);
    if ($value === false) {
        return false;
    }
    $sql_cond = '';
    if (zbx_numeric($idx2)) {
        $sql_cond = ' AND idx2=' . $idx2 . ' AND ' . DBin_node('idx2');
    }
    if (profile_type($type, 'array')) {
        $sql = 'DELETE FROM profiles ' . ' WHERE userid=' . $USER_DETAILS["userid"] . ' AND idx=' . zbx_dbstr($idx) . $sql_cond;
        DBstart();
        DBexecute($sql);
        foreach ($value as $id => $val) {
            insert_profile($idx, $val, $type, $idx2, $source);
        }
        $result = DBend();
    } else {
        $sql = 'SELECT profileid ' . ' FROM profiles ' . ' WHERE userid=' . $USER_DETAILS['userid'] . ' AND idx=' . zbx_dbstr($idx) . $sql_cond;
        $row = DBfetch(DBselect($sql));
        if (!$row) {
            $result = insert_profile($idx, $value, $type, $idx2, $source);
        } else {
            $val = array();
            $value_type = profile_field_by_type($type);
            $val['value_id'] = 0;
            $val['value_int'] = 0;
            $val['value_str'] = '';
            $val[$value_type] = $value;
            $idx2 = zbx_numeric($idx2) ? $idx2 : 0;
            $src = is_null($source) ? '' : $source;
            if (is_array($value)) {
                $val[$value_type] = isset($value['value']) ? $value['value'] : '';
                $src = isset($value['source']) ? $value['source'] : $src;
            }
            if (is_null($val[$value_type])) {
                return false;
            }
            $sql = 'UPDATE profiles ' . ' SET value_id=' . $val['value_id'] . ',' . ' value_int=' . $val['value_int'] . ',' . ' value_str=' . zbx_dbstr($val['value_str']) . ',' . ' type=' . $type . ',' . ' source=' . zbx_dbstr($src) . ' WHERE userid=' . $USER_DETAILS["userid"] . ' AND idx=' . zbx_dbstr($idx) . $sql_cond;
            //if($idx == 'web.audit.filter.action') SDI($sql);
            $result = DBexecute($sql);
        }
    }
    return $result;
}