public function saveapptree() { $list = D('apptree'); $tids = explode(',', $_POST['sortvaue']); //数组转换 $list->delete('type=1 and link ="" and pid=' . $_POST[pid]); for ($i = 0; $i < count($tids); $i++) { $passshort = id_To_EValue('apptree', 'shortname', 'id', $_POST[pid]); $passtitle = id_To_EValue('Sys_tables', 'caption', 'id', $tids[$i]); $passtitle = substr($passtitle, strpos($passtitle, ']') + 1); $adddate[$i]['pid'] = $_POST[pid]; $adddate[$i]['tid'] = $tids[$i]; $adddate[$i]['title'] = $passtitle; $adddate[$i]['shortname'] = $passshort . '_' . $i; $adddate[$i]['type'] = 1; $adddate[$i]['projectid'] = $_SESSION[workingprojectid]; $adddate[$i]['seqNo'] = $i; $list->create($adddate[$i]); $list->add(); } //dump($adddate); //exit; $this->ajaxReturn('', '操作成功!', 1); }
function makeproviewmodel($id) { //生成基本VIEWMODEL $app_path = $this->getapppath(); //获取生成程序的根目录 $tpl_path = $this->gettplpath(); //获取程序模板的根目录 $tpl = new tpl($tpl_path . '/Model_tpl/viewmodel.tpl'); $field = D('Sys_viewfields'); $tables = $field->where('vid=' . $id, 'distinct `tid`')->findall(); //查出无序的数据 foreach ($tables as $tb) { $f = $field->findall("vid={$id} and tid={$tb['tid']}"); $tablename = id_To_EValue('sys_tables', 'title', 'id', $tb[tid]); $tablecaption = id_To_EValue('sys_tables', 'caption', 'id', $tb[tid]); $tablefield = $this->makeviewfield($f); //生成字段 $val_var_field[$i]['tablename'] = $tablename; $val_var_field[$i]['caption'] = $tablecaption; $val_var_field[$i]['field'] = $tablefield; $i++; } $condition = D('Sys_viewcondition'); $condition = $condition->where('vid=' . $id)->findall(); $viewmodel = D('Sys_viewmodel'); $viewmodel = $viewmodel->where('id=' . $id)->find(); $filename = $app_path . '/Lib/Model/' . $viewmodel['title'] . 'ViewModel.class.php'; $tpl->tplsign("name", $viewmodel['title']); //替换 $tpl->tplblocksign("val_var_field", $val_var_field); //替换 $tpl->tplblocksign("val_var_condition", $condition); //替换 $filecontent = $tpl->tplreturn(); writefile($filename, $filecontent); }
public function ajaxFields() { $fields = D('Sys_fields'); $key = $_REQUEST['id']; $pid = id_To_EValue('Sys_tables', 'datemodelid', 'id', $key); if ($pid != 0) { $sqlwhere = "pid ='{$key}' or pid='{$pid}'"; } else { $sqlwhere = "pid ='{$key}' "; } $list = $fields->findAll($sqlwhere, '*', 'seqNO asc'); $this->assign('list', $list); $this->display(); }