// Twillo management toosl #include "clog.h" #include "cgi.h" #include "input.h" #include "wrenchboard_api.h" #include "reco_engine.h" //error in file name #include "email.h" #include "safestring.h" #include #include "pgsql.h" #include "pgsql_wrapper.h" #include #include "account.h" #include "cards.h" #include "twilo.h" #include "mobile.h" /* #define RECOMMEND_COUPON 1000 #define RECOMMEND_BLOG 1005 #define RECOMMEND_NEWTASK 1010 #define RECOMMEND_TOKEN 1015 #define RECOMMEND_OFFERS 1020 //======================== */ long sendOffersRecommendation( CVars in, CVars &out); long sendCouponRecommendation( CVars in, CVars &out); long recommendation_engine(long action , CVars in, CVars &out) { try{ switch (action) { case RECOMMEND_COUPON: return sendCouponRecommendation( in, out); break; case RECOMMEND_BLOG: return 0; break; case RECOMMEND_NEWTASK: return 0; break; case RECOMMEND_TOKEN: return 0; break; case RECOMMEND_OFFERS: return sendOffersRecommendation( in, out); break; } } catch (bad_parameter) { logfmt(logINFO, "ERROR CALL long recommendation_engine"); } return 0; } // also used from accounts long WrenchHomeBanners(CVars in, CVars &out) { out["status"] = "long WrenchHomeBanners(CVars in, CVars &out)"; CVars offV; char vname[30]; WrenchReturnJobOffersList(in, offV); long total_offers = offV["total_record"].Long(); if( total_offers > 0){ for (int i = 0, n = total_offers; i < n; i++) { snprintf(vname, sizeof (vname), "title_%05d", i); out[vname] = offV[vname]; snprintf(vname, sizeof (vname), "card_style_%05d", i); out[vname] = offV[vname]; snprintf(vname, sizeof (vname), "description_%05d", i); out[vname] = offV[vname]; snprintf(vname, sizeof (vname), "card_type_%05d", i); out[vname] = "OFFERS"; snprintf(vname, sizeof (vname), "offer_id_%05d", i); out[vname] = offV[vname]; snprintf(vname, sizeof (vname), "blog_id_%05d", i); out[vname] = "0"; snprintf(vname, sizeof (vname), "card_icon_%05d", i); out[vname] = "icon1"; snprintf(vname, sizeof (vname), "contract_%05d", i); out[vname] = offV[vname];; } } out["total_record"] = total_offers; return 0; } long sendOffersRecommendation( CVars in, CVars &out){ try{ long member_id = REQ_LONG(in, "member_id", 1, -1); REQ_LONG(in, "offer_id", 1, -1); if ( load_db_record(out, "SELECT client_id FROM members_jobs_offer WHERE id=%lu", in["offer_id"].Long())> 0){ CVars xx; CVars xout; xx["action"] = WRENCHBOARD_CARDS_CREATECARD; xx["action"].set_valid( true ); xx["member_id"] = out["client_id"]; xx["member_id"].set_valid( true ); // the card is going to job recipient xx["title"] = "New job offer"; xx["title"].set_valid( true ); xx["description"] = "You have received a new Task/Job offer"; xx["description"].set_valid( true ); xx["card_type"] = "OFFERS"; xx["card_type"].set_valid( true ); xx["card_style"] = "card2"; xx["card_style"].set_valid( true ); xx["card_icon"] = "icon1"; xx["card_icon"].set_valid( true ); xx["offer_id"] = in["offer_id"]; xx["offer_id"].set_valid( true ); xx["blog_id"] = "0"; xx["blog_id"].set_valid( true ); card_calls(xx, xout); } } catch (bad_parameter) { logfmt(logINFO, "ERROR CALL long sendCouponRecommendation"); } return 0; } long sendCouponRecommendation( CVars in, CVars &out){ /* CVars xx; xx["member_id"] = in["member_id"]; xx["member_id"].set_valid(true); xx["code"] = rec["code"]; xx["code"].set_valid(true); xx["amount"] = rec["amount"]; xx["amount"].set_valid(true); xx["status"] = COUPON_ACTIVE; xx["status"].set_valid(true); coupon_id = insert_db_record(DBS_VALID, "coupons_allocation", "coupons_allocation_id_seq", xx); ['title'=>'This is your coupon', 'description'=>'This is the description of the description', 'card_type'=>'COUPON', 'card_style' =>'card1', 'card_icon' =>'icon1', 'assign_id'=> 0, */ try{ long member_id = REQ_LONG(in, "member_id", 1, -1); REQ_LONG(in, "coupon_id", 1, -1); CVars xx; CVars xout; xx["action"] = WRENCHBOARD_CARDS_CREATECARD; xx["action"].set_valid( true ); xx["member_id"] = member_id; xx["member_id"].set_valid( true ); xx["title"] = "This is your coupon"; xx["title"].set_valid( true ); xx["description"] = "Click to redeem your coupon to your account"; xx["description"].set_valid( true ); xx["card_type"] = "COUPON"; xx["card_type"].set_valid( true ); xx["card_style"] = "card1"; xx["card_style"].set_valid( true ); xx["card_icon"] = "icon1"; xx["card_icon"].set_valid( true ); xx["blog_id"] = "0"; xx["blog_id"].set_valid( true ); xx["offer_id"] = "0"; xx["offer_id"].set_valid( true ); card_calls(xx, xout); } catch (bad_parameter) { logfmt(logINFO, "ERROR CALL long sendCouponRecommendation"); } return 0; }