public function loadAction() { $type_form = new Admin_Model_Form(); $form_key = $this->getParam('key'); $form_data = $type_form->fetchRow(K_Db_Select::create()->where("type_form_id={$form_key}")); if ($form_data) { K_Loader::load('formbuilder', APP_PATH . '/plugins'); $form_builder = new Formbuilder(unserialize($form_data['type_form_content'])); $this->putAjax($form_builder->render_json()); } else { $this->putAjax('ERROR'); } }
public function exportcsvAction() { $request = $this->getRequest()->getParams(); // if(isset($request['source']) && $request['source'] == 'list') { // $whereSearch = "t1.state != 'Reviewing' and t1.state != 'Return' "; // } else { // $whereSearch = "1=1"; // } $where = "1=1"; foreach ($request as $k => $v) { if ($v) { if ($k == 'search_tag') { $where .= " and (t1.tag like '%{$v}%' or t1.project_info like '%{$v}%' or t1.code like '%{$v}%' or t1.name like '%{$v}%' or t1.description like '%{$v}%' or t1.remark like '%{$v}%' or t2.cname like '%{$v}%')"; } else { if ("search_category" == $k && $v) { $where .= " and t5.category = '{$v}'"; } else { if ("search_archive_date_from" == $k && $v) { $where .= " and t1.archive_time >= '" . str_replace('T', ' ', $v) . "'"; } else { if ("search_archive_date_to" == $k && $v) { $where .= " and t1.archive_time <= '" . str_replace('T00:00:00', ' 23:59:59', $v) . "'"; } else { $col = str_replace('search_', '', $k); if ($col != $k) { // 查询条件 $where .= " and t1." . $col . " like '%" . $v . "%'"; } } } } } } } $files = new Dcc_Model_Files(); $record = new Dcc_Model_Record(); // 获取物料数据 $data = $files->getFilesListForEdit($where, null, null); $data_csv = array(); $title = array('#', 'ID', '文件简号', '简号中文解释', '文件类别', '文件号', '版本', '文件名', '状态', '产品型号', '描述', '更改原因类型', '更改描述', '备注', '归档时间', '申请人', '申请时间', '自定义信息'); $title = $this->object_array($title); $date = date('YmdHsi'); $filename = "files_list" . $date; $path = "../temp/" . $filename . ".csv"; $file = fopen($path, "w"); $k = 0; for ($i = 0; $i < count($data); $i++) { $d = $data[$i]; $k++; $info = array('cnt' => $k, 'id' => $d['id'], 'prefix' => $d['type_code'], 'type_name' => $d['type_name'], 'category_name' => $d['category_name'], 'code' => $d['code'], 'ver' => 'V' . $d['ver'], 'name' => $d['name'], 'state' => $d['state'], 'project_name' => $d['project_name'], 'description' => $d['description'], 'reason_type' => $d['reason_type_name'], 'reason' => $d['reason'], 'remark' => $d['remark'], 'archive_time' => $d['archive_time'], 'creater' => $d['creater'], 'create_time' => $d['create_time']); // 获取自定义信息 $menu = 'oa_doc_files_' . $d['id']; $form = new Admin_Model_Form(); $dataform = $form->getAttrAndValByMenu($menu); foreach ($dataform as $row) { $name = $row['name']; $value = $row['value']; $info[] = "[{$name}]:[{$value}]"; } $d = $this->object_array($info); if ($i == 0) { fputcsv($file, $title); array_push($data_csv, $title); } array_push($data_csv, $info); fputcsv($file, $d); } fclose($file); $this->operate("文件导出"); echo $filename; exit; }
/** * @abstract 删除自定义表单 * @return null */ public function removeAction() { // 返回值数组 $result = array('success' => true, 'info' => '删除成功'); $request = $this->getRequest()->getParams(); $now = date('Y-m-d H:i:s'); $user_session = new Zend_Session_Namespace('user'); $user = $user_session->user_info['employee_id']; $json = json_decode($request['json']); $deleted = $json->deleted; $form = new Admin_Model_Form(); if (count($deleted) > 0) { foreach ($deleted as $val) { try { $form->delete("id = " . $val->id); } catch (Exception $e) { $result['result'] = false; $result['info'] = $e->getMessage(); echo Zend_Json::encode($result); exit; } } } echo Zend_Json::encode($result); exit; }