contract_id

This commit is contained in:
CHIEFSOFT\ameye
2023-06-13 17:54:46 -04:00
parent 33136d62ba
commit 7ca6824a32
2 changed files with 50 additions and 24 deletions
+49 -23
View File
@@ -44,27 +44,51 @@ long WrenchContractStatus( CVars in, CVars &out )
long ret = 0; long ret = 0;
logfmt( logINFO, "WrenchContractStatus()" ); logfmt( logINFO, "WrenchContractStatus()" );
REQ_LONG( in, "member_id", 1, -1 ); REQ_LONG( in, "member_id", 1, -1 );
REQ_STRING (in, "job_contract", 7, 25, "(.*)"); REQ_STRING (in, "contract", 7, 25, "(.*)");
REQ_LONG( in, "job_id", 1, -1 ); contract_uid (in, "contract_uid", 7, 125, "(.*)");
//REQ_LONG( in, "job_id", 1, -1 );
long job_action = REQ_LONG( in, "job_action", 1, -1 ); long job_action = REQ_LONG( in, "job_action", 1, -1 );
out["result"] = "Yes i go to this back end"; out["result"] = "Yes i go to this back end";
long extension = 0; 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 ) switch( job_action )
{ {
case CONTRACT_NOTIFY_COMPLETE: case CONTRACT_NOTIFY_COMPLETE:
ret = load_db_record( out, "SELECT id AS jobs_contract_id, * FROM members_jobs_contract WHERE status IN (1,2) " 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 ); logfmt( logINFO, "~~~~ ~~~~~ WrenchContractStatus() ret 1 = %lu",ret );
if (ret) if (ret)
{ {
if ( out["jobs_contract_id"].Long() > 0 ){ 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 " 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); project_email(CONTRACT_NOTIFY_COMPLETE, in, out);
out["result"] = "We have notify the task owner of your completion. Expect a response soon"; 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: case CONTRACT_REQUEST_CANCEL:
ret = load_db_record( out, "SELECT id AS jobs_contract_id,* FROM members_jobs_contract WHERE status IN (1,2) " 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 ); logfmt( logINFO, "~~~~ ~~~~~ WrenchContractStatus() ret 1 = %lu",ret );
if (ret) if (ret)
{ {
@@ -83,7 +107,7 @@ long WrenchContractStatus( CVars in, CVars &out )
pgsql_exec("UPDATE members_jobs_contract SET status = %lu,updated=now() " pgsql_exec("UPDATE members_jobs_contract SET status = %lu,updated=now() "
" WHERE id = %lu",CONTRACT_REQUEST_CANCEL, in["job_id"].Long() ); " WHERE id = %lu",CONTRACT_REQUEST_CANCEL, in["job_id"].Long() );
if ( load_db_record( out, "SELECT * FROM members_jobs_contract WHERE status = %lu " 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); project_email(CONTRACT_REQUEST_CANCEL, in, out);
out["result"] = "We have notify the task owner of your request for cancellation."; 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: 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 ); logfmt( logINFO, "~~~~ ~~~~~ WrenchContractStatus() ret 1 = %lu",ret );
if (ret) if (ret)
{ {
pgsql_exec("UPDATE members_jobs_contract SET status = %lu,updated=now() WHERE id = %lu",CONTRACT_ACCEPT_COMPLETE, in["job_id"].Long() ); 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 // 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 //let us do the accounting parts here now
CVars y; CVars y;
y["member_id"] = in["member_id"]; // note we are actually paying the client_id 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["code"] = "COPAY";
y["dir"] = DIR_TARGET; y["dir"] = DIR_TARGET;
if ( WrenchContractPayment(y,out) == PHP_CREATED_OK ) if ( WrenchContractPayment(y,out) == PHP_CREATED_OK )
{ // if you reserve pauments { // if you reserve pauments
//char offer_code[15] = ""; //char offer_code[15] = "";
//GetOfferCode(offer_id, offer_code, sizeof (offer_code)); // this stamp the offer code directly in that call //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 else
{ {
@@ -128,13 +154,13 @@ long WrenchContractStatus( CVars in, CVars &out )
break; break;
case CONTRACT_REJECT_COMPLETE: 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 ); logfmt( logINFO, "~~~~ ~~~~~ WrenchContractStatus() ret 1 = %lu",ret );
if (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 // 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); project_email(CONTRACT_REJECT_COMPLETE, in, out);
out["result"] = "You have rejected that this task is complete. We have notified all parties accordingly"; 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"; out["result"] = "CONTRACT_EXTEND_TIMELINE";
extension = REQ_LONG( in, "extension", 1, -1 ); 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 ); logfmt( logINFO, "~~~~ ~~~~~ WrenchContractStatus() ret 1 = %lu",ret );
if (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 // 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); project_email(CONTRACT_EXTEND_TIMELINE, in, out);
out["result"] = "We have extended the timeline as requested"; out["result"] = "We have extended the timeline as requested";
@@ -163,17 +189,17 @@ long WrenchContractStatus( CVars in, CVars &out )
case CONTRACT_CANCEL_CONTRACT: case CONTRACT_CANCEL_CONTRACT:
out["result"] = "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) if (ret)
{ {
pgsql_exec("UPDATE members_jobs_contract SET status = %lu,updated=now() WHERE id = %lu",CONTRACT_CANCEL_CONTRACT, in["job_id"].Long() ); 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 // 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 //let us do the accounting parts here now
CVars y; CVars y;
y["member_id"] = in["member_id"]; // note we are actually paying the client_id 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["code"] = "COCNL";
y["dir"] = DIR_TARGET; y["dir"] = DIR_TARGET;
y["job_status"] = CONTRACT_CANCEL_CONTRACT; y["job_status"] = CONTRACT_CANCEL_CONTRACT;
@@ -181,7 +207,7 @@ long WrenchContractStatus( CVars in, CVars &out )
{ // if you reserve pauments { // if you reserve pauments
//char offer_code[15] = ""; //char offer_code[15] = "";
//GetOfferCode(offer_id, offer_code, sizeof (offer_code)); // this stamp the offer code directly in that call //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 else
{ {
+1 -1
View File
@@ -109,7 +109,7 @@ class ResultFormatter extends Model
} }
break; break;
case WRENCHBOARD_ACCOUNT_DASHDATA: case WRENCHBOARD_ACCOUNT_DASHDATA:
$res = $out; $res = $out;
$res['home_activities'] = []; $res['home_activities'] = [];