
// History Listing
#include "clog.h"
#include "cgi.h"
#include "input.h"
#include "wrenchboard_api.h"
#include "history.h"
#include "market.h"
#include "email.h"
#include "payments.h"
#include "safestring.h"
#include <string>
#include "pgsql.h"
#include "pgsql_wrapper.h"
#include "cfg.h"
#include <curl/curl.h>


long market_calls(CVars in, CVars &out) {
    logfmt(logINFO, "market_calls()");
    long ret = PHP_API_BAD_PARAM;
    char vname[700];
    char file_section[50];
        try {
        long action = REQ_LONG( in, "action", 1, -1 );
            switch(action){
                    case WRENCHBOARD_MARKET_PLAN01_START:
                      snprintf(vname, sizeof (vname), "SELECT uid AS member_uid, profile_pic AS saved_file_name FROM members WHERE uid ='%s'", in["file_uid"].c_str());
                      market_email(WRENCHBOARD_MARKET_PLAN01_START, in, in);

                    break;

                    case WRENCHBOARD_MARKET_PLAN01_NEXT1:
                      snprintf(vname, sizeof (vname), "SELECT uid AS member_uid, profile_pic AS saved_file_name FROM members WHERE uid ='%s'", in["file_uid"].c_str());
                     market_email(WRENCHBOARD_MARKET_PLAN01_START, in, in);
                    break;
            }

    } catch (bad_parameter) {
        logfmt(logINFO, "ERROR CALL long market_calls(CVars in, CVars &out)");
    }
    logfmt(logINFO, "/market_calls()");
    return ret;
}

/*
#define WRENCHBOARD_MARKET_PLAN01_START   220001
#define WRENCHBOARD_MARKET_PLAN01_NEXT1   220003
*/