family count

This commit is contained in:
CHIEFSOFT\ameye
2023-11-11 10:07:01 -05:00
parent 16514b960f
commit 8ad44b2781
2 changed files with 19 additions and 5 deletions
+13
View File
@@ -519,6 +519,8 @@ CREATE TABLE members_myfiles (
long WrenchGetRecentDash(CVars in, CVars &out) {
long WrenchJobCount(long member_id);
long WrenchFamilyCount(long member_id);
logfmt(logINFO, "WrenchGetRecentDash()");
char vname[30];
@@ -2198,6 +2200,15 @@ long WrenchJobCount(long member_id){
return active_job_count;
}
long WrenchFamilyCount(long member_id){
CVars out;
long active_family_count = 0 ;
if ( load_db_record(out, "SELECT count(id) AS active_job_count FROM members_family WHERE member_id=%lu AND status = 1",member_id)> 0 ){
active_family_count = out["active_job_count"].Long();
}
return active_family_count;
}
long LoginWrenchBoardAccount(CVars in, CVars &out) {
long ret = PHP_API_BAD_PARAM;
@@ -2247,6 +2258,7 @@ long LoginWrenchBoardAccount(CVars in, CVars &out) {
out["profile_pic_url"] = "https://www.wrenchboard.com/assets/images/profile.jpg";
out["password"] = "";
out["active_job_count"] = WrenchJobCount( out["member_id"].Long() );
out["active_family_count"] = WrenchFamilyCount( out["member_id"].Long() );
LoginLogger(out["member_id"].Long(),login_mode);
} else {
out["status"] = "Session check failed";
@@ -2395,6 +2407,7 @@ long LoginWrenchBoardExternal(CVars in, CVars &out) {
account_email(ACCOUNT_LOGIN_ALERT, out, out); // ALERT CUSTOMER OF LOGIN
out["profile_pic_url"] = "https://www.wrenchboard.com/assets/images/profile.jpg";
out["active_job_count"] = WrenchJobCount( out["member_id"].Long() );
out["active_family_count"] = WrenchFamilyCount( out["member_id"].Long() );
res = PHP_LOGIN_OK;
} else {
out["status"] = "Session check failed";
+6 -5
View File
@@ -120,13 +120,14 @@ long WrenchContractStatus( CVars in, CVars &out )
break;
case CONTRACT_ACCEPT_COMPLETE:
logfmt( logINFO, "~~~~ ~~~~~ WrenchContractStatus() CONTRACT_ACCEPT_COMPLETE" );
ret = load_db_record( out, "SELECT *, id AS job_id FROM members_jobs_contract WHERE status = %lu AND contract='%s' AND id=%lu "
logfmt( logINFO, "~~~~ ~~~~~ WrenchContractStatus() :: :: :: CONTRACT_ACCEPT_COMPLETE" );
//logfmt( logINFO, "~~~~ ~~~~~ WrenchContractStatus() CONTRACT_ACCEPT_COMPLETE" );
ret = load_db_record( out, "SELECT *, id AS contract_id FROM members_jobs_contract WHERE status = %lu AND contract='%s' AND id=%lu "
" AND member_id =%lu",CONTRACT_NOTIFY_COMPLETE,in["job_contract"].c_str(),in["contract_id"].Long(),in["member_id"].Long() );
logfmt( logINFO, "~~~~ ~~~~~ WrenchContractStatus() ret 1 = %lu",ret );
if (ret && out["job_id"].Long() > 0 )
if (ret && out["contract_id"].Long() > 0 )
{
pgsql_exec("UPDATE members_jobs_contract SET status = %lu,updated=now() WHERE id = %lu",CONTRACT_ACCEPT_COMPLETE, out["job_id"].Long() );
pgsql_exec("UPDATE members_jobs_contract SET status = %lu,updated=now() WHERE id = %lu",CONTRACT_ACCEPT_COMPLETE, out["contract_id"].Long() );
// make sure the update was done
if ( load_db_record( out, "SELECT * FROM members_jobs_contract WHERE status = %lu AND id=%lu "
" AND member_id =%lu",CONTRACT_ACCEPT_COMPLETE,in["contract_id"].Long(),in["member_id"].Long() ) > 0 )
@@ -134,7 +135,7 @@ long WrenchContractStatus( CVars in, CVars &out )
//let us do the accounting parts here now
CVars y;
y["member_id"] = in["member_id"]; // note we are actually paying the client_id
y["contract_id"] = in["contract_id"];
y["contract_id"] = out["contract_id"];
y["code"] = "COPAY";
y["dir"] = DIR_TARGET;
if ( WrenchContractPayment(y,out) == PHP_CREATED_OK )