date = $this->rock->date; $this->now = $this->rock->now; $this->option = m('option'); } public function initUser($uid) { $this->adminid = $uid; $this->urs = m('admin')->getone($uid, '`name`,`deptname`'); $this->adminname= $this->urs['name']; } public function initFields($stwhe='') { $fieldarr = m('flow_element')->getrows($stwhe,'*','`sort`'); foreach($fieldarr as $k=>$rs){ $this->fieldarr[$rs['fields']] = $rs; } return $fieldarr; } /** * 读取表单样式(有默认值的) */ public function getfieldcontval($fid, $val=false, $objs=null) { return $this->getfieldcont($fid, $objs,'',0, $val); } /** * 读取表单样式 */ public function getfieldcont($fid, $objs=null, $leox='', $iszb=0, $deval=false) { $fida= explode(',', $fid);$xu0='0'; $ism = $this->ismobile; $fid = $fida[0]; $str = $val =''; if(isset($fida[1]))$xu0=$fida[1]; if($fid=='base_name'){ $str = ''; } if($fid=='base_deptname'){ $str = ''; } if($fid=='base_sericnum'){ $str = ''; } if($fid=='file_content'){ $str = '
+添加文件
'; } if($fid=='删'){ $str=''; } if($fid=='新增'){ $str='+新增'; } if($str!='')return $str; if(!isset($this->fieldarr[$fid]))return ''; $isasm = 1; $a = $this->fieldarr[$fid]; $fname = $fid.$leox; $type = $a['fieldstype']; $placeholder = arrvalue($a, 'placeholder'); $isbt = arrvalue($a, 'isbt'); $zdsm = arrvalue($a, 'zdsm'); $data = $a['data']; $val = $a['dev']; if(isset($a['value']))$val=$a['value']; $attr = $a['attr']; $lens = (int)arrvalue($a, 'lens','0'); $styles = ''; $style = ''; if(contain($attr,',')){ $attra = explode(',', $a['attr']); $style = $attra[1]; $attr = $attra[0]; } if(!isempt($style))$styles=' style="'.$style.'"'; $fnams = $this->rock->arrvalue($a,'name');$fieldname = $fnams; if($isbt==1)$fnams='*'.$fnams.''; $val = $this->rock->get('def_'.$fname.'', $val); if(isempt($val))$val=''; if($deval !== false)$val = $deval; //设置默认值 if(isempt($attr))$attr=''; if($val!='' && contain($val,'{')){ $val = m('base')->strreplace($val, $this->adminid, 1); if($val=='{sericnum}' && $this->flow!=null)$val = $this->flow->createnum(); } if($type=='num'){ if($this->flow != null){ $val = $this->flow->createinputnum($data, $fid); } } //读默认值 if($objs != null && method_exists($objs, 'inputfieldsval')){ $_vals = $objs->inputfieldsval($fname, $a); if(!isempt($_vals))$val = $_vals; } if(!isempt($placeholder))$attr.=' placeholder="'.$placeholder.'"'; if($type=='email' || $type=='tel' || $type=='mobile' || $type=='url'){ $attr.=' inputtype="'.$type.'"'; } $lenstr = ''; if($lens>0)$lenstr=' maxlength="'.$lens.'"'; $onblue = ' onblur="c.inputblur(this, '.$iszb.')"'; $iszhang= false; if($type=='text' && !isempt($data)){ $attr.=' onclick="c.autocomplete(this,\''.$data.'\','.$a['id'].', '.$iszb.',event)"'; } $str = ''; if($type=='fixed'||$type=='hidden'){ $str = ''; $isasm=0; } if($type=='textarea'){ $iszhang= false; $str = ''; } if($type=='rockcombo' || $type=='select' || $type=='checkboxall' || $type=='radio'){ $attr.=' onchange="c.inputblur(this, '.$iszb.')"'; $str =''.$rs['name'].'  '; $str2.='  '; } if($type=='select' && $optgroup!='')$str.=''; $str.=''; if($type=='checkboxall')$str = $str1; if($type=='radio')$str = $str2; } if($type=='datetime'||$type=='date'||$type=='time'||$type=='month'){ $str = ''; } //数字类型 if($type=='number'){ $xiaoshu= arrvalue($a,'xiaoshu','0'); $str = ''; } if($type=='xuhao'){ $str = ''; $str.= ''; } if($type=='changeusercheck'||$type=='changeuser'||$type=='changedept'||$type=='changedeptcheck'||$type=='changedeptusercheck'){ $zbnae = $data; if($iszb>0)$zbnae = $data.''.($iszb-1).''.$leox.''; $str = $this->inputchangeuser(array( 'name' => $fname, 'id' => $zbnae, 'value' => $val, 'type' => $type, 'title' => $fieldname, 'changerange' => arrvalue($a, 'gongsi'), 'placeholder' => $placeholder, 'attr' => $onblue, 'style' => '', )); } if($type=='selectdatafalse' || $type=='selectdatatrue'){ $str = '
'; if($isbt=='0')$str .= ''; $str .= '
'; } if($type=='ditumap'){ $zbnae = $data; if($iszb>0)$zbnae = ''.($iszb-1).''.$leox.''; $str = '
'; if($isbt=='0')$str .= ''; if(contain($this->rock->HTTPweb, 'XINHUOAAPP'))$str .= ''; $str .= '
'; } if($type=='htmlediter'){ $iszhang= false; $str = ''; } if($type=='checkbox'){ $chk = ''; if($val=='1'||$val=='true')$chk='checked'; $str = ' '; } if($type=='uploadimg'){ $str1= '库中选 '; if(M=='login' || $this->adminid==0 || $a['attr']=='onlychange')$str1=''; $str = ''; $str.= ''; $str.= '
 '.$str1.'
'; } if($type=='uploadfile'){ $str = ''; $str.= '
'; $str.= ''; } if($type=='graph'){ $str = ''; $str.= '
'; $str.= '
'; } if($type=='auto'){ $datanum = $data; if(!isempt($datanum)){ if($objs!=null && method_exists($objs, $datanum)){ $str = $objs->$datanum($this->mid, $this->flow); } } } if(!isempt($zdsm))$str.='
'.$zdsm.''; if($iszb>0)return $str; if($isasm==1){ $lx = 'span';if($ism==1)$lx='div'; $str = '<'.$lx.' id="div_'.$fname.'" class="divinput">'.$str.''; if($ism==1 && $iszb==0){ if($iszhang){ $str = '
'.$fnams.'
'.$str.''; }else{ $str = ''.str_replace(' ','
', $fnams).''.$str.''; } } } return $str; } /** * 输出选择人员html */ public function inputchangeuser($arr=array()) { $oarr = array( 'name'=>'', 'id'=>'', 'type'=>'changeuser', 'value'=> '', 'valueid'=> '', 'title' => '', 'changerange' => '', 'placeholder' => '', 'attr' => '', ); foreach($arr as $k=>$v)$oarr[$k]=$v; $fname = $oarr['name']; $zbnae = $oarr['id']; $type = $oarr['type']; $valea = explode('|', $oarr['value']); $_vals0 = $valea[0]; $_vals1 = arrvalue($valea,1, $oarr['valueid']); $str = '
'; $str .= '
'; return $str; } private function issql($str) { $bo = false; $str = strtoupper($str); if(contain($str,' FROM '))$bo=true; return $bo; } public function getdatastore($type, $objs, $datanum, $fid='') { $fopt = array(); $tyepa = explode(',','rockcombo,select,checkboxall,radio'); if(!in_array($type, $tyepa) || isempt($datanum))return $fopt; //判断是不是SQL([SQL] name,value from [Q]abc) if($this->issql($datanum)){ $sql = str_replace('[SQL]','select ', $datanum); $sql = m('base')->strreplace($sql); $rows = $this->db->getall($sql); if($rows)foreach($rows as $k=>$rs){ $nam = arrvalue($rs,'name'); $val = $nam; if(isset($rs['id']))$val = $rs['id']; if(isset($rs['value']))$val = $rs['value']; $fopt[] = array( 'name' => $nam, 'value' => $val, ); } } //20250722从模块中读取做数据源 if(substr($datanum,0,5)=='rmod:'){ return $this->modestore($datanum); } //2021-02-26新增新的数据源,开头 if(substr($datanum,0,1)==','){ return $this->sqlstore($datanum); } //用:读取model上的数据 if(!$fopt && !isempt($datanum) && contain($datanum,':')){ $tata = explode(',', $datanum); $acta = explode(':', $tata[0]); $objs = m($acta[0]); $tacs = $acta[1]; $cshu1= arrvalue($tata, 1); if(method_exists($objs, $tacs)){ $fopt = $objs->$tacs($cshu1); if(is_array($fopt)){ return $fopt; } } } //自定义方法读取数据源 if(!$fopt && $objs!=null && method_exists($objs, $datanum)){ $fopt = $objs->$datanum($fid,$this->mid); if(is_array($fopt)){ return $fopt; } } //从flow上读取 if(!$fopt && $this->flow!=null && method_exists($this->flow, $datanum)){ $fopt = $this->flow->$datanum($fid,$this->mid); if(is_array($fopt)){ return $fopt; } } if(!$fopt && ($type=='rockcombo' || $type=='checkboxall' || $type=='radio')){ $_ars = explode(',', $datanum); $fopt = $this->option->getselectdata($_ars[0], isset($_ars[2])); $fvad = 'nameo'; if(isset($_ars[1])&&($_ars[1]=='value'||$_ars[1]=='id'||$_ars[1]=='num'))$fvad=$_ars[1]; if($fopt){ foreach($fopt as $k=>$rs){ $fopt[$k]['value'] = $rs[$fvad]; } if($type=='rockcombo' && $fvad=='name' && M=='input'){ //$fopt[] = array('name' => '其它..','value' => $_ars[0],); } } } if(!$fopt && ($type=='select' || $type=='checkboxall' || $type=='radio')){ $fopt = c('array')->strtoarray($datanum); $barr = array(); foreach($fopt as $k=>$rs){ $barr[] = array( 'name' => $rs[1], 'value' => $rs[0], 'color' => $rs[2] ); } $fopt = $barr; } return $fopt; } /** * 新的获取数据源方法 */ public function sqlstore($actstr1) { $rows = array(); $acta = explode(',', $actstr1); if(count($acta)>=3){ if($acta[1]){ $cats = explode(','.$acta[1].',', $actstr1); $sqlw = $cats[1]; }else{ $sqlw = substr($actstr1,2); } $sqla = explode('|', $sqlw); $wher = arrvalue($sqla,2,'1=1'); if(contain($wher,'{'))$wher = m('where')->getstrwhere($wher,$this->adminid); $wher = str_replace('$','"', $wher); $rowa = m($sqla[0])->getall($wher,$sqla[1]); $ndf = 'name'; $vdf = 'id'; if($rowa)foreach($rowa as $k=>$rs1){ if($k==0){ if(!isset($rs1[$ndf])){ foreach($rs1 as $k1=>$v1){$ndf = $k1;break;} } if(!isset($rs1[$vdf])){ $xus = 0; foreach($rs1 as $k1=>$v1){ $xus++; $vdf = $k1; if($xus>=2)break; } } } $rs1['name'] = $rs1[$ndf]; $rs1['value'] = $rs1[$vdf]; $rows[] = $rs1; } } return $rows; } /** * 模块数据 20250722添加 */ public function modestore($act) { $rows = array(); if(!$act)return $rows; $acta = explode(',',substr($act,5)); $cana = explode('|',$acta[0]); $flow = m('flow')->initflow($cana[0]); $rowd = $flow->getflowrows($this->adminid, $cana[1], -1); if($rowd)foreach($rowd as $k=>$rs){ $sname = ''; if(isset($cana[4]))$sname = $this->rock->reparr($cana[4], $rs); $rows[] = array( 'value' => $rs[$cana[3]], 'name' => $this->rock->reparr($cana[2], $rs), 'subname' => $sname ); } return $rows; } /** * 创建签名图片生成的 */ public function createqianming($_val) { if(isempt($_val))return ''; if(substr($_val,0,10)=='data:image'){ $_vlu = ''.UPDIR.'/'.date('Y-m').'/qmimg'.time().''.rand(10,99).'.png'; $bar= explode(',', $_val); $bo = $this->rock->createtxt($_vlu, base64_decode($bar[1])); if($bo)$_val = $_vlu; } return $_val; } }