public function getlistAction() { $request = $this->getRequest()->getParams(); $limit = $request['limit']; $start = $request['start']; $type = new Product_Model_Type(); $state = $this->getRequest()->getParam('search_state'); if (!$state) { $whereSearch = "t1.state != 'Reviewing' and t1.state != 'Return' "; } else { $whereSearch = "t1.state = '{$state}'"; } foreach ($request as $k => $v) { if ($v) { if ($k == 'search_tag') { $cols = array("t1.name", "t1.remark", "t1.manufacturers", "t1.code", "t1.description", "t3.cname"); $arr = preg_split('/\\s+/', trim($v)); for ($i = 0; $i < count($arr); $i++) { $tmp = array(); foreach ($cols as $c) { $tmp[] = "ifnull({$c},'')"; } $arr[$i] = "concat(" . implode(',', $tmp) . ") like '%" . $arr[$i] . "%'"; } $whereSearch .= " and " . join(' AND ', $arr); // $whereSearch .= " and (ifnull(t1.name,'') like '%$v%' or ifnull(t1.remark,'') like '%$v%' or ifnull(t1.manufacturers,'') like '%$v%' or ifnull(t1.code,'') like '%$v%' or ifnull(t1.description,'') like '%$v%' or ifnull(t3.cname,'') like '%$v%')"; } else { if ($k == 'search_state' && $v == 1) { $whereSearch .= " and (state = 'Active' or state = 'APL' or state = 'Preliminary')"; } else { if ("search_type" == $k && $v) { // $ids = $type->getTypes($v); // if($ids) { // $whereSearch .= " and t1.type in ($ids)"; // } $whereSearch .= " and t1.type in ({$v})"; } else { if ("search_archive_date_from" == $k && $v) { $whereSearch .= " and t1.archive_time >= '" . str_replace('T', ' ', $v) . "'"; } else { if ("search_archive_date_to" == $k && $v) { $whereSearch .= " and t1.archive_time <= '" . str_replace('T00:00:00', ' 23:59:59', $v) . "'"; } else { $col = str_replace('search_', '', $k); if ($col != $k) { // 查询条件 $whereSearch .= " and ifnull(t1." . $col . ",'') like '%" . $v . "%'"; } } } } } } } } $materiel = new Product_Model_Materiel(); $record = new Dcc_Model_Record(); // 获取物料数据 $data = $materiel->getList($whereSearch, $start, $limit); $count = $materiel->getCount($whereSearch, $start, $limit); $totalCount = $count; for ($i = 0; $i < count($data); $i++) { if (($typeId = $data[$i]['type']) != '') { $typeName = $this->getTypeByConnect($typeId, ''); $data[$i]['type_name'] = $typeName; } $data[$i]['create_time'] = strtotime($data[$i]['create_time']); $data[$i]['archive_time'] = strtotime($data[$i]['archive_time']); $data[$i]['record'] = $record->getHis($data[$i]['id'], 'materiel'); } $resutl = array("totalCount" => $totalCount, "topics" => $data); // 转为json格式并输出 echo Zend_Json::encode($resutl); exit; }