function arr2string($array) { if (is_array($array)) { $res = array(); foreach ($array as $item) { $res[] = arr2string($item); } return '[' . implode(',', $res) . ']'; } else { return $array; } }
/** * $data[0] $controllType 组件类型 lookup , lookupsuper * $data[1] $vo 页面vo数据 * $data[2] $controllProperty 当前组件的属性ID或属性数组 * $data[3] $isedit 是否为修改操作页面 * $data[4] $isreturnvalue 是否为view操作页面 * $data[5] $ganshe 干涉页面 状态归0 * @see Widget::render() */ public function render($data) { /** 数据收集 */ unset($vo); $controllType = $data[0]; //组件类型 lookup , lookupsuper $vo = $data[1]; //页面vo数据 $controllProperty = $data[2]; //当前组件的属性ID或属性数组 $isedit = $data[3]; //是否为修改操作页面 $isreturnvalue = $data[4]; //是否为view操作页面 $ganshe = $data[5]; //干涉页面 状态归0 $ismuchchoice = $data[6]; //是否多选 1是0否 /** 数据处理 */ $dir = CONF_PATH; $controlls = (require $dir . 'controlls.php'); require $dir . 'property.php'; $privateProperty = array(); foreach ($controlls as $key => $val) { if ($val['property']) { $privateProperty[$key] = array_merge($NBM_COMMON_PROPERTY, $val['property']); } else { $privateProperty[$key] = $NBM_COMMON_PROPERTY; } } $property = $privateProperty['lookup']; switch ($controllType) { case 1: $controllType = 'lookup'; break; case 2: $controllType = 'lookupsuper'; default: $controllType = 'lookup'; break; } if (!is_array($controllProperty)) { $obj = M('mis_dynamic_form_propery'); $controllProperty = $obj->where('id=' . $controllProperty)->find(); if ($ganshe == '1') { $controllProperty[$property['islock']['dbfield']] = 1; $controllProperty[$property['requiredfield']['dbfield']] = 1; $controllProperty[$property['isshow']['dbfield']] = 0; } } if (!is_array($controllProperty)) { return '<error>Lookup组件配置错误/没有属性<error>'; } /** 开始lookup属性解析 */ if (!$isreturnvalue) { $chtml = ''; if ($controllProperty[$property['checkfunc']['dbfield']]) { $chtml = $controllProperty[$property['checkfunc']['dbfield']]; } $required = ''; // 必填验证 if ($controllProperty[$property['requiredfield']['dbfield']] && $ganshe != '1') { $required = 'required'; } $chtml = $required . 'nbm ' . $chtml; //获取lookup key值 动态加载lookup配置 $lookupchoice = $controllProperty[$property['lookupchoice']['dbfield']]; $lookupObj = D('LookupObj'); $lookupDetail = $lookupObj->GetLookupDetail($lookupchoice); //var_dump($lookupDetail['condition']); $defaultLookupCondition = $lookupDetail['condition']; // lookup配置时生成的过滤条件。 $model = $lookupDetail['mode']; $urls = $lookupDetail['url']; $lookupgroup = $controllProperty[$property['lookupgroup']['dbfield']]; //视图特殊处理 if ($lookupDetail["viewname"]) { $viewname = $lookupDetail["viewname"]; //视图名称 $viewsavefield = $lookupDetail["val"]; //视图显示字段 $viewshowfield = $lookupDetail["filed"]; //视图存储字段 $dataViewModel = M("mis_system_dataview_mas"); $viewsql = "SELECT s.field FROM mis_system_dataview_mas AS m LEFT JOIN mis_system_dataview_sub AS s ON m.id=s.masid WHERE m.status=1 and s.status=1 and m.`name`='{$viewname}' AND s.otherfield="; //存储字段 $savefieldviewsql = $viewsql . "'{$viewsavefield}' limit 1"; $savefieldviewfieldarr = $dataViewModel->query($savefieldviewsql); $savefieldviewfieldexplode = explode(".", $savefieldviewfieldarr[0]['field']); $savefieldviewtable = $savefieldviewfieldexplode[0]; //存储字段所在的真实表名 $orgval = $savefieldviewfieldexplode[1]; //存储字段真实字段名 //显示字段 $showfieldviewsql = $viewsql . "'{$viewshowfield}' limit 1"; $showfieldviewfieldarr = $dataViewModel->query($showfieldviewsql); $showfieldviewfieldexplode = explode(".", $showfieldviewfieldarr[0]['field']); $showfieldviewtable = $showfieldviewfieldexplode[0]; //显示字段所在的真实表名 $orgchar = $showfieldviewfieldexplode[1]; //显示字段真实字段名 } else { $orgval = $lookupDetail['val'] ? $lookupDetail['val'] : 'id'; $orgchar = $lookupDetail['filed'] ? $lookupDetail['filed'] : 'name'; } $orgLookuoVal = $controllProperty[$property['org']['dbfield']]; // 值 value $orgLookupText = $controllProperty[$property['org1']['dbfield']]; // 显示内容 text $readonly = $controllProperty[$property['islock']['dbfield']] == 1 ? false : true; $view = ''; if ($lookupDetail['viewname']) { $view = '&viewname=' . $lookupDetail['viewname']; } if ($lookupDetail['dt']) { $dtcon = '&lookuptodatatable=2'; } $muchchoice = ''; if ($ismuchchoice == 1) { $muchchoice = '&ismuchchoice=' . $ismuchchoice; } // lookup的值反写 $textCounterCheck = ''; // 显示文本的反写 text $valCounterCheck = ''; // 值的反写 value // lporder 从外部lookup中取值字段 // lpkey 当前lookup的key // lpfor 往哪个东西里写值 // lpself 当前项的字段名称 if ($orgLookuoVal) { unset($temp); $temp = explode('.', $orgLookuoVal); $valCounterCheck = "callback=\"lookup_counter_check\" lpkey=\"{$lookupchoice}\" lpfor=\"{$lookupgroup}.{$orgchar}\" lpself=\"{$orgval}\" lporder=\"{$temp[1]}\""; } if ($orgLookupText) { unset($temp); $temp = explode('.', $orgLookupText); $textCounterCheck = "callback=\"lookup_counter_check\" lpkey=\"{$lookupchoice}\" lpfor=\"{$lookupgroup}.{$orgval}\" lpself=\"{$orgchar}\" lporder=\"{$temp[1]}\""; } // lookup附加条件处理 $appendCondtionArr = array(); $appendCondtion = $controllProperty[$property['additionalconditions']['name']]; // 附加条件设置信息 if ($appendCondtion) { $appendCondtion = unserialize(base64_decode($appendCondtion)); // proexp 表单字段列表 // sysexp 系统字段列表 $formFiledList = $appendCondtion['proexp']; $sysFieldList = $appendCondtion['sysexp']; // $formFiledFmt=array(); // $sysFieldFmt = array(); $sysFieldFmt = unserialize($sysFieldList) or array(); // 获取真实的表单字段名。 if ($formFiledList) { $formFiledListArr = unserialize($formFiledList) or array(); if (is_array($formFiledListArr) && count($formFiledListArr)) { $formFiledKey = array_keys($formFiledListArr); $properModel = M('mis_dynamic_form_propery'); $properMap['id'] = array('in', $formFiledKey); $fd = $properModel->where($properMap)->field('fieldname,id')->select(); if ($fd) { foreach ($fd as $k => $v) { // $fieldArr[] = $v['fieldname']; if ($formFiledListArr[$v['id']] == -1) { $formFiledFmt[$v['fieldname']] = $v['fieldname']; } else { $formFiledFmt[$v['fieldname']] = $formFiledListArr[$v['id']]; //$formFiledFmt[$formFiledListArr[$v['id']]] = $v['fieldname']; } } } } } if (is_array($sysFieldFmt) && is_array($formFiledFmt)) { $appendCondtionArr = array_merge($sysFieldFmt, $formFiledFmt); } elseif (is_array($sysFieldFmt) && !is_array($formFiledFmt)) { $appendCondtionArr = $sysFieldFmt; } elseif (!is_array($sysFieldFmt) && is_array($formFiledFmt)) { $appendCondtionArr = $formFiledFmt; } else { $appendCondtionArr = array(); } $conditions = getAppendCondition($vo, $formFiledFmt); $systemconditionsTemp = getAppendCondition($vo, $sysFieldFmt); // if($defaultLookupCondition){ // $systemconditions = $defaultLookupCondition; // if($systemconditionsTemp){ // $systemconditions .= ' and '.$systemconditionsTemp; // } // }else{ // $systemconditions = $systemconditionsTemp; // } $systemconditions = $systemconditionsTemp; } $val = ''; $tempModel = D($model); $temptable = ''; //视图时取字段对应的真实字段所在真实表名 if ($lookupDetail["viewname"]) { $temptable = $savefieldviewtable; } else { $temptable = $tempModel->getTableName(); } $map = ''; $value = $vo[$controllProperty[$property['fields']['dbfield']]]; if ($value) { if (strpos($value, ',')) { $valueStr = explode(',', $value); $map = $orgval . " in ('" . join("','", $valueStr) . "')"; } else { $map = $orgval . "='" . $value . "'"; } } //$viewval = $isedit ?(getFieldBy($value , $orgval , $orgchar , $tempModel->getTableName())):''; // if(!$map){ // $viewval=''; // }else{ // $viewval = $isedit ?(getFieldData($orgchar , $temptable , $map , true , 1000)):''; // } //多做了个分支,主要是应付视图里储存字段不唯一的情况 /** *当储存字段(以orderno=06为例)查询结果有n条记录,显示字段(以type为例)可以和储存字段保证一致性(当orderno=06时,查出的type全部都是“请假”) */ if (!$map) { $viewval = ''; } else { if (strpos($value, ',')) { $viewval = $isedit ? getFieldData($orgchar, $temptable, $map, true, 1000) : ''; } else { $viewval = $isedit ? getFieldBy($value, $orgval, $orgchar, $temptable) : ''; // } } $html = "<div class=\"tml-input-lookup\">"; $paramsEcho = arr2string($map); $controllPropertyEcho = '字段名:' . $controllProperty[$property['fields']['dbfield']] . '__表名:' . $tempModel->getTableName(); // $html.=<<<EOF // <script> // console.log("lookup查询条件:{$controllPropertyEcho}--{$orgchar}--查询条件:{$paramsEcho} 修改状态:{$isedit}"); // </script> // EOF; $readonlyCls = 'active_lookup'; if ($readonly) { $readonlyCls = ''; } $html .= "<input type=\"text\" {$textCounterCheck} class=\"{$lookupgroup}.{$orgchar} {$chtml} input_new half_angle_input {$orgLookupText} {$readonlyCls} \" autocomplete=\"off\" readonly=\"readonly\" value=\"" . $viewval . "\" />"; $html .= "<input type=\"hidden\" {$valCounterCheck} class=\"{$required} {$lookupgroup}.{$orgval} {$orgLookuoVal}\" name=\"" . $controllProperty[$property['fields']['dbfield']] . "\" value=\"" . $vo[$controllProperty[$property['fields']['dbfield']]] . "\" />"; if ($readonly) { // 只读情况 // lookup 触发按钮 $html .= "<a class=\"icon_elm mid_icon_elm icon-plus\"></a>"; // $title // 清空 lookup 按钮 $html .= "<a title=\"清空信息-只读\" class=\"icon_elm icon-trash\" href=\"javascript:void(0);\"></a>"; } else { $formFiledFmt = array_flip($formFiledFmt); $conditionOprateString = "condition=\"\""; if (is_array($formFiledFmt)) { $conditionOprateString = "condition=" . json_encode($formFiledFmt); } // lookup 触发按钮 $html .= "<a class=\"icon_elm mid_icon_elm icon-plus\" syscondition=\"{$systemconditions}\" newconditions=\"{$conditions}\" ismuchchoice=\"{$ismuchchoice}\" {$conditionOprateString} param=\"lookupchoice={$lookupchoice}{$muchchoice}&newconditions={$view}{$dtcon}\" href=\"__URL__/{$urls}\" lookupGroup=\"{$lookupgroup}\" ></a>"; //$title // 清空 lookup 按钮 $html .= "<a title=\"清空信息-可读写\" class=\"icon_elm icon-trash\" href=\"javascript:void(0);\" onclick=\"clearOrg('{$lookupgroup}');\"></a>"; } $html .= "</div>"; } else { $func = ""; $parmFunc = array(); // 处理子表及主表的lookup值转换 , modify by nbmxkj at 20150127 20 // *****注意:func 与 funcdata 数组项一定要个数对应。**** $scdmodel = D('SystemConfigDetail'); $detailList = $scdmodel->getDetail(MODULE_NAME, '', '', '', 'status'); $dval = $detailList[$controllProperty[$property['fields']['dbfield']]]; if (is_array($dval)) { if (count($dval['func']) > 0) { $varchar = ""; foreach ($dval['func'] as $k3 => $v3) { //开始html字符 if (isset($dval['extention_html_start'][$k3])) { $varchar = $dval['extention_html_start'][$k3]; } //中间内容 $varchar .= getConfigFunction($vo[$dval['name']], $v3, $dval['funcdata'][$k3], $vo); if (isset($dval['extention_html_end'][$k3])) { $varchar .= $dval['extention_html_end'][$k3]; } //结束html字符 } $html = $varchar; } else { $viewval = $vo[$controllProperty[$property['fields']['dbfield']]]; $html = $viewval; } } } return $html; }
function debug_header() { $this->debug_info .= "Trace information for debug purposes. Phreedom release " . MODULE_PHREEDOM_VERSION . ", generated " . date('Y-m-d H:i:s') . ".\n\n"; $this->debug_info .= "\nGET Vars = " . arr2string($_GET); $this->debug_info .= "\nPOST Vars = " . arr2string($_POST); $this->debug_info .= "\nREQUEST Vars = " . arr2string($_REQUEST); $this->debug_info .= "\nSESSION Vars = " . arr2string($_SESSION); }
function F($name, $value = '', $path = DATA_PATH) { static $_cache = array(); $filename = $path . $name . '.php'; if ('' !== $value) { if (is_null($value)) { // 删除缓存 return unlink($filename); } else { // 缓存数据 $dir = dirname($filename); // 目录不存在则创建 if (!is_dir($dir)) { mkdir($dir); } return file_put_contents($filename, strip_whitespace("<?php\nreturn " . arr2string($value) . ";\n?>")); } } if (isset($_cache[$name])) { return $_cache[$name]; } // 获取缓存数据 if (is_file($filename)) { $value = (include $filename); $_cache[$name] = $value; } else { $value = false; } return $value; }
/** * @Title: destroy * @Description: todo(销毁指定Action名称的所有文件) * @param string $actionName * @author quqiang * @date 2014-11-26 下午06:36:02 * @throws */ protected function destroy($actionName) { // 日志存储位置 $logsName = 'destriylogs_' . date('Ymd'); $tableName = ''; /** * 动态表单删除文件流程: * 1:销毁action、model、view、actionExtend、modelExtend、模板文件 * 2:销毁动态配置下的Models项、Sytem下的listInc * 3:动态表单的组件配置文件,动态表单的字段记录信息(MisAutoAnameList.inc.php), * 4:清DB数据 mis_auto_primary_mas 表 mis_auto_primary_sub * 5:表单(mis_dynamic_form_manage) 及 表单下的字段记录(mis_dynamic_form_field) */ // 检查Action是否存在 $actionFileName = LIB_PATH . "Action/" . $actionName . "Action.class.php"; if (!file_exists($actionFileName)) { logs("用户指定删除Action:{$actionName}不存在", $logsName); } // 得到当前action的表名。 $curModel = D($actionName); // 主表名称 $tableName = $curModel->getTableName(); // logs($tableName, $logsName); // 得到主表在表单记录中的Id然后找到所有datatable /** * 构建删除文件列表 * 1.Action , Model , View , ActionExtend , ModelExtend , Template * 2.销毁动态配置 */ /** * 单文件删除列表 * @var unknown_type */ $destriyFileList = array(); /** * 文件夹删除列表 * @var unknown_type */ $destriyFolderList = array(); // 1 // action , actionExtend $destriyFileList[] = LIB_PATH . "Action/" . $actionName . "Action.class.php"; $destriyFileList[] = LIB_PATH . "Action/" . $actionName . "ExtendAction.class.php"; // Model , ModelExtend , View $destriyFileList[] = LIB_PATH . "Model/" . $actionName . "Model.class.php"; $destriyFileList[] = LIB_PATH . "Model/" . $actionName . "ExtendModel.class.php"; $destriyFileList[] = LIB_PATH . "Model/" . $actionName . "ViewModel.class.php"; // 模板文件目录 $destriyFolderList[] = TMPL_PATH . C('DEFAULT_THEME') . '/' . $actionName; // 2 // Models , 组件配置文件 $dir = '/autoformconfig/'; $destriyFolderList[] = C('DYNAMIC_PATH') . '/Models/' . $actionName; $destriyFileList[] = C('DYNAMIC_PATH') . '/autoformconfig/' . $actionName . '.php'; /** * 删除表记录 * 1.删除模板 * 1.删除组件表propery * 2.删除sub表字段记录 * 3.删除mas表 * 4.内嵌表格删除 * */ $formid = getFieldBy($actionName, "actionname", "id", "mis_dynamic_form_manage"); //删除mas表 $deltemp = "DELETE FROM mis_dynamic_form_template WHERE formid={$formid}"; //删除组件记录表 $delpropery = "DELETE FROM mis_dynamic_form_propery WHERE formid={$formid}"; //查找当前表单主表 $tablename = getFieldBy($formid, "formid", "tablename", "mis_dynamic_database_mas", "isprimary", "1"); //查询表是否被复用 $ischoise = getFieldBy($tablename, "tablename", "tablename", "mis_dynamic_database_mas", "ischoise", "1"); //丢弃表SQL $droptable = ""; if (!$ischoise) { //删除mas表记录 $delMas = "DELETE FROM mis_dynamic_database_mas WHERE formid={$formid}"; //丢弃表 $droptable = "drop table " . $tablename; //删除sub表记录 $delSub = "DELETE FROM mis_dynamic_database_sub WHERE formid={$formid}"; } // 4.删除数据表。 $getDataTableSql = "SELECT\n\t\tCONCAT(tablename, '_sub_', `FIELD`) AS datatablename\n\t\tFROM\n\t\tmis_dynamic_database_sub AS sub,\n\t\t(SELECT\n\t\ttablename\n\t\tFROM\n\t\tmis_dynamic_database_mas\n\t\tWHERE id IN\n\t\t(SELECT\n\t\tmasid\n\t\tFROM\n\t\tmis_dynamic_database_sub\n\t\tWHERE formid = {$formid}\n\t\tAND category = 'datatable')) AS tablename\n\t\tWHERE sub.formid = {$formid}\n\t\tAND sub.category = 'datatable' "; /** * 删除数据表, * 先得到所有数据表格记录 * 1。删除字段记录表 * 2。删除内嵌表格的表 * 3. 删除表单记录 * 4. 删除当前使用表 */ // $delFieldSql = "DELETE FROM mis_dynamic_form_field WHERE formid ={$formid}"; $delDataTableSql = ""; $delFormSql = "DELETE FROM mis_dynamic_form_manage WHERE actionname='{$actionName}'"; if ($tableName) { $delSql = "DELETE FROM {$tableName}"; } logs('单文件删除列表:' . arr2string($destriyFileList), $logsName); logs('文件件删夹除列表:' . arr2string($destriyFolderList), $logsName); logs('数据表-字段记录删除:' . $delFieldSql, $logsName); logs('数据表-内嵌表删除:' . $delDataTableSql, $logsName); logs('数据表-表单记录删除:' . $delFormSql, $logsName); /** * 真实删除 */ foreach ($destriyFileList as $k => $v) { $ret = unlink($v); logs("文件 {$v} 删除" . ($ret ? '成功' : '失败'), $logsName); } foreach ($destriyFolderList as $k => $v) { $ret = deldir($v); logs("文件夹 {$v} 删除" . ($ret ? '成功' : '失败'), $logsName); } $modelObj = M(); $fieldDelRet = $modelObj->query($delFieldSql); logs("组件字段记录 {$delFieldSql} 删除 " . ($fieldDelRet ? '失败' : '成功'), $logsName); $formDelRet = $modelObj->query($delFormSql); logs("表单记录 {$delFormSql} 删除 " . ($formDelRet ? '失败' : '成功'), $logsName); if ($delSql) { $delRet = $modelObj->query($delSql); logs("表单记录 {$delFormSql} 删除 " . ($delRet ? '失败' : '成功'), $logsName); } else { logs("表 {$tableName} 不存在", $logsName); } // 删除数据表 $dataTableList = $modelObj->query($getDataTableSql); logs("删除数据表SQL {$getDataTableSql} ", $logsName); if ($dataTableList) { foreach ($dataTableList as $k => $v) { $delDataTableSql = "DROP TABLE {$v['datatablename']}"; // 删除数据表 $tempDelRet = $modelObj->query($delDataTableSql); logs("删除数据表 {$delDataTableSql} 删除 " . ($tempDelRet ? '失败' : '成功'), $logsName); } } //删除模板 $tempDelRet = $modelObj->query($deltemp); logs("删除模板 {$deltemp} 删除 " . ($tempDelRet ? '失败' : '成功'), $logsName); //删除组件 $properyDelRet = $modelObj->query($delpropery); logs("删除组件 {$delpropery} 删除 " . ($properyDelRet ? '失败' : '成功'), $logsName); //删除sub表 $subResult = $modelObj->query($delSub); logs("删除sub表 {$delSub} 删除 " . ($subResult ? '失败' : '成功'), $logsName); //删除mas表记录 $masResult = $modelObj->query($delMas); logs("删除mas表 {$delMas} 删除 " . ($masResult ? '失败' : '成功'), $logsName); $modelObj->commit(); }
/** * @Title: getControl * @Description: todo(将组件属性生成组件实际html代码) * * @param array $controllProperty * 组件信息 * @param boolean $isedit * 是否是编辑,默认flase:新增 * @param boolean $isreturnvalue * 是否直接显示值 * @param boolean $special * @author quqiang * @date 2014-8-21 上午10:12:43 * @throws * */ private function getControl($controllProperty, $isedit = false, $isreturnvalue = false, $special = true) { // 重新取得当前文件的list配置文件 if ($this->nodeName) { $path = DConfig_PATH . "/Models/" . $this->nodeName . "/list.inc.php"; $detailList = (require $path); $this->datalist = $detailList; } // print_r($this->datalist); // if($_POST['nodename']=='MisAutoPvb'){ // print_r($detailList); // } if (!is_array($controllProperty)) { return ''; } $property = $this->getProperty($controllProperty['catalog']); if ($controllProperty[$property['checkfunc']['name']]) { $chtml = $controllProperty[$property['checkfunc']['name']]; } $readonly = 0; $readonlyStr = ''; $islockHtml = '<div class="display_none {$classNodeSettingArr[\'' . $controllProperty[$property['fields']['name']] . '\']}">$viewval</div>'; if (!$controllProperty[$property['islock']['name']]) { $chtml .= " readonly"; $readonly = 1; $readonlyStr = "readonly=\"readonly\" "; } $html = ''; if ($controllProperty['catalog'] == 'tablabel') { $prefTag = "\t\t\t<label class=\"label_new\">" . $controllProperty[$property['title']['name']] . "</label>\r\n\t\t\t\t\t\t\t\t"; } else { $prefTag = "\t\t\t<label class=\"label_new\">{\$fields[\"" . $controllProperty[$property['fields']['name']] . "\"]}:</label>\r\n\t\t\t\t\t\t\t\t"; } $org = ''; if ($controllProperty[$property['org']['name']]) { $org = $controllProperty[$property['org']['name']]; } $required = ''; // 必填验证 if ($controllProperty[$property['requiredfield']['name']]) { $required = 'required'; } $dropback = "dropback=\"{$controllProperty[$property['dropback']['name']]}\""; $chtml = $required . ' ' . $chtml; // 读取当前list.inc.php文件 switch ($controllProperty['catalog']) { case 'text': // 绑定事件 $tagEvent = $controllProperty[$property['tagevent']['name']]; // 获取事件名 $calculate = $controllProperty[$property['calculate']['name']]; // 获取事件名 $tagEventSytr = ''; if ($tagEvent) { $tagEventSytr = 'on' . ucwords($tagEvent) . '="' . $this->nodeName . '_' . $controllProperty[$property['fields']['name']] . '_' . $tagEvent . '(this);"'; } $tagEventSytr = $dropback . ' ' . $tagEventSytr; $valStr = ''; $unitChangeStr = ''; if ($isedit) { $unitl = $controllProperty[$property['unitl']['name']]; $unitls = $controllProperty[$property['unitls']['name']]; if ($unitl && $unitls) { $unitChangeStr = "|unitExchange=###,{$unitl},{$unitls},2"; } $valStr = "{\$vo['{$controllProperty[$property['fields']['name']]}']{$unitChangeStr}}"; } if (!$isreturnvalue) { $unitlsStr = ''; $unitlsPanelStart = ''; $unitlsPanelEnd = ''; $unitlsCls = ''; $uFStr = ''; $defaultCls = 'input_new '; if ($controllProperty[$property['unitls']['name']]) { $unitlsPanelStart = "<div class=\"tml-input-unit\">"; $unitlsPanelEnd = '</div>'; $unitlsStr = "<span class=\"icon_elm icon_unit\" title=\"{$this->untils[$controllProperty[$property['unitls']['name']]]}\">{$this->untils[$controllProperty[$property['unitls']['name']]]}</span>"; // $unitlsCls=' unitlpase '; $defaultCls .= ' half_angle_input'; // $uFStr=" unitl=\"{$controllProperty[$property['unitls']['name']]}\" "; } $unitlsCls .= $defaultCls; // checkfor 属性设置 // checkfor 当 $controllProperty[$property['checkfortable']['name']] 指定了表名, // $controllProperty[$property['checkforshow']['name']] 显示字段 // $controllProperty[$property['checkforbindd']['name']] 绑定真实值 // 单换算功能 不能与checkfor功能同用,原因为:checkfor会生成hidden标签,单们换算也会生成hidden无法赋值。 /* * if($controllProperty[$property['unitls']['name']]){ * $html="\r\n\t\t\t\t\t{$prefTag}<input $tagEventSytr type=\"text\" {$readonlyStr} unitl=\"{$controllProperty[$property['unitls']['name']]}\" name=\"". * $controllProperty[$property['fields']['name']]."\" class=\"input_new {$org} {$unitlsCls} unitlpase {$chtml}\" value=\"".($isedit?"{\$vo['". * $controllProperty[$property['fields']['name']]."']}":'')."\">"; * }else{ 单位与checkfor 不共用 */ if ($controllProperty[$property['checkfortable']['name']]) { $insert = $controllProperty[$property['checkforbindd']['name']] ? htmlspecialchars("insert=\"" . $controllProperty[$property['checkforbindd']['name']] . "\"") : ''; // 隐藏域绑定字段名 $show = $controllProperty[$property['checkforshow']['name']] ? htmlspecialchars("show=\"" . $controllProperty[$property['checkforshow']['name']] . "\"") : ''; // 显示字段名 $table = $controllProperty[$property['checkfortable']['name']] ? htmlspecialchars("checkfor=\"" . $controllProperty[$property['checkfortable']['name']] . "\"") : ''; // checkfor查询表 $orderby = $controllProperty[$property['checkfororderby']['name']] ? htmlspecialchars("order=\"" . $controllProperty[$property['checkfororderby']['name']] . "\"") : ''; // 排序条件 $iswrite = $controllProperty[$property['checkforiswrite']['name']] ? htmlspecialchars("iswrite=\"" . $controllProperty[$property['checkforiswrite']['name']] . "\"") : ''; // 是否清除未找到内容 $fileds = $controllProperty[$property['checkfororfields']['name']] ? htmlspecialchars("fields=\"array(" . $controllProperty[$property['checkfororfields']['name']] . ");\"") : ''; // 查看字段 $map = $controllProperty[$property['checkformap']['name']] ? htmlspecialchars("newconditions=\"" . $controllProperty[$property['checkformap']['name']] . "\"") : ''; // 过滤条件 $org = ''; // 时当前文本框 没得name属性, if ($controllProperty[$property['checkforbindd']['name']]) { $iswrite = ''; $hiden = "<input type=\"hidden\" {$uFStr} name=\"" . $controllProperty[$property['fields']['name']] . "\" value=\"" . ($isedit ? "{\$vo['" . $controllProperty[$property['fields']['name']] . "']}" : '') . "\">"; $viewval = $isedit ? "{\$vo['" . $controllProperty[$property['fields']['name']] . "']|getFieldBy='{$controllProperty[$property['checkforbindd']['name']]}','{$controllProperty[$property['checkforshow']['name']]}','{$controllProperty[$property['checkfortable']['name']]}'}" : ''; $html = "\r\n\t\t\t\t\t{$prefTag}{$hiden}\r\n<input {$tagEventSytr} type=\"text\" {$readonlyStr} class=\"{$org} input_new {$unitlsCls} checkByInput {$chtml}\" \r\n" . "{$table} \r\n" . "{$insert} \r\n" . "{$show} \r\n" . "{$map} \r\n" . "{$orderby} \r\n" . "{$fileds} \r\n" . "{$iswrite} autocomplete=\"on\" value=\"" . $viewval . "\">"; // id:{$controllProperty[$property['checkforbindd']['name']]} $islockHtml = parameReplace('$viewval', $viewval, $islockHtml); } else { $viewval = $valStr; $html = "\r\n\t\t\t\t\t{$prefTag}<input {$uFStr} {$tagEventSytr} type=\"text\" {$readonlyStr} name=\"" . $controllProperty[$property['fields']['name']] . "\" class=\"{$org} {$unitlsCls} input_new {$chtml}\" value=\"" . $viewval . "\">"; $islockHtml = parameReplace('$viewval', $viewval, $islockHtml); } } else { $viewval = $valStr; $html = "\r\n\t\t\t\t\t{$prefTag}<input {$uFStr} {$tagEventSytr} type=\"text\" {$readonlyStr} name=\"" . $controllProperty[$property['fields']['name']] . "\" class=\"{$org} {$unitlsCls} input_new {$chtml}\" value=\"" . $valStr . "\">"; $islockHtml = parameReplace('$viewval', $viewval, $islockHtml); } // } } else { /* 查看页面单位转换 */ $unitChangeStr = ''; $unitl = $controllProperty[$property['unitl']['name']]; $unitls = $controllProperty[$property['unitls']['name']]; if ($unitl && $unitls) { $unitChangeStr = "|unitExchange=###,{$unitl},{$unitls},3"; } $valStr = "{\$vo['{$controllProperty[$property['fields']['name']]}']{$unitChangeStr}}"; /** * ************** */ if ($controllProperty[$property['checkfortable']['name']]) { if ($controllProperty[$property['checkforbindd']['name']]) { // id : {$controllProperty[$property['checkforbindd']['name']]} $viewval = ''; $html = "{\$vo['" . $controllProperty[$property['fields']['name']] . "']|getFieldBy='{$controllProperty[$property['checkforbindd']['name']]}','{$controllProperty[$property['checkforshow']['name']]}','{$controllProperty[$property['checkfortable']['name']]}'}"; } else { $viewval = ''; $html = $valStr; // "{\$vo['".$controllProperty[$property['fields']['name']]."']}"; } } else { $viewval = ''; $html = $valStr; // "{\$vo['".$controllProperty[$property['fields']['name']]."']}"; } // $viewval= ''; // $islockHtml=''; } $islockHtml = parameReplace('$viewval', $viewval, $islockHtml); $html = $unitlsPanelStart . htmlspecialchars_decode($html) . $unitlsStr . $unitlsPanelEnd . $islockHtml; break; case 'password': if (!$isreturnvalue) { $viewval = $isedit ? "{\$vo['" . $controllProperty[$property['fields']['name']] . "']}" : ''; $html = "<input type=\"password\" class=\" input_new\" name=\"" . $controllProperty[$property['fields']['name']] . "\" value=\"" . $viewval . "\" />"; $html = $prefTag . $html; } else { $viewval = '********'; $html = $viewval; } $islockHtml = parameReplace('$viewval', $viewval, $islockHtml); $html .= $islockHtml; break; case 'hiddens': if (!$isreturnvalue) { $viewval = $isedit ? "{\$vo['" . $controllProperty[$property['fields']['name']] . "']}" : ''; $html = "<input type=\"hidden\" class=\"{$org} input_new\" name=\"" . $controllProperty[$property['fields']['name']] . "\" value=\"" . $viewval . "\" />"; } else { $func = ""; foreach ($detailList as $dkey => $dval) { if ($dval['name'] == $controllProperty[$property['fields']['name']]) { if ($dval['func']) { $func .= $dval['func'][0][0]; if ($dval['func'][0][0] = "getFieldBy") { $func .= "="; } } if ($dval['funcdata']) { $func .= "'" . $dval['funcdata'][0][0][1]; if ($dval['funcdata'][0][0][2]) { $func .= "','" . $dval['funcdata'][0][0][2] . "','" . $dval['funcdata'][0][0][3] . "'}"; } else { $func .= "'}"; } } } } if ($func) { $viewval = ''; $html = "{\$vo['" . $controllProperty[$property['fields']['name']] . "']|" . $func; } else { $viewval = ''; $html = "{\$vo['" . $controllProperty[$property['fields']['name']] . "']}"; } // $viewval = ''; // $islockHtml=''; } $islockHtml = parameReplace('$viewval', $viewval, $islockHtml); $html .= $islockHtml; break; case 'tablabel': // $html="\r\n\t\t\t\t\t{$prefTag}\r\n<input class=\"{$org} nbm_tablabel\" value=\"\" type=\"text\" readonly=\"readonly\" disabled=\"disabled\" />"; // $html="\r\n\t\t\t\t\t{$prefTag}\r\n<input class=\"{$org} nbm_tablabel input_new \" value=\"\" type=\"text\" readonly=\"readonly\" disabled=\"disabled\" />"; $html = "\r\n\t\t\t\t\t{$prefTag}\r\n<input class=\"{$org} input_new nbm_tablabel\" value=\"\" type=\"text\" readonly=\"readonly\" disabled=\"disabled\" />"; if ($isreturnvalue) { // $viewval=''; // $islockHtml = ''; } $viewval = ''; $islockHtml = parameReplace('$viewval', $viewval, $islockHtml); $html .= $islockHtml; break; case 'subtitles': $html = "\r\n\t\t\t\t\t"; $style = "style=\""; if ($controllProperty[$property['aligntype']['name']]) { $style .= "text-align:" . $controllProperty[$property['aligntype']['name']] . ";"; } else { $style .= "text-align:{$property['aligntype']['default']};"; } if ($controllProperty[$property['backgroundcolor']['name']]) { $style .= "background:#" . $controllProperty[$property['backgroundcolor']['name']] . ";"; } else { $style .= "background:#{$property['backgroundcolor']['default']};"; } if ($controllProperty[$property['fontcolor']['name']]) { $style .= "color:#" . $controllProperty[$property['fontcolor']['name']] . ";"; } else { $style .= "color:#{$property['fontcolor']['default']};"; } if ($controllProperty[$property['fontsize']['name']]) { $style .= "font-size:" . $controllProperty[$property['fontsize']['name']] . "px;"; } else { $style .= "font-size:{$property['fontsize']['default']}px;"; } if ($controllProperty[$property['fontheight']['name']]) { $style .= "line-height:" . $controllProperty[$property['fontheight']['name']] . "px;"; } else { $style .= "line-height:{$property['fontheight']['default']}px;"; } if ($controllProperty[$property['fontweight']['name']]) { $style .= "font-weight:" . $controllProperty[$property['fontweight']['name']] . ";"; } else { $style .= "font-weight:{$property['fontweight']['default']};"; } $style .= "\""; $viewval = $controllProperty[$property['title']['name']]; $html .= "<div class=\"fieldset_legend_toggle side-catalog-text side-catalog-firstanchor\" {$style}>" . "{$viewval}" . "</div>"; if ($isreturnvalue) { // $viewval=''; // $islockHtml = ''; } $islockHtml = parameReplace('$viewval', $viewval, $islockHtml); $html .= $islockHtml; break; case 'fiexdtext': $html = "\r\n\t\t\t\t\t"; $style = "style=\""; if ($controllProperty[$property['aligntype']['name']]) { $style .= "text-align:" . $controllProperty[$property['aligntype']['name']] . ";"; } else { $style .= "text-align:{$property['aligntype']['default']};"; } if ($controllProperty[$property['backgroundcolor']['name']]) { $style .= "background:#" . $controllProperty[$property['backgroundcolor']['name']] . ";"; } else { $style .= "background:#{$property['backgroundcolor']['default']};"; } if ($controllProperty[$property['fontcolor']['name']]) { $style .= "color:#" . $controllProperty[$property['fontcolor']['name']] . ";"; } else { $style .= "color:#{$property['fontcolor']['default']};"; } if ($controllProperty[$property['fontsize']['name']]) { $style .= "font-size:" . $controllProperty[$property['fontsize']['name']] . "px;"; } else { $style .= "font-size:{$property['fontsize']['default']}px;"; } if ($controllProperty[$property['fontheight']['name']]) { $style .= "line-height:" . $controllProperty[$property['fontheight']['name']] . "px;"; } else { $style .= "line-height:{$property['fontheight']['default']}px;"; } /* * 高度影响 页面显示效果 * if($controllProperty[$property['contentheight']['name']]){ * $style .="height:".$controllProperty[$property['contentheight']['name']]."px;"; * }else{ * $style .="height:12px;"; * } */ if ($controllProperty[$property['fontweight']['name']]) { $style .= "font-weight:" . $controllProperty[$property['fontweight']['name']] . ";"; } else { $style .= "font-weight:{$property['fontweight']['default']};"; } // $style .="background:#".$controllProperty[$property['backgroundcolor']['name']]?$controllProperty[$property['backgroundcolor']['name']]:"fff".";"; // $style .="color:#".$controllProperty[$property['fontcolor']['name']]?$controllProperty[$property['fontcolor']['name']]:'333'.";"; // $style .="font-size:".$controllProperty[$property['fontsize']['name']]?$controllProperty[$property['fontsize']['name']]:'12' ."px;"; // $style .="line-height:".$controllProperty[$property['fontheight']['name']]?$controllProperty[$property['fontheight']['name']]:'12'."px;"; // $style .="height:".$controllProperty[$property['contentheight']['name']]?$controllProperty[$property['contentheight']['name']]:'12'."px;"; // $style .="font-weight:".$controllProperty[$property['fontweight']['name']]?$controllProperty[$property['fontweight']['name']]:"400".";\""; // "border:1px solid #d8d8d8;". $style .= "\""; // tml-form-text $viewval = $controllProperty[$property['title']['name']]; $html .= "<span class=\"block\" {$style}>{$viewval}</span>"; if ($isreturnvalue) { // $viewval=''; // $islockHtml = ''; } $islockHtml = parameReplace('$viewval', $viewval, $islockHtml); $html .= $islockHtml; break; case 'select': // 是否只读 $readonly = $controllProperty[$property['islock']['name']]; // 绑定的事件 $targevent = $controllProperty[$property['tagevent']['name']]; // 数据字段名 $filedName = $controllProperty[$property['fields']['name']]; // 组件标题 $filedTitle = $controllProperty[$property['title']['name']]; // 默认选中项的值 $defaultcheckitem = $controllProperty[$property['defaultcheckitem']['name']]; // 外部传入首选项的值 $defaultval = $controllProperty[$property['defaultval']['name']]; // 外部传入首选项的显示文本 $defaulttext = $controllProperty[$property['defaulttext']['name']]; // Action名称 $ActionName = $this->nodeName; // 直接显示内容的控制阀 $isshowresoult = $controllProperty[$property['isshowresoult']['name']]; // 下拉返回唯一标识 $dropbackkey = $controllProperty[$property['dropbackkey']['name']]; $conditions = ''; // 数据来源方式:table|selectlist if ($controllProperty[$property['showoption']['name']]) { $type = 'selectlist'; $key = $controllProperty[$property['showoption']['name']]; } else { if ($controllProperty[$property['subimporttableobj']['name']] || $controllProperty[$property['treedtable']['name']]) { $conditions = $controllProperty[$property['conditions']['name']]; $type = 'table'; if ($controllProperty[$property['subimporttableobj']['name']]) { // 查询表名 $tableName = $controllProperty[$property['subimporttableobj']['name']]; // 值字段名 $tableVal = $controllProperty[$property['subimporttablefield2obj']['name']]; // 显示字段名 $tableText = $controllProperty[$property['subimporttablefieldobj']['name']]; } elseif ($controllProperty[$property['treedtable']['name']]) { // 查询表名 $tableName = $controllProperty[$property['treedtable']['name']]; // 值字段名 $tableVal = $controllProperty[$property['treevaluefield']['name']]; // 显示字段名 $tableText = $controllProperty[$property['treeshowfield']['name']]; $parentid = $controllProperty[$property['treeparentfield']['name']]; // 是否末级操作 $mulit = $controllProperty[$property['mulit']['name']]; // 是否多选 $isnextend = $controllProperty[$property['isnextend']['name']]; // 树形-下拉高度 $treeheight = $controllProperty[$property['treeheight']['name']]; // 树形-下拉宽度 $treewidth = $controllProperty[$property['treewidth']['name']]; // 树形-是否对话框模式 $treedialog = $controllProperty[$property['isdialog']['name']] ? true : false; } } } // 组件外样式 $content_cls = "col_" . $controllProperty[$property['titlepercent']['name']] . "_" . $controllProperty[$property['contentpercent']['name']] . " form_group_lay field_" . $controllProperty[$property['fields']['name']]; $paramArr = ''; if ($isedit) { $paramArr .= "array(\$vo['{$controllProperty[$property['fields']['name']]}']"; } else { $paramArr .= "array(''"; } // 拼接class 属性 $cls = $chtml . ' ' . $org; // 拼接组件配置参数 $subassembly = ''; $subassembly .= "array('readonly'=>'{$readonly}','targevent'=>'{$targevent}','actionName'=>'{$ActionName}','names'=>'{$filedName}','defaultcheckitem'=>'{$defaultcheckitem}','defaultval'=>'{$defaultval}','defaulttext'=>'{$defaulttext}','table'=>'{$tableName}', 'id'=>'{$tableVal}','name'=>'{$tableText}','conditions'=>'{$conditions}','parentid'=>'{$parentid}','mulit'=>'{$mulit}','isnextend'=>'{$isnextend}','treeheight'=>'{$treeheight}','treewidth'=>'{$treewidth}','treedialog'=>'{$treedialog}','key'=>'{$key}','isedit'=>'{$isedit}','showtype'=>'{$isshowresoult}','dropbackkey'=>'{$dropbackkey}')"; $param = ''; $param .= "{$paramArr},array('{$cls}',array('type'=>'{$type}',{$subassembly})))"; if (!$isreturnvalue) { $viewval = ''; $html = "\r\n\t\t\t\t\t{$prefTag}"; if ($isedit) { if ($readonly) { $html .= "\r\n\t\t\t\t\t\t\t\t{:W('ShowSelect',{$param})}"; } else { $html .= "\r\n\t\t\t\t\t\t\t\t{:W('ShowSelect',{$param})}"; } } else { $html .= "\r\n\t\t\t\t\t\t\t\t{:W('ShowSelect',{$param})}"; } if ($controllProperty[$property['subimporttableobj']['name']]) { $viewval = "{\$vo['" . $controllProperty[$property['fields']['name']] . "']|getFieldBy='" . "{$controllProperty[$property['subimporttablefield2obj']['name']]}'" . ",'{$controllProperty[$property['subimporttablefieldobj']['name']]}'," . "'{$controllProperty[$property['subimporttableobj']['name']]}'}"; // 普通表数据 // $html=$viewval; } elseif ($controllProperty[$property['treedtable']['name']]) { $viewval = "{\$vo['" . $controllProperty[$property['fields']['name']] . "']|getFieldBy='" . "{$controllProperty[$property['treevaluefield']['name']]}'" . ",'{$controllProperty[$property['treeshowfield']['name']]}'," . "'{$controllProperty[$property['treedtable']['name']]}'}"; // 树形数据 // $html=$viewval; } else { $viewval = "{\$vo['{$controllProperty[$property['fields']['name']]}']|getSelectlistValue='{$controllProperty[$property['showoption']['name']]}'}"; // selectlist数据 // $html=$viewval; } } else { if ($controllProperty[$property['subimporttableobj']['name']]) { $viewval = "{\$vo['" . $controllProperty[$property['fields']['name']] . "']|getFieldBy='" . "{$controllProperty[$property['subimporttablefield2obj']['name']]}'" . ",'{$controllProperty[$property['subimporttablefieldobj']['name']]}'," . "'{$controllProperty[$property['subimporttableobj']['name']]}'}"; // 普通表数据 $html = $viewval; } elseif ($controllProperty[$property['treedtable']['name']]) { $viewval = "{\$vo['" . $controllProperty[$property['fields']['name']] . "']|getFieldBy='" . "{$controllProperty[$property['treevaluefield']['name']]}'" . ",'{$controllProperty[$property['treeshowfield']['name']]}'," . "'{$controllProperty[$property['treedtable']['name']]}'}"; // 树形数据 $html = $viewval; } else { $viewval = "{\$vo['{$controllProperty[$property['fields']['name']]}']|getSelectlistValue='{$controllProperty[$property['showoption']['name']]}'}"; // selectlist数据 $html = $viewval; } // $viewval=''; // $islockHtml = ''; } $islockHtml = parameReplace('$viewval', $viewval, $islockHtml); $html .= $islockHtml; break; case 'checkbox': $checked = ""; $tagEvent = $controllProperty[$property['tagevent']['name']]; // 获取事件名 $conditions = ''; $tagEventSytr = ''; if ($tagEvent) { $tagEventSytr = 'on' . ucwords($tagEvent) . '="' . $this->nodeName . '_' . $controllProperty[$property['fields']['name']] . '_' . $tagEvent . '(this)"'; } $html = "\r\n\t\t\t\t\t{$prefTag}"; if (!$isreturnvalue) { $viewval = ''; if ($controllProperty[$property['subimporttableobj']['name']]) { $conditions = $controllProperty[$property['conditions']['name']]; $html .= "{:getControllbyHtml('table',array('type'=>'checkbox','names'=>'{$controllProperty[$property['fields']['name']]}[]','targevent'=>'{$tagEventSytr}','table'=>'{$controllProperty[$property['subimporttableobj']['name']]}','id'=>'{$controllProperty[$property['subimporttablefield2obj']['name']]}','name'=>'{$controllProperty[$property['subimporttablefieldobj']['name']]}','conditions'=>'{$conditions}','selected'=>\$vo['{$controllProperty[$property['fields']['name']]}']))}"; } else { $html .= "{:getControllbyHtml('selectlist',array('type'=>'checkbox','names'=>'{$controllProperty[$property['fields']['name']]}[]','targevent'=>'{$tagEventSytr}','key'=>'{$controllProperty[$property['showoption']['name']]}','selected'=>\$vo['{$controllProperty[$property['fields']['name']]}']))}"; } } else { if ($controllProperty[$property['subimporttableobj']['name']]) { $viewval = "{\$vo['" . $controllProperty[$property['fields']['name']] . "']|excelTplidTonameAppend=" . "'{$controllProperty[$property['subimporttablefield2obj']['name']]}'," . "'{$controllProperty[$property['subimporttablefieldobj']['name']]}'" . ",'{$controllProperty[$property['subimporttableobj']['name']]}'}"; $html = $viewval; } else { $viewval = "{\$vo['{$controllProperty[$property['fields']['name']]}']|getSelectlistByName='{$controllProperty[$property['showoption']['name']]}'}"; $html = $viewval; } $viewval = ''; $islockHtml = ''; } $islockHtml = parameReplace('$viewval', $viewval, $islockHtml); $html .= $islockHtml; break; case 'radio': $checked = ""; $conditions = ''; $tagEvent = $controllProperty[$property['tagevent']['name']]; // 获取事件名 $tagEventSytr = ''; if ($tagEvent) { $tagEventSytr = 'on' . ucwords($tagEvent) . '="' . $this->nodeName . '_' . $controllProperty[$property['fields']['name']] . '_' . $tagEvent . '(this)"'; } if (!$isreturnvalue) { $html = "\r\n\t\t\t\t\t{$prefTag}"; if ($controllProperty[$property['subimporttableobj']['name']]) { $conditions = $controllProperty[$property['conditions']['name']]; $html .= "{:getControllbyHtml('table',array('type'=>'radio','targevent'=>'{$tagEventSytr}','names'=>'{$controllProperty[$property['fields']['name']]}','table'=>'{$controllProperty[$property['subimporttableobj']['name']]}','id'=>'{$controllProperty[$property['subimporttablefield2obj']['name']]}','name'=>'{$controllProperty[$property['subimporttablefieldobj']['name']]}','conditions'=>'{$conditions}','selected'=>\$vo['{$controllProperty[$property['fields']['name']]}']))}"; } else { $html .= "{:getControllbyHtml('selectlist',array('type'=>'radio','targevent'=>'{$tagEventSytr}','names'=>'{$controllProperty[$property['fields']['name']]}','key'=>'{$controllProperty[$property['showoption']['name']]}','selected'=>\$vo['{$controllProperty[$property['fields']['name']]}']))}"; } } else { if ($controllProperty[$property['subimporttableobj']['name']]) { $viewval = "{\$vo['" . $controllProperty[$property['fields']['name']] . "']|getFieldBy='" . "{$controllProperty[$property['subimporttablefield2obj']['name']]}'" . ",'{$controllProperty[$property['subimporttablefieldobj']['name']]}'," . "'{$controllProperty[$property['subimporttableobj']['name']]}'}"; $html = $viewval; } else { $viewval = "{\$vo['{$controllProperty[$property['fields']['name']]}']|getSelectlistValue='{$controllProperty[$property['showoption']['name']]}'}"; $html = $viewval; } // $islockHtml = ''; } $islockHtml = parameReplace('$viewval', $viewval, $islockHtml); $html .= $islockHtml; break; case 'textarea': $html = ''; $richBoxCls = ''; if ($controllProperty[$property['isrichbox']['name']]) { $richBoxCls = 'ueditor'; } if (!$isreturnvalue) { $rows = 4; $cols = 100; if ($controllProperty[$property['rows']['name']]) { $rows = $controllProperty[$property['rows']['name']]; } if ($controllProperty[$property['cols']['name']]) { $cols = $controllProperty[$property['cols']['name']]; } $viewval = $isedit ? "{\$vo['" . $controllProperty[$property['fields']['name']] . "']}" : ''; $val = ""; if ($viewval) { $textareahtml = "<if condition=\"\$vo['" . $controllProperty[$property['fields']['name']] . "']\">{\$vo['" . $controllProperty[$property['fields']['name']] . "']}<else/>" . $controllProperty[$property['defaultval']['name']] . "</if>"; } else { $textareahtml = ""; } $html = "\r\n\t\t\t\t\t{$prefTag}<textarea {$readonlyStr} cols=\"{$cols}\" rows=\"{$rows}\" class=\"{$chtml} text_area {$richBoxCls} {$org}\" name=\"" . $controllProperty[$property['fields']['name']] . "\">" . $textareahtml . "</textarea>"; // .$islockHtml; } else { if ($controllProperty[$property['isrichbox']['name']]) { $viewval = "{\$vo['{$controllProperty[$property['fields']['name']]}']|richtext2str}"; } else { $viewval = "{\$vo['{$controllProperty[$property['fields']['name']]}']}"; } $html = $viewval; // $islockHtml = ''; // $viewval = ''; } $islockHtml = parameReplace('$viewval', $viewval, $islockHtml); if ($controllProperty[$property['isrichbox']['name']]) { $islockHtml = ''; } $html .= $islockHtml; break; case 'date': $style = ""; $format = ''; $format1 = ''; $formatSouce = ''; if ($controllProperty[$property['format']['name']]) { $formatSouce = $controllProperty[$property['format']['name']]; } else { $formatSouce = $property['format']['default']; } if ($formatSouce) { $temp = ''; $temp = explode('@', $formatSouce); $format = "format=\"{dateFmt:'" . $temp[0] . "'}\""; if ($temp[1]) { $format1 = "='{$temp[1]}'"; } } if (!$isreturnvalue) { // 直接显示内容的控制阀 $isshowresoult = $controllProperty[$property['isshowresoult']['name']]; $dateControllCls = ''; $dateJsEventTag = ' Wdate js-wdate'; $a = 'js-inputCheckDate'; // 只读 if (!$controllProperty[$property['islock']['name']]) { $a = ''; $dateJsEventTag = ''; $dateControllCls = $chtml; } if ($isedit) { $viewval = "{\$vo['" . $controllProperty[$property['fields']['name']] . "']|transtime{$format1}}"; $html = "\r\n\t\t\t\t\t{$prefTag}"; if ($isshowresoult) { $html .= "\r\n\t\t\t\t\t<span class=\"input_new\">{$viewval}</span>"; } else { $html .= "\r\n\t\t\t\t\t<div class=\"tml-input-calendar\">\r\n\t\t\t\t\t<input type=\"text\" name=\"" . $controllProperty[$property['fields']['name']] . "\" class=\"{$required} {$org} input_new half_angle_input {$dateJsEventTag} input_left {$dateControllCls}\" {$format} {$readonlyStr} value=\"{$viewval}\"/>"; $html .= "\r\n\t\t\t\t\t<a href=\"javascript:;\" class=\"icon_elm icon-calendar {$a} \"></a>"; $html .= "\r\n\t\t\t\t</div>"; } } else { $viewval = ''; $html = "\r\n\t\t\t\t\t{$prefTag}"; if ($isshowresoult) { $html .= "\r\n\t\t\t\t\t<span class=\"input_new\">{$viewval}</span>"; } else { $html .= "\r\n\t\t\t\t\t<div class=\"tml-input-calendar\">\r\n\t\t\t\t\t<input type=\"text\" name=\"" . $controllProperty[$property['fields']['name']] . "\" class=\"{$required} {$org} input_new half_angle_input {$dateJsEventTag} input_left {$dateControllCls}\" {$format} {$readonlyStr} value=\"{$viewval}\"/>"; $html .= "\r\n\t\t\t\t\t<a href=\"javascript:;\" class=\"icon_elm icon-calendar {$a} \"></a>"; } $html .= "\r\n\t\t\t\t</div>"; } } else { $viewval = "{\$vo['" . $controllProperty[$property['fields']['name']] . "']|transtime{$format1}}"; $html = $viewval; // $islockHtml = ''; // $viewval= ''; } $islockHtml = parameReplace('$viewval', $viewval, $islockHtml); $html .= $islockHtml; break; case 'checkfor': break; case 'lookup': $html = ''; if (!$isreturnvalue) { $lookupchoice = $controllProperty[$property['lookupchoice']['name']]; $lookupObj = D('LookupObj'); $lookupDetail = $lookupObj->GetLookupDetail($lookupchoice); $model = $lookupDetail['mode']; $orgchar = $lookupDetail['filed'] ? $lookupDetail['filed'] : 'name'; $orgval = $lookupDetail['val'] ? $lookupDetail['val'] : 'id'; if (1 == $lookupDetail['viewtype'] && $orgval != $orgchar) { $configObj = D('MisSystemDataviewMasView'); $viewConfig = $configObj->getViewConf($lookupDetail['viewname']); $searchField = $viewConfig[$orgval]['searchField']; $orderModelArr = explode('.', $searchField); if ($orderModelArr[0] && $searchField) { $tempModel = D($orderModelArr[0]); } } else { $tempModel = D($model); } // 当lookup配置中的存储值与显示一致时不需要做值转换。nbmxkj@20150608 1610 $viewval = $isedit ? $orgval == $orgchar ? "{\$vo['" . $controllProperty[$property['fields']['name']] . "']}" : "{\$vo['" . $controllProperty[$property['fields']['name']] . "']|getFieldBy='{$orgval}','{$orgchar}','{$tempModel->getTableName()}'}" : ''; $html = "\r\n\t\t\t\t\t\t{$prefTag}"; } else { $func = ""; // 处理子表及主表的lookup值转换 , modify by nbmxkj at 20150127 20 // *****注意:func 与 funcdata 数组项一定要个数对应。**** foreach ($this->datalist as $dkey => $dval) { if ($dval['name'] == $controllProperty[$property['fields']['name']]) { $count = count($dval['func'][0]); if ($dval['func']) { $func .= $dval['func'][0][$count - 1]; // if($dval['func'][0][0]="getFieldBy"){ $func .= "="; // } } if ($dval['funcdata']) { $func .= "'" . $dval['funcdata'][0][$count - 1][1]; if ($dval['funcdata'][0][$count - 1][1]) { $func .= "','" . $dval['funcdata'][0][$count - 1][2] . "','" . $dval['funcdata'][0][$count - 1][3] . "'}"; } else { $func .= "'}"; } } } } if ($func) { $viewval = "{\$vo['" . $controllProperty[$property['fields']['name']] . "']|" . $func; } else { $viewval = "{\$vo['" . $controllProperty[$property['fields']['name']] . "']}"; } } $html .= "\r\n\t\t\t\t\t\t\t\t{:W('Lookup',array('1',\$vo,'{$controllProperty[$property['id']['name']]}','{$isedit}','{$isreturnvalue}'))}"; $islockHtml = parameReplace('$viewval', $viewval, $islockHtml); $html .= "\r\n\t\t\t\t\t\t\t\t" . $islockHtml; break; case 'lookupsuper': if (!$isreturnvalue) { // 获取lookup key值 动态加载lookup配置 $lookupchoice = $controllProperty[$property['lookupchoice']['name']]; $lookupObj = D('LookupObj'); $lookupDetail = $lookupObj->GetLookupDetail($lookupchoice); $model = $lookupDetail['mode']; $urls = $lookupDetail['url']; $lookupgroup = $controllProperty[$property['lookupgroup']['name']]; $orgchar = $lookupDetail['filed'] ? $lookupDetail['filed'] : 'name'; $orgval = $lookupDetail['val'] ? $lookupDetail['val'] : 'id'; $orgLookuoVal = $controllProperty[$property['org1']['name']]; // 显示绑定 $orgLookupText = $controllProperty[$property['org']['name']]; // 值绑定 $title = "{\$fields[\"" . $controllProperty[$property['fields']['name']] . "\"]}"; $view = ''; if ($lookupDetail['viewname']) { $view = '&viewname=' . $lookupDetail['viewname']; } if ($lookupDetail['dt']) { $dtcon = '&lookuptodatatable=2'; } $conditions = ''; $checkformodel = $lookupDetail['checkformodel']; // checkfor的org显示字段 $checkfororgchar = $detailList['field'] ? $detailList['field'] : $orgchar; // lookup的org值字段 // lookup的值反写 $textCounterCheck = ''; // 显示文本的反写 text $valCounterCheck = ''; // 值的反写 value // lporder 从外部lookup中取值字段 // lpkey 当前lookup的key // lpfor 往哪个东西里写值 // lpself 当前项的字段名称 if ($orgLookuoVal) { unset($temp); $temp = explode('.', $orgLookuoVal); $valCounterCheck = "callback=\"lookup_counter_check\" lpkey=\"{$lookupchoice}\" lpfor=\"{$lookupgroup}.{$orgchar}\" lpself=\"{$orgval}\" lporder=\"{$temp[1]}\""; } if ($orgLookupText) { unset($temp); $temp = explode('.', $orgLookupText); $textCounterCheck = "callback=\"lookup_counter_check\" lpkey=\"{$lookupchoice}\" lpfor=\"{$lookupgroup}.{$orgval}\" lpself=\"{$orgchar}\" lporder=\"{$temp[1]}\""; } // checkfor的列表显示字段 $checkfororgshowfield = $detailList['checkfororgshowfield'] ? $detailList['checkfororgshowfield'] : ''; // $urls = $controllProperty[$property['geturls']['name']]; // $lookupgroup = $controllProperty[$property['lookupgroup']['name']]; // $filedback = $controllProperty[$property['filedback']['name']]; // $model = $controllProperty[$property['model']['name']]; // $checkformodel = $controllProperty[$property['checkformodel']['name']]; // $orgchar = $controllProperty[$property['lookuporg']['name']]?$controllProperty[$property['lookuporg']['name']]:'name'; // $orgval = $controllProperty[$property['lookuporgval']['name']]?$controllProperty[$property['lookuporgval']['name']]:'id'; // checkfor的org显示字段 // $checkfororgchar = $controllProperty[$property['checkfororg']['name']]?$controllProperty[$property['checkfororg']['name']]:$orgchar; // checkfororfields // checkfor显示字段 // $checkfororgshowfield = $controllProperty[$property['checkfororgshowfield']['name']]?$controllProperty[$property['checkfororgshowfield']['name']]:''; // $conditions = $controllProperty[$property['conditions']['name']]; // auditState,3;status,1;ischange,0 // $title = "{\$fields[\"".$controllProperty[$property['fields']['name']]."\"]}"; $val = ''; $tempModel = D($model); $html = "\r\n\t\t\t\t\t\t{$prefTag}<div class=\"tml-input-lookupSuper\">"; if ($readonly) { // checkfor 文本框 $checkfororgchar $html .= "\r\n\t\t\t\t\t\t<input type=\"text\" class=\"{$lookupgroup}.{$checkfororgchar} {$chtml} lookupSuper_input input_new half_angle_input\" autocomplete=\"off\" readonly=\"readonly\" value=\"" . ($isedit ? "{\$vo['" . $controllProperty[$property['fields']['name']] . "']|getFieldBy='{$orgval}','{$orgchar}','{$tempModel->getTableName()}'}" : '') . "\" />"; } else { // $html .="\r\n\t\t\t\t\t\t<input type=\"text\" class=\"{$lookupgroup}.{$checkfororgchar} {$chtml} \" autocomplete=\"off\" value=\"".($isedit?"{\$vo['".$controllProperty[$property['fields']['name']]."']|getFieldBy='{$orgval}','{$orgchar}','{$tempModel->getTableName()}'}":'')."\" />"; if ($checkfororgshowfield) { $fileds = "array(" . $checkfororgshowfield . ");"; } else { $fileds = ''; } $html .= "\r\n\t\t\t\t\t\t<input type=\"text\" " . "autocomplete=\"off\" " . "checkfor=\"{$checkformodel}\" " . "insert=\"{$orgval}\" " . "show=\"{$checkfororgchar}\" " . "name=\"{$checkfororgchar}\" " . "newconditions=\"{$conditions}\" " . "fields=\"{$fileds}\" " . "other " . "value=\"" . ($isedit ? "{\$vo['" . $controllProperty[$property['fields']['name']] . "']|getFieldBy='id','{$orgchar}','{$tempModel->getTableName()}'}" : '') . "\" " . "class=\"{$lookupgroup}.{$checkfororgchar} checkByInput lookupSuper_input input_new half_angle_input {$chtml}\">"; } // checkfor 文本框的隐藏域 $html .= "\r\n\t\t\t\t\t\t<input type=\"hidden\" class=\"{$lookupgroup}.{$orgval}\" name=\"" . $controllProperty[$property['fields']['name']] . "\" value=\"{\$vo['" . $controllProperty[$property['fields']['name']] . "']}\" />"; if ($readonly) { // 只读情况 $viewval = $isedit ? "{\$vo['" . $controllProperty[$property['fields']['name']] . "']|getFieldBy='{$orgval}','{$orgchar}','{$tempModel->getTableName()}'}" : ''; // lookup 触发按钮 $html .= "\r\n\t\t\t\t\t\t<a class=\"icon_elm mid_icon_elm icon-plus\"></a>"; // looup 默认显示框 $html .= "<input type=\"text\" readonly=\"readonly\" class=\"{$lookupgroup}.{$orgchar} input_new square_input readonly valid\"\tcheck_key=\"othername\" name=\"{$lookupgroup}{$orgchar}\" value=\"" . $viewval . "\">"; // 清空 lookup 按钮 $html .= "\r\n\t\t\t\t\t\t<a title=\"清空信息\" class=\"icon_elm icon-trash\" href=\"javascript:void(0);\"></a>"; } else { $viewval = $isedit ? "{\$vo['" . $controllProperty[$property['fields']['name']] . "']|getFieldBy='{$orgval}','{$orgchar}','{$tempModel->getTableName()}'}" : ''; // lookup 触发按钮 $html .= "\r\n\t\t\t\t\t\t<a class=\"icon_elm mid_icon_elm icon-plus\" param=\"lookupchioce={$lookupchioce}&newconditions={$conditions}{$view}{$dtcon}\" href=\"__URL__/{$urls}\" lookupGroup=\"{$lookupgroup}\" ></a>"; // $title // looup 默认显示框 $html .= "<input type=\"text\" readonly=\"readonly\" class=\"{$lookupgroup}.{$orgchar} textInput input_new square_input readonly valid\"\tcheck_key=\"{$orgchar}\" name=\"{$lookupgroup}{$orgchar}\" value=\"" . $viewval . "\">"; // 清空 lookup 按钮 // $html .="\r\n\t\t\t\t\t\t<a title=\"清空信息\" class=\"input-addon input-addon-recycle\" href=\"javascript:void(0);\" onclick=\"clearInput('{$checkfororgchar},{$controllProperty[$property['fields']['name']]},{$lookupgroup}{$orgchar}');\"></a>"; $html .= "\r\n\t\t\t\t\t\t<a title=\"清空信息\" class=\"icon_elm icon-trash\" href=\"javascript:void(0);\" onclick=\"clearOrg('{$lookupgroup}');\"></a>"; } $html .= "\r\n\t\t\t\t\t\t</div>"; } else { // $html="{\$vo['".$controllProperty[$property['fields']['name']]."']}"; $func = ""; // 处理子表及主表的lookup值转换 , modify by nbmxkj at 20150127 20 // *****注意:func 与 funcdata 数组项一定要个数对应。**** foreach ($this->datalist as $dkey => $dval) { if ($dval['name'] == $controllProperty[$property['fields']['name']]) { $count = count($dval['func'][0]); if ($dval['func']) { $func .= $dval['func'][0][$count - 1]; // if($dval['func'][0][0]="getFieldBy"){ $func .= "="; // } } if ($dval['funcdata']) { $func .= "'" . $dval['funcdata'][0][$count - 1][1]; if ($dval['funcdata'][0][$count - 1][1]) { $func .= "','" . $dval['funcdata'][0][$count - 1][2] . "','" . $dval['funcdata'][0][$count - 1][3] . "'}"; } else { $func .= "'}"; } } } } if ($func) { $viewval = "{\$vo['" . $controllProperty[$property['fields']['name']] . "']|" . $func; $html = $viewval; } else { $viewval = "{\$vo['" . $controllProperty[$property['fields']['name']] . "']}"; $html = $viewval; } // $viewval=''; // $islockHtml = ''; } $islockHtml = parameReplace('$viewval', $viewval, $islockHtml); $html .= $islockHtml; break; case 'upload': // 数据字段名 $filedName = $controllProperty[$property['fields']['name']]; // 组件标题 $filedTitle = $controllProperty[$property['title']['name']]; // 上传数量 $uploadNum = $controllProperty[$property['uploadnum']['name']]; // 上传类型 $uploadType = $controllProperty[$property['uploadtype']['name']]; $param = 'array("0"=>$uploadarry["' . $filedName . '"],"1"=>' . $filedName . ',"2"=>$fields[' . $filedName . '],"3"=>"' . $uploadNum . '","4"=>"' . $uploadType . '")'; $viewval = ''; if (!$isreturnvalue) { if ($isedit) { if ($readonly) { $html .= "\r\n\t\t\t\t\t\t\t\t{:W('ShowUpload',{$param})}"; } else { $html .= "\r\n\t\t\t\t\t\t\t\t{:W('ShowUpload',{$param})}"; } } else { $html .= "\r\n\t\t\t\t\t\t\t\t{:W('ShowUpload',{$param})}"; } } else { $html .= "\r\n\t\t\t\t\t\t\t\t{:W('ShowUploadView',{$param})}"; // $islockHtml = ''; } $islockHtml = parameReplace('$viewval', $viewval, $islockHtml); $html .= $islockHtml; break; case 'userselect': $viewval = ''; if (!$isreturnvalue) { if ($isedit) { if ($readonly) { $html .= "\r\n\t\t\t\t\t\t\t\t{:W('ShowUserSelect',\$attarry)}" . $islockHtml; } else { $html .= "\r\n\t\t\t\t\t\t\t\t{:W('ShowUserSelect',\$attarry)}" . $islockHtml; } } else { $html .= "\r\n\t\t\t\t\t\t\t\t{:W('ShowUserSelect')}"; } } else { // 视图模式 // $islockHtml = ''; } $islockHtml = parameReplace('$viewval', $viewval, $islockHtml); $html .= $islockHtml; break; case 'areainfo': $viewval = ''; // 数据字段名 $filedName = $controllProperty[$property['fields']['name']]; // 组件标题 $filedTitle = $controllProperty[$property['title']['name']]; // 组件外样式 $content_cls = "col_" . $controllProperty[$property['titlepercent']['name']] . "_" . $controllProperty[$property['contentpercent']['name']] . " form_group_lay field_" . $controllProperty[$property['fields']['name']]; $param = 'array("0"=>$areainfoarry["' . $filedName . '"],"1"=>' . $filedName . ',"2"=>$fields[' . $filedName . '],"3"=>"' . $content_cls . '","5"=>"' . $required . '")'; $viewval = "{\$vo['" . $controllProperty[$property['fields']['name']] . "']}"; if (!$isreturnvalue) { if ($isedit) { if ($readonly) { $html .= "\r\n\t\t\t\t\t\t\t\t{:W('ShowArea',{$param})}" . $islockHtml; } else { $html .= "\r\n\t\t\t\t\t\t\t\t{:W('ShowArea',{$param})}" . $islockHtml; } } else { $html .= "\r\n\t\t\t\t\t\t\t\t{:W('ShowArea',{$param})}"; } } else { $html = $viewval; // $viewval=''; // $islockHtml = ''; } $islockHtml = parameReplace('$viewval', $viewval, $islockHtml); $html .= $islockHtml; break; case 'datatable': $viewval = ''; $titles = <<<EOF \t \t\t\t\t<if condition="\$fields['{$controllProperty[$property['fields']['name']]}']"> \t\t\t\t<div class="into_table_title">{\$fields["{$controllProperty[$property['fields']['name']]}"]}</div> \t\t\t\t</if> EOF; /* 获取字段信息 */ $filedTag = $property['fieldlist']['name']; // 获取配置信息中的标识名称 // 获取所有节点 $configPath = $controllProperty; $controlName = $controlTag = $controllProperty[$property['fields']['name']]; // 组件唯一标识 datatable8,...... $tableName = $this->tableName . '_sub_' . $controlTag; $namses = "datatable[#index#][{$controlName}]"; if ($configPath) { $innerTableFieldInfo = $configPath[$filedTag]; // 获取到内嵌表字段设置信息 } $innerTableFieldInfoObj = json_decode(htmlspecialchars_decode($innerTableFieldInfo), true); // 得到字段信息json对象数据 usort($innerTableFieldInfoObj, function ($a, $b) { $al = $a['fieldsort']; $bl = $b['fieldsort']; if ($al == $bl) { return 0; } return $al < $bl ? -1 : 1; }); $innerTableFieldInfoObj = json_decode(json_encode($innerTableFieldInfoObj)); // 修改及展示 页面组件列表 $showandeditfieldlist = ''; $filedList = ""; $filedList .= "<th style='width:40px;' template_key=\"serial\" >"; $filedList .= "\t\t\t\t序号"; $filedList .= "\t\t\t</th>"; $count = 0; $nameKey = ''; foreach ($innerTableFieldInfoObj as $key => $val) { if ($val->fieldshow == 1) { // 0 允许编辑, 1:不可编辑 $isDatatableEdit = intval($val->isedit) ? false : true; $editStatusConfig = ''; if (!$isDatatableEdit) { $editStatusConfig = 'is_readonly=true'; } $dt_readonly = ""; $class_readonly = ""; $int_readonly = 1; if ($editStatusConfig) { // 内嵌表控件不可编辑 $dt_readonly = "readonly='readonly'"; $class_readonly = "readonly"; $int_readonly = 0; } $nameKey = "template_controll={$val->fieldname}"; switch ($val->fieldshowtype) { case 'text': //查询公式 $misDynamicFormDatatableModel = M('mis_dynamic_form_datatable'); $datatablemap['id'] = $val->fieldid; $datatableList = $misDynamicFormDatatableModel->where($datatablemap)->find(); $validdigit = $datatableList['validdigit'] ? $datatableList['validdigit'] : 2; $fieldname = $datatableList['fieldname']; $calculate = $datatableList['calculate']; $subassembly = $datatableList['subassembly']; $subassemblyArr = explode(',', $subassembly); $formulaType = $datatableList['type']; $formulaJindu = $datatableList['jindu']; //替换id $inputString = ""; $FormulArr = array(); foreach ($subassemblyArr as $sk => $sval) { $propertymap['id'] = $sval; $properyList = $misDynamicFormDatatableModel->where($propertymap)->find(); $name = $properyList['fieldname']; $FormulArr[$sval] = $name; } // @todo $calculateString = preg_replace_callback('/(\\[(.*?)\\])+/', function ($callbackParame) use($FormulArr) { return '[' . $FormulArr[$callbackParame[2]] . ']'; }, $calculate); $config = ''; $orgConfigVal = ''; $dataConfig = ''; if ($val->fieldshowtypeconfig) { $config = unserialize(base64_decode($val->fieldshowtypeconfig)); } $curCls = ''; if (is_array($config)) { // 将组件属性转换为html代码 $dataConfig = $config['parame']; // 获取select的配置项 if (!$controllProperty['ganshe_datatable'] && $config['required']) { $curCls .= ' required '; } if ($config['checktype']) { $curCls .= $config['checktype']; } } $orgSet = ''; if (is_array($dataConfig)) { $orgConfigVal = $dataConfig[0]; if ($orgConfigVal) { $orgSet = $orgConfigVal; } } $untilsCls = ''; $unit = $config['baseuntils']; // 基础单位 $untils = $config['untils']; // 显示单位 $tempData = ''; $template_data = ''; $orgshowfield = ''; logs('org set ::' . $orgSet); if ($orgSet) { $orgshowfield = str_replace('org', "org{\$key}", $orgSet); $temp = explode('.', $orgSet); if (is_array($temp)) { $template_data['bindlookupname'] = $temp[0]; $template_data['upclass'] = $temp[1]; } } if ($untils && $unit) { $template_data['unitl'] = $config['untils']; $template_data['unitlname'] = urlencode(iconv("UTF-8", "UTF-8//IGNORE", $config['untilschar'])); } // 添加统计功能 // is_stats="true" 统计控制 // $stats_num = 'stats_num=\\"2\\"'; // 统计时的小数有效位数 $is_stats = ''; // 统计状态 $edit_count_str = ''; // 编辑时统计数据 $edit_count_cls = ''; // 统计的标识样式 $y_num = ""; if ($datatableList['calculate']) { $edit_calculate_cls = ' calc '; // 计算样式 $template_data['formula'] = $calculateString; $template_data['stats_num'] = $validdigit; $template_data['formulaType'] = $formulaType; $template_data['formulaJindu'] = $formulaJindu; } if ($val->fieldcount == 1) { $is_stats = ' is_stats="true" '; $edit_count_str = " y_num=\"{\$item[{$val->fieldname}]|unitExchange=###,{$unit},{$untils},2}\""; $edit_count_cls = ' into_table_tj_input '; $stats_num = $datatableList['stats_num'] ? "stats_num=\"{$datatableList['stats_num']}\"" : $stats_num; //"stats_num=\"{$config['stats_num']}\""; // 指定有效位数。 if ($unit && $untils) { $y_num = "y_num='{\$item[{$val->fieldname}]|unitExchange=###,{$unit},{$untils},2}'"; } else { $y_num = "y_num='{\$item[{$val->fieldname}]}'"; } } if (is_array($template_data)) { $tempData = "template_data='" . _urldecode(json_encode($template_data)) . "'"; } if ($untils && $unit) { $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t<td>"; $showandeditfieldlist .= <<<EOF \t\t\t \t\t\t\t\t\t\t\t\t<div class="list_group_lay" style="display: none;"> \t\t\t\t\t\t\t\t\t\t<div class="list_public_lay"> \t\t\t\t\t\t\t\t\t\t\t<input type="text" {$y_num} {$dt_readonly} class="{$class_readonly} {$orgshowfield} {$edit_calculate_cls} {$edit_count_cls} {$curCls} list_unit_input list_public_input" {$edit_count_str} disabled="disabled" name="#hide#datatable[#index#][{$controlTag}][{$val->fieldname}]" value="{\$item[{$val->fieldname}]|unitExchange=###,{$unit},{$untils},2}"> \t\t\t\t\t\t\t\t\t\t\t<span class="list_icon_elm_unit" title="{$config['untilschar']}">{$config['untilschar']} \t\t\t\t\t\t\t\t\t\t\t</span> \t\t\t\t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t\t\t<span class="datatable_show_val">{\$item[{$val->fieldname}]|unitExchange=###,{$unit},{$untils},3}</span> EOF; $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t</td>"; } else { $showandeditfieldlist .= <<<EOF \t\t\t\t\t\t\t\t\t\t\t<td> \t\t\t\t\t\t\t\t\t\t\t<div class="list_group_lay" style="display: none;"> \t\t\t\t\t\t\t\t\t\t\t<input type="text" {$dt_readonly} {$y_num} class="list_input {$class_readonly} {$edit_calculate_cls} {$untilsCls} {$orgshowfield} {$edit_count_cls} {$curCls}" disabled="disabled" name="#hide#datatable[#index#][{$controlTag}][{$val->fieldname}]" {$untils} value="{\$item[{$val->fieldname}]}" /> \t\t\t\t\t\t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t\t\t\t\t\t<span class="datatable_show_val">{\$item[{$val->fieldname}]}</span> \t\t\t\t\t\t\t\t\t\t\t\t</td> EOF; } // 统计绑定表头文本框字段 $bindhz = ""; if ($val->countassignment && $val->fieldcount) { $bindhz = "bindhz=\"{$val->countassignment}\""; } $filedList .= "\r\n<th {$bindhz} style=\"width:{$val->colwidth}px;min-width:{$val->colwidth}px;min-width:{$val->colwidth}px;\" template_key=\"input\" template_name=\"{$namses}[{$val->fieldname}]\" {$tempData} {$stats_num}"; $filedList .= "\r\n{$is_stats} {$editStatusConfig}\ttemplate_class=\"{$untilsCls} {$curCls}\" {$nameKey}>"; // unitlpase $filedList .= "\r\n{$val->fieldtitle}"; $filedList .= "\r\n</th>"; // logs($filedList); break; case 'select': unset($template_data); /* * template_key="select" * template_data='[{"value":1,"name":"第一人"},{"value":2,"name":"第二人"}]' * template_class="code" */ $config = ''; if ($val->fieldshowtypeconfig) { $config = unserialize(base64_decode($val->fieldshowtypeconfig)); } $curCls = ''; if (is_array($config)) { // 将组件属性转换为html代码 $lookupConfig = $config['datasouceparame']; // 获取select的配置项 $lookuptolookupconfig = $config['lookto']; $dateConfig = $config['parame']; // 获取select的配置项 if (!$controllProperty['ganshe_datatable'] && $config['required']) { $curCls .= ' required '; } if ($config['checktype']) { $curCls .= $config['checktype']; } } // 下拉组件org效果 $orgSet = ''; if (is_array($dateConfig)) { $orgConfigVal = $dateConfig['org']; if ($orgConfigVal) { $orgSet = $orgConfigVal; } } if ($orgSet) { $orgshowfield = str_replace('org', "org{\$key}", $orgSet); $temp = explode('.', $orgSet); if (is_array($temp)) { $template_data['bindlookupname'] = $temp[0]; $template_data['upclass'] = $temp[1]; } } $dateOrgConfig = ''; // 对现有DB数据编辑时的 org 属性解析。 $orgshowfield = ''; if ($orgSet) { $orgshowfield = str_replace('org', "org{\$key}", $orgSet); $temp = explode('.', $orgSet); if (is_array($temp)) { $template_data['lookupname'] = $temp[0]; $template_data['name'] = $temp[1]; } $dateOrgConfig = 'bindlookup=\'' . json_encode($template_data) . '\''; } $dataSouceArr = ''; $getControllbyHtmlStr = ""; if ($lookuptolookupconfig[0]) { // 如果有lookup带回 $l = array(); foreach ($innerTableFieldInfoObj as $k => $v) { if ($k == $lookuptolookupconfig[0]) { $l = unserialize(base64_decode($v->fieldshowtypeconfig)); } } $lookmodel = D("LookupObj"); $lookuplist = $lookmodel->GetLookupDetail($l['parame'][0]); // $lookupParame['lpkey'] = reset($lookupConfig);//$l['parame'][0]; $lookupParame['lporder'] = $l[$lookuptolookupconfig[1]]; // $lookupobjmodel = D("lookupObj"); // $c = reset($lookupConfig); // $lookuplist = $lookupobjmodel->GetLookupDetail($c); // $lookupParame['lpfor'] = $lookuplist['val']; // $lookupParame['lpself'] = $lookuplist['field']; // lporder 从外部lookup中取值字段 // lpkey 当前lookup的key ? // lpfor 往哪个东西里写值 // lpself 当前项的字段名称 } $template_key = "select"; if ($config['datasouce'] == 0) { // 数据源为 select list $selectInc = $lookupConfig[0]; // lookup时 if ($lookupParame['lporder']) { $selectInc = $lookupParame['lporder']; } $getControllbyHtmlStr = '{:getControllbyHtml("selectlist",array("type"=>"select","key"=>"' . $selectInc . '"))}'; if ($selectInc) { $selectlistData = $this->getSelectList($selectInc); if (is_array($selectlistData[$selectInc])) { foreach ($selectlistData[$selectInc] as $selk => $selv) { $temp['value'] = urlencode(iconv("UTF-8", "UTF-8//IGNORE", $selk)); $temp['name'] = urlencode(iconv("UTF-8", "UTF-8//IGNORE", $selv)); $dataSouceArr[] = $temp; } } $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t<td><div style='display: none;' class='list_group_lay'>"; $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t<select class=\"list_select2 {$class_readonly} {$orgshowfield} {$curCls} \" data-placeholder=\"没有可用数据\""; $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t name=\"#hide#datatable[#index#][{$controlTag}][{$val->fieldname}]\">"; $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t{:getControllbyHtml('selectlist',array('type'=>'select','names'=>\"datatable[\$key][{$controlTag}][{$val->fieldname}]\",'key'=>'{$selectInc}','selected'=>\$item['{$val->fieldname}']))}"; $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t</select></div><span class='datatable_show_val'>{:getControllbyHtml('selectlist',array('type'=>'select','names'=>\"datatable[\$key][{$controlTag}][{$val->fieldname}]\",'key'=>'{$selectInc}','selected'=>\$item['{$val->fieldname}'],'showtype'=>1))}</span>"; $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t</td>"; } } else { // 数据源为 table if ($lookupConfig[0] && $lookupConfig[1] && $lookupConfig[2]) { if ($lookupConfig['treeparentfield']) { $template_key = "selecttree"; // 设置为树形结构 $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t<td>"; $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t<div style='display: none;' class='list_group_lay'>"; $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t{:W('ShowSelectDT',array(\$item['{$val->fieldname}'], array(' {$curCls} ',array('type'=>'table',array('readonly'=>'1','targevent'=>'','actionName'=>'{$this->nodeName}','names'=>\"#hide#datatable[#index#][{$controlTag}][{$val->fieldname}]\",'defaultcheckitem'=>'','defaultval'=>'','defaulttext'=>'','table'=>'{$lookupConfig[0]}', 'id'=>'{$lookupConfig[2]}','name'=>'{$lookupConfig[1]}','conditions'=>'','parentid'=>'{$lookupConfig['treeparentfield']}','mulit'=>'{$lookupConfig['mulit']}','isnextend'=>'{$lookupConfig['isnextend']}','treeheight'=>'{$lookupConfig['treeheight']}','treewidth'=>'{$lookupConfig['treewidth']}','key'=>'','isedit'=>'{$int_readonly}','showtype'=>'0','namesappend'=>'{$val->fieldname}#index#')))))}"; $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t</div><span class='datatable_show_val'>{:getControllbyHtml('table',array('type'=>'select','names'=>\"datatable[\$key][{$controlTag}][{$val->fieldname}]\",'table'=>{$lookupConfig[0]},'id'=>'{$lookupConfig[2]}','name'=>'{$lookupConfig[1]}','selected'=>\$item['{$val->fieldname}'],'showtype'=>1))}</span>"; $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t</td>"; $chkStyle = "radio"; if ($lookupConfig["mulit"] == 1) { $chkStyle = "checkbox"; } $isnextend = $lookupConfig['isnextend'] == 1 ? 1 : 0; $dataSouceArr = '{"treeconfig":' . '{"expandAll":false,' . '"checkEnable":true,' . '"chkStyle":"' . $chkStyle . '",' . '"radioType":"all",' . '"onClick":"S_NodeClick",' . '"onCheck":"S_NodeCheck"},' . '"treeheight":"' . $lookupConfig['treeheight'] . '",' . '"treewidth":"' . $lookupConfig['treewidth'] . '",' . '"treedata":<?php ' . 'echo getControllbyHtml(' . '"table",' . 'array("type"=>"select",' . '"table"=>"' . $lookupConfig[0] . '",' . '"id"=>"' . $lookupConfig[2] . '",' . '"name"=>"' . $lookupConfig[1] . '",' . '"showtype"=>"1",' . '"comboxtree"=>"1",' . '"parentid"=>"' . $lookupConfig['treeparentfield'] . '",' . '"isnextend"=>' . $isnextend . ')); ' . '?>}'; } else { $obj = M($lookupConfig[0]); $data = $obj->field("{$lookupConfig[1]} , {$lookupConfig['2']}")->select(); $getControllbyHtmlStr = '{:getControllbyHtml("table",array("type"=>"select","table"=>"' . $lookupConfig[0] . '","id"=>"' . $lookupConfig[2] . '","name"=>"' . $lookupConfig[1] . '"))}'; if ($data) { foreach ($data as $dk => $dv) { $temp['value'] = urlencode(iconv("UTF-8", "UTF-8//IGNORE", $dv[$lookupConfig[2]])); $temp['name'] = urlencode(iconv("UTF-8", "UTF-8//IGNORE", $dv[$lookupConfig[1]])); $dataSouceArr[] = $temp; } } $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t<td>"; $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t<div style='display: none;' class='list_group_lay'><select class=\"list_select2 {$class_readonly} {$orgshowfield} {$curCls} \" data-placeholder=\"没有可用数据\""; $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t name=\"#hide#datatable[#index#][{$controlTag}][{$val->fieldname}]\">"; $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t{:getControllbyHtml('table',array('type'=>'select','names'=>\"datatable[\$key][{$controlTag}][{$val->fieldname}]\",'table'=>'{$lookupConfig[0]}','id'=>'{$lookupConfig[2]}','name'=>'{$lookupConfig[1]}','selected'=>\$item['{$val->fieldname}']))}"; $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t</select></div><span class='datatable_show_val'>{:getControllbyHtml('table',array('type'=>'select','names'=>\"datatable[\$key][{$controlTag}][{$val->fieldname}]\",'table'=>'{$lookupConfig[0]}','id'=>'{$lookupConfig[2]}','name'=>'{$lookupConfig[1]}','selected'=>\$item['{$val->fieldname}'],'showtype'=>1))}</span>"; $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t</td>"; } } } if (empty($getControllbyHtmlStr) && is_array($dataSouceArr)) { $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t<td>"; $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t<div style='display: none;' class='list_group_lay'><select class=\"list_select2 {$class_readonly} {$orgshowfield} {$curCls} \" data-placeholder=\"没有可用数据\""; $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t name=\"#hide#datatable[#index#][{$controlTag}][{$val->fieldname}]\">"; $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t{:getControllbyHtml('table',array('type'=>'select','names'=>\"datatable[\$key][{$controlTag}][{$val->fieldname}]\",'table'=>'{$lookupConfig[0]}','id'=>'{$lookupConfig[2]}','name'=>'{$lookupConfig[1]}','selected'=>\$item['{$val->fieldname}']))}"; $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t</select></div><span class='datatable_show_val'>{:getControllbyHtml('table',array('type'=>'select','names'=>\"datatable[\$key][{$controlTag}][{$val->fieldname}]\",'table'=>'{$lookupConfig[0]}','id'=>'{$lookupConfig[2]}','name'=>'{$lookupConfig[1]}','selected'=>\$item['{$val->fieldname}'],'showtype'=>1))}</span>"; $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t</td>"; } $template_data = $dataSouceArr; if (is_array($dataSouceArr)) { $template_data = urldecode(json_encode($dataSouceArr)); } // select绑定表头下拉框字段 $bindGroup = ""; if ($config["selectassignment"]) { $bindGroup = "bindGroup=\"{$config['selectassignment']}\""; } $filedList .= "\r\n\t\t\t<th {$bindGroup} style=\"width:{$val->colwidth}px;min-width:{$val->colwidth}px;min-width:{$val->colwidth}px;\" template_key='{$template_key}' template_name=\"{$namses}[{$val->fieldname}]\" {$dateOrgConfig}"; $filedList .= "\r\n\t\t\ttemplate_data='{$template_data}' {$editStatusConfig}"; $filedList .= "\r\n\t\t\ttemplate_html='{$getControllbyHtmlStr}'"; $filedList .= "\r\n\t\t\ttemplate_class=\" {$curCls} \" {$nameKey}>"; $filedList .= "\r\n\t\t\t\t{$val->fieldtitle}"; $filedList .= "\r\n\t\t\t</th>"; break; case 'date': $config = ''; if ($val->fieldshowtypeconfig) { $config = unserialize(base64_decode($val->fieldshowtypeconfig)); } $curCls = ''; if (is_array($config)) { // 将组件属性转换为html代码 $dateConfig = $config['parame']; // 获取select的配置项 if (!$controllProperty['ganshe_datatable'] && $config['required']) { $curCls .= ' required '; } if ($config['checktype']) { $curCls .= $config['checktype']; } } $format = $dateConfig['0'] ? $dateConfig['0'] : 'yyyy-MM-dd'; $format1 = ''; switch ($format) { case 'yyyy-MM-dd': $format1 = "='Y-m-d'"; break; case 'yyyy-MM-dd HH:mm': $format1 = "='Y-m-d H:i'"; break; case 'yyyy-MM': $format1 = "='Y-m'"; break; case 'MM-dd': $format1 = "='m-d'"; break; case 'yyyy': $format1 = "='Y'"; break; case 'MM': $format1 = "='m'"; break; case 'dd': $format1 = "='d'"; break; case 'HH:mm': $format1 = "='H:i'"; break; default: break; } // 日期组件org效果 $orgSet = ''; if (is_array($dateConfig)) { $orgConfigVal = $dateConfig['org']; if ($orgConfigVal) { $orgSet = $orgConfigVal; } } $dateOrgConfig = ''; // 对现有DB数据编辑时的 org 属性解析。 $orgshowfield = ''; if ($orgSet) { unset($template_data); $orgshowfield = str_replace('org', "org{\$key}", $orgSet); $temp = explode('.', $orgSet); if (is_array($temp)) { $template_data['lookupname'] = $temp[0]; $template_data['name'] = $temp[1]; } $dateOrgConfig = 'bindlookup=' . json_encode($template_data); } // $filedList .= "\r\n\t\t\t<th style=\"width:{$val->colwidth}px;min-width:{$val->colwidth}px;min-width:{$val->colwidth}px;\" template_key=\"date\" template_name=\"{$namses}[{$val->fieldname}]\" {$dateOrgConfig} "; $filedList .= "\r\n\t\t\ttemplate_data='{\"format\":\"{$format}\"}' {$editStatusConfig}"; $filedList .= "\r\n\t\t\ttemplate_class=\" {$curCls} \" {$nameKey}>"; $filedList .= "\r\n\t\t\t\t{$val->fieldtitle}"; $filedList .= "\r\n\t\t\t</th>"; $showandeditfieldlist .= <<<EOF \t \t\t\t\t\t\t\t\t\t\t\t\t<td> \t\t\t\t\t\t\t\t\t\t\t\t<div class="list_group_lay" style='display: none;'> \t\t\t\t\t\t\t\t\t\t\t\t<input type="text" {$dt_readonly} disabled="disabled" name="#hide#datatable[#index#][{$controlTag}][{$val->fieldname}]" class="Wdate js-wdate list_input {$orgshowfield} {$class_readonly} {$curCls} " format="{dateFmt:'{$format}'}" value="{\$item.{$val->fieldname}|transTime{$format1}}"> \t\t\t\t\t\t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t\t\t\t\t\t<span class='datatable_show_val'>{\$item.{$val->fieldname}|transTime{$format1}}</span> \t\t\t\t\t\t\t\t\t\t\t\t</td> EOF; break; case 'uploadfilenew': $config = ''; if ($val->fieldshowtypeconfig) { $config = unserialize(base64_decode($val->fieldshowtypeconfig)); } $filedList .= "\r\n\t\t\t<th style=\"width:{$val->colwidth}px;min-width:{$val->colwidth}px;min-width:{$val->colwidth}px;\" template_key=\"uploadfilenew\" template_name=\"{$namses}[{$val->fieldname}]\" "; $filedList .= "\r\n\t\t\ttemplate_data='{\"url\":\"__URL__/DT_uploadnew\"}' {$editStatusConfig} "; $filedList .= "\r\n\t\t\ttemplate_class=\"\" {$nameKey}>"; $filedList .= "\r\n\t\t\t\t{$val->fieldtitle}"; $filedList .= "\r\n\t\t\t</th>"; $uploadFileType = ''; if ($isreturnvalue || $editStatusConfig) { $uploadFileType = 'rel_type="view"'; } $fileattlist = $this->getDTAttachedRecordList($tableid, $tablename = '', $subid = 0, $fieldname); $tableModelname = createRealModelName($tableName); $showandeditfieldlist .= <<<EOF \t\t\t\t\t\t\t<td> \t\t\t\t\t\t\t<div class="list_group_lay"> \t\t\t\t\t\t\t<div class="js_privyIndex"> \t\t\t\t\t\t\t<a \t\t\t\t\t\t\ttitle="附件管理" \t\t\t\t\t\t\tclass="tml_task_btn" \t\t\t\t\t\t\tstyle="padding:3px 10px;" \t\t\t\t\t\t\thref="javascript:;" \t\t\t\t\t\t\tid="DT_upload_{$val->fieldname}#index#" \t\t\t\t\t\t\trel_index="#index#" \t\t\t\t\t\t\trel_url="__URL__/DT_uploadnew" \t\t\t\t\t\t\trel_subid="{\$item['id']}" \t\t\t\t\t\t\trel_fieldname = "{$val->fieldname}" \t\t\t\t\t\t\trel_tablename = "{$tableModelname}" \t\t\t\t\t\t\trel_tableid = "{\$vo['id']}" \t\t\t\t\t\t\t\t\t\t\t{$uploadFileType} \t\t\t\t\t\t\t\t\t\t\trel_name="datatable[#index#][{$controlTag}][{$val->fieldname}]" \t\t\t\t\t\t\t\t\t\t\t\tonclick="DTopenFile(this)"> \t\t\t\t\t\t\t\t\t\t\t\t\t\t附件管理(<span class="attached_count">{\$item.id|getDTCount=\$vo['id'],'{$tableModelname}',###,'{$val->fieldname}'}</span>) \t\t\t\t\t\t\t\t\t\t\t\t\t\t</a></div></div> \t\t\t\t\t\t\t\t\t\t\t\t\t\t</td> EOF; break; case 'lookup': $lookupParame = ''; $config = ''; $parme = ''; $lookupurl = ''; $callbackFileds = ''; $modelName = ''; $conditionsStr = ''; $showFiled = ''; $valField = ''; $lookupConfig = ''; $orgval = ''; $appendCondtionStr = ''; $appendCondtionArr = array(); if ($val->fieldshowtypeconfig) { $config = unserialize(base64_decode($val->fieldshowtypeconfig)); } $curCls = ''; if (is_array($config)) { // 将组件属性转换为html代码 $lookupConfig = $config['parame']; // 获取lookup等特殊组件的配置项 $lookuptolookupconfig = $config['ltol']; if (!$controllProperty['ganshe_datatable'] && $config['required']) { $curCls .= ' required '; } if ($config['checktype']) { $curCls .= $config['checktype']; } } $dataTableEventControll = $config['fieldname']; if ($lookupConfig[0]) { // 用户配置了lookup前置对象 // 获取指定项的lookup配置内容 $lookupConfigData = $this->lookuoconfig(false, true); $lookupConfigData = $lookupConfigData[reset($lookupConfig)]; // fields 带回字段列表 // url 请求地址 // mode 处理Model // filed 显示字段 // val 值字段 // condition 过滤条件 $lookupurl = '__URL__/' . $lookupConfigData['url']; // 请求地址 $callbackFileds = "{$lookupConfigData['fields']}"; // 带回字段列表 $modelName = "{$lookupConfigData['mode']}"; // 处理Model $lookupConfigData['filed'] = $lookupConfigData['filed'] ? $lookupConfigData['filed'] : 'name'; $showFiled = "{$lookupConfigData['filed']}"; // 显示字段 $lookupConfigData['val'] = $lookupConfigData['val'] ? $lookupConfigData['val'] : "id"; $valField = "{$lookupConfigData['val']}"; // 值字段 if (1 == $lookupConfigData['viewtype']) { $configObj = D('MisSystemDataviewMasView'); $viewConfig = $configObj->getViewConf($lookupConfigData['viewname']); $searchField = $viewConfig[$valField]['searchField']; $orderModelArr = explode('.', $searchField); if ($orderModelArr[0] && $searchField) { $tempModel = D($orderModelArr[0]); } } else { $tempModel = D($lookupConfigData['mode']); } $modelName = $tempModel->getTableName(); // throw new NullDataExcetion(var_dump($modelName)); $conditionsStr = ''; // $lookupConfigData['condition'] ? preg_replace("/'/", ''', $lookupConfigData['condition']).' and ' : ''; // $parme[]="field={$lookupConfigData['fields']}"; // $parme[]="model={$lookupConfigData['mode']}"; // ////////////////////////////////////////////////////////////////////////////////////// // lookup附加条件处理 $appendCondtion = ''; $sysFieldFmt = ''; $sysFieldList = ''; $formFiledList = ''; $fd = ''; $formFiledListArr = ''; $formFiledFmt = ''; $appendCondtionArr = ''; $appendCondtionStr = ''; // iscontrollchange // {:getAppendCondition($vo,'wenbenkuang,createtime')} $appendCondtion = $config['dateconditions']; // 附加条件设置信息 logs($dataTableEventControll . '::::' . arr2string($appendCondtion), 'fffffffffffffffffffff'); if ($appendCondtion) { $appendCondtion = unserialize(base64_decode($appendCondtion)); // proexp 表单字段列表 // sysexp 系统字段列表 $formFiledList = $appendCondtion['proexp']; $sysFieldList = $appendCondtion['sysexp']; // $formFiledFmt=array(); // $sysFieldFmt = array(); $sysFieldFmt = unserialize($sysFieldList) or array(); // 获取真实的表单字段名。 if ($formFiledList) { $formFiledListArr = unserialize($formFiledList) or array(); if (is_array($formFiledListArr) && count($formFiledListArr)) { $formFiledKey = array_keys($formFiledListArr); $properModel = M('mis_dynamic_form_propery'); $properMap['id'] = array('in', $formFiledKey); $fd = $properModel->where($properMap)->field('fieldname,id')->select(); if ($fd) { foreach ($fd as $k => $v) { // $fieldArr[] = $v['fieldname']; if ($formFiledListArr[$v['id']] == -1) { $formFiledFmt[$v['fieldname']] = $v['fieldname']; } else { $formFiledFmt[$v['fieldname']] = $formFiledListArr[$v['id']]; } } } } } if (is_array($sysFieldFmt) && is_array($formFiledFmt)) { $appendCondtionArr = array_merge($sysFieldFmt, $formFiledFmt); } elseif (is_array($sysFieldFmt) && !is_array($formFiledFmt)) { $appendCondtionArr = $sysFieldFmt; } elseif (!is_array($sysFieldFmt) && is_array($formFiledFmt)) { $appendCondtionArr = $formFiledFmt; } else { $appendCondtionArr = array(); } $appendCondtionStr = arr2string($appendCondtionArr); $appendCondtionStr = "<?php echo getAppendCondition(\$vo,{$appendCondtionStr}) ?>"; } $parme[] = "lookupchoice=" . reset($lookupConfig) . '&type=dt'; $parme[] = "newconditions={$conditionsStr}{$appendCondtionStr}"; // getAppendCondition if ($lookuptolookupconfig[0]) { // 如果有lookup带回lookup $ll = array(); // lporder 从外部lookup中取值字段 $lookupParame1['lporder'] = "ORG" . $lookuptolookupconfig[0]; // lpkey 当前lookup的key $lookupParame1['lpkey'] = reset($lookupConfig); // lporder 从外部lookup中取值字段 // lpkey 当前lookup的key ? // lpfor 往哪个东西里写值 // lpself 当前项的字段名称 } } $orgval = $lookupConfig[1]; // ? $lookupConfig[1] : 'org_'.$val->fieldname.rand(1, 100); $onEditParame = ''; $paramStr = ''; if (is_array($parme)) { $paramStr = join('&', $parme); $onEditParame = join('&', $parme); } // 拼接lookup参数 $lookupParame['upclass'] = $showFiled; $lookupParame['callback'] = 'lookup_counter_check'; //'lookupDataToCell'; $lookupParame['param'] = $paramStr; $lookupParame['condition'] = array_flip($appendCondtionArr); // $appendCondtionArr;// $lookupParame['lookupname'] = $orgval; $lookupParame['href'] = $lookupurl; $lookupParame['hidden_data'] = array(array('upclass' => $valField, 'name' => "{$namses}[{$val->fieldname}]")); // 回写 lookup中指定的值字段名。当前字段名。lookup->lookup if ($lookuptolookupconfig[0]) { $lookupParame['bindlookupname'] = 'org' . $lookuptolookupconfig[0]; $lookupParame['lporder'] = $lookuptolookupconfig[1]; //$lookupParame1 ['lporder']; $lookupParame['lpkey'] = $lookupParame1['lpkey']; $lookupParame['hidden_data'] = array(array('upclass' => $valField, 'name' => "{$namses}[{$val->fieldname}]", "lporder" => $lookuptolookupconfig[1])); } $filedList .= "\r\n\t\t\t<th style=\"width:{$val->colwidth}px;min-width:{$val->colwidth}px;min-width:{$val->colwidth}px;\" template_key=\"lookup\" \r\n "; $filedList .= "\r\n \t\t\ttemplate_name=\"\" \r\n "; $filedList .= "\r\n\t\ttemplate_data='" . urldecode(json_encode($lookupParame)) . "' {$editStatusConfig} \r\n"; $filedList .= "\r\n\t\t\ttemplate_class=\" {$curCls} \" {$nameKey}>"; $filedList .= "\r\n\t\t\t\t{$val->fieldtitle}"; $filedList .= "\r\n\t\t\t</th>"; // org 没设定哦。 $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t<td>"; $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t<div class='list_group_lay' style='display: none;'><div class=\"list_public_lay\">"; $lookupvaluechange = ''; if ($valField && $showFiled && $modelName) { $lookupvaluechange = "{\$item.{$val->fieldname}|getFieldBy='{$valField}','{$showFiled}','{$modelName}'}"; } else { $lookupvaluechange = "{\$item.{$val->fieldname}}"; } if ($editStatusConfig) { $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t<input type=\"text\" callback=\"\" class=\"list_public_input list_lookup_input readonly org{\$key}{$val->fieldname}.{$showFiled} \" readonly=\"readonly\" value=\"{$lookupvaluechange}\">"; $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t<input type=\"hidden\" class=\"org{\$key}{$val->fieldname}.{$valField} {$curCls}\" disabled=\"disabled\" name=\"#hide#datatable[#index#][{$controlTag}][{$val->fieldname}]\" value=\"{\$item.{$val->fieldname}}\">"; $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t<a class=\"list_icon_elm list_mid_icon_elm icon-plus\"></a>"; $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t<a title=\"清空信息\" class=\"list_icon_elm icon-trash\" href=\"javascript:void(0);\"></a>"; $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t</div></div>"; } else { $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t<input type=\"text\" callback=\"\" class=\"list_public_input list_lookup_input readonly org{\$key}{$val->fieldname}.{$showFiled} \" readonly=\"readonly\" value=\"{$lookupvaluechange}\">"; $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t<input type=\"hidden\" class=\"org{\$key}{$val->fieldname}.{$valField} {$curCls}\" disabled=\"disabled\" name=\"#hide#datatable[#index#][{$controlTag}][{$val->fieldname}]\" value=\"{\$item.{$val->fieldname}}\">"; $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t<a class=\"list_icon_elm list_mid_icon_elm icon-plus\" param=\"{$onEditParame}\" href=\"{$lookupurl}\" lookupgroup=\"org{\$key}{$val->fieldname}\" autocomplete=\"off\"></a>"; $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t<a title=\"清空信息\" class=\"list_icon_elm icon-trash\" href=\"javascript:void(0);\" onclick=\"clearOrg('org{\$key}{$val->fieldname}');\"></a>"; $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t</div></div>"; } $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t\t<span class='datatable_show_val'>{$lookupvaluechange}</span>"; $showandeditfieldlist .= "\r\n\t\t\t\t\t\t\t\t\t\t</td>"; break; } $count++; } } // logs($count); // table 组件的操作类型设置@20141211 nbmxkj $tableoprate = ''; $container = ''; $containerend = ''; $oprateItem = ''; $dataTableModelName = createRealModelName($tableName); $tableOprateTitle = <<<EOF \t\t\t\t<th style='width:90px;' template_data='{"table":"{$controlName}","post_table":"{$tableName}","post_url":"__URL__/onesave","del_url":"__URL__/delsubinfo/delmodel/{$dataTableModelName}"}' template_key="action">操作</th> EOF; $tableOprateContent = <<<EOF \t \t\t\t\t<td {$oprateItem}> \t\t\t\t\t\t<input type="hidden" name="#hide#datatable[#index#][{$controlTag}][id]" value="{\$item.id}" /> \t\t\t\t\t\t<button title="删除" type="button" class="into_table_new_trash_tr into_table_btn itb_del" del_url="__URL__/delsubinfo/delmodel/{$dataTableModelName}" del_id="{\$item.id}" del_table="{$tableName}" nbmonclick="del_sub_info('{$this->nodeName}','{$tableName}',{\$item.id},this)"> \t\t\t\t\t\t<span class="icon-remove"></span></button> \t\t\t\t\t\t<button post_id="{\$item.id}" post_url="__URL__/onesave" post_id="{\$item.id}" post_table="{$tableName}" rel_type="edit" class="save_row_btn" type="button" title="编辑"><span class="icon-pencil"></span></button> \t\t\t\t\t</td> EOF; if ($isreturnvalue) { $tableoprate = 'view'; $tableOprateContent = ''; $tableOprateTitle = ''; // $container='<div class="temp_cell_right">'; // $containerend='</div>'; $oprateItem = 'style="display:none"'; } else { if ($isedit) { $tableoprate = 'edit'; } else { $tableoprate = 'add'; } } $datatableID = 'dt_' . $controlName . rand_string() . '_' . $tableoprate; $orgTag = $controllProperty[$property['org']['name']]; // 获取数据表格的数据带回绑定标识 $dataTableCallBackFunc = 'nbm_datatable_callback'; $datatableLookupInsertDataTag = ''; if ($orgTag) { // 取得组件记录的ID值。 $propertyid = $controllProperty[$property['id']['name']]; // 从这个表中得到对应关系 。 `mis_dynamic_form_indatatable` // datafieldname:当前这个数据表格的字段名。 // datainfieldname:这个是 带回数据表格中取值的字段名。 // 允许组合方式:{datafieldname:datainfieldname}, // datafieldname: a, b , c ,d // datainfieldname: e , f ,g ,h // {a:e},{b:e},{c:e} // 在需要回绑表时将数据的key带回数据的表名)查询出来。即当前表关联信息中记录的表 $relationData = $controllProperty[$property['dtlookup']['name']]; $relationData = unserialize(base64_decode($relationData)); $relationDataTableName = key($relationData); $relation = reset($relationData); $relation = $relation['list']; $relation = json_encode($relation); // dtkey: 从哪个表中的得数据。 // dtid:当前这个数据表格的ID值 // dtrelation:字段对应关系 $datatableLookupInsertDataTag = <<<EOF \t\t\t\t\t\t\t \t\t\t\t\t\t<input style="display:none;" type="text" value="datatableinsert" class="{$orgTag}.datatable_data" dtrelation='{$relation}' dtkey="{$relationDataTableName}" dtid="{$datatableID}" callback="{$dataTableCallBackFunc}" /> EOF; } $temp = <<<EOF \t \t\t\t\t\t\t\t\t\t\t\t\t{$container} \t\t\t\t\t\t\t\t\t\t\t\t<div class="into_table_lay"> \t\t\t\t\t\t\t\t\t\t\t\t{$datatableLookupInsertDataTag} \t\t\t\t\t\t\t\t\t\t\t\t{$titles} \t\t\t\t\t\t\t\t\t\t\t\t<table class="into_table_new nbm_data_table" table_data='{"formModel":"{$this->nodeName}","datatableModel":"{$dataTableModelName}","importUrl":"__APP__/MisImportExcel/misimportexceladd"}' id="{$datatableID}" table_type="{$tableoprate}"> \t\t\t\t\t\t\t\t\t\t\t\t<thead> \t\t\t\t\t\t\t\t\t\t\t\t<tr class="thead_tr"> \t\t\t\t\t\t\t\t\t\t\t\t{$filedList} \t\t\t\t\t\t\t\t\t\t\t\t{$tableOprateTitle} \t\t\t\t\t\t\t\t\t\t\t\t</tr> \t\t\t\t\t\t\t\t\t\t\t\t</thead> \t\t\t\t\t\t\t\t\t\t\t\t<tbody cellpadding="0" cellspacing="1"> EOF; /** * *************现有数据的修改展示***************************** */ $temp .= <<<EOF \t \t\t\t\t\t\t\t\t\t\t\t\t{~\$key=0;} \t\t\t\t\t\t\t\t\t\t\t\t<volist name="innerTabelObj{$controlTag}Data" id="item"> \t\t\t\t\t\t\t\t\t\t\t\t<tr> \t\t\t\t\t\t\t\t\t\t\t\t<td> \t\t\t\t\t\t\t\t\t\t\t\t<span class="serial_number"> \t\t\t\t\t\t\t\t\t\t\t\t{\$key+1} \t\t\t\t\t\t\t\t\t\t\t\t</span> \t\t\t\t\t\t\t\t\t\t\t\t</td> \t\t\t\t\t\t\t\t\t\t\t\t<!-- 现有数据 --> \t\t\t\t\t\t\t\t\t\t\t\t{$showandeditfieldlist} \t\t\t\t\t\t\t\t\t\t\t\t{$tableOprateContent} \t\t\t\t\t\t\t\t\t\t\t\t</tr> \t\t\t\t\t\t\t\t\t\t\t\t{~\$key++} \t\t\t\t\t\t\t\t\t\t\t\t</volist> EOF; /** * *****************现有数据呈现end************************* */ $temp .= "\t</tbody>"; /* * $temp .=" <tfoot>"; * $temp .=" <tr>"; * $temp .=" <td colspan=\"".($count+2)."\">"; * $temp .=" <span class=\"right\">"; * $temp .=" <input class=\"add_col_input\" type=\"text\" />"; * $temp .=" <a class=\"add_col_btn\" href=\"#\">"; * $temp .=" 新增行"; * $temp .=" </a>"; * $temp .=" </span>"; * $temp .=" </td>"; * $temp .=" </tr>"; * $temp .=" </tfoot>"; */ $temp .= "</table></div>{$containerend}"; $html = $temp; $islockHtml = parameReplace('$viewval', $viewval, $islockHtml); $html .= $islockHtml; break; default: $html = ''; } return $html; }
/** * ajax获取文本框的固定显示-动态取值功能 * @Title: lookupAjaxAppendCondtionData * @Description: todo(动态取值功能) * @author quqiang * @date 2015年4月28日 上午11:06:46 * @throws */ function lookupAjaxAppendCondtionData() { $table = $_POST['table']; // 数据检索表名 $field = $_POST['field']; // 数据检索字段名 $action = $_POST['action']; // 当前操作action名 $key = $_POST['key']; // 当前操作的字段名 $condition = html_entity_decode($_POST['condition']); $condition = str_replace(''', "'", $condition); if ($table && $field) { $obj = D($table); if (!$condition) { $condition = '1=1'; } $fieldVal = $obj->where($condition)->getField($field, 1); // 配置文件数据转换 if ($fieldVal && $action && $key) { $data['debug_3'] = '进入格式换算!'; $scdmodel = D('SystemConfigDetail'); //读取列名称数据(按照规则,应该在index方法里面) $detailList = $scdmodel->getDetail($action, false); $data['debug_5'] = '测试配置:' . arr2string($detailList); if (is_array($detailList) && $detailList[$key]) { $data['debug_4'] = '允许格式换算!'; $funcName = $detailList[$key]['func']; $funcDataSouce = $detailList[$key]['funcdata']; // 排除子表时的特殊处理。直接取得数据中的最后一项 $funcName = $funcName[count($funcName) - 1]; $funcData = $funcDataSouce[count($funcDataSouce) - 1]; switch ($funcName[0]) { case 'unitExchange': $funcData[0][3] = '2'; break; } $fieldVal = getConfigFunction($fieldVal, $funcName, $funcData); $data['debug_0'] = arr2string($funcName) . '_' . arr2string($funcData); } } $data['debug_1'] = $action . '_' . $key . '_' . $fieldVal; $data[$field] = $fieldVal; $data['sql'] = $obj->getLastSql(); echo json_encode($data); } }
public function insertsub() { $model = M("mis_system_intercalate_sub"); if ($_POST['modelid']) { $_POST['modelname'] = getFieldBy($_POST['modelid'], "id", "name", "node"); } $data = $model->create(); if (false === $data) { $this->error($model->getError()); } //保存当前数据对象 try { $list = $model->add($data); //echo $model->getlastsql(); } catch (Exception $e) { $this->error($e->__toString()); } $msg = $model->getlastsql() . arr2string($data); if (false === $list) { $this->error($msg); } else { $this->success("操作成功!"); } }
/** * (non-PHPdoc) * @Description: setFormField(通过数据库字典生成list相关信息) * @param $listFieldVal array list文件配置字段信息 * @author yangxi 2014-12-12 * @see CommonAction::update() */ public function setFormInfo($modelname) { $formList = array(); //初始化存储表单元素数组 //获取form字段的组件信息 $formid = M('mis_dynamic_form_manage')->where("actionname= '" . $modelname . "'")->getfield('id'); if ($formid) { //$result=D("MisDynamicFormProperyAndSubView")->where("formid= '".$formid."'")->select(); $sql = "SELECT\n mis_dynamic_form_propery.`id` AS `id`,\n mis_dynamic_form_propery.`showoption` AS `showoption`,\n mis_dynamic_form_propery.`subimporttableobj` AS `subimporttableobj`,\n mis_dynamic_form_propery.`subimporttablefieldobj` AS `subimporttablefieldobj`,\n mis_dynamic_form_propery.`subimporttablefield2obj` AS `subimporttablefield2obj`,\n mis_dynamic_form_propery.`subimporttableobjcondition` AS `subimporttableobjcondition`,\n mis_dynamic_form_propery.`treedtable` AS `treedtable`,\n\t \t\t\t mis_dynamic_form_propery.`dateformat` AS `dateformat`,\n mis_dynamic_form_propery.`lookupfiledback` AS `lookupfiledback`,\n mis_dynamic_form_propery.`lookupgrouporg` AS `lookupgrouporg`,\n\t \t\t\t \t\t mis_dynamic_form_propery.`org` AS `org`,\n mis_dynamic_form_propery.`org1` AS `org1`,\n mis_dynamic_form_propery.`lookupurls` AS `lookupurls`,\t \t\t\t\t \t\t\t\n mis_dynamic_form_propery.`lookupmodel` AS `lookupmodel`,\n mis_dynamic_form_propery.`lookupshoworg` AS `lookupshoworg`,\n mis_dynamic_form_propery.`lookuporgval` AS `lookuporgval`,\t \t\t\t\t \t\t\t \t\t\t\n mis_dynamic_form_propery.`lookupconditions` AS `lookupconditions`,\n mis_dynamic_form_propery.`lookupchoice` AS `lookupchoice`,\n mis_dynamic_form_propery.`viewname` AS `viewname`,\n mis_dynamic_form_propery.`viewtype` AS `viewtype`,\t\n\t \t\t\t mis_dynamic_form_propery.`org` AS `org`,\n\t \t\t\t\t mis_dynamic_form_propery.`unit` AS `unit`,\t \t\t\t\t \t\t\t\t \t\t\t\n\t \t\t\t mis_dynamic_form_propery.`unitls` AS `unitls`,\n mis_dynamic_form_propery.`title` AS `title`,\n mis_dynamic_form_propery.`category` AS `category`,\n mis_dynamic_form_propery.`fieldname` AS `fieldname`,\n mis_dynamic_form_propery.`ids` AS `ids`,\n mis_dynamic_form_propery.`formid` AS `formid`,\n mis_dynamic_form_propery.`tplid` AS `tplid`,\n mis_dynamic_form_propery.`status` AS `status`,\n\t \t\t\t\t\t mis_dynamic_form_propery.`islock` AS `islock`,\n\t \t\t\t\t\t mis_dynamic_form_propery.`isrequired` AS `isrequired`,\n\t \t\t\t\n\t \t\t\tmis_dynamic_form_propery.`treedtable`\t\t\t\t\t\tAS `treedtable`,\n\t \t\t\tmis_dynamic_form_propery.`treevaluefield` AS `treevaluefield`,\n\t \t\t\tmis_dynamic_form_propery.`treeshowfield` AS `treeshowfield`,\n\t \t\t\tmis_dynamic_form_propery.`treeparentfield` AS `treeparentfield`,\n\t \t\t\tmis_dynamic_form_propery.`isnextend` \t\t\tAS `isnextend`,\n\t \t\t\tmis_dynamic_form_propery.`mulit` \t\t\t\tAS `mulit`,\n\t \t\t\tmis_dynamic_form_propery.`treeheight` \t\tAS `treeheight`,\n\t \t\t\tmis_dynamic_form_propery.`treewidth` \t\t\tAS `treewidth`,\n\t \t\t\t\n\t \t\t\t\t\tmis_dynamic_form_propery.`additionalconditions`\t\t\t\t\t\t\t\tAS `addconditions`,\n mis_dynamic_database_sub.`field` AS `field`,\n mis_dynamic_database_sub.`formid` AS `subformid`\n FROM mis_dynamic_form_propery mis_dynamic_form_propery\n LEFT JOIN mis_dynamic_database_sub mis_dynamic_database_sub\n ON mis_dynamic_form_propery.`ids` = mis_dynamic_database_sub.`id`\n WHERE mis_dynamic_form_propery.formid = " . $formid; //M('mis_dynamic_database_sub')->where("formid= '".$formid."'")->select(); $formList = $this->query($sql); // print_r($this->getLastSql());exit; // print_r($formList); // echo 123; foreach ($formList as $key => $val) { if (!empty($val['fieldname'])) { $temp = array(); //组件name,用来提交数据的 $temp["template_name"] = "datatable[#index#][table][" . $val['fieldname'] . "]"; $temp["template_data"] = ""; $temp["template_class"] = $val["isrequired"] ? "required" : ""; $temp["template_key"] = ""; $temp["is_readonly"] = $val["islock"] ? "" : "true"; switch ($val['category']) { case "text": $temp["template_key"] = "input"; $template_data = array(); //获取ORG参数 if (!empty($val['org'])) { $org = explode(".", $val['org']); $template_data["bindlookupname"] = $org[0]; $template_data["upclass"] = $org[1]; } if (!empty($val['unitls'])) { //存储的单位编码 $template_data["unitl"] = $val['unitls']; //获取单位编码中文名 $template_data["unitlname"] = getFieldBy($val['unitls'], 'danweidaima', 'danweimingchen', 'mis_system_unit'); } $temp["template_data"] = json_encode($template_data); //列是否统计 $temp["is_stats"] = false; //小数位数 $temp["stats_num"] = 2; break; case "select": //获取ORG参数 if (!empty($val['org'])) { $org = explode(".", $val['org']); $bindlookup = array("lookupname" => $org[0], "name" => $org[1]); $temp["bindlookup"] = json_encode($bindlookup); } /* * 下拉树配置 * */ if ($val['treedtable'] && $val['treevaluefield'] && $val['treeshowfield'] && $val['treeparentfield']) { $chkStyle = "radio"; // 单选,多选 if ($val["mulit"] == 1) { $chkStyle = "checkbox"; } $isnextend = $val['isnextend'] == 1 ? 1 : 0; // 获取下拉树的显示数据 $treeData = getControllbyHtml("table", array("type" => "select", "table" => $val['treedtable'], "id" => $val['treevaluefield'], "name" => $val['treeshowfield'], "showtype" => "1", "comboxtree" => "1", "parentid" => $val['treeparentfield'], "isnextend" => $isnextend)); $dataSouceArr = '{"treeconfig":' . '{"expandAll":false,' . '"checkEnable":true,' . '"chkStyle":"' . $chkStyle . '",' . '"radioType":"all",' . '"onClick":"S_NodeClick",' . '"onCheck":"S_NodeCheck"},' . '"treeheight":"' . $val['treeheight'] . '",' . '"treewidth":"' . $val['treewidth'] . '",' . '"treedata":' . $treeData . '}'; $temp["template_data"] = $dataSouceArr; $temp["template_key"] = "selecttree"; } else { $temp["template_key"] = "select"; $temp["template_data"] = "["; $abc = $this->getSelectSource($val); foreach ($abc as $skey => $sval) { $temp["template_data"] .= '{"value":"' . $skey . '","name":"' . $sval . '"},'; } //去掉最后一个, $temp["template_data"] = $abc ? substr($temp["template_data"], 0, -1) . "]" : $temp["template_data"] . "]"; //数据格式例子 //$temp["template_data"] = '[{"value":1,"name":"第一人"},{"value":2,"name":"第二人"}]'; } break; case "lookup": $temp["template_key"] = "lookup"; $abc = $this->getLookupSource($val); //upclass:查找带回显示字段,格式 string class="textInput enterIndex readonly into_table_new9122317_wrapperorgfandanbaocuoshibianhao11.name" class里 org.name //callback是回调函数 param是传递到lookupGeneral函数的参数,格式 string 例:param="field=orderno,pid,name,id&model=MisSaleProfession&newconditions=" //herf是请求地址 格式 string 例:href="/workarea/workstation/systemui/product/Admin/index.php/MisAutoDap/lookupGeneral" //hidden_data:隐藏的存入数据库字段的值 格式 :[{"upclass":"","name":"datatable[#index#][datatable1][sinianji]"}],其中upclass是查找带回存储字段,name是隐藏输入入框的name,[datatable1][sinianji]表名,字段名 $param = ""; //初始化参数 $param .= "lookupchoice=" . $val['lookupchoice']; //传Key值 unset($lookuporg0); unset($lookuporg1); $lookuporg0 = explode('.', $val['org']); $lookuporg1 = explode('.', $val['org1']); $bindlookupname = $lookuporg1[0] ? $lookuporg1[0] : $lookuporg0[0]; $param .= ''; // //lookup带回字段 // $param.="field=".$val['lookupfiledback']; // //lookup的模型对象 // $param.="&model=".$val['lookupmodel']; //过滤条件 ////////////////////////////////////////////////////////////////////////////////////////////// unset($conditionConfigJson); unset($appendCondtion); unset($additionalconditions); unset($formFiledList); unset($sysFieldList); unset($sysFieldFmt); unset($appendCondtionArr); unset($appendCondtionStr); unset($conditions); unset($formFiledFmt); $additionalconditions = $val['addconditions']; if ($additionalconditions) { $appendCondtion = unserialize(base64_decode($additionalconditions)); // proexp 表单字段列表 // sysexp 系统字段列表 $formFiledList = $appendCondtion['proexp']; $sysFieldList = $appendCondtion['sysexp']; // $formFiledFmt=array(); // $sysFieldFmt = array(); $sysFieldFmt = unserialize($sysFieldList) or array(); // 获取真实的表单字段名。 if ($formFiledList) { $formFiledListArr = unserialize($formFiledList) or array(); if (is_array($formFiledListArr) && count($formFiledListArr)) { $formFiledKey = array_keys($formFiledListArr); $properModel = M('mis_dynamic_form_propery'); $properMap['id'] = array('in', $formFiledKey); unset($fd); $fd = $properModel->where($properMap)->field('fieldname,id')->select(); if ($fd) { foreach ($fd as $k => $v) { // $fieldArr[] = $v['fieldname']; if ($formFiledListArr[$v['id']] == -1) { $formFiledFmt[$v['fieldname']] = $v['fieldname']; } else { $formFiledFmt[$v['fieldname']] = $formFiledListArr[$v['id']]; } } } } } if (is_array($sysFieldFmt) && is_array($formFiledFmt)) { $appendCondtionArr = array_merge($sysFieldFmt, $formFiledFmt); } elseif (is_array($sysFieldFmt) && !is_array($formFiledFmt)) { $appendCondtionArr = $sysFieldFmt; } elseif (!is_array($sysFieldFmt) && is_array($formFiledFmt)) { $appendCondtionArr = $formFiledFmt; } else { $appendCondtionArr = array(); } // 将条件转换为可用的sql where语句 $appendCondtionStr = arr2string($appendCondtionArr); logs($val['fieldname'] . $appendCondtionStr, 'rinidaye'); //$conditions = "{:getAppendCondition(\$vo ,$appendCondtionStr)}"; $conditions = getAppendCondition($vo, $appendCondtionArr); if (is_array($appendCondtionArr)) { unset($tempData); foreach ($appendCondtionArr as $k => $v) { $tempData[$v] = $k; } $conditionConfigJson = ',"condition":' . json_encode($tempData); } } //////////////////////////////////////////////////////////////////// $param .= "&newconditions=" . $conditions; $val['callback'] = "lookup_counter_check"; //herf路径 $herf = __APP__ . '/' . $modelname . '/' . $val['lookupurls']; $temp["template_data"] = '{"bindlookupname":"' . $bindlookupname . '","upclass":"' . $val['lookupshoworg'] . '","lporder":"' . $lookuporg1[1] . '","lpkey":"' . $val['lookupchoice'] . '","callback":"' . $val['callback'] . '","param":"' . $param . '","lookupname":"' . $val['lookupgrouporg'] . '","href":"' . $herf . '","hidden_data":[{"upclass":"' . $val['lookuporgval'] . '","lporder":"' . $lookuporg0[1] . '","name":"datatable[#index#][table][' . $val['fieldname'] . ']"}]' . $conditionConfigJson . '}'; break; case "date": $temp["template_key"] = "date"; //日期格式 if (empty($val['format'])) { $val['dateformat'] = "yyyy-MM-dd"; } else { $formatTemp = explode('@', $val['dateformat']); $val['dateformat'] = $formatTemp[0]; } $temp["template_data"] = '{"format":"' . $val['dateformat'] . '"}'; break; case "upload": $temp["template_key"] = "uploadfilenew"; $temp["template_data"] = '{"url":"__URL__/DT_uploadnew"}'; break; default: break; } $th_html = array(); foreach ($temp as $k => $v) { $th_html[] = $k . "='" . $v . "'"; } $th_html = implode(" ", $th_html); $val['datatable'] = $th_html; $list[$val["fieldname"]] = $val; } } } $this->SetRules($list, $modelname, $typename = "form"); }
require_once DIR_FS_MODULES . 'general/language/' . $_SESSION['language'] . '/language.php'; require $filepath; execute_upgrade(); } else { die('Trying to upgrade to Release ' . PROJECT_VERSION_MAJOR . '.' . PROJECT_VERSION_MINOR . ' but the upgrade file could not be found!'); } } // load currency classes require DIR_FS_CLASSES . 'currencies.php'; $currencies = new currencies(); } // initialize the message stack for output messages, must be after session starts and configuration variables load require DIR_FS_CLASSES . 'message_stack.php'; $messageStack = new messageStack(); $messageStack->debug("\nGET Vars = " . arr2string($_GET)); $messageStack->debug("\nPOST Vars = " . arr2string($_POST)); // pull in the custom language over-rides for this module (to pre-define the standard language) $custom_path = DIR_FS_MY_FILES . 'custom/' . $cat . '/' . $module . '/extra_defines.php'; if (file_exists($custom_path)) { include $custom_path; } // load general language translation, Check for global define overrides first $extra_datafiles_dir = DIR_FS_MY_FILES . 'custom/extra_defines/'; if ($dir = @dir($extra_datafiles_dir)) { while ($file = $dir->read()) { if (!is_dir($extra_datafiles_dir . $file)) { if (preg_match('/\\.php$/', $file) > 0) { include_once $extra_datafiles_dir . $file; } } }
function arr2string($arr) { if (!is_array($arr)) { return $arr; } $output = "Array ("; if (sizeof($arr) > 0) { foreach ($arr as $key => $val) { if (is_array($val)) { $output .= ' [' . $key . '] => ' . arr2string($val); } else { $output .= ' [' . $key . '] => ' . $val; } } } $output .= ' )'; return $output; }
/** +---------------------------------------------------------- * 创建数据对象 但不保存到数据库 +---------------------------------------------------------- * @access public +---------------------------------------------------------- * @param mixed $data 创建数据 * @param string $type 状态 +---------------------------------------------------------- * @return mixed +---------------------------------------------------------- */ public function create($data = '', $type = '') { // 如果没有传值默认取POST数据 if (empty($data)) { $data = $_POST; } elseif (is_object($data)) { $data = get_object_vars($data); } // 验证数据 if (empty($data) || !is_array($data)) { $this->error = L('_DATA_TYPE_INVALID_'); return false; } // 检查字段映射 $data = $this->parseFieldsMap($data, 0); // 状态 $type = $type ? $type : (!empty($data[$this->getPk()]) ? self::MODEL_UPDATE : self::MODEL_INSERT); // 检测提交字段的合法性 if (isset($this->options['field'])) { // $this->field('field1,field2...')->create() $fields = $this->options['field']; unset($this->options['field']); } elseif ($type == self::MODEL_INSERT && isset($this->insertFields)) { $fields = $this->insertFields; } elseif ($type == self::MODEL_UPDATE && isset($this->updateFields)) { $fields = $this->updateFields; } if (isset($fields)) { if (is_string($fields)) { $fields = explode(',', $fields); } // 判断令牌验证字段 if (C('TOKEN_ON')) { $fields[] = C('TOKEN_NAME'); } foreach ($data as $key => $val) { if (!in_array($key, $fields)) { unset($data[$key]); } } } // 数据自动验证 if (!$this->autoValidation($data, $type)) { return false; } // 表单令牌验证 if (C('TOKEN_ON') && !$this->autoCheckToken($data)) { $this->error = L('_TOKEN_ERROR_'); return false; } // 验证完成生成数据对象 if ($this->autoCheckFields) { // 开启字段检测 则过滤非法字段数据 $vo = array(); foreach ($this->fields as $key => $name) { if (substr($key, 0, 1) == '_') { continue; } $val = isset($data[$name]) ? $data[$name] : null; //保证赋值有效 if (!is_null($val)) { $vo[$name] = MAGIC_QUOTES_GPC && is_string($val) ? stripslashes($val) : $val; } } } else { $vo = $data; } // 创建完成对数据进行自动处理 $this->autoOperation($vo, $type); logs("----------1---------" . arr2string($vo), MODULE_NAME . '_list_data_' . date('Y-m-d-H', time()), '', __CLASS__, __FUNCTION__, __METHOD__); logs(ACTION_NAME . "----------1---------" . arr2string($this->_filter), MODULE_NAME . '_filter_list_data_' . date('Y-m-d-H', time()), '', __CLASS__, __FUNCTION__, __METHOD__); // 数据字段添加条件过滤,(加入了新增和修改页面模板控制,所有过滤掉新增和启动流程底层控制) add by nbmxkj at 20150128 1943 if (ACTION_NAME == 'insert' || ACTION_NAME == 'startprocess' || ACTION_NAME == 'lookupUpdateProcess') { $this->_filter = array(); } else { if (!empty($this->_filter)) { foreach ($this->_filter as $field => $filter) { if ($this->getPk() == $field) { //排除主键过滤 continue; } if (is_array($filter)) { if ($filter[0] == 'filterWritSetEmpty' || $filter[1] == 'filterReadSetEmpty') { unset($vo[$field]); } } } $this->_filter = array(); } } logs(ACTION_NAME . "----------2---------" . arr2string($this->_filter), MODULE_NAME . '_filter_list_data_' . date('Y-m-d-H', time()), '', __CLASS__, __FUNCTION__, __METHOD__); logs("----------2---------" . arr2string($vo), MODULE_NAME . '_list_data_' . date('Y-m-d-H', time()), '', __CLASS__, __FUNCTION__, __METHOD__); // 赋值当前数据对象 $this->data = $vo; // 返回创建的数据以供其他调用 return $vo; }
function load_so_po_balance($ref_id, $id = '', $post = true) { global $db, $messageStack; $messageStack->debug("\n Starting to load SO/PO balances ..."); $item_array = array(); if ($ref_id) { switch ($this->journal_id) { case 4: case 6: case 7: case 21: $gl_type = 'poo'; $proc_type = 'por'; break; case 10: case 12: case 13: case 19: $gl_type = 'soo'; $proc_type = 'sos'; break; default: return $this->fail_message('Error in classes/gen_ledger, function load_so_po_balance. Bad $journal_id for this function.'); } // start by retrieving the po/so item list $sql = "select id, sku, qty from " . TABLE_JOURNAL_ITEM . " \r\n\t\t\t\twhere ref_id = " . $ref_id . " and gl_type = '" . $gl_type . "'"; $result = $db->Execute($sql); while (!$result->EOF) { if ($result->fields['sku']) { $item_array[$result->fields['id']]['ordered'] = $result->fields['qty']; } $result->MoveNext(); } // retrieve the total number of units processed (received/shipped) less this order (may be multiple sales/purchases) $sql = "select i.so_po_item_ref_id as id, i.sku, i.qty \r\n\t\t\t\tfrom " . TABLE_JOURNAL_MAIN . " m left join " . TABLE_JOURNAL_ITEM . " i on m.id = i.ref_id\r\n\t\t\t\twhere m.so_po_ref_id = " . $ref_id . " and i.gl_type = '" . $proc_type . "'"; if (!$post && $id) { $sql .= " and m.id <> " . $id; } // unposting so don't include current id (journal_id = 6 or 12) $result = $db->Execute($sql); while (!$result->EOF) { if ($result->fields['sku']) { $item_array[$result->fields['id']]['processed'] += $result->fields['qty']; } $result->MoveNext(); } } $this->so_po_balance_array = $item_array; $messageStack->debug(" Finished loading SO/PO balances = " . arr2string($item_array)); return $item_array; }
private function find_right_invoice() { global $db, $messageStack, $currencies; $messageStack->debug("\n trying to find the right invoice"); $found_invoices = array(); $invoice_number = array(); $invoice_id = array(); $epsilon = 1.0E-5; if (isset($this->open_inv[$this->bill_acct_id])) { foreach ($this->open_inv[$this->bill_acct_id] as $key => $invoice) { //when we find a invoice we book a payment to it if (strripos($this->_description, $invoice['purchase_invoice_id']) !== false) { // if invoice is part of the description use it $messageStack->debug("\n Found matching invoice number in description purchase_invoice_id " . $invoice['purchase_invoice_id'] . ' id ' . $invoice['id'] . "\n variables " . arr2string($invoice)); $invoice['found_by_number'] = true; $found_invoices[] = $invoice; } else { if (abs($invoice['total_amount'] - $invoice['amount_paid'] - $this->total_amount) < $epsilon) { $messageStack->debug("\n Found by value matching invoice purchase_invoice_id " . $invoice['purchase_invoice_id'] . ' id ' . $invoice['id'] . "\n variables " . arr2string($invoice)); $invoice['found_by_number'] = false; $found_invoices[] = $invoice; } } } } if ($this->_accounttype == 'c') { $this->_firstjid = 18; $gl_acct_id = AR_DEFAULT_GL_ACCT; $gl_disc_acct_id = AR_DISCOUNT_SALES_ACCOUNT; $this->purchase_invoice_id = 'DP' . $this->post_date; $this->description = sprintf(TEXT_JID_ENTRY, constant('ORD_TEXT_18_C_WINDOW_TITLE')); define('GL_TYPE', 'pmt'); } else { $this->_firstjid = 20; $gl_acct_id = AP_DEFAULT_PURCHASE_ACCOUNT; $gl_disc_acct_id = AP_DISCOUNT_PURCHASE_ACCOUNT; $result = $db->Execute("select next_check_num from " . TABLE_CURRENT_STATUS); $this->description = sprintf(TEXT_JID_ENTRY, constant('ORD_TEXT_20_V_WINDOW_TITLE')); define('GL_TYPE', 'chk'); } $this->journal_id = $this->_firstjid; $good = false; $step = 1; $difference_perc = 100; while (!$good && $step <= 9 && sizeof($found_invoices) > 0) { $amount_used = 0; if (!$good) { $this->journal_rows = null; } for ($i = 0; $i < sizeof($found_invoices); $i++) { $found_invoices[$i]['amount'] = $found_invoices[$i]['total_amount'] - $found_invoices[$i]['amount_paid']; $found_invoices[$i]['payed_if_full'] = true; switch ($step) { case 6: case 1: // full amount is payed $found_invoices[$i]['discount'] = false; $messageStack->debug("\n step {$step} trying if we get totals balanced when the full amount is payed. "); break; case 7: case 2: // make use of discount full $messageStack->debug("\n step {$step} trying if we get totals balanced when the full discount is used. "); if ($found_invoices[$i]['early_date'] >= $this->post_date) { // if post_date is smaller than early_date allow discount $found_invoices[$i]['discount'] = round($found_invoices[$i]['total_amount'] * $found_invoices[$i]['percent'], $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']); $messageStack->debug("\n discount could be used for invoice " . $found_invoices[$i]['purchase_invoice_id'] . " Payed = " . $found_invoices[$i]['amount'] . " Discount = " . $found_invoices[$i]['discount']); } break; case 8: case 3: // make use of less discount than is allowed. $messageStack->debug("\n step {$step} trying if we get totals balanced when less than the full discount is used. "); if ($found_invoices[$i]['discount'] && $difference > 0) { $messageStack->debug("\n for invoice " . $found_invoices[$i]['purchase_invoice_id'] . " discount = " . $found_invoices[$i]['discount'] . " difference = " . $difference); if ($found_invoices[$i]['discount'] >= $difference) { $found_invoices[$i]['discount'] -= $difference; $difference = 0; $messageStack->debug("\n for invoice " . $found_invoices[$i]['purchase_invoice_id'] . " discount reduced by the difference."); } else { $difference -= $found_invoices[$i]['discount']; $found_invoices[$i]['discount'] = false; $messageStack->debug("\n for invoice " . $found_invoices[$i]['purchase_invoice_id'] . " discount is set to null and difference is decreased by the discount."); } $found_invoices[$i]['discount'] = round($found_invoices[$i]['discount'], $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']); } break; case 5: // unset items that where not found by invoice_number $messageStack->debug("\n step {$step} removing items that were not found by invoice number. "); if (!$found_invoices[$i]['found_by_number']) { $messageStack->debug("\n removing invoice number. " . $found_invoices[$i]['purchase_invoice_id']); $found_invoices[$i]['total_amount'] = 0; $found_invoices[$i]['amount_paid'] = 0; $found_invoices[$i]['amount'] = 0; $found_invoices[$i]['early_date'] = 0; $found_invoices[$i]['percent'] = 0; $found_invoices[$i]['discount'] = false; } $messageStack->debug("\n now only use invoices " . arr2string($invoice)); break; case 9: //do a partial payment if ($difference_perc > 0) { $found_invoices[$i]['amount'] = round($found_invoices[$i]['amount'] / $difference_perc, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']); $messageStack->debug("\n step " . $step . " doing a partial payment. "); $found_invoices[$i]['payed_if_full'] = false; $found_invoices[$i]['discount'] = false; } else { $found_invoices[$i]['amount'] = 0; $found_invoices[$i]['payed_if_full'] = false; $found_invoices[$i]['discount'] = false; } break; case 4: //try the first invoice $messageStack->debug("\n step {$step} trying the first invoice. "); if ($i > 0) { $found_invoices[$i]['discount'] = false; $found_invoices[$i]['amount'] = 0; $found_invoices[$i]['payed_if_full'] = false; } break; } if ($found_invoices[$i]['amount'] != 0) { $this->journal_rows[] = array('so_po_item_ref_id' => $found_invoices[$i]['id'], 'gl_type' => GL_TYPE, 'gl_account' => $gl_acct_id, 'serialize_number' => $found_invoices[$i]['purchase_invoice_id'], 'post_date' => $this->post_date, 'debit_amount' => $this->_firstjid == 20 ? $found_invoices[$i]['amount'] : 0, 'credit_amount' => $this->_firstjid == 20 ? 0 : $found_invoices[$i]['amount'], 'description' => $this->_description); } if ($found_invoices[$i]['discount']) { $this->journal_rows[] = array('so_po_item_ref_id' => $found_invoices[$i]['id'], 'gl_type' => 'dsc', 'gl_account' => $gl_disc_acct_id, 'serialize_number' => $found_invoices[$i]['purchase_invoice_id'], 'post_date' => $this->post_date, 'debit_amount' => $this->_firstjid == 20 ? 0 : $found_invoices[$i]['discount'], 'credit_amount' => $this->_firstjid == 20 ? $found_invoices[$i]['discount'] : 0, 'description' => $this->_description); } $amount_used += $found_invoices[$i]['amount'] - $found_invoices[$i]['discount']; } if ($step == 5) { $difference_perc = $amount_used / $this->total_amount; } $difference = $this->total_amount - $amount_used; $good = abs($this->total_amount - $amount_used) < $epsilon; $messageStack->debug("\n contiune = {$good} total_amount = {$this->total_amount} amount_used = {$amount_used} difference percent = {$difference_perc}"); $step++; } if ($good == false) { if (sizeof($found_invoices) != 0) { $messageStack->debug("\n Found invoices but total amounts didn't align. "); $this->journal_rows = null; $amount_used = 0; } $messageStack->debug("\n posting payment as a deposit "); $this->journal_rows[] = array('so_po_item_ref_id' => '', 'gl_type' => GL_TYPE, 'gl_account' => $gl_acct_id, 'serialize_number' => '', 'post_date' => $this->post_date, 'debit_amount' => $this->_debitamount, 'credit_amount' => $this->_creditamount, 'description' => $this->_description); $this->waiting = 1; } else { for ($i = 0; $i < sizeof($found_invoices); $i++) { $this->open_inv[$this->bill_acct_id][$found_invoices[$i]['purchase_invoice_id']]['amount_paid'] += $found_invoices[$i]['amount']; if ($found_invoices[$i]['payed_if_full']) { $messageStack->debug("\n unsetting invoice " . arr2string($this->open_inv[$this->bill_acct_id][$found_invoices[$i]['purchase_invoice_id']])); unset($this->open_inv[$this->bill_acct_id][$found_invoices[$i]['purchase_invoice_id']]); } } $messageStack->debug("\n posting payment to invoices " . arr2string($found_invoices)); } $this->journal_rows[] = array('gl_type' => 'ttl', 'gl_account' => $this->gl_acct_id, 'post_date' => $this->post_date, 'debit_amount' => $this->_creditamount, 'credit_amount' => $this->_debitamount, 'description' => $this->_description); $this->journal_main_array = $this->build_journal_main_array(); $this->validate_purchase_invoice_id(); $this->Post('insert', true); $this->increment_purchase_invoice_id(); if ($good == false) { // make credit inv $messageStack->debug("\n Making credit invoice. "); $this->journal_main_array = null; $this->journal_id = $this->_firstjid == 20 ? 7 : 13; $this->gl_acct_id = $gl_acct_id; $this->id = null; $this->description = GENERAL_JOURNAL_7_DESC; $this->purchase_invoice_id = ''; $this->journal_rows = null; $this->journal_rows[] = array('gl_type' => 'por', 'gl_account' => $gl_acct_id, 'post_date' => $this->post_date, 'debit_amount' => $this->_debitamount, 'credit_amount' => $this->_creditamount); $this->journal_rows[] = array('id' => '', 'gl_type' => 'ttl', 'gl_account' => $this->gl_acct_id, 'post_date' => $this->post_date, 'debit_amount' => $this->_creditamount, 'credit_amount' => $this->_debitamount, 'description' => $this->_description); $this->journal_main_array = $this->build_journal_main_array(); $this->validate_purchase_invoice_id(); $this->Post('insert', true); $this->increment_purchase_invoice_id(); } $this->_succes = true; return true; }
/** * @Title: createAction * @Description: todo(生成Action代码) * @param array $fieldData 组件属性列表 * @param string $cotrollname 控制器名称 * @param boolean $add 是否覆盖现有文件,默认为false:需要覆盖 * @param boolean $isaudit 是否带审批流,默认为false:不带审批流 * @param boolean $isinitExtendAction 是否初始化扩展Action代码 默认为空,不初始化【为组合表单的初化解绑准备】 * @author quqiang * @date 2014-8-21 上午10:03:39 * @throws */ function createAction($fieldData, $cotrollname, $add = false, $isaudit = false, $isinitExtendAction = false) { $cotrollname = ucfirst($cotrollname); $actionPath = LIB_PATH . "Action/" . $cotrollname . "Action.class.php"; $actionExtendPath = LIB_PATH . "Action/" . $cotrollname . "ExtendAction.class.php"; $isExist = file_exists($actionPath); if ($isExist && $add) { $this->error($actionPath . "文件已存在!"); } $extendphpcode .= "<?php\r\n/**"; $extendphpcode .= "\r\n * @Title: {$cotrollname}Action"; $extendphpcode .= "\r\n * @Package package_name"; $extendphpcode .= "\r\n * @Description: todo(动态表单_扩展类。本类为用户代码注入入口,系统一旦生成将不再重复生成。"; $extendphpcode .= "\r * \t\t\t\t\t\t但当用户选为组合表单方案后会更新该文件,请做好备份)"; $extendphpcode .= "\r\n * @author " . $_SESSION['loginUserName']; $extendphpcode .= "\r\n * @company Aqo5Re65bSr5zG755m45t92YuQnZvNHbtRnL3d3d"; $extendphpcode .= "\r\n * @copyright 本文件归属于Aqo5Re65bSr5zG755m45t92YuQnZvNHbtRnL3d3d"; $extendphpcode .= "\r\n * @date " . date('Y-m-d H:i:s'); $extendphpcode .= "\r\n * @version V1.0"; $extendphpcode .= "\r\n*/"; $extendphpcode .= "\r\nclass "; $phpcode .= "<?php\r\n/**"; $phpcode .= "\r\n * @Title: {$cotrollname}Action"; $phpcode .= "\r\n * @Package package_name"; $phpcode .= "\r\n * @Description: todo(动态表单_自动生成-" . $this->nodeTitle . ")"; $phpcode .= "\r\n * @author " . $_SESSION['loginUserName']; $phpcode .= "\r\n * @company Aqo5Re65bSr5zG755m45t92YuQnZvNHbtRnL3d3d"; $phpcode .= "\r\n * @copyright 本文件归属于Aqo5Re65bSr5zG755m45t92YuQnZvNHbtRnL3d3d"; $phpcode .= "\r\n * @date " . date('Y-m-d H:i:s'); $phpcode .= "\r\n * @version V1.0"; $phpcode .= "\r\n*/"; $phpcode .= "\r\nclass "; if ($isaudit) { $jcc = "CommonAuditAction"; } else { $jcc = "CommonAction"; } $extendsCC = $cotrollname . "ExtendAction"; $extendphpcode .= $cotrollname . "ExtendAction extends " . $jcc . " {\r\n"; $phpcode .= $cotrollname . "Action extends " . $extendsCC . " {\r\n"; $phpcode .= "\tpublic function _filter(&\$map){"; //start filter $extendphpcode .= "\tpublic function _extend_filter(&\$map){"; //start filter $phpcode .= "\r\n"; // \$map['allnode']=\$this->getActionName(); $phpcode .= <<<COD \t\t\$fieldtype=\$_REQUEST['fieldtype']; \t\t\$relationmodelname=\$_REQUEST['bindaname']; \t\t//获取表单类型 \t\t\$type=getFieldBy(\$relationmodelname, "bindaname", "typeid", "mis_auto_bind"); \t\t \t\tif(\$fieldtype){ \t\t\t\$map[\$fieldtype]=\$_REQUEST[\$fieldtype]; \t\t\t\$this->assign("fieldtype",\$fieldtype); \t\t\t\$this->assign("fieldtypeval",\$_REQUEST[\$fieldtype]); \t\t}else{ \t\t\t//组从表单需加此条件过滤 \t\t\tif(\$type==1){ \t\t\t\tif(\$relationmodelname){ \t\t\t\t\t\$map['relationmodelname']=\$relationmodelname;\t \t\t\t\t} \t\t\t} \t\t} \t\t//强制加allnode 4.25 为区分复用表数据 \t\t \$map['allnode']=\$this->getActionName(); \t\tif(\$type==1){ \t\t\t// 为了兼容普通模式下的表单使用 \t\t\t\$bindid = \$_REQUEST['bindid']; \t\t\tif(\$bindid){ \t\t\t\t\$map['bindid']=\$bindid; \t\t\t\t\$this->assign("bindid",\$bindid); \t\t\t} \t\t} \t\tif (\$_SESSION["a"] != 1){ \t\t\t\$map['status']=array("gt",-1); \t\t} \t\t\$this->_extend_filter(\$map); COD; $phpcode .= "\r\n\t}"; $extendphpcode .= "\r\n\t}"; $extendphpcode .= "\r\n\t/**"; $extendphpcode .= "\r\n\t * @Title: _extend_before_index"; $extendphpcode .= "\r\n\t * @Description: todo(扩展前置index函数)"; $extendphpcode .= "\r\n\t * @author " . $_SESSION['loginUserName']; $extendphpcode .= "\r\n\t * @date " . date('Y-m-d H:i:s'); $extendphpcode .= "\r\n\t * @throws "; $extendphpcode .= "\r\n\t*/"; $extendphpcode .= "\r\n\tfunction _extend_before_index() {"; $extendphpcode .= "\r\n\t}"; $extendphpcode .= "\r\n\t/**"; $extendphpcode .= "\r\n\t * @Title: _extend_before_edit"; $extendphpcode .= "\r\n\t * @Description: todo(扩展的前置编辑函数)"; $extendphpcode .= "\r\n\t * @author " . $_SESSION['loginUserName']; $extendphpcode .= "\r\n\t * @date " . date('Y-m-d H:i:s'); $extendphpcode .= "\r\n\t * @throws "; $extendphpcode .= "\r\n\t*/"; $extendphpcode .= "\r\n\tfunction _extend_before_edit(){"; $extendphpcode .= "\r\n\t}"; $extendphpcode .= "\r\n\t/**"; $extendphpcode .= "\r\n\t * @Title: _extend_before_insert"; $extendphpcode .= "\r\n\t * @Description: todo(扩展的前置添加函数)"; $extendphpcode .= "\r\n\t * @author " . $_SESSION['loginUserName']; $extendphpcode .= "\r\n\t * @date " . date('Y-m-d H:i:s'); $extendphpcode .= "\r\n\t * @throws "; $extendphpcode .= "\r\n\t*/"; $extendphpcode .= "\r\n\tfunction _extend_before_insert(){"; $extendphpcode .= "\r\n\t}"; $extendphpcode .= "\r\n\t/**"; $extendphpcode .= "\r\n\t * @Title: _extend_before_update"; $extendphpcode .= "\r\n\t * @Description: todo(扩展前置修改函数) "; $extendphpcode .= "\r\n\t * @author " . $_SESSION['loginUserName']; $extendphpcode .= "\r\n\t * @date " . date('Y-m-d H:i:s'); $extendphpcode .= "\r\n\t * @throws"; $extendphpcode .= "\r\n\t*/"; $extendphpcode .= "\r\n\tfunction _extend_before_update(){"; $extendphpcode .= "\r\n\t}"; $extendphpcode .= "\r\n\t/**"; $extendphpcode .= "\r\n\t * @Title: _extend_after_edit"; $extendphpcode .= "\r\n\t * @Description: todo(扩展后置编辑函数)"; $extendphpcode .= "\r\n\t * @author " . $_SESSION['loginUserName']; $extendphpcode .= "\r\n\t * @date " . date('Y-m-d H:i:s'); $extendphpcode .= "\r\n\t * @throws "; $extendphpcode .= "\r\n\t*/"; $extendphpcode .= "\r\n\tfunction _extend_after_edit(&\$vo){"; // $extendphpcode .="\r\n\t\tif(\$_GET['viewtype']=='view'){"; // $extendphpcode .="\r\n\t\t\t\$this->assign( 'vo', \$vo );"; // $extendphpcode .="\r\n\t\t\t\$this->display('formview');"; // $extendphpcode .="\r\n\t\t\texit;"; // $extendphpcode .="\r\n\t\t}"; $extendphpcode .= "\r\n\t}"; $extendphpcode .= "\r\n\t/**"; $extendphpcode .= "\r\n\t * @Title: _extend_after_list"; $extendphpcode .= "\r\n\t * @Description: todo(扩展前置List)"; $extendphpcode .= "\r\n\t * @author " . $_SESSION['loginUserName']; $extendphpcode .= "\r\n\t * @date " . date('Y-m-d H:i:s'); $extendphpcode .= "\r\n\t * @throws "; $extendphpcode .= "\r\n\t*/"; $extendphpcode .= "\r\n\tfunction _extend_after_list(){"; $extendphpcode .= "\r\n\t}"; $extendphpcode .= "\r\n\t/**"; $extendphpcode .= "\r\n\t * @Title: _extend_after_insert"; $extendphpcode .= "\r\n\t * @Description: todo(扩展后置insert函数) "; $extendphpcode .= "\r\n\t * @author " . $_SESSION['loginUserName']; $extendphpcode .= "\r\n\t * @date " . date('Y-m-d H:i:s'); $extendphpcode .= "\r\n\t * @throws"; $extendphpcode .= "\r\n\t*/"; $extendphpcode .= "\r\n\tfunction _extend_after_insert(\$id){"; $extendphpcode .= "\r\n\t}"; $extendphpcode .= "\r\n\t/**"; $extendphpcode .= "\r\n\t * @Title: _extend_before_add"; $extendphpcode .= "\r\n\t * @Description: todo(扩展前置add函数) "; $extendphpcode .= "\r\n\t * @author " . $_SESSION['loginUserName']; $extendphpcode .= "\r\n\t * @date " . date('Y-m-d H:i:s'); $extendphpcode .= "\r\n\t * @throws"; $extendphpcode .= "\r\n\t*/"; $extendphpcode .= "\r\n\tfunction _extend_before_add(&\$vo){"; $extendphpcode .= "\r\n\t\t\$this->getFormIndexLoad(\$vo);"; $extendphpcode .= "\r\n\t}"; $extendphpcode .= "\r\n\t/**"; $extendphpcode .= "\r\n\t * @Title: _extend_after_update"; $extendphpcode .= "\r\n\t * @Description: todo(扩展后置update函数) "; $extendphpcode .= "\r\n\t * @author " . $_SESSION['loginUserName']; $extendphpcode .= "\r\n\t * @date " . date('Y-m-d H:i:s'); $extendphpcode .= "\r\n\t * @throws"; $extendphpcode .= "\r\n\t*/"; $extendphpcode .= "\r\n\tfunction _extend_after_update(){"; $extendphpcode .= "\r\n\t}"; // beforindex $before_index = ''; $before_index .= "\r\n\t/**"; $before_index .= "\r\n\t * @Title: _before_index"; $before_index .= "\r\n\t * @Description: todo(前置index函数)"; $before_index .= "\r\n\t * @author " . $_SESSION['loginUserName']; $before_index .= "\r\n\t * @date " . date('Y-m-d H:i:s'); $before_index .= "\r\n\t * @throws "; $before_index .= "\r\n\t*/"; $before_index .= "\r\n\tfunction _before_index() {"; // 默认生成 前置函数 $before_edit = ''; $before_edit .= "\r\n\t/**"; $before_edit .= "\r\n\t * @Title: _before_edit"; $before_edit .= "\r\n\t * @Description: todo(前置编辑函数)"; $before_edit .= "\r\n\t * @author " . $_SESSION['loginUserName']; $before_edit .= "\r\n\t * @date " . date('Y-m-d H:i:s'); $before_edit .= "\r\n\t * @throws "; $before_edit .= "\r\n\t*/"; $before_edit .= "\r\n\tfunction _before_edit(){"; $before_insert = ''; $before_insert .= "\r\n\t/**"; $before_insert .= "\r\n\t * @Title: _before_insert"; $before_insert .= "\r\n\t * @Description: todo(前置添加函数)"; $before_insert .= "\r\n\t * @author " . $_SESSION['loginUserName']; $before_insert .= "\r\n\t * @date " . date('Y-m-d H:i:s'); $before_insert .= "\r\n\t * @throws "; $before_insert .= "\r\n\t*/"; $before_insert .= "\r\n\tfunction _before_insert(){"; $allNodeconfig = $fieldData['all']; if (in_array("orderno", array_keys($allNodeconfig)) || $this->isaudit) { //判断是否带审批流,必须验证编码是否重复 $before_insert .= "\r\n\t\t\$this->checkifexistcodeororder('{$this->tableName}','orderno',\$this->getActionName());"; } $before_update = ''; $before_update .= "\r\n\t/**"; $before_update .= "\r\n\t * @Title: _before_update"; $before_update .= "\r\n\t * @Description: todo(前置修改函数) "; $before_update .= "\r\n\t * @author " . $_SESSION['loginUserName']; $before_update .= "\r\n\t * @date " . date('Y-m-d H:i:s'); $before_update .= "\r\n\t * @throws"; $before_update .= "\r\n\t*/"; $before_update .= "\r\n\tfunction _before_update(){"; if (in_array("orderno", array_keys($allNodeconfig)) || $this->isaudit) { //判断是否带审批流,必须验证编码是否重复 $before_update .= "\r\n\t\t\$this->checkifexistcodeororder('{$this->tableName}','orderno',\$this->getActionName(),1);"; } // 重写父类编辑函数--为多表操作所做的修改 屈强@20141008 15:53 $edit = ''; $edit .= "\r\n\t/**"; $edit .= "\r\n\t * @Title: edit"; $edit .= "\r\n\t * @Description: todo(重写父类编辑函数)"; $edit .= "\r\n\t * @author " . $_SESSION['loginUserName']; $edit .= "\r\n\t * @date " . date('Y-m-d H:i:s'); $edit .= "\r\n\t * @throws "; $edit .= "\r\n\t*/"; $edit .= "\r\n\tfunction edit(\$isdisplay=1){"; $edit .= "\r\n\t\t\$mainTab = '{$this->tableName}';"; $edit .= "\r\n\t\t//获取当前控制器名称"; $edit .= "\r\n\t\t\$name=\$this->getActionName();"; $edit .= "\r\n\t\t\$model = D(\"{$this->nodeName}View\");"; $edit .= "\r\n\t\t//获取当前主键"; $edit .= "\r\n\t\t\$map[\$mainTab.'.id']=\$_REQUEST['id'];"; $edit .= "\r\n\t\t\$vo = \$model->where(\$map)->find();"; $edit .= "\r\n\t\tif(!\$vo){"; $edit .= "\r\n\t\t\$this->getFormIndexLoad(\$vo);"; $edit .= "\r\n\t\t}"; $edit .= "\r\n\t\tif(method_exists ( \$this, '_filter' )) {"; $edit .= "\r\n\t\t\t\$this->_filter ( \$map );"; $edit .= "\r\n\t\t}"; $edit .= "\r\n\t\t//读取动态配制"; $edit .= "\r\n\t\t\$this->getSystemConfigDetail(\$name);"; $edit .= "\r\n\t\t//扩展工具栏操作"; $edit .= "\r\n\t\t\$scdmodel = D('SystemConfigDetail');"; $edit .= "\r\n\t\t// 上一条数据ID"; $edit .= "\r\n\t\t\$map['id'] = array(\"lt\",\$id);"; $edit .= "\r\n\t\t\$updataid = \$model->where(\$map)->order('id desc')->getField('id');"; $edit .= "\r\n\t\t\$this->assign(\"updataid\",\$updataid);"; $edit .= "\r\n\t\t// 下一条数据ID"; $edit .= "\r\n\t\t\$map['id'] = array(\"gt\",\$id);"; $edit .= "\r\n\t\t\$downdataid = \$model->where(\$map)->getField('id');"; $edit .= "\r\n\t\t\$this->assign(\"downdataid\",\$downdataid);"; $edit .= "\r\n\t\t//lookup带参数查询"; $edit .= "\r\n\t\t\$module=A(\$name);"; $edit .= "\r\n\t\tif (method_exists(\$module,\"_after_edit\")) {"; $edit .= "\r\n\t\t\tcall_user_func(array(\$module,\"_after_edit\"),\$vo);"; $edit .= "\r\n\t\t}"; $edit .= "\r\n\t\t\$this->assign( 'vo', \$vo );"; $edit .= "\r\n\t\tif(\$isdisplay)"; $edit .= "\r\n\t\t\$this->display ();"; $edit .= "\r\n\t}"; ////////////////////////////////////////////////////////////////// /* * 不要重写父类中的edit函数 */ $edit = ''; ///////////////////////////////////////////////////////////////////// // 默认生成后置函数 $after_edit = ''; $after_list = ''; $after_insert = ''; $before_add = ''; $after_update = ''; // 删除子表数据 $delChildData = ''; $is_create_del_child = false; $is_create_opraete_child = false; $is_create_modify_child = false; $is_create_insert_child = false; //控制地址组件修改代码生成 $isArea = false; // 实例化MODE $model_code = ''; $is_include_model = false; $after_edit .= "\r\n\t/**"; $after_edit .= "\r\n\t * @Title: _after_edit"; $after_edit .= "\r\n\t * @Description: todo(后置编辑函数)"; $after_edit .= "\r\n\t * @author " . $_SESSION['loginUserName']; $after_edit .= "\r\n\t * @date " . date('Y-m-d H:i:s'); $after_edit .= "\r\n\t * @throws "; $after_edit .= "\r\n\t*/"; $after_edit .= "\r\n\tfunction _after_edit(\$vo){"; $after_list .= "\r\n\t/**"; $after_list .= "\r\n\t * @Title: _after_list"; $after_list .= "\r\n\t * @Description: todo(前置List)"; $after_list .= "\r\n\t * @author " . $_SESSION['loginUserName']; $after_list .= "\r\n\t * @date " . date('Y-m-d H:i:s'); $after_list .= "\r\n\t * @throws "; $after_list .= "\r\n\t*/"; $after_list .= "\r\n\tfunction _after_list(){"; $after_insert .= "\r\n\t/**"; $after_insert .= "\r\n\t * @Title: _after_insert"; $after_insert .= "\r\n\t * @Description: todo(后置insert函数) "; $after_insert .= "\r\n\t * @author " . $_SESSION['loginUserName']; $after_insert .= "\r\n\t * @date " . date('Y-m-d H:i:s'); $after_insert .= "\r\n\t * @throws"; $after_insert .= "\r\n\t*/"; $after_insert .= "\r\n\tfunction _after_insert(\$id){"; $before_add .= "\r\n\t/**"; $before_add .= "\r\n\t * @Title: _before_add"; $before_add .= "\r\n\t * @Description: todo(前置add函数) "; $before_add .= "\r\n\t * @author " . $_SESSION['loginUserName']; $before_add .= "\r\n\t * @date " . date('Y-m-d H:i:s'); $before_add .= "\r\n\t * @throws"; $before_add .= "\r\n\t*/"; $before_add .= "\r\n\tfunction _before_add(){"; $after_update .= "\r\n\t/**"; $after_update .= "\r\n\t * @Title: _after_update"; $after_update .= "\r\n\t * @Description: todo(后置update函数) "; $after_update .= "\r\n\t * @author " . $_SESSION['loginUserName']; $after_update .= "\r\n\t * @date " . date('Y-m-d H:i:s'); $after_update .= "\r\n\t * @throws"; $after_update .= "\r\n\t*/"; $after_update .= "\r\n\tfunction _after_update(){"; /** * 步骤: * 1。先源数据 $filedData['visibility'] 中的项按表名['tablename']分组。 * 2。区分出主从表,主表的文件名用当前action名命名,从表以直接表名命名。 * 3。遍历分组后的数据,依次生成Model文件。 * * 表数组,基础为二维. * 0=>主表信息 * 1=>所有从表的信息 */ /* 处理子表错误,子表不做数据添加 会导致修改 视图查询数据若用户只勾取部分表字段 引起的查询不出数据。 * 处理方式为:取出当前action的所有子表 都生成 添加与修改都 做处理 **/ $curTabData = $this->getDataBaseConf(); $curTabData = $curTabData['cur']; foreach ($curTabData['datebase'] as $key => $val) { if (!$val['isprimay']) { $after_update .= "\r\n\t\t//添加子表数据处理--" . $_SESSION['loginUserName'] . '@' . date('Y-m-d H:i:s'); $after_update .= "\r\n\t\t\${$key}Mode = D('" . createRealModelName($key) . "');"; $after_update .= "\r\n\t\t\${$key}Data = \${$key}Mode->create();"; $after_update .= "\r\n\t\tunset(\${$key}Data['id']);"; $after_update .= "\r\n\t\tif(\${$key}Data){"; $after_update .= "\r\n\t\t\tif(\${$key}Mode->where('masid='.\${$key}Data['masid'])->find())"; $after_update .= "\r\n\t\t\t\t\${$key}Mode->where('masid='.\${$key}Data['masid'])->save(\${$key}Data);"; $after_update .= "\r\n\t\t\telse"; $after_update .= "\r\n\t\t\t\t\${$key}Mode->add(\${$key}Data);"; $after_update .= "\r\n\t\t}"; $after_insert .= "\r\n\t\t// 添加子表数据处理----" . $_SESSION['loginUserName'] . '@' . date('Y-m-d H:i:s'); $after_insert .= "\r\n\t\t\${$key}Mode = D('" . createRealModelName($key) . "');"; $after_insert .= "\r\n\t\t\${$key}Data = \${$key}Mode->create();"; $after_insert .= "\r\n\t\tunset(\${$key}Data['id']);"; $after_insert .= "\r\n\t\tif(\${$key}Data){"; $after_insert .= "\r\n\t\t\t\t\${$key}Data['masid']=\$id;"; $after_insert .= "\r\n\t\t\t\t\${$key}Mode->add(\${$key}Data);"; $after_insert .= "\r\n\t\t}"; } } // 审批流 if ($isaudit) { } foreach ($fieldData['visibility'] as $k => $v) { $property = $this->getProperty($v['catalog']); // 时间组件的自动获取当前系统时间功能 if ($v[$property['catalog']['name']] == 'date') { // if ($v[$property['defaulttimechar']['name']] && stringToTime($v[$property['defaulttimechar']['name']])) { $before_add .= "\r\n\t\t\$vo['{$v[$property['fields']['name']]}']=stringToTime('{$v[$property['defaulttimechar']['name']]}');"; } else { if ($v[$property['acquiretime']['name']]) { $before_add .= "\r\n\t\t\$vo['{$v[$property['fields']['name']]}']=time();"; } if ($v[$property['editacquiretime']['name']]) { $after_edit .= "\r\n\t\t\$vo['{$v[$property['fields']['name']]}']=time();"; } } } if (($v[$property['catalog']['name']] == 'lookup' || $v[$property['catalog']['name']] == 'text') && $v[$property['defaultval']['name']]) { //Lookup默认值 $defaultval = str_replace(array('"', ''', '<', '>'), array('"', "'", '<', '>'), $v[$property['defaultval']['name']]); if ($defaultval == "user_txsj") { $before_add .= "\r\n\t\t\$txsj=M('User')->where('id='.\$_SESSION[C('USER_AUTH_KEY')])->getField('txsj');"; $before_add .= "\r\n\t\t\$vo['{$v[$property['fields']['name']]}']=\$txsj;"; } else { $before_add .= "\r\n\t\t\$vo['{$v[$property['fields']['name']]}']=\$_SESSION[{$defaultval}];"; } } // 文本框组件的默认显示数据功能 by nbmxkj@20150408 1642 if ($v[$property['catalog']['name']] == 'text') { // 对现有字段 subimporttableobj(数据来源表) subimporttablefieldobj(显示字段) subimporttablefield2obj(值字段) // 做功用重定义 数据来源表 显示字段 是否在修改页面时也启用功能 $conditions = $v[$property['conditions']['name']]; $table = $v[$property['subimporttableobj']['name']]; $showField = $v[$property['subimporttablefieldobj']['name']]; $isEditShow = $v[$property['subimporttablefield2obj']['name']]; // throw new NullCreateOprateException($isEditShow); // 附加条件 $textAppendCondtionConfigStr = $v[$property['additionalconditions']['name']]; if ($table && $showField) { $conditionsOperated = "'"; if ($conditions) { $conditionsOperated .= $conditions; } $textAppendCondtionConfigArr = appendConditionConfigResolve($textAppendCondtionConfigStr); if ($conditions && $textAppendCondtionConfigStr) { $configResilvedArr = getAppendCondition($vo, $textAppendCondtionConfigArr); $conditionsOperated .= " and '.parameReplace(\"'\",\"'\",getAppendConditionExceptEmpty(\$vo," . arr2string($textAppendCondtionConfigArr) . "))"; } else { if (!$conditions && $textAppendCondtionConfigStr) { $conditionsOperated .= "'.parameReplace(\"'\",\"'\",getAppendConditionExceptEmpty(\$vo," . arr2string($textAppendCondtionConfigArr) . "))"; } else { $conditionsOperated .= "'"; } } $before_add .= "\r\n\t\t\$vo['{$v[$property['fields']['name']]}']=getFieldData('{$showField}','{$table}' , {$conditionsOperated});"; // 修改页面自动生成控制 if ($isEditShow) { $after_edit .= "\r\n\t\t\$vo['{$v[$property['fields']['name']]}']=getFieldData('{$showField}','{$table}' ,{$conditionsOperated});"; } } } if ($v[$property['catalog']['name']] == 'upload') { //存在上传组件 $after_edit .= "\r\n\t\t\$this->getAttachedRecordList(\$vo['id']);"; } if ($v[$property['catalog']['name']] == 'datatable') { //存在datatable类型组件 // 删除子表数据 if (!$is_create_del_child) { $delChildData .= $this->getDataTableAction(); $is_create_del_child = true; } $after_edit .= $this->dataTableEditCode($v, $property); if (!$is_create_modify_child) { $after_update .= "\r\n\t\t// 内嵌表数据添加处理"; $after_update .= $this->updateDatatableCode(); $is_create_modify_child = true; } if (!$is_create_insert_child) { $after_insert .= $this->insertDatatableCode(); $is_create_insert_child = true; } } if ($v[$property['catalog']['name']] == 'areainfo' && $isArea == false) { //存在areainfo类型组件 $after_edit .= $this->getAreaInfoCode(); $isArea = true; } } /**************************************************************************************************************************************/ /* 左侧树代码的处理 20141114 1957 */ /**************************************************************************************************************************************/ $misdynamicform = M('mis_dynamic_form_manage'); $formData = $misdynamicform->where("`actionname`='{$this->nodeName}'")->find(); $temp = explode('#', $formData['tpl']); if ($temp[0] == 'noaudittpl' && $temp[1] == 'ltrl') { $before_index .= "\r\n\t\t//查询绑定数据源"; $before_index .= "\r\n\t\t\$this->getDateSoure();"; } /**************************************************************************************************************************************/ /* 左侧树代码的处理 end */ /**************************************************************************************************************************************/ $before_index .= "\r\n\t\t\$this->_extend_before_index();"; $before_index .= "\r\n\t}"; $before_edit .= "\r\n\t\tif(\$_REQUEST['main'])"; $before_edit .= "\r\n\t\t\t\$this->assign(\"main\",\$_REQUEST['main']);"; $before_edit .= "\r\n\t\t\$this->_extend_before_edit();"; $before_edit .= "\r\n\t}"; $before_insert .= "\r\n\t\t\$this->_extend_before_insert();"; $before_insert .= "\r\n\t}"; $before_update .= "\r\n\t\t\$this->_extend_before_update();"; $before_update .= "\r\n\t}"; $after_edit .= "\r\n\t\t\$this->_extend_after_edit(\$vo);"; $after_edit .= "\r\n\t}"; $after_list .= "\r\n\t\t\$this->_extend_after_list();"; $after_list .= "\r\n\t}"; $after_insert .= "\r\n\t\t\$this->_extend_after_insert(\$id);"; $after_insert .= "\r\n\t}"; $before_add .= "\r\n\t\tif(\$_REQUEST['main'])"; $before_add .= "\r\n\t\t\t\$this->assign(\"main\",\$_REQUEST['main']);"; $before_add .= "\r\n\t\t\$this->_extend_before_add(\$vo);"; $before_add .= "\r\n\t}"; $after_update .= "\r\n\t\t\$this->_extend_after_update();"; $after_update .= "\r\n\t}"; //$phpcode.=$before_edit.$before_insert.$before_update.$after_edit.$after_list.$after_insert.$after_add.$after_update; $phpcode .= $edit . $before_index . $before_edit . $before_insert . $before_update . $after_edit . $after_insert . $before_add . $after_update . $delChildData; $phpcode .= "\r\n}\r\n?>"; $extendphpcode .= "\r\n}\r\n?>"; if (!is_dir(dirname($actionPath))) { mk_dir(dirname($actionPath), 0777); } if (false === file_put_contents($actionPath, $phpcode)) { $this->error("Action文件生成失败!"); } if ($isinitExtendAction) { if (false === file_put_contents($actionExtendPath, $extendphpcode)) { $this->error("扩展Action文件生成失败!"); } } else { if (false == file_exists($actionExtendPath)) { if (false === file_put_contents($actionExtendPath, $extendphpcode)) { $this->error("扩展Action文件生成失败!"); } } else { // 扩展文件已存在时的内部代码指定位置替换修改。 // by nbmxkj@20150605 1711 // 获取现有代码内容 $actionExtendContent = file_get_contents($actionExtendPath); //var_dump($actionExtendContent); // 正则匹配关键字 $baseExtendClass = 'CommonAction'; if ($this->isaudit) { $baseExtendClass = 'CommonAuditAction'; } // 替换基类 $clearUpContent = preg_replace_callback('/(extends)(.*?)(\\{)+/s', function ($vo) use($baseExtendClass) { return $vo[1] . ' ' . $baseExtendClass . ' ' . $vo[3]; }, $actionExtendContent); //var_dump($clearUpContent); /* 替换其中的特殊代码问题 获取该文件的创建间 如果创建时间大于 2015-04-28 00:00:01 后的代码文件不进行特殊代码替换生成 */ // 创建时间 $createTime = filectime($actionExtendPath); // 目标比较时间 $orderTime = strtotime('2015-04-28 00:00:01'); if (false !== $createTime) { //&& $createTime < $orderTime ){ // 为 _extend_before_add(扩展前置添加函数) 增加参数,及内容代码调用处理 /* function _extend_before_add(){ $this->getFormIndexLoad(); } */ $extendBeforeAdd = '&$vo'; $clearUpContent = preg_replace_callback('/(_extend_before_add\\()(.*?)(\\))+/s', function ($vo) use($extendBeforeAdd) { return $vo[1] . $extendBeforeAdd . $vo[3]; }, $clearUpContent); $outerFuncParam = '$vo'; $clearUpContent = preg_replace_callback('/(getFormIndexLoad\\()(.*?)(\\))+/s', function ($vo) use($outerFuncParam) { return $vo[1] . $outerFuncParam . $vo[3]; }, $clearUpContent); } file_put_contents($actionExtendPath, $clearUpContent); } } //return $phpcode; }