if (empty($pageCurrent)) {
    $pageCurrent = 1;
}
$pageLimit = webDataFilter('g', 'pagerow', 'int');
if (empty($pageLimit)) {
    $pageLimit = WEB_PAGE_RECORDS;
}
$data = array('page' => 0, 'total' => 0, 'records' => 0, 'rows' => array(), 'error' => array('errcode' => 0, 'errmsg' => ''));
$pageTotal = 1;
/*============================
 * Public Functions
 *===========================*/
/*============================
 * Main execution
 *===========================*/
$modelContact = new AlertContact();
$result_total = $modelContact->getContactCount(WebSession::get(PRODUCT_ID, 'tno'));
if ($result_total['success'] === true) {
    $count = $result_total['data'];
    unset($result_total);
    if ($count > 0) {
        $pageTotal = ceil($count / $pageLimit);
    }
    if ($pageCurrent > $pageTotal) {
        $pageCurrent = $pageTotal;
    }
    $start = $pageLimit * $pageCurrent - $pageLimit;
    // do not put $limit*($page - 1)
    $result_list = $modelContact->getContactList(WebSession::get(PRODUCT_ID, 'tno'), $start, $pageLimit);
    if ($result_list['success'] === true) {
        foreach ($result_list['data'] as $k => $v) {
if (is_null($ctno)) {
    $ctno = 0;
}
$sendAct = $_POST && isset($_POST['sendAct']) ? webDataFilter('p', 'sendAct', 'string') : '';
$name = $email = $mobileArea = $mobile = $sp = '';
/*============================
 * Public Functions
 *===========================*/
function printSuccessMsgBox()
{
    printHTMLContent('genStandalongJSBlock', array(genJSExistBoxWithCloseRedirect(WEB_JS_OKMSGBOX_ID, $GLOBALS['MOD_LANG']->getMessage('gl.txt.update.success'), WEB_ROOT . '/contact/')));
}
/*============================
 * Main execution
 *===========================*/
$modelContact = new AlertContact();
if (!empty($sendAct)) {
    $name = webDataFilter('p', 'name', 'string');
    $email = webDataFilter('p', 'email', 'email');
    $mobileArea = webDataFilter('p', 'mobileArea', 'string');
    $mobile = webDataFilter('p', 'mobile', 'string');
    $sp = webDataFilter('p', 'sp', 'string');
    switch ($sendAct) {
        case 'add':
            $param = array("login_no" => WebSession::get(PRODUCT_ID, 'tno'), "name" => &$name, "email" => &$email, "mobile_area" => &$mobileArea, "mobile" => &$mobile, "sp" => &$sp);
            $result = $modelContact->addContact($param);
            if ($result['success'] === false) {
                $view['jsErrMsg'] =& $result['errmsg'];
                //show add UI using post data
                $action = 'addPost';
                //no exit
{
    //i=3~4 will never use in this product
    $data = array();
    for ($i = 0; $i <= 6; $i++) {
        if (in_array($i, $target) === true) {
            $data[$i] = 'CHECKED';
        } else {
            $data[$i] = '';
        }
    }
    return $data;
}
/*============================
 * Main execution
 *===========================*/
$modelContact = new AlertContact();
if ($_POST) {
    $result = $modelContact->updateContactAlert($_POST['ctno'], $_POST['emailTypes'], $_POST['mobileTypes']);
    if ($result['success'] === false) {
        $view['jsErrMsg'] =& $result['errmsg'];
        //show add UI using post data
        $ctno =& $_POST['ctno'];
        $emailType = explode(',', $_POST['emailTypes']);
        $view['emailCheck'] = genChecedkArray($emailType);
        $mobileType = explode(',', $_POST['mobileTypes']);
        $view['mobileCheck'] = genChecedkArray($mobileType);
        $action = 'modifyPost';
        //no exit
    } else {
        //header("location: ".WEB_ROOT.'/contact/');
        printHTMLContent('genStandalongJSBlock', array(genJSExistBoxWithCloseRedirect(WEB_JS_OKMSGBOX_ID, $GLOBALS['MOD_LANG']->getMessage('gl.txt.update.success'), WEB_ROOT . '/contact/')));