function customfield_extension_hoaid($value,$propertyarr)
{
return customfield_extension_hoa("hoaid",$value,$propertyarr);
}
function customfield_extension_hoa2id($value,$propertyarr)
{
return customfield_extension_hoa("hoa2id",$value,$propertyarr);
}
function customfield_extension_hoa3id($value,$propertyarr)
{
return customfield_extension_hoa("hoa3id",$value,$propertyarr);
}
function customfield_extension_hoa($name,$value,$property)
{
timetrack_start("customfield_extension_hoa",$name);
ob_start();
if (!is_array($property) && $_POST[clientcompanypropertyid])
{
$property = get_clientcompanyproperty($_POST[clientcompanypropertyid]);
foreach($_POST as $k=>$value)
{
$property[extension]["propertyextension".$k] = $value;
}
$skip=1;
}
unset ($COMPANYSIDE);
switch ($name)
{
case "hoaid":
$dname="HOA";
$hoafieldsid=1;
break;
case "hoa2id":
$dname="HOA2";
$hoafieldsid=2;
break;
case "hoa3id":
$dname="HOA3";
$hoafieldsid=3;
break;
}
if ($property && !$skip)
{
if (array_key_exists("propertyid",$property))
{
$prefix = "property";
$db_table_prefix ="";
$COMPANYSIDE = 1;
$hoaid=$property[$name];
}elseif (array_key_exists("clientcompanypropertyid",$property))
{
$prefix ="propertyextension";
$db_table_prefix="clientcompany";
}
}
elseif (clientcompanyid() || $skip) // at this time we are unable to find propertyid or clientcompanypropertyid therefore we assume we are adding new property
{
$prefix ="propertyextension";
$db_table_prefix="clientcompany";
}elseif (companyid())
{
$prefix = "property";
$db_table_prefix ="";
$COMPANYSIDE = 1;
}else
{
// Changed from die to dlog so that the previews work with any values
if (is_developer())
dlog(hoa,"Developer error. Parameter is missing. HOA parameters passed in: property".$property." value ".$value);
else
return ""; // I hope we will never get this message. Return blank because of the previews without any values
}
echo"
$dname :
";
$thisstate = $db_table_prefix."propertystate";
$dropdownlengthrestriction=110;
if ($COMPANYSIDE || client_portal())
{
$sql = "select * from tblhoa
where companyid = '".db_number(companyid())."'
and hoainactive is null
order by hoaname asc";
$my_hoas = db_query($sql);
$exclude = '';
if($my_hoas)
{
foreach($my_hoas as $key => $hoa)
{
if($exclude)
$exclude .= ',';
$exclude .= $hoa['hoaid_master'];
}
$my_hoaarray[0][id]=" ";
$my_hoaarray[0][value]="**************** My HOA's *****************";
$my_hoaarray[0][label]=1;
$i=1;
foreach ($my_hoas as $key=>$hoa)
{
$my_hoaarray[$i][id]=$hoa['hoaid'];
$my_hoaarray[$i][value]=$hoa['hoaname'];
$i++;
}
}
}
$sql = "select hoaid
,hoaname
,hoaaddress
,hoacity
,hoastate
,hoazip
,hoacontact
,hoaphone
,(
'n-' || coalesce(hoaname,'')
|| '-a-' || coalesce(hoaaddress,'')
|| '-c-' || coalesce(hoacity,'')
|| '-s-' || coalesce(hoastate,'')
|| '-z-' || coalesce(hoazip,'')
|| '-ct-' || coalesce(hoacontact,'')
|| '-p-' || coalesce(hoaphone,'')
) as hoakey
from tblhoa";
if ($property)
{
$sql .=" left join ( select name,code
from tblstate
where code = '".db_col($property[$thisstate])."'
or name ='".db_col($property[$thisstate])."')
tblstate on (tblstate.name = hoastate or tblstate.code = hoastate)";
}
$sql .=" where companyid = 0
and hoaid_master = 0 ";
if($property)
$sql .=" and (hoastate = name or hoastate = code) ";
$sql.= " and hoainactive is null ";
if ($exclude)
$sql .=" ". ($exclude ? "and hoaid not in (".$exclude.")" : "");
$sql .= " order by hoaname asc";
global $hoanodups;
if($hoanodups && is_array($hoanodups))
$hoas=$hoanodups;
else
{
$hoas = db_query($sql);
if($hoas)
{
if(!strstr($_SERVER['SCRIPT_NAME'],'property_add.php') && ($_GET['action']!='add'))
$hoas=hoa_removeduplicate($hoas); //Cache for same page because sometimes same date pulled 3 times.
$hoanodups=$hoas;
}
}
if ($hoas)
{
if ($property)
$insertstate ="( $property[$thisstate] )";
$hoaarray[0][id]=" ";
$hoaarray[0][value]=" ********* HOA State $insertstate Database **********";
$hoaarray[0][label]=1;
$i=1;
foreach ($hoas as $key=>$hoa)
{
$selectiondisplay=$hoa['hoaname'];
$dupfields="";
if($hoa['hoacontact'])
$dupfields.=" ".$hoa['hoacontact'];
if($hoa['hoaphone'])
$dupfields.=" (".$hoa['hoaphone'].")";
if($hoa['hoaaddress'])
$dupfields.=" ".$hoa['hoaaddress'];
if($hoa['hoacity'])
$dupfields.=" ".$hoa['hoacity'];
if($hoa['hoastate'])
$dupfields.=" ".$hoa['hoastate'];
if($hoa['hoazip'])
$dupfields.=" ".$hoa['hoazip'];
if($dupfields)
{
if((strlen($dupfields)+strlen($selectiondisplay)+4)>$dropdownlengthrestriction)
{
$duplenrestrict=$dropdownlengthrestriction-(strlen($selectiondisplay)+4);
if($duplenrestrict<0)
$duplenrestrict=0;
$dupfields=substr($dupfields,0,$duplenrestrict)." ...";
}
$selectiondisplay=$selectiondisplay." - [".trim($dupfields)."]";
}
$hoaarray[$i][id]=$hoa['hoaid'];
$hoaarray[$i][value]=$selectiondisplay;
$i++;
}
}
if ($my_hoaarray && $hoaarray)
$hoaarray = array_merge ($my_hoaarray,$hoaarray);
elseif (!$hoaarray) // we got 0 HOA for this state going national.
{
if ($COMPANYSIDE)
{
$mystates = get_mystates();
$sql = "select *
,(
'n-' || coalesce(hoaname,'')
|| '-a-' || coalesce(hoaaddress,'')
|| '-c-' || coalesce(hoacity,'')
|| '-s-' || coalesce(hoastate,'')
|| '-z-' || coalesce(hoazip,'')
|| '-ct-' || coalesce(hoacontact,'')
|| '-p-' || coalesce(hoaphone,'')
) as hoakey
from tblhoa
left join( select name,code
from tblstate";
if($property)
$sql .=" where code = '".db_col($property[$thisstate])."'
or name ='".db_col($property[$thisstate])."')";
if (!$property)
$sql .=" where code in ('" .implode("','",$mystates)."')
or name in ('" .implode("','",$mystates)."'))";
$sql .=" tblstate on (tblstate.name = hoastate)
where (companyid = '".db_number(companyid())."'
or companyid = 0)
and hoaid_master = 0
and hoainactive is null ";
if($property)
$sql .=" and (hoastate=name or hoastate=code) ";
if (!$property)
$sql .="and hoastate in ('" .implode("','",$mystates)."') ";
if ($exclude)
$sql .=" ". ($exclude ? "and hoaid not in (".$exclude.")" : "");
$sql .=" order by hoaname asc";
global $hoanationalnodups;
if($hoanationalnodups && is_array($hoanationalnodups))
$hoas=$hoanationalnodups;
else
{
$hoas = db_query($sql);
if($hoas)
{
if(!strstr($_SERVER['SCRIPT_NAME'],'property_add.php') && ($_GET['action']!='add'))
$hoas=hoa_removeduplicate($hoas); //Cache for same page because sometimes same date pulled 3 times.
$hoanationalnodups=$hoas;
}
}
if ($hoas)
{
$insertstate="";
if ($property)
$insertstate ="State( $property[$thisstate] ) ";
$hoaarray[0][id]=" ";
$hoaarray[0][value]=" ********* HOA ".$insertstate."Database **********";
$hoaarray[0][label]=1;
$i=1;
foreach ($hoas as $key=>$hoa)
{
$selectiondisplay=$hoa['hoaname'];
$dupfields="";
if($hoa['hoacontact'])
$dupfields.=" ".$hoa['hoacontact'];
if($hoa['hoaphone'])
$dupfields.=" (".$hoa['hoaphone'].")";
if($hoa['hoaaddress'])
$dupfields.=" ".$hoa['hoaaddress'];
if($hoa['hoacity'])
$dupfields.=" ".$hoa['hoacity'];
if($hoa['hoastate'])
$dupfields.=" ".$hoa['hoastate'];
if($hoa['hoazip'])
$dupfields.=" ".$hoa['hoazip'];
if($dupfields)
{
if((strlen($dupfields)+strlen($selectiondisplay)+4)>$dropdownlengthrestriction)
{
$duplenrestrict=$dropdownlengthrestriction-(strlen($selectiondisplay)+4);
if($duplenrestrict<0)
$duplenrestrict=0;
$dupfields=substr($dupfields,0,$duplenrestrict)." ...";
}
$selectiondisplay=$selectiondisplay." - [".trim($dupfields)."]";
}
$hoaarray[$i][id]=$hoa['hoaid'];
$hoaarray[$i][value]=$selectiondisplay;
$i++;
}
}
if ($my_hoaarray && $hoaarray)
{
//d("merge",$my_hoaarray);
$hoaarray = array_merge ($my_hoaarray,$hoaarray);
}
else
{
$hoaarray=$my_hoaarray;
}
}
}
if ($COMPANYSIDE)
{
$hoaprefix="property".strtolower($dname);
$sql = " select * from tblproperty
where propertyid = '".db_number ($property[propertyid])."'";
$hoadata=db_first($sql);
}
else
{
$hoaprefix="propertyextension".strtolower($dname);
if ($property)
{
$hoadata1=$property[extension];
unset($hodata);
d($hoadata1);
if (is_array($hoadata1))
{
foreach ($hoadata1 as $row=>$extension)
{
if(strstr($row,'propertyextensionhoa'))
$hoadata[$row]=$extension[propertyextensionentryvalue];
}
$hoaid = $hoadata1[$name][propertyextensionentryvalue];
}else
unset ($hoaid);
}
if (!$hoadata)
{
$hoadata1=$_POST;
unset($hodata);
d(myhoa, $hoadata1);
if (is_array($hoadata1))
{
foreach ($hoadata1 as $extension)
{
if(strstr($row,'propertyextensionhoa'))
$hoadata[$row]=$extension[propertyextensionentryvalue];
}
$hoaid = $hoadata1[$name];
}else
unset ($hoaid);
}
if ($skip)
{
$hoadata = $hoadata1;
$hoaid = $hoadata[propertyextensionhoaid];
}
// AMC Hack to show any hoa that we have id
if ($hoaid)
{
unset($foundhoa);
foreach ($hoaarray as $key=>$value)
{
if ($value[id] == $hoaid)
$foundhoa=1;
}
if (!$foundhoa)
$hoaarray[]=db_first("select hoaid as id, hoaname as value from tblhoa where hoaid=".db_number($hoaid));
}
}
if (!$hoaid && $GLOBALS[customfield_viewonly]) // no hoa selected in readonly mode no need to process any further
{
echo "
";
return ob_get_clean();
}
?>
// this field has same name for both sides since its 1st field.
customfield ("sqldropdown",$name,$hoaid,$hoaarray," ","onchange='displayhoacontactinfo($(this).val(),\"".$name."\");' hideshowspan='hoadetails_'");
echo "";
echo "";
echo"
";
// strip prefix and make temparray
if ($hoadata)
{
foreach($hoadata as $fld =>$val)
{
if (preg_replace("/".$hoaprefix."/","",$fld)!=$fld)
{
$hoadata[preg_replace("/".$hoaprefix."/","",$fld)]=$hoadata[$fld];
unset ($hoadata[$fld]);
}
}
}
$yesvl=0;
$novl='checked';
if($hoadata[assessment])
{
$yesvl='checked';
$novl=0;
}
echo "
";
timetrack_stop("customfield_extension_hoa",$name);
$content = ob_get_clean();
return $content;
}
function customfield_extension_propertyextensionutility($value,$property)
{
return customfield_extension_utility_list($value,$property);
}
// Utilities
function customfield_extension_utility_list($value,$property)
{
global $customfield_readonly, $customfield_readonly_nextonly;
if (companyid())
{
if (db_number($property[propertyid])>0)
$sql = "select propertyextensionkey,propertyextensionentryvalue from tblpropertyextensionentry where propertyid='".db_number($property[propertyid])."' and propertyextensionkey like 'propertyextensionutil%'";
else
$sql = "select propertyextensionkey,propertyextensionentryvalue from tblpropertyextensionentry where clientcompanypropertyid='".db_number($property[clientcompanypropertyid])."' and propertyextensionkey like 'propertyextensionutil%'";
$tmp_arr=db_query($sql);
foreach ($tmp_arr as $key=>$tmpfld)
{
$property[extension][$tmpfld[propertyextensionkey]]=$tmp_arr[$key][propertyextensionentryvalue];
}
}
unset($COMPANYSIDE);
if ($property)
{
if (array_key_exists("propertyid",$property))
$COMPANYSIDE=1;
}
else if(companyid())
$COMPANYSIDE=1;
$form = !($customfield_readonly||$customfield_readonly_nextonly || $value);
if (!$COMPANYSIDE)
$form = 0;
return utility_list2($property,$form,$COMPANYSIDE);
}
function customfield_extension_propertyextensionclosingattorneyclientid($val,$property,$par3=0,$par4=0,$par5=0,$par6=0,$par7=0,$par8=0)
{
$sqltext = "select clientid as id,
clientcompanyname as value
from tblclient
where clienttypeid in (select clienttypeid
from tblclienttype
where clienttypegroupid in (select clienttypegroupid
from tblclienttype
where clienttypeid = 3)
)
and companyid = " . companyid() . "
";
$sqladdition=" and clientinactive is null
";
if($val && db_number($val)>0)
{
$sqladdition=" and (
clientinactive is null
or clientid=".db_number($val)."
)
";
}
$sqltext.=$sqladdition;
$sql=db_query($sqltext);
customfield('sqldropdown','propertyextensionclosingattorneyclientid',$val,$sql,'[select closing attorney office]',' class="client_select" data-clienttypeid="3" data-contacttypeid="23" data-propertyextensionkey="propertyextensionclosingattorney"');
return;
}
function customfield_extension_propertyextensionproppresclientid($value,$property=0,$par3=0,$par4=0,$par5=0,$par6=0,$par7=0,$par8=0)
{
if (clientcompanyid())
{
if(is_array($property))
if(is_array($property['extension']))
if(is_array($property['extension']['propertyextensionproppresclientid']))
if ($property['extension']['propertyextensionproppresclientid']['propertyextensionentryvalue'])
{
$sql = "
select clientcompanyname
from tblcontact
left join tblclient using (clientid)
where clientid = '".db_number($property['extension']['propertyextensionproppresclientid']['propertyextensionentryvalue'])."'
and contactinactive is null
and clientinactive is null
group by clientcompanyname";
$result = db_first($sql);
echo ucwords($result[clientcompanyname]);
}else
echo " ";
return;
}
$sql = db_query("
select clientid as id
, clientcompanyname as value
from tblclient
where clienttypeid in
(
select clienttypeid
from tblclienttype
where clienttypegroupid in
(
select clienttypegroupid
from tblclienttype
where clienttypeid = 179
)
)
and companyid = " . companyid() . "
and clientinactive is null");
customfield('sqldropdown','propertyextensionproppresclientid',$val,$sql,'',' class="client_select" data-clienttypeid="179" data-contacttypeid="23" data-propertyextensionkey="propertyextensionpropertypreservation"');
return;
}
function customfield_extension_propertyextensiontitleofficerclientid($val,$property=0,$par3=0,$par4=0,$par5=0,$par6=0,$par7=0,$par8=0)
{
if (clientcompanyid())
{
if(!is_array($property))
{
if ($_GET['page'] == 'details' && $_GET['action'] == 'add')
return; // This will prevent false positive on Add New Client property action. VL
else
developer_error('function called without property array');
return;
}
if ($property['extension']['propertyextensiontitleofficerclientid']['propertyextensionentryvalue'])
{
$sql = "select clientcompanyname from tblcontact
left join tblclient using (clientid)
where clientid = '".db_number($property['extension']['propertyextensiontitleofficerclientid']['propertyextensionentryvalue'])."'
and contactinactive is null
and clientinactive is null
group by clientcompanyname";
$result = db_first($sql);
echo ucwords($result[clientcompanyname]);
}else
echo " ";
return;
}
?>
$sqltext = "select clientid as id, clientcompanyname as value
from tblclient
where clienttypeid in (select clienttypeid from tblclienttype
where clienttypegroupid in (select clienttypegroupid from tblclienttype where clienttypeid = 9)
)
and companyid = " . companyid() . "
";
$sqladdition=" and clientinactive is null
";
if($val && db_number($val)>0)
{
$sqladdition=" and (
clientinactive is null
or clientid=".db_number($val)."
)
";
}
$sqltext.=$sqladdition;
$sql=db_query($sqltext);
customfield('sqldropdown','propertyextensiontitleofficerclientid',$val,$sql,'[select title office]',' class="client_select" data-clienttypeid="9" data-contacttypeid="11,3" data-propertyextensionkey="propertyextensiontitleofficer"');
}
function customfield_extension_propertyextensionclosinglenderclientid($val,$property,$par3=0,$par4=0,$par5=0,$par6=0,$par7=0,$par8=0){
$sql = db_query("select clientid as id, clientcompanyname as value
from tblclient
where clienttypeid in (select clienttypeid
from tblclienttype
where clienttypegroupid in (select clienttypegroupid
from tblclienttype
where clienttypeid = 74)
)
and companyid = " . companyid() . "
and clientinactive is null");
customfield('sqldropdown','propertyextensionclosinglenderclientid',$val,$sql,'[select closing lender office]',' class="client_select" data-clienttypeid="74" data-contacttypeid="6" data-propertyextensionkey="propertyextensionfinancinglender"');
}
function customfield_extension_propertyextensionpropertyaddress($propertyid)
{
$prop = db_first("select * from tblproperty where propertyid = ".db_number($propertyid));
//d($prop,"CF_OB");
ob_start();
?>
$sql = "select name as id, name as value
from tblstate
order by name";
$qry = db_query($sql);
customfield ("sqldropdown",propertystate,$prop['propertystate'],$qry);
?>
// Only run if not read only.
global $customfield_readonly;
if (!$customfield_readonly) { ?>
//d("CF OB 2 ",__LINE__);
//Do Not Remove the following Comment. Commenting section to prevent Validate Address button from being visible until Geocoding is working again. Mac
/*
?>
*/
// d("CF OB 3")
?>
}
return ob_get_clean();
}
function is_inactive_staff($staffid)
{
$ql="select logininactive from tblstaff join tbllogin using (staffid) where staffid=".db_number($staffid);
$inactivatedate=db_first($ql);
if($inactivatedate[logininactive])
return 1;
return 0;
}
function customfield_extension_propertyextensionpropertygroupstaff ($propertyid)
{
//d("JUst a d to confirm");
$propertyid=$_GET[view];
$pegql="select * from tblpropertygroupstaff join tblgroup using(groupid) where propertyid=".db_number($propertyid);
$pegs = db_query ($pegql,0,1,groupid);
$agent_groups = array();
$sql="select groupid,staffid
as id,(
select stafffname ||' ' || stafflname
from tblstaff
where staffid =tblstaffgroup.staffid)
as value, (
select groupname
from tblgroup
where groupid=tblstaffgroup.groupid)
as groupname
from tblstaffgroup
where staffid in (
select staffid
from tbllogin
where companyid =".(db_number($propertyid)?"(
select companyid
from tblproperty
where propertyid = ".db_number($propertyid).")":db_number(companyid()))."
and logininactive is null)
order by groupname";
// ob_flush();
$posttext="";
//d($sql,'$sql');
//d($pegql,'pegs');
//d($pegs,'pegs result');
$propgroups=db_query($sql);
//d($propgroups,'$propgroups');
if(is_array($propgroups))
foreach($propgroups as $pk=>$pv)
{
$propgroupids[$pv[groupid]]=$pv[groupid];
}
if(is_array($pegs))
foreach($pegs as $k=>$v)
{
if(is_array($propgroupids))
if(!in_array($k,array_keys($propgroupids)))
{
if(is_inactive_staff($v[staffid]))
$posttext=" (Inactive) ";
if($v[groupid]==0)
{
//d($v);
continue;
}
$propgroups[$k][id]=$v[staffid];
$propgroups[$k][groupid]=$v[groupid];
$propgroups[$k][value]=mystaffname_fromid(db_number($v[staffid]))." ".$posttext;
$propgroups[$k][groupname]=$v[groupname];
}
}
if(is_array($propgroups))
foreach ($propgroups as $key=>$row)
{
if ($row[groupid] <> $oldgrpid)
{
$idx=1;
$oldgrpid=$row[groupid];
}
if(is_inactive_staff($row[id]))
$posttext=" (Inactive) ";
$agent_groups[$row[groupid]][sqldropdown][$idx][id]=$row[id];
$agent_groups[$row[groupid]][sqldropdown][$idx][value]=$row[value]." ".$posttext;
$agent_groups[$row[groupid]][groupname]=$row[groupname];
$selboxidopts[$row[groupid]][$row[id]]=$row[id];
$idx++;
}
//d($agent_groups,'ag groups');
//d($selboxidopts,'$selboxidopts');
ob_start();
unset($idx);
global $customfield_readonly,$customfield_viewonly;
?>
Group
Agent
foreach ($agent_groups as $key=>$row){
if ($row[groupname]=="Listing Agent")
continue; // MTX 18305 Client request to remove.
// verify that we have the selected staffid available
$selectedstaff=$pegs[$key][staffid];
$nam=mystaffname_fromid($selectedstaff);
//d($nam,$row[groupname]);
foreach($row[sqldropdown] as $selection=>$selectionidvals)
{
$idsarray[]=$selectionidvals[id];
}
if($selectedstaff && !in_array($selectedstaff,array_values($idsarray)))
{
//d("Not in ids array: ".$nam);
// this staff memeber assigned here has since been deactivated and so they do not get returned with the original query
// We will check to see if this selected staffid is in the query, if not, we will get the name to add to thew array for visibility
$sql="select stafffname ||' ' || stafflname as staffname from tblstaff where staffid =".db_number($selectedstaff);
$ret=db_query($sql);
if($ret)
{
if(is_inactive_staff($selectedstaff))
$posttext=" (Inactive) ";
$row[sqldropdown][$selection][id]=$selectedstaff;
$row[sqldropdown][$selection][value]=$ret[0][staffname]." ".$posttext;
}
}
$stid=db_number($pegs[$key][staffid]);
$selectidops=$selboxidopts[$key];
if(!in_array($stid,$selectidops) && $stid!=0)
{
if(is_inactive_staff($stid))
$posttext=" (Inactive) ";
$row[sqldropdown][$selection][id]=$stid;
$row[sqldropdown][$selection][value]=mystaffname_fromid($stid)." ".$posttext;
}
//d($stid)
//d($row);
//if($row[groupname]=="BPO Coordinator")
// d($stid,$row);
if($row[groupname]=="")
{
//d($row);
continue;
}
?>
';
}
// this will onmy be editable by the above perms, but it can still be viewed by staff, just no editing... In Development JTrull 08272015
if ($enablebox){
?>
Name of Transaction Company Deduction
Amount
Type
//d($data['trx_company_deduction'],text_highlight("company deductions","red"));
if (is_array($data['trx_company_deduction'])){
foreach ($data['trx_company_deduction'] as $trxk =>$trxvalues){
//d($customfield_readonly,'$customfield_readonly');
?>
Commission: Fatal error: Uncaught Error: Call to undefined function dollar_format() in /data/webs/rio_api_dev/_inc/functions_customfield_ob.php:1483
Stack trace:
#0 {main}
thrown in /data/webs/rio_api_dev/_inc/functions_customfield_ob.php on line 1483