$form->addData($formData4, $_GET);
     $form->addHtml(renderNotes('sot', $dea_id, array('viewform' => 4, 'label' => 'Status Notes')));
     $buttons = $form->makeField("submit", $formName, "", "Save Changes", array('class' => 'submit'));
 } else {
     if (is_array($additional_fields)) {
         $form->addData($additional_fields, $_GET);
     }
     $form->addData($formData4, $_GET);
     $form->addHtml(renderNotes('sot', $dea_id, array('viewform' => 4, 'label' => 'Status Notes')));
     $buttons = $form->makeField("submit", $formName, "", "Save Changes", array('class' => 'submit'));
 }
 if ($_GET["prompt"] == "app_production") {
     $buttons .= $form->makeField("button", "", "", "Book Production Appointment", array('class' => 'button', 'onClick' => 'document.location.href=\'production_add.php?stage=vendor&dea+id=' . $dea_id . '\''));
 }
 $form->addHtml($buttons);
 $form->addSeperator();
 $form->addHtml($form->addLabel('history', 'Status history', $sot_table));
 $form->addHtml('</div>');
 $form->addHtml("</fieldset>\n");
 $formName = 'form5';
 $form->addHtml("<fieldset>\n");
 $form->addLegend('Keys & Viewing Times', array('style' => 'cursor:pointer', 'onClick' => 'javascript:showHide(\'' . $formName . '\');'));
 $form->addHtml('<div id="' . $formName . '" style="display:none">');
 $form->addHtml($key_table);
 $form->addData($formData5, $_GET);
 $form->addHtml(renderNotes('viewing_arrangements', $dea_id, array('viewform' => 5, 'label' => 'View Times and Info')));
 $form->addHtml($form->addDiv($form->makeField("submit", $formName, "", "Save Changes", array('class' => 'submit'))));
 $form->addHtml('</div>');
 $form->addHtml("</fieldset>\n");
 $formName = 'form6';
 $form->addHtml("<fieldset>\n");
            $form2->addField("hidden", "carry", "", $_GET["carry"]);
            $form2->addField("hidden", "cli_name", "", $_GET["cli_name"]);
            $form2->addField("hidden", "date", "", $_GET["date"]);
            $form2->addHtml("<fieldset>\n");
            if ($form_title2b) {
                $form2->addLegend($form_title2b);
            } else {
                $form2->addLegend('New Client');
            }
            $form2->addData($formData1, $_GET);
            // allow lettings staff to enter applicants with no address
            // name of this button is noaddress, which is used on following page
            if (in_array('SuperAdmin', $_SESSION["auth"]["roles"]) || $_SESSION["auth"]["default_scope"] == 'Lettings') {
                $form2->addHtml($form2->addDiv($form->makeField("submit", "noaddress", "", "Save Changes (with no address)", array('class' => 'submit'))));
            }
            $form2->addSeperator();
            $form2->addRow('radio', 'p2c_type', 'Address Type', 'Home', '', db_enum("pro2cli", "p2c_type", "array"));
            if (!$_GET["pro_pro_id"]) {
                $form2->ajaxPostcode("by_freetext", "pro");
            } else {
                $form2->addData($formData2, $_GET);
                $form2->addHtml($form2->addDiv($form->makeField("submit", "", "", "Save Changes", array('class' => 'submit'))));
            }
            $form2->addHtml("</fieldset>\n");
            $form2->addHtml("</div>\n");
            $navbar_array = array('back' => array('title' => 'Back', 'label' => 'Back', 'link' => $return), 'search' => array('title' => 'Client Search', 'label' => 'Client Search', 'link' => 'client_search.php'));
            $navbar = navbar2($navbar_array);
            $additional_js = '
function validateForm() {
if (document.forms.existing_clients_form.cli_id.value == "") {
alert(\'Please select a client from the list\');