Example #1
0
/**
 * 初始化记账管理基本数据
 */
function init_bill_manage_data()
{
    $userId = (int) $_SESSION['userId'];
    $code = '0';
    // 加载账户列表
    $accountDefault = get_user_config('accountDefault');
    $accountService = new AccountService();
    $accountList = $accountService->getAccountSimpleList($userId, null);
    $accountDebtList = $accountService->getAccountSimpleList($userId, 2);
    $accountCreditList = $accountService->getAccountSimpleList($userId, 3);
    // 加载收支类别列表
    $billTypeService = new BillTypeService();
    $billTypeList = $billTypeService->getBillTypeSimpleList($userId, null);
    $billTypeInList = array();
    $billTypeOutList = array();
    foreach ($billTypeList as $row) {
        // print_r($row);
        $flag = (int) $row['bill_type_flag'];
        if ($flag == 1) {
            $billTypeInList[] = $row;
        } else {
            if ($flag == 0) {
                $billTypeOutList[] = $row;
            }
        }
    }
    $output = array('retCode' => $code, 'accountDefault' => $accountDefault, 'accountList' => $accountList, 'accountDebtList' => $accountDebtList, 'accountCreditList' => $accountCreditList, 'billTypeList' => $billTypeList, 'billTypeInList' => $billTypeInList, 'billTypeOutList' => $billTypeOutList);
    echo get_json($output);
}
 protected function _list($model, $map, $sortBy = '', $asc = false, $extend_attr = '')
 {
     //排序字段 默认为主键名
     if (isset($_REQUEST['_order'])) {
         $order = $_REQUEST['_order'];
     } else {
         if (!empty($sortBy)) {
             $order = $sortBy;
         } else {
             if (in_array('sort', get_model_fields($model))) {
                 $order = 'sort';
                 $asc = true;
             } else {
                 $order = $model->getPk();
             }
         }
     }
     //排序方式默认按照倒序排列
     //接受 sost参数 0 表示倒序 非0都 表示正序
     if (isset($_REQUEST['_sort'])) {
         $sort = $_REQUEST['_sort'] ? 'asc' : 'desc';
     } else {
         $sort = $asc ? 'asc' : 'desc';
     }
     //取得满足条件的记录数
     $count_model = clone $model;
     //取得满足条件的记录数
     //        dump($map);die;
     if (!empty($count_model->pk)) {
         $count = $count_model->where($map)->count($model->pk);
     } else {
         $count = $count_model->where($map)->count();
     }
     if ($count > 0) {
         import("@.ORG.Util.Page");
         //创建分页对象
         if (!empty($_REQUEST['list_rows'])) {
             $listRows = $_REQUEST['list_rows'];
         } else {
             $listRows = get_user_config('list_rows');
         }
         $p = new Page($count, $listRows);
         //分页查询数据
         $voList = $model->where($map)->order("`" . $order . "` " . $sort)->limit($p->firstRow . ',' . $p->listRows)->select();
         if ($extend_attr != '') {
             foreach ($extend_attr as $item) {
                 foreach ($voList as $key => $value) {
                     //                        var_dump($this->extend_process($item['param'],$value));
                     $voList[$key][$item['attr']] = $this->extend_process($item['param'], $value);
                 }
             }
         }
         $p->parameter = $this->_search();
         //分页显示
         $page = $p->show();
         //列表排序显示
         $sortImg = $sort;
         //排序图标
         $sortAlt = $sort == 'desc' ? '升序排列' : '倒序排列';
         //排序提示
         $sort = $sort == 'desc' ? 1 : 0;
         //排序方式
         //模板赋值显示
         $name = $this->getActionName();
         if ($name == "DutyRecord") {
             for ($i = 0; $i < count($voList); $i++) {
                 if ($voList[$i]["add_file"]) {
                     $file_arr = explode(';', $voList[$i]["add_file"]);
                     for ($j = 0; $j < count($file_arr) - 1; $j++) {
                         $file_model = D("File");
                         $where['sid'] = $file_arr[$j];
                         $file_msg = $file_model->where($where)->select();
                         $voList[$i]["pic"][] = $file_msg[0]['savename'];
                     }
                 }
             }
         }
         //var_dump($voList);
         $this->assign('list', $voList);
         $this->assign('sort', $sort);
         $this->assign('order', $order);
         $this->assign('sortImg', $sortImg);
         $this->assign('sortType', $sortAlt);
         $this->assign("page", $page);
     }
     return;
 }
 public function folder()
 {
     $widget['date-range'] = true;
     $this->assign("widget", $widget);
     $arr_read = explode("_", get_user_config("readed_notice"));
     $arr_readed_notice = array();
     $arr_readed_id = array();
     foreach ($arr_read as $key => $val) {
         $tmp = explode("|", $val);
         $notiec_id = $tmp[0];
         $create_time = $tmp[1];
         if ($create_time >= time() - 3600 * 24 * 30) {
             $arr_readed_notice[] = $val;
             $arr_readed_id[] = $notiec_id;
         }
     }
     $this->assign("readed_id", $arr_readed_id);
     $model = D("Notice");
     $map = $this->_search();
     if (method_exists($this, '_search_filter')) {
         $this->_search_filter($map);
     }
     $folder_id = $_REQUEST['fid'];
     $this->assign("folder_id", $folder_id);
     $map['folder'] = $folder_id;
     if (!empty($model)) {
         $this->_list($model, $map);
     }
     $this->assign("folder_name", D("SystemFolder")->get_folder_name($folder_id));
     $this->assign('auth', $this->config['auth']);
     $this->_assign_folder_list();
     $this->display();
 }
 function show_gongzi()
 {
     $userId = get_user_id();
     $userInfo = get_user_info($userId, 'id,name,emp_no,email,phone');
     import("@.ORG.Util.Page");
     $count = D('udf_salary')->where("emp_no = '" . $userInfo[$userId]['emp_no'] . "'")->count();
     if (!empty($_REQUEST['list_rows'])) {
         $listRows = $_REQUEST['list_rows'];
     } else {
         $listRows = get_user_config('list_rows');
     }
     $p = new Page($count, $listRows);
     $info = D('udf_salary')->where("emp_no = '" . $userInfo[$userId]['emp_no'] . "'")->limit($p->firstRow . ',' . $p->listRows)->select();
     //        $p->parameter = $this->_search();
     $page = $p->show();
     $this->assign('list', $info);
     $this->assign("page", $page);
     $this->display();
 }
Example #5
0
function get_new_count()
{
    $data = array();
    //获取待裁决
    $where = array();
    $FlowLog = M("WorkflowLog");
    $emp_no = get_emp_no();
    $where['emp_no'] = $emp_no;
    $where['_string'] = "result is null";
    $data['new_workflow_count'] = $FlowLog->where($where)->count();
    // 会议未读
    $user_id = get_user_id();
    $where = array();
    $where['user_id'] = $user_id;
    $where['is_del'] = array('eq', '0');
    $where['finish'] = array('elt', '0');
    $model = M("Meeting");
    $meeting_count = $model->where($where)->count();
    //    dump($meeting_count);die;
    $data['new_meeting_count'] = $meeting_count;
    // dump($data);
    //获取未读邮件
    $user_id = get_user_id();
    $where = array();
    $where['user_id'] = $user_id;
    $where['is_del'] = array('eq', '0');
    $where['folder'] = array(array('eq', 1), array('gt', 6), 'or');
    $where['read'] = array('eq', '0');
    $model = M("Mail");
    $new_mail_count = $model->where($where)->count();
    $data['new_mail_count'] = $new_mail_count;
    $data['new_mail_class'] = $new_mail_count == 0 ? '' : 'icon-animated-vertical';
    //获取待裁决
    $where = array();
    $FlowLog = M("FlowLog");
    $emp_no = get_emp_no();
    $where['emp_no'] = $emp_no;
    $where['_string'] = "result is null";
    $data['new_documentFlow_count'] = $FlowLog->where($where)->count();
    $data['new_documentFlow_class'] = $data['new_confirm_count'] == 0 ? '' : 'icon-animated-vertical';
    //获取最新通知,一个月以内未被阅读过的公告
    $model = D('Notice');
    $where = array();
    $where['is_del'] = array('eq', '0');
    $folder_list = D("SystemFolder")->get_authed_folder(get_user_id(), "NoticeFolder");
    $new_notice_count = 0;
    if ($folder_list) {
        $where['folder'] = array("in", $folder_list);
        $where['create_time'] = array('egt', time() - 3600 * 24 * 30);
        $new_notice_list = $model->where($where)->field('id')->select();
        $readed = get_user_config("readed_notice");
        if ($new_notice_list) {
            foreach ($new_notice_list as $key => $val) {
                if (!notice_readed($val['id'])) {
                    $new_notice_count++;
                }
            }
        }
    }
    $data['new_notice_count'] = $new_notice_count;
    $data['new_notice_class'] = $new_notice_count == 0 ? '' : 'icon-animated-bell';
    //获取待办事项
    $model = M("Todo");
    $where = array();
    $where['user_id'] = $user_id;
    $where['status'] = array("in", "1,2");
    $new_todo_count = M("Todo")->where($where)->count();
    $data['new_todo_count'] = $new_todo_count;
    //获取最新消息
    $model = M("Message");
    $where = array();
    $where['user_id'] = $user_id;
    $where['receiver_id'] = $user_id;
    $where['is_read'] = array('eq', '0');
    $new_message_count = M("Message")->where($where)->count();
    $data['new_message_count'] = $new_message_count;
    return $data;
}
Example #6
0
         } else {
             $object->addSoftkey('10', Aastra_get_label('Exit', $language), 'SoftKey:Exit');
         }
     }
 } else {
     # Load menu config file
     $all = Aastra_readINIfile($menu_source . '.menu', '#', '=');
     foreach ($all as $key => $value) {
         if ($value[$header['model']] == 'no') {
             unset($all[$key]);
         } else {
             $all[$key]['title'] = Aastra_get_label($all[$key]['title'], $language);
         }
     }
     # Load menu_user config file
     $config = get_user_config($menu_user, $menu_source, $menu_mode);
     # At least one menu?
     if (count($config['menu']) > 0) {
         # Retrieve last menu_page
         $nb_menu_pages = count($config['menu']);
         $last = intval($nb_menu_pages / $MaxLines);
         if ($nb_menu_pages - $last * $MaxLines != 0) {
             $last++;
         }
         if ($menu_page > $last) {
             $menu_page = $last;
         }
         # Display menu
         $object = new AastraIPPhoneTextMenu();
         $object->setDestroyOnExit();
         if ($menu_action == 'list' and $menu_pos != '') {
 private function _readed($id)
 {
     $folder_list = D("SystemFolder")->get_authed_folder(get_user_id());
     $map['folder'] = array("in", $folder_list);
     $map['create_time'] = array("egt", time() - 3600 * 24 * 30);
     $arr_read = array_filter(explode(",", get_user_config("readed_notice") . "," . $id));
     $map['id'] = array('in', $arr_read);
     $readed_notice = M("Notice")->where($map)->getField("id,name");
     $readed_notice = implode(",", array_keys($readed_notice));
     $where['id'] = array('eq', get_user_id());
     M("UserConfig")->where($where)->setField('readed_notice', $readed_notice);
 }
$is_textmenu_wrapitem = Aastra_is_textmenu_wrapitem_supported();
# Retrieve the size of the display
$chars_supported = Aastra_size_display_line();
if ($is_style_textmenu) {
    $chars_supported--;
}
# To handle non softkey phones
if ($nb_softkeys) {
    $MaxLines = AASTRA_MAXLINES;
} else {
    $MaxLines = AASTRA_MAXLINES - 2;
}
# Update URI
$XML_SERVER .= '?user='******'&source=' . $source . '&back=' . $back;
# Get user context
$ARRAY_USER = get_user_config($user);
# Get csv file location
$error = False;
$ARRAY_CONFIG = Aastra_readINIfile(AASTRA_CONFIG_DIRECTORY . 'directory.conf', '#', '=');
if ($ARRAY_CONFIG[$source]['location'] != '') {
    if ($ARRAY_CONFIG[$source]['speed'] == '0') {
        $SPEED = False;
    } else {
        $SPEED = True;
    }
    if ($ARRAY_CONFIG[$source]['mode'] == 'list') {
        $XML_SERVER .= '&mode=list';
        $mode = 'list';
        if ($action == 'input') {
            $action = 'lookup';
        }
Example #9
0
 public function receiving()
 {
     $this->_mailTime();
     $widget['date-range'] = true;
     $widget['uploader'] = true;
     $widget['editor'] = true;
     // $this -> assign("widget", $widget);
     $this->assign("widget", $widget);
     $this->_assign_mail_folder_list();
     $where = $this->_search();
     if (method_exists($this, '_search_filter')) {
         $this->_search_filter($where);
     }
     $where['is_del'] = 0;
     $where['folder'] = 1;
     $model = D('Mail');
     if (!empty($model->pk)) {
         $where['read'] = 0;
         $count1 = $model->where($where)->count($model->pk);
         $where['read'] = 1;
         $count2 = $model->where($where)->count($model->pk);
     } else {
         $where['read'] = 0;
         $count1 = $model->where($where)->count();
         $where['read'] = 1;
         $count2 = $model->where($where)->count();
     }
     if ($count1 > 0) {
         $where['read'] = 0;
         import("@.ORG.Util.Page");
         //创建分页对象
         if (!empty($_REQUEST['list_rows'])) {
             $listRows = $_REQUEST['list_rows'];
         } else {
             $listRows = get_user_config('list_rows');
         }
         $p = new Page($count1, $listRows);
         //分页查询数据
         $info1 = $model->where($where)->order('create_time desc')->limit($p->firstRow . ',' . $p->listRows)->select();
         $p->parameter = $this->_search();
         //分页显示
         $page1 = $p->show();
     }
     if ($count2 > 0) {
         $where['read'] = 1;
         import("@.ORG.Util.Page");
         //创建分页对象
         if (!empty($_REQUEST['list_rows'])) {
             $listRows = $_REQUEST['list_rows'];
         } else {
             $listRows = get_user_config('list_rows');
         }
         $p = new Page($count2, $listRows);
         //分页查询数据
         $info2 = $model->where($where)->order('create_time desc')->limit($p->firstRow . ',' . $p->listRows)->select();
         $p->parameter = $this->_search();
         //分页显示
         $page2 = $p->show();
     }
     $this->assign("noread_list", $info1);
     $this->assign("readed_list", $info2);
     $this->assign("page1", $page1);
     $this->assign("page2", $page2);
     $this->display();
 }
Example #10
0
 protected function _list($model, $map, $sortBy = '', $asc = false)
 {
     //排序字段 默认为主键名
     if (isset($_REQUEST['_order'])) {
         $order = $_REQUEST['_order'];
     } else {
         if (!empty($sortBy)) {
             $order = $sortBy;
         } else {
             if (in_array('sort', get_model_fields($model))) {
                 $order = 'sort';
                 $asc = true;
             } else {
                 $order = $model->getPk();
             }
         }
     }
     //排序方式默认按照倒序排列
     //接受 sost参数 0 表示倒序 非0都 表示正序
     if (isset($_REQUEST['_sort'])) {
         $sort = $_REQUEST['_sort'] ? 'asc' : 'desc';
     } else {
         if (strpos($sortBy, ',')) {
             $sort = '';
         } else {
             $sort = $asc ? 'asc' : 'desc';
         }
     }
     //取得满足条件的记录数
     $count_model = clone $model;
     //取得满足条件的记录数
     if (!empty($count_model->pk)) {
         $count = $count_model->where($map)->count($model->pk);
     } else {
         $count = $count_model->where($map)->count();
     }
     if ($count > 0) {
         import("@.ORG.Util.Page");
         //创建分页对象
         if (!empty($_REQUEST['list_rows'])) {
             $listRows = $_REQUEST['list_rows'];
         } else {
             $listRows = get_user_config('list_rows');
         }
         $p = new Page($count, $listRows);
         //分页查询数据
         if ($sort) {
             $voList = $model->where($map)->order("`" . $order . "` " . $sort)->limit($p->firstRow . ',' . $p->listRows)->select();
         } else {
             $voList = $model->where($map)->order($order)->limit($p->firstRow . ',' . $p->listRows)->select();
         }
         //echo $model->getlastSql();
         $p->parameter = $this->_search();
         //分页显示
         $page = $p->show();
         //列表排序显示
         $sortImg = $sort;
         //排序图标
         $sortAlt = $sort == 'desc' ? '升序排列' : '倒序排列';
         //排序提示
         $sort = $sort == 'desc' ? 1 : 0;
         //排序方式
         //模板赋值显示
         $name = $this->getActionName();
         $this->assign('list', $voList);
         $this->assign('sort', $sort);
         $this->assign('order', $order);
         $this->assign('sortImg', $sortImg);
         $this->assign('sortType', $sortAlt);
         $this->assign("page", $page);
     }
     return;
 }
Example #11
0
function checkUser()
{
    global $kga, $conn;
    $p = $kga['server_prefix'];
    if (isset($_COOKIE['kimai_usr']) && isset($_COOKIE['kimai_key']) && $_COOKIE['kimai_usr'] != "0" && $_COOKIE['kimai_key'] != "0") {
        $kimai_usr = addslashes($_COOKIE['kimai_usr']);
        $kimai_key = addslashes($_COOKIE['kimai_key']);
        if (get_seq($kimai_usr) != $kimai_key) {
            kickUser();
        } else {
            if (strncmp($kimai_usr, 'knd_', 4) == 0) {
                $knd_name = MySQL::SQLValue(substr($kimai_usr, 4));
                $query = "SELECT knd_ID FROM {$p}knd WHERE knd_name = {$knd_name} AND NOT knd_trash = '1';";
                $conn->Query($query);
                $row = $conn->RowArray(0, MYSQL_ASSOC);
                $knd_ID = $row['knd_ID'];
                if ($knd_ID < 1) {
                    kickUser();
                }
            } else {
                $query = "SELECT usr_ID,usr_sts,usr_grp FROM {$p}usr WHERE usr_name = '{$kimai_usr}' AND usr_active = '1' AND NOT usr_trash = '1';";
                $conn->Query($query);
                $row = $conn->RowArray(0, MYSQL_ASSOC);
                $usr_ID = $row['usr_ID'];
                $usr_sts = $row['usr_sts'];
                // User Status -> 0=Admin | 1=GroupLeader | 2=User
                $usr_grp = $row['usr_grp'];
                $usr_name = $kimai_usr;
                if ($usr_ID < 1) {
                    kickUser();
                }
            }
        }
    } else {
        kickUser();
    }
    if (isset($knd_ID) && $knd_ID < 1 || isset($usr_ID) && $usr_ID < 1) {
        kickUser();
    }
    // load configuration and language
    get_global_config();
    if (strncmp($kimai_usr, 'knd_', 4) == 0) {
        get_customer_config($knd_ID);
    } else {
        get_user_config($usr_ID);
    }
    // override default language if user has chosen a language in the prefs
    if ($kga['conf']['lang'] != "") {
        $kga['language'] = $kga['conf']['lang'];
        $kga['lang'] = array_replace_recursive($kga['lang'], include WEBROOT . "language/{$kga['language']}.php");
    }
    return isset($kga['usr']) ? $kga['usr'] : null;
}
Example #12
0
/**
 * 获取每页条目数
 */
function get_page_size()
{
    $size = get_user_config('pageSize');
    echo $size;
    return $size == null ? 20 : $size;
}
 function Sshen()
 {
     $map['uid'] = get_user_id();
     import("@.ORG.Util.Page");
     $count = D('leave')->where($map)->count();
     if (!empty($_REQUEST['list_rows'])) {
         $listRows = $_REQUEST['list_rows'];
     } else {
         $listRows = get_user_config('list_rows');
     }
     $p = new Page($count, $listRows);
     $list = D('leave')->where($map)->limit($p->firstRow . ',' . $p->listRows)->select();
     for ($i = 0; $i < count($list); $i++) {
         $list[$i]['user_name'] = D('user')->where('id=' . $list[$i]['uid'])->getField('emp_name');
         $list[$i]['dept_name'] = D('dept')->where('id=' . $list[$i]['dept'])->getField('name');
         if ($list[$i]['status'] == 0) {
             $list[$i]['status'] = "待部门领导审批";
         } elseif ($list[$i]['status'] == 1) {
             if ($list[$i]['kind'] == 2) {
                 $list[$i]['status'] = "待副总经理审批";
             } else {
                 $list[$i]['status'] = "待总经理审批";
             }
         } elseif ($list[$i]['status'] == 2) {
             $list[$i]['status'] = "待人事审批";
         } elseif ($list[$i]['status'] == 3) {
             $list[$i]['status'] = "已通过";
         } elseif ($list[$i]['status'] < 0) {
             $list[$i]['status'] = "已拒绝";
         }
         $list[$i]['tt'] = 2;
     }
     //        $p->parameter = $this->_search();
     $page = $p->show();
     $this->assign('type', 2);
     $this->assign('list', $list);
     $this->assign("page", $page);
     $this->display('list');
 }
Example #14
0
function get_new_count()
{
    $emp_no = get_emp_no();
    //获取未读邮件
    $data = array();
    $user_id = get_user_id();
    $where['user_id'] = $user_id;
    $where['is_del'] = array('eq', '0');
    $where['folder'] = array('eq', 1);
    $where['read'] = array('eq', '0');
    $new_mail_inbox = M("Mail")->where($where)->count();
    $data['bc-mail']['bc-mail-inbox'] = $new_mail_inbox;
    //获取未读邮件
    $where['user_id'] = $user_id;
    $where['is_del'] = array('eq', '0');
    $where['folder'] = array('gt', 6);
    $where['read'] = array('eq', '0');
    $new_mail_myfolder = M("Mail")->where($where)->count();
    $data['bc-mail']['bc-mail-myfolder'] = $new_mail_myfolder;
    //获取待裁决
    $where = array();
    $FlowLog = M("FlowLog");
    $where['emp_no'] = $emp_no;
    $where['_string'] = "result is null";
    $log_list = $FlowLog->where($where)->field('flow_id')->select();
    $log_list = rotate($log_list);
    $new_confirm_count = 0;
    if (!empty($log_list)) {
        $map['id'] = array('in', $log_list['flow_id']);
        $new_confirm_count = M("Flow")->where($map)->count();
    }
    $data['bc-flow']['bc-flow-confirm'] = $new_confirm_count;
    //获取收到的流程
    $where = array();
    $where['emp_no'] = $emp_no;
    $where['step'] = 100;
    $where['is_read'] = 1;
    $log_list = M("FlowLog")->where($where)->field('flow_id')->select();
    $log_list = rotate($log_list);
    $new_receive_count = 0;
    if (!empty($log_list)) {
        $map['id'] = array('in', $log_list['flow_id']);
        $new_receive_count = M("Flow")->where($map)->count();
    }
    $data['bc-flow']['bc-flow-receive'] = $new_receive_count;
    //获取最新通知
    $where = array();
    $where['is_del'] = array('eq', '0');
    $folder_list = D("SystemFolder")->get_authed_folder(get_user_id(), "NoticeFolder");
    $where['folder'] = array('in', $folder_list);
    $where['create_time'] = array("egt", time() - 3600 * 24 * 30);
    $readed = array_filter(explode(",", get_user_config("readed_notice")));
    $where['id'] = array("not in", $readed);
    $new_notice_count = M('Notice')->where($where)->count();
    $data['bc-notice']['bc-notice-new'] = $new_notice_count;
    //获取待办事项
    $where = array();
    $where['user_id'] = $user_id;
    $where['status'] = array("in", "1,2");
    $new_todo_count = M("Todo")->where($where)->count();
    $data['bc-personal']['bc-personal-todo'] = $new_todo_count;
    //获取日程事项
    $where = array();
    $where['user_id'] = $user_id;
    $where['start_date'] = array("elt", date("Y-m-d"));
    $where['end_date'] = array("egt", date("Y-m-d"));
    $new_schedule_count = M("Schedule")->where($where)->count();
    $data['bc-personal']['bc-personal-schedule'] = $new_schedule_count;
    //获取最新消息
    $model = M("Message");
    $where = array();
    $where['owner_id'] = $user_id;
    $where['receiver_id'] = $user_id;
    $where['is_read'] = array('eq', '0');
    $new_message_count = M("Message")->where($where)->count();
    $data['bc-message']['bc-message-new'] = $new_message_count;
    //等我接受的任务
    $where = array();
    $where_log['type'] = 1;
    $where_log['status'] = 0;
    $where_log['executor'] = get_user_id();
    $task_list = M("TaskLog")->where($where_log)->getField('task_id id,task_id');
    $where['id'] = array('in', $task_list);
    $task_todo_count = M("Task")->where($where)->count();
    $data['bc-task']['task_todo_count'] = $task_todo_count;
    //我部门任务
    $where = array();
    $auth = D("Role")->get_auth("Task");
    if ($auth['admin']) {
        $where_log['type'] = 2;
        $where_log['executor'] = get_dept_id();
        $task_list = M("TaskLog")->where($where_log)->getField('task_id id,task_id');
        $where['id'] = array('in', $task_list);
    } else {
        $where['_string'] = '1=2';
    }
    $task_dept_count = M("Task")->where($where)->count();
    $data['bc-task']['task_dept_count'] = $task_dept_count;
    return $data;
}
Example #15
0
/**
 * 删除账户
 */
function delete_account()
{
    $userId = $_SESSION['userId'];
    $accountId = $_REQUEST['accountId'];
    $accountTypeFlag = $_REQUEST['accountTypeFlag'];
    $code = '0';
    // 校验该用户下的账户数
    $accountService = new AccountService();
    $accountCount = $accountService->countAccount($userId, $accountTypeFlag);
    if ($accountCount == 1) {
        // 只剩一组帐户不能再删除
        $code = 'mustHaveAccount';
    } else {
        $billService = new BillService();
        //校验账户下是否有记账
        if ($billService->countBill(null, $accountId, null) > 0 || $billService->countBillDebtRelated($accountId) > 0) {
            $code = 'existBillInAccount';
        } else {
            $accountDefault = get_user_config('accountDefault');
            if ($accountId == $accountDefault) {
                //如果删除的是默认账户
                //取按照accountId排序最小的账户作为默认
                $minId = $accountService->getMinAccountId($userId);
                set_user_config('accountDefault', $minId);
                //更新到用户表
                $userService = new UserService();
                $userService->updateConfig($userId, $_SESSION['userDetail']['user_config']);
            }
            $accountService->deleteAccount($accountId);
        }
    }
    $output = array('retCode' => $code);
    echo get_json($output);
}
 protected function _list($model, $map, $sort = '')
 {
     //排序字段 默认为主键名
     if (isset($_REQUEST['_sort'])) {
         $sort = $_REQUEST['_sort'];
     } else {
         if (in_array('sort', get_model_fields($model))) {
             $sort = "sort asc";
         } else {
             if (empty($sort)) {
                 $sort = "id desc";
             }
         }
     }
     //取得满足条件的记录数
     $count_model = clone $model;
     //取得满足条件的记录数
     $count = $count_model->where($map)->count();
     if ($count > 0) {
         //创建分页对象
         if (!empty($_REQUEST['list_rows'])) {
             $list_rows = $_REQUEST['list_rows'];
         } else {
             $list_rows = get_user_config('list_rows');
         }
         import("@.ORG.Util.Page");
         $p = new \Page($count, $list_rows);
         //分页查询数据
         $vo_list = $model->where($map)->order($sort)->limit($p->firstRow . ',' . $p->listRows)->select();
         //echo $model->getlastSql();
         $p->parameter = $this->_search($model);
         //分页显示
         $page = $p->show();
         if ($vo_list) {
             $this->assign('list', $vo_list);
             $this->assign('sort', $sort);
             $this->assign("page", $page);
             return $vo_list;
         }
     }
     return FALSE;
 }