$fld) { if($fld[deprecated]) { d(unseting,$fld); unset($offer_map[$k]); } } foreach($offer_map as $key => $val) { if($val[deprecated]) continue; if ($key == clientoffersellertitle || $key == clientofferbuyertitle || $key == clientofferfinancingtype || $key == clientoffertitlechoice || $key == clientoffertitle || $key == clientofferrushofferresponse) if(strlen($_POST[$key]) >= 200) $errorkeys[]=$key; if($val['customfieldtypeid'] == 38) { $_POST[$key] = db_number($_POST[$key]); if (!is_numeric($_POST[$key]) || $_POST[$key] < 0) $errorkeys[]=$key; } if($val['netpurchase'] == 'addable' && (!is_numeric($_POST[$key] ) || $_POST[$key] <0)) { $errorkeys[]=$key; } elseif($val['netpurchase'] == 'subtractable' && (!is_numeric($_POST[$key] ) || $_POST[$key] <0)) { $errorkeys[]=$key; } elseif($val['required'] && isset($val['required_unless'])){ if(!$val['required_unless'] && $_POST[$key] === ''){ $errorkeys[]=$key; } } else if($val['required'] && $val['required_for']){ if($val['required_for']() && $_POST[$key] === ''){ $errorkeys[]=$key; } } else if($val['required']){ if($_POST[$key] === ''){ $errorkeys[]=$key; } } } $clientcompanyclientid = db_firstval("select clientcompanyclientid from tblclientcompanyproperty where clientcompanypropertyid = ".db_number($_POST[clientcompanypropertyid])); // only check that the netpurchase requires escalation if clientcompany if (clientcompanyid() && $clientcompanyclientid ) { $level = clientoffer_getescalation($clientcompanyclientid, $_POST, $offer_map); if($level) { $amt = clientoffer_calcsum('netpurchase', $_POST, $offer_map); $errorkeys['netpurchase']['error_message'] = "Net Purchase Amount($amt) requires escalation level '$level' and is not allowed. Please adjust one or more of the values in your counter offer."; d(errorkeys, $errorkeys); } } return $errorkeys; } function clientoffer_insert($clientnegotiationid,$_POST,$offer_map,$skipvalidation=0) { // CHECK THAT ALL REQUIRED FIELDS ARE FILLED OUT if(!$skipvalidation) //only do this validation if we have not skipped it. foreach($offer_map as $key => $val){ if($val[deprecated]) continue; if($val['required'] && isset($val['required_unless'])){ if(!$val['required_unless'] && $_POST[$key] === ''){ d($key, $val); echo $key; return false; } } else if($val['required'] && $val['required_for']){ if($val['required_for']() && $_POST[$key] === ''){ d($key, $val); echo $key; return false; } } else if($val['required']){ if($_POST[$key] === ''){ d($key, $val); echo $key; return false; } } } $db_clientnegotiationid = db_number($clientnegotiationid); // UPDATE NEGOTIATION WITH OFFER EXPIRATION $sql = "update tblclientnegotiation set clientnegotiationexpirationdate = " . (clientcompanyid() ? db_datetime($_POST['clientofferexpirationdate']) : "null") . " where clientnegotiationid = " . $db_clientnegotiationid; db_exec($sql); if(companyid()) $offer_map['clientofferexpirationdate'] = null; // ONLY THE CLIENT SIDE CAN MODIFY OFFER EXPIRATION $clientofferid = db_first("select nextval('tblclientoffer_clientofferid_seq') as id"); $clientofferid = $clientofferid['id']; $sql = "insert into tblclientoffer (clientofferid, clientoffercreatedby, clientnegotiationid, clientoffernetpurchaseamount\n"; foreach($offer_map as $key => $field) { if ($field['calc_type'] != 'percent') $sql .= "," . $key . "\n"; } $sql .= ")"; $sql .= " values (" . $clientofferid . ", " . loginid() . ", " . $db_clientnegotiationid . ", " . clientoffer_calcsum('netpurchase', $_POST, $offer_map); foreach($offer_map as $key => $field) { //loop through all of the documents uploaded and save them //d($field); if($field['type'] == 'documentupload' && $_FILES[$key]) { $retval = process_customfield_documentupload_type($clientofferid, clientoffer, $key, 'clientoffer', 0); if($retval) //only set this if needed $_POST[$key]=$retval; } } foreach($offer_map as $key => $field) { $_POST[$key]=trim($_POST[$key]); if($key == 'clientofferexpirationdate') $sql .= "," . ($_POST[$key] != '' ? db_datetime($_POST[$key]) : "null")." "; elseif($key == 'clientofferinspectiontime' || $key == 'clientofferentrareferralpct' || $key == 'clientofferentrareferralamount') $sql .= "," . (strlen($_POST[$key]) != '' ? db_number(floor($_POST[$key])) : "null")." "; elseif($field['type'] == 'number' || $field['customfieldtypeid'] == 38) { if ($field['highestandbestreplacement'] && $field['highestandbestreplacement'] == $_POST[$key]) $sql .= ", '".$_POST[$key]."' "; else $sql .= "," . (strlen($_POST[$key]) != '' ? db_number($_POST[$key]) : "null")." "; } else if (strpos($key, 'date') !== false) $sql .= ", " . db_date($_POST[$key]) . " "; // this will convert any input into date/time for date fields. VL MTX 19924 elseif(strlen($_POST[$key])) $sql.= ", '".db_col($_POST[$key])."' "; else $sql.= ", ".db_tick($_POST[$key])." "; $sql.=" -- $key\n"; // $sql .= "," . ($_POST[$key] != '' ? db_tick($_POST[$key]) : "null"); } $sql .= ")"; //d("squeel","
$sql
"); $ret = db_exec($sql,1); //if we have a valid update, update the negotiation updated //date to the lastest created date in the offers section if ($ret === true) clientnegotiation_updateddate($db_clientnegotiationid); if(companyid()) { //if the current user is a companyid() that means they are //and if the negotiations was NOT just entered, that means they are submitting a folloup offer /counter global $clientnegotiation_inserted; if(!$clientnegotiation_inserted)//if the negotiation was just entered, dont run this trigger, this is only for counters (which are offers AFTER the first offer) { $neg = db_first("select clientcompanypropertyassignmentid from tblclientnegotiation where clientnegotiationid = ".db_number($clientnegotiationid)); //trigger the events for offers submitted $event = get_workflowevent("propertyoffercountered"); //Modified offer workflowevents so that they can pull offer info via clientofferid. 2-2-2013 MDM workflowevent($event[workfloweventshortname],clientoffer,$clientofferid); //trigger the event //workflowevent($event[workfloweventshortname],clientcompanypropertyassignment,$neg['clientcompanypropertyassignmentid']); //trigger the event } } elseif(clientcompanyid()) { //if the current user is a clientcompanyid() that means they are //and if the negotiations was NOT just entered, that means thee asset ma nagment company submitting a folloup offer /counter global $clientnegotiation_inserted; if(!$clientnegotiation_inserted)//if the negotiation was just entered, dont run this trigger, this is only for counters (which are offers AFTER the first offer) { $neg = db_first("select clientcompanypropertyassignmentid from tblclientnegotiation where clientnegotiationid = ".db_number($clientnegotiationid)); //trigger the events for offers submitted //d(_POST,$_POST); if($_POST[highestandbest]) $event = get_workflowevent("propertyofferhighestcountermade"); else $event = get_workflowevent("propertyoffercountermade"); //d(event,$event); //ddie($event); //workflowevent($event[workfloweventshortname],clientcompanypropertyassignment,$neg['clientcompanypropertyassignmentid']); //trigger the event //Modified offer workflowevents so that they can pull offer info via clientofferid. 2-2-2013 MDM workflowevent($event[workfloweventshortname],clientoffer,$clientofferid); //trigger the event } } if($ret) return $clientofferid; else return false; } function clientoffer_get($clientnegotiationid = '', $clientofferid = '') { //ddie(); $sql = "select tblclientoffer.* , (select 1 from tbllogin where loginid = tblclientoffer.clientoffercreatedby and companyid = ".companyid()." and clientcompanyid = ".clientcompanyid().") as mycompanyoffer from tblclientoffer join tblclientnegotiation using(clientnegotiationid) where 0 = 0"; if(clientcompanyid()) $sql .= " and clientcompanyid = " . clientcompanyid(); if(companyid()) $sql .= " and companyid = " . companyid(); if($clientnegotiationid) $sql .= " and clientnegotiationid = " . db_number($clientnegotiationid); if($clientofferid) $sql .= " and clientofferid = " . db_number($clientofferid); $sql .= " order by clientofferid"; //d($sql); if($clientofferid) $offers = db_first($sql); else $offers = db_query($sql); if($offers) return $offers; else return false; } function clientoffer_reject($negotiationid,$offerid) { $continue = true; if(!clientnegotiation_reject($negotiationid)) $continue = false; if($continue){ $sql = "update tblclientoffer set clientofferrejecteddate = now(), clientofferrejectedby = " . loginid() . " where clientofferid = " . db_number($offerid); if(db_exec($sql)) { clientnegotiation_updateddate($negotiationid); return true; } else return false; } else return false; } function clientoffer_retract($offerid) { //echo ""; $offer = clientoffer_get('',$offerid); if(!$offer[mycompanyoffer]) return false; $neg = db_first("select * from tblclientnegotiation where clientnegotiationid = $offer[clientnegotiationid]"); $event = get_workflowevent("propertyofferretracted"); d(event, $event); //workflowevent($event[workfloweventshortname],clientcompanypropertyassignment,$neg['clientcompanypropertyassignmentid']); //trigger the event //Modified offer workflowevents so that they can pull offer info via clientofferid. 2-2-2013 MDM workflowevent($event[workfloweventshortname],clientoffer,$offerid); //trigger the event $sql = "update tblclientoffer set clientofferretracteddate = now(), clientofferretractedby = " . loginid() . " where clientofferid = " . db_number($offerid); if(db_exec($sql)) { clientnegotiation_updateddate($offer[clientnegotiationid]); return true; } else return false; } function clientoffer_expire($offerid) { $offer = clientoffer_get('',$offerid); if(!$offer[mycompanyoffer]) return false; $sql = "update tblclientoffer set clientofferexpireddate = now(), clientofferexpiredby = " . loginid() . " where clientofferid = " . db_number($offerid); $neg = db_first("select * from tblclientnegotiation where clientnegotiationid = $offer[clientnegotiationid]"); $event = get_workflowevent("propertyofferretracted"); //workflowevent($event[workfloweventshortname],clientcompanypropertyassignment,$neg['clientcompanypropertyassignmentid']); //trigger the event //Modified offer workflowevents so that they can pull offer info via clientofferid. 2-2-2013 MDM workflowevent($event[workfloweventshortname],clientoffer,$offerid); //trigger the event if(db_exec($sql)) { //clientnegotiation_updateddate($negotiationid); return true; } else return false; } function clientoffer_calcpercent($shortname, $netpurchase, $clientcompanypropertyid) { $percent = false; if ($netpurchase) { $value = clientoffer_calcfactor($clientcompanypropertyid, $shortname); if ($value > 0) $percent = round(($netpurchase/$value*100), 2, PHP_ROUND_HALF_UP); } return $percent; } function clientoffer_calcfactor($clientcompanypropertyid, $shortname) { if ($clientcompanypropertyid) return db_number(get_clientpropertyextensionentry($clientcompanypropertyid,$shortname)); else return false; } function clientoffer_calcsum($shortname, $offer, $offer_map = '') { $sum = 0; if (is_array($offer_map)) { foreach ($offer_map as $key => $field) { if ($field[$shortname] == 'addable' || $field[$shortname] == 'subtractable') { $val = $offer[$key]; if ($field[$shortname] == 'addable') { if (!is_numeric($val) || $val < 0) return 0; } else $val = (is_numeric($val))?-$val:0; $sum += $val; } } } return $sum; } function clientoffer_process($offer_map, $offer = '', $clientcompanyid = 0, $prev = '', $includecounteroffer = 0, $columnname = "") { $is_portalview = ($_SERVER[SCRIPT_NAME] == '/clientproperty.php'); if($clientcompanyid && $offer) { foreach($offer as $k => $v){ if(!strstr($k, 'client')){ $offer['client'.$k] = $v; } } } global $offer_count; global $preferred_lender; // HARD CODED PREFERRED LENDERS added the code below because public offers didn't have a $_GET['view'] and might not have an offer yet and so the property wasn't getting pulled correctly. if($clientcompanyid) { if($_GET['makeoffer']) { $sql = "select clientcompanypropertyid from tblproperty where propertyid=".db_number($_GET['makeoffer']); $qry = db_query($sql); //d(__LINE__,$sql); if($qry && $qry[0][clientcompanypropertyid]) $clientcompanypropertyid = $qry[0][clientcompanypropertyid]; else $clientcompanypropertyid = clientnegotiation_attr($offer['clientnegotiationid'],'clientcompanypropertyid'); } else $clientcompanypropertyid = ($_GET['view'] ? $_GET['view'] : clientnegotiation_attr($offer['clientnegotiationid'],'clientcompanypropertyid')); } else $clientcompanypropertyid = ($_GET['view'] ? $_GET['view'] : clientnegotiation_attr($offer['clientnegotiationid'],'clientcompanypropertyid')); //d("clientcompanypropertyid: ",$clientcompanypropertyid); if($clientcompanyid == 5){ $prop = get_clientcompanyproperty($clientcompanypropertyid); $shore_states = array('AL','CA','FL','MD','MI','NC','OR','PA'); //d("prop: ",$prop); $propstate=$prop[clientcompanypropertystate]; if(strlen($propstate) >2) { $sql = "select code from tblstate where name='".trim($propstate)."'"; $qrystate = db_query($sql); if($qrystate && $qrystate[0][code]) $propstate=$qrystate[0][code]; } if(in_array($propstate,$shore_states)) { $preferred_lender['name'] = 'Shore Mortgage'; $preferred_lender['address'] = '770 S. Adams Rd.'; $preferred_lender['city'] = 'Birmingham'; $preferred_lender['state'] = 'MI'; $preferred_lender['zip'] = '48009'; $preferred_lender['url'] = 'www.shoremortgage.com/home123'; $preferred_lender['phone'] = '866-258-7764 /801-736-7736'; } else { $preferred_lender['name'] = 'Primary Residence Mortgage, Inc.'; $preferred_lender['address'] = '4750 W. Wiley Post Way, Suite 200'; $preferred_lender['city'] = 'Salt Lake City'; $preferred_lender['state'] = 'Utah'; $preferred_lender['zip'] = '84116'; $preferred_lender['url'] = 'www.pmimortgage.com'; } } else if($clientcompanyid == 7){ $preferred_lender['name'] = 'Idaho Independent Bank'; $preferred_lender['address'] = '560 E State St.'; $preferred_lender['city'] = 'Eagle'; $preferred_lender['state'] = 'Idaho'; $preferred_lender['zip'] = '83616'; } if($offer) { if ($columnname) echo " $columnname"; foreach($offer_map as $key => $field) { //d(__line__.$key,$field); if($offer[$key] && function_exists("customfield_display_$field[type]")) { $fn = "customfield_display_$field[type]"; $offer[$key] = $fn($offer[$key], array(pretty=>1)); } elseif($field[display_format_function]) { $fn = $field[display_format_function]; $offer[$key] = $fn($offer[$key], array(pretty=>1)); } } //loop through and if any of the fields are 'deprecated' and do not have a value, remove them from the offer_map, that is our way of deleting things, but showing historically saved information if ((companyid() || clientcompanyid()) && $is_portalview) { if ($_POST['clientnegotiation_counter']) { $createdby = get_login_info(loginid()); $createddate = dttime_format(date("Y-m-d H:i:s")); } else { if ($offer[clientoffercreatedby]) $createdby = get_login_info($offer[clientoffercreatedby]); if ($offer[clientoffercreateddate]) $createddate = dttime_format($offer[clientoffercreateddate]); } ?> >Created By
>Created Date
$field) { if($field[deprecated] && !$offer[$key] && !strlen($offer[$key]) && !$field['calc_type']) {//remove only ones that do not have ANY entry in it and is not calculated, even if it is only a 0, for new offers, the field would always be removed unset($offer_map[$key]); } } foreach($offer_map as $key => $field) { //d($key, $field); if($field['clientcompanyids']) $tmp_clientids = explode(',',$field['clientcompanyids']); if(!$tmp_clientids) $tmp_clientids = array(); //$clientcompanypropertyid = ($_GET['view'] ? $_GET['view'] : clientnegotiation_attr($offer['clientnegotiationid'],'clientcompanypropertyid')); $restricted = $field['input_visible_for']; $restriction_met = ($field['input_visible_for'] ? $field['input_visible_for']() : ''); // IF WE HAVE A MAP KEY THAT IS INTENDED FOR THE PUBLIC AND WE'RE NOT LOGGED IN if($field['input_visible_for'] == 'companyid' && $field['clientcompany-publicoffer'] && !companyid() && !clientcompanyid()) $restriction_met = true; $clientcompany_specific = isset($field['clientcompanyids']); $clientcompany_specific_met = in_array(clientproperty_attr($clientcompanypropertyid,'clientcompanyid'),$tmp_clientids) || in_array($clientcompanyid, $tmp_clientids); $addclass = $field['addclass']; //d(!$restricted || $restriction_met); //d(!$clientcompany_specific || $clientcompany_specific_met); //d($key); if((!$restricted || $restriction_met) && (!$clientcompany_specific || $clientcompany_specific_met)) { global $customfield_viewonly; $additional_class=""; if((!dttime_format($offer[$key]) && $offer[$key] != $prev[$key]) || (dttime_format($offer[$key]) && dttime_format($offer[$key]) != dttime_format($prev[$key]))) //MB - I added dttime format checking so that if the dates are the same but just in different formats the highlighting does not show { if($offer_count > 1) $additional_class='highlight'; } if($field['type']==documentupload && !$offer[$key]) //clear out the highlight if documents are not uploaded the second time $additional_class=""; if($addclass) $additional_class.=$addclass; if($field['required'] == addoffer && $offer_count >1) $field['required'] = ""; /* ///MB - i commented this out, we WANT to require this information if($field['required'] == addoffer && $_POST[clientnegotiation_counter]) $field['required'] = ""; */ //d(__line__,$key); $isPreferredLenderKey = ($key == 'clientofferpreferredlender' ? true : false); /* if (1 == 2 && $isPreferredLenderKey) { d(isPreferredLenderKey,$isPreferredLenderKey); d(preferred_lender,$preferred_lender); d(offer,$offer); d(field_type,$field['type']); } */ if($isPreferredLenderKey && $preferred_lender || !$isPreferredLenderKey && (!$offer || $field['type'] != 'documentupload')) { ?> > class='' datatype=''> ",$offer[$key]); //display this formatted so that \n have a
so it dislays in a browser if($field['display'] == 'contact') { $contact = contact_get($offer[$key]); echo "
" . $contact['contactcname'] . "
"; } else { echo "
" ; if(!$offer[$key] && $field['default']) echo $field['default']; else { if ($field['customfieldtypeid'] == 39 || $field['customfieldtypeid'] == 76||$field['customfieldtypename']=='timedatepicker') echo dttime_format($offer[$key]); else if ($field['highestandbestreplacement'] && $field['highestandbestreplacement'] == $offer[$key]) echo $offer[$key]; else { if($key == 'clientoffercreditinlieuofrepairs' || $field[customfieldtypeid] == 38 || strpos($key,'amount')) echo "$".dollar_format(db_number($offer[$key])); else echo $offer[$key]; } } echo "
"; } } else if($offer_map[$key]['readonly_for'] && $offer_map[$key]['readonly_for']()) { ?>
' name='' id='' />
' . $preferred_lender['address'] . '
' . $preferred_lender['city'] . ', '. $preferred_lender['state'] . ' ' . $preferred_lender['zip']. '' . '
'.$preferred_lender[phone].''. '
'.$preferred_lender['url'].'' ; $prefclass="hidden"; if ($offer[$key] && $offer[$key] != 'No') $prefclass = ''; ?> value='No' />No value='' />Yes
All offers being submitted on this said property must have a residential prequalification.
Please contact:
' . $preferred_lender['city'] . ', '. $preferred_lender['state'] . ' ' . $preferred_lender['zip'].' '. '
'.$preferred_lender[phone].'
'. '
'.$preferred_lender['url'].''; ?>
> datatype=''> "; if ($offer && !$_POST['clientnegotiation_counter']) echo $offer[$key]; echo ""; ?> $field) if(clientcompanyid() && $is_portalview && $offer) { $netpurchaseamount = $offer[clientoffernetpurchaseamount]; $netlpamount = clientoffer_calcpercent('propertyextensionlistprice', $netpurchaseamount, $clientcompanypropertyid); if (!$netlpamount) $title = "title='Missing required values for this calculation.'"; ?> style='color:navy'>Net Purchase Amount
style='color:navy'>Net/Listed Price Percent
>
style='color:navy'> Net/ Percent
>
$data){ if(!$data['clientcompany-publicoffer'][$clientcompanyid]) unset($offer_map[$key]); //$offer_map[str_replace('client','',$key)] = $data; } return $offer_map; } function clientoffer_gettechfeeamount($clientcompanyid = 0, $companyid = 0) { $clientoffertechfeeamountvalue='199'; //Default value hard coded here because all old offers had this hard coded. //d('I_ct '.__line__.' clientcompanyid',$clientcompanyid); if($_GET[view]) { //If currently looking at a property pull the value based on the clientcompanyid associated with the property. $sql = "select clientcompanyid from tblclientcompanyproperty where clientcompanypropertyid= '".$_GET[view]."'";; $checkreturn=db_query($sql); if($checkreturn) { $clientcompanyid=$checkreturn[0][clientcompanyid]; $sql = "select case when coalesce(configextensionentryvalue,'') = '' then configextensiondefault else configextensionentryvalue end as value from tblconfigextension left join (select * from tblconfigextensionentry where clientcompanyid = '".$clientcompanyid."') a using (configextensionid) where configextensionkey='clientoffertechfeeamount' "; $checkreturn=db_query($sql); if($checkreturn) { $clientoffertechfeeamountvalue=$checkreturn[0][value]; //d('I_ct '.__line__.' clientoffertechfeeamountvalue',$clientoffertechfeeamountvalue); } } } else { //If not currently looking at a property pull the value based on the clientcompanyid and companyid passed into the function. if($clientcompanyid || $companyid) { $sql = "select * from tblconfigextensionentry where 0=0"; if($clientcompanyid) $sql .= " and clientcompanyid = '".$clientcompanyid."'"; if($companyid) $sql .= " and companyid = '".$companyid."'"; $sql = "select case when coalesce(configextensionentryvalue,'') = '' then configextensiondefault else configextensionentryvalue end as value from tblconfigextension left join ($sql) a using (configextensionid) where configextensionkey='clientoffertechfeeamount' "; $checkreturn=db_query($sql); if($checkreturn) { $clientoffertechfeeamountvalue=$checkreturn[0][value]; //d('I_ct '.__line__.' clientoffertechfeeamountvalue',$clientoffertechfeeamountvalue); } } } return $clientoffertechfeeamountvalue; } function clientoffer_getmap($clientcompanyid = 0) { $clientoffertechfeeamountvalue=clientoffer_gettechfeeamount($clientcompanyid); $offer_map['clientofferlistedoncontractdate']['label'] = "Date Listed on State Contact"; $offer_map['clientofferlistedoncontractdate']['customfieldtypeid'] = 39; $offer_map['clientofferlistedoncontractdate']['required'] = true; $offer_map['clientofferpurchaseamount']['label'] = "Purchase Amount"; $offer_map['clientofferpurchaseamount']['netpurchase'] = "addable"; $offer_map['clientofferpurchaseamount']['customfieldtypeid'] = 38; $offer_map['clientofferpurchaseamount']['default'] = 0; $offer_map['clientofferpurchaseamount']['required'] = true; $offer_map['clientofferpurchaseamount']['highestandbestreplacement'] = "H & B"; $offer_map['clientofferearnestmoneyamount']['label'] = "Earnest Money Amount"; $offer_map['clientofferearnestmoneyamount']['customfieldtypeid'] = 38; $offer_map['clientofferearnestmoneyamount']['default'] = 0; $offer_map['clientofferearnestmoneyamount']['required'] = true; $offer_map['clientofferearnestmoneyamount']['highestandbestreplacement'] = "H & B"; $offer_map['clientofferdownpaymentpercent']['label'] = "Down Payment Percent"; $offer_map['clientofferdownpaymentpercent']['type'] = "number"; $offer_map['clientofferdownpaymentpercent']['default'] = 0; $offer_map['clientofferdownpaymentpercent']['required'] = true; $offer_map['clientofferdownpaymentpercent']['highestandbestreplacement'] = "H & B"; $offer_map['clientofferdownpaymentamount']['label'] = "Down Payment Amount"; $offer_map['clientofferdownpaymentamount']['customfieldtypeid'] = 38; $offer_map['clientofferdownpaymentamount']['default'] = 0; $offer_map['clientofferdownpaymentpercent']['required'] = true; $offer_map['clientofferdownpaymentpercent']['highestandbestreplacement'] = "H & B"; $offer_map['clientofferdownpaymentamount']['label'] = "Down Payment Amount"; $offer_map['clientofferdownpaymentamount']['customfieldtypeid'] = 38; $offer_map['clientofferdownpaymentamount']['default'] = 0; $offer_map['clientofferdownpaymentamount']['required'] = true; $offer_map['clientofferdownpaymentamount']['highestandbestreplacement'] = "H & B"; $offer_map['clientofferclosingdate']['label'] = "Closing Date"; $offer_map['clientofferclosingdate']['customfieldtypeid'] = 39; $offer_map['clientofferclosingdate']['required'] = true; $offer_map['clientofferexpirationdate']['label'] = "Offer Expiration Date"; $offer_map['clientofferexpirationdate']['customfieldtypename'] = timedatepicker; $offer_map['clientofferexpirationdate']['customfieldtypeattr3label'] = "23:59"; $offer_map['clientofferexpirationdate']['readonly_for'] = "companyid"; $offer_map['clientofferexpirationdate']['required'] = true; $offer_map['clientofferexpirationdate']['required_for'] = "clientcompanyid"; $offer_map['clientofferexpirationdate']['clearonedit'] = true; $offer_map['clientofferfinancingtype']['label'] = "Financing Type"; $offer_map['clientofferfinancingtype']['customfieldtypeid'] = 59; $offer_map['clientofferfinancingtype']['required'] = true; $offer_map['clientofferpublicfunds']['label'] = "Public Funds"; $offer_map['clientofferpublicfunds']['customfieldtypename'] = "select box"; $offer_map['clientofferpublicfunds']['customfieldtypeattr1label'] = "Buyer not using,Individual is using,Public Entity is using,Other Entity is using"; $offer_map['clientofferpublicfunds']['required'] = true; $offer_map['clientofferpublicfunds']['required_for'] = 'companyid'; $offer_map['clientofferfinancingprequal']['label'] = "Financing Prequal"; $offer_map['clientofferfinancingprequal']['customfieldtypeid'] = 47; $offer_map['clientofferfinancingprequal']['required'] = false; $offer_map['clientofferfinancingprequal']['required_unless'] = "clientofferfinancingtype == 'Cash'"; $offer_map['clientofferpreferredlender']['label'] = "Preferred Lender Prequal"; $offer_map['clientofferpreferredlender']['customfieldtypeid'] = 47; $offer_map['clientofferpreferredlender']['clientcompanyids'] = '5,7'; // COMMA DELIMITED LIST. THESE CLIENT COMPANIES USE THE PREFERRED LENDER SYSTEM $offer_map['clientofferpreferredlender']['required'] = false; $offer_map['clientofferpreferredlender']['required_unless'] = "clientofferfinancingtype == 'Cash'"; $offer_map['clientofferpreferredlender']['clientcompany-publicoffer'][5] = true; $offer_map['clientofferbuyerlendercontactid']['label'] = "Buyer Lender"; $offer_map['clientofferbuyerlendercontactid']['customfieldtypeid'] = 58; $offer_map['clientofferbuyerlendercontactid']['extra1']['contacttypeid'] = '6'; $offer_map['clientofferbuyerlendercontactid']['type'] = "number"; $offer_map['clientofferbuyerlendercontactid']['display'] = "contact"; $offer_map['clientofferbuyerlendercontactid']['required'] = true; $offer_map['clientofferbuyerlendercontactid']['required_unless'] = "(clientofferpreferredlender == 'yes' || clientofferfinancingtype == 'Cash')"; $offer_map['clientofferfinancingrate']['label'] = "Financing Rate"; $offer_map['clientofferfinancingrate']['type'] = "number"; $offer_map['clientofferfinancingrate']['required'] = true; $offer_map['clientofferfinancingrate']['required_unless'] = "clientofferfinancingtype == 'Cash'"; $offer_map['clientofferperdiemamount']['label'] = "Per Diem Amount"; $offer_map['clientofferperdiemamount']['customfieldtypeid'] = 38; $offer_map['clientofferperdiemamount']['default'] = 0; $offer_map['clientofferperdiemamount']['required'] = true; $offer_map['clientofferloanamount']['label'] = "Loan Amount"; $offer_map['clientofferloanamount']['customfieldtypeid'] = 38; $offer_map['clientofferloanamount']['default'] = 0; $offer_map['clientofferloanamount']['required'] = true; $offer_map['clientofferpointsoriginationpercentage']['label'] = "Points Origination Percentage"; $offer_map['clientofferpointsoriginationpercentage']['type'] = "number"; $offer_map['clientofferpointsoriginationpercentage']['required'] = true; $offer_map['clientofferpointsoriginationamount']['label'] = "Points Origination Amount"; $offer_map['clientofferpointsoriginationamount']['customfieldtypeid'] = 38; $offer_map['clientofferpointsoriginationamount']['default'] = 0; $offer_map['clientofferpointsoriginationamount']['required'] = true; $offer_map['clientofferbuyercostamount']['label'] = "Seller Paid Closing Cost"; $offer_map['clientofferbuyercostamount']['netpurchase'] = "subtractable"; $offer_map['clientofferbuyercostamount']['customfieldtypeid'] = 38; $offer_map['clientofferbuyercostamount']['default'] = 0; $offer_map['clientofferbuyercostamount']['required'] = true; $offer_map['clientofferrepairsdescription']['label'] = "Repairs Description"; $offer_map['clientofferrepairsdescription']['required'] = true; $offer_map['clientofferrepairsamount']['label'] = "Repairs Amount"; $offer_map['clientofferrepairsamount']['customfieldtypeid'] = 38; $offer_map['clientofferrepairsamount']['default'] = 0; $offer_map['clientofferrepairsamount']['netpurchase'] = "subtractable"; $offer_map['clientofferrepairsamount']['required'] = true; $offer_map['clientofferrequiredrepairsdescription']['label'] = "Lender Required Repairs Description"; $offer_map['clientofferrequiredrepairsdescription']['required'] = true; $offer_map['clientofferrequiredrepairsamount']['label'] = "Lender Required Repairs Amount"; $offer_map['clientofferrequiredrepairsamount']['customfieldtypeid'] = 38; $offer_map['clientofferrequiredrepairsamount']['default'] = 0; $offer_map['clientofferrequiredrepairsamount']['required'] = true; $offer_map['clientoffercreditinlieuofrepairs']['label'] = "Credit in Lieu of Repairs"; $offer_map['clientoffercreditinlieuofrepairs']['customfieldtypeid'] = 38; $offer_map['clientoffercreditinlieuofrepairs']['default'] = 0; $offer_map['clientoffercreditinlieuofrepairs']['required'] = true; $offer_map['clientofferhomewarrantyamount']['label'] = "Home Warranty Amount"; $offer_map['clientofferhomewarrantyamount']['netpurchase'] = "subtractable"; $offer_map['clientofferhomewarrantyamount']['customfieldtypeid'] = 38; $offer_map['clientofferhomewarrantyamount']['default'] = 0; $offer_map['clientofferhomewarrantyamount']['required'] = true; $offer_map['clientofferinspectiontime']['label'] = "Inspection Time (Days)"; $offer_map['clientofferinspectiontime']['type'] = "number"; $offer_map['clientofferinspectiontime']['required'] = true; $offer_map['clientoffertermiteamount']['label'] = "Termite Amount"; $offer_map['clientoffertermiteamount']['netpurchase'] = "subtractable"; $offer_map['clientoffertermiteamount']['customfieldtypeid'] = 38; $offer_map['clientoffertermiteamount']['default'] = 0; $offer_map['clientoffertermiteamount']['required'] = true; $offer_map['clientoffertransferfeesamount']['label'] = "Transfer Fees Amount"; $offer_map['clientoffertransferfeesamount']['customfieldtypeid'] = 38; $offer_map['clientoffertransferfeesamount']['default'] = 0; $offer_map['clientoffertransferfeesamount']['required'] = true; $offer_map['clientoffertraditionalsellercostsamount']['label'] = "Traditional Seller (customary) Costs"; $offer_map['clientoffertraditionalsellercostsamount']['customfieldtypeid'] = 38; $offer_map['clientoffertraditionalsellercostsamount']['default'] = 0; $offer_map['clientoffertraditionalsellercostsamount']['required'] = true; $offer_map['clientoffertraditionalsellercostsamount']['required_for'] = 'companyid'; $offer_map['clientofferfinancecontingency']['label'] = "Finance Contingency"; $offer_map['clientofferfinancecontingency']['customfieldtypeid'] = 39; $offer_map['clientofferfinancecontingency']['required'] = true; $offer_map['clientofferappraisalcontingency']['label'] = "Appraisal Contingency"; $offer_map['clientofferappraisalcontingency']['customfieldtypeid'] = 39; $offer_map['clientofferappraisalcontingency']['required'] = true; $offer_map['clientoffercommissionpercent']['label'] = "Commission Percent"; $offer_map['clientoffercommissionpercent']['type'] = "number"; $offer_map['clientoffercommissionpercent']['default'] = 6.00; $offer_map['clientoffercommissionpercent']['required'] = true; $offer_map['clientoffercommissionpercent']['readonly_for'] = "companyid"; $offer_map['clientoffercommissionpercent']['hidefromapprovalqueue'] = "1"; $offer_map['clientoffercommissionamount']['label'] = "Commission Amount"; $offer_map['clientoffercommissionamount']['customfieldtypeid'] = 38; $offer_map['clientoffercommissionamount']['default'] = 0; $offer_map['clientoffercommissionamount']['required'] = true; $offer_map['clientoffercommissionamount']['readonly_for'] = "companyid"; $offer_map['clientoffercommissionamount']['hidefromapprovalqueue'] = "1"; $am_label = "Asset Management"; if($clientcompanyid == 5) //BSI $am_label = 'Entra'; $offer_map['clientofferentrareferralpct']['label'] = "$am_label Referral Percent (Included in the commission percent above)"; $offer_map['clientofferentrareferralpct']['default'] = 1.00; $offer_map['clientofferentrareferralpct']['readonly_for'] = "companyid"; $offer_map['clientofferentrareferralpct']['required'] = true; $offer_map['clientofferentrareferralpct']['required_for'] = "clientcompanyid"; $offer_map['clientofferentrareferralpct']['hidefromapprovalqueue'] = "1"; $offer_map['clientofferentrareferralamount']['label'] = "$am_label Referral Amount"; $offer_map['clientofferentrareferralamount']['readonly_for'] = "companyid"; $offer_map['clientofferentrareferralamount']['required'] = true; $offer_map['clientofferentrareferralamount']['customfieldtypeid'] = 38; $offer_map['clientofferentrareferralamount']['default'] = 0; $offer_map['clientofferentrareferralamount']['required_for'] = "clientcompanyid"; $offer_map['clientofferentrareferralamount']['hidefromapprovalqueue'] = "1"; $offer_map['clientofferlistingagentincentive']['label'] = "Listing Agent Incentive"; $offer_map['clientofferlistingagentincentive']['required'] = true; $offer_map['clientofferlistingagentincentive']['hidefromapprovalqueue'] = "1"; $offer_map['clientoffersellingagentincentive']['label'] = "Selling Agent Incentive"; $offer_map['clientoffersellingagentincentive']['required'] = true; $offer_map['clientoffersellingagentincentive']['hidefromapprovalqueue'] = "1"; $offer_map['clientofferotherexpensedescription']['label'] = "Other Expense Description"; $offer_map['clientofferotherexpensedescription']['required'] = true; $offer_map['clientofferotherexpenseamount']['label'] = "Other Expense Amount"; $offer_map['clientofferotherexpenseamount']['netpurchase'] = "subtractable"; $offer_map['clientofferotherexpenseamount']['customfieldtypeid'] = 38; $offer_map['clientofferotherexpenseamount']['default'] = 0; $offer_map['clientofferotherexpenseamount']['required'] = true; //$offer_map['clientoffersellertitle']['label'] = "Seller's Choice Title"; //$offer_map['clientofferbuyertitle']['label'] = "Buyer's Choice Title"; //MB - added the following four lines $offer_map['clientoffertitlechoice']['label'] = "Title Choice"; $offer_map['clientoffertitlechoice']['required'] = true; $offer_map['clientoffertitlechoice']['customfieldtypename'] = "select box"; $offer_map['clientoffertitlechoice']['customfieldtypeattr1label'] = "Buyer's,Seller's"; if($clientcompanyid==10) $offer_map['clientoffertitlechoice']['customfieldtypeattr1label'] = "Seller's"; $offer_map['clientoffertitlechoice']['clientcompany-publicoffer'][5] = true; $offer_map['clientoffertitlechoice']['hidefromapprovalqueue'] = "1"; $offer_map['clientoffertitle']['label'] = "Title Company"; $offer_map['clientoffertitle']['required'] = true; $offer_map['clientoffertitle']['customfieldtypeid'] = 51; $offer_map['clientoffertitle']['clientcompany-publicoffer'][5] = true; $offer_map['clientoffertitle']['clientcompany-publicoffer'][7] = true; $offer_map['clientoffertitle']['hidefromapprovalqueue'] = "1"; if($clientoffertechfeeamountvalue) { //in order to create a situation where these fees are displayed, //the listing agent must have online offers enabled for the property. When // a public user clicks the "Make Offer" Button, those fees are listed under "Additional Information". // To test from public side - search for property: 123 Public St. Boise, ID | Listing Agent : Joe Test // by clicking the link to submit an offer (while not logged in) You are able to view the //Technology Fee amount of $301 $offer_map['clientoffertechfee']['label'] = "$".$clientoffertechfeeamountvalue." Technology Fee (Paid at COE)"; $offer_map['clientoffertechfee']['required'] = true; $offer_map['clientoffertechfee']['clientcompany-publicoffer'][5] = true; $offer_map['clientoffertechfee']['clientcompany-publicoffer'][7] = true; $offer_map['clientoffertechfee']['hidefromapprovalqueue'] = "1"; } if($clientcompanyid == 10) // BAM does not want to track a technogyfee amount in their stuff unset( $offer_map['clientoffertechfee']); if($clientcompanyid == 5) //mnmcompany { $offer_map['clientofferrushofferresponse']['label'] = "Buyers Agent Opted In for Rush Offer Response"; $offer_map['clientofferrushofferresponse']['required'] = true; $offer_map['clientofferrushofferresponse']['customfieldtypename'] = "select box"; $offer_map['clientofferrushofferresponse']['customfieldtypeattr1label'] = "Yes,No"; $offer_map['clientofferrushofferresponse']['addclass'] = "highlight"; } $offer_map['clientofferbuyercomments']['label'] = "Comments to Seller"; $offer_map['clientofferbuyercomments']['customfieldtypeid'] = 51; $offer_map['clientofferbuyercomments']['input_visible_for'] = "companyid"; $offer_map['clientofferbuyercomments']['required'] = true; $offer_map['clientoffersellercomments']['label'] = "Comments to Buyer"; $offer_map['clientoffersellercomments']['customfieldtypeid'] = 51; $offer_map['clientoffersellercomments']['input_visible_for'] = "clientcompanyid"; $offer_map['clientoffersellercomments']['required'] = true; $offer_map['clientoffersellertolacomments']['label'] = "Comments to Listing Agent"; $offer_map['clientoffersellertolacomments']['customfieldtypeid'] = 51; $offer_map['clientoffersellertolacomments']['input_visible_for'] = "clientcompanyid"; $offer_map['clientoffersellertolacomments']['required'] = true; if($clientcompanyid == 10) // for BAM only { $offer_map[clientofferadditionalterms]['label'] = "Additional Terms to Contract"; $offer_map[clientofferadditionalterms]['customfieldtypeid'] = 51; $offer_map[clientofferadditionalterms]['input_visible_for'] = "clientcompanyid"; $offer_map[clientofferadditionalterms]['required'] = false; } $offer_map['clientofferdocument']['label'] = "Offer Document"; $offer_map['clientofferdocument']['customfieldtypeid'] = 82; //documentupload $offer_map['clientofferdocument']['input_visible_for'] = "companyid"; $offer_map['clientofferdocument']['type'] = "documentupload"; $offer_map['clientofferdocument']['required'] = "addoffer"; $offer_map['clientofferdocument']['clientcompany-publicoffer'][5] = true; $offer_map['clientofferpreapprovaldocument']['label'] = "Pre Approval Document/POF Document"; $offer_map['clientofferpreapprovaldocument']['customfieldtypeid'] = 82; //documentupload $offer_map['clientofferpreapprovaldocument']['input_visible_for'] = "companyid"; $offer_map['clientofferpreapprovaldocument']['type'] = "documentupload"; $offer_map['clientofferpreapprovaldocument']['required'] = false; $offer_map['clientofferpreapprovaldocument']['clientcompany-publicoffer'][5] = true; $offer_map['clientofferpreapprovaldocument']['clientcompany-publicoffer'][7] = true; if(clientcompanyssp()) { $offer_map['clientsspadditionaldocument']['label'] = "Additional Offer Document"; $offer_map['clientsspadditionaldocument']['customfieldtypeid'] = 82; //documentupload $offer_map['clientsspadditionaldocument']['input_visible_for'] = "companyid"; $offer_map['clientsspadditionaldocument']['type'] = "documentupload"; $offer_map['clientsspadditionaldocument']['clientcompany-publicoffer'][5] = true; } if($clientcompanyid == 10) // BAM { //lets deprecate certain fields we do not want to show up for bam, we deprecate, because if the offer already has a value, we dont' want it to disapeer $deprecated[clientofferfinancingprequal]=1; $deprecated[clientofferpreferredlender]=1; $deprecated[clientofferfinancingrate]=1; $deprecated[clientofferpointsoriginationpercentage]=1; $deprecated[clientofferpointsoriginationamount]=1; $deprecated[clientofferrequiredrepairsdescription]=1; $deprecated[clientofferrequiredrepairsamount]=1; $deprecated[clientoffercreditinlieuofrepairs]=1; $deprecated[clientoffertransferfeesamount]=1; $deprecated[clientofferfinancecontingency]=1; $deprecated[clientofferappraisalcontingency]=1; $deprecated['clientofferentrareferralamount']=1; $deprecated['clientofferentrareferralpct']=1; $deprecated['clientofferlistingagentincentive']=1; $deprecated['clientoffersellingagentincentive']=1; $deprecated['clientoffercommissionpercent']=1; $deprecated['clientoffercommissionamount']=1; $deprecated['clientoffertitlechoice']=1; $deprecated['clientoffertitle']=1; $deprecated['clientoffersellertolacomments']=1; $deprecated['clientoffersellercomments']=1; } if($deprecated) // any users with deprecated { //d(deprecated,$deprecated); foreach($deprecated as $dkey=> $dfld) $offer_map[$dkey][deprecated] = true; } // DATABASE SCHEMA CHECK // HERE WE CHECK THE SCHEMA FOR BOTH tbloffer AND tblclientoffer, TO ENSURE ALL THE NEEDED COLUMNS ARE ALREADY IN THE TABLE // WE CHECK BOTH BECAUSE THIS MAP IS UTILIZED ON BOTH inc_clientpropertyoffers AND inc_propertyoffers_form.php $sql = "select column_name from INFORMATION_SCHEMA.COLUMNS where table_name = 'tbloffer'"; $cols = db_query($sql, '', '', 'column_name'); foreach($offer_map as $key => $val){ if($val['clientcompany-publicoffer'] && !$cols[str_replace('client','',$key)]) ddie('Line: ' . __LINE__ . ' - functions_tblclientoffer.php // You must create the column(' . str_replace('client','',$key) . ') in tbloffer.'); } $sql = "select column_name from INFORMATION_SCHEMA.COLUMNS where table_name = 'tblclientoffer'"; $cols = db_query($sql, '', '', 'column_name'); foreach($offer_map as $key => $val) { if(!$cols[$key] && !($val['calc_type'] == 'percent')) ddie('Line: ' . __LINE__ . ' - functions_tblclientoffer.php // You must create the column(' . $key . ') in tblclientoffer.'); } return $offer_map; } function offer_template($offer_map, $offer = '', $last = false, $prev = '', $status = '', $clientcompanyid = '') { //d(inside_offer_template, $offer_map); global $offer_count; global $preferred_lender; $offer_count++; //d(offer,$offer); if($offer['clientnegotiationid']) { $negotiation = clientnegotiation_get('',$offer['clientnegotiationid'],1); $negotiation = $negotiation[0]; $property = get_clientcompanyproperty($negotiation[clientcompanypropertyid]); } if($_POST['offerid']) $offer = clientoffer_get('',$_POST['offerid']); //d(_first_, $offer); if($offer) { $sql = "select * from tbllogin where loginid = " . $offer['clientoffercreatedby']; $login = db_first($sql); if($login['clientcompanyid'] > 0) $offer_author = 'client'; else if($login['companyid'] > 0) $offer_author = 'company'; } if($offer[clientofferretracteddate]) $status='Retracted'; ?>
'>

** Please input n/a in all not applicable fields **

Retracted ".dttime_format($offer[clientofferretracteddate])." by ".get_login_info($offer[clientofferretractedby]).""; disable_d_start(); ?>
** Please input n/a in all not applicable fields ** * Required
$escalationlevel) $escalationlevel=$percentescalationlevel; if(!$escalationlevel) d("No Escalation is required grade:$propertygrade lp: $lp, net:$net, diff:$pricediff, percent:$percentdiff"); else { $client = get_clientcompanyclient($property[clientcompanyclientid]); $opts[button_new] = "Request Escalation($escalationlevel) to Accept This Offer "; $queueapproval_display = queueapproval_getdisplay(clientoffer,$offer[clientofferid],clientofferaccept,$property[clientcompanyclientid], $escalationlevel,$opt); $st = queueapproval_status(clientoffer,$offer[clientofferid],clientofferaccept); //d(status, $st); //d("QUEUEAPPROVAL_GIVEN", QUEUEAPPROVAL_GIVEN); if(queueapproval_status(clientoffer,$offer[clientofferid],clientofferaccept)!=QUEUEAPPROVAL_GIVEN) $hideacceptbutton = 1; // lets hide the approve button } } } ?>
** Please input n/a in all not applicable fields ** * Required
** Please input n/a in all not applicable fields ** * Required
$field) { $sep = ""; if ($field['netpurchase'] == 'addable') $sep = "+"; else if ($field['netpurchase'] == 'subtractable') $sep = "-"; if ($sep) $retval .= $sep."Number($('#$key').val())"; } return "(".$retval.")"; } function clientoffer_getescalation($clientcompanyclientid, $offer, $offer_map) { //calculate the escalation information $listprice = db_number(get_clientpropertyextensionentry($_GET[view],propertyextensionlistprice)); if($listprice) { $propertygrade = get_escalationgrade($clientcompanyclientid,$listprice); $netpurchase = clientoffer_calcsum('netpurchase', $offer, $offer_map); $pricediff = $listprice - $netpurchase; $percentdiff = ($pricediff/$listprice)*100; $dollarescalationlevel = offerescalationlevel_dollar($clientcompanyclientid,$propertygrade,$pricediff); $percentescalationlevel = offerescalationlevel_percent($clientcompanyclientid,$propertygrade,$percentdiff); $escalationlevel = $dollarescalationlevel; if($percentescalationlevel > $escalationlevel) $escalationlevel = $percentescalationlevel; /* d(clientcompanyclientid,$clientcompanyclientid); d(netpurchase, $netpurchase); d(pricediff, $pricediff); d(percentdiff, $percentdiff); d(dollarescalationlevel, $dollarescalationlevel); d(percentescalationlevel, $percentescalationlevel); d(escalationlevel,$escalationlevel); */ return $escalationlevel; } d(ERROR); return false; } function clientoffer_ishighestandbest($offer) { d("clientoffer_ishighestandbest", $offer); if ($offer) { foreach ($offer as $field) { if ($field == 'H & B') return true; } } return false; } function clientoffer_getofferrole($offer) { if (!$offer) return false; $sql = " select companyid, clientcompanyid from tbllogin where loginid = ".$offer['clientoffercreatedby']; $result = db_first($sql); if ($result[clientcompanyid] > 0) $offerrole = "Seller"; else if ($result[companyid] > 0) $offerrole = "Buyer"; return " - $offerrole"; } function getrequiredtext($field) { $required = ""; if($field['required'] && $field['required_for']) { $functionName = $field['required_for']; if($functionName()) $required = " data-required='true'"; } else if($field['required']) { $required = " data-required='true'"; } return $required; }