Example #1
0
        $results = $result->process($fields, $_POST);
        $db_data = $results['Results'];
    }
    // build return link
    $redirect = $_SERVER['SCRIPT_NAME'] . '?';
    if ($con_id) {
        $redirect .= 'con_id=' . $con_id;
    }
    if ($viewForm) {
        $redirect .= '&viewForm=' . $viewForm;
    }
    if ($searchLink) {
        $redirect .= '&searchLink=' . urlencode($searchLink);
    }
    if ($results['Errors'] || $errors) {
        if (is_array($results['Results'])) {
            $redirect .= '&' . http_build_query($results['Results']);
        }
        echo error_message(join_arrays(array($results['Errors'], $errors)), urlencode($redirect));
        exit;
    }
    if ($viewForm !== 2 && $viewForm !== 7) {
        db_query($db_data, "UPDATE", "contact", "con_id", $con_id);
    }
    if ($forward_company) {
        header("Location:company.php?com_title=" . $_POST["con_company"]);
    }
    $msg = urlencode('Update Successful');
    header("Location:{$redirect}&msg={$msg}");
    exit;
}
     $return .= http_build_query($results['Results']);
 }
 // validate second form, but this is only required is posctcode lookup isnt used
 if (!$_POST["pro_pro_id"]) {
     $results2 = $result->process($formData2, $_POST);
     $db_data2 = $results2['Results'];
     if (is_array($results2['Results'])) {
         $return2 = http_build_query($results2['Results']);
     }
 } else {
     // successfull postcode lookup, show read-only form?
     $return2 = "pro_pro_id=" . $_POST["pro_pro_id"] . "&";
 }
 $return .= '&' . $return2;
 if ($results['Errors'] && $results2['Errors']) {
     $errors = join_arrays(array($results['Errors'], $results2['Errors']));
     echo error_message($errors, urlencode($return));
     exit;
 } elseif ($results['Errors']) {
     echo error_message($results['Errors'], urlencode($return));
     exit;
 } elseif ($results2['Errors']) {
     echo error_message($results2['Errors'], urlencode($return));
     exit;
 }
 // no errors, continue
 unset($formData1["cli_tel"]);
 $db_data['cli_created'] = $date_mysql;
 $cli_id = db_query($db_data, "INSERT", "client", "cli_id");
 $db_dataTel = array('tel_number' => phone_format($_POST["telnew"]), 'tel_type' => $_POST["telnewtype"], 'tel_cli' => $cli_id, 'tel_ord' => 1);
 db_query($db_dataTel, "INSERT", "tel", "tel_id");
     if ($db_data["dea_status"] && $db_data["dea_status"] !== $dea_status) {
         $db_data2["sot_deal"] = $dea_id;
         $db_data2["sot_status"] = $db_data["dea_status"];
         $db_data2["sot_date"] = $date_mysql;
         $db_data2["sot_notes"] = $_GET["notes"];
         $db_data2["sot_user"] = $_SESSION["auth"]["use_id"];
         $sot_id = db_query($db_data2, "INSERT", "sot", "sot_id");
     }
     // prompt: changed to production, ask if appointment should be booked....
     if ($sot_id && $db_data2["sot_status"] == "Production") {
         $prompt = "app_production";
     }
 } elseif ($_GET["form5"]) {
     $fields = $form5;
     $viewForm = 5;
     $formData5 = join_arrays(array($formData5));
     $result = new Validate();
     $results = $result->process($formData5, $_GET);
     $db_data = $results['Results'];
     // build return link
     $return = 'stage=1&dea_id=' . $dea_id . '&searchLink=' . $searchLink . '&';
     // extract notes from db_data and store in notes table
     if ($db_data["dea_notes_arr"]) {
         $notes = $db_data["dea_notes_arr"];
         $db_data_note = array('not_blurb' => $notes, 'not_row' => $dea_id, 'not_type' => 'viewing_arrangements', 'not_user' => $_SESSION["auth"]["use_id"], 'not_date' => $date_mysql);
         db_query($db_data_note, "INSERT", "note", "not_id");
     }
     unset($db_data["dea_notes_arr"]);
     if ($results['Errors']) {
         if (is_array($results['Results'])) {
             $return .= http_build_query($results['Results']);
Example #4
0
 }
 if (!$_GET["action"]) {
     if (!$_GET["scope"]) {
         $_GET["scope"] = $_SESSION["auth"]["default_scope"];
     }
     // disable term (pw/pcm) unless term == let
     if ($_GET["scope"] == "Lettings") {
         $term_attributes = array();
     } else {
         $term_attributes = array('disabled' => 'disabled');
     }
     // ensure user's brnach is NOT selected, set to ALL
     if (!$_GET["branch"]) {
         $_GET["branch"] = 999;
     }
     $formData1 = array('scope' => array('type' => 'radio', 'label' => 'Sales or Lettings', 'value' => $_GET["scope"], 'init' => $_SESSION["auth"]["default_scope"], 'options' => array('Sales' => 'sale', 'Lettings' => 'let'), 'attributes' => array('onClick' => 'javascript:disableTermField(\'scope\',\'term\');')), 'keyword' => array('type' => 'text', 'label' => 'Keyword(s)', 'value' => $_GET["keyword"], 'attributes' => array('class' => 'addr'), 'tooltip' => 'Seperate multiple keywords with commas'), 'branch' => array('type' => 'select_branch', 'label' => 'Branch', 'value' => $_GET["branch"], 'options' => array('' => 'Any'), 'attributes' => array('style' => 'width:200px')), 'status' => array('type' => 'select', 'label' => 'Status', 'value' => $_GET["status"], 'default' => 'Available', 'options' => join_arrays(array(array('' => 'Any'), db_enum("deal", "dea_status", "array"))), 'attributes' => array('style' => 'width:200px')), 'price_min' => array('type' => 'text', 'label' => 'Price From', 'value' => $_GET["price"], 'group' => 'Price Range', 'init' => '(minimum)', 'attributes' => array('style' => 'width:100px', 'onFocus' => 'javascript:clearField(this,\'(minimum)\')')), 'price_max' => array('type' => 'text', 'label' => 'Price To', 'value' => $_GET["price"], 'group' => 'Price Range', 'init' => '(maximum)', 'attributes' => array('style' => 'width:100px', 'onFocus' => 'javascript:clearField(this,\'(maximum)\')')), 'term' => array('type' => 'select', 'label' => 'Term', 'value' => $_GET["term"], 'group' => 'Price Range', 'last_in_group' => '1', 'attributes' => $term_attributes, 'options' => array('per week' => 'per week', 'per month' => 'per month'), 'tooltip' => 'If you enter a price range, properties without a price will not appear'), 'bed' => array('type' => 'select_number', 'label' => 'Minimum Beds'));
     // get any past viewings for this client
     if ($cli_id) {
         // get all viewings and build table
         $sql = "SELECT\napp_id,app_type,app_start,app_end,app_status,\nCONCAT(user.use_fname,' ',user.use_sname) AS use_name,CONCAT(LEFT(user.use_fname,1),LEFT(user.use_sname,1)) AS use_initial,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') AS app_date,\nd2a_id,d2a_feedback,\nCONCAT(property.pro_addr1,' ',property.pro_addr2,' ',property.pro_addr3,' ',LEFT(property.pro_postcode,4)) AS pro_addr\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\nLEFT JOIN deal ON link_deal_to_appointment.d2a_dea = deal.dea_id\nLEFT JOIN property ON deal.dea_prop = property.pro_id\nWHERE\nclient.cli_id = {$cli_id} AND appointment.app_status != 'Deleted' AND appointment.app_type = 'Viewing'\nGROUP BY d2a_id\nORDER BY app_start DESC";
         $q = $db->query($sql);
         if (DB::isError($q)) {
             die("db error: " . $q->getMessage());
         }
         $numApps = $q->numRows();
         if ($numApps) {
             while ($row = $q->fetchRow()) {
                 // only show feedback for appointments in the past
                 if (strtotime($row["app_end"]) < strtotime($date_mysql)) {
                     if (!$row["d2a_feedback"]) {
                         $feedback = '(not entered)';
 while ($row = $q->fetchRow()) {
     $matched_areas[$row["are_title"]] = $row["are_id"];
     if ($numRows == 1) {
         $default_area = $row["are_title"];
     }
 }
 if ($are_title) {
     $default_area = $are_title;
 }
 if ($matched_areas) {
     $formDataArea = array('pro_area' => array('type' => 'radio', 'label' => 'Area', 'value' => $default_area, 'options' => $matched_areas), 'pro_areanew' => array('type' => 'button', 'label' => 'New Area', 'value' => 'New Area', 'attributes' => array('class' => 'button', 'onClick' => 'javascript:addArea(\'' . $pc1 . '\',\'' . urlencode($_SERVER['SCRIPT_NAME'] . '?' . $_SERVER['QUERY_STRING']) . '\')')));
 } else {
     $formDataArea = array('pro_areanew' => array('type' => 'button', 'label' => 'New Area', 'value' => 'New Area', 'attributes' => array('class' => 'button', 'onClick' => 'javascript:addArea(\'' . $pc1 . '\',\'' . urlencode($_SERVER['SCRIPT_NAME'] . '?' . $_SERVER['QUERY_STRING']) . '\')')));
 }
 # build data arrays for property particulars
 $formData = array('dea_ptype' => array('type' => 'select_multi', 'label' => 'Property Type', 'required' => 2, 'options' => array('dd1' => $ptype['dd1'], 'dd2' => $ptype['dd2'])), 'dea_bedroom' => array('type' => 'select_number', 'label' => 'Bedrooms', 'value' => $dea_bedroom, 'attributes' => array('class' => 'narrow'), 'options' => array('blank' => 'blank')), 'dea_reception' => array('type' => 'select_number', 'label' => 'Receptions', 'value' => $dea_reception, 'attributes' => array('class' => 'narrow'), 'options' => array('blank' => 'blank')), 'dea_bathroom' => array('type' => 'select_number', 'label' => 'Bathrooms', 'value' => $dea_bathroom, 'attributes' => array('class' => 'narrow'), 'options' => array('blank' => 'blank')), 'dea_floor' => array('type' => 'select', 'label' => 'Floor', 'value' => $dea_floor, 'options' => join_arrays(array(array('blank' => ''), db_enum("deal", "dea_floor", "array"))), 'attributes' => array('class' => 'medium')), 'dea_floors' => array('type' => 'select_number', 'label' => 'Floors', 'options' => array('blank' => '', 'min' => '1'), 'value' => $dea_floors, 'attributes' => array('class' => 'narrow')));
 // remove area from the equation
 #$formData = join_arrays(array($formDataArea,$formData));
 if (!$_GET["action"]) {
     // start new form object
     $form = new Form();
     $form->addForm("form", "get", $PHP_SELF);
     $form->addHtml("<div id=\"standard_form\">\n");
     $form->addField("hidden", "stage", "", "particulars");
     $form->addField("hidden", "action", "", "update");
     $form->addField("hidden", "cli_id", "", $cli_id);
     $form->addField("hidden", "pro_id", "", $pro_id);
     $form->addField("hidden", "dea_id", "", $dea_id);
     $form->addHtml("<fieldset>\n");
     $form->addLegend('Property Particulars');
     $form->addData($formDataArea, $_GET);
     $page->setBodyAttributes(array('onLoad' => $ptype['onload']));
     $page->addBodyContent($header_and_menu);
     $page->addBodyContent('<div id="content">');
     $page->addBodyContent($navbar);
     $page->addBodyContent($render);
     $page->addBodyContent($form->renderForm());
     $page->addBodyContent('</div>');
     $page->display();
 } else {
     // if form is submitted
     // get dea_date out of array
     if ($_GET["dea_date"]) {
         $dea_date = $_GET["dea_date"];
         unset($formData1["dea_date"]);
     }
     $formData = join_arrays(array($formData1, $formData));
     // validate (dea)
     $result = new Validate();
     $results = $result->process($formData, $_GET);
     $db_data = $results['Results'];
     // build return link
     $return = $_SERVER['SCRIPT_NAME'] . '?stage=particulars&';
     if ($cli_id) {
         $results['Results']['cli_id'] = $cli_id;
     }
     if (is_array($results['Results'])) {
         $return .= http_build_query($results['Results']);
     }
     if ($results['Errors']) {
         echo error_message($results['Errors']);
         exit;
     $page->addBodyContent('</div>');
     $page->display();
     exit;
 } else {
     // if form is submitted
     // initiale new validate instance before anything to get acces to functions (i.e. array2string)
     $result = new Validate();
     // add any additional fields not in array (ptype, reqs, etc)
     if ($cli_sales == "Yes") {
         $addFormData1 = array('cli_saleptype' => array('label' => 'Property Type', 'required' => 2, 'value' => array2string($_GET["cli_saleptype"], "|")));
     }
     if ($cli_lettings == "Yes") {
         $addFormData2 = array('cli_letptype' => array('label' => 'Property Type', 'required' => 2, 'value' => array2string($_GET["cli_letptype"], "|")));
     }
     // join the arrays
     $formData = join_arrays(array($formData1, $formData2, $addFormData1, $addFormData2));
     $results = $result->process($formData, $_GET);
     $db_data = $results['Results'];
     // build return link
     $return = $_SERVER['SCRIPT_NAME'] . '?';
     if ($stage) {
         $results['Results']['stage'] = $stage;
     }
     if ($cli_id) {
         $results['Results']['cli_id'] = $cli_id;
     }
     if ($viewForm) {
         $results['Results']['viewForm'] = $viewForm;
     }
     if (is_array($results['Results'])) {
         $return .= http_build_query($results['Results']);
Example #8
0
     $page->addBodyContent('</div>');
     $page->display();
 } else {
     // if form is submitted
     // first deal with the client status. if mulitple clients are linked to deal, update all
     if ($dea_type == 'Sales') {
         if ($_GET["cli_salestatus"]) {
             $db_data_cli["cli_salestatus"] = $_GET["cli_salestatus"];
         }
     } elseif ($dea_type == 'Lettings') {
         if ($_GET["cli_letstatus"]) {
             $db_data_cli["cli_letstatus"] = $_GET["cli_letstatus"];
         }
     }
     $result = new Validate();
     $fields = join_arrays(array($formData1));
     $results = $result->process($fields, $_GET);
     $db_data = $results['Results'];
     $cli_id = array2string($cli_id);
     $redirect = $_SERVER['SCRIPT_NAME'] . '?dea_id=' . $dea_id . '&cli_id=' . $cli_id;
     if ($return) {
         $redirect .= '&return=' . $return;
     }
     if ($results['Errors']) {
         if (is_array($results['Results'])) {
             $redirect .= '&' . http_build_query($results['Results']);
         }
         echo error_message($results['Errors'], urlencode($redirect));
         exit;
     }
     $db_data["off_deal"] = $_GET["dea_id"];
     $term_attributes = array('disabled' => 'disabled');
 }
 $status_special_array = array('available' => 'Available &nbsp;<span style="color:#666666; font-size: 10px">Available only</span><br />', 'onsite' => 'On Website &nbsp;<span style="color:#666666; font-size: 10px">Available, Under Offer and Exchanged</span><br />', 'pending' => 'Coming On &nbsp;<span style="color:#666666; font-size: 10px">Instructions and Production</span><br />', 'won' => 'Won &nbsp;<span style="color:#666666; font-size: 10px">Completed with us</span><br />', 'lost' => 'Lost &nbsp;<span style="color:#666666; font-size: 10px">Withdrawn, Disinstructed and Sold by Other</span><br />', 'all' => 'Everything &nbsp;<span style="color:#666666; font-size: 10px">The whole lot</span><br />');
 if (!$_GET["status_special"]) {
     $_GET["status_special"] = 'available';
 }
 $status_special_selected = $status_special_array[$_GET["status_special"]];
 // str_replace('<br /><br />','<br />',$status_special_array[$_GET["status_special"]]);
 unset($_GET["status_special"]);
 $status_special_array_flip = array_flip($status_special_array);
 $formData1 = array('scope' => array('type' => 'radio', 'label' => 'Sales or Lettings', 'value' => $_GET["scope"], 'default' => $_SESSION["auth"]["default_scope"], 'options' => array('Sales' => 'Sales', 'Lettings' => 'Lettings'), 'attributes' => array('onClick' => 'javascript:disableTermField(\'scope\',\'term\');javascript:disableTermField(\'scope\',\'dea_term\');')), 'keyword' => array('type' => 'text', 'label' => 'Keyword(s)', 'value' => $_GET["keyword"], 'attributes' => array('style' => 'width:400px'), 'tooltip' => 'Any part of property address, or vendor/landlord name(s). Seperate multiple keywords with commas'), 'type' => array('type' => 'select', 'label' => 'Property Type', 'value' => $_GET["type"], 'options' => array('' => 'Any', '1' => 'House', '2' => 'Apartment', '3' => 'Other'), 'attributes' => array('style' => 'width:150px')), 'status_special' => array('type' => 'radio', 'label' => 'Status<br><br><br><br><br><br><br><br><br>', 'value' => $status_special_selected, 'options' => $status_special_array_flip), 'price_min' => array('type' => 'text', 'label' => 'Price From', 'value' => $_GET["price"], 'group' => 'Price Range', 'init' => '(minimum)', 'attributes' => array('style' => 'width:100px', 'onFocus' => 'javascript:clearField(this,\'(minimum)\')')), 'price_max' => array('type' => 'text', 'label' => 'Price To', 'value' => $_GET["price"], 'group' => 'Price Range', 'init' => '(maximum)', 'attributes' => array('style' => 'width:100px', 'onFocus' => 'javascript:clearField(this,\'(maximum)\')')), 'term' => array('type' => 'select', 'label' => 'Term', 'value' => $_GET["term"], 'group' => 'Price Range', 'last_in_group' => '1', 'attributes' => $term_attributes, 'options' => array('per week' => 'per week', 'per month' => 'per month')), 'dea_term' => array('type' => 'select', 'label' => 'Rental Term', 'value' => $_GET["dea_term"], 'attributes' => $term_attributes, 'options' => join_arrays(array(array('' => 'Any'), db_enum('deal', 'dea_term', 'array')))), 'bed' => array('type' => 'select_number', 'label' => 'Minimum Beds', 'value' => $_GET["bed"]), 'maxBed' => array('type' => 'select_number', 'label' => 'Maximum Beds', 'value' => $_GET["maxBed"]));
 // prevent form class from select current user's branch
 if (!$_GET["branch"]) {
     $_GET["branch"] = "999";
 }
 $formData2 = array('status' => array('type' => 'checkbox_table', 'label' => 'Status', 'value' => $_GET["status"], 'options' => array('Available' => 'Available', 'Under Offer' => 'Under Offer', 'Exchanged' => 'Exchanged', 'Completed' => 'Completed', 'Valuation' => 'Valuation', 'Instructed' => 'Instructed', 'Production' => 'Production', 'Proofing' => 'Proofing', 'U/O with Other' => 'U/O with Other', 'Collapsed' => 'Collapsed', 'Withdrawn' => 'Withdrawn', 'Not Instructed' => 'Not Instructed', 'Disinstructed' => 'Disinstructed', 'Comparable' => 'Comparable', 'Chain' => 'Chain', 'Unknown' => 'Unknown')), 'neg' => array('type' => 'select_user', 'label' => 'Negotiator', 'value' => $_GET["neg"], 'options' => array('' => 'Any'), 'attributes' => array('class' => 'wide')), 'branch' => array('type' => 'select_branch', 'label' => 'Branch', 'value' => $_GET["branch"], 'options' => array('' => 'Any'), 'attributes' => array('class' => 'wide')), 'contract' => array('type' => 'select', 'label' => 'Contract', 'value' => $_GET["contract"], 'options' => join_arrays(array(array('' => 'Any'), db_enum('deal', 'dea_contract', 'array'))), 'attributes' => array('class' => 'wide')), 'hip' => array('type' => 'select', 'label' => 'HIP', 'value' => $_GET["hip"], 'options' => join_arrays(array(array('' => 'Any'), db_enum('deal', 'dea_hip', 'array'))), 'attributes' => array('class' => 'wide')), 'board' => array('type' => 'select', 'label' => 'Board', 'value' => $_GET["board"], 'options' => join_arrays(array(array('' => 'Any'), db_enum('deal', 'dea_board', 'array'))), 'attributes' => array('class' => 'wide')));
 $form = new Form();
 $form->addForm("", "GET", $PHP_SELF);
 $form->addHtml("<div id=\"standard_form\">\n");
 $form->addField("hidden", "stage", "", "1");
 $form->addField("hidden", "action", "", "advanced_search");
 $buttons = $form->makeField("submit", "", "", "Search", array('class' => 'submit'));
 $buttons .= $form->makeField("button", "", "", "Reset", array('class' => 'button', 'onClick' => 'javascript:location.href=\'' . $PHP_SELF . '\';'));
 $formName = 'form1';
 $form->addHtml("<fieldset>\n");
 $form->addHtml('<div class="block-header">Property Search</div>');
 $form->addHtml('<div id="' . $formName . '">');
 $form->addData($formData1, $_GET);
 $form->addHtml($form->addDiv($buttons));
 $form->addHtml("</div>\n");
 $form->addHtml("</fieldset>\n");
Example #10
0
    <tr>
    <td>Notes:</td>
    <td><textarea name="notes" style="width:200px;height:60px"></textarea></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td><input type="submit" value="Change Status"></td>
    </tr>
    </table>
    </form>
    </div>';
    */
} else {
    // if form is submitted
    $result = new Validate();
    $fields = join_arrays(array($formData1, $additional_fields));
    #,$formData2
    $results = $result->process($fields, $_GET);
    $db_data = $results['Results'];
    $redirect = $_SERVER['SCRIPT_NAME'] . '?dea_id=' . $dea_id;
    if ($return) {
        $redirect .= '&return=' . $return;
    }
    if ($results['Errors']) {
        if (is_array($results['Results'])) {
            $redirect .= '&' . http_build_query($results['Results']);
        }
        echo error_message($results['Errors'], urlencode($redirect));
        exit;
    }
    #todo: check the new status hasnt already been set, check the status is valid
 case 1:
     if (!$_GET["action"]) {
         /*
         if (!$_GET["date_from"]) {
         	   $_GET["date_from"] = date('d/m/Y'); //23/11/2006
         	   }
         if (!$_GET["date_to"]) {
         	   $_GET["date_to"] = date('d/m/Y');
         	   }
         */
         if ($_GET["type"] == 'Note') {
             $notetype_display = "";
         } else {
             $notetype_display = "none";
         }
         $formData1 = array('keyword' => array('type' => 'text', 'label' => 'Keyword(s)', 'value' => $_GET["keyword"], 'attributes' => array('class' => 'addr'), 'tooltip' => 'Seperate multiple keywords with commas'), 'branch' => array('type' => 'select_branch_2', 'label' => 'Branch', 'value' => $_GET["branch"], 'attributes' => array('class' => 'medium')), 'user' => array('type' => 'select_user', 'label' => 'User', 'value' => $_GET["user"], 'attributes' => array('class' => 'medium'), 'tooltip' => 'Lead user only (does not include attendees)', 'options' => array('' => 'Any')), 'type' => array('type' => 'select', 'label' => 'Appointment Type', 'group' => 'Appointment Type', 'value' => $_GET["type"], 'options' => join_arrays(array(array('' => 'Any'), db_enum("appointment", "app_type", "array"))), 'attributes' => array('class' => 'medium', 'onChange' => 'controlAppointmentType(this,\'type\');')), 'notetype' => array('type' => 'select', 'label' => 'Sub-Type', 'group' => 'Appointment Type', 'last_in_group' => 1, 'value' => $_GET["notetype"], 'options' => db_enum("appointment", "app_notetype", "array"), 'attributes' => array('style' => 'display:' . $notetype_display)), 'date_from' => array('type' => 'datetime', 'label' => 'Date (from)', 'value' => $_GET["date_from"], 'attributes' => array('class' => 'medium')), 'date_to' => array('type' => 'datetime', 'label' => 'Date (to)', 'value' => $_GET["date_to"], 'attributes' => array('class' => 'medium')), 'status' => array('type' => 'select', 'label' => 'Status', 'value' => $_GET["status"], 'options' => db_enum("appointment", "app_status", "array"), 'attributes' => array('class' => 'medium')));
         $form = new Form();
         $form->addForm("", "GET", $PHP_SELF);
         $form->addHtml("<div id=\"standard_form\">\n");
         $form->addField("hidden", "stage", "", "1");
         $form->addField("hidden", "action", "", "advanced_search");
         $formName = 'form1';
         $form->addHtml("<fieldset>\n");
         $form->addHtml('<div class="block-header">Search Calendar</div>');
         $form->addHtml('<div id="' . $formName . '">');
         $form->addData($formData1, $_GET);
         $form->addHtml($form->addDiv($form->makeField("submit", "", "", "Search", array('class' => 'submit'))));
         $form->addHtml("</div>\n");
         $form->addHtml("</fieldset>\n");
         if (!$_GET["viewForm"]) {
             $viewForm = 1;
     $page->addBodyContent($navbar);
     $page->addBodyContent($form->renderForm());
     $page->addBodyContent('</div>');
     $page->display();
     exit;
 } else {
     // if the form has been submitted
     // join up the arrays, depending on user selection
     $formData = join_arrays(array($formData0, $formData1));
     if ($_GET["cli_sales"] == 'Yes') {
         $addFormData2 = array('cli_saleptype' => array('label' => 'Property Type', 'required' => 2, 'value' => array2string($_GET["cli_saleptype"], "|")));
         $formData = join_arrays(array($formData, $formData2, $addFormData2));
     }
     if ($_GET["cli_lettings"] == 'Yes') {
         $addFormData3 = array('cli_letptype' => array('label' => 'Property Type', 'required' => 2, 'value' => array2string($_GET["cli_letptype"], "|")));
         $formData = join_arrays(array($formData, $formData3, $addFormData3));
     }
     // new source
     if ($_GET["cli_source"] == "x") {
         if (!$_GET["sourceNew"]) {
             $errors[] = "Please enter a referer title or choose existing from the list";
             echo error_message($errors);
             exit;
         } else {
             // check if it already exists... (not fail-safe, but worth a try)
             // lower case all, and remove space from both new and existing for comparison
             $sql_source_check = "SELECT sou_id FROM source\n\t\tWHERE sou_type = " . $_GET["cli_source1"] . " AND REPLACE(LOWER(sou_title),' ','') = '" . trim(strtolower(str_replace(" ", "", $_GET["sourceNew"]))) . "'";
             $result_source_check = mysql_query($sql_source_check);
             if (mysql_num_rows($result_source_check)) {
                 while ($row_source_check = mysql_fetch_array($result_source_check)) {
                     $_GET["cli_source"] = $row_source_check["sou_id"];
    // active clients cannot complete the questionaire
    if ($row["cli_status"] == 'Active') {
        header("Location:client_edit.php?cli_id=" . $row["cli_id"]);
    }
    foreach ($row as $key => $val) {
        ${$key} = $val;
    }
}
if ($tel) {
    $tel_numbers = explode("|", $tel);
    foreach ($tel_numbers as $tels) {
        $tel_detail = explode("~", $tels);
        $telephone[] = array('id' => $tel_detail[0], 'number' => $tel_detail[1], 'type' => $tel_detail[2], 'order' => $tel_detail[3]);
    }
}
$form1 = array('cli_salutation' => array('type' => 'select', 'group' => 'Full Name', 'label' => 'Salutation', 'value' => $cli_salutation, 'required' => 2, 'options' => join_arrays(array(array('' => ''), db_enum("client", "cli_salutation", "array"))), 'attributes' => array('style' => 'width:60px')), 'cli_fname' => array('type' => 'text', 'group' => 'Full Name', 'label' => 'Forename', 'value' => $cli_fname, 'init' => 'Forename(s)', 'required' => 2, 'attributes' => array('style' => 'width:100px', 'onFocus' => 'javascript:clearField(this,\'Forename(s)\')'), 'function' => 'format_name'), 'cli_sname' => array('type' => 'text', 'group' => 'Full Name', 'last_in_group' => 1, 'label' => 'Surname', 'value' => $cli_sname, 'init' => 'Surname', 'required' => 2, 'attributes' => array('style' => 'width:152px', 'onFocus' => 'javascript:clearField(this,\'Surname\')'), 'function' => 'format_name'), 'cli_tel' => array('type' => 'tel', 'label' => 'Telephone', 'value' => $telephone), 'cli_email' => array('type' => 'text', 'label' => 'Email', 'value' => $cli_email, 'required' => 3, 'attributes' => array('style' => 'width:320px', 'maxlength' => 255)));
$form2 = array('pro_addr1' => array('type' => 'text', 'label' => 'House Number', 'value' => $pro_addr1, 'required' => 2, '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_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'));
$sql = "SELECT * FROM cstatus WHERE cst_scope = 'Sales'";
$q = $db->query($sql);
while ($row = $q->fetchRow()) {
    if ($row["cst_id"] == $cli_salestatus) {
        $checked = ' checked="checked"';
    } else {
        unset($checked);
    }
    $statusRender .= '<div style="overflow:auto;">
<label class="formLabel">' . $row["cst_title"] . '</label>
<span class="required">
<input type="radio" name="cli_saleletstatus" value="' . $row["cst_id"] . '"' . $checked . ' />
</span>
 $result = new Validate();
 foreach ($_POST as $key => $val) {
     #$_POST[$key] = trim($val);
 }
 if ($_POST["form1"]) {
     $viewForm = 1;
     // extract notes from _POST and store in notes table
     if ($_POST["dea_notes_production"]) {
         $notes = $_POST["dea_notes_production"];
         $db_data_note = array('not_blurb' => $notes, 'not_row' => $dea_id, 'not_type' => 'deal_production', 'not_user' => $_SESSION["auth"]["use_id"], 'not_date' => $date_mysql);
         db_query($db_data_note, "INSERT", "note", "not_id");
     }
     unset($_POST["dea_notes_production"]);
     // add psubtype
     $addFormData1 = array('dea_psubtype' => array('label' => 'Property Type', 'required' => 2, 'value' => $_POST["dea_psubtype"]));
     $formData1 = join_arrays(array($formData1, $addFormData1));
     #print_r($formData3);
     $results = $result->process($formData1, $_POST);
     $db_data = $results['Results'];
     // build return link
     $return = $_SERVER['SCRIPT_NAME'] . '?stage=1&dea_id=' . $dea_id . '&searchLink=' . $searchLink . '&viewForm=' . $viewForm . '&';
     if ($results['Errors']) {
         if (is_array($results['Results'])) {
             $return .= http_build_query($results['Results']);
         }
         echo error_message($results['Errors'], urlencode($return));
         exit;
     }
     $dea_id = db_query($db_data, "UPDATE", "deal", "dea_id", $dea_id);
     if ($_POST["pro_area"]) {
         db_query(array('pro_area' => $_POST["pro_area"]), "UPDATE", "property", "pro_id", $_POST["pro_id"]);