<?php
require_once '_admin_setting.php';

$theId = trim($_GET['id']);
$theId = is_numeric($theId) ? $theId : '';

$thePostData = array();

if ($theId) {
	$sql = "SELECT * FROM qa WHERE id = {$theId}";
	$qa = $nsodb->get_row($sql, ARRAY_A);
    $thaAction = 'update';
}

addHeaderJavascript('../javascripts/jquery/jquery.form.js');
addHeaderJavascript($nsoCkeditorJavascripts, $nsoSwfuploadScripts);
addHeaderJavascript('javascripts/qa_form.js');
require_once '_top.php';
require_once '_header.php';
require_once '_menuPane.php';
?>
<div id="godContentContainer">
    <div class="content_part">
        <div class="title"><h2>问答</h2></div>
        <div id="topToolbar" class="toolbar">
            <div class="tool_button">
                <div class="button save_button">保存<span class="deco_left"></span><span class="deco_right"></span></div>
            </div>
        </div>
        <div class="infobar">
            <div class="message_box">正在保存...</div>
        </div>
        <div class="content">
            <div class="form_content">
                <form id="postForm" action="qa_edit_action.php" method="post">
                    <table>
                        <tbody>
                            <tr>
                                <td class="label">标题</td>
                                <td>
                                    <div class="form_element form_element_title"><?php echo $qa['title']?></div>
                                </td>
                            </tr>
                            <tr>
                                <td class="label">问题</td>
                                <td>
                                    <div class="form_element form_element_title"><?php echo $qa['question']?></div>
                                </td>
                            </tr>
                           <tr>
                                <td class="label">名称</td>
                                <td>
                                    <div class="form_element form_element_title"><?php echo $qa['name']?></div>
                                </td>
                            </tr>
                            <tr>
                                <td class="label">电话</td>
                                <td>
                                    <div class="form_element form_element_title"><?php echo $qa['tel']?></div>
                                </td>
                            </tr>
                            <tr>
                                <td class="label">地址</td>
                                <td>
                                    <div class="form_element form_element_title"><?php echo $qa['address']?></div>
                                </td>
                            </tr>
                            <tr>
                                <td class="label">Email</td>
                                <td>
                                    <div class="form_element form_element_title"><?php echo $qa['email']?></div>
                                </td>
                            </tr>
                            <tr>
                                <td class="label">内容</td>
                                <td class="editor">
                                    <textarea class="editor" name="content"><?php echo $qa['answer'];?></textarea>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                    <div class="line"></div>
                    <input type="hidden" name="id" value="<?php echo $theId?>" id="form-post-id-input" />
                    <input type="hidden" name="action" value="<?php echo $thaAction?>" id="form-action-input" />
                </form>
            </div>
        </div>
        <div style="display:none">
            <div id="hiddenParamAddNewPostUri"><?php $addNewUri = explode('&', $_SERVER['REQUEST_URI']); echo $addNewUri[0];?></div>
        </div>
    </div>
</div>
<?php include_once '_bottom.php'; ?>