";
}
return $display_result;
}else{
return false;
}
}
/**
* @name customfield_obstart
* @param string $name
* @return boolean
*/
function customfield_obstart($name)
{
global $customfield_ob_current;
$customfield_ob_current = $name;
ob_start();
}
/**
* @name customfield_obend
*/
function customfield_obend()
{
global $customfield_ob_current, $customfield_ob;
$customfield_ob[$customfield_ob_current] = ob_get_clean();
$customfield_ob_current=false; //
}
function customfield_ob_inprogress() //returns true if there is currently a customfield in progress
{
global $customfield_ob_current;
return $customfield_ob_current;
}
/**
* @name customfield_obget
* @param string $name
* @return boolean
*/
function customfield_obget($name)
{
global $customfield_ob;
if(!$customfield_ob[$name])
{
developer_error("Invalid customfield ($name) must be set by surrounding some text with customfield_obstart($name)"); // this change can be immediately migrated
return "
Invalid customfield ($name), must be set by surrounding some text with customfield_obstart($name); echo '...text...' '; customfield_obend();
";
}
return $customfield_ob[$name];
}
/**
* @name customfield_display_documentupload
* @param array $extarray
* @param array $ext2array
* @return boolean
*/
function customfield_display_documentupload($extarray,$ext2array='')
{
$pretty = 0;
if(!$extarray)
return;
if($extarray==1)
return; // no documents = 1, this is default value to ignore
if(!is_array($extarray))
{
$value=$extarray;
$extarray = $ext2array;
}
if(!$value)
$value = $extarray[propertyextensionentryvalue];
if(!$value)
$value = $extarray[value];
if(is_array($extarray))
{
if(!$value)
$value = $extarray[documentid];
if(!$value || !is_numeric($value ) )
return;
if($extarray[pretty])
$pretty = 1;
}
if( is_numeric($value) )
{
$qry = db_query("select *, documenttitle as title from tbldocument where documentid = " . db_number($value));
if(!$qry[0][documenttitle])
{
$qry1 = db_first("select notesubject from tblnote where notedocument1 =" .db_number( $value));
$qry[0][documenttitle] = $qry1[notesubject];
}
if(!$qry)
return " document $value deleted";
$urlpath = "/document/".getrelativedocumentdir($qry[0][documentid])."/{$qry[0][documentname]}";
$ext = strtolower(end (explode('.',$qry[0][documentname])));
$addedtext = icon($ext);
$title = $qry[0][documenttitle];
if(!$title)
$title = $qry[0][documentname];
$title = list_first($title,"-");
if($pretty)
$out = "$addedtext$title";
else
$out = "$addedtext{$title}";
return $out;
}
elseif($value)
return "Invalid File Uploaded ($value)";
else
return "No File Uploaded";
}
/**
* @name customfield_return
* @param string $type
* @param string $name
* @param string $value
* @param string $attr1
* @param string $attr2
* @param string $attr3
* @param string $attr4
* @param string $showonlyif
* @param string $extra1
* @param string $layout
* @return boolean
*/
function customfield_return($type,$name,$value,$attr1="",$attr2="",$attr3="",$attr4="",$showonlyif="",$extra1="",$layout="")
{
ob_start();
customfield($type,$name,$value,$attr1,$attr2,$attr3,$attr4,$showonlyif,$extra1,$layout);
$out = ob_get_clean();
return $out;
}
/**
* @name customfield_validatsavenewdoc
* @param string $downloadfilename
* @return boolean
*/
function customfield_validatsavenewdoc($downloadfilename)
{
if( $_GET[debug])
echo BREAKING_DEBUG;
$property = vault_getproperties($propertyid);
$path=vault_filepath($property,$_GET[download]);
if($path)
{
$type=$_GET[download];
if ($property[clientcompanyid])
db_exec("update tblarchive set archive{$type}downloadeddate = now() where clientcompanypropertyid = $propertyid");
else
db_exec("update tblarchive set archive{$type}downloadeddate = now() where propertyid = $propertyid");
$mime=mime_content_type ( $path);
$fn = "$_GET[download]-".loginusername()."-$property[address] $property[city]-".dt_format($property[archivebuildcompleteddate])."";
$fn=str_replace("/","_",$fn);
$fn=str_replace("@","_",$fn);
$fn=str_replace("!","_",$fn);
$fn=str_replace("'","",$fn);
$fn=str_replace('"',"",$fn);
//do not remove these headers
//http://support.microsoft.com/kb/316431
//ie has a requirement that makes it so that if you are downloading a file, it has to right it to the cache.
// and if you have a no-cache header (which our site does by default) then ie enforces that No cache directive over ssl
// by just making it private caching, then it will not attempt to use cache and break.
header("Cache-Control: private");
header("Pragma: private");
// END do not remove these headers
//header("Expires: " . date(DATE_RFC822,strtotime(" 30 minutes")));
header("Content-Disposition: attachment; filename=\"$fn.zip\"");
//exit;
// The PDF source is in original.pdf
readfile($path);
exit(123);
}
}
function customfield_placeholder($type,$name,$value,$placeholder,$otherattr,$id='',$attr1='',$attr2='')
{
if(!$id)
$id=$name;
customfield($type,$name,$value,$attr1," $attr2 data-name='$id' title='$placeholder' placeholder=\"$placeholder\" $otherattr id=\"$id\"");
}
/**
* @name customfield
* @param string $type
* @param string $name
* @param string $value
* @param string $attr1
* @param string $attr2
* @param string $attr3
* @param string $attr4
* @param string $showonlyif
* @param string $extra1
* @param string $layout
* @param array $propertyarr
* @return boolean
*/
function customfield($type,$name,$value,$attr1="",$attr2="",$attr3="",$attr4="",$showonlyif="",$extra1="",$layout="",$propertyarr="")
{ //extra1 comes from the propertyextensiontable so it is more easily extendable (no need to create a special customfieldtypeid for each type
timetrack_start(customfield,$name);
global $mtarr;
global $customfield_class;
$skipreadviewdisplayofvalue=FALSE;
if($type=="nofield")
return;
if(list_first($type,"_")=="ob" && $type != "ob")
{
$name=list_allbutfirst($type,"_");
$type="ob";
}
if(trim($customfield_class))
$input_class=" class='".$customfield_class." '";
if(!is_devsite() && !$type)
return;
if($_POST[$name])
{
$value = $_POST[$name];
}
if(is_array($value))
{
if(!$value)
$value="";
elseif($value[extension][$name])
$value = $value[extension][$name];
elseif(array_key_exists($name,$value))
$value = $value[$name];
elseif($type==mini_html_form)//
;
elseif(strstr($type,checkboxes))
;
elseif($type == 'propertyextension' || $type == 'custombox')
;
elseif($type == 'select box multi')
$value = $value;
else
$value=''; // some objects requirearrays
}
if($type==datepicker&&$value&&$extra1 != 'disablecontraint')
$value=dt_format($value);
$other = "";
$id = "";
$style = "";
//The following globals are to assure that on update is to be done if set.
global $customfield_readonly;
global $customfield_readonly_nextonly;
global $customfield_viewonly;
global $customfield_viewonly_nextonly;
global $customfield_edit_nextonly;
if (1 == 2)
{
d(customfield_readonly,$customfield_readonly);
d(customfield_readonly_nextonly,$customfield_readonly_nextonly);
d(customfield_viewonly,$customfield_viewonly);
d(customfield_viewonly_nextonly,$customfield_viewonly_nextonly);
}
if($showonlyif)
{
$showonlyif = trim($showonlyif);
}
if($customfield_viewonly||$customfield_viewonly_nextonly||$customfield_readonly||$customfield_readonly_nextonly)
{
ob_start(); //your d statements won't work after this is executed.
}
if ($showonlyif==$name)
{
if ($type=="yesnoradio")
$other = "onclick='show_hide_extension(this);";
else
$other = "onchange='show_hide_extension(this);";
if($type==mlist)
{
$other.="$attr4";
unset($attr4);
}
$other.="'";
echo "";
}
elseif ($showonlyif!=$name && $showonlyif!=""&&!$value)
{
$thisnm = "showonlyif_$name";
echo "";
$id = "id='$thisnm'";
}
if(count(explode("_",$showonlyif))>1)
{
$tmpvr=explode("_",$showonlyif);
$other.=" eval_vl=\"".$tmpvr[1]."\"";
}
if($input_class)
$other.=$input_class;
if ($type=='label')
{
$outvalue = $value;
echo $value;
}
elseif ($type=='number')
{
$outvalue = "".(int)$value;
echo (int)$value;
}
elseif ($type=='numberentry')
{
$outvalue = "".(int)$value;
echo "";
}
elseif($type==textbox)
{
$value = str_replace('"','"',$value);
echo "";
}
elseif($type == 'wysiwyg')
{
innova($name, $value, $attr1, $attr2, $attr3);
}
elseif($type == 'emailautocomplete')
{
// USAGE:
// To programmatically change the value with JS:
// emailAutocomplete_val(name, value);
// - name is the name used when creating the customfield type emailautocomplete.
// - value is the new value you want added to the field. Only valid emails will create labels.
// TODO:
// - When removing an email, it should only remove that email, not all matching emails.
// - Could update the cursor to trail behind the labels. Not too bad for the first row. Much more complicated for subsequent rows.
// - Ability to remove entrys from tblemailautocomplete
global $emailAutocomplete_count;
$emailAutocomplete_count++;
if($emailAutocomplete_count == 1){
?>
}
?>
X
}
elseif($type==timedatepicker)
{
global $timedatepicker_count;
$timedatepicker_count++;
$other .= " $attr2";
$thisid=$name;
$thisid = str_replace("%","",$thisid);
//using the extra1 to provide a default
//date/time if there is not a value there already
$defaulthour=0;
$defaultminute=0;
$defaultsecond=0;
if($attr3)
{
$defaulthour = list_first($attr3,":");
if(list_second($attr3,":"))
$defaultminute=list_second($attr3,":");
if(list_item($attr3,3,":"))
$defaultsecond=list_item($attr3,3,":");
}
if ($extra1 && !$value)
$value = $extra1;
$value=dttime_format($value);
echo "
";
}
elseif($type==propertyextension)
{
$sql = "select * from tblpropertyextension join tblcustomfieldtype using(customfieldtypeid) where propertyextensionkey = '".$attr1."'";
$cf = db_first($sql);
$typename = $cf[customfieldtypename];
if($typename == ob && $name!=$attr1)
$typename="ob_$attr1";
$outvalue= customfield_return($typename,$name,$value,($cf[propertyextensionextra1] ? $cf[propertyextensionextra1] : $cf[customfieldtypeattr1label]),$cf[customfieldtypeattr2label],$cf[customfieldtypeattr3label],$cf[customfieldtypeattr4label]);
echo $outvalue;
}
elseif($type==password)
{
echo "";
}
elseif($type==ssn)
{
echo "";
}
elseif($type==ob)
{
if($name=='propertyextensionpropertyaddress')
$skipreadviewdisplayofvalue=TRUE;
$fn_name = "customfield_extension_$name";
if(function_exists($fn_name))
{
if ($showonlyif)
app_set('showonlyif',$showonlyif);
$fieldcontents = $fn_name($value,$propertyarr);
echo "
";
if($allow_existing_propertydocuments_id&&!$value) //only show this option, if a properyt document has not already been chosen
{
global $property_document_list;
$sql = "select documentid as id, documenttitle as value
from tmp_property_documents
join tbldocument using (documentid, propertyid)
where documenttitle is not null ";
if(companyid())
$sql .= " and (propertyid = ".db_number($allow_existing_propertydocuments_id).") ";
elseif (clientcompanyid())
$sql.=" and ( clientcompanypropertyid = ".db_number($allow_existing_propertydocuments_id).")";
if($extra1[documentswithoutofferid])
$sql.=" and (tbldocument.offerid is null or tbldocument.offerid = 0 )";
if(!$property_document_list[$allow_existing_propertydocuments_id])
$property_document_list[$allow_existing_propertydocuments_id] = db_query($sql );
if($property_document_list[$allow_existing_propertydocuments_id] )
{
echo "
Choose an Existing Document
";
customfield(sqldropdown,$name."_use_existing_documentid",'',$property_document_list[$allow_existing_propertydocuments_id] ,'[select a document]');
echo ";
";
}
}
echo "
";
if($value>1)
{
$outvalue=customfield_display_documentupload(array(propertyextensionentryvalue=>$value ));
// Pass the current doc id so that if the person saves without uploading a document
// then the previous document isn't overwritten.
echo "";
echo $outvalue;
if(strstr($name,propertyextension))
{
echo " Remove
";
}
}
else
echo "".$outvalue;
echo "";
if($value==1)
$outvalue="";
}
elseif($type==fillablepdf)
{
$outvalue = "";
if (!$value)
$sql = "select *
from tbltasktemplatefieldversion join tbldocument using (documentid)
where tbltasktemplatefieldversion.tasktemplatefieldid = ".db_number($attr2[tasktemplatefieldid])."
order by tasktemplatefieldversionid desc
limit 1";
else
$sql = "select *
from tbltasktemplatefieldversion join tbldocument using (documentid)
where tbltasktemplatefieldversion.tasktemplatefieldid = ".db_number($attr2[tasktemplatefieldid])."
and tasktemplatefieldversionid = ".db_number($value)."
order by tasktemplatefieldversionid desc
limit 1";
$versionqry = db_first($sql);
if (!is_array($versionqry) || count($versionqry) == 0)
ddie("cf_fillablepdf was not able to find a pdf version id for tasktemplatefieldid: $attr2[tasktemplatefieldid]. Use the Task Template to upload fillable document.");
echo "Step 1. Download Form (Fillable PDF):";
echo "{$versionqry[documentname]}";
// Only show this when we are in the custom because we display the table below in both read and edit mode
if($customfield_viewonly||$customfield_viewonly_nextonly||$customfield_readonly||$customfield_readonly_nextonly)
{
$outvalue .= "Form (Fillable PDF):";
$outvalue .= customfield_display_documentupload($versionqry[documentid]);
}
// The only thing to save is the version id of the fillable document
echo "";
echo " Step 2. Open the pdf file and click Submit button to save.";
// Get previous revisions
$sql = "select distinct clienttaskid, tasktemplatefieldrevisionentryrevision, tasktemplatefieldrevisionentrycreateddate::date
from tbltasktemplatefieldrevisionentry
where clienttaskid = ".db_number($attr2[clienttaskid])."
order by tasktemplatefieldrevisionentryrevision";
$revisionarr = db_query($sql);
if (is_array($revisionarr) && count($revisionarr) != 0)
{
$outvalue .= "
Revision
Date
Downlod
";
foreach ($revisionarr as $k=>$revs)
{
$outvalue .= "
";
}
elseif($type==photoaddendum)
{
$fieldname = $name;
$savetoproperty = $attr1;
$processdir= 'upftp2' . loginid() . time();
// Pass in the fieldname so that we can group the photos together
if (is_array($attr2))
{
foreach($attr2 as $a=>$att) {
$getparam .= "&$a=".urlencode($att);
}
}
$getparam.="&uploadtype=addendum";
// Ignore the existing uploads for clienttasks because we're going to pull them below
if (!$attr2[clienttaskid] && !$attr2[clientcompanypropertyid])
$outvalue .= "";
$outvalue .= "
";
$outvalue .= "
";
// Get a list of currently uploaded files
if ($attr2[clienttaskid] && $attr2[clientcompanypropertyid])
{
$sql = "select * from tblimage
where clienttaskid = ".db_number($attr2[clienttaskid])."
and clientcompanypropertyid = ".db_number($attr2[clientcompanypropertyid])."
and photogroupnames = ".db_tick($attr2[albumname])."
order by imagetitle";
$imgarr = db_query($sql);
$outvalue .= "
";
if (empty($imgarr))
$outvalue .= "No photos uploaded yet.";
foreach ($imgarr as $k=>$img)
{
$outvalue .= "
Addendum
";
if (!$attr2[viewonly])
$outvalue .= "";
$outvalue .= "";
// New Line to fix the formatting issue when you remove the delete icon for IE
if ($attr2[viewonly])
$outvalue .= " ";
$outvalue .= customfield_return(text,"imagetitle[$img[imageid]]",$img[imagetitle], '','','');
$outvalue .= "
";
}
$outvalue .="
";
}
echo $outvalue;
}
elseif($type=='contacttype')
{
global $customfield_contacttype_count;
$customfield_contacttype_count++;
$contactid = $value;
$clienttypeid = $attr1;
$contacttypeid = $attr3;
?>
if($contacttypeid || ($clienttypeid && ($clienttypeid!=-1))){
$sql = "select clienttypegroupid
from tblclienttype
where clienttypeid in (select clienttypeid
from tblcontacttype
where contacttypeid = " . db_number($contacttypeid) . ")
" . ($clienttypeid ? "
or clienttypeid in (" . $clienttypeid . ")"
: "") . "
and clienttypeshowall > 0";
$showall = db_first($sql);
}
if($showall){
$sql = "select clienttypeid
from tblclienttype
where clienttypegroupid = " . $showall['clienttypegroupid'] . "
and (companyid = " . companyid() . "
or companyid = 0)";
$clienttypeids2 = db_query($sql);
$clienttypeids = '';
foreach($clienttypeids2 as $key => $val)
$clienttypeids .= ($key ? ',' : '') . $val['clienttypeid'];
}
$sql = "select *
from tblcontact_contacttype
where contactid = " . db_number($contactid);
$contact_contacttypes = db_query($sql,'','','contacttypeid');
$sql = "select *
from tblcontacttype
where (companyid = 0
or companyid = " . companyid() . ")";
// THIS IS ONLY USED WHEN THE CLIENT TYPE HAS SHOWALL SET IN THE DB
if($clienttypeids)
$sql .= "
and (
0=0
--clienttypeid in (" . db_col($clienttypeids) . ") -- Commented this so classifications can be used by more than one clienttype
or contacttypeid in (select contacttypeid
from tblcontact_contacttype
where contactid = " . db_number($contactid) . ")
)";
// THIS IS USED IF MULTIPLE CLIENT TYPES ARE PASSED INTO THE FUNCTION
else if($clienttypeid && ($clienttypeid!=-1))
$sql .= "
and (
0=0
--clienttypeid in (" . db_col($clienttypeid) . ") -- Commented this so classifications can be used by more than one clienttype
or contacttypeid in
(
select contacttypeid
from tblcontact_contacttype
where contactid = " . db_number($contactid) . "
)
)";
else if($contacttypeid)
$sql .= "
and contacttypeid in (" . db_col($contacttypeid) . ")";
$contacttypes = db_query($sql);
$clienttypegroupid = $contacttypes[0]['clienttypegroupid'];
echo "
";
}
elseif($type=='contact_addstaff')
{
global $addstafftocontact;
$addstafftocontact=true;
customfield('contact',$name,$value,$attr1,$attr2,$attr3,$attr4,$showonlyif,$extra1,$layout,$propertyarr);
}
elseif($type=='staff_addcontact')
{
global $addcontacttostaff;
$addcontacttostaff=true;
customfield('contact',$name,$value,$attr1,$attr2,$attr3,$attr4,$showonlyif,$extra1,$layout,$propertyarr);
}
elseif($type=='contact')
{
global $addstafftocontact, $addcontacttostaff;
$contact_type = $attr1;
$filter_clienttypegroupid = $attr3;
$autolaunch_add = $extra1['autolaunch_add'];
$autolaunch_display = $extra1['autolaunch_display'];
$display_only = $extra1['display_only'];
$hide_add = $extra1['hide_add'];
$hide_clientname = $extra1['hide_clientname'];
$hide_primary = $extra1['hide_primary'];
$allow_client_add = $extra1['allow_client_add'];
$filter_clientid = $extra1['clientid'];
$filter_clientcompanyclientid = $extra1['clientcompanyclientid'];
$clienttypeids = $extra1['clienttypeid'];
$filter_clienttypeshortname = $attr2;
$filter_contacttypeid = $extra1['contacttypeids'];
$filter_contactid = $extra1['contactid'];
if(clientcompanyid())
{
$hide_add = 1;
}
if($contact_type == 'hoa'){
// GET CONTACTS FOR HOA ** THIS IS A DIFFERENT SELECT, AS THIS DATA IS NOT A TRUE CONTACT IN tblcontact, WE'RE JUST BORROWING THE CUSTOMFIELD
$sql = "SELECT hoaid as contactid,
hoaname as contactname,
hoacontact as contactcname,
'hoa' as contact_custom
FROM tblhoa
WHERE companyid = " . companyid() ."
AND hoainactive is null
ORDER BY hoaname, hoacontact";
}else if($contact_type == 'client'){
$sql = "SELECT clientid as contactid,
clientcompanyname as contactname,
clientfname || ' ' || clientlname as contactcname,
'client' as contact_custom
FROM tblclient
WHERE companyid = " . companyid() ."
AND clientinactive is null
ORDER BY clientcompanyname, clientfname";
}else{
// GET CONTACTS FOR THIS COMPANY
$sql = "select --*
contactid
, contactcname
, contactfname
, contactlname
, clienttypegroupid
, clientcompanyname
, clienttypeid
, clienttypeshortname
, contacttype
from tblcontact
left join tblclient using(clientid)
left join tblclienttype using(clienttypeid)
";
if (clientcompanyid())
$sql .= " where (tblcontact.clientcompanyid = " . clientcompanyid();
if (companyid())
$sql .= " where (tblcontact.companyid = " . companyid();
$valuecheck=str_replace("_c", "", $value);
if($valuecheck>0 && (companyid() || clientcompanyid()))
$sql.=" or tblcontact.contactid = ".db_number($valuecheck).") ";
else if ((!($valuecheck>0)) && (companyid() || clientcompanyid()))
$sql .=" )";
if (!companyid() && !clientcompanyid())
$sql .= " where tblcontact.contactid = ".db_number($valuecheck);
$sql .= "
and contactinactive is null
and clientinactive is null ";
if ($filter_clientid && $filter_clientid>0)
$sql .=" and clientid = ".db_number($filter_clientid);
if ($filter_clienttypeshortname)
$sql .=" and clienttypeshortname = '".db_col($filter_clienttypeshortname)."'";
if ($filter_contactid)
$sql .= "and contactid = ".db_number($filter_contactid);
$sql .="
and trim (contactcname) <> ''
order by " . (!$clientid ? "clientcompanyname, " : "") . "contactcname";
}
$contacts = db_query($sql);
//d('$contacts',$contacts);
global $glbcontacttypes;
// ADD CONTACT TYPE INFO
foreach($contacts as $key => $contact)
if(!$glbcontacttypes[$contact[contactid]])
$cntid[$contact[contactid]]=$contact[contactid];
if ($cntid)
$cntcs = implode(",",$cntid);
if ($cntcs)
{
$sql = "select *
from tblcontact_contacttype
join tblcontacttype using (contacttypeid)
where contactid in (".$cntcs.")
order by contactid";
$qrycontacttypes = db_query($sql,0,1,contactid);
foreach($qrycontacttypes as $contactid=>$contacttype)
$glbcontacttypes[$contactid]=$contacttype;
}
// New optimized code
if (!empty($glbcontacttypes) && !$filter_contactid){
foreach ($contacts as $key=>$contact){
if ($glbcontacttypes[$contact[contactid]] )
$contacts[$key]['contacttypes'] = $glbcontacttypes[$contact[contactid]];
}
}
// End
if (!clientcompanyid() && !$filter_contactid)
{
foreach ($contacts as $key=>$contact)
{
if (!is_array($contact['contacttypes']) || (!$contact[clienttypeid] || ($contact[clienttypeid]==-1))){
if (($filter_clientid && $contact['clientid'] != $filter_clientid) && (!$contact[clienttypeid] || ($contact[clienttypeid]==-1)) && !$contact[contacttypes][contacttypeid]){
unset($contacts[$key]);
}
}
}
}
// FILTER BY CLIENT TYPE SHORTNAME
if($filter_clienttypeshortname){
foreach($contacts as $key => $contact){
if($contact['clienttypeshortname'] != $filter_clienttypeshortname)
unset($contacts[$key]);
}
}
if($filter_clienttypegroupid){
foreach($contacts as $key => $contact){
if($contact['clienttypegroupid'] != $filter_clienttypegroupid)
unset($contacts[$key]);
}
}
// FILTER BY CONTACT TYPE
if($filter_contacttypeid){
$sql = "select contacttypeid
from tblcontacttype
where contacttypeid in (" . $filter_contacttypeid .")";
$result = db_query($sql,'','','contacttypeid');
foreach($contacts as $key => $contact){
unset($found);
foreach($result as $key=>$contacttype){
if (!$contact['contacttypes'])
continue;
if(array_key_exists($contacttype['contacttypeid'],$contact['contacttypes']))
$found = 1;
}
if(!$found)
unset($contacts[$key]);
}
}
// FILTER BY CONTACT
if($filter_contactid){
foreach($contacts as $key => $contact){
if($contact['contactid'] != $filter_contactid)
unset($contacts[$key]);
}
$contacts = array_values($contacts); // REINDEX THE ARRAY, SINCE WE'VE ONLY GOT ONE VALUE LEFT
}
?>
if(companyid())
{
$sql = "select *
from tblclient
left join tblclienttype using(clienttypeid)
where tblclient.companyid = " . companyid();
if($filter_contacttypeid)
$sql .= "
and (clienttypeid in(select tblclienttype.clienttypeid
from tblclienttype
join (select
distinct clienttypeid,
clienttypename,
tblclienttype.clienttypegroupid,
clienttypeshowall
from tblclienttype
join tblcontacttype using(clienttypeid)
where contacttypeid in (" . $filter_contacttypeid . ")
) ct
on (ct.clienttypeid = tblclienttype.clienttypeid
or (ct.clienttypegroupid = tblclienttype.clienttypegroupid
and ct.clienttypeshowall = 1))
)
or clienttypeid = -1)";
if($filter_clientid){
$sql .= "
and clientid = " . $filter_clientid;
}
if($filter_clienttypeshortname){
$sql .= "
and clienttypeshortname = '" . db_col($filter_clienttypeshortname) . "'";
}
$sql .= "
order by clientcompanyname";
$clients = db_query($sql);
}
else if(clientcompanyid())
{
$sql = "select *
from tblclientcompanyclient
where clientcompanyclientid = " . db_number($extra1['clientcompanyclientid']);
$clientcompanyclient = db_first($sql);
}
if(!$filter_clientid && companyid()){
//all users are be able to enter company name instead of being redirected to client.php.
//free invited users get to type in the company name / clientname_add field since they can not directly access the company
?>
}
else
{
if(companyid())
{
echo "";
echo $clients[0]['clientcompanyname'];
}
else if(clientcompanyid())
{
echo "";
echo $clientcompanyclient['clientcompanyclientname'];
}
}
?>
//All users could enter company name in input box instead of being redirected to client.php
//free invites get to add the client here since they can not get to client.php
?>
$sql = db_query("select name as id, name as value from tblstate");
customfield('sqldropdown','contactstate',$results[0]['contactstate'],$sql,'[select a state]',' class="' . $name . '_contact_form_input" ',$client[$key]);
?>
>
Zip
>
Phone
>
Cell Phone
>
Phone Ext.
>
Fax
>
Email
>
Website
* Required
$sql = "select *
from tblcontact
left join tblclient
using (clientid)
where contactid = " . db_number($value);
$contact = db_first($sql);
$outvalue = '
';
$outvalue .= '
Company:
' . $contact['clientcompanyname'] . '
';
$outvalue .= '
First Name:
' . $contact['contactfname'] . '
';
$outvalue .= '
Last Name:
' . $contact['contactfname'] . '
';
$outvalue .= '
Phone:
' . $contact['contactphone'] . '
';
$outvalue .= '
Email:
' . $contact['contactemail'] . '
';
$outvalue .= '
Address:
' . $contact['contactaddress'] . '
';
$outvalue .= '
Address 2:
' . $contact['contactaddress2'] . '
';
$outvalue .= '
City:
' . $contact['contactcity'] . '
';
$outvalue .= '
State:
' . $contact['contactstate'] . '
';
$outvalue .= '
Zip:
' . $contact['contactzip'] . '
';
$outvalue .= '
';
if (clientcompanyid())
$outvalue=" ";
if (!$contact)
$outvalue=" ";
}
elseif($type=='contact2')
{
$clienttypegroups = clienttypegroups_get();
foreach($clienttypegroups as $kk =>$ct)
if(!$ct[clienttypegroupcontacttypeonly])
unset($clienttypegroups[$kk]);
$clienttypes = clienttypes_get();
$contacttypes = contacttypes_get();
?>
Loading...
if($value)
echo "";
?>
//setTimeout needs to be at the end because it should NOT execute until the contact picker is setup, the code works when the pag is note loaded through AJAX, but this works for AJAX
}
elseif($type=='mlist')
{
global $mlist_clientcompanyid_next, $mlist_clientcompanyid;
$clientcompanyid = clientcompanyid();
if($mlist_clientcompanyid_next) //create a hack which makes it so that we can set a global which makes it so that the clientcompanyid is set for when agents need to use the clientocmpanyid mlist (task templates, etc)
{
$clientcompanyid = $mlist_clientcompanyid_next;
$mlist_clientcompanyid_next =0;
}
if($mlist_clientcompanyid) //create a hack which makes it so that we can set a global which makes it so that the clientcompanyid is set for when agents need to use the clientocmpanyid mlist (task templates, etc)
{
$clientcompanyid = $mlist_clientcompanyid;
}
$extraoption = $attr2;
// GET mLIST TYPE ID
$qry = "SELECT mlisttypeid, mlisttypetrackrank FROM tblmlisttype WHERE mlisttypeshortname = '" . db_col($attr1) . "' ";
if($clientcompanyid)
$qry .= " and (clientcompanyid =0 or clientcompanyid = $clientcompanyid) ";
else
$qry .= " and clientcompanyid =0 "; //do not let a non clientcompany load a list that belongs TO a client company
// REMOVED ONCE ALL mLIST CUSTOMFIELDS HAVE BEEN CHANGED TO USE SHORTNAME
$mlisttypeid = db_first($qry);
//d($mlisttypeid,'$mlisttypeid');
if(!$mlisttypeid){
d('Error: That mList shortname does not exist in the database.');
echo "Invalid Select Box '$attr1'";
}
else
{
// GET mLIST VALUES
if($mlisttypeid[mlisttypetrackrank])
$addorderby = " mlistrank, ";
$qry2 = "
SELECT mlistvalue as id
, mlistvalue as value
FROM tblmlist
WHERE mlisttypeid = $mlisttypeid[mlisttypeid]
order by $addorderby mlistvalue
";
$results = db_query($qry2);
}
if(!$results)
$results=array();
$found = 0;
foreach($results as $k=>$row)
if($row[id]==$value)
$found=1;
echo "";
}
elseif($type=='propertystatus')
{
$assignmenttypes = explode (",",PROPERTYASSIGNMENTTYPES);
$transactiontypes[]='listing';
$transactiontypes[]='sale';
$jassignmenttypes=json_encode($assignmenttypes);
$jtransactiontypes=json_encode($transactiontypes);
$transactiontype='listing';
$assignmenttype='REO';
$displayallpropertystatus=FALSE;
if($extra1 && !is_array($extra1) && $extra1=='displayall')
$displayallpropertystatus=TRUE;
elseif(is_array($extra1))
{
if(in_array($extra1['transactiontype'],$transactiontypes))
$transactiontype=$extra1['transactiontype'];
if(in_array($extra1['assignmenttype'],$assignmenttypes))
$assignmenttype=$extra1['assignmenttype'];
}
$extraoption = $attr2;
// GET mLIST TYPE ID
$qry = "SELECT mlisttypeid
FROM tblmlisttype
WHERE mlisttypeshortname = '" . db_col($attr1) . "'
and clientcompanyid =0 "; //do not let a non clientcompany load a list that belongs TO a client company
$mlisttypeid = db_first($qry);
if(!$mlisttypeid){
d('Error: That mList shortname does not exist in the database.');
echo "Invalid Select Box '$attr1'";
}
else
{
// GET mLIST VALUES
$qry2 = "SELECT mlistvalue as id, mlistvalue as value FROM tblmlist WHERE mlisttypeid = " . $mlisttypeid['mlisttypeid'];
$results = db_query($qry2);
}
if(!$results)
$results=array();
$sql="select *
from tblpropertystatusvisibilityentry
join tblmlist using (mlistid)
where 0=0
";
$propertystatusvisibilityentry=db_query($sql);
$currentvisibilitylist=array();
foreach($propertystatusvisibilityentry as $psvekey=>$psveinfo)
if($psveinfo['propertystatusvisibilityentryvalue'])
$currentvisibilitylist[$psveinfo['transactiontype']][$psveinfo['mlistvalue']][$psveinfo['assignmenttype']]=$psveinfo['propertystatusvisibilityentryvalue'];
$jcurrentvisibilitylist=json_encode($currentvisibilitylist);
$jpropertystatusmlist=json_encode($results);
$found = 0;
foreach($results as $k=>$row)
if($row[id]==$value)
$found=1;
$results=db_sort($results,value,"");
echo "";
echo "";
}
elseif($type=='custombox')
{
d('customfield '.$type);
global $custombox_query;
$arr = explode(",",$attr1);
$found = 0;
foreach($arr as $v)
{
$spl[strtolower(trim($v))]=$v;
}
if(!is_array($custombox_query[$name]))
{
if($name==documenttype)
{
$custombox_query[$name] = company_getdocumenttypes();
}
elseif($name==utilitytype)
{
$custombox_query[$name] = company_getutilitytypes();
}
else
$custombox_query[$name] = db_query("select distinct propertyextensionentryvalue as value from tblpropertyextensionentry where propertyextensionentryvalue <> '' and propertyextensionkey = '$name' and propertyid in (select propertyid from tblproperty where companyid = {$_SESSION[login][companyid]})");
}
foreach($custombox_query[$name] as $k=>$row)
{
if($row[value]==="")
continue;
$spl[strtolower(trim($row[value]))]=$row[value];
}
// We normally have two items in the array
// 1 is the selected value
// 2 is the empty value
if (is_array($value))
foreach($value as $k=>$v)
{
if(strlen($v)!=0)
{
$value = $v;
break;
}
}
// Both item were empty
if (is_array($value))
$value = "";
foreach($spl as $k=>$v)
if($v==$value)
$found=1;
ksort($spl);
echo "
";
}
else if($type=='submit')
{
$roout = "";
return "";
}
elseif ($type=='datepicker')
{
global $datepicker_count;
$datepicker_count++;
$other .= " $attr2";
$thisid=$name;
$thisid = str_replace("%","",$thisid);
if ($extra1 == 'disablecontraint')
$datetime_contraint = " constrainInput: false ";
/**
* Backed out changes to datepicker that were put in place to provide unique id's (particular circumstances with modals and underlying pages
* were causing instances where fields with the same names were displayed on the same page causing javascript to break). The changes ended up
* causing more widespread issues across the website, so they were backed out to implement a different approach instead.
*/
echo "
";
}
elseif ($type=='datepickerlabeled')
{
global $datepicker_count;
$datepicker_count++;
$other .= " $attr2";
if (!is_array($attr1)) // Did they just pass in the label name
$attr1 = array('labelname' => $attr1);
$thisid=$name;
$thisid = str_replace("%","",$thisid);
$thisid_clean = str_replace('[]','',$thisid);
echo "
";
echo "
{$attr1[labelname]}:
";
}
elseif($type==hidden)
{
echo "";
}
elseif($type=='crmcontact_listbuilder')
{
include('crmcontact_listbuilder.php');
}
elseif($type=='html5upload')
{
$uploadtype=$attr1;
$full_ui=$attr2;
$callback=$attr3;
include('_html5uploader.php');
}
elseif($type=='clienttaskbid')
{
unset($outvalue);
$multi = $attr1;
$taskdata = $attr2;
$readonly = (($customfield_displayonly ||
$customfield_readonly ||
$customfield_readonly_nextonly ||
$customfield_viewonly ||
$customfield_viewonly_nextonly) ? 1 : 0);
$randomid = preg_replace("/[^A-z,0-9]/","",substr(base64_encode(time()+rand(123,453453452)),rand(0,2),rand(3,5)));
if ($readonly)
ob_start();
$taskid = $taskdata['clienttaskid'];
$biddata = db_query("SELECT * FROM tblclienttaskbid
LEFT JOIN (select documentname, documentid from tbldocument ) as d using(documentid)
WHERE clienttaskid = " . db_number($taskid) . "
ORDER BY clienttaskbidid");
$biddata[]=db_first("SELECT * FROM tblclienttaskbid
LEFT JOIN (select documentname, documentid from tbldocument ) as d using(documentid)
WHERE clienttaskid = 0
ORDER BY clienttaskbidid");
$tasktemplatefieldid = db_firstval("SELECT tasktemplatefieldid FROM tbltasktemplatefield WHERE tasktemplateid = (SELECT tasktemplateid from tblclienttask where clienttaskid= " . db_number($taskid) . ") and tasktemplatefieldtype='clienttaskbid'");
$fieldname = 'tasktemplatefield_' . $tasktemplatefieldid;
if (!$readonly)
{
?>
}
?>
>
Name
Amount
Document
if ($multi && !$readonly)
echo "
 
";
?>
$i = count($biddata);
foreach ($biddata as $k => $bid){
if ($readonly && $i == 1)
continue;
echo "
";
if (!$multi && !$bid['clienttaskbidname'])
$bid['clienttaskbidname'] = $taskdata['clienttasktitle'];
echo "
* Press <F5> or CMD+R (mac users) To refresh screen and see uploaded files before Completing the task. * Documents can only be uploaded if name or amount is present.
if (!$readonly)
echo "";
}
else
{
ddie("Invalid customfield type($type,$name,$value)");
}
$skipreadviewdisplayofvalue=FALSE;
if($type=='ob' && $name=='propertyextensionpropertyaddress')
$skipreadviewdisplayofvalue=TRUE;
if(($customfield_viewonly||$customfield_viewonly_nextonly) && !$customfield_edit_nextonly)
{
$customfield_viewonly_nextonly=0;
$out = ob_get_clean();
if(isset($outvalue))
$value = $outvalue;
if(is_array($value))
$value=implode(',',$value);
if ($out && !isset($outvalue) && $readonly)
$value = $out;
timetrack_stop("customfield_viewonly_echo",$name);
if(!$skipreadviewdisplayofvalue)
echo $value;
timetrack_stop("customfield_viewonly_echo",$name);
return;
}
if(($customfield_readonly || $customfield_readonly_nextonly) && !$customfield_edit_nextonly)
{
$customfield_readonly_nextonly=0;
$out = ob_get_clean();
echo "$out";
if(isset($outvalue))
$value=$outvalue;
if(is_array($value))
$value=implode(',',$value);
timetrack_stop("customfield_readonly_echo",$name);
if(!$skipreadviewdisplayofvalue)
echo "$value";
timetrack_stop("customfield_readonly_echo",$name);
timetrack_stop("customfield",$name);
return;
}
global $customfield_edit_nextonly;
if ($customfield_edit_nextonly)
$customfield_edit_nextonly=0;
//this "quickfix" makes it so that the mastertask only displayes once per page
global $display_propertyfield_tasks_called;
if(!$display_propertyfield_tasks_called[$name])
display_propertyfield_tasks($mtarr[$name], $value);
$display_propertyfield_tasks_called[$name]=1;
timetrack_stop("customfield",$name);
}
/**
* @name display_propertyfield_tasks
* @param array $tasks
* @param integer $selected_value
* @return boolean
*/
function display_propertyfield_tasks($tasks, $selected_value)
{
if(!$tasks)
return;
echo "";
$br = 1;
$mtidlist="";
$mt=array();
//Start of Optimization to replate call to has_mastertaskassignment($task[mastertaskid])) for each masterautotask
//with array built up for all masterautotasks being checked that are assigned to someone with valid email.
foreach($tasks as $task)
{
if(!$task[taskname] && $task[mastertaskid])
$mtidlist.=",".$task[mastertaskid];
$mtidlist=trim($mtidlist,',');
}
if($mtidlist)
{
$sql = "
select mastertaskid, mastertaskcompanyassignedstaffgroups, mastertaskcompanyassignedstaffids
from tblmastertask
join tblmastertaskcompany using (mastertaskid)
where mastertaskid in (".db_number_list($mtidlist).")
and tblmastertaskcompany.companyid = ".companyid()."
";
$mt = db_query($sql,1,0,'mastertaskid');
$mtcastaffgrouplist='';
$mtcastaffidlist='';
foreach($mt as $mastertaskid=>$mastertaskinfo)
{
$mt[$mastertaskid]['groupid']=array();
$mt[$mastertaskid]['staffid']=array();
$mtcastaffgrouparr=array();
$mtcastaffgroup=trim($mastertaskinfo['mastertaskcompanyassignedstaffgroups']);
if($mtcastaffgroup)
{
$mtcastaffgrouparr=explode(',',$mtcastaffgroup);
if($mtcastaffgrouparr)
{
$mtcastaffgrouplist.=','.$mtcastaffgroup;
foreach($mtcastaffgrouparr as $key=>$groupid)
$mt[$mastertaskid]['groupid'][$groupid]=1;
}
}
$mtcastaffgrouplist=trim($mtcastaffgrouplist,',');
$mtcastaffidarr=array();
$mtcastaffid=trim($mastertaskinfo['mastertaskcompanyassignedstaffids']);
if($mtcastaffid)
{
$mtcastaffidarr=explode(',',$mtcastaffid);
if($mtcastaffidarr)
{
$mtcastaffidlist.=','.$mtcastaffid;
foreach($mtcastaffidarr as $key=>$staffid)
$mt[$mastertaskid]['staffid'][$staffid]=1;
}
}
$mtcastaffidlist=trim($mtcastaffidlist,',');
}
if($mtcastaffgrouplist || $mtcastaffidlist)
{
$sql = "
select loginid, staffid, groupid
from tblstaffgroup
join tbllogin using (staffid)
where companyid = ".companyid()."
and logininactive is null
and
(
groupid in (".db_number_list($mtcastaffgrouplist).")
or staffid in (".db_number_list($mtcastaffidlist).")
)";
$lids = db_query($sql);
foreach($lids as $lidkey=>$logininfo)
{
if (trim(get_loginemailaddress($logininfo['loginid'])) == '')
continue;
foreach($mt as $mastertaskid=>$mastertaskinfo)
{
if($logininfo['groupid'] && in_array($logininfo['groupid'], array_keys($mt[$mastertaskid]['groupid'])))
$mt[$mastertaskid]['loginid'][$logininfo['loginid']]=1;
if($logininfo['staffid'] && in_array($logininfo['staffid'], array_keys($mt[$mastertaskid]['staffid'])))
$mt[$mastertaskid]['loginid'][$logininfo['loginid']]=1;
}
}
}
}
//End of Optimization to replate call to has_mastertaskassignment($task[mastertaskid])) for each masterautotask with check in array built up for all masterautotasks for tasks passed to function.
foreach($tasks as $task)
{
$disp="none";
if($selected_assignmenttype == $task[mastertaskassignmenttype] && $selected_value == $task[mastertaskfieldvalue])
$disp="";
if($br)
{
echo " ";
$br = 0;
}
echo "";
if($task[taskname] )
echo " ".button(box_checked)." $task[taskname]";
else if ($mt[$task['mastertaskid']]['loginid'])
echo " $task[mastertaskname] ";
else
echo " $task[mastertaskname] ";
if(is_developer())
echo " taskid: ".$task[mastertaskid];
echo " ";
}
echo "";
}
/**
* @name utility_list
* @param string $parr
* @param integer $form
* @param integer $COMPANYSIDE
* @return boolean
*/
function utility_list($parr, $form=0,$COMPANYSIDE=1 )
{
ob_start();
$utils = company_getutilitytypes();
echo "
";
if (!$parr)
{
$parr[extension]=$_POST;
}
if ($COMPANYSIDE || is_admin())
{
$sql = "select utilityid as id, utilityname as value, utilitytype from tblutility where 0=0";
if($parr[companyid])
$sql.=" and companyid = $parr[companyid] ";
elseif(companyid())
$sql.=" and companyid = ".companyid();
$qryu = db_query($sql);
}
if ($parr[clientcompanyid] || !$parr[companyid])
{
$utilsextensions = $parr[extension];
foreach ($utils as $util)
{
$t=$util[value];
$t=str_replace(" ","_",$t);
if ($parr[extension]["propertyextensionutility_$t"])
if (!is_array($parr[extension]["propertyextensionutility_$t"]))
$allutils.=$parr[extension]["propertyextensionutility_$t"].",";
else
if ($parr[extension]["propertyextensionutility_$t"][propertyextensionentryvalue])
$allutils.=$parr[extension]["propertyextensionutility_$t"][propertyextensionentryvalue].",";
}
$allutils=substr($allutils,0,-1); // strip last ,
$sql = "select utilityid as id, utilityname as value, utilitytype from tblutility where 0=0";
if ($allutils)
$sql.= " and utilityid in (".$allutils.") ";
if (!$qryu)
$qryu = db_query($sql);
}
foreach($qryu as $k=>$row)
{
$uarr[str_replace(" ","_",$row[utilitytype])][$row[id]]=$row;
$utilv[$row[id]]=$row[value];
}
unset($qryu);
foreach($utils as $util)
{
$t=$util[value];
$t=str_replace(" ","_",$t);
if ($parr)
$id=$parr[extension]["propertyextensionutility_$t"];
if (is_array($id))
$id=$parr[extension]["propertyextensionutility_$t"][propertyextensionentryvalue];
if(!$form &&!$id && !is_admin())
continue;
echo "
";
echo "Status:: ";
$offarr[y]="Utilities Left Off";
$offarr[""]="Utilities On ";
customfield('select box',"propertyextensionutility_{$t}_leftoff",$parr,$offarr);
echo " Account Number: ";
customfield(textbox,"propertyextensionutility_{$t}_accountnumber",$parr,10);
echo " Deposit Amount: ";
customfield(textbox,"propertyextensionutility_{$t}_depositamount",$parr,10);
echo " Date Req ON: ";
customfield(datepicker,"propertyextensionutility_{$t}_datereq_on",$parr);
if(!is_vendor())
{
echo " Date Verified: ";
customfield(datepicker,"propertyextensionutility_{$t}_dateverified",$parr);
}
echo " Date Req OFF: ";
customfield(datepicker,"propertyextensionutility_{$t}_datereq_off",$parr);
}
else
{
$display="";
$dates = "";
if(!$utilv[$id]||!$_POST["propertyextensionutility_$t"])
$display="none";
if (is_array($parr[extension]["propertyextensionutility_{$t}_leftoff"]))
{
if($parr[extension]["propertyextensionutility_{$t}_leftoff"][propertyextensionentryvalue] =='y')
$dates.="Utilities Left Off ";
else
$dates.="Utilities On ";
}
elseif($parr[extension]["propertyextensionutility_{$t}_leftoff"] =='y')
$dates.="Utilities Left Off ";
elseif ($utilv[$id])
$dates.="Utilities On ";
echo $parr[extension]["propertyextensionutility_{$t}_depositamount"][propertyextensionentryvalue];
if(is_array($parr[extension]["propertyextensionutility_{$t}_accountnumber"]))
{
$display="";
if ($parr[extension]["propertyextensionutility_{$t}_accountnumber"][propertyextensionentryvalue])
$dates.="Account Number: ". $parr[extension]["propertyextensionutility_{$t}_accountnumber"][propertyextensionentryvalue]." ";
}
elseif($parr[extension]["propertyextensionutility_{$t}_accountnumber"])
$dates.="Account Number: ". $parr[extension]["propertyextensionutility_{$t}_accountnumber"]." ";
if(is_array($parr[extension]["propertyextensionutility_{$t}_depositamount"]))
{
if(is_numeric($parr[extension]["propertyextensionutility_{$t}_depositamount"][propertyextensionentryvalue]))
$dates.="Deposit Amount: ". dollar_format($parr[extension]["propertyextensionutility_{$t}_depositamount"][propertyextensionentryvalue])." ";
else
$dates.="Deposit Amount: ". $parr[extension]["propertyextensionutility_{$t}_depositamount"][propertyextensionentryvalue]." ";
}
elseif($parr[extension]["propertyextensionutility_{$t}_depositamount"])
{
if(is_numeric($parr[extension]["propertyextensionutility_{$t}_depositamount"]))
$dates.="Deposit Amount: ". dollar_format($parr[extension]["propertyextensionutility_{$t}_depositamount"])." ";
else
$dates.="Deposit Amount: ". $parr[extension]["propertyextensionutility_{$t}_depositamount"]." ";
}
if (is_array($parr[extension]["propertyextensionutility_{$t}_datereq_on"]))
{
if($parr[extension]["propertyextensionutility_{$t}_datereq_on"][propertyextensionentryvalue])
$dates.="Date Req ON: ". $parr[extension]["propertyextensionutility_{$t}_datereq_on"][propertyextensionentryvalue]." ";
}
else if($parr[extension]["propertyextensionutility_{$t}_datereq_on"])
$dates.="Date Req ON: ". $parr[extension]["propertyextensionutility_{$t}_datereq_on"]." ";
if (is_array($parr[extension]["propertyextensionutility_{$t}_dateverified"]))
{
if($parr[extension]["propertyextensionutility_{$t}_dateverified"][propertyextensionentryvalue])
$dates.="Date Verified: ". $parr[extension]["propertyextensionutility_{$t}_dateverified"][propertyextensionentryvalue]." ";
}
else if($parr[extension]["propertyextensionutility_{$t}_dateverified"])
$dates.="Date Verified: ". $parr[extension]["propertyextensionutility_{$t}_dateverified"]." ";
if (is_array($parr[extension]["propertyextensionutility_{$t}_datereq_off"]))
{
if($parr[extension]["propertyextensionutility_{$t}_datereq_off"][propertyextensionentryvalue])
$dates.="Date Req OFF: ". $parr[extension]["propertyextensionutility_{$t}_datereq_off"][propertyextensionentryvalue]." ";
}
elseif($parr[extension]["propertyextensionutility_{$t}_datereq_off"])
$dates.="Date Req OFF: ". $parr[extension]["propertyextensionutility_{$t}_datereq_off"]." ";
if(!$dates)
$display="none";
else
unset($display);
echo "
$dates";
}
echo "
";
}
echo "
";
$outvalue =ob_get_clean();
return $outvalue;
}
/**
* @name icmp
* @param string $a
* @param string $b
* @return boolean
*/
function icmp($a, $b)
{
$a=strtolower($a);
$b=strtolower($b);
if ($a == $b) {
return 0;
}
return ($a < $b) ? -1 : 1;
}
/**
* @name loadsupplementdoc
* @param string $suppname
* @param string $supptype
* @param string $htmlname
* @param integer $staffid
* @return boolean
*/
function loadsupplementdoc($suppname, $supptype, $htmlname, $staffid)
{
$sql = "select nextval('tblstaffsupplement_staffsupplementid_seq') as staffsupplementid";
$next = db_first($sql);
$maxdocid = $next[staffsupplementid];
$sql = "insert into tblstaffsupplement
( staffsupplementid
,staffid
, staffsupplementname
, staffsupplementtype
)
values ( $maxdocid
,".db_tick($staffid)."
,".db_tick($suppname)."
,".db_tick($supptype)."
)";
db_exec($sql);
process_customfield_documentupload_type($maxdocid,'staffsupplement',$htmlname,$suppname,0,0,$suppname);
}
/**
* @name mini_html_form
* @param string $fieldname
* @param string $html
* @param integer $version
* @param string $value
* @return boolean
*/
function mini_html_form($fieldname, $html, $version='original',$value='')
{
if($value&&!is_array($value))
$value=unserialize($value);
//this custom form field, allows the user to paste in html content from some other program, then we will process that content by creating a form field that modifies the form field
//and gives a viewable status and a method to open the larger editor/preview
//use the simple dom parser to calculate how many of each field we have, this will help us have a display we can show instead of the content
$selectcount=0;
$inputcount=0;
$textareacount=0;
$html=str_replace("[LT]","<",$html);
$html=str_replace("[AMP]","&",$html);
$html=str_replace("[TICK]","'",$html);
$html=str_replace("[PLUS]","+",$html);
$usehtml = $html;
ob_start();
if($version=='original')
{
//only load the modal once
echo "
";
}
else
{
echo "
";
}
//this is setup to avoid the problems of htmlentities, we only replace the characters we are converned with // check _mini_html_form.php for the "other side" of the conversion
$characterount= strlen($html);
if(!$html)
{
echo "Embedded Form Not Setup ";
}
else
{
$html=str_replace("[LT]","<",$html);
$html=str_replace("[AMP]","&",$html);
$html=str_replace("[TICK]","'",$html);
$html=str_replace("[PLUS]","+",$html);
require_once("_inc/simple_html_dom.php");
$dom = str_get_html($html);
foreach($dom->find('input') as $input)
$inputs[$input->name]=$input;
foreach($dom->find('select') as $input)
$selects[$input->name]=$input;
foreach($dom->find('textarea') as $input)
$textareas[$input->name]=$input;
foreach($dom->find('script') as $input)
$scripts[$input->name]=$input;
echo "
$jsfield
";
$out[html]=$usehtml;
$out[formfield]=$formfield;
return $out;
}
/**
* Formats the time for the timedatepicker so the calendar is set correctly
* @param number $hour The hour of the day (24 hour clock)
* @param number $minute The minute of the hour
* @param number $second The second of the minute
* @return The time set for the current date to the provided time
*/
/**
* @name get_timepickerformat
* @param integer $hour
* @param integer $minute
* @param integer $version
* @param integer $second
* @return boolean
*/
function get_timepickerformat($hour=-1, $minute=-1, $second=-1)
{
$date = new DateTime(date("m/d/Y h:i a"));
$hour = ($hour < 0)?$date->format("H"):$hour;
$minute = ($minute < 0)?$date->format("i"):$minute;
$second = ($second < 0)?$date->format("s"):$second;
$date->setTime($hour, $minute, $second);
return $date->format("m/d/Y h:i a");
}
/**
* @name set_customfield_viewonly
* @param integer $value Must be a 1 or 0
*/
function set_customfield_viewonly($value)
{
if(($value!==1) && ($value!==0))
{
developer_error("set_customfield_viewonly, Invalid value passed to function");
return;
}
global $customfield_viewonly;
$customfield_viewonly=$value;
return;
}
/**
* @name set_customfield_viewonly_nextonly
* @param integer $value Must be a 1 or 0
*/
function set_customfield_viewonly_nextonly($value)
{
if(($value!==1) && ($value!==0))
{
developer_error("set_customfield_viewonly_nextonly, Invalid value passed to function");
return;
}
global $customfield_viewonly_nextonly;
$customfield_viewonly_nextonly=$value;
return;
}
function customfield_documentupload_cloudpicker_js()
{
if (!defined('DROPBOX_INCLUDED'))
{
define('DROPBOX_INCLUDED', '1');
?>
}
}
function customfield_documentupload_cloudpicker($name)
{
$rand="$name".rand(100000,10000000);
$rand_=$rand."_";
$out="
Google Drive
";
return $out;
}
include ("functions_customfield_ob.php");