0) { //this is a way that they can override upload the document and just use an exiting one see attribute 1 of customfield(documentupload,""); return $_POST[$fieldname."_use_existing_documentid"]; } $f = $_FILES[$fieldname]; $outarray=array(); $id=db_number($id); if(is_array($f[name])) { //create an indexed array foreach($f[name] as $fid =>$fieldname) foreach($f as $fieldkey=>$fieldarray) $outarray[$fid][$fieldkey] = $f[$fieldkey][$fid]; } else $outarray[] = $f; foreach($outarray as $index => $f) { //if we were provided an index and this is not that index, skip this one if ($documentindex >= 0 && $documentindex != $index) continue; if(!$f) // no file was uploaded return false, no uploade should be done continue; if($f[name] && $f[error]) ddie("Error uploading file!, click back and reupload",$f); if(!$f[name]) continue; $fname = $f[name]; $fname = websafe_filename($fname); if(!$title) $title =$extarray[title]; if (!$description) $description = $title; $tempname = $f[tmp_name]; if (!is_uploaded_file($tempname) && !file_exists($tempname)) ddie("There was a problem uploading the file $fname (a".__LINE__.").
".$tempname); if(!$documentloadedby) $documentloadedby = loginid(); $sql = "select nextval('tbldocument_documentid_seq') as documentid"; $next = db_first($sql); $maxdocid[] = $next[documentid]; $sql = " insert into tbldocument ( documentid , documenttitle , documentname , {$type}id , documentdescription , documentdateloaded , documentpublic , documentloadedby , documenttype , documentgroup"; if($workfloweventkey) $sql.= " , documentworkfloweventkey"; $sql.= " ) values ( $next[documentid] ,'".db_col($title)."' , '".db_col($fname)."' , $id , '".db_col($description)."' , now() , $documentpublic , $documentloadedby , '".db_col($documenttype)."' , '".db_col($documentgroup)."'"; if($workfloweventkey) $sql.= " , ".db_tick($workfloweventkey); $sql.= " )"; db_exec($sql,1); if (companyid()) { $propid=0; $propid = db_firstval ("select propertyid from tbldocument where documentid =" . $next['documentid']); if ($propid >0) update_documents_uploaded(0, $propid); } $dirname = getrelativedocumentdir($next[documentid]); $pathname = "$_SERVER[DOCUMENT_ROOT]/document/$dirname"; if(!mkdir_wrapper($pathname)) ddie("Server Configuration Issue: could not create directory : $pathname"); $docfile = $pathname.$fname; if (is_uploaded_file($tempname)) { if (!move_uploaded_file($tempname, $docfile)) ddie("
Server Configuration Issue: Could not write the file to the directory: $dirname$fname"); } else if(!file_exists($tempname)) { ddie("Server Configuration Issue: could not find file: $tempname"); exit(123); } else { rename_wrapper($tempname,$docfile); } } if(is_array($maxdocid)) $maxdocid = implode(",",$maxdocid); return $maxdocid; } /** * @name process_customfield_display_documentupload * @param integer $propertyid * @param string $fieldname * @param string $fieldvalue * @param array $extarray * @return boolean */ function process_customfield_display_documentupload($propertyid, $fieldname, $fieldvalue, $extarray) //needs to have 3 parametsrs { //extarray has details of the current fieldnames extesion object if($_POST[$fieldname."_use_existing_documentid"]>0) { //this is a way that they can override upload the document and just use an exiting one see attribute 1 of customfield(documentupload,""); return $_POST[$fieldname."_use_existing_documentid"]; } $f = $_FILES[$fieldname]; if(!$f) // no file was uploaded return false, no uploade should be done return false; if($f[name] && $f[error]) ddie("Error uploading file!, click back and reupload",$f); if(!$f[name]) if(!$fieldvalue) return false; else return $fieldvalue; // lets return the field value to give more control to the calling application to be able to update their document if(!$propertyid) $propertyid = 0; if($extarray[clientcompanypropertyid]) { $clientcompanypropertyid = $extarray[clientcompanypropertyid]; $propertyid = 0; } elseif(clientcompanyid() && $propertyid) { $clientcompanypropertyid = $propertyid; $propertyid = 0; } else $clientcompanypropertyid = 0; $fname = $f[name]; $fname = websafe_filename($fname); $title = $extarray[propertyextensionlabel]; if(!$title) $title =$extarray[title]; $tempname = $f[tmp_name]; $fs = @filesize($tempname); if(!$fs) return false; if (!is_uploaded_file($tempname)) // If this fails.... { if (!file_exists($tempname) && $f[error]==0) ddie("There was a problem uploading the file $fname (a".__LINE__.").
".$tempname); else $dontuse_phpmove=1; } $documenttype = "propertyupload"; if( $extarray[documenttype] ) $documenttype = $extarray[documenttype]; $documenttype_result = get_documenttype_byname($documenttype); $documenttypeid = $documenttype_result[documenttypeid]; if( $extarray[documenttypeid]>0 ) $documenttypeid = $extarray[documenttypeid]; if( $extarray[documentloadedby] ) $documentloadedby = $extarray[documentloadedby]; else $documentloadedby = loginid(); if($extarray[documentgroup]) $documentgroup = $extarray[documentgroup]; $sql = "select nextval('tbldocument_documentid_seq') as documentid"; $next = db_first($sql); $maxdocid = $next[documentid]; $sql = " insert into tbldocument ( documentid , documenttitle , documentname , propertyid , offerid , documentdescription , documentdateloaded , documentpublic , documentloadedby , documenttypeid , documentgroup , clientcompanypropertyid ) values ( $maxdocid , ".db_tick($title)." , ".db_tick($fname)." , $propertyid , ".($extarray[offerid] ? pg_escape_string($extarray[offerid]) : 'NULL' )." , '".db_col($extarray[propertyextensionextra1]?$extarray[propertyextensionextra1]:$title)."' , now() , 0 , $documentloadedby , $documenttypeid , ".db_tick($documentgroup)." , ".db_number($clientcompanypropertyid)." )"; db_exec($sql,1); $dirname = getrelativedocumentdir($maxdocid); $pathname = "$_SERVER[DOCUMENT_ROOT]/document/$dirname"; if(!mkdir_wrapper($pathname)) { echo "
Server Configuration Issue: could not create directory : $dirname"; exit(123); } $docfile = $pathname.$fname; if (!$dontuse_phpmove) { if (!move_uploaded_file($tempname, $docfile)) { echo "
Server Configuration Issue: Could not write the file to the directory: $docfile ".__LINE__; exit(123); } } else { if (!rename_wrapper($tempname,$docfile)) { echo "
Server Configuration Issue: Could not write the file to the directory: $docfile".__LINE__; exit(123); } } if($propertyid) update_documents_uploaded_property($propertyid); else update_documents_uploaded(); $_POST[$fieldname] = $maxdocid; return $maxdocid; } /** * @name process_customfield_display_documentupload_task * @param integer $taskid * @param string $fieldname * @param string $fieldvalue * @param array $extarray * @return boolean */ function process_customfield_display_documentupload_task($taskid, $fieldname, $fieldvalue, $extarray) //needs to have 3 parametsrs {//extarray has details of the current fieldnames extesion object d($f,$_FILES); $f = $_FILES[$fieldname]; if(!$f) // no file was uploaded return false, no uploade should be done return false; if($f[name] && $f[error]) ddie("Error uploading file!, click back and reupload",$f); if(!$f[name]) return false; if(!$taskid) $taskid = 0; $fname = websafe_filename ($f[name]); $title = $extarray[propertyextensionlabel]; if(!$title) $title =$extarray[title]; $tempname = $f[tmp_name]; if (!is_uploaded_file($tempname)) { ddie("There was a problem uploading the file $fname (a".__LINE__.").
".$tempname); } $documenttype = get_documenttype_byname("propertyupload"); $sql = "select nextval('tbldocument_documentid_seq') as documentid"; $next = db_first($sql); $maxdocid = $next[documentid]; $sql = "insert into tbldocument ( documentid , documenttitle , documentname , taskid , documentdescription , documentdateloaded , documentpublic , documentloadedby , documenttypeid ) values ( $maxdocid , '".db_col(substr($title,0,100))."' , '".db_col($fname)."' , $taskid , '".db_col($extarray[propertyextensionextra1]?$extarray[propertyextensionextra1]:$title)."' , now() , 0 , {$_SESSION[login][loginid]} , '".$documenttype[documenttypeid]."' )"; db_exec($sql,1); $dirname = getrelativedocumentdir($maxdocid); $pathname = "$_SERVER[DOCUMENT_ROOT]/document/$dirname"; if(!mkdir_wrapper($pathname)) { echo "
Server Configuration Issue: could not create directory : $dirname"; exit(123); } $docfile = $pathname.$fname; if (!move_uploaded_file($tempname, $docfile)) { echo "
Server Configuration Issue: Could not write the file to the directory: $dirname$fname".__LINE__; exit(123); } return $maxdocid; } /** * @name process_customfield_display_contact * @param integer $propertyid * @param string $fieldname * @param string $fieldvalue * @return boolean */ function process_customfield_display_contact($propertyid,$fieldname,$fieldvalue){ return $fieldvalue; } /** * @name customfield_display_contact_assetmanager * @param integer $managerid * @param array $row * @return boolean */ function customfield_display_contact_assetmanager($managerid,$row = ""){ if ($managerid < 1) return ""; $manager = db_first("select assetmanagername from tblassetmanager where assetmanagerid = '".db_number($managerid)."'"); return $manager[assetmanagername]; } /** * @name customfield_display_contact_client * @param integer $contactid * @param array $row * @return boolean */ function customfield_display_contact_client($contactid,$row = ""){ if ($contactid < 1) return ""; global $customfield_display_contact_client_cache; if(!$customfield_display_contact_client_cache[$contactid]) { $client = db_first("select * from tblclient where clientid = " . db_number($contactid)); if($client['clientcompanyname']){ $display_result .= "Company Name" . $client['clientcompanyname'] . ""; } if($result['contactcname']) $display_result = $result['contactcname']; else $display_result = $client['clientcompanyname']; $customfield_display_contact_client_cache[$contactid]=$display_result; } return $customfield_display_contact_client_cache[$contactid]; } /** * @name customfield_display_staffname * @param integer $staffid * @return string */ function customfield_display_staffname($staffid) { return get_staff_name($staffid); } /** * @name customfield_display_daystillnow * @param string $propertyextensionkey * @param integer $clientcompanypropertyid * @param integer $propertyid * @return integer */ function customfield_display_daystillnow($propertyextensionkey,$clientcompanypropertyid=0,$propertyid=0) { if (!db_number($clientcompanypropertyid) && !db_number($propertyid)) return false; $value = db_firstval("select propertyextensionentryvalue from tblpropertyextensionentry where propertyextensionkey=".db_tick($propertyextensionkey)." and ".(db_number($propertyid)?" propertyid=".db_number($propertyid):" clientcompanypropertyid=".db_number($clientcompanypropertyid))); return get_daystillnow(dt_format($value)); } /** * @name customfield_display_contact * @param integer $contactid * @param array $row * @param integer $previewmode * @return boolean */ function customfield_display_contact($contactid,$row,$previewmode = 0){ if($row['customfieldtypeattr1label'] == 'hoa'){ $sql = "SELECT "; $sql .= "hoaid as contactid,"; $sql .= "hoaname as contactname,"; $sql .= "hoacontact as contactcname,"; $sql .= "hoaaddress as contactaddress,"; $sql .= "hoaaddress2 as contactaddress2,"; $sql .= "hoacity as contactcity,"; $sql .= "hoastate as contactstate,"; $sql .= "hoazip as contactzip,"; $sql .= "hoaphone as contactphone,"; $sql .= "hoafax as contactfax,"; $sql .= "hoaemail as contactemail,"; $sql .= "hoawebsite as contactwebsite,"; $sql .= "'hoa' as contact_custom "; $sql .= "FROM tblhoa "; $sql .= "WHERE hoaid = " . db_number($contactid); }else if($row['customfieldtypeattr1label'] == 'client'){ $sql = "SELECT "; $sql .= "clientid as contactid,"; $sql .= "clientcompanyname as contactname,"; $sql .= "clientfname as contactfname,"; $sql .= "clientlname as contactlname,"; $sql .= "clientaddress as contactaddress,"; $sql .= "clientcity as contactcity,"; $sql .= "clientstate as contactstate,"; $sql .= "clientzip as contactzip,"; $sql .= "clientphone as contactphone,"; $sql .= "clientphoneextension as contactphoneextension,"; $sql .= "clientfax as contactfax,"; $sql .= "clientemail as contactemail,"; $sql .= "clientwebsite as contactwebsite,"; $sql .= "'client' as contact_custom "; $sql .= "FROM tblclient "; $sql .= "WHERE clientid = " . db_number($contactid); }else{ $sql = "SELECT * FROM tblcontact where contactid = " . db_number($contactid); } if($contactid){ $result = db_first($sql); if($result['clientid']) $client = db_first("select * from tblclient where clientid = " . db_number($result['clientid'])); if (empty($result)) return ""; if ($previewmode) { if($result['contactcname']) $display_result = $result['contactcname']; else $display_result = $client['clientcompanyname']; } else { $display_result = "
"; $display_result .= ""; if($client['clientcompanyname']){ $display_result .= ""; } if($result['contactcname']){ $display_result .= ""; } if($result['contactaddress']){ $display_result .= ""; } if($result['contactaddress2']){ $display_result .= ""; } if($result['contactcity']){ $display_result .= ""; } if($result['contactstate']){ $display_result .= ""; } if($result['contactzip']){ $display_result .= ""; } if($result['contactphone']){ $display_result .= ""; } if($result['contactphoneextension']){ $display_result .= ""; } if($result['contactfax']){ $display_result .= ""; } if($result['contactemail']){ $display_result .= ""; } if($result['contactwebsite']){ $display_result .= ""; } $display_result .= "
Company Name" . $client['clientcompanyname'] . "
Contact" . $result['contactcname'] . "
Address" . $result['contactaddress'] . "
Address 2" . $result['contactaddress2'] . "
City" . $result['contactcity'] . "
State" . $result['contactstate'] . "
Zip" . $result['contactzip'] . "
Phone" . $result['contactphone'] . "
Phone Ext." . $result['contactphoneextension'] . "
Fax" . $result['contactfax'] . "
Email" . $result['contactemail'] . "
Website" . $result['contactwebsite'] . "
"; $display_result .= "
"; } 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){ ?>
"; } 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 "
".$fieldcontents."
"; } else echo "
".customfield_obget($name)."
"; } elseif($type==documentupload) { $allow_existing_propertydocuments_id=db_number(trim($attr1)); 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 "; } } 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 .= ""; foreach ($revisionarr as $k=>$revs) { $outvalue .= ""; } $outvalue .= "
Revision Date Downlod
"; $outvalue .= $revs[tasktemplatefieldrevisionentryrevision]; $outvalue .= " "; $outvalue .= $revs[tasktemplatefieldrevisionentrycreateddate]; $outvalue .= " "; $outvalue .= "{$versionqry[documentname]}"; $outvalue .= "
"; } echo $outvalue; } elseif($type==textarea) { if(!strstr($attr3,'width')) $attr3.=";min-width:150px;"; echo "
"; } elseif($type=='seller') { $extra1[contacttypeids]=$attr1; customfield("contact",$name,$value,"","","","","",$extra1); } elseif($type=='text') { $other .= " $attr2"; echo "
" . $attr3 . "" . $attr4 . "
"; } elseif($type=='number') { $other .= " $attr2"; echo "
" . $attr3 . "" . $attr4 . "".$value."
"; } elseif($type=='money') { if($value !== false) $value = "$".dollar_format(db_number($value)); ?>
>
"; } elseif($type=='floatpercent') { if($value) $value = "".round(db_col($value),2)."%"; echo "
"; } elseif($type=='roundeddecimal') { if($value) $value = "".round(db_number($value),2).""; echo "
"; } elseif($type=='longroundeddecimal') { if($value) $value = "".round(db_number($value),4).""; echo "
"; } elseif ($type=='date') { echo "
"; } elseif($type=='select box' && $attr1=='yn') { echo " "; if(strtolower($value) == 'y' || strtolower($value) == 'yes') $outvalue='Yes'; elseif(strtolower($value) == 'n' || strtolower($value) == 'no') $outvalue='No'; } elseif($type=='select box' && $attr1=='01') { echo " "; $outvalue=yesno($value); } elseif($type=='yesnoradio' ) { echo "
No Yes
"; $outvalue=yesno($value); } elseif($type=='singlecheckbox' ) { // Commented out the following line and put back in original because code wasn't checked in. MAC echo " $attr3"; if($value==$attr1) $outvalue=""; elseif(!$value) $outvalue=""; else $outvalue=$value; } elseif($type=='singleradio' ) { echo " $attr3"; if($value==$attr1&&$attr1 ) $outvalue=""; else $outvalue=""; } elseif($type=='statedropdown') { $qry = db_query("select * from tblstate order by name"); $opt=array(); foreach($qry as $k=>$v) $opt[$v[code]]=$v[name]; if(!$value) $value=''; customfield('select box',$name,$value,$opt,$attr2,$attr1) ; } elseif($type=='radios' ) { echo ""; if(!is_array($attr1)) $attr1=explode(',',$attr1); if(!is_array($value)) $value=explode(',',$value); $other = $attr3; foreach($attr1 as $itm) { $checked=''; if(in_array($itm,$value) ) $checked="checked"; $label = ''; if ($extra1 != "nolabel") $label = "$itm $attr2"; echo " $label"; } echo ""; } elseif($type=='radiosvertical' ) { echo ""; if(!is_array($attr1)) $attr1=explode(',',$attr1); if(!is_array($value)) $value=explode(',',$value); foreach($attr1 as $itm) { $checked=''; if(in_array($itm,$value) ) $checked="checked"; if ($itm == 'textbox') echo " Other $attr2 ".customfield_return(textbox,$itm."_value",'')."
"; else echo " $itm $attr2
"; } echo ""; } elseif($type=='radiosvertical_key' ) { echo ""; if(!is_array($attr1)) $attr1=explode(',',$attr1); if(!is_array($value)) $value=explode(',',$value); foreach($attr1 as $ky=>$itm) { if ($itm == 'textbox') echo " Other $attr2 ".customfield_return(textbox,$itm."_value",'')."
"; else echo " $itm $attr2
"; if(in_array($ky,$value)) $outvalue=$itm; } echo ""; } elseif($type=='checkboxes' ) { echo ""; if(!is_array($attr1)) if(explode("\n",$attr1)>1) $attr1 = str_replace("\n",",",$attr1); if(!is_array($attr1)) $attr1=explode(',',$attr1); if(!is_array($value)) $value=explode(',',$value); $br = $attr2; if(!$br) $br='
'; $cntr=0; if (db_number($attr3)) echo ""; foreach($attr1 as $itm) { if(!is_array($itm)) { $itm = trim($itm); $id=$itm; $curvalue = $itm; }else { $id=$itm[id]; $curvalue=$itm[value]; } if (db_number($attr3)) echo ""; $cntr++; if (db_number($attr3) && $attr3 == $cntr){ echo ""; $cntr=0; } } if (db_number($attr3)) echo "
"; echo "
$curvalue$br
"; if (db_number($attr3)) echo "
"; echo "
"; } elseif($type=='checkboxes_key' ) { echo ""; if(!is_array($attr1)) $attr1=explode(',',$attr1); if(!is_array($value)) $value=explode(',',$value); $br = $attr2; if(!$br) $br='
'; foreach($attr1 as $ky=>$itm) { echo " $itm $br"; if(in_array($ky,$value)) $checkedkeyarr[$ky]=$itm; } echo "
"; if($checkedkeyarr && is_array($checkedkeyarr)) $outvalue=implode(',',$checkedkeyarr); } elseif($type=='select box') { $usekey = 1; $spl=$attr1; $blankdisplaytext = $attr3; if(!is_array($attr1)) { $attr1=str_replace("\n",",",$attr1); $usekey=0; $spl = explode(",",$attr1); } if(!$extra1['disable_sort']) uasort($spl,"icmp"); $found = 0; foreach($spl as $k=>$v) if($usekey && strtolower(trim($value))==strtolower(trim($k))) $found=1; elseif(!$usekey && strtolower(trim($v))==strtolower(trim($value)) ) $found=1; echo ""; } elseif($type=='select box multi') { $usekey = 1; $spl = $attr1; $blankdisplaytext = $attr3; if(!is_array($attr1)) { $attr1 = str_replace("\n",",",$attr1); $usekey = 0; $spl = explode(",",$attr1); } if(!$extra1['disable_sort']) uasort($spl,"icmp"); $found = 0; if ($value) foreach($value as $kv => $vv) { if(is_array($vv)) { $valarray[]=$vv; } } foreach($spl as $k=>$v) if(!is_array($v) && !is_array($k) && !is_array($value)) { if($usekey && strtolower($value)==strtolower($k)) $found=1; elseif(!$usekey && strtolower($v)==strtolower($value) ) $found=1; } echo " "; } elseif($type=='sqldropdown') { $qry = $attr1; if($attr2!=-1) $extraoption = $attr2; $extraoptionvalue = $attr4; $extraselectattr = $attr3; if(!$qry) $qry=array(); $found = 0; foreach($qry as $k=>$row) if($row[id]==$value) $found=1; foreach($qry as $thisrow) if($thisrow[label]) $dontsort=1; if (!$dontsort) $qry=db_sort($qry,value,""); if ($thisrow[option_attr]) $option_attr = "option_attr='".$thisrow[option_attr]."'"; echo ""; } elseif($type==propertyextensionpicker) { $extensionsarr=get_propertyextensionpickerlist(clientcompanyid(), 1); $defaultvalue = $attr1; if($defaultvalue) { if(!$value || $value=="") $value=-1; $defarr[0][id]=-1; $defarr[0][value]=$defaultvalue; foreach($extensionsarr as $extensionsarrkey=>$extensionsarrvar) $defarr[]=$extensionsarrvar; $extenarr=$defarr; } else $extenarr=$extensionsarr; customfield("sqldropdown",$name,$value,$extenarr,$attr2,$attr3,$attr4,$showonlyif,$extra1,$layout,$propertyarr); } elseif($type==mini_html_form) { $ret = mini_html_form($name, $attr3, $version, $value); echo $ret[embed_in_form]; //this value is reset incase this is called as read only in which case these fields all display $outvalue="
$ret[embed_in_form]
"; } 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 .= "
".button(delete,"","","","align=right")."

Create Addendum

Addendum Title: "; $outvalue .= ""; $outvalue .="
"; $outvalue .= "

"; $outvalue .= "
"; $outvalue .="

Existing Uploaded Photos: ".button(photoalbum)." Addendum Mode

"; 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; ?> 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 "
"; echo ""; if(($clienttypeid && ($clienttypeid!=-1)) || $contacttypeid) echo "
Add Classification
"; 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 } ?>
"; else $displayoutval.= ""; } $displayoutval.= ""; } $contacttypedisplay=""; if($addstafftocontact) $contacttypedisplay="addstafftocontact='1'"; if($addcontacttostaff) $contacttypedisplay="addcontacttostaff='1'"; $displayoutval.= ""; $displayoutval.= ""; $displayoutval.= ""; $displayoutval.= "
"; if($displayoverrideoutval) echo $displayoverrideoutval; else echo $displayoutval; if(companyid()) { ?>
> >>> > >>>> >>>>>>>
Company Name* "; echo $clients[0]['clientcompanyname']; } else if(clientcompanyid()) { echo ""; echo $clientcompanyclient['clientcompanyclientname']; } } ?>
First Name *
Last Name *
Classification 0) $clienttypeids = $clients[0]['clienttypeid']; customfield('contacttype','contacttypeid','',$clienttypeids,"class='" . $name . "_contact_form_input'",$filter_contacttypeid); ?>
Title
Address
Address 2
City
State
Zip
Phone
Cell Phone
Phone Ext.
Fax
Email
Website
* Required
'; $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(); ?>
$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) { ?>
>  "; ?> $bid){ if ($readonly && $i == 1) continue; echo ""; if (!$multi && !$bid['clienttaskbidname']) $bid['clienttaskbidname'] = $taskdata['clienttasktitle']; echo ""; echo ""; echo ""; else echo ""; echo ""; $i--; } ?>
Name Amount Document
" . customfield_return ("text" , "clienttaskbidname", $bid['clienttaskbidname'],""," data-id='" . db_number($bid['clienttaskbidid']) . "' onchange='clienttaskbid_update(this)'") . "" . customfield_return ("money", "clienttaskbidamount" , $bid['clienttaskbidamount'],""," data-id='" . db_number($bid['clienttaskbidid']) . "' onchange='clienttaskbid_update(this)'") . ""; if ($bid['documentid']>0) { ?> " > "; if ($multi && !$readonly) if ($i>1) 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.
"; } 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 ""; } 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 ""; if($form>0 && ($utilv[$id]||$_POST["propertyextensionutility_$t"])) $display=""; else $display="none"; if($form>0) { echo ""; } echo "
$util[value]"; if($form>0) { echo customfield(sqldropdown, "propertyextensionutility_$t",$id,$uarr[$t],"None","onchange=\"show_hide_value(this,'propertyextensionutility_{$t}_dates_div')\""); echo " new refresh "; } else { if(!$utilv[$id]) echo "None"; echo $utilv[$id]; } 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
"; 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]."
"; }elseif($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]."
"; }elseif($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 "
"; $outvalue =ob_get_clean(); return $outvalue; } /** * @name utility_list2 * @param string $parr * @param integer $form * @param integer $COMPANYSIDE * @return boolean */ function utility_list2($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 , utilitywebsite , utilitycontact , utilityphone , utilityphone2 , utilityemail , 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 , utilitywebsite , utilitycontact , utilityphone , utilityphone2 , utilityemail , 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]; $utilitycontactinfo[]=$row; } 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 "
".$util[value]."
"; if($form>0) { echo customfield(sqldropdown, "propertyextensionutility_$t",$id,$uarr[$t],"None","onchange=\"show_hide_value(this,'propertyextensionutility_{$t}_dates_div')\""); echo " new refresh "; } else { foreach(db_query($sql) as $datarecord) { if($datarecord[id] == $id) $thispropertyutilityprovider=$datarecord; } if(!$utilv[$id]) echo "None"; $utilitynamenospecialchars=str_replace(' ','',$utilv[$id]); $utilitynamenospecialchars1=str_replace('&','',$utilitynamenospecialchars); $utilitynamenospecialchars2=str_replace('\'','',$utilitynamenospecialchars1); $utilitynamenospecialchars3=str_replace(',','',$utilitynamenospecialchars2); $utilitynamenospecialchars4=str_replace('.','',$utilitynamenospecialchars3); ?> " . $utilv[$id] ."
"; //don't want to show blank contact info if($thispropertyutilityprovider['utilityphone']) { ?> >>> > > > >"; } if($form>0 && ($utilv[$id]||$_POST["propertyextensionutility_$t"])) $display=""; else $display="none"; if($form>0) { echo ""; } echo "
Phone
Phone 2
Website
Website Username
Website Password
Email
No Contact Information Available
  "; 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 "
"; $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 ""; } $html=str_replace("<","[LT]",$html); $html=str_replace("&","[AMP]",$html); $html=str_replace("'","[TICK]",$html); $html=str_replace("+","[PLUS]",$html); echo " "; if($html) echo ""; if($version!='original') echo ""; echo ""; if($version=='original') { echo " "; } else { echo " "; } $formfield=ob_get_clean(); ob_start() ?> $val) { if(is_array($val)) $val=implode(',',$val); echo "\n"; } } $jsfield=ob_get_clean(); $out[value] = $value; $out[javascript] = $jsfield; $out[embed_in_form]="
$usehtml
$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'); ?> if(typeof(window.top.customfield_documentupload_cloudpicker)=='undefined') alert('SYSTEM CONFIGURATION ERROR:\\n The cloudpicker can not be run on this page until all dependent scripts have run \\n TECH: customfield_documentupload_cloudpicker() function called, but customfield_documentupload_cloudpicker_js() was not called to load the API scripts from providers'); baseName = function (str) { var base = new String(str).substring(str.lastIndexOf('/') + 1); return base; } setgdrivelink=function(name,link,browserlink,filename, auth) { //clear drop box data $('#DROPBOXLINK$rand_' +name).val(''); $('#DROPBOXSEL$rand_' +name).html(''); fl = 'Google File: '+filename+''; $('#GDRIVESEL$rand_' +name).html(fl); $('#GDRIVELINK$rand_' +name).val(link); $('#GDRIVEFILENAME$rand_' +name).val(filename); $('#GDRIVEAUTH$rand_' +name).val(auth); } setdropboxlink= function (name,link) { //clear google data $('#GDRIVELINK$rand_' +name).val(''); $('#GDRIVEFILENAME$rand_' +name).val(''); $('#GDRIVEAUTH$rand_' +name).val(''); $('#GDRIVESEL$rand_' +name).html(''); var fl = baseName(link) fl = 'Dropbox File: '+fl+''; $('#DROPBOXSEL$rand_' +name).html(fl); $('#DROPBOXLINK$rand_' +name).val(link); } pickercallback$rand=function(data) { if (data.action == google.picker.Action.PICKED) { gapi.client.request({ 'path': '/drive/v2/files/'+data.docs[0].id , callback:function(res){ setgdrivelink('$name',res.downloadUrl,res.webContentLink, res.originalFilename , oauthtoken$rand)} }); } } var pickerapiloaded$rand = false; var oauthtoken$rand; // Use the API Loader script to load google.picker and gapi.auth. startpicker$rand=function () { gapi.load('auth', {'callback': onauthapiload$rand}); gapi.load('picker', {'callback': onpickerapiload$rand}); } onauthapiload$rand = function() { window.gapi.auth.authorize( { 'client_id': '520773079935-c6qg4kcs1jupirt223ahkia0kufqbdki.apps.googleusercontent.com', 'scope': ['https://www.googleapis.com/auth/drive.readonly'], 'immediate': false }, handleauthresult$rand); } onpickerapiload$rand = function () { pickerapiloaded$rand = true; createpicker$rand(); } handleauthresult$rand=function (authResult) { if (authResult && !authResult.error) { oauthtoken$rand = authResult.access_token; createpicker$rand(); } } // Create and render a Picker object for picking user Photos. createpicker$rand = function () { if (pickerapiloaded$rand && oauthtoken$rand) { var picker = new google.picker.PickerBuilder() .enableFeature(google.picker.Feature.NAV_HIDDEN) .setOAuthToken(oauthtoken$rand) .addView(google.picker.ViewId.PDFS) .setTitle('Select a Document') .setCallback(pickercallback$rand).build(); picker.setVisible(true); } } Google Drive "; return $out; } include ("functions_customfield_ob.php");

Embedded Form

$characterount characters"; if($selects) echo "
".count($selects)." Select Box"; if(count($selects)>1) echo "es"; if($inputs) echo "
".count($inputs)." Input Box"; if(count($inputs)>1) echo "es"; if($textareas) echo "
".count($textareas)." Text Area"; if(count($textareas)>1) echo "s"; if($scripts) echo "
".count($scripts)." Script"; if(count($scripts)>1) echo "s"; echo "
".button(edit)." - Setup Embedded Form
".icon('print')." - Preview Embedded Form
You must save to keep changes