示例#1
0
function replaceQueryStringArray($query_string, $to_remove)
{
    // we are only interested in anything after the ?, if there is one.
    if (strstr($query_string, '?')) {
        $parts = explode('?', $query_string);
        $filename = $parts[0];
        $query_string = $parts[1];
    }
    $query_string = str_replace('&', '&', $query_string);
    parse_str($query_string, $haystack);
    foreach ($haystack as $key => $val) {
        if (in_array($key, $to_remove)) {
            unset($haystack[$key]);
        } else {
            $output .= $key . '=' . $val . '&';
        }
    }
    if ($filename) {
        $filename .= '?';
    }
    return $filename . remove_lastchar($output, "&");
    //http_build_query($haystack);
}
示例#2
0
function ptype2($_ptype = NULL, $_psubtype = NULL, $_querystring = NULL)
{
    // add onload statement
    $output['onload'] = 'init(document.forms[0].dea_psubtype); ';
    // if subtype is supplied, get js to select it onload
    // not used. instead we build manual list, which is replaced by js list onChange (first list)
    if ($_psubtype) {
        $output['onload'] .= '';
    }
    // get ptype types to populate javascript drop downs (select current ptype, use js to select subtype)
    $sql = "SELECT pty_id,pty_title,pty_type FROM ptype ORDER BY pty_title";
    $_result = mysql_query($sql);
    if (!$_result) {
        die("MySQL Error:  " . mysql_error() . "<pre>ptype: " . $sql . "</pre>");
    }
    while ($row = mysql_fetch_array($_result)) {
        if (!$row["pty_type"]) {
            $render_ptype .= '<option value="' . $row["pty_id"] . '"';
            if ($_ptype == $row["pty_id"]) {
                $render_ptype .= ' selected';
            }
            $render_ptype .= '>' . $row["pty_title"] . '</option>' . "\n";
        } elseif ($row["pty_type"] == "1") {
            $_js1 .= "'" . $row["pty_title"] . "','" . $row["pty_id"] . "',";
        } elseif ($row["pty_type"] == "2") {
            $_js2 .= "'" . $row["pty_title"] . "','" . $row["pty_id"] . "',";
        } elseif ($row["pty_type"] == "3") {
            $_js3 .= "'" . $row["pty_title"] . "','" . $row["pty_id"] . "',";
        }
    }
    // create master type drop down
    $output['dd1'] = '<select name="dea_ptype" onchange="populate(document.forms[0].dea_ptype,document.forms[0].dea_psubtype)">' . "\n";
    $output['dd1'] .= '<option value="0"></option>' . "\n";
    $output['dd1'] .= $render_ptype;
    $output['dd1'] .= '</select>' . "\n";
    // create subtype drop down (with populated list if a subtype is present)
    if ($_psubtype) {
        $sql = "SELECT pty_id,pty_type,pty_title FROM ptype WHERE pty_type = " . $_ptype;
        $_result = mysql_query($sql);
        if (!$_result) {
            die("MySQL Error:  " . mysql_error() . "<pre>ptype: " . $sql . "</pre>");
        }
        while ($row = mysql_fetch_array($_result)) {
            $render_psubtype .= '<option value="' . $row["pty_id"] . '"';
            if ($row["pty_id"] == $_psubtype) {
                $render_psubtype .= ' selected';
            }
            $render_psubtype .= '>' . $row["pty_title"] . '</option>' . "\n";
        }
    } else {
        $render_psubtype .= '<option></option>' . "\n";
    }
    $output['dd2'] = '<select name="dea_psubtype" style="width:140px">' . "\n";
    $output['dd2'] .= $render_psubtype . "\n";
    $output['dd2'] .= '</select>' . "\n";
    // format javascript arrays
    $_js1 = "'(select)',''," . remove_lastchar($_js1, ",");
    $_js2 = "'(select)',''," . remove_lastchar($_js2, ",");
    $_js3 = "'(select)',''," . remove_lastchar($_js3, ",");
    $output['js'] = '
var thelist = new Array();
thelist[0] = new Array(' . $_js0 . ');
thelist[1] = new Array(' . $_js1 . ');
thelist[2] = new Array(' . $_js2 . ');
thelist[3] = new Array(' . $_js3 . ');
	
function init(dd1) 	{
	optionTest = true;
	lgth = dd1.options.length;
	dd1.options[lgth] = null;
	if (dd1.options[lgth]) optionTest = false;
	}
	
// dd1 is the first drop down, dd2 is the second
function populate(dd1,dd2) 	{
	if (!optionTest) return;
	var box = dd1;
	var number = box.options[box.selectedIndex].value;
	if (!number) return;
	var list = thelist[number];
	var box2 = dd2;
	box2.options.length = 0;
	for(i=0;i<list.length;i+=2) {
		box2.options[i/2] = new Option(list[i],list[i+1]);
		}
	dd2.focus();
	}		

';
    return $output;
}
function top20($dept = 'sales')
{
    global $db, $CONFIG;
    // unset last search
    unset($_SESSION['searchPage']);
    if ($dept == 'sales') {
        $type = 'Sales';
    } elseif ($dept == 'lettings') {
        $type = 'Lettings';
    } else {
        return;
    }
    // most viewed property from preceeding sunday for 7 previous days
    $endDate = strtotime('last Sunday');
    $startDate = $endDate - 7 * 24 * 60 * 60;
    $sql = "SELECT COUNT(*) as hits, deal.* ,CONCAT(pro_addr3,', ',area.are_title,' ',LEFT(pro_postcode, 4)) AS pro_addr, media.*\n\tFROM propertyviews\n\tLEFT JOIN deal ON propertyviews.dea_id = deal.dea_id\n\tLEFT JOIN property ON deal.dea_prop = property.pro_id\n\tLEFT JOIN area ON property.pro_area = area.are_id\n\tLEFT JOIN media ON deal.dea_id = media.med_row AND media.med_table = 'deal' AND med_order = 1 AND med_type= 'Photograph'\n\tWHERE\n\tdatetime > '" . date('Y-m-d H:i:s', $startDate) . "' AND datetime < '" . date('Y-m-d H:i:s', $endDate) . "' AND\n\tdea_type = '{$type}' AND\n\t(deal.dea_status = 'Available')\n\tGROUP BY propertyviews.dea_id\n\tORDER BY hits DESC\n\tLIMIT 20";
    $q = $db->query($sql);
    while ($row = $q->fetchRow()) {
        if (!$first) {
            $first = '<a href="' . $CONFIG['SITE_URL'] . 'details/' . $row['dea_id'] . '.html"><img src="' . IMAGE_URL_PROPERTY . $row['dea_id'] . '/' . str_replace('.jpg', '_full.jpg', $row['med_file']) . '" alt="' . $row['pro_addr'] . '" /></a>';
            $selected = ' class="selected"';
        } else {
            unset($selected);
        }
        if ($row['dea_type'] == 'Lettings') {
            $suffix = 'p/w';
        } else {
            unset($suffix);
        }
        if ($row['dea_status'] == 'Under Offer') {
            $class = ' class="uo"';
        } else {
            unset($class);
        }
        $list .= '<li' . $selected . ' id="deal_' . $row['dea_id'] . '"><a href="' . $CONFIG['SITE_URL'] . 'details/' . $row['dea_id'] . '.html"' . $class . '>' . $row['pro_addr'] . ' ' . format_price($row['dea_marketprice']) . $suffix . '</a></li>' . "\n";
        $preload .= '"' . IMAGE_URL_PROPERTY . $row['dea_id'] . '/' . str_replace('.jpg', '_full.jpg', $row['med_file']) . '",';
    }
    $output = '
<script type="text/javascript">
jQuery.preLoadImages(' . remove_lastchar($preload, ",") . ');
</script>
<div id="top20Image">' . $first . '</div>

<h3>Most Viewed : Top 20 ' . $type . '</h3>
<ol>
' . $list . '</ol>
<p><a href="' . $CONFIG['SITE_URL'] . $dept . '.html?o=Date">Full ' . $type . ' List</a></p>';
    return $output;
}
示例#4
0
 if ($return) {
     $returnLink = '?' . http_build_query($return);
 }
 if ($sql1) {
     $sql1 = remove_lastchar($sql1, "AND");
     $sql1 = remove_lastchar($sql1, "OR");
     $sql1 = "AND {$sql1} ";
 }
 if ($sql2) {
     $sql2 = remove_lastchar($sql2, "AND");
     $sql2 = remove_lastchar($sql2, "OR");
     $sql2 = "AND {$sql2} ";
 }
 if ($sql3) {
     $sql3 = remove_lastchar($sql3, "AND");
     $sql3 = remove_lastchar($sql3, "OR");
     $sql3 = "AND {$sql3} ";
 }
 $searchLink = $_SERVER['PHP_SELF'] . urlencode('?' . $_SERVER['QUERY_STRING']);
 $sql = "\nSELECT com_id,com_title,\nGROUP_CONCAT(DISTINCT CONCAT(e.con_fname,' ',e.con_sname,'(',e.con_id,')') ORDER BY e.con_fname ASC SEPARATOR ', ') AS con_name,\ncon_id,cty_title,\ncom_title AS ord\nFROM contact AS e\nLEFT OUTER JOIN company ON com_id = e.con_company\nLEFT JOIN ctype ON con_type = ctype.cty_id\nWHERE (con_company > 0) {$sql1}\nGROUP BY com_id\n\nUNION ALL\n\nSELECT con_id,'' AS empty,\nCONCAT(e.con_fname,' ',e.con_sname) AS con_name,\ncon_id,cty_title,\ncon_fname AS ord\nFROM contact AS e\nLEFT JOIN ctype ON con_type = ctype.cty_id\nWHERE (con_company = 0) {$sql2}\nGROUP BY con_id\n\nUNION ALL\n\nSELECT com_id,com_title,'' AS empty,'' AS empty2,cty_title,\ncom_title AS ord\nFROM company as sc\nLEFT JOIN ctype ON com_type = ctype.cty_id\nWHERE com_id NOT IN ( SELECT con_company from contact ) {$sql3}\nGROUP BY com_id\n\nORDER BY ord\n\n";
 $q = $db->query($sql);
 if (DB::isError($q)) {
     die("db error: " . $q->getMessage() . $sql);
 }
 $numRows = $q->numRows();
 if ($numRows !== 0) {
     while ($row = $q->fetchRow()) {
         $row["con_name"] = preg_replace("/\\([a-z0-9\\ ]+\\)/", "", $row["con_name"]);
         if (!$row["com_title"]) {
             $row["com_title"] = $row["con_name"];
             $row["con_name"] = '';
示例#5
0
    $render .= str_replace(',', '&#44;', $row["dea_description"]) . "{$d}";
    //furnished
    $render .= $furnishedId . "{$d}";
    //image_url
    if ($row["photos"]) {
        $photo_array = explode("~", $row["photos"]);
    }
    foreach ($photo_array as $val) {
        //$render .= 'http://www.woosterstock.co.uk/v3/images/p/'.$row["dea_id"].'/'.str_replace(".jpg","_large.jpg",$val)."|";
        if (file_exists(WS_PATH_IMAGES . '/' . $row["dea_id"] . '/' . str_replace(".jpg", "_large.jpg", $val))) {
            $render .= WS_URL_IMAGES . '/' . $row["dea_id"] . '/' . str_replace(".jpg", "_large.jpg", $val) . "|";
        } else {
            $render .= WS_URL_IMAGES . '/' . $row["dea_id"] . '/' . str_replace(".jpg", "_small.jpg", $val) . "|";
        }
    }
    $render = remove_lastchar($render, "|") . $d;
    //ip_address
    $render .= $_SERVER['SERVER_ADDR'] . "{$d}";
    //price
    $render .= $row["dea_marketprice"] . "{$d}";
    //registration
    $render .= "no";
    $render .= "\n";
    unset($features, $furnishedId);
}
$strPath = dirname(__FILE__) . '/oodle';
// name of textfile (date.blm)
$strTextFile = "oodle.csv";
$local_file = $strPath . "/" . $strTextFile;
// if the file already exists, delet before re-writing
if (file_exists($local_file)) {
 if ($_GET["pro_pro_id"]) {
     $sqlP = "SELECT * FROM property WHERE pro_id = " . $_GET["pro_pro_id"] . " LIMIT 1";
     $qP = $db->query($sqlP);
     if (DB::isError($qP)) {
         die("db error: " . $q->getMessage() . "sqlP<br>" . $sqlP);
     }
     while ($row = $qP->fetchRow()) {
         $formData2 = array('pro_pro_id' => array('type' => 'hidden', 'value' => $row["pro_id"]), 'pro_pcid' => array('type' => 'hidden', 'value' => $row["pro_pcid"]), 'pro_addr1' => array('type' => 'text', 'label' => 'House Number', 'value' => $row["pro_addr1"], 'required' => 1, 'attributes' => array('class' => 'addr', 'readonly' => 'readonly'), 'function' => 'format_street'), 'pro_addr2' => array('type' => 'text', 'label' => 'Building Name', 'value' => $row["pro_addr2"], 'required' => 1, 'attributes' => array('class' => 'addr', 'readonly' => 'readonly'), 'function' => 'format_street'), 'pro_addr3' => array('type' => 'text', 'label' => 'Street', 'value' => $row["pro_addr3"], 'required' => 1, 'attributes' => array('class' => 'addr', 'readonly' => 'readonly'), 'function' => 'format_street'), 'pro_addr5' => array('type' => 'text', 'label' => 'City or County', 'value' => $row["pro_addr5"], 'required' => 1, 'attributes' => array('class' => 'addr', 'readonly' => 'readonly'), 'function' => 'format_street'), 'pro_postcode' => array('type' => 'text', 'label' => 'Postcode', 'value' => $row["pro_postcode"], 'required' => 1, 'attributes' => array('class' => 'pc', 'maxlength' => 9, 'readonly' => 'readonly'), 'function' => 'format_postcode', 'group' => 'Postcode'), 'pro_postcode_change' => array('type' => 'button', 'label' => 'Postcode', 'value' => 'Change Address', 'group' => 'Postcode', 'attributes' => array('class' => 'button', 'onClick' => 'javascript:document.location.href = \'' . $_SERVER['SCRIPT_NAME'] . '?' . replaceQueryString($_SERVER['QUERY_STRING'], 'pro_pro_id') . '\';'), 'last_in_group' => 1));
     }
     // manually inputted address
 } else {
     $formData2 = array('pro_addr1' => array('type' => 'text', 'label' => 'House Number', 'value' => $pro_addr1, 'required' => 2, 'attributes' => array('class' => 'addr'), 'function' => 'format_street'), 'pro_addr2' => array('type' => 'text', 'label' => 'Building Name', 'value' => $pro_addr2, 'required' => 1, 'attributes' => array('class' => 'addr'), 'function' => 'format_street'), 'pro_addr3' => array('type' => 'text', 'label' => 'Street', 'value' => $pro_addr3, 'required' => 2, 'attributes' => array('class' => 'addr'), 'function' => 'format_street'), 'pro_addr4' => array('type' => 'text', 'label' => 'Town or Area', 'value' => $pro_addr4, 'required' => 3, 'attributes' => array('class' => 'addr'), 'function' => 'format_street'), 'pro_addr5' => array('type' => 'text', 'label' => 'City or County', 'value' => $pro_addr5, 'required' => 2, 'attributes' => array('class' => 'addr'), 'function' => 'format_street'), 'pro_postcode' => array('type' => 'text', 'label' => 'Postcode', 'value' => $pro_postcode, 'required' => 2, 'attributes' => array('class' => 'pc', 'maxlength' => 9), 'function' => 'format_postcode'), 'pro_country' => array('type' => 'select', 'label' => 'Country', 'value' => $pro_country, 'required' => 2, 'options' => db_lookup("cli_country", "country", "array"), 'attributes' => array('class' => 'addr')));
 }
 if (!$_POST["action"]) {
     $sql_1 = remove_lastchar(trim($sql_1), "OR");
     $sql_2 = remove_lastchar(trim($sql_2), "OR");
     if (!$_GET["return"]) {
         $return = $_SERVER['SCRIPT_NAME'] . '?' . http_build_query(array('cli_name' => $_GET["cli_name"], 'cli_email' => $_GET["cli_email"], 'dest' => $_GET["dest"], 'dea_id' => $_GET["dea_id"]));
     } else {
         $return = $_GET["return"];
     }
     if ($sql_1) {
         // first, match both first AND surnames and put at top of list
         $sql = "SELECT cli_id,cli_fname,cli_sname,pro_addr1,pro_addr2,pro_addr3,pro_postcode FROM client\n\tLEFT JOIN property ON property.pro_id = client.cli_pro\n\tWHERE " . $sql_1 . "\n\tORDER BY cli_fname ASC, cli_sname ASC";
         $q = $db->query($sql);
         if (DB::isError($q)) {
             die("db error: " . $q->getMessage() . "sql_1<br>" . $sql);
         }
         $numRows = $q->numRows();
         if ($numRows !== 0) {
             while ($row = $q->fetchRow()) {
示例#7
0
                $use_colour = '<span class="use_col" style="background-color: #FFFFFF;"><img src="/images/sys/admin/blank.gif" width="10" height="10"></span>&nbsp;';
            }
            if (!$row["use_name"]) {
                $row["use_name"] = '(unassigned)';
            }
            $use_name = $use_colour . $row["use_name"];
            $cli_names = explode(",", $row["cli_name"]);
            foreach ($cli_names as $name) {
                $cli_name_parts = explode("|", $name);
                $cli_name_render .= '<a href="client_edit.php?cli_id=' . $cli_name_parts[1] . '&searchLink=' . $_SERVER['SCRIPT_NAME'] . urlencode('?' . replaceQueryString($_SERVER['QUERY_STRING'], 'viewForm') . '&viewForm=6') . '">' . $cli_name_parts[0] . '</a>, ';
            }
            $viewings_table .= '
  <tr>
	<td width="20%" valign="top">' . $row["app_date"] . '</td>
	<td width="25%" valign="top">' . $use_name . '</td>
	<td width="35%" valign="top">' . remove_lastchar($cli_name_render, ",") . '</td>
	<td width="15%" valign="top">' . $feedback . '</td>
	<td width="5%" align="right" valign="top">
	  <a href="appointment_edit.php?app_id=' . $row["app_id"] . '&searchLink=' . $_SERVER['SCRIPT_NAME'] . urlencode('?' . replaceQueryString($_SERVER['QUERY_STRING'], 'viewForm') . '&viewForm=5') . '"><img src="/images/sys/admin/icons/edit-icon.png" width="16" height="16" border="0" alt="View/Edit Appointment"/></a>
	  </td>
  </tr>';
            $countViewing++;
        } elseif ($row["app_type"] == 'Valuation') {
            $countValuation++;
        } elseif ($row["app_type"] == 'Production') {
            $countProduction++;
        } elseif ($row["app_type"] == 'Inspection') {
            $countInspection++;
        }
        unset($cli_name_render);
    }
示例#8
0
function db_query($_data, $_action, $_table, $_field, $_row = "temp_row_id")
{
    global $current_user_id;
    // update - select existing values for comparison
    if ($_action == "UPDATE") {
        foreach ($_data as $_key => $_val) {
            $_fields .= $_key . ",";
            $_newvalues[] = format_data("{$_val}");
        }
        $_fields = remove_lastchar(trim($_fields), ",");
        if ($_fields) {
            $_sql_select = "SELECT " . $_fields . " FROM " . $_table . " WHERE " . $_field . " = " . $_row . " LIMIT 1";
            $_result = mysql_query($_sql_select);
            if (!$_result) {
                die("MySQL Error:  " . mysql_error() . "<pre>db_query: " . $_sql_select . "</pre>");
            }
            while ($_row_select = mysql_fetch_array($_result)) {
                foreach ($_data as $_key => $_val) {
                    // format old values to make sure sql works
                    $_oldvalues[$_key] = format_data($_row_select[$_key]);
                }
            }
            mysql_free_result($_result);
        }
    } elseif ($_action == "INSERT") {
        foreach ($_data as $_key => $_val) {
            $_newvalues[] = format_data($_val);
            $_oldvalues[$_key] = "NULL";
        }
    }
    /* // delete
    	elseif ($_action == "DELETE") {
    		foreach($_data as $_key=>$_val) {			
    			$_newvalues[] = "NULL";
    			$_oldvalues[$_key] = trim("$_val");
    			}
    		}*/
    // we should now have 2 arrarys of fieldnames as keys and new and old values
    if (count($_data) !== count($_oldvalues)) {
        echo 'db_query: array count not matched<p>';
        exit;
    }
    // construct sql for $_table AND changelog table, single query with multiple inserts
    $_sql_log = "INSERT INTO changelog \n\t(cha_user,cha_session,cha_action,cha_table,cha_row,cha_field,cha_old,cha_new)\n\tVALUES \n\t";
    // loop _data, check if current(old) value is different to new, and create sql statements accordingly
    foreach ($_data as $_key => $_val) {
        if ($_oldvalues[$_key] !== $_val) {
            // enter NULL value without quotes (09/05/06)
            if ($_val == "NULL") {
                $_sql_update .= $_key . "=NULL,";
            } elseif ($_val == "") {
                $_sql_update .= $_key . "='',";
            } else {
                $_sql_update .= $_key . "='" . format_data($_val) . "',";
            }
            $_sql_insert1 .= $_key . ",";
            $_sql_insert2 .= "'" . format_data($_val) . "',";
            $_sql_log .= "('" . $current_user_id . "','" . session_id() . "','" . $_action . "','" . $_table . "','" . $_row . "','" . format_data($_key) . "','" . format_data($_oldvalues[$_key]) . "','" . format_data($_val) . "'),\n";
            $_msg .= $_key . " was changed from " . $_oldvalues[$_key] . " to " . $_val . "\n";
            $_changecount++;
        }
    }
    $_sql_log = remove_lastchar(trim($_sql_log), ",");
    $_sql_update = remove_lastchar(trim($_sql_update), ",");
    $_sql_insert1 = remove_lastchar(trim($_sql_insert1), ",");
    $_sql_insert2 = remove_lastchar(trim($_sql_insert2), ",");
    if ($_action == "UPDATE") {
        $_sql_return = "UPDATE " . $_table . " SET " . $_sql_update . " WHERE " . $_field . " = " . $_row;
    } elseif ($_action == "INSERT") {
        $_sql_return = "INSERT INTO " . $_table . " (" . $_sql_insert1 . ") VALUES (" . $_sql_insert2 . ")";
    }
    /* elseif ($_action == "DELETE") {
    		$_sql_return = "DELETE FROM ".$_table." WHERE ".$_field." = ".$_row;
    		}*/
    if ($_changecount) {
        // only execute the sql queries if a change has been made
        $_result_return = mysql_query($_sql_return);
        if (!$_result_return) {
            die("MySQL Error:  " . mysql_error() . "<pre>db_query RETURN: " . $_sql_return . "</pre>");
        }
        if ($_action == "UPDATE") {
            $_insert_id = $_row;
        } elseif ($_action == "INSERT") {
            $_insert_id = mysql_insert_id();
            $_sql_log = str_replace("temp_row_id", $_insert_id, $_sql_log);
            // replace temp_row_id with insert_id
        }
        //mysql_free_result($_result_return);
        $_result_log = mysql_query($_sql_log);
        if (!$_result_log) {
            die("MySQL Error:  " . mysql_error() . "<pre>db_query LOG: " . $_sql_log . "</pre>");
        }
        //mysql_free_result($_result_log);
    }
    /* // dubug info
    	echo "<pre><b>Current values</b>\n";
    	print_r($_oldvalues);
    	echo "<pre><b>New values</b>\n";
    	print_r($_data);
    	echo "<hr>sql_log: ".$_sql_log;
    	echo "<hr>msg: ".$_msg;	*/
    return $_insert_id;
    // return the effected row in $_table, not changelog
    unset($_data, $_action, $_table, $_field, $_row);
}
            $render .= remove_lastchar($render2, ",") . '</p>' . "\n";
        }
        $render .= '<hr />';
        break;
    case "Note":
        $app["type"] = $app["subtype"] . ' ' . $app["type"];
        $render .= '<p>' . $app["subject"] . '</p>';
        $render .= renderNotes('appointment', $app_id, array('label' => 'Appointment Notes:', 'layout' => 'simple'));
        if ($attendees) {
            $render2 .= '<hr>' . "\n";
            $render2 .= '<h2>Attendees:</h2>
<p>';
            foreach ($attendees as $attendee) {
                $render2 .= $attendee . ', ';
            }
            $render .= remove_lastchar($render2, ",") . '</p>' . "\n";
        }
        $render .= '<hr />';
        break;
    default:
        //$render = "<p>No further printable information available</p>";
}
$sql = "SELECT address.searchString AS `address`, address.lat lat, address.lng lng FROM appointment a\nINNER JOIN link_deal_to_appointment l ON a.app_id = l.d2a_app\nINNER JOIN deal d ON d.dea_id = l.d2a_dea\nINNER JOIN property p ON d.dea_prop = p.pro_id\nINNER JOIN address ON address.id = p.addressId\n WHERE a.app_id = '{$_GET['app_id']}'\n AND address.lat != '' AND address.lng != '' AND address.lat IS NOT NULL AND address.lng IS NOT NULL ORDER BY l.d2a_ord DESC";
$q = $db->query($sql);
$showMap = false;
$markers = [];
while ($row = $q->fetchRow()) {
    $showMap = true;
    $lat = $row['lat'];
    $lng = $row['lng'];
    $markers[] = $lat . ',' . $lng;
示例#10
0
function source($_source = NULL, $_querystring)
{
    // if a source is supplied, don't show the muti drop downs.
    if ($_source) {
        $ref = '?' . replaceQueryString($_querystring, 'cli_source');
        $sql = "SELECT sou_id,sou_title,sou_type FROM source WHERE sou_id = {$_source} LIMIT 1";
        $_result = mysql_query($sql);
        if (!$_result) {
            die("MySQL Error:  " . mysql_error() . "<pre>source: " . $sql . "</pre>");
        }
        while ($row = mysql_fetch_array($_result)) {
            $output['dd1'] = '<input type="text" readonly="readonly" value="' . $row["sou_title"] . ' (' . $row["sou_type"] . ')" class="inputInvisible">' . "\n";
            $output['dd1'] .= '<input type="button" value="Change" class="button" onClick="javascript:document.location.href=\'' . $ref . '\';">' . "\n";
            $output['dd1'] .= '<input type="hidden" name="cli_source" value="' . $row["sou_id"] . '">';
        }
    } else {
        // only add onload statement if source is not specified
        $output['onload'] = 'init(document.forms[0].cli_source)';
        // get source types to populate javascript drop downs
        $sql = "SELECT sou_id,sou_title,sou_type FROM source ORDER BY sou_title";
        $_result = mysql_query($sql);
        if (!$_result) {
            die("MySQL Error:  " . mysql_error() . "<pre>source: " . $sql . "</pre>");
        }
        while ($row = mysql_fetch_array($_result)) {
            if (!$row["sou_type"]) {
                $render_source .= '<option value="' . $row["sou_id"] . '"';
                if ($cli_source1 == $row["sou_id"]) {
                    $render_source .= ' selected';
                }
                $render_source .= '>' . $row["sou_title"] . '</option>' . "\n";
                // array of types to loop through later
                $types[] = $row["sou_id"];
            } else {
                ${'_js' . $row["sou_type"]} .= "'" . $row["sou_title"] . "','" . $row["sou_id"] . "',";
            }
            /*~
            		elseif ($row["sou_type"] == "Portal") {
            			$_js1 .= "'".$row["sou_title"]."','".$row["sou_id"]."',";
            			}
            		elseif ($row["sou_type"] == "Press") {
            			$_js2 .= "'".$row["sou_title"]."','".$row["sou_id"]."',";
            			}
            		elseif ($row["sou_type"] == "Search Engine") {
            			$_js3 .= "'".$row["sou_title"]."','".$row["sou_id"]."',";
            			}
            		elseif ($row["sou_type"] == "Referral") {
            			$_js4 .= "'".$row["sou_title"]."','".$row["sou_id"]."',";
            			}*/
        }
        // create master type drop down
        $output['dd1'] = '<select name="cli_source1" style="width:200px" onchange="populate(document.forms[0].cli_source1,document.forms[0].cli_source)">' . "\n";
        $output['dd1'] .= '<option value="0">(click here)</option>' . "\n";
        $output['dd1'] .= $render_source;
        $output['dd1'] .= '</select>' . "\n";
        $output['dd2'] = '<select name="cli_source" style="width:200px;display:none;">' . "\n";
        $output['dd2'] .= '<option></option>' . "\n";
        $output['dd2'] .= '</select>' . "\n";
        // format javascript arrays (add "other" option to each?)
        foreach ($types as $type) {
            if (${'_js' . $type}) {
                ${'_js' . $type} = "'(select)',''," . remove_lastchar(${'_js' . $type}, ",");
                $render_js .= 'thelist[' . $type . '] = new Array(' . ${'_js' . $type} . ');' . "\n";
            }
        }
        $output['js'] = '
var thelist = new Array();
thelist[0] = new Array();
' . $render_js . '
	
function init(dd1) 	{
	optionTest = true;
	lgth = dd1.options.length;
	dd1.options[lgth] = null;
	if (dd1.options[lgth]) optionTest = false;
	}
	
// dd1 is the first drop down, dd2 is the second
function populate(dd1,dd2) 	{
	if (!optionTest) return;
	dd2.style.display = "";
	/* dd1.style.display = "none"; */
	var box = dd1;
	var number = box.options[box.selectedIndex].value;
	if (!number) return;
	var list = thelist[number];
	var box2 = dd2;
	box2.options.length = 0;
	for(i=0;i<list.length;i+=2) {
		box2.options[i/2] = new Option(list[i],list[i+1]);
		}
	dd2.focus();
	}		
';
    }
    return $output;
}
    $owner = 'Landlord';
}
$render = '<table cellpadding="2" cellspacing="2" border="0">
  <tr>
	<td class="label" valign="top">Property</td>
	<td><a href="/admin4/instruction/summary/id/' . $dea_id . '">' . $pro_addr . '</a></td>
  </tr>
  <tr>
	<td class="label" valign="top">' . $owner . '(s)</td>
	<td class="spaced">' . remove_lastchar($vendor_name, '<br />') . '</td>
  </tr>';
if ($tenant_name) {
    $render .= '
  <tr>
	<td class="label" valign="top">Tenant(s)</td>
	<td class="spaced">' . remove_lastchar($tenant_name, '<br />') . '</td>
  </tr>';
}
$render .= '
  <tr>
	<td class="label" valign="top">Key</td>
	<td>' . $key_info . '</td>
  </tr>
</table>
' . renderNotes('viewing_arrangements', $dea_id, array('layout' => 'readonly', 'label' => 'View Times and Info'));
$formData1 = array('d2a_cv' => array('type' => 'radio', 'label' => 'Confirm Status', 'value' => $d2a_cv, 'options' => db_enum("link_deal_to_appointment", "d2a_cv", "array")), 'notes' => array('type' => 'textarea', 'label' => 'Add Confirmation Note', 'attributes' => array('class' => 'noteInput'), 'tooltip' => 'Notes relating to the confirmation of this property only'));
if (!$_GET["action"]) {
    $form = new Form();
    $form->addForm("app_form", "GET", $PHP_SELF);
    $form->addHtml("<div id=\"standard_form\">\n");
    $form->addField("hidden", "action", "", "update");
示例#12
0
define("FEED_NAME", "trovit");
require_once dirname(__FILE__) . "/../../../../../config/config_feed.inc.php";
$sql = "SELECT\n\tdeal.*,\n\tarea.are_title,\n\tpro_addr1,pro_addr3,pro_addr5,LEFT(pro_postcode,4) as pro_postcode,\n\tCONCAT(pro_addr3,' ',area.are_title,' ',LEFT(pro_postcode,4)) as pro_address,\n\tpro_east,pro_north,pro_latitude,pro_longitude,\n\tbranch.bra_id,branch.bra_title,branch.bra_tel,branch.bra_fax,branch.bra_email,\n\tT.pty_title AS ptype,\n\tST.pty_title AS psubtype,\n\tGROUP_CONCAT(DISTINCT CONCAT(photos.med_file,'|',photos.med_title) ORDER BY photos.med_order ASC SEPARATOR '~') AS photos,\n\tGROUP_CONCAT(DISTINCT CONCAT(floorplans.med_file,'|',floorplans.med_title) ORDER BY floorplans.med_order ASC SEPARATOR '~') AS floorplans\n\nFROM deal\n\nLEFT JOIN property ON deal.dea_prop = property.pro_id\nLEFT JOIN area ON property.pro_area = area.are_id\nLEFT JOIN branch ON deal.dea_branch = branch.bra_id\n\nLEFT JOIN ptype AS T ON deal.dea_ptype = T.pty_id\nLEFT JOIN ptype AS ST ON deal.dea_psubtype = ST.pty_id\n\nLEFT JOIN media AS photos ON deal.dea_id = photos.med_row AND photos.med_table = 'deal' AND photos.med_type = 'Photograph'\nLEFT JOIN media AS floorplans ON deal.dea_id = floorplans.med_row AND floorplans.med_table = 'deal' AND floorplans.med_type = 'Floorplan'\n\n\nWHERE\n(deal.dea_status = 'Available' OR deal.dea_status = 'Under Offer' OR deal.dea_status = 'Under Offer with Other')\nAND (deal.noPortalFeed <> 1 AND deal.underTheRadar <> 1)\nGROUP BY dea_id\n";
//echo $sql;
$q = $db->query($sql);
if (DB::isError($q)) {
    die("error: " . $q->getMessage());
}
$numRows = $q->numRows();
// header
$render = '<?xml version="1.0" encoding="utf-8"?>' . "\n";
$render .= '<trovit>' . "\n";
while ($row = $q->fetchRow()) {
    // description
    $description = str_replace(array("&eacute;", "&rsquo;", "&pound;", "&lsquo;", "&ndash;"), array("&#233;", "&#8217;", "&#163;", "&#8216;", "&#8211;"), $row["dea_description"]);
    $description = remove_lastchar($description, "<p>");
    // remove all tags except <p>
    $description = strip_tags($description, '<p>');
    // remove any attributes from tags
    $description = preg_replace('/<\\s*(\\w+)[^>]+>/i', '<$1>', $description);
    $render .= '<ad>' . "\n";
    $render .= '<id><![CDATA[' . $row["dea_id"] . ']]></id>' . "\n";
    $render .= '<url><![CDATA[http://' . WS_HOSTNAME . '/Detail.php?id=' . $row["dea_id"] . ']]></url>' . "\n";
    $render .= '<title><![CDATA[' . $row["pro_address"] . ']]></title>' . "\n";
    if ($row["dea_type"] == 'Sales') {
        $render .= '<type><![CDATA[For sale]]></type>' . "\n";
    } else {
        $render .= '<type><![CDATA[For rent]]></type>' . "\n";
    }
    $render .= '<agency><![CDATA[Wooster &amp; Stock]]></agency>' . "\n";
    $render .= '<content><![CDATA[<h1>' . $row["dea_strapline"] . '</h1>' . $description . ']]></content>' . "\n";
             $cli_ptype .= $row["pty_id"] . '|';
         }
     }
 }
 if ($_POST["cli_price_bracket"]) {
     $parts = explode('-', $_POST["cli_price_bracket"]);
     $minprice = $parts[0];
     $maxprice = $parts[1];
 }
 $db_data["cli_deposit"] = $_POST["cli_deposit"];
 // dept specific //
 $db_data["cli_salestatus"] = $_POST["cli_saleletstatus"];
 $db_data["cli_salebed"] = $_POST["cli_salebed"];
 $db_data["cli_saleemail"] = $_POST["cli_saleemail"];
 $db_data["cli_sales"] = 'Yes';
 $db_data["cli_saleptype"] = remove_lastchar($cli_ptype, '|');
 $db_data["cli_salemin"] = $minprice;
 $db_data["cli_salemax"] = $maxprice;
 // office $form6 //
 $db_data["cli_branch"] = $_POST["cli_branch"];
 $db_data["cli_neg"] = $_POST["cli_neg"];
 // notes...
 // other
 $db_data["cli_regd"] = $_SESSION["auth"]["use_id"];
 $db_data["cli_reviewed"] = date('Y-m-d H:i:s');
 if ($_POST["activate"]) {
     $db_data["cli_status"] = 'Active';
 }
 //print_r($db_data);
 db_query($db_data, "UPDATE", "client", "cli_id", $cli_id);
 unset($db_data);
    $price = format_price($dea_valueprice) . ' (Valuation)';
} else {
    if ($dea_qualifier !== 'None') {
        $qual = ' (' . $dea_qualifier . ')';
    }
    if ($dea_type == 'Sales') {
        $price = format_price($dea_marketprice) . ' ' . $dea_tenure;
    } elseif ($dea_type == 'Lettings') {
        $price .= format_price($dea_marketprice, 'GBP', true) . ' per week / ' . format_price(pw2pcm($dea_marketprice), 'GBP', true) . ' per month';
    }
    $price .= $qual;
}
foreach ($vendors as $ven_id => $ven_name) {
    $vendor_summary .= $ven_name . ', ';
}
$vendor_summary = remove_lastchar($vendor_summary, ",");
// moved summary table lower down page to catch offer info
// deal table, positioned above formData
$deal_table = '
<table cellpadding="2" cellspacing="2" border="0">
  <tr>
    <td class="label" valign="top">' . $owner . '(s)</td>
	<td>' . $vendor_table . '</td>
  </tr>
</table>
';
// get state of trade, and history
$sql = "SELECT\nsot_id,sot_status,sot_nextdate,\nCONCAT(use_fname,' ',use_sname) AS use_name,\nDATE_FORMAT(sot_date, '%D %M %Y %l:%i%p') AS date\nFROM\nsot\nLEFT JOIN user ON user.use_id = sot.sot_user\nWHERE\nsot_deal = {$dea_id}\nORDER BY sot_date DESC";
$q = $db->query($sql);
if (DB::isError($q)) {
    die("db error: " . $q->getMessage());
示例#15
0
                $_js1 .= "'" . $row["pty_title"] . "','" . $row["pty_id"] . "',";
            } elseif ($row["pty_type"] == 2) {
                $_js2 .= "'" . $row["pty_title"] . "','" . $row["pty_id"] . "',";
            } elseif ($row["pty_type"] == 3) {
                $_js3 .= "'" . $row["pty_title"] . "','" . $row["pty_id"] . "',";
            }
        }
        // create master type drop down
        $render_ptype = '<select name="pro_ptype" onchange="populate(document.forms[0].pro_ptype,document.forms[0].pro_psubtype)">
<option value="0"></option>
' . $render_ptype . '
</select>';
        // format javascript arrays
        $_js1 = "'(select)',''," . remove_lastchar($_js1, ",");
        $_js2 = "'(select)',''," . remove_lastchar($_js2, ",");
        $_js3 = "'(select)',''," . remove_lastchar($_js3, ",");
        // if the property already has a subtype, manually make the drop down
        if ($pro_psubtype) {
            $render_ptype .= '
	<select name="pro_psubtype" style="width:150px">';
            $sql = "SELECT pty_id,pty_type,pty_title FROM ptype WHERE pty_type = " . $pro_ptype;
            $q = $db->query($sql);
            if (DB::isError($q)) {
                die("db error: " . $q->getMessage());
            }
            while ($row = $q->fetchRow()) {
                $render_ptype .= '<option value="' . $row["pty_id"] . '"';
                if ($row["pty_id"] == $pro_psubtype) {
                    $render_ptype .= ' selected';
                }
                $render_ptype .= '>' . $row["pty_title"] . '</option>
示例#16
0
         }
     }
     $sql = remove_lastchar($sql, "OR");
     $sql .= ")";
 }
 $operator = 'OR';
 if ($feature) {
     $sql .= "AND (";
     foreach ($feature as $fea) {
         if ($fea) {
             $sql .= "\n\t\t\tfeature.fea_title LIKE '%{$fea}%' {$operator}\n\t\t\tnote.not_blurb LIKE '%{$fea}%' {$operator}\n\t\t\t(area.are_title LIKE '%{$fea}%' OR area.are_postcode LIKE '{$fea}%') AND ";
             /*
              */
         }
     }
     $sql = remove_lastchar($sql, 'AND');
     $sql .= ")";
 }
 $sql .= "\nGROUP BY client.cli_id\nORDER BY {$orderby} {$direction}";
 //echo $sql;
 //exit;
 $q = $db->query($sql);
 if (DB::isError($q)) {
     die("db error: " . $q->getMessage() . $sql);
 }
 $numRows = $q->numRows();
 if ($numRows !== 0) {
     while ($row = $q->fetchRow()) {
         // onClick="trClick(\'client_edit.php?cli_id='.$row["cli_id"].'&searchLink='.$searchLink.'\');"
         $all_clients[] = array('cli_id' => $row["cli_id"], 'cli_fname' => $row["cli_fname"], 'cli_sname' => $row["cli_sname"], 'cli_name' => $row["cli_name"], 'cli_email' => $row["cli_email"], 'cli_addr' => $row["pro_addr"], 'date' => $row["date"]);
     }
示例#17
0
        $cli_letptype_array = explode("|", $cli_letptype);
        if (array_intersect($cli_letptype_array, $proptype1)) {
            $letptype_array[] = 'House';
        }
        if (array_intersect($cli_letptype_array, $proptype2)) {
            $letptype_array[] = 'Apartment';
        }
        if (array_intersect($cli_letptype_array, $proptype3)) {
            $letptype_array[] = 'Other';
        }
        if (is_array($letptype_array)) {
            foreach ($letptype_array as $val) {
                $letptype .= $val . ' or ';
            }
        }
        $letptype = remove_lastchar(trim($letptype), 'or');
        // put all associated properties into an array, with default at the top
        if ($row["pro_id"] == $row["cli_pro"]) {
            $default_property = array('pro_addr1' => $row["pro_addr1"], 'pro_addr2' => $row["pro_addr2"], 'pro_addr3' => $row["pro_addr3"], 'pro_addr4' => $row["pro_addr4"], 'pro_addr5' => $row["pro_addr5"], 'pro_postcode' => $row["pro_postcode"], 'pro_pcid' => $row["pro_pcid"], 'p2c_type' => $row["p2c_type"], 'p2c_id' => $row["p2c_id"], 'p2c_pro' => $row["p2c_pro"]);
        } else {
            $properties[$row["p2c_id"]] = array('pro_addr1' => $row["pro_addr1"], 'pro_addr2' => $row["pro_addr2"], 'pro_addr3' => $row["pro_addr3"], 'pro_addr4' => $row["pro_addr4"], 'pro_addr5' => $row["pro_addr5"], 'pro_postcode' => $row["pro_postcode"], 'pro_pcid' => $row["pro_pcid"], 'p2c_type' => $row["p2c_type"], 'p2c_id' => $row["p2c_id"], 'p2c_pro' => $row["p2c_pro"]);
        }
    }
}
// put the default address (as defined in the cli_pro row) on top of the array of properties
array_unshift($properties, $default_property);
// get the tels into an array ready for the form
if ($tel) {
    $tel_numbers = explode("|", $tel);
    foreach ($tel_numbers as $tels) {
        $tel_detail = explode("~", $tels);
示例#18
0
function db_lookup($_name, $_table, $_type = "select", $_pick = null, $_order = null, $_isnull = null, $_where = null)
{
    $_render = "";
    $_query = "SELECT * FROM {$_table}";
    if (is_array($_where)) {
        foreach ($_where as $key => $val) {
            $_wheresql .= $key . " = '" . $val . "' AND ";
        }
        $_query .= " WHERE " . remove_lastchar(trim($_wheresql), 'AND');
    }
    if ($_order) {
        $_query .= " ORDER BY {$_order}";
    }
    $_result = mysql_query($_query);
    if (!$_result) {
        die("MySQL Error:  " . mysql_error());
    }
    if ($_type == "array") {
        while ($_v = mysql_fetch_array($_result)) {
            $_render[$_v[0]] = $_v[1];
        }
    } elseif ($_type == "checkbox") {
        while ($_v = mysql_fetch_array($_result)) {
            $_render .= '<input type="checkbox" name="' . $_table . '" value="' . $_v[0] . '"';
            if ($_v[0] == $_pick) {
                $_render .= ' checked';
            }
            $_render .= ' />' . $_v[1] . '
			';
        }
    } elseif ($_type == "radio") {
        while ($_v = mysql_fetch_array($_result)) {
            $_render .= '<input type="radio" name="' . $_table . '" value="' . $_v[0] . '"';
            if ($_v[0] == $_pick) {
                $_render .= ' checked';
            }
            $_render .= ' />' . $_v[1] . '
			';
        }
    } elseif ($_type == "select") {
        // insert a blank option
        if ($_isnull && !isset($_pick)) {
            $_render .= '<option value=""></option>
			';
        }
        while ($_v = mysql_fetch_array($_result)) {
            $_render .= '<option value="' . $_v[0] . '"';
            if ($_v[0] == $_pick) {
                $_render .= ' selected';
            }
            $_render .= '>' . $_v[1] . '</option>
			';
        }
        $_render = '<select name="' . $_name . '">' . $_render . '</select>
		';
    }
    mysql_free_result($_result);
    return $_render;
    unset($_table, $_where, $_query, $_sqlresult, $_sqlrow, $_v, $_value, $_matches, $_render, $_count, $_isnull);
}
         }
     }
     $sql2 = remove_lastchar($sql2, "OR");
     $sql2 .= ")";
 }
 $operator = 'OR';
 if ($feature) {
     $sql2 .= "AND (";
     foreach ($feature as $fea) {
         if ($fea) {
             $sql2 .= "\n\t\t\tfeature.fea_title LIKE '{$fea}%' {$operator}\n\t\t\tnote.not_blurb LIKE '%{$fea}%' {$operator}\n\t\t\t(area.are_title LIKE '{$fea}%' OR area.are_postcode LIKE '{$fea}%') AND ";
             /*
              */
         }
     }
     $sql2 = remove_lastchar($sql2, 'AND');
     $sql2 .= ")";
 }
 $sql2 .= "\nGROUP BY client.cli_id";
 //echo $sql2;
 //exit;
 $q = $db->query($sql2);
 if (DB::isError($q)) {
     die("db error: " . $q->getMessage() . $sql);
 }
 $numRows = $q->numRows();
 if ($numRows !== 0) {
     while ($row = $q->fetchRow()) {
         // onClick="trClick(\'client_edit.php?cli_id='.$row["cli_id"].'&searchLink='.$searchLink.'\');"
         $all_clients[] = array('cli_id' => $row["cli_id"], 'cli_fname' => $row["cli_fname"], 'cli_sname' => $row["cli_sname"], 'cli_name' => $row["cli_name"], 'cli_email' => $row["cli_email"], 'cli_addr' => $row["pro_addr"], 'date' => $row["date"]);
     }
示例#20
0
 if (!$_POST["action"]) {
     // get all potentially matching clients into array
     $sql = "SELECT cli_id,cli_fname,cli_sname,\n\t\t\t\t\tCONCAT(cli_fname,' ',cli_sname) AS cli_name,\n\t\t\t\t\tcli_email,cli_timestamp,cli_oldaddr,\n\t\t\t\t\tCONCAT(pro_addr1,' ',pro_addr2,' ',pro_addr3,' ',pro_postcode) AS pro_addr,\n\t\t\t\t\ttel_number\n\t\t\t\t\tFROM client\n\t\t\t\t\tLEFT JOIN property ON property.pro_id = client.cli_pro\n\t\t\t\t\tLEFT JOIN tel ON client.cli_id = tel.tel_cli AND tel.tel_ord = 1\n\t\t\t\t\tWHERE\n\t\t\t\t\t{$sql_email}\n\t\t\t\t\t";
     // single keyword, do not use soundex
     if ($keyword_count == 1) {
         foreach ($string as $str) {
             $str = mysql_real_escape_string($str);
             $sql .= "cli_fname LIKE '{$str}%' OR cli_sname LIKE '{$str}%' OR ";
         }
     } else {
         foreach ($string as $str) {
             $srt = mysql_real_escape_string($str);
             $sql .= "cli_fname LIKE '{$str}%' OR cli_sname LIKE '{$str}%' OR soundex(cli_fname) = soundex('{$str}') OR soundex(cli_sname) = soundex('{$str}') OR ";
         }
     }
     $sql = remove_lastchar($sql, "OR");
     $q = $db->query($sql);
     if (DB::isError($q)) {
         die("db error: " . $q->getMessage() . "sql<br>" . $sql);
     }
     while ($row = $q->fetchRow()) {
         // clean up the address
         if ($row["pro_addr"]) {
             $row["pro_addr"] = ' (' . trim(str_replace(array(",,", "   ", "  "), array(",", " ", " "), ucwords($row["pro_addr"]))) . ')';
         } elseif ($row["cli_oldaddr"]) {
             $row["pro_addr"] = ' (' . trim(str_replace(array(",,", "   ", "  "), array(",", " ", " "), ucwords($row["cli_oldaddr"]))) . ')';
         } elseif ($row["tel_number"]) {
             $row["pro_addr"] = ' (' . $row["tel_number"] . ')';
         } elseif ($row["cli_email"]) {
             $row["pro_addr"] = ' (' . $row["cli_email"] . ')';
         }
示例#21
0
 if (is_array($cli_id)) {
     foreach ($cli_id as $client) {
         $sql = "SELECT CONCAT(cli_fname,' ',cli_sname) AS cli_name FROM client WHERE client.cli_id = {$client}";
         $q = $db->query($sql);
         if (DB::isError($q)) {
             die("db error: " . $q->getMessage());
         }
         $numRows = $q->numRows();
         while ($row = $q->fetchRow()) {
             $clients[] = $row["cli_name"];
         }
     }
     foreach ($clients as $name) {
         $cli_name .= $name . ' &amp; ';
     }
     $cli_name = remove_lastchar(trim($cli_name), "&amp;");
 } else {
     // single client
     $sql = "SELECT CONCAT(cli_fname,' ',cli_sname) AS cli_name,cli_salestatus,cli_letstatus FROM client WHERE client.cli_id = {$cli_id}";
     $q = $db->query($sql);
     if (DB::isError($q)) {
         die("db error: " . $q->getMessage());
     }
     $numRows = $q->numRows();
     while ($row = $q->fetchRow()) {
         $cli_name = $row["cli_name"];
         $cli_salestatus = $row["cli_salestatus"];
         $cli_letstatus = $row["cli_letstatus"];
     }
 }
 // deal table, positioned above formData
示例#22
0
	<td>' . $vendor_summary . '</td>
  </tr>
  <tr>
    <td class="label">Property Type</td>
	<td>' . $ptype . ' / ' . $psubtype . '</td>
  </tr>
  <tr>
    <td class="label">Rooms</td>
	<td>' . $dea_bedroom_word . ' Bedroom, ' . $dea_reception_word . ' Reception, ' . $dea_bathroom_word . ' Bathroom</td>
  </tr>
  ';
if ($dea_type == "Lettings" && remove_lastchar($render_features, ",")) {
    $summary_table .= '
  <tr>
    <td class="label">Features</td>
	<td>' . remove_lastchar($render_features, ",") . '</td>
  </tr>';
}
$summary_table .= '
  <tr>
    <td class="label">Internal Area</td>
	<td>' . $internal_area . '</td>
  </tr>
</table>
';
// get all appointments and build table
$countViewing = 0;
$countValuation = 0;
$countProduction = 0;
$countInspection = 0;
$sql = "SELECT\napp_id,app_type,app_start,app_end,app_status,\nCONCAT(user.use_fname,' ',user.use_sname) as use_name,use_colour,\ncli_id,GROUP_CONCAT(DISTINCT CONCAT(cli_fname,' ',cli_sname,'(',cli_id,')') ORDER BY client.cli_id ASC SEPARATOR ', ') AS cli_name,\nGROUP_CONCAT(DISTINCT CONCAT(cli_id) ORDER BY client.cli_id ASC SEPARATOR '|') AS cli,\nDATE_FORMAT(appointment.app_start, '%d/%m/%y %H:%i') AS app_date,\nd2a_id,d2a_feedback\nFROM link_deal_to_appointment\nLEFT JOIN appointment ON link_deal_to_appointment.d2a_app = appointment.app_id\nLEFT JOIN user ON appointment.app_user = user.use_id\nLEFT JOIN cli2app ON appointment.app_id = cli2app.c2a_app\nLEFT JOIN client ON cli2app.c2a_cli = client.cli_id\nWHERE\nlink_deal_to_appointment.d2a_dea = {$dea_id}  AND appointment.app_status != 'Deleted'\nGROUP BY appointment.app_id\nORDER BY app_start DESC";
示例#23
0
 $db_data["cli_salemin"] = round_to_nearest(numbers_only($row["MinPrice"]), 10000);
 $db_data["cli_salemax"] = round_to_nearest(numbers_only($row["MaxPrice"]), 10000);
 $db_data["cli_salebed"] = $row["Bedrooms"];
 if ($row["Areas"]) {
     // areas are full area titles split with hats. explode into array, match against area table in v3?
     $original_areas = explode("^", $row["Areas"]);
     foreach ($original_areas as $area_title) {
         //if (in_array($area_title,$areas)) {
         $area_array[] = array_search($area_title, $areas);
         //}
     }
     $new_areas = implode("|", $area_array);
     $new_areas = str_replace("||", "|", $new_areas);
     $new_areas = str_replace("||", "|", $new_areas);
     $new_areas = remove_firstchar($new_areas, "|");
     $new_areas = remove_lastchar($new_areas, "|");
     $db_data["cli_area"] = $new_areas;
     unset($original_areas, $area_array, $new_areas);
 }
 // heardby - match title to title on source table
 if ($row["FoundBy_Title"]) {
     $db_data["cli_source"] = array_search(strtolower(str_replace(" ", "", $row["FoundBy_Title"])), $source);
 }
 // dates should already be in the correct format
 $db_data["cli_created"] = $row["DateCreated"];
 // status (sales) L = live, S = not live
 if ($row["Status"] == 'L') {
     $db_data["cli_sales"] = 'Yes';
     $db_data["cli_saleemail"] = 'Yes';
 }
 //////////// lettings specific at end of table //////////////
示例#24
0
            $render .= $rm_image_name . "^";
            //MEDIA_FLOOR_PLAN_01
            $filesToDelete[] = $strPath . "/" . $rm_image_name;
            $render .= $floorplan[1] . "^";
            //MEDIA_FLOOR_PLAN_TEXT_01
        } else {
            // no image
            $render .= "^";
            //MEDIA_FLOOR_PLAN_01
            $render .= "^";
            //MEDIA_FLOOR_PLAN_TEXT_01
        }
    }
    unset($floorplan, $floorplan_array, $i);
    $render = remove_lastchar($render, "^");
    $render = remove_lastchar($render, "^");
    // brochure
    $render .= "http://" . WS_HOSTNAME . "/property/pdf/" . $row['dea_id'];
    $render .= "~\n";
    //End of record + line feed
    // loop
}
// end of datafeed
$render .= "#END#";
$local_file = $strPath . "/" . $strTextFile;
// if the file already exists, delet before re-writing
if (file_exists($local_file)) {
    unlink($local_file);
}
// write $render to file
if (!file_put_contents($local_file, $render)) {
示例#25
0
function source($_source = NULL, $_querystring, $_readonly = NULL)
{
    $otherText = '>> create new';
    // if a source is supplied, don't show the muti drop downs.
    if ($_source && $_source != 'x') {
        $ref = '?' . replaceQueryString($_querystring, 'cli_source');
        $sql = "SELECT \n\t\tsource.sou_id,source.sou_title,source.sou_type,source2.sou_title AS sou_title2 \n\t\tFROM source \n\t\tLEFT JOIN  source AS source2 ON source2.sou_id = source.sou_type\n\t\tWHERE source.sou_id = {$_source} LIMIT 1";
        $_result = mysql_query($sql);
        if (!$_result) {
            die("MySQL Error:  " . mysql_error() . "<pre>source: " . $sql . "</pre>");
        }
        while ($row = mysql_fetch_array($_result)) {
            $output['dd1'] = '<input type="text" readonly="readonly" value="' . $row["sou_title"] . ' (' . $row["sou_title2"] . ')" class="inputInvisible">' . "\n";
            if (!$_readonly) {
                $output['dd1'] .= '<input type="button" value="Change" class="button" onClick="javascript:document.location.href=\'' . $ref . '\';">' . "\n";
            }
            $output['dd1'] .= '<input type="hidden" name="cli_source" value="' . $row["sou_id"] . '">';
        }
    } else {
        // only add onload statement if source is not specified
        $output['onload'] = 'init(document.forms[0].cli_source)';
        // get source types to populate javascript drop downs
        $sql = "SELECT sou_id,sou_title,sou_type FROM source ORDER BY sou_title";
        $_result = mysql_query($sql);
        if (!$_result) {
            die("MySQL Error:  " . mysql_error() . "<pre>source: " . $sql . "</pre>");
        }
        while ($row = mysql_fetch_array($_result)) {
            if ($row["sou_type"] == 0) {
                // types
                $render_source .= '<option value="' . $row["sou_id"] . '"';
                if ($cli_source1 == $row["sou_id"]) {
                    $render_source .= ' selected';
                }
                $render_source .= '>' . $row["sou_title"] . '</option>' . "\n";
                // array of types to loop through later
                $types[] = $row["sou_id"];
            } else {
                // sub-types
                ${'_js' . $row["sou_type"]} .= "'" . $row["sou_title"] . "','" . $row["sou_id"] . "',";
            }
        }
        // create master type drop down
        $output['dd1'] = '<select name="cli_source1" id="source1" onchange="populate(document.forms[0].cli_source1,document.forms[0].cli_source)">' . "\n";
        $output['dd1'] .= '<option value="0"></option>' . "\n";
        $output['dd1'] .= $render_source;
        $output['dd1'] .= '</select>' . "\n";
        $output['dd2'] = '<select name="cli_source" id="source" style="width:200px" onChange="sourceOther(this);">' . "\n";
        $output['dd2'] .= '<option></option>' . "\n";
        $output['dd2'] .= '</select>' . "\n";
        $output['dd2'] .= '<input type="text" name="sourceNew" id="sourceNew" style="display:none" />' . "\n";
        // format javascript arrays (add "other" option to each?)
        foreach ($types as $type) {
            if (${'_js' . $type}) {
                ${'_js' . $type} .= "'{$otherText}','x',";
                ${'_js' . $type} = "'(select)',''," . remove_lastchar(${'_js' . $type}, ",");
                $render_js .= 'thelist[' . $type . '] = new Array(' . ${'_js' . $type} . ');' . "\n";
            }
        }
        $output['js'] = '
var thelist = new Array();
thelist[0] = new Array();
' . $render_js . '
	
function init(dd1) 	{
	optionTest = true;
	lgth = dd1.options.length;
	dd1.options[lgth] = null;
	if (dd1.options[lgth]) optionTest = false;
	}
	
// dd1 is the first drop down, dd2 is the second
function populate(dd1,dd2) 	{

	
	
	
	
	if (!optionTest) return;
	var box = dd1;
	var number = box.options[box.selectedIndex].value;
	if (!number) return;
	var list = thelist[number];
	var box2 = dd2;
	
	// make sure dd2 is visible
	if (box2.style.display == "none") {
		box2.style.display = "";
		var sourceNew = document.getElementById(\'sourceNew\');
		sourceNew.style.display = "none";
		}
	box2.options.length = 0;
	for(i=0;i<list.length;i+=2) {
		box2.options[i/2] = new Option(list[i],list[i+1]);
		}
	dd2.focus();
	}	

// replaced dd2 with text field and hidden field for type	
function sourceOther(selectedItem) {

	if (selectedItem.value == \'x\') {
		var source = document.getElementById(\'source\');
		source.style.display = "none";
		var sourceNew = document.getElementById(\'sourceNew\');
		sourceNew.style.display = "";
		sourceNew.focus();
		}
	}	
';
    }
    return $output;
}