From 7ca6824a32a28b4b8cb1571db2dc90a623f91a17 Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Tue, 13 Jun 2023 17:54:46 -0400 Subject: [PATCH] contract_id --- wrenchboard/src/shared_tool/contract.cc | 72 +++++++++++++++++-------- www-api/app/Models/ResultFormatter.php | 2 +- 2 files changed, 50 insertions(+), 24 deletions(-) diff --git a/wrenchboard/src/shared_tool/contract.cc b/wrenchboard/src/shared_tool/contract.cc index a042eb76..8a585b62 100644 --- a/wrenchboard/src/shared_tool/contract.cc +++ b/wrenchboard/src/shared_tool/contract.cc @@ -44,27 +44,51 @@ long WrenchContractStatus( CVars in, CVars &out ) long ret = 0; logfmt( logINFO, "WrenchContractStatus()" ); REQ_LONG( in, "member_id", 1, -1 ); - REQ_STRING (in, "job_contract", 7, 25, "(.*)"); - REQ_LONG( in, "job_id", 1, -1 ); + REQ_STRING (in, "contract", 7, 25, "(.*)"); + contract_uid (in, "contract_uid", 7, 125, "(.*)"); + //REQ_LONG( in, "job_id", 1, -1 ); long job_action = REQ_LONG( in, "job_action", 1, -1 ); out["result"] = "Yes i go to this back end"; long extension = 0; - - in["contract_id"] = in["job_id"]; in["contract_id"].set_valid( true ); // the email system uses contract_id + + + ret = load_db_record( out, "SELECT id AS contract_id FROM members_jobs_contract WHERE contract='%s' AND uid = '%s'",in["contract"].c_str(),in["job_contract"].c_str(),); + if (ret){ + if ( out["contract_id"].Long() > 0 ){ + + } + else{ + + return ret; + } + } + else{ + + return ret; + } + /* + 'uid' => '3119b744-42ad-4834-bb83-b737588754ca', + 'contract' => 'X2Y9WR5632', + 'contract_uid' => '10654dc5-f574-4aa6-b8e6-93b95ac5fcec', + 'job_action' => ‘ACCEPT_COMPLETE’, + + */ + in["contract_id"] = out["contract_id"]; in["contract_id"].set_valid( true ); // the email system uses contract_id + in["job_contract"] = in["contract"]; in["job_contract"].set_valid( true ); switch( job_action ) { case CONTRACT_NOTIFY_COMPLETE: ret = load_db_record( out, "SELECT id AS jobs_contract_id, * FROM members_jobs_contract WHERE status IN (1,2) " - " AND contract='%s' AND id=%lu AND client_id =%lu",in["job_contract"].c_str(),in["job_id"].Long(),in["member_id"].Long() ); + " AND contract='%s' AND id=%lu AND client_id =%lu",in["job_contract"].c_str(),in["contract_id"].Long(),in["member_id"].Long() ); logfmt( logINFO, "~~~~ ~~~~~ WrenchContractStatus() ret 1 = %lu",ret ); if (ret) { if ( out["jobs_contract_id"].Long() > 0 ){ - pgsql_exec("UPDATE members_jobs_contract SET status = %lu,updated=now() WHERE id = %lu",CONTRACT_NOTIFY_COMPLETE, in["job_id"].Long() ); + pgsql_exec("UPDATE members_jobs_contract SET status = %lu,updated=now() WHERE id = %lu",CONTRACT_NOTIFY_COMPLETE, in["contract_id"].Long() ); if ( load_db_record( out, "SELECT * FROM members_jobs_contract " - " WHERE status = %lu AND id=%lu AND client_id =%lu",CONTRACT_NOTIFY_COMPLETE,in["job_id"].Long(),in["member_id"].Long() ) ) + " WHERE status = %lu AND id=%lu AND client_id =%lu",CONTRACT_NOTIFY_COMPLETE,in["contract_id"].Long(),in["member_id"].Long() ) ) { project_email(CONTRACT_NOTIFY_COMPLETE, in, out); out["result"] = "We have notify the task owner of your completion. Expect a response soon"; @@ -75,7 +99,7 @@ long WrenchContractStatus( CVars in, CVars &out ) case CONTRACT_REQUEST_CANCEL: ret = load_db_record( out, "SELECT id AS jobs_contract_id,* FROM members_jobs_contract WHERE status IN (1,2) " - " AND contract='%s' AND id=%lu AND client_id =%lu",in["job_contract"].c_str(),in["job_id"].Long(),in["member_id"].Long() ); + " AND contract='%s' AND id=%lu AND client_id =%lu",in["job_contract"].c_str(),in["contract_id"].Long(),in["member_id"].Long() ); logfmt( logINFO, "~~~~ ~~~~~ WrenchContractStatus() ret 1 = %lu",ret ); if (ret) { @@ -83,7 +107,7 @@ long WrenchContractStatus( CVars in, CVars &out ) pgsql_exec("UPDATE members_jobs_contract SET status = %lu,updated=now() " " WHERE id = %lu",CONTRACT_REQUEST_CANCEL, in["job_id"].Long() ); if ( load_db_record( out, "SELECT * FROM members_jobs_contract WHERE status = %lu " - " AND id=%lu AND client_id =%lu",CONTRACT_REQUEST_CANCEL,in["job_id"].Long(),in["member_id"].Long() ) ) + " AND id=%lu AND client_id =%lu",CONTRACT_REQUEST_CANCEL,in["contract_id"].Long(),in["member_id"].Long() ) ) { project_email(CONTRACT_REQUEST_CANCEL, in, out); out["result"] = "We have notify the task owner of your request for cancellation."; @@ -95,25 +119,27 @@ long WrenchContractStatus( CVars in, CVars &out ) case CONTRACT_ACCEPT_COMPLETE: - ret = load_db_record( out, "SELECT * 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["job_id"].Long(),in["member_id"].Long() ); + ret = load_db_record( out, "SELECT * 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) { pgsql_exec("UPDATE members_jobs_contract SET status = %lu,updated=now() WHERE id = %lu",CONTRACT_ACCEPT_COMPLETE, in["job_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["job_id"].Long(),in["member_id"].Long() ) ) + 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() ) ) { //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["job_id"]; + y["contract_id"] = in["contract_id"]; y["code"] = "COPAY"; y["dir"] = DIR_TARGET; if ( WrenchContractPayment(y,out) == PHP_CREATED_OK ) { // if you reserve pauments //char offer_code[15] = ""; //GetOfferCode(offer_id, offer_code, sizeof (offer_code)); // this stamp the offer code directly in that call - pgsql_exec("UPDATE members_jobs_contract SET updated = now(),payment_date=now() WHERE id = %lu",out["job_id"].Long()); + pgsql_exec("UPDATE members_jobs_contract SET updated = now(),payment_date=now() WHERE id = %lu",out["contract_id"].Long()); } else { @@ -128,13 +154,13 @@ long WrenchContractStatus( CVars in, CVars &out ) break; case CONTRACT_REJECT_COMPLETE: - ret = load_db_record( out, "SELECT * 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["job_id"].Long(),in["member_id"].Long() ); + ret = load_db_record( out, "SELECT * 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) { - pgsql_exec("UPDATE members_jobs_contract SET status = %lu,updated=now() WHERE id = %lu",CONTRACT_REJECT_COMPLETE, in["job_id"].Long() ); + pgsql_exec("UPDATE members_jobs_contract SET status = %lu,updated=now() WHERE id = %lu",CONTRACT_REJECT_COMPLETE, in["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_REJECT_COMPLETE,in["job_id"].Long(),in["member_id"].Long() ) ) + if ( load_db_record( out, "SELECT * FROM members_jobs_contract WHERE status = %lu AND id=%lu AND member_id =%lu",CONTRACT_REJECT_COMPLETE,in["contract_id"].Long(),in["member_id"].Long() ) ) { project_email(CONTRACT_REJECT_COMPLETE, in, out); out["result"] = "You have rejected that this task is complete. We have notified all parties accordingly"; @@ -146,13 +172,13 @@ long WrenchContractStatus( CVars in, CVars &out ) out["result"] = "CONTRACT_EXTEND_TIMELINE"; extension = REQ_LONG( in, "extension", 1, -1 ); - ret = load_db_record( out, "SELECT * FROM members_jobs_contract WHERE status IN (1,2) AND contract='%s' AND id=%lu AND member_id =%lu AND delivery_date < now()",in["job_contract"].c_str(),in["job_id"].Long(),in["member_id"].Long() ); + ret = load_db_record( out, "SELECT * FROM members_jobs_contract WHERE status IN (1,2) AND contract='%s' AND id=%lu AND member_id =%lu AND delivery_date < now()",in["job_contract"].c_str(),in["contract_id"].Long(),in["member_id"].Long() ); logfmt( logINFO, "~~~~ ~~~~~ WrenchContractStatus() ret 1 = %lu",ret ); if (ret) { - pgsql_exec("UPDATE members_jobs_contract SET due_remind = NULL, delivery_date = now() +'%lu days' WHERE status IN (1,2) AND id = %lu AND contract='%s'",extension, in["job_id"].Long() ,in["job_contract"].c_str()); + pgsql_exec("UPDATE members_jobs_contract SET due_remind = NULL, delivery_date = now() +'%lu days' WHERE status IN (1,2) AND id = %lu AND contract='%s'",extension, in["contract_id"].Long() ,in["job_contract"].c_str()); // make sure the update was done - if ( load_db_record( out, "SELECT * FROM members_jobs_contract WHERE id=%lu AND member_id =%lu AND delivery_date > now()",in["job_id"].Long(),in["member_id"].Long() ) ) + if ( load_db_record( out, "SELECT * FROM members_jobs_contract WHERE id=%lu AND member_id =%lu AND delivery_date > now()",in["contract_id"].Long(),in["member_id"].Long() ) ) { project_email(CONTRACT_EXTEND_TIMELINE, in, out); out["result"] = "We have extended the timeline as requested"; @@ -163,17 +189,17 @@ long WrenchContractStatus( CVars in, CVars &out ) case CONTRACT_CANCEL_CONTRACT: out["result"] = "CONTRACT_CANCEL_CONTRACT"; - ret = load_db_record( out, "SELECT * FROM members_jobs_contract WHERE status IN (1,2) AND delivery_date < now() AND contract='%s' AND id=%lu AND member_id =%lu",in["job_contract"].c_str(),in["job_id"].Long(),in["member_id"].Long() ); + ret = load_db_record( out, "SELECT * FROM members_jobs_contract WHERE status IN (1,2) AND delivery_date < now() AND contract='%s' AND id=%lu AND member_id =%lu",in["job_contract"].c_str(),in["contract_id"].Long(),in["member_id"].Long() ); if (ret) { pgsql_exec("UPDATE members_jobs_contract SET status = %lu,updated=now() WHERE id = %lu",CONTRACT_CANCEL_CONTRACT, in["job_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_CANCEL_CONTRACT,in["job_id"].Long(),in["member_id"].Long() ) ) + if ( load_db_record( out, "SELECT * FROM members_jobs_contract WHERE status = %lu AND id=%lu AND member_id =%lu",CONTRACT_CANCEL_CONTRACT,in["contract_id"].Long(),in["member_id"].Long() ) ) { //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["job_id"]; + y["contract_id"] = in["contract_id"]; y["code"] = "COCNL"; y["dir"] = DIR_TARGET; y["job_status"] = CONTRACT_CANCEL_CONTRACT; @@ -181,7 +207,7 @@ long WrenchContractStatus( CVars in, CVars &out ) { // if you reserve pauments //char offer_code[15] = ""; //GetOfferCode(offer_id, offer_code, sizeof (offer_code)); // this stamp the offer code directly in that call - pgsql_exec("UPDATE members_jobs_contract SET updated = now(),payment_date=now() WHERE id = %lu",out["job_id"].Long()); + pgsql_exec("UPDATE members_jobs_contract SET updated = now(),payment_date=now() WHERE id = %lu",out["contract_id"].Long()); } else { diff --git a/www-api/app/Models/ResultFormatter.php b/www-api/app/Models/ResultFormatter.php index 8d0fc74a..6d7e7ffe 100644 --- a/www-api/app/Models/ResultFormatter.php +++ b/www-api/app/Models/ResultFormatter.php @@ -109,7 +109,7 @@ class ResultFormatter extends Model } break; - + case WRENCHBOARD_ACCOUNT_DASHDATA: $res = $out; $res['home_activities'] = [];