$carr) { foreach($carr as $cid) { $sql = "insert into tblqueueapprovalinvite ( queueapprovalid , queueapprovalinvitecreatedby , {$k_type}id) values ( ".db_number($queueapproval[queueapprovalid])." ,".db_number($queueapproval[queueapprovalcreatedby])." ,".db_number($cid)." )"; db_exec($sql,1); } } $queueapproval = queueapproval_get($queueapproval[type],$queueapproval[queueapprovalid],$queueapproval[queueapprovalmodifier]); } } $emailvars[lowerlevelcontacts]=""; //d('Function queueapproval_sendnotice queueapproval: ',$queueapproval); if($queueapproval[data][clientcompanyproperty][clientcompanyclientid] && $queueapproval[queueapprovalparam2]) { //d('clientcompanyclientid: ', $queueapproval[data][clientcompanyproperty][clientcompanyclientid]); $lowerescalationcontacts=get_lowerescalationcontacts($queueapproval[data][clientcompanyproperty][clientcompanyclientid], $queueapproval[queueapprovalparam2]); //d("lowerescalationcontacts", $lowerescalationcontacts); if($lowerescalationcontacts && is_array($lowerescalationcontacts)) { //d('lowerescalationcontacts: ', $lowerescalationcontacts); $emailarr[lowerlevelcontacts]=''; foreach($lowerescalationcontacts as $contactkey=>$contactid) { $lowerlevelemail = contact_getfield($contactid, contactemail); //d("lowerlevelemail", $lowerlevelemail); if($lowerlevelemail) { $emailvars[lowerlevelcontacts].=contact_getfield($contactid, contactcname)."
"; } } } } $emailvars[loannumber]=""; if($queueapproval[data][clientcompanyproperty][clientcompanypropertyid]) $emailvars[loannumber]=get_clientpropertyextensionentry($queueapproval[data][clientcompanyproperty][clientcompanypropertyid],propertyextensionloannumber); $emailvars[requestername]= get_login_info($queueapproval[queueapprovalcreatedby]); $emailvars[level]=$queueapproval[queueapprovalparam2]; $emailvars[invitedcontacts]=""; if($queueapproval[invites] && is_array($queueapproval[invites])) { foreach($queueapproval[invites] as $invite) { $externalusertype = externalusertype_get(approvalcontact); $data = array(); // Contact doesn't get clientcompanyid or property $data[new_companyidfieldlabel] = 'clientcompanyid'; $data[new_companyidfieldvalue] = 0; $data[new_propertyidfieldlabel] = 'propertyid'; $data[new_externaluserinviteemail] = contact_getfield($invite[contactid], contactemail); $data[externalusertypeid] = $externalusertype[externalusertypeid]; $data[new_contactid] = $invite[contactid]; $externaluserinviteid = externaluserinvite_create($data); d(__SENDING_INVITE__, $invitearr); $proto="https"; if($_SERVER[SERVER_PORT]==80) $proto="http"; $emailvars["link"] = "$proto://$_SERVER[HTTP_HOST]?redirect_queueapprovalid=".$queueapproval[queueapprovalid]; $emailvars["additionallinkinfo"]="&redirect_queueapprovalid=".$queueapproval[queueapprovalid]; $emailvars[additionalinfo] = ''; if($queueapproval[additionalinfo]) $emailvars[additionalinfo] = implode('
',$queueapproval[additionalinfo]); // Send email notification externaluserinvite_sendinvite($externaluserinviteid, 'approvalrequestinvite',$emailvars); $sql = "update tblqueueapprovalinvite set queueapprovalinvitelastnoticesentdate = now() where queueapprovalinviteid = $invite[queueapprovalinviteid]"; db_exec($sql); if($invite[name]) $emailvars[invitedcontacts].=$invite[name]."
"; } } //d("Pulling clientcompanyclient for current clientproperty", $queueapproval[data][clientcompanyproperty][clientcompanyclient]); if($lowerescalationcontacts && is_array($lowerescalationcontacts)) { //d(emailvars,$emailvars); $em = get_email('approvalrequestinvitenotice'); $emailvars[additionalinfo] = ''; if($queueapproval[additionalinfo]) $emailvars[additionalinfo] = implode('
',$queueapproval[additionalinfo]); $emailtext = $em[emailtext]; $emailtext = email_replace_arr($emailtext,$emailvars); $emailsubject = $em[emailsubject]; $emailsubject = email_replace_arr($emailsubject,$emailvars); foreach($lowerescalationcontacts as $contactkey=>$contactid) { $emailto = contact_getfield($contactid, contactemail); //d("emailto", $emailto); if($emailto) html_mail($emailto,$em[emailfrom],$emailsubject,$emailtext); } } } function queueapproval_request($type, $id,$modifier,$param1, $param2, $requestto,$comment) { //$type could be clientoffer,xxxx,yyyyy (add more here as they are allowed) //$modifier (future use, this will be so that different kinds of approval can be requested and given on the same '$type:$id' //Removed the following lines so this function could be called and wouldn't die even if $requestto wasn't sent or wasn't an array. //if(!$requestto && !is_array($requestto)) // ddie("Invalid, this request is being made to NOONE!!"); $arr = queueapproval_get($type, $id,$modifier); d(arr,$arr); if($arr[id]) return $arr; $qaid =db_nextid('queueapproval'); $sql = "insert into tblqueueapproval ( queueapprovalid ,queueapprovalcreatedby ,{$type}id ,queueapprovalmodifier ,queueapprovalparam1 ,queueapprovalparam2 ,queueapprovalcreatorcomment )values( $qaid ,".loginid()." ,".db_number($id)." ,'".db_col($modifier)."' ,'".db_col($param1)."' ,'".db_col($param2)."' ,'".db_col($comment)."' )"; d(queueapprovalinsert,$sql); db_exec($sql,1); if($requestto && is_array($requestto)) { //Only add invites if we have a requestto foreach($requestto as $k_type=>$carr) { foreach($carr as $cid) { $sql = "insert into tblqueueapprovalinvite ( queueapprovalid , queueapprovalinvitecreatedby , {$k_type}id) values ( $qaid ,".loginid()." ,".db_number($cid)." )"; db_exec($sql,1); } } } $queueapproval = queueapproval_get($type,$id,$modifier); d(queueapproval,$queueapproval); queueapproval_sendnotice($queueapproval); $queueapproval = queueapproval_get($type,$id,$modifier); return $queueapproval ; } function queueapproval_status($type, $id,$modifier='') { //$type could be clientoffer,xxxx,yyyyy (add more here as they are allowed) //$modifier (future use, this will be so that different kinds of approval can be requested and given on the same '$type:$id' $allowedtypes=explode(',',QUEUEAPPROVAL_TYPELIST); if(!in_array($type,$allowedtypes)) { d(debug_backtrace()); return QUEUEAPPROVAL_INVALIDTYPE.$type; } $sql = " select * from tblqueueapproval where {$type}id = $id and queueapprovalmodifier = '".db_col($modifier)."' order by queueapprovalid desc limit 1"; $qry = db_first($sql); return queueapproval_statusfromarray($qry); } function queueapproval_statusfromarray($arr) { if(!$arr[queueapprovalid]) return QUEUEAPPROVAL_UNREQUESTED; if($arr[queueapprovalgivendate]) return QUEUEAPPROVAL_GIVEN; if($arr[queueapprovalrejecteddate]) return QUEUEAPPROVAL_REJECTED; return QUEUEAPPROVAL_PENDING; } function queueapproval_given($type,$id,$modifier='') { //this function will only return true if approval has been given //the function should be used to show / hide functionality in the system which should only be shown if it has been approved return (queueapproval_status($type, $id,$modifier) == QUEUEAPPROVAL_GIVEN); } function queueapproval_getdisplay($type,$id,$modifier,$param1='', $param2='',$options='') { if(!$options) $options=array(); //this function will echo out the step of a queue approval /* 1) if no queue approval has been requested, a button which allows it to be requested is display 2) if the approval has been requested details of the request will be displayed 3) if the approval has been accepted or rejected that will display 4) a link will display which will give full details of the request this function will ONLY return true, if the approval has been given, otherwise it returns false */ // define the methods / types that could be used to define who could approe the items and what option1 and option2 paramaeters are $modifiers[clientofferaccept] = array(1=>clientcompanyclientid,2=>escalationlevel) ; $modifiers[clientoffercounter] = array(1=>clientcompanyclientid,2=>escalationlevel) ; $modifiers[grouprequestaccept] = array(1=>clientcompanyclientid,2=>escalationlevel) ; if(!in_array($modifier,array_keys($modifiers))) ddie("Not a valid modifier type: $modifier"); $paramlist = $modifiers[$modifier]; foreach($paramlist as $paramnum=>$param) { $varname = "param$paramnum"; $params[$param] = $$varname; $params[param.$paramnum] = $$varname; } //d(params,$params); if(!$options) $options = array(); if(!$options[unrequestedstatus]) $options[unrequestedstatus] = QUEUEAPPROVAL_UNREQUESTED; if(!$options[button_pending]) $options[button_pending] = "Approval Pending: Details"; if(!$options[button_given]) $options[button_given] = "Approved: Details"; if(!$options[button_rejected]) $options[button_rejected] = "Rejected: Details"; if(!$options[button_unrequested]) $options[button_unrequested] = "Request Approval"; if($options[button_new]) $options[button_unrequested] = $options[button_new]; if(!$options[unrequestedstatus]) $options[unrequestedstatus] = QUEUEAPPROVAL_UNREQUESTED; /* posible options: unrequestedstatus - overrides the status */ $status = queueapproval_status($type,$id,$modifier); $statusout = $status; if($status == QUEUEAPPROVAL_UNREQUESTED) $statusout = $options[unrequestedstatus]; $buttontext = $options[button_unrequested]; if($status == QUEUEAPPROVAL_PENDING) $buttontext=$options[button_pending]; if($status == QUEUEAPPROVAL_REJECTED) $buttontext=$options[button_rejected]; if($status == QUEUEAPPROVAL_GIVEN) $buttontext=$options[button_given]; $r = 'queueapprovaldetail'.rand(time()/2,time()); // d($params); foreach($params as $param=>$val) { $val = str_replace('"',"",$val); // dont allow the input code to break out of the attributes $added.=" $param=\"$val\""; } $out.= " "; //echo "Approval: $statusout"; return $out; } function queueapproval_paramlabels($type,$modifier) { //d(type,$type); //d(modifier,$modifier); if($type==clientoffer) $arr[clientoffer][''][queueapprovalparam2]='Escalation Level'; elseif($type==propertyextensiongrouprequest) $arr[propertyextensiongrouprequest][''][queueapprovalparam2]='Escalation Level'; if(!$arr[$type][$modifier]) $modifier=''; $arr = $arr[$type][$modifier]; if($arr) return $arr; return array(); } function queueapproval_setaddeddata($type,$modifier, &$data) { $params= queueapproval_paramlabels($type,$modifier); //d(params,$params); foreach($params as $param=>$label) $data[addeddata][$label] = $data[$param]; if($type==clientoffer) { // d(data,$data); $data[name]="Approve Client Offer #$data[clientofferid]"; $offer = clientoffer_get('',$data[clientofferid]); //d(offer,$offer); $data[data][clientoffer]=$offer; $neg = clientnegotiation_get('',$offer[clientnegotiationid]); //d(neg,$neg); $neg=$neg[0]; $prop = get_clientcompanyproperty($neg[clientcompanypropertyid]); //d(prop,$prop); $data[data][clientoffer]=$offer; $data[data][clientnegotiation]=$neg; $data[data][clientcompanyproperty]=$prop; $data[address] = $prop[clientcompanypropertyaddress]; $data[descr] = "On $prop[clientcompanypropertyaddress] "; if($data[addeddata] && is_array($data[addeddata])){ foreach($data[addeddata] as $label => $value) $data[descr] .=" $label $value "; } } elseif($type==propertyextensiongrouprequest) { //d(data,$data); $grouprequest = get_grouprequest($data[propertyextensiongrouprequestid]); //d(grouprequest,$grouprequest); //$data[name]="Approve Group Request #$data[propertyextensiongrouprequestid]"; $data[name]="Approve ".$grouprequest[0][propertyextensiongroupname]." Change#".$data[propertyextensiongrouprequestid]; $data[data][propertyextensiongrouprequest]=$grouprequest; $prop = get_clientcompanyproperty($grouprequest[0][clientcompanypropertyid]); //d(prop,$prop); $data[data][clientcompanyproperty]=$prop; $data[address] = $prop[clientcompanypropertyaddress]; $data[descr] = "On $prop[clientcompanypropertyaddress] "; if($data[addeddata] && is_array($data[addeddata])){ foreach($data[addeddata] as $label => $value) { if($value==0) $data[descr] .=" $label Auto Approved "; else $data[descr] .=" $label $value "; } } } if($data[data][clientcompanyproperty][clientcompanypropertyid]) { $loannumber=clientcompanyproperty_get_propertyextension($data[data][clientcompanyproperty][clientcompanypropertyid], 'propertyextensionloannumber'); if($loannumber) $data[data][loannumber]=$loannumber; } $additionalinfo=array(); if($data[address]) $additionalinfo[]=" Address: $data[address]"; if($data[name]) $additionalinfo[]=" Request: $data[name]"; if($data[addeddata]) foreach($data[addeddata] as $k=>$v) $additionalinfo[]=" $k: $v"; if($additionalinfo) $data[additionalinfo] = $additionalinfo; //d(data,$data); } function queueapproval_displaydetail($queueapproval) { d("In Function: queueapproval_displaydetail",$queueapproval); $status = $queueapproval[status]; echo ""; echo ""; echo ""; if(!$queueapproval[i_was_invited]) { if(queueapproval_decided($queueapproval)) { if($queueapproval[queueapprovalvieweddate]) { if($queueapproval[queueapprovalcreatedby]==loginid()) echo ""; } else { if($queueapproval[queueapprovalcreatedby]==loginid()) echo ""; } } else echo ""; } else echo ""; echo " "; echo ""; if($queueapproval[queueapprovalcreateddate]) echo ""; if($queueapproval[data][loannumber]) echo ""; if($queueapproval[address]) echo ""; if($queueapproval[data][clientcompanyproperty][clientcompanypropertycity]) echo ""; if($queueapproval[data][clientcompanyproperty][clientcompanypropertystate]) echo ""; if($queueapproval[data][clientcompanyproperty][clientcompanypropertyzip]) echo ""; if($queueapproval[queueapprovalcreatedby]) echo ""; if($queueapproval[addeddata]) foreach($queueapproval[addeddata] as $label=>$value) if($value) echo ""; if($queueapproval[queueapprovalcreatorcomment]) echo ""; if($queueapproval[queueapprovalgivendate]) { echo ""; echo ""; } if($queueapproval[queueapprovalrejecteddate]) { echo ""; echo ""; } if($queueapproval[queueapprovalreplycomment]) echo ""; echo "
Request $queueapproval[name]Mark(X) as NewMark(X) as Read  
Approval Request Status $status
Approval Request Created ".dttime_format($queueapproval[queueapprovalcreateddate])."
Loan # ".$queueapproval[data][loannumber]."
Address $queueapproval[address]
City ".$queueapproval[data][clientcompanyproperty][clientcompanypropertycity]."
State ".$queueapproval[data][clientcompanyproperty][clientcompanypropertystate]."
Zip ".$queueapproval[data][clientcompanyproperty][clientcompanypropertyzip]."
Approval Request Created By ".get_login_info($queueapproval[queueapprovalcreatedby])."
$label $value
Requestor Comment $queueapproval[queueapprovalcreatorcomment]
Approval Given ".dttime_format($queueapproval[queueapprovalgivendate])."
Approval Given By ".get_login_info($queueapproval[queueapprovalgivenby])."
Approval Rejected ".dttime_format($queueapproval[queueapprovalrejecteddate])."
Approval Rejected By ".get_login_info($queueapproval[queueapprovalrejectedby])."
Reply Comment $queueapproval[queueapprovalreplycomment]
"; $propertyid = $queueapproval[data][clientcompanyproperty][clientcompanypropertyid]; $ccid = $queueapproval[data][clientcompanyproperty][clientcompanyid]; d(propertyextensiongrouprequest,$queueapproval[data][propertyextensiongrouprequest]); if($queueapproval[data][propertyextensiongrouprequest]) { d("queueapproval[data][propertyextensiongrouprequest]",$queueapproval[data][propertyextensiongrouprequest]); d("status",$status); $hascompare=FALSE; foreach($queueapproval[data][propertyextensiongrouprequest] as $grouprequestkey=>$grouprequestvalue) { if($grouprequestvalue[propertyextensiongrouprequestcompareid]) $hascompare=TRUE; } if(is_array($queueapproval[data][propertyextensiongrouprequest])) { echo ""; echo ""; if($status==QUEUEAPPROVAL_PENDING) echo""; elseif($status ==QUEUEAPPROVAL_GIVEN) echo""; if($hascompare) { echo " "; } echo ""; foreach($queueapproval[data][propertyextensiongrouprequest] as $grouprequestkey=>$grouprequestvalue) { $compareotherattribute=FALSE; if($grouprequestvalue[propertyextensiongrouprequestcompareid]) { $comparelabel=getgroupcomparelabel($grouprequestvalue[propertyextensiongrouprequestcompareid]); $compareotherattribute=TRUE; } echo ""; if($status==QUEUEAPPROVAL_PENDING) { echo ""; } elseif($status ==QUEUEAPPROVAL_GIVEN) if($grouprequestvalue[propertyextensiongrouprequestentrychangevalue]) echo""; else echo""; if($comparelabel == $grouprequestvalue[propertyextensionlabel] && trim($grouprequestvalue[propertyextensiongrouprequestentryoldvalue]) == trim($grouprequestvalue[propertyextensiongrouprequestcomparevalue])) { $comparelabel = ""; $grouprequestvalue[propertyextensiongrouprequestcomparevalue] = ""; } if($hascompare && $compareotherattribute) { echo " "; } else { if($hascompare) { echo " "; } } echo " "; } echo "

Attribute

Before Request

Request

Change

Saved

Compare

Compare Attribute

"; echo $grouprequestvalue[propertyextensionlabel]." ".$grouprequestvalue[propertyextensiongrouprequestentryoldvalue]." ".$grouprequestvalue[propertyextensiongrouprequestentryvalue].""; echo customfield('textbox','overridechange['.$grouprequestvalue[propertyextensiongrouprequestentryid].']',$grouprequestvalue[propertyextensiongrouprequestentryvalue]); echo "".$grouprequestvalue[propertyextensiongrouprequestentrychangevalue]."".$grouprequestvalue[propertyextensiongrouprequestentryvalue]."".$grouprequestvalue[propertyextensiongrouprequestcomparevalue]." ".$comparelabel."   
"; } $displayexten=get_propertyextensions_byconfigtypematch(displayonattributeescalation,y,$ccid); } if($queueapproval[data][clientoffer]) $displayexten=get_propertyextensions_byconfigtypematch(displayonofferescalation,y,$ccid); if($displayexten) { echo " "; foreach($displayexten as $k=>$extension) { $value = get_clientpropertyextensionentry($propertyid , $k); echo ""; } echo "
Current Property Information(".dttime_format(time()).")
$extension[propertyextensionlabel] $value
"; } } function queueapproval_notifyrequestor($queueapproval, $decision, $note) { $emailto=get_loginemailaddress($queueapproval[queueapprovalcreatedby]); if($emailto && $emailto!="") { $em = get_email(approvalrequestresponse); $emailsubject=$em[emailsubject]; if($queueapproval[additionalinfo]) $emailarr[additionalinfo].= implode("
",$queueapproval[additionalinfo]); if($emailarr[additionalinfo] !="") $emailarr[additionalinfo] .="
"; $emailarr[invitedcontacts]=""; if($queueapproval[invites]) { foreach($queueapproval[invites] as $invite) { if($invite[name]) $emailarr[invitedcontacts].=$invite[name]."
"; } } //d(invitedcontacts,$emailarr[invitedcontacts]); $emailarr[additionalinfo] .= "Comment: $note"; $emailarr[requestername]= get_login_info($queueapproval[queueapprovalcreatedby]); //d(requestername,$emailarr[requestername]); $emailarr[level]=$queueapproval[queueapprovalparam2]; //d(level,$emailarr[level]); $sql="Select queueapprovalgivendate , queueapprovalgivenby , queueapprovalrejecteddate , queueapprovalrejectedby from tblqueueapproval where queueapprovalid=".db_number($queueapproval[queueapprovalid]); $qry=db_first($sql); $emailarr[decisionmaker]=""; if($qry[queueapprovalgivendate]) $emailarr[decisionmaker]=get_login_info($qry[queueapprovalgivenby]); elseif($qry[queueapprovalrejecteddate]) $emailarr[decisionmaker]=get_login_info($qry[queueapprovalrejectedby]); //d(decisionmaker,$emailarr[decisionmaker]); $emailarr[loannumber]=""; if($queueapproval[data][clientcompanyproperty][clientcompanypropertyid]) $emailarr[loannumber]=get_clientpropertyextensionentry($queueapproval[data][clientcompanyproperty][clientcompanypropertyid],propertyextensionloannumber); //d(loannumber,$emailarr[loannumber]); $emailarr[status]=$decision; $emailarr[lowerlevelcontacts]=""; //d('Function queueapproval_notifyrequestor queueapproval: ',$queueapproval); if($queueapproval[data][clientcompanyproperty][clientcompanyclientid] && $queueapproval[queueapprovalparam2]) { //d('clientcompanyclientid: ', $queueapproval[data][clientcompanyproperty][clientcompanyclientid]); $lowerescalationcontacts=get_lowerescalationcontacts($queueapproval[data][clientcompanyproperty][clientcompanyclientid], $queueapproval[queueapprovalparam2]); //d("lowerescalationcontacts", $lowerescalationcontacts); if($lowerescalationcontacts && is_array($lowerescalationcontacts)) { //d('lowerescalationcontacts: ', $lowerescalationcontacts); $emailarr[lowerlevelcontacts]=''; foreach($lowerescalationcontacts as $contactkey=>$contactid) { $lowerlevelemail = contact_getfield($contactid, contactemail); //d("lowerlevelemail", $lowerlevelemail); if($lowerlevelemail) { $additionalccaddresses.=",$lowerlevelemail"; $emailarr[lowerlevelcontacts].=contact_getfield($contactid, contactcname)."
"; //d(contactname, contact_getfield($contactid, contactcname)); //d(contactnameid, $contactid); } } if($em[emailccaddress]) $em[emailccaddress]=$em[emailccaddress].$additionalccaddresses; else $em[emailccaddress]=trim($additionalccaddresses,','); } } //d(emailccaddress,$em[emailccaddress]); //d(lowerlevelcontacts,$emailarr[lowerlevelcontacts]); $proto="https"; if($_SERVER[SERVER_PORT]==80) $proto="http"; $emailarr["link"] = "$proto://$_SERVER[HTTP_HOST]/queueapproval.php?redirect_queueapprovalid=".$queueapproval[queueapprovalid]; $emailtext = email_replace_arr($em[emailtext],$emailarr); if($em[emailccaddress]) html_mail_cc($emailto,$em[emailccaddress],$em[emailfrom],$emailsubject,$emailtext); else html_mail($emailto,$em[emailfrom],$emailsubject,$emailtext); } } function queueapproval_approve($queueapproval, $note, $changeapprove='') { $sql = "update tblqueueapproval set queueapprovalgivendate = coalesce(queueapprovalgivendate, now()) ,queueapprovalgivenby = coalesce(queueapprovalgivenby, ".loginid().") ,queueapprovalreplycomment =coalesce(queueapprovalreplycomment||'\n','')||".db_tick($note); $sql.=" where queueapprovalid = ".db_number($queueapproval[queueapprovalid]); db_exec($sql,1); if($queueapproval[propertyextensiongrouprequestid]) queueapproval_approvegrouprequest($queueapproval[propertyextensiongrouprequestid], 0, $changeapprove); $approvalmsg="Approved"; if($changeapprove=='change') $approvalmsg.=" with Changes"; queueapproval_notifyrequestor($queueapproval, $approvalmsg, $note); } function queueapproval_deny($queueapproval, $note, $fields='') { if($fields && is_array($fields)) $fields = serialize($fields); $sql = "update tblqueueapproval set queueapprovalrejecteddate = coalesce(queueapprovalrejecteddate, now()) ,queueapprovalrejectedby = coalesce(queueapprovalrejectedby, ".loginid().") ,queueapprovalreplycomment =coalesce(queueapprovalreplycomment||'\n','')||".db_tick($note); if ($fields) $sql .=" ,queueapprovalreplycommentfields = ".db_tick($fields); $sql .= " where queueapprovalid = ".db_number($queueapproval[queueapprovalid]); db_exec($sql,1); queueapproval_notifyrequestor($queueapproval, "Denied", $note); } function queueapproval_decided($arr) { if(queueapproval_statusfromarray($arr)==QUEUEAPPROVAL_GIVEN || queueapproval_statusfromarray($arr)==QUEUEAPPROVAL_REJECTED) return TRUE; return FALSE; } function queueapproval_approvegrouprequest($requestid, $autoapprove=0, $changeapprove='') { d("Function queueapproval_approvegrouprequest requestid:",$requestid); if(!$requestid || !is_numeric($requestid)) ddie("Invalid Group Request ID "); $request=get_grouprequest($requestid); d(request,$request); d(changeapprove,$changeapprove); if(!$request) { ddie("Invalid Group Request"); } else { foreach($request as $requestkey=>$requestvalue) { if($changeapprove[$requestvalue[propertyextensiongrouprequestentryid]]) { $sql="update tblpropertyextensiongrouprequestentry set propertyextensiongrouprequestentrychangevalue=".db_tick($changeapprove[$requestvalue[propertyextensiongrouprequestentryid]])." where propertyextensiongrouprequestentryid=".db_number($requestvalue[propertyextensiongrouprequestentryid]); d($sql); db_exec($sql); if(!$requestvalue[propertyextensiongrouprequestentrychangevalue]) $requestvalue[propertyextensiongrouprequestentrychangevalue] = $changeapprove[$requestvalue[propertyextensiongrouprequestentryid]]; clientcompanyproperty_set_propertyextension($requestvalue[clientcompanypropertyid],$requestvalue[propertyextensionkey],$requestvalue[propertyextensiongrouprequestentrychangevalue]); } elseif($requestvalue[propertyextensiongrouprequestentryvalue]) clientcompanyproperty_set_propertyextension($requestvalue[clientcompanypropertyid],$requestvalue[propertyextensionkey],$requestvalue[propertyextensiongrouprequestentryvalue]); } if($autoapprove) { $sql = "select queueapprovalid from tblqueueapproval where propertyextensiongrouprequestid= ".db_number($requestid); $queueapprovalid=db_first($sql); if($queueapprovalid[queueapprovalid]) { $sql = "update tblqueueapproval set queueapprovalgivendate = coalesce(queueapprovalgivendate, now()) ,queueapprovalgivenby = coalesce(queueapprovalgivenby, ".loginid().") ,queueapprovalreplycomment = 'Auto Approved' where queueapprovalid = ".db_number($queueapprovalid[queueapprovalid]); db_exec($sql,1); } } } }