Backend Service
This commit is contained in:
@@ -12,86 +12,72 @@
|
||||
//char confirmation[20] = "";
|
||||
//Confirmation(payment_id, confirmation, sizeof (confirmation));
|
||||
|
||||
void GenerateInnerConfirmationSeed(char * number, int sz, int seed) {
|
||||
char chars[] = "WRB01234WRB56789WRB";
|
||||
int n = sizeof (chars);
|
||||
int i;
|
||||
/*
|
||||
time_t t;
|
||||
time( &t );
|
||||
pid_t pid = getpid();
|
||||
|
||||
srand(t+pid);
|
||||
*/
|
||||
srand((unsigned int) time((time_t *) NULL));
|
||||
|
||||
|
||||
void GenerateInnerConfirmationSeed( char * number, int sz, int seed )
|
||||
{
|
||||
char chars[] = "WRB01234WRB56789WRB";
|
||||
int n = sizeof(chars);
|
||||
int i;
|
||||
/*
|
||||
time_t t;
|
||||
time( &t );
|
||||
pid_t pid = getpid();
|
||||
|
||||
srand(t+pid);
|
||||
*/
|
||||
srand((unsigned int)time((time_t *)NULL));
|
||||
|
||||
for ( i=0; i<10 && i<sz-1; i++ )
|
||||
{
|
||||
int k = seed%n;
|
||||
if (seed>1 && k==i) {
|
||||
number[i] = chars[n-k];
|
||||
} else {
|
||||
number[i] = chars[ (int) ( (n-1.0)*rand()/(RAND_MAX+1.0)) ];
|
||||
}
|
||||
for (i = 0; i < 10 && i < sz - 1; i++) {
|
||||
int k = seed % n;
|
||||
if (seed > 1 && k == i) {
|
||||
number[i] = chars[n - k];
|
||||
} else {
|
||||
number[i] = chars[ (int) ((n - 1.0) * rand() / (RAND_MAX + 1.0)) ];
|
||||
}
|
||||
number[i] = 0;
|
||||
}
|
||||
number[i] = 0;
|
||||
}
|
||||
|
||||
void ConfirmationNew(unsigned long payment_id, char * number, int sz) {
|
||||
SQLINTEGER rows;
|
||||
char confirmation[11];
|
||||
|
||||
// Lock table to prevent generation of two identical confirmation numbers
|
||||
pgsql_exec("BEGIN; LOCK TABLE members_payments;");
|
||||
int i = 0;
|
||||
do {
|
||||
GenerateInnerConfirmationSeed(confirmation, sizeof (confirmation), i++);
|
||||
|
||||
void ConfirmationNew( unsigned long payment_id, char * number, int sz )
|
||||
{
|
||||
SQLINTEGER rows;
|
||||
char confirmation[11];
|
||||
//st.CloseCursor();
|
||||
rows = 0;
|
||||
const PGresult *res = pgsql_query("SELECT id FROM members_payments WHERE confirmation='%s'", confirmation);
|
||||
if (res != NULL) {
|
||||
rows = pgsql_num_rows(res);
|
||||
}
|
||||
} while (rows > 0 && i < 100);
|
||||
|
||||
// Lock table to prevent generation of two identical confirmation numbers
|
||||
pgsql_exec("BEGIN; LOCK TABLE members_payments;" );
|
||||
int i = 0;
|
||||
do
|
||||
{
|
||||
GenerateInnerConfirmationSeed( confirmation, sizeof(confirmation), i++ );
|
||||
|
||||
//st.CloseCursor();
|
||||
rows = 0;
|
||||
const PGresult *res = pgsql_query("SELECT id FROM members_payments WHERE confirmation='%s'", confirmation );
|
||||
if (res!=NULL )
|
||||
{
|
||||
rows = pgsql_num_rows(res);
|
||||
}
|
||||
} while ( rows>0 && i<100 );
|
||||
|
||||
pgsql_exec("UPDATE members_payments SET confirmation='%s', dt_confirmed=now() WHERE id=%lu", confirmation, payment_id );
|
||||
pgsql_exec("COMMIT" ); // Unlock table 'data'
|
||||
strsafecpy( number, confirmation, sz );
|
||||
pgsql_exec("UPDATE members_payments SET confirmation='%s', dt_confirmed=now() WHERE id=%lu", confirmation, payment_id);
|
||||
pgsql_exec("COMMIT"); // Unlock table 'data'
|
||||
strsafecpy(number, confirmation, sz);
|
||||
}
|
||||
|
||||
void GetMemberAccountLink(long member_id, unsigned long acc_link, char * number) {
|
||||
SQLINTEGER rows;
|
||||
char offer_code[14];
|
||||
|
||||
void GetMemberAccountLink( long member_id, unsigned long acc_link, char * number )
|
||||
{
|
||||
SQLINTEGER rows;
|
||||
char offer_code[14];
|
||||
// Lock table to prevent generation of two identical confirmation numbers
|
||||
pgsql_exec("BEGIN; LOCK TABLE members;");
|
||||
int i = 0;
|
||||
do {
|
||||
GenerateInnerConfirmationSeed(offer_code, sizeof (offer_code), i++);
|
||||
|
||||
// Lock table to prevent generation of two identical confirmation numbers
|
||||
pgsql_exec("BEGIN; LOCK TABLE members_jobs_offer;" );
|
||||
int i = 0;
|
||||
do
|
||||
{
|
||||
GenerateInnerConfirmationSeed( offer_code, sizeof(offer_code), i++ );
|
||||
//st.CloseCursor();
|
||||
rows = 0;
|
||||
const PGresult *res = pgsql_query("SELECT id FROM members WHERE acc_link='%s'", offer_code);
|
||||
if (res != NULL) {
|
||||
rows = pgsql_num_rows(res);
|
||||
}
|
||||
} while (rows > 0 && i < 100);
|
||||
|
||||
//st.CloseCursor();
|
||||
rows = 0;
|
||||
const PGresult *res = pgsql_query("SELECT id FROM members WHERE offer_code='%s'", offer_code );
|
||||
if (res!=NULL )
|
||||
{
|
||||
rows = pgsql_num_rows(res);
|
||||
}
|
||||
} while ( rows>0 && i<100 );
|
||||
|
||||
pgsql_exec("UPDATE members_jobs_offer SET acc_link='%s' WHERE id=%lu", offer_code, member_id );
|
||||
pgsql_exec("COMMIT" ); // Unlock table 'data'
|
||||
// strsafecpy( acc_link, offer_code, sz );
|
||||
pgsql_exec("UPDATE members SET acc_link='%s' WHERE id=%lu", offer_code, member_id);
|
||||
pgsql_exec("COMMIT"); // Unlock table 'data'
|
||||
// strsafecpy( acc_link, offer_code, sz );
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
*/
|
||||
*/
|
||||
|
||||
/* -- */
|
||||
#include "function_members.h"
|
||||
@@ -42,15 +42,15 @@ long MemberLogin(CVars in, CVars &out) {
|
||||
// Create New Session Now
|
||||
if (MemberSessionCheck(out["member_id"].Long(), out["sessionid"].c_str(), 1) > 0) {
|
||||
|
||||
out["acc_link"] = "ME345FT6789";
|
||||
char acc_link[11];
|
||||
// GetMemberAccountLink(out["member_id"].Long(),acc_link, sizeof (acc_link) );
|
||||
// out["acc_link"] = acc_link;
|
||||
|
||||
out["acc_link"] = "ME345FT6789";
|
||||
char acc_link[11];
|
||||
// GetMemberAccountLink(out["member_id"].Long(),acc_link, sizeof (acc_link) );
|
||||
// out["acc_link"] = acc_link;
|
||||
|
||||
out["stauts"] = "OK";
|
||||
/*LOAD THE SESSION INTO OUT now */
|
||||
load_db_record(out, "SELECT session FROM members_session WHERE member_id=%lu ORDER BY id DESC LIMIT 1", out["member_id"].Long());
|
||||
member_email_calls(in["action"].Long(), out, out);
|
||||
member_email_calls(in["action"].Long(), out, out);
|
||||
//===============================================================================================================================
|
||||
pgsql_query("UPDATE members SET last_login = now() WHERE id = %lu", out["member_id"].Long());
|
||||
// account_email(ACCOUNT_LOGIN_ALERT,out,out); // ALERT CUSTOMER OF LOGIN
|
||||
@@ -137,147 +137,146 @@ long MemberSessionCheck(long uid, const char *sessionid, int create) {
|
||||
return 0L; // No route
|
||||
}
|
||||
|
||||
|
||||
long CreateMember(CVars in, CVars &out) {
|
||||
long ret = PHP_API_BAD_PARAM;
|
||||
logfmt(logINFO, "CreateMember()");
|
||||
|
||||
try {
|
||||
|
||||
// REQ_LONG(in, "pid", 0, -1);
|
||||
REQ_STRING(in, "username", 5, 49, "(.*)");
|
||||
REQ_STRING(in, "firstname", 2, 49, "(.*)");
|
||||
REQ_STRING(in, "lastname", 2, 49, "(.*)");
|
||||
OPTIONAL(in, "phone") REQ_STRING(in, "phone", 5, 23, "(.*)");
|
||||
REQ_STRING(in, "password", 5, 49, "(.*)");
|
||||
OPTIONAL(in, "phone") REQ_STRING(in, "loc", 5, 16, "(.*)");
|
||||
OPTIONAL(in, "login") REQ_LONG(in, "login", 0, -1);
|
||||
// REQ_LONG(in, "pid", 0, -1);
|
||||
REQ_STRING(in, "username", 5, 49, "(.*)");
|
||||
REQ_STRING(in, "firstname", 2, 49, "(.*)");
|
||||
REQ_STRING(in, "lastname", 2, 49, "(.*)");
|
||||
OPTIONAL(in, "phone") REQ_STRING(in, "phone", 5, 23, "(.*)");
|
||||
REQ_STRING(in, "password", 5, 49, "(.*)");
|
||||
OPTIONAL(in, "phone") REQ_STRING(in, "loc", 5, 16, "(.*)");
|
||||
OPTIONAL(in, "login") REQ_LONG(in, "login", 0, -1);
|
||||
|
||||
long member_id = 0;
|
||||
long member_id = 0;
|
||||
|
||||
//REQ_STRING (in, "sessionid", 4, 40, "(.*)");
|
||||
const char * loc = getenv("REMOTE_ADDR");
|
||||
//REQ_STRING (in, "sessionid", 4, 40, "(.*)");
|
||||
const char * loc = getenv("REMOTE_ADDR");
|
||||
|
||||
ret = load_db_record(out, "SELECT *,id AS member_id FROM members WHERE LOWER(username)=LOWER('%s') ", in["username"].c_str());
|
||||
if (ret > 0) {
|
||||
ret = load_db_record(out, "SELECT *,id AS member_id FROM members WHERE LOWER(username)=LOWER('%s') ", in["username"].c_str());
|
||||
if (ret > 0) {
|
||||
|
||||
|
||||
|
||||
// LETS CREATE THE ACOUNT NOW
|
||||
CVars x;
|
||||
|
||||
x["username"] = in["username"];
|
||||
x["username"].set_valid(true);
|
||||
x["firstname"] = in["firstname"];
|
||||
x["firstname"].set_valid(true);
|
||||
x["lastname"] = in["lastname"];
|
||||
x["lastname"].set_valid(true);
|
||||
x["phone"] = in["phone"];
|
||||
x["phone"].set_valid(true);
|
||||
x["loc"] = in["loc"];
|
||||
x["loc"].set_valid(true);
|
||||
x["email"] = in["email"];
|
||||
x["email"].set_valid(true);
|
||||
x["password"] = in["email"];
|
||||
x["password"].set_valid(true);
|
||||
out["member_id"] = insert_db_record(DBS_VALID, "members", "members_id_seq", x);
|
||||
if (out["member_id"].Long() > 0) {
|
||||
pgsql_query("UPDATE members SET password = md5('%s') WHERE id = %lu", in["password"].c_str(), out["member_id"].Long()); // setting the password MD5 now
|
||||
// Now Send Email
|
||||
ret = PHP_API_OK;
|
||||
out["status"] = "OK";
|
||||
member_id = out["member_id"].Long();
|
||||
// LETS CREATE THE ACOUNT NOW
|
||||
CVars x;
|
||||
|
||||
//---emailbad member_email_calls(MERMS_USER_CREATEACCOUNT, out, out);
|
||||
// out["member_id"] = member_id;
|
||||
|
||||
// if (in["login"] != "" && in["login"] == 1) {
|
||||
x["username"] = in["username"];
|
||||
x["username"].set_valid(true);
|
||||
x["firstname"] = in["firstname"];
|
||||
x["firstname"].set_valid(true);
|
||||
x["lastname"] = in["lastname"];
|
||||
x["lastname"].set_valid(true);
|
||||
x["phone"] = in["phone"];
|
||||
x["phone"].set_valid(true);
|
||||
x["loc"] = in["loc"];
|
||||
x["loc"].set_valid(true);
|
||||
x["email"] = in["email"];
|
||||
x["email"].set_valid(true);
|
||||
x["password"] = in["email"];
|
||||
x["password"].set_valid(true);
|
||||
out["member_id"] = insert_db_record(DBS_VALID, "members", "members_id_seq", x);
|
||||
if (out["member_id"].Long() > 0) {
|
||||
pgsql_query("UPDATE members SET password = md5('%s') WHERE id = %lu", in["password"].c_str(), out["member_id"].Long()); // setting the password MD5 now
|
||||
// Now Send Email
|
||||
ret = PHP_API_OK;
|
||||
out["status"] = "OK";
|
||||
member_id = out["member_id"].Long();
|
||||
|
||||
//---emailbad member_email_calls(MERMS_USER_CREATEACCOUNT, out, out);
|
||||
// out["member_id"] = member_id;
|
||||
|
||||
// if (in["login"] != "" && in["login"] == 1) {
|
||||
in["action"] = MERMS_USER_LOGIN;
|
||||
in["action"].set_valid(true); // needed for next action to know what email to send
|
||||
ret = MemberLogin(in, out);
|
||||
ret = 100; // needed if login is good
|
||||
// }
|
||||
// }
|
||||
|
||||
// ==============
|
||||
}
|
||||
|
||||
// ==============
|
||||
}
|
||||
|
||||
} else {
|
||||
// LETS CREATE THE ACOUNT NOW
|
||||
CVars x;
|
||||
|
||||
x["username"] = in["username"];
|
||||
x["username"].set_valid(true);
|
||||
x["firstname"] = in["firstname"];
|
||||
x["firstname"].set_valid(true);
|
||||
x["lastname"] = in["lastname"];
|
||||
x["lastname"].set_valid(true);
|
||||
x["phone"] = in["phone"];
|
||||
x["phone"].set_valid(true);
|
||||
x["loc"] = in["loc"];
|
||||
x["loc"].set_valid(true);
|
||||
x["email"] = in["email"];
|
||||
x["email"].set_valid(true);
|
||||
x["password"] = in["email"];
|
||||
x["password"].set_valid(true);
|
||||
out["member_id"] = insert_db_record(DBS_VALID, "members", "members_id_seq", x);
|
||||
if (out["member_id"].Long() > 0) {
|
||||
pgsql_query("UPDATE members SET password = md5('%s') WHERE id = %lu", in["password"].c_str(), out["member_id"].Long()); // setting the password MD5 now
|
||||
// Now Send Email
|
||||
ret = PHP_API_OK;
|
||||
out["status"] = "OK";
|
||||
|
||||
|
||||
//Email bad member_email_calls(in["action"].Long(), out, out);
|
||||
|
||||
// if (in["login"] != "" && in["login"] == 1) {
|
||||
} else {
|
||||
// LETS CREATE THE ACOUNT NOW
|
||||
CVars x;
|
||||
|
||||
x["username"] = in["username"];
|
||||
x["username"].set_valid(true);
|
||||
x["firstname"] = in["firstname"];
|
||||
x["firstname"].set_valid(true);
|
||||
x["lastname"] = in["lastname"];
|
||||
x["lastname"].set_valid(true);
|
||||
x["phone"] = in["phone"];
|
||||
x["phone"].set_valid(true);
|
||||
x["loc"] = in["loc"];
|
||||
x["loc"].set_valid(true);
|
||||
x["email"] = in["email"];
|
||||
x["email"].set_valid(true);
|
||||
x["password"] = in["email"];
|
||||
x["password"].set_valid(true);
|
||||
out["member_id"] = insert_db_record(DBS_VALID, "members", "members_id_seq", x);
|
||||
if (out["member_id"].Long() > 0) {
|
||||
pgsql_query("UPDATE members SET password = md5('%s') WHERE id = %lu", in["password"].c_str(), out["member_id"].Long()); // setting the password MD5 now
|
||||
// Now Send Email
|
||||
ret = PHP_API_OK;
|
||||
out["status"] = "OK";
|
||||
|
||||
|
||||
//Email bad member_email_calls(in["action"].Long(), out, out);
|
||||
|
||||
// if (in["login"] != "" && in["login"] == 1) {
|
||||
in["action"] = MERMS_USER_LOGIN;
|
||||
in["action"].set_valid(true); // needed for next action to know what email to send
|
||||
ret = MemberLogin(in, out);
|
||||
ret = 100; // needed if login is good
|
||||
// }
|
||||
// }
|
||||
|
||||
// ==============
|
||||
// ==============
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}catch (bad_parameter) {
|
||||
|
||||
} catch (bad_parameter) {
|
||||
logfmt(logINFO, "ERROR CALL CreateMember");
|
||||
}
|
||||
}
|
||||
logfmt(logINFO, "/CreateMember()");
|
||||
return ret;
|
||||
}
|
||||
long getMemberProfile(CVars in, CVars &out);
|
||||
long MemberProfile(CVars in, CVars &out){
|
||||
|
||||
|
||||
try{
|
||||
long task_mode = REQ_LONG(in, "task_mode", 0, -1);
|
||||
REQ_LONG(in, "member_id", 0, -1);
|
||||
switch (task_mode) {
|
||||
case MODE_SETVALUE:
|
||||
return medTrUpdateProfile(in, out);
|
||||
break;
|
||||
|
||||
case MODE_GETVALUE:
|
||||
return getMemberProfile(in, out);
|
||||
break;
|
||||
}
|
||||
}catch (bad_parameter) {
|
||||
long MemberProfile(CVars in, CVars &out) {
|
||||
|
||||
|
||||
try {
|
||||
long task_mode = REQ_LONG(in, "task_mode", 0, -1);
|
||||
REQ_LONG(in, "member_id", 0, -1);
|
||||
switch (task_mode) {
|
||||
case MODE_SETVALUE:
|
||||
return medTrUpdateProfile(in, out);
|
||||
break;
|
||||
|
||||
case MODE_GETVALUE:
|
||||
return getMemberProfile(in, out);
|
||||
break;
|
||||
}
|
||||
} catch (bad_parameter) {
|
||||
logfmt(logINFO, "ERROR CALL CreateMember");
|
||||
}
|
||||
}
|
||||
logfmt(logINFO, "/MemberReminders()");
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
long getMemberProfile(CVars in, CVars &out) {
|
||||
|
||||
|
||||
long ret = load_db_record(out, "SELECT m.*,mp.*,m.id AS member_id,mp.id AS member_profile_id FROM members m \
|
||||
long ret = load_db_record(out, "SELECT m.*,mp.*,m.id AS member_id,mp.id AS member_profile_id FROM members m \
|
||||
LEFT JOIN members_profile mp ON mp.member_id = m.id \
|
||||
WHERE m.id = %lu", in["member_id"].Long());
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -299,12 +298,12 @@ long medTrUpdateStartProfile(CVars in, CVars &out) {
|
||||
long medTrUpdateProfile(CVars in, CVars &out) {
|
||||
long ret = PHP_API_BAD_PARAM;
|
||||
logfmt(logINFO, "medTrUpdateProfile()");
|
||||
|
||||
|
||||
REQ_LONG(in, "member_id", 0, -1);
|
||||
REQ_STRING(in, "street1", 2, 49, "(.*)");
|
||||
OPTIONAL(in, "street2") REQ_STRING(in, "street2", 1, 49, "(.*)");
|
||||
REQ_STRING(in, "city", 5, 49, "(.*)");
|
||||
// OPTIONAL(in, "phone") REQ_STRING(in, "phone", 5, 23, "(.*)");
|
||||
// OPTIONAL(in, "phone") REQ_STRING(in, "phone", 5, 23, "(.*)");
|
||||
OPTIONAL(in, "zipcode") REQ_STRING(in, "zipcode", 1, 12, "(.*)");
|
||||
REQ_STRING(in, "state", 1, 59, "(.*)");
|
||||
REQ_STRING(in, "country", 1, 3, "(.*)");
|
||||
@@ -313,16 +312,16 @@ long medTrUpdateProfile(CVars in, CVars &out) {
|
||||
//REQ_STRING (in, "sessionid", 4, 40, "(.*)");
|
||||
const char * loc = getenv("REMOTE_ADDR");
|
||||
CVars x;
|
||||
// x["pid"] = in["pid"];
|
||||
// x["pid"].set_valid(true);
|
||||
// x["pid"] = in["pid"];
|
||||
// x["pid"].set_valid(true);
|
||||
x["street1"] = in["street1"];
|
||||
x["street1"].set_valid(true);
|
||||
x["street2"] = in["street2"];
|
||||
x["street2"].set_valid(true);
|
||||
x["city"] = in["city"];
|
||||
x["city"].set_valid(true);
|
||||
// x["phone"] = in["phone"];
|
||||
// x["phone"].set_valid(true);
|
||||
// x["phone"] = in["phone"];
|
||||
// x["phone"].set_valid(true);
|
||||
x["zipcode"] = in["zipcode"];
|
||||
x["zipcode"].set_valid(true);
|
||||
x["loc"] = in["loc"];
|
||||
@@ -336,7 +335,7 @@ long medTrUpdateProfile(CVars in, CVars &out) {
|
||||
if (ret > 0) {
|
||||
update_db_record(DBS_VALID, "members_profile", x, in["member_profile_id"].Long());
|
||||
member_email_calls(in["action"].Long(), in, out);
|
||||
ret = PHP_API_OK;
|
||||
ret = PHP_API_OK;
|
||||
} else {
|
||||
// LETS CREATE THE ACOUNT NOW
|
||||
x["member_id"] = in["member_id"];
|
||||
@@ -345,7 +344,7 @@ long medTrUpdateProfile(CVars in, CVars &out) {
|
||||
if (out["member_profile_id"].Long() > 0) {
|
||||
member_email_calls(in["action"].Long(), in, out);
|
||||
// Now Send Email
|
||||
ret = PHP_API_OK;
|
||||
ret = PHP_API_OK;
|
||||
// ==============
|
||||
}
|
||||
}
|
||||
@@ -355,38 +354,37 @@ long medTrUpdateProfile(CVars in, CVars &out) {
|
||||
|
||||
/*
|
||||
"sessionid" => $sessionid,
|
||||
"practice_id" => 0,
|
||||
"encounter_id"=> 0,
|
||||
"practice_id" => 0,
|
||||
"encounter_id"=> 0,
|
||||
"member_id" => "1",
|
||||
"description"=> $description,
|
||||
"repeat" => $repeat,
|
||||
"start_date" => $start_date,
|
||||
"end_date" => $end_date,
|
||||
"reminder" => rand(0,3)
|
||||
*/
|
||||
|
||||
"description"=> $description,
|
||||
"repeat" => $repeat,
|
||||
"start_date" => $start_date,
|
||||
"end_date" => $end_date,
|
||||
"reminder" => rand(0,3)
|
||||
*/
|
||||
|
||||
long setMemberReminders(CVars in, CVars &out);
|
||||
long getMemberReminders(CVars in, CVars &out);
|
||||
long MemberReminders(CVars in, CVars &out)
|
||||
{
|
||||
try{
|
||||
long task_mode = REQ_LONG(in, "task_mode", 0, -1);
|
||||
switch (task_mode) {
|
||||
case USER_CREATETASK:
|
||||
return setMemberReminders(in, out);
|
||||
break;
|
||||
|
||||
case USER_LOADTASK:
|
||||
return getMemberReminders(in, out);
|
||||
break;
|
||||
}
|
||||
}catch (bad_parameter) {
|
||||
long MemberReminders(CVars in, CVars &out) {
|
||||
try {
|
||||
long task_mode = REQ_LONG(in, "task_mode", 0, -1);
|
||||
switch (task_mode) {
|
||||
case USER_CREATETASK:
|
||||
return setMemberReminders(in, out);
|
||||
break;
|
||||
|
||||
case USER_LOADTASK:
|
||||
return getMemberReminders(in, out);
|
||||
break;
|
||||
}
|
||||
} catch (bad_parameter) {
|
||||
logfmt(logINFO, "ERROR CALL CreateMember");
|
||||
}
|
||||
}
|
||||
logfmt(logINFO, "/MemberReminders()");
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
long setMemberReminders(CVars in, CVars &out) {
|
||||
long ret = PHP_API_BAD_PARAM;
|
||||
@@ -394,52 +392,52 @@ long setMemberReminders(CVars in, CVars &out) {
|
||||
|
||||
try {
|
||||
|
||||
REQ_LONG(in, "member_id", 0, -1);
|
||||
REQ_LONG(in, "practice_id", 0, -1);
|
||||
REQ_LONG(in, "encounter_id", 0, -1);
|
||||
REQ_STRING(in, "description", 5, 99, "(.*)");
|
||||
REQ_LONG(in, "repeat", 0, -1);
|
||||
REQ_STRING(in, "start_date", 2, 15, "(.*)");
|
||||
REQ_STRING(in, "end_date", 2, 15, "(.*)");
|
||||
REQ_LONG(in, "reminder", 0, -1);
|
||||
//REQ_STRING (in, "sessionid", 4, 40, "(.*)");
|
||||
const char * loc = getenv("REMOTE_ADDR");
|
||||
REQ_LONG(in, "member_id", 0, -1);
|
||||
REQ_LONG(in, "practice_id", 0, -1);
|
||||
REQ_LONG(in, "encounter_id", 0, -1);
|
||||
REQ_STRING(in, "description", 5, 99, "(.*)");
|
||||
REQ_LONG(in, "repeat", 0, -1);
|
||||
REQ_STRING(in, "start_date", 2, 15, "(.*)");
|
||||
REQ_STRING(in, "end_date", 2, 15, "(.*)");
|
||||
REQ_LONG(in, "reminder", 0, -1);
|
||||
//REQ_STRING (in, "sessionid", 4, 40, "(.*)");
|
||||
const char * loc = getenv("REMOTE_ADDR");
|
||||
|
||||
ret = load_db_record(out, "SELECT *,id AS member_id FROM members WHERE id=%lu ", in["member_id"].Long());
|
||||
if (ret > 0) {
|
||||
// LETS CREATE REMINDER
|
||||
CVars x;
|
||||
|
||||
x["member_id"] = in["member_id"];
|
||||
x["member_id"].set_valid(true);
|
||||
x["practice_id"] = in["practice_id"];
|
||||
x["practice_id"].set_valid(true);
|
||||
x["encounter_id"] = in["encounter_id"];
|
||||
x["encounter_id"].set_valid(true);
|
||||
x["description"] = in["description"];
|
||||
x["description"].set_valid(true);
|
||||
x["loc"] = in["loc"];
|
||||
x["loc"].set_valid(true);
|
||||
x["repeat"] = in["repeat"];
|
||||
x["repeat"].set_valid(true);
|
||||
x["reminder"] = in["reminder"];
|
||||
x["reminder"].set_valid(true);
|
||||
|
||||
x["start_date"] = in["start_date"];
|
||||
x["start_date"].set_valid(true);
|
||||
ret = load_db_record(out, "SELECT *,id AS member_id FROM members WHERE id=%lu ", in["member_id"].Long());
|
||||
if (ret > 0) {
|
||||
// LETS CREATE REMINDER
|
||||
CVars x;
|
||||
|
||||
x["end_date"] = in["end_date"];
|
||||
x["end_date"].set_valid(true);
|
||||
|
||||
out["member_reminder_id"] = insert_db_record(DBS_VALID, "members_reminders", "members_reminders_id_seq", x);
|
||||
if (out["member_reminder_id"].Long() > 0) {
|
||||
//---emailbad member_email_calls(MERMS_USER_CREATEACCOUNT, out, out);
|
||||
}
|
||||
}
|
||||
|
||||
}catch (bad_parameter) {
|
||||
x["member_id"] = in["member_id"];
|
||||
x["member_id"].set_valid(true);
|
||||
x["practice_id"] = in["practice_id"];
|
||||
x["practice_id"].set_valid(true);
|
||||
x["encounter_id"] = in["encounter_id"];
|
||||
x["encounter_id"].set_valid(true);
|
||||
x["description"] = in["description"];
|
||||
x["description"].set_valid(true);
|
||||
x["loc"] = in["loc"];
|
||||
x["loc"].set_valid(true);
|
||||
x["repeat"] = in["repeat"];
|
||||
x["repeat"].set_valid(true);
|
||||
x["reminder"] = in["reminder"];
|
||||
x["reminder"].set_valid(true);
|
||||
|
||||
x["start_date"] = in["start_date"];
|
||||
x["start_date"].set_valid(true);
|
||||
|
||||
x["end_date"] = in["end_date"];
|
||||
x["end_date"].set_valid(true);
|
||||
|
||||
out["member_reminder_id"] = insert_db_record(DBS_VALID, "members_reminders", "members_reminders_id_seq", x);
|
||||
if (out["member_reminder_id"].Long() > 0) {
|
||||
//---emailbad member_email_calls(MERMS_USER_CREATEACCOUNT, out, out);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (bad_parameter) {
|
||||
logfmt(logINFO, "ERROR CALL CreateMember");
|
||||
}
|
||||
}
|
||||
logfmt(logINFO, "/CreateMember()");
|
||||
return ret;
|
||||
}
|
||||
@@ -447,27 +445,27 @@ long setMemberReminders(CVars in, CVars &out) {
|
||||
/*
|
||||
members_reminders
|
||||
"sessionid" => $sessionid,
|
||||
"practice_id" => 0,
|
||||
"encounter_id"=> 0,
|
||||
"practice_id" => 0,
|
||||
"encounter_id"=> 0,
|
||||
"member_id" => "1",
|
||||
"description"=> $description,
|
||||
"repeat" => $repeat,
|
||||
"start_date" => $start_date,
|
||||
"end_date" => $end_date,
|
||||
"reminder" => rand(0,3)
|
||||
status = 1
|
||||
*/
|
||||
|
||||
long getMemberReminders(CVars in, CVars &out) {
|
||||
"description"=> $description,
|
||||
"repeat" => $repeat,
|
||||
"start_date" => $start_date,
|
||||
"end_date" => $end_date,
|
||||
"reminder" => rand(0,3)
|
||||
status = 1
|
||||
*/
|
||||
|
||||
long getMemberReminders(CVars in, CVars &out) {
|
||||
long ret = PHP_API_BAD_PARAM;
|
||||
char vname[20];
|
||||
try {
|
||||
// REQ_LONG(in, "status", 0, -1);
|
||||
REQ_LONG( in, "member_id", 0, -1);
|
||||
// REQ_LONG(in, "status", 0, -1);
|
||||
REQ_LONG(in, "member_id", 0, -1);
|
||||
|
||||
out["total_record"] = "0";
|
||||
|
||||
const PGresult *res = pgsql_query("SELECT *,start_date::date AS start_date_formatted,end_date::date AS end_date_formatted FROM members_reminders WHERE member_id = %lu AND status = 1 ORDER BY start_date ASC",in["member_id"].Long());
|
||||
const PGresult *res = pgsql_query("SELECT *,start_date::date AS start_date_formatted,end_date::date AS end_date_formatted FROM members_reminders WHERE member_id = %lu AND status = 1 ORDER BY start_date ASC", in["member_id"].Long());
|
||||
if (res != NULL && pgsql_num_rows(res) > 0) {
|
||||
out["total_record"] = pgsql_num_rows(res);
|
||||
|
||||
@@ -476,11 +474,11 @@ members_reminders
|
||||
if (f.empty()) continue;
|
||||
CVars rec;
|
||||
map_to_cvars(f, rec);
|
||||
|
||||
snprintf(vname, sizeof (vname), "id_%05d", i);
|
||||
|
||||
snprintf(vname, sizeof (vname), "id_%05d", i);
|
||||
out[vname] = rec["id"];
|
||||
|
||||
|
||||
|
||||
snprintf(vname, sizeof (vname), "description_%05d", i);
|
||||
out[vname] = rec["description"];
|
||||
|
||||
@@ -495,10 +493,10 @@ members_reminders
|
||||
|
||||
snprintf(vname, sizeof (vname), "reminder_%05d", i);
|
||||
out[vname] = rec["reminder"];
|
||||
|
||||
snprintf(vname, sizeof (vname), "status_%05d", i);
|
||||
|
||||
snprintf(vname, sizeof (vname), "status_%05d", i);
|
||||
out[vname] = rec["status"];
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
ret = PHP_API_OK;
|
||||
@@ -519,7 +517,7 @@ long medTrMemberTransportById(CVars in, CVars &out) {
|
||||
long ret = PHP_API_BAD_PARAM;
|
||||
ret = load_db_record(out, "SELECT * FROM members_service_request WHERE id = %lu ", in["transport_id"].Long());
|
||||
if (ret > 0) {
|
||||
ret = PHP_API_OK;
|
||||
ret = PHP_API_OK;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -542,11 +540,10 @@ long DeletAallCards(CVars in, CVars &out) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
long medTrMemberServiceById(CVars in, CVars &out) {
|
||||
long ret = PHP_API_BAD_PARAM;
|
||||
|
||||
logfmt(logINFO, " CALL long medTrMemberServiceById(CVars in, CVars &out)");
|
||||
|
||||
logfmt(logINFO, " CALL long medTrMemberServiceById(CVars in, CVars &out)");
|
||||
try {
|
||||
REQ_LONG(in, "member_id", 0, -1);
|
||||
REQ_LONG(in, "service_id", 0, -1);
|
||||
@@ -554,18 +551,18 @@ long medTrMemberServiceById(CVars in, CVars &out) {
|
||||
ret = load_db_record(out, "SELECT s.service_date,s.quantity,a.agent_name,s.est_cost AS estimated_cost,s.flags,s.status,"
|
||||
" TO_CHAR(s.service_date :: TIMESTAMP, 'Day Mon dd, yyyy HH:MM AM') AS long_date,"
|
||||
" a.street,a.city,a.zipcode,a.phone,a.state, "
|
||||
" (CASE WHEN s.dt_confirmed IS NOT NULL THEN 'Confirmed' ELSE 'Not Confirmed' END) AS confirm_text,s.id AS service_id "
|
||||
" (CASE WHEN s.dt_confirmed IS NOT NULL THEN 'Confirmed' ELSE 'Not Confirmed' END) AS confirm_text,s.id AS service_id "
|
||||
" FROM members_service_request s "
|
||||
" LEFT JOIN agents a ON a.id = s.agent_id "
|
||||
" WHERE s.id = %lu ", in["service_id"].Long());
|
||||
if (ret > 0) {
|
||||
// out["estimated_cost"] ="34.00";
|
||||
|
||||
getServiceDetail( out["service_id"].Long(), out);
|
||||
|
||||
// snprintf(vname, sizeof (vname), "service_list_detail_%05d", i);
|
||||
// out[vname] = out["service_list"];
|
||||
|
||||
// out["estimated_cost"] ="34.00";
|
||||
|
||||
getServiceDetail(out["service_id"].Long(), out);
|
||||
|
||||
// snprintf(vname, sizeof (vname), "service_list_detail_%05d", i);
|
||||
// out[vname] = out["service_list"];
|
||||
|
||||
ret = PHP_API_OK;
|
||||
}
|
||||
|
||||
@@ -577,13 +574,12 @@ long medTrMemberServiceById(CVars in, CVars &out) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
long medTrLanguageList(CVars in, CVars &out) {
|
||||
long ret = PHP_API_BAD_PARAM;
|
||||
char vname[20];
|
||||
try {
|
||||
// REQ_LONG(in, "status", 0, -1);
|
||||
REQ_LONG( in, "member_id", 0, -1);
|
||||
// REQ_LONG(in, "status", 0, -1);
|
||||
REQ_LONG(in, "member_id", 0, -1);
|
||||
|
||||
out["total_record"] = "0";
|
||||
|
||||
@@ -611,7 +607,7 @@ long medTrLanguageList(CVars in, CVars &out) {
|
||||
|
||||
snprintf(vname, sizeof (vname), "zipcode_%05d", i);
|
||||
out[vname] = rec["zipcode"];
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
ret = PHP_API_OK;
|
||||
@@ -621,6 +617,7 @@ long medTrLanguageList(CVars in, CVars &out) {
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* street | city | zipcode
|
||||
kleen=> SELECT t.*,a.agent_name,TO_CHAR(t.service_date :: TIMESTAMP, 'Day Mon dd, yyyy HH:MM AM') AS long_date FROM members_service_request t LEFT JOIN agents a ON a.id=t.agent_id;
|
||||
@@ -641,14 +638,14 @@ long medTrMemberTransportList(CVars in, CVars &out) {
|
||||
out["total_record"] = "0";
|
||||
|
||||
const PGresult *res = pgsql_query("SELECT t.id AS service_id, t.*,a.agent_name,"
|
||||
" TO_CHAR(t.service_date :: TIMESTAMP, 'Day Mon dd, yyyy HH:MM AM') AS long_date , "
|
||||
" (CASE WHEN t.dt_confirmed IS NOT NULL THEN 'Confirmed' ELSE 'Not Confirmed' END) AS confirm_text,"
|
||||
" (CASE WHEN t.flags IN(0,1) THEN 'Not Confirmed' WHEN t.flags=2 THEN 'Confirmed' WHEN t.flags=4 THEN 'Assigned' ELSE 'Unknown' END) AS flag_text,"
|
||||
" (CASE WHEN t.service_type=1 THEN 'Laundry' WHEN t.service_type=2 THEN 'Dryclean' ELSE 'Service' END) AS service_type_description"
|
||||
" FROM members_service_request t LEFT JOIN agents a ON a.id=t.agent_id "
|
||||
" WHERE t.member_id= %lu "
|
||||
" ORDER BY t.id DESC LIMIT %lu", in["member_id"].Long(), in["limit"].Long());
|
||||
|
||||
" TO_CHAR(t.service_date :: TIMESTAMP, 'Day Mon dd, yyyy HH:MM AM') AS long_date , "
|
||||
" (CASE WHEN t.dt_confirmed IS NOT NULL THEN 'Confirmed' ELSE 'Not Confirmed' END) AS confirm_text,"
|
||||
" (CASE WHEN t.flags IN(0,1) THEN 'Not Confirmed' WHEN t.flags=2 THEN 'Confirmed' WHEN t.flags=4 THEN 'Assigned' ELSE 'Unknown' END) AS flag_text,"
|
||||
" (CASE WHEN t.service_type=1 THEN 'Laundry' WHEN t.service_type=2 THEN 'Dryclean' ELSE 'Service' END) AS service_type_description"
|
||||
" FROM members_service_request t LEFT JOIN agents a ON a.id=t.agent_id "
|
||||
" WHERE t.member_id= %lu "
|
||||
" ORDER BY t.id DESC LIMIT %lu", in["member_id"].Long(), in["limit"].Long());
|
||||
|
||||
if (res != NULL && pgsql_num_rows(res) > 0) {
|
||||
out["total_record"] = pgsql_num_rows(res);
|
||||
|
||||
@@ -659,7 +656,7 @@ long medTrMemberTransportList(CVars in, CVars &out) {
|
||||
map_to_cvars(f, rec);
|
||||
|
||||
long service_id = rec["service_id"].Long();
|
||||
|
||||
|
||||
snprintf(vname, sizeof (vname), "service_date_%05d", i);
|
||||
out[vname] = rec["service_date"];
|
||||
|
||||
@@ -692,17 +689,17 @@ long medTrMemberTransportList(CVars in, CVars &out) {
|
||||
|
||||
snprintf(vname, sizeof (vname), "stype_desc_%05d", i);
|
||||
out[vname] = rec["service_type_description"];
|
||||
|
||||
getServiceDetail( service_id, out);
|
||||
|
||||
|
||||
getServiceDetail(service_id, out);
|
||||
|
||||
snprintf(vname, sizeof (vname), "service_list_detail_%05d", i);
|
||||
out[vname] = out["service_list"];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
snprintf(vname, sizeof (vname), "flag_text_%05d", i);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
snprintf(vname, sizeof (vname), "flag_text_%05d", i);
|
||||
out[vname] = rec["flag_text"];
|
||||
}
|
||||
}
|
||||
@@ -718,8 +715,8 @@ long medTrMemberTransportList(CVars in, CVars &out) {
|
||||
long getServiceDetail(long service_id, CVars &out) {
|
||||
out["service_list"] = "";
|
||||
char vname[300];
|
||||
long ret = 0;
|
||||
int icc=0;
|
||||
long ret = 0;
|
||||
int icc = 0;
|
||||
ret = load_db_record(out, "SELECT * FROM members_service_request WHERE id = %lu ", service_id);
|
||||
if (ret > 0) {
|
||||
|
||||
@@ -727,11 +724,11 @@ long getServiceDetail(long service_id, CVars &out) {
|
||||
case 1:
|
||||
snprintf(vname, sizeof (vname), "%lu Bag(s)", out["quantity"].Long());
|
||||
out["service_list"] = vname;
|
||||
out["total_detail_record"] ="1";
|
||||
out["total_detail_record"] = "1";
|
||||
break;
|
||||
|
||||
case 2:
|
||||
|
||||
|
||||
const PGresult *res = pgsql_query(" SELECT code,description,price*0.01 AS price,quantity,total*0.01 AS total "
|
||||
" FROM members_service_detail "
|
||||
" WHERE service_id=%lu", service_id);
|
||||
@@ -763,18 +760,11 @@ long getServiceDetail(long service_id, CVars &out) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
vector<string> split_string(const char *str, char c = ' ')
|
||||
{
|
||||
vector<string> split_string(const char *str, char c = ' ') {
|
||||
vector<string> result;
|
||||
do {
|
||||
const char *begin = str;
|
||||
while(*str != c && *str)
|
||||
while (*str != c && *str)
|
||||
str++;
|
||||
result.push_back(string(begin, str));
|
||||
} while (0 != *str++);
|
||||
@@ -782,36 +772,42 @@ vector<string> split_string(const char *str, char c = ' ')
|
||||
}
|
||||
|
||||
// trim from start (in place)
|
||||
|
||||
static inline void ltrim(std::string &s) {
|
||||
s.erase(s.begin(), std::find_if(s.begin(), s.end(),
|
||||
std::not1(std::ptr_fun<int, int>(std::isspace))));
|
||||
}
|
||||
|
||||
// trim from end (in place)
|
||||
|
||||
static inline void rtrim(std::string &s) {
|
||||
s.erase(std::find_if(s.rbegin(), s.rend(),
|
||||
std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end());
|
||||
}
|
||||
|
||||
// trim from both ends (in place)
|
||||
|
||||
static inline void trim(std::string &s) {
|
||||
ltrim(s);
|
||||
rtrim(s);
|
||||
}
|
||||
|
||||
// trim from start (copying)
|
||||
|
||||
static inline std::string ltrim_copy(std::string s) {
|
||||
ltrim(s);
|
||||
return s;
|
||||
}
|
||||
|
||||
// trim from end (copying)
|
||||
|
||||
static inline std::string rtrim_copy(std::string s) {
|
||||
rtrim(s);
|
||||
return s;
|
||||
}
|
||||
|
||||
// trim from both ends (copying)
|
||||
|
||||
static inline std::string trim_copy(std::string s) {
|
||||
trim(s);
|
||||
return s;
|
||||
@@ -819,8 +815,8 @@ static inline std::string trim_copy(std::string s) {
|
||||
|
||||
long kleenNewLundryPickUp(CVars in, CVars &out) {
|
||||
CVars k;
|
||||
out = in;
|
||||
|
||||
out = in;
|
||||
|
||||
long ret = PHP_API_BAD_PARAM;
|
||||
long service_total = 0;
|
||||
long discount_rate = 0;
|
||||
@@ -841,16 +837,16 @@ long kleenNewLundryPickUp(CVars in, CVars &out) {
|
||||
//REQ_STRING (in, "sessionid", 4, 40, "(.*)");
|
||||
OPTIONAL(in, "coupon") REQ_STRING(in, "coupon", 1, 15, "(.*)");
|
||||
OPTIONAL(in, "discount_rate") REQ_LONG(in, "discount_rate", 0, -1);
|
||||
|
||||
discount_rate = in["discount_rate"].Long() + 0;
|
||||
|
||||
|
||||
discount_rate = in["discount_rate"].Long() + 0;
|
||||
|
||||
const char * loc = getenv("REMOTE_ADDR");
|
||||
|
||||
long memberF = 0;
|
||||
logfmt(logINFO, "~~~~~SPLIT_IN1~~~~ MEMBER %lu", memberF);
|
||||
memberF = load_db_record(k, "SELECT *,id AS member_id FROM members WHERE id=%lu ", in["member_id"].Long());
|
||||
logfmt(logINFO, "~~~~~SPLIT_IN2~~~~ MEMBER %lu", memberF);
|
||||
// memberF = 1;
|
||||
long memberF = 0;
|
||||
logfmt(logINFO, "~~~~~SPLIT_IN1~~~~ MEMBER %lu", memberF);
|
||||
memberF = load_db_record(k, "SELECT *,id AS member_id FROM members WHERE id=%lu ", in["member_id"].Long());
|
||||
logfmt(logINFO, "~~~~~SPLIT_IN2~~~~ MEMBER %lu", memberF);
|
||||
// memberF = 1;
|
||||
if (memberF > 0) {
|
||||
// LETS CREATE THE REQUEST NOW
|
||||
CVars x;
|
||||
@@ -880,35 +876,34 @@ long kleenNewLundryPickUp(CVars in, CVars &out) {
|
||||
|
||||
x["coupon"] = in["coupon"];
|
||||
x["coupon"].set_valid(true);
|
||||
|
||||
//in["service_list"] = " S01-1@S02-1@S03-1@S04-1@S05-1@S06-4@S07-1@S08-1@S09-1@S10-1@ ";
|
||||
/*
|
||||
I want to spilit int
|
||||
|
||||
//in["service_list"] = " S01-1@S02-1@S03-1@S04-1@S05-1@S06-4@S07-1@S08-1@S09-1@S10-1@ ";
|
||||
/*
|
||||
I want to spilit int
|
||||
|
||||
S01 1
|
||||
S02 2
|
||||
S03 1
|
||||
S04 1
|
||||
S05 1
|
||||
S06 2
|
||||
S07 1
|
||||
S08 1
|
||||
S09 1
|
||||
S10 1
|
||||
S01 1
|
||||
S02 2
|
||||
S03 1
|
||||
S04 1
|
||||
S05 1
|
||||
S06 2
|
||||
S07 1
|
||||
S08 1
|
||||
S09 1
|
||||
S10 1
|
||||
|
||||
INSERT INTO table (SO1, 1)
|
||||
*/
|
||||
|
||||
|
||||
INSERT INTO table (SO1, 1)
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
out["service_id"] = insert_db_record(DBS_VALID, "members_service_request", "members_service_request_id_seq", x);
|
||||
if (out["service_id"].Long() > 0) {
|
||||
|
||||
if (in["instruction"].length() > 0)
|
||||
{
|
||||
// let us save instruction to another table
|
||||
}
|
||||
|
||||
if (in["instruction"].length() > 0) {
|
||||
// let us save instruction to another table
|
||||
}
|
||||
|
||||
if (x["service_type"].Long() == 2) { // dry clean service now
|
||||
logfmt(FLOG_MAX, "service_list=%s", in["service_list"].c_str());
|
||||
@@ -924,9 +919,9 @@ long kleenNewLundryPickUp(CVars in, CVars &out) {
|
||||
key = strtok((char *) item.c_str(), "-");
|
||||
val = strtok(NULL, "-");
|
||||
logfmt(FLOG_MAX, "key=%s, val=%s", key, val);
|
||||
|
||||
|
||||
CVars v;
|
||||
if ( load_db_record(v, "SELECT * FROM dryclean_service WHERE code='%s' ", key) > 0 ) {
|
||||
if (load_db_record(v, "SELECT * FROM dryclean_service WHERE code='%s' ", key) > 0) {
|
||||
CVars m;
|
||||
m["member_id"] = in["member_id"];
|
||||
m["member_id"].set_valid(true);
|
||||
@@ -940,51 +935,51 @@ long kleenNewLundryPickUp(CVars in, CVars &out) {
|
||||
m["price"].set_valid(true);
|
||||
m["quantity"] = val;
|
||||
m["quantity"].set_valid(true);
|
||||
m["total"] = m["quantity"].Long() * v["price"].Long();
|
||||
m["total"] = m["quantity"].Long() * v["price"].Long();
|
||||
m["total"].set_valid(true);
|
||||
out["detail_id"] = insert_db_record(DBS_VALID, "members_service_detail", "members_service_detail_id_seq", m);
|
||||
|
||||
service_total = m["total"].Long() + service_total;
|
||||
|
||||
/*
|
||||
id | code | description | price | added
|
||||
----+------+-------------------+-------+----------------------------
|
||||
1 | S01 | Shirt (Laundry) | 160 | 2018-07-19 09:43:21.379297
|
||||
2 | S02 | Shirt (Dry Clean) | 400 | 2018-07-19 09:43:21.383512
|
||||
3 | S03 | Shirt (Ladies) | 400 | 2018-07-19 09:43:21.386951
|
||||
service_total = m["total"].Long() + service_total;
|
||||
|
||||
/*
|
||||
id | code | description | price | added
|
||||
----+------+-------------------+-------+----------------------------
|
||||
1 | S01 | Shirt (Laundry) | 160 | 2018-07-19 09:43:21.379297
|
||||
2 | S02 | Shirt (Dry Clean) | 400 | 2018-07-19 09:43:21.383512
|
||||
3 | S03 | Shirt (Ladies) | 400 | 2018-07-19 09:43:21.386951
|
||||
|
||||
*/
|
||||
|
||||
*/
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
CVars t;
|
||||
if (in["service_type"].Long() == 2) {
|
||||
|
||||
if (discount_rate < 100) {
|
||||
service_total = service_total * (100 - discount_rate)/100;
|
||||
service_total = service_total * (100 - discount_rate) / 100;
|
||||
}
|
||||
t["est_cost"] = service_total;
|
||||
} else {
|
||||
t["est_cost"] = serviceCost(out["service_id"].Long(), discount_rate);
|
||||
}
|
||||
|
||||
pgsql_query("UPDATE members_service_request SET est_cost = %lu, discount_rate = %lu WHERE id = %lu", t["est_cost"].Long(),discount_rate, out["service_id"].Long());
|
||||
|
||||
serviceCost( out["service_id"].Long(),discount_rate );
|
||||
|
||||
pgsql_query("UPDATE members_service_request SET est_cost = %lu, discount_rate = %lu WHERE id = %lu", t["est_cost"].Long(), discount_rate, out["service_id"].Long());
|
||||
|
||||
serviceCost(out["service_id"].Long(), discount_rate);
|
||||
load_db_record(out, "SELECT * FROM members_service_request WHERE id=%lu ", out["service_id"].Long());
|
||||
// Now Send Email
|
||||
member_email_calls(in["action"].Long(), out, out);
|
||||
alert_email_calls(in["action"].Long(), out, out);
|
||||
// ==============
|
||||
ret = 100;
|
||||
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -1013,7 +1008,7 @@ long serviceCost(long service_id, long discount_rate) {
|
||||
|
||||
}
|
||||
if (discount_rate < 100) {
|
||||
service_cost = service_cost * (100 - discount_rate)/100;
|
||||
service_cost = service_cost * (100 - discount_rate) / 100;
|
||||
}
|
||||
return service_cost;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user