function myviews_display_javascript()
{
echo "
";
echo "";
}
function myviews_display_masterheader_return()
{
ob_start();
$master_header_nondisplay = myviews_display_masterheader();
$null = ob_get_clean();
unset($null);
return $master_header_nondisplay;
}
function myviews_display_masterheader()
{
if (is_developer() && $_GET[killmyviews])
{
unset($_SESSION['myviews']);
echo " click to reload last page ";
ddie("Developer, you made this die on purpose. Cookie Monster says: don't forget to eat cookie! ");
}
// Master Header will hold all the columns from different sources with the same parameters
$master_header = array();
global $display_assignmentmethod;
global $searcharray;
global $csv_export;
global $csv_row_cnt;
global $prop_roles;
// Add the static information
$master_header[] = array("type" => "static", "key" => "static_view", "label" => "View", "class" => "skip", "sortable" => 0, "addcsv" => 0, "centered" => 1);
if (clientcompanyid() )
'';
if (!clientcompanyid() && !client_portal() && !companyid() && !staffid()) //Added restriction to prevent master users from seeing column since it just shows their own company name for each property.
$master_header[] = array("type" => "static", "key" => "static_company", "label" => "Company", "class" => "", "sortable" => 0, "addcsv" => 1, "centered" => 0);
if (vendorid())
$master_header[] = array("type" => "static", "key" => "static_reason", "label" => "Display Reason", "class" => "", "sortable" => 0, "addcsv" => 1, "centered" => 0);
$master_header[] = array("type" => "static", "key" => "static_quicklinks", "label" => "Quick Links", "class" => "skip", "sortable" => 0, "addcsv" => 0, "centered" => 1);
if($_SESSION['myviews']['displaycolumns'] )
foreach ($_SESSION['myviews']['displaycolumns'] as $k=>$column)
{
if ($column[myviewscolumntype] == "special" && $column[myviewscolumnkey] == "propertyphoto")
$master_header[] = array("type" => $column[myviewscolumntype], "key" => $column[myviewscolumnkey], "label" => "", "class" => "hideable_column ", "sortable" => 0, "addcsv" => 0, "centered" => 1);
}
if(companyid() && !client_portal() && $showacquisitionsagentside)
{
if(is_mlsagentincompany())
{
$master_header[] = array("type" => "static", "key" => "static_acquisitionnotes", "label" => "Acquisition Notifications", "class" => "skip", "sortable" => 0, "addcsv" => 0, "centered" => 1);
$companymlsagent=true;
}
$directofferdetailslabel='Acquisition Details';
if($_GET[legendselect]=='propertyinescrow')
$directofferdetailslabel='Escrow Details';
if($_GET[legendselect]=='propertyclosed')
$directofferdetailslabel='Closing Details';
$master_header[] = array("type" => "static", "key" => "static_directofferdetails", "label" => "$directofferdetailslabel", "class" => "skip", "sortable" => 0, "addcsv" => 0, "centered" => 1);
if($companymlsagent)
$master_header[] = array("type" => "static", "key" => "static_acquisitionofferdate", "label" => "Offer Date", "class" => "skip", "sortable" => 0, "addcsv" => 0, "centered" => 1);
}
// Go through the myview displaycolumns
if($_SESSION['myviews']['displaycolumns'] )
$agentgoups = db_query("select groupname
, lower(groupname) as shortname
from tblgroup
where 0=0
and group_companyid in (0,-1, ".companyid().")
",1,0,shortname);
if (is_array($_SESSION['myviews']['displaycolumns']))
foreach ($_SESSION['myviews']['displaycolumns'] as $k=>$column)
{
if ($column[myviewscolumntype] == "propertyfield")
$master_header[] = array("type" => $column[myviewscolumntype], "key" => $column[myviewscolumnkey], "label" => $_SESSION[myviews][columnslabels][$column[myviewscolumnkey]][label], "class" => "hideable_column ", "sortable" => 1, "addcsv" => 1, "centered" => 0);
elseif ($column[myviewscolumntype] == "propertyextension")
$master_header[] = array("type" => $column[myviewscolumntype], "key" => $column[myviewscolumnkey], "label" => $_SESSION[myviews][columnslabels][$column[myviewscolumnkey]][label], "class" => "hideable_column ", "sortable" => 1, "addcsv" => 1, "centered" => 0);
elseif ($column[myviewscolumntype] == "special" && $column[myviewscolumnkey] == "searchedcolumns")
{
if (is_array($searcharray[searchfield]) && !empty($searcharray[searchfield]))
foreach ($searcharray[searchfield] as $search_key => $searchvalue)
{
// Skip if they didn't type a search value
if ($searchvalue == "")
continue;
$master_header[] = array("type" => $column[myviewscolumntype], "key" => "searchedcolumns_".$search_key, "label" => $_SESSION[myviews][columnslabels][$search_key][label], "class" => "", "sortable" => 1, "addcsv" => 1, "centered" => 0);
}
}
elseif ($column[myviewscolumntype] == "agentgroup" && companyid() && !client_portal() )
{
if ($agentgoups[$column[myviewscolumnkey]]){
$master_header[] = array("type" => $column[myviewscolumntype], "key" => "searchedcolumns_".$search_key, "label" => $agentgoups[$column[myviewscolumnkey]][groupname], "class" => "", "sortable" => 1, "addcsv" => 1, "centered" => 0);
}
}
elseif ($column[myviewscolumntype] == "special" && $column[myviewscolumnkey] == "propertyphoto")
; //Handled in loop above to put photo next to quicklinks.
elseif ($column[myviewscolumntype] == "special" && $column[myviewscolumnkey] == "listingagentphone" && is_mlsagent())
$master_header[] = array("type" => $column[myviewscolumntype], "key" => $column[myviewscolumnkey], "label" => "Acq MLS Listing Agent", "class" => "", "sortable" => 1, "addcsv" => 1, "centered" => 0);
elseif ($column[myviewscolumntype] == "special" && $column[myviewscolumnkey] == "assignto")
$master_header[] = array("type" => $column[myviewscolumntype], "key" => $column[myviewscolumnkey], "label" => "Assigned To", "class" => "hideable_column ", "sortable" => 1, "addcsv" => 1, "centered" => 0);
elseif ($column[myviewscolumntype] == "special" && $column[myviewscolumnkey] == "offers")
$master_header[] = array("type" => $column[myviewscolumntype], "key" => $column[myviewscolumnkey], "label" => "Offers", "class" => "hideable_column ", "sortable" => 1, "addcsv" => 1, "centered" => 0);
elseif ($column[myviewscolumntype] == "special" && $column[myviewscolumnkey] == "tasks")
$master_header[] = array("type" => $column[myviewscolumntype], "key" => $column[myviewscolumnkey], "label" => "Tasks", "class" => "hideable_column ", "sortable" => 1, "addcsv" => 1, "centered" => 0);
else
$master_header[] = array("type" => $column[myviewscolumntype], "key" => $column[myviewscolumnkey], "label" => $_SESSION[myviews][columnslabels][$column[myviewscolumnkey]][label], "class" => "hideable_column ", "sortable" => 1, "addcsv" => 1, "centered" => 0);
}
if (clientcompanyid() )
{
// Add the static columns on the end
if($display_assignmentmethod)
$master_header[] = array("type" => "static", "key" => "static_assignmentmethod", "label" => $display_assignmentmethod[assignmentmethodname], "class" => "", "sortable" => 1, "addcsv" => 1, "centered" => 0);
// -- These are set in my views change columns now
}
// Display the header
echo "";
foreach ($master_header as $k=>$head)
{
if($head['key']=='clientcompanyclientid') //Removing Client column at client request in task 22686 Mac
{
unset($master_header[$k]);
continue;
}
echo "
";
}
echo "";
// Write to the csv
$isfirst = 1;
foreach ($master_header as $k=>$head)
{
if (!$head[addcsv])
continue;
if ($isfirst == 1)
{
$isfirst = 0;
$csv_export[$csv_row_cnt] = '"'.$head[label].'"';
}
else
$csv_export[$csv_row_cnt] .= ',"'.$head[label].'"';
}
return $master_header;
}
function myviews_display_properties($master_header, $properties)
{
// Note: You'll need to deal with the way you retrieve the value depending on which side is using it
// Client side formats the $properties using:
// $property[] = fields are in root array
// $property[extensions] = Property Extentions are in sub array
//
// Broker side $properties has
// $property[] = fields are in root array
// $property[extensions] = Property Extentions are in sub array
//
global $csv_export;
global $display_assignmentmethod;
global $csv_row_cnt;
$property_page_hoa = array();
$property_page_offices = array();
if (companyid() && !client_portal()){
foreach ($properties as $key=>$val)
$prop[$val[propertyid]]=$val[propertyid];
if (count($prop)){
$tofferstatus = db_query("select propertyid
, (case when (select offercounterid
from tbloffercounter
where offerid = (select offerid from tbloffer where propertyid = tblproperty.propertyid and (tbloffer.offerstatus ilike 'New' or tbloffer.offerstatus is null or tbloffer.offerstatus='') limit 1)
order by offercounterid desc limit 1) >0 then 'In Negotiation'
else (select (case when offerid>0 then (case when (tbloffer.offerstatus ilike 'New'
or tbloffer.offerstatus is null
or tbloffer.offerstatus='')
then 'New' else tbloffer.offerstatus end)
else '' end) as offerstatus
from tbloffer where tblproperty.propertyid = propertyid
order by offerid desc limit 1)
end) as offerstatus
from tblproperty where propertyid in (" . implode ("," , $prop) . ")
order by propertyid asc",1,0,propertyid);
foreach ($tofferstatus as $propid => $data){
if ($data[offerstatus])
$offerstatus[$propid]=$data[offerstatus];
}
unset($tofferstatus);
$tallagentsinproperties = db_query("select
(select stafffname || ' ' ||stafflname from tblstaff where staffid=tblpropertygroupstaff.staffid) as name
, groupname as group
,propertyid
from tblpropertygroupstaff
join (
select lower(groupname) as groupname
, groupid from tblgroup
where 0=0
and group_companyid in (0,-1, ".companyid().")
) as tblgroup using (groupid)
where propertyid in (" . implode (",",$prop) . ") and staffid >0 and groupid <>7");
unset ($prop);
foreach ($tallagentsinproperties as $key=>$data){
$out[$data[propertyid]][$data[group]]=$data[name];
}
}
unset ($tallagentsinproperties);
foreach ($properties as $key=>$property){
if ($out[$property[pid]]){
if (is_array($out[$key]))
$properties[$key]=array_merge($properties[$key],$out[$key]);
}
}
unset($out);
}
// To reduce sql hits get HOA and Office Locations here
$display_hoa = 0;
$display_offices = 0;
foreach($master_header as $k=>$head)
{
if ($head[key] == hoaid || $head[key] == hoa2id || $head[key] == hoa3id)
$display_hoa = 1;
if ($head[key] == officelocationid)
$display_offices = 1;
if ($head[key] == utility_list)
$display_utilities = 1;
}
if (!empty($properties))
{
foreach ($properties as $k=>$prop)
{
if ($prop[propertytransactiontype])
$properties[$k][propertytransactiontype] = ucwords($prop[propertytransactiontype]);
if (db_number($prop[hoaid]) > 0)
$hoaid_arr[] = $prop[hoaid];
if (db_number($prop[hoa2id]) > 0)
$hoaid_arr[] = $prop[hoa2id];
if (db_number($prop[hoa3id]) > 0)
$hoaid_arr[] = $prop[hoa3id];
if (db_number($prop[extension][hoaid][propertyextensionentryvalue]) > 0)
$hoaid_arr[] = $prop[extension][hoaid][propertyextensionentryvalue];
if (db_number($prop[extension][hoa2id][propertyextensionentryvalue]) > 0)
$hoaid_arr[] = $prop[extension][hoaid][propertyextensionentryvalue];
if (db_number($prop[extension][hoa3id][propertyextensionentryvalue]) > 0)
$hoaid_arr[] = $prop[extension][hoaid][propertyextensionentryvalue];
if (db_number($prop[officelocationid]) > 0)
$officeid_arr[] = $prop[officelocationid];
}
if ($display_hoa && !empty($hoaid_arr))
{
$hoaid_arr = array_unique($hoaid_arr);
$property_page_hoa = hoa_get_hoaname_array($hoaid_arr);
}
if ($display_offices && !empty($officeid_arr))
{
$officeid_arr = array_unique($officeid_arr);
$sql = "select *
from tblofficelocation
where officelocationid in (
". implode(',', $officeid_arr) ."
) ";
if(companyid())
$sql.=" and companyid = ".companyid();
elseif(accountid())
$sql.=" and accountid = ".accountid();
$sql.=" order by officelocationid ";
$property_page_offices = db_query($sql,1,0,officelocationid);
}
}
// Get the list of extensions that have customfield display function
if (clientcompanyid() || client_portal() )
{
$sql = "select propertyextensionkey as key, customfieldtypelayout, customfieldtypeattr1label
from tblclientcompanypropertyextension
join tblpropertyextension using (propertyextensionid)
join tblcustomfieldtype using(customfieldtypeid)
where customfieldtypelayout != ''
union
select myviewscolumnlabelfield as key, myviewscolumnlabellayout as customfieldtypelayout, myviewscolumnlabelattr1label as customfieldtypeattr1label
from tblmyviewscolumnlabel
where myviewscolumnlabellayout != ''
";
}
else
{
if(is_mlsagentincompany())
$companymlsagent=true;
$sql = "select propertyextensionkey as key, customfieldtypelayout, customfieldtypeattr1label
from tblpropertyextension
join tblcustomfieldtype using(customfieldtypeid)
where customfieldtypelayout != ''
union
select myviewscolumnlabelfield as key, myviewscolumnlabellayout as customfieldtypelayout, myviewscolumnlabelattr1label as customfieldtypeattr1label
from tblmyviewscolumnlabel
where myviewscolumnlabellayout != ''";
}
$customfieldlayout = db_query($sql,1,0, key);
$customfieldtypeinfo=get_customfieldtypeinfo();
global $customfield_viewonly_nextonly;
// We need to determine if the client company allowed the agent to view their property extension
if ( client_portal())
$current_available_columns = myviews_get_availablecolumns();
$myviews_propertyids_array = array();
$myviews_propertyids_csv = "";
if(is_array($properties) && !empty($properties))
foreach($properties as $key => $property)
$myviews_propertyids_array[$property[clientcompanypropertyid]] = db_number($property[clientcompanypropertyid]);
$myviews_propertyids_csv = implode (",",$myviews_propertyids_array);
echo "