示例#1
0
<?php

$_SESSION['direct_to'] = BASE_URL . "covering_letter/";
include_once 'sessioninc.php';
$req = return_url();
$action = $req[1];
$id = $req[2];
$username = $session->get_username();
$user_id = $session->get_user_id();
$employee = Employee::find_by_id($user_id);
$covingletter = new CovingLetter();
$total_max_cl = CovingLetter::count_all_by_employee($user_id);
$smarty->assign('total_max_cl', $total_max_cl);
switch ($action) {
    case "add":
        if ($total_max_cl >= MAX_COVER_LETTER) {
            $v = format_lang('errormsg', 8);
            //exit;
            $session->message("<div class='error'>" . format_lang('errormsg', 8) . "</div>");
            redirect_to(BASE_URL . "covering_letter/");
            die;
        }
        //when add button is clicked
        if (isset($_POST['bt_cl_add'])) {
            if ($total_max_cl >= MAX_COVER_LETTER) {
                $session->message("<div class='error'>" . format_lang('errormsg', 8) . "</div>");
                redirect_to(BASE_URL . "covering_letter/");
                die;
            }
            $_SESSION['cl']['title'] = $covingletter->cl_title = strip_html($_POST['txt_name']);
            $_SESSION['cl']['text'] = $covingletter->cl_text = strip_tags($_POST['txt_letter'], "\n\t");