Пример #1
0
function updateReportInDB($report_id = NULL, $from_MC = false)
{
    if (!$report_id) {
        return;
    }
    global $form;
    $ret = $form->getSubmitValues();
    if ($from_MC) {
        updateReport_MC($report_id);
    } else {
        updateReport($report_id, $from_MC);
    }
    # Function for updating cg
    # 1 - MC with deletion of existing cg
    # 2 - MC with addition of new cg
    # 3 - Normal update
    if (isset($ret["mc_mod_cgs"]["mc_mod_cgs"]) && $ret["mc_mod_cgs"]["mc_mod_cgs"]) {
        updateReportContactGroup($report_id);
        updateReportContact($report_id);
    } else {
        if (isset($ret["mc_mod_cgs"]["mc_mod_cgs"]) && !$ret["mc_mod_cgs"]["mc_mod_cgs"]) {
            updateReportContactGroup_MC($report_id);
            updateReportContact_MC($report_id);
        } else {
            updateReportContactGroup($report_id);
            updateReportContact($report_id);
        }
    }
    # Function for updating host/hg
    # 1 - MC with deletion of existing host/hg
    # 2 - MC with addition of new host/hg
    # 3 - Normal update
    if (isset($ret["mc_mod_Pars"]["mc_mod_Pars"]) && $ret["mc_mod_Pars"]["mc_mod_Pars"]) {
        updateReportHost($report_id);
    } else {
        if (isset($ret["mc_mod_Pars"]["mc_mod_Pars"]) && !$ret["mc_mod_Pars"]["mc_mod_Pars"]) {
            updateReportHost_MC($report_id);
        } else {
            updateReportHost($report_id);
        }
    }
    # Function for updating sg
    # 1 - MC with deletion of existing host/hg parent
    # 2 - MC with addition of new host/hg parent
    # 3 - Normal update
    if (isset($ret["mc_mod_sg"]["mc_mod_sg"]) && $ret["mc_mod_sg"]["mc_mod_sg"]) {
        updateReportServiceGroup($report_id);
    } else {
        if (isset($ret["mc_mod_sg"]["mc_mod_sg"]) && !$ret["mc_mod_sg"]["mc_mod_sg"]) {
            updateReportServiceGroup_MC($report_id);
        } else {
            updateReportServiceGroup($report_id);
        }
    }
}
Пример #2
0
complete
*/
$app->post('/api/updateReport', function () use($dbh) {
    $changeCode = $_POST['changeCode'];
    if ($changeCode == 1) {
        $args[':message'] = $_POST['message'];
        $args[':reportID'] = $_POST['reportID'];
    } else {
        if ($changeCode == 2) {
            $args[':paidAmount'] = $_POST['paidAmount'];
            $args[':reportID'] = $_POST['reportID'];
            $result['gotIn'] = 1;
        }
    }
    $result = updateReport($dbh, $args, $changeCode);
    $result['post'] = $_POST;
    echo json_encode($result);
});
/*
Ryan Edson
getReportsFromUsername
Returns all reports a username has submitted
Error Codes:
Returns

complete
*/
$app->get('/api/getReportsFromUsername/:username', function ($username) use($dbh) {
    $args[':username'] = $username;
    echo json_encode(getReportsFromUsername($dbh, $args));