Exemplo n.º 1
0
function subtext($str, $start = 0, $end = 180)
{
    $str = strip_tags($str);
    $str = trim(str_replace(' ', '', $str));
    $str = preg_replace("/\\s/", "", $str);
    return cSubstr($str, $start, $end);
}
Exemplo n.º 2
0
 /**
  * 项目列表
  *@param $json    为NULL输出模板。为1时输出列表数据到前端,格式为Json
  *@param $method  为1时,单独输出记录数
  *@examlpe 
  */
 public function index($json = NULL, $method = NULL)
 {
     $Public = A('Index', 'Public');
     $App = A('App', 'Public');
     $role = $Public->check('Project', array('r'));
     //main
     if (!is_int((int) $json)) {
         $json = NULL;
     }
     $view = C('DATAGRID_VIEW');
     $page_row = C('PAGE_ROW');
     $comyid = $_SESSION['login']['se_comyID'];
     $comy = M('User_company_table');
     $userid = $_SESSION['login']['se_id'];
     $username = $_SESSION['login']['se_user'];
     $access = $Public->GS('User_group_table', $gid);
     $Project = M('Project_table');
     if ($json == 1) {
         $result = M();
         $get_sort = $this->_get('sort');
         $get_order = $this->_get('order');
         $sort = isset($get_sort) ? strval($get_sort) : 't1_old_status';
         $sort = str_replace('_new_', '_old_', $sort);
         $order = isset($get_order) ? strval($get_order) : 'asc';
         cookie('sort_Project', $sort);
         cookie('order_Project', $order);
         $Project_table = C('DB_PREFIX') . 'project_table';
         $Project_concern = C('DB_PREFIX') . 'project_concern_table';
         $Project_baseinfo = C('DB_PREFIX') . 'project_baseinfo_table';
         $Comy_table = C('DB_PREFIX') . 'user_company_table';
         $Linkage = C('DB_PREFIX') . 'linkage';
         $map = array();
         if (cookie('Project') || cookie('aProject')) {
             if (cookie('Project')) {
                 $str_map = cookie('Project');
                 $map = unserialize($str_map);
             } else {
                 $str_map = cookie('aProject');
                 $map = unserialize($str_map);
             }
             unset($str_map);
         } else {
             $map['id'] = "id>0";
             cookie('Project', serialize($map));
         }
         $protype = $comy->where('id=' . $comyid)->getField('type');
         if ($protype) {
             $map['client_id'] = ' and client_id=' . $comyid . ' and view_status=15';
         }
         if ($role == 'all' || in_array('a', $role)) {
             unset($map['order_where']);
             if ($st == 1) {
                 $map['client_id'] = " and client_id='" . $cid . "'";
                 $map['view_state'] = " and view_state=3";
             } else {
             }
         } else {
             $sql = $result->table($Project_concern . ' as tt1')->field('GROUP_CONCAT(tt1.pro_id ORDER BY tt1.pro_id) as pid')->where('tt1.user_id=' . $userid)->find();
             $map['order_where'] = " and (app_handler='" . $username . "' or pro_creator='" . $username . "' or id in(" . $sql['pid'] . "))";
         }
         //dump(unserialize(cookie('Project')));
         $map = implode($map, ' ');
         $get_page = $this->_get('page');
         $get_rows = $this->_get('rows');
         $page = isset($get_page) ? intval($get_page) : 1;
         $rows = isset($get_rows) ? intval($get_rows) : $page_row;
         $now_page = $page - 1;
         $offset = $now_page * $rows;
         $arr_flelds = array('id' => 't1.id as id', 'name' => 't1.name as name', 'status' => 't1.status as status', 'status2' => 't3.val as t1_new_status', 'status3' => 't3.sort as t1_old_status', 'view_state' => 't1.view_state as view_state', 'itemtype' => 't1.itemtype as itemtype', 'itemtype2' => 't4.val as t1_new_itemtype', 'itemtype3' => 't4.sort as t1_old_itemtype', 'client_id' => 't1.client_id as client_id', 'app_handler' => 'case t2.app_handler when \'\' then \'无\' else t2.app_handler end as app_handler', 'pro_creator' => 'case t2.pro_creator when \'\' then \'无\' else t2.pro_creator end as pro_creator', 'pro_creatdate' => 'case t2.pro_creatdate when \'\' then \'无\' else t2.pro_creatdate end as pro_creatdate', 'pro_progress' => 'case t2.pro_progress when \'\' then \'暂无\' else t2.pro_progress end as pro_progress', 'description' => 'case t2.description when \'\' then \'无\' else t2.description end as description');
         $fields = implode(',', $arr_flelds);
         if (!$view) {
             $info = $result->table($Project_table . ' as t1')->field('SQL_CALC_FOUND_ROWS ' . $fields)->join(' ' . $Project_baseinfo . ' as t2 on t2.pro_id = t1.id')->join(' ' . $Linkage . ' as t3 on t3.id = t1.status')->join(' ' . $Linkage . ' as t4 on t4.id = t1.itemtype')->having($map)->order($sort . ' ' . $order)->limit($offset, $rows)->select();
             $count = $result->query('SELECT FOUND_ROWS() as total');
             $count = $count[0]['total'];
         } else {
             $info = $result->table($Project_table . ' as t1')->field('SQL_CALC_FOUND_ROWS ' . $fields)->join(' ' . $Project_baseinfo . ' as t2 on t2.pro_id = t1.id')->join(' ' . $Linkage . ' as t3 on t3.id = t1.status')->join(' ' . $Linkage . ' as t4 on t4.id = t1.itemtype')->having($map)->order($sort . ' ' . $order)->select();
             $count = count($info);
         }
         //dump($info);exit;
         $new_info = array();
         $items = array();
         //$items = array_sort($items,$sort,$mode='nokeep',$type=$order);
         foreach ($info as $t) {
             if ((strlen(strip_tags($t['description'])) + mb_strlen(strip_tags($t['description']), 'UTF8')) / 2 > 45) {
                 $d_len = '...';
             } else {
                 $d_len = '';
             }
             $t['description'] = '<span title="' . htmlspecialchars($t['description']) . '">' . htmlspecialchars(cSubstr(strip_tags($t['description']), 0, 45) . $d_len) . '</span>';
             $t['pro_progress'] = '<span title="' . htmlspecialchars($t['pro_progress']) . '">' . htmlspecialchars($t['pro_progress']) . '</span>';
             $items[] = $t;
         }
         $new_info['total'] = $count;
         if ($method == 'total') {
             echo json_encode($new_info);
             exit;
         }
         $new_info['rows'] = $items;
         $new_info['footer'] = '';
         //dump($new_info);
         echo json_encode($new_info);
         unset($new_info, $info, $comy, $order, $sort, $count, $items, $fields, $result, $arr_status, $arr_plan);
     } else {
         $iinfo = $App->getJson('xiangmuleixing', 'Linkage/');
         $sinfo = $App->getJson('xiangmuzhuangtai', 'Linkage/');
         $this->assign('page_row', $page_row);
         $this->assign('iinfo', $iinfo);
         $this->assign('sinfo', $sinfo);
         $this->assign('cid', $cid);
         $this->display();
         unset($Public, $comy, $cinfo, $Project, $sinfo, $pinfo, $cinfo);
     }
 }
Exemplo n.º 3
0
 /**
  * 出差日志列表
  *@param $json    为NULL输出模板。为1时输出列表数据到前端,格式为Json
  *@param $method  为1时,单独输出记录数
  *@examlpe 
  */
 public function index($json = NULL, $method = NULL)
 {
     $Public = A('Index', 'Public');
     $role = $Public->check('Business', array('r'));
     //main
     if (!is_int((int) $json)) {
         $json = NULL;
     }
     $view = C('DATAGRID_VIEW');
     $page_row = C('PAGE_ROW');
     if ($json == 1) {
         $Business = M('Trip_daily');
         $result = M();
         $get_sort = $this->_get('sort');
         $get_order = $this->_get('order');
         $sort = isset($get_sort) ? strval($get_sort) : 't1_old_status';
         $sort = str_replace('_new_', '_old_', $sort);
         $order = isset($get_order) ? strval($get_order) : 'asc';
         $Business_table = C('DB_PREFIX') . 'trip_daily';
         $user = C('DB_PREFIX') . 'user_table';
         $map = array();
         if (cookie('Business') || cookie('aBusiness')) {
             if (cookie('Business')) {
                 $str_map = cookie('Business');
                 $map = unserialize($str_map);
             } else {
                 $str_map = cookie('aBusiness');
                 $map = unserialize($str_map);
             }
             unset($str_map);
         } else {
             $map['daily_date'] = 'TO_DAYS(NOW()) - TO_DAYS(DATE_FORMAT(daily_date,\'%Y-%m-%d\')) <= 30';
             cookie('Business', serialize($map));
         }
         //dump(unserialize(cookie('Business')));
         $map = implode($map, ' ');
         $get_page = $this->_get('page');
         $get_rows = $this->_get('rows');
         $page = isset($get_page) ? intval($get_page) : 1;
         $rows = isset($get_rows) ? intval($get_rows) : $page_row;
         $now_page = $page - 1;
         $offset = $now_page * $rows;
         $sql = $result->table($user . ' as tt1')->field('GROUP_CONCAT(tt1.username)')->where('tt1.id in (t1.user_id)')->select(false);
         $arr_flelds = array('id' => 't1.id as id', 'user_id' => 't1.user_id as user_id', 'status' => 't1.status as t1_old_status', 'status2' => 'CASE t1.status WHEN 1 THEN \'<div style="background-color: #9F0; width:100%; text-align:center;">正在出差</div>\' WHEN 2 THEN \'<div style="background-color: #fe6c6c; width:100%; text-align:center;">总结出差</div>\' WHEN 3 THEN \'<div style="background-color: #83a6fe; width:100%; text-align:center;">结束出差</div>\' END as t1_new_status', 'username' => 'concat_ws(\' \',' . $sql . ') as username', 'customer' => 'if(t1.customer<>\'\',t1.customer,\'无>\') as customer', 'daily_date' => 't1.daily_date as t1_old_daily_date', 'show_date' => 'if(HOUR(t1.daily_date)<14,concat(\'\',DATE_FORMAT(t1.daily_date,\'%Y-%m-%d\'),\' 上午\'),concat(\'\',DATE_FORMAT(t1.daily_date,\'%Y-%m-%d\'),\' 下午\')) as show_date', 'project' => 't1.project as project', 'purpose' => 't1.purpose as purpose', 'day_count' => 't1.day_count as t1_old_day_count', 'day_count2' => 'CONCAT(t1.day_count,\'天\') as t1_new_day_count', 'result' => 't1.result as result', 'checker' => 'if(t2.username<>\'\',t2.username,\'<span class="up-font-over">未审核</span>\') as checker');
         $fields = implode(',', $arr_flelds);
         unset($arr_flelds);
         if ($sort == 'daily_date') {
             $new_order = $sort . ' ' . $order;
         } else {
             $new_order = 'convert(' . $sort . ' using gbk) ' . $order;
         }
         if (!$view) {
             $info = $result->table($Business_table . ' as t1')->field('SQL_CALC_FOUND_ROWS ' . $fields)->having($map)->order($sort . ' ' . $order)->join(' ' . $user . ' as t2 on t2.id = t1.checker')->limit($offset, $rows)->select();
             $count = $result->query('SELECT FOUND_ROWS() as total');
             $count = $count[0]['total'];
         } else {
             $info = $result->table($Business_table . ' as t1')->field($fields)->having($map)->order($sort . ' ' . $order)->join(' ' . $user . ' as t2 on t2.id = t1.checker')->select();
             $count = count($info);
         }
         //dump($info);exit;
         $new_info = array();
         $items = array();
         $new_info['total'] = $count;
         if ($method == 'total') {
             echo json_encode($new_info);
             exit;
         }
         foreach ($info as $t) {
             if (strstr($t['username'], ',')) {
                 $t['username_one'] = '<span title="' . htmlspecialchars($t['username']) . '">' . substr($t['username'], 0, strpos($t['username'], ',')) . '...</span>';
             } else {
                 $t['username_one'] = $t['username'];
             }
             if ((strlen(strip_tags($t['purpose'])) + mb_strlen(strip_tags($t['purpose']), 'UTF8')) / 2 > 35) {
                 $d_len = '...';
             } else {
                 $d_len = '';
             }
             $t['purpose'] = htmlspecialchars(cSubstr(strip_tags($t['purpose']), 0, 35) . $d_len);
             if ((strlen(strip_tags($t['result'])) + mb_strlen(strip_tags($t['result']), 'UTF8')) / 2 > 35) {
                 $d_len = '...';
             } else {
                 $d_len = '';
             }
             if (strip_tags($t['result']) == '') {
                 $t['result'] = '暂无';
             } else {
                 $t['result'] = htmlspecialchars(cSubstr(strip_tags($t['result']), 0, 35) . $d_len);
             }
             $items[] = $t;
         }
         $new_info['rows'] = $items;
         echo json_encode($new_info);
     } else {
         $this->assign('page_row', $page_row);
         $this->display();
         unset($Public);
     }
 }