|  | @@ -2031,7 +2031,9 @@ class Database
 | 
	
		
			
				|  |  |                                  $load = Dever::load($temp[0] . '/' . $temp[1] . '-one', array('option_' . $v['sync'][3] => $vi[$v['sync'][2]], 'option_' . $v['sync'][4] => $vi[$v['sync'][0]]));
 | 
	
		
			
				|  |  |                              }
 | 
	
		
			
				|  |  |                              
 | 
	
		
			
				|  |  | -                            $data[$ki][$k] = $vi[$k] = isset($load[$temp[2]]) ? $load[$temp[2]] : $v['default'];
 | 
	
		
			
				|  |  | +                            if (isset($temp[2])) {
 | 
	
		
			
				|  |  | +                                $data[$ki][$k] = $vi[$k] = isset($load[$temp[2]]) ? $load[$temp[2]] : $v['default'];
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  |                          }
 | 
	
		
			
				|  |  |                          if (true) {
 | 
	
		
			
				|  |  |                              $value = $vi[$k];
 | 
	
	
		
			
				|  | @@ -2320,7 +2322,10 @@ class Database
 | 
	
		
			
				|  |  |                          $load = Dever::load($temp[0] . '/' . $temp[1] . '-one', $lw);
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                      
 | 
	
		
			
				|  |  | -                    $data[$k][$ki] = $v[$ki] = isset($load[$temp[2]]) ? $load[$temp[2]] : $vi['default'];
 | 
	
		
			
				|  |  | +                    if (isset($temp[2])) {
 | 
	
		
			
				|  |  | +                        $data[$k][$ki] = $v[$ki] = isset($load[$temp[2]]) ? $load[$temp[2]] : $vi['default'];
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    
 | 
	
		
			
				|  |  |                  } elseif (strpos($k, 'dever_') !== false) {
 | 
	
		
			
				|  |  |                      continue;
 | 
	
		
			
				|  |  |                  } elseif (strpos($k, 'option_') !== false) {
 | 
	
	
		
			
				|  | @@ -2567,7 +2572,9 @@ class Database
 | 
	
		
			
				|  |  |                              $load = Dever::load($temp[0] . '/' . $temp[1] . '-one', $lw);
 | 
	
		
			
				|  |  |                          }
 | 
	
		
			
				|  |  |                          
 | 
	
		
			
				|  |  | -                        $data[$k][$ki] = $v[$ki] = isset($load[$temp[2]]) ? $load[$temp[2]] : $vi['default'];
 | 
	
		
			
				|  |  | +                        if (isset($temp[2])) {
 | 
	
		
			
				|  |  | +                            $data[$k][$ki] = $v[$ki] = isset($load[$temp[2]]) ? $load[$temp[2]] : $vi['default'];
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                      if (isset($vi['list']) && $vi['list']) {
 | 
	
	
		
			
				|  | @@ -3246,6 +3253,9 @@ class Database
 | 
	
		
			
				|  |  |              $upload_call = $this->value($config['manage']['upload'], $data);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          foreach ($config['struct'] as $k => $v) {
 | 
	
		
			
				|  |  | +            if (isset($config['manage']['lang']) && isset($v['sync']) && strpos($k, '-')) {
 | 
	
		
			
				|  |  | +                continue;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |              $state = false;
 | 
	
		
			
				|  |  |              if ($tab == 0) {
 | 
	
		
			
				|  |  |                  if (!isset($v['tab']) || (isset($v['tab']) && $v['tab'] == $tab)) {
 | 
	
	
		
			
				|  | @@ -3270,7 +3280,7 @@ class Database
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |                  $index = $k;
 | 
	
		
			
				|  |  | -                if ($prefix) {
 | 
	
		
			
				|  |  | +                if ($prefix && !strstr($k, '-')) {
 | 
	
		
			
				|  |  |                      $k = $prefix . '_' . $k;
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |                  # 处理show模式下的class
 | 
	
	
		
			
				|  | @@ -3286,7 +3296,7 @@ class Database
 | 
	
		
			
				|  |  |                      $result[$k] = '<div class="layui-form-item ' . $class . '" '.$style.'><div classs="layui-col-lg6">';
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                      if (is_array($v['update'])) {
 | 
	
		
			
				|  |  | -                        $result[$k] = '<div class="layui-form-item ' . $class . '" '.$style.'><div class="layui-tab-card">';
 | 
	
		
			
				|  |  | +                        $result[$k] = '<div class="layui-form-item ' . $class . '" '.$style.'><div class="layui-tab layui-tab-card">';
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -3294,7 +3304,7 @@ class Database
 | 
	
		
			
				|  |  |                      $v['upload_call'] = $upload_call . '&key=' . $k;
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                $result[$k] .= $this->create_update_html($k, $v, $data);
 | 
	
		
			
				|  |  | +                $result[$k] .= $this->create_update_html($k, $v, $data, false, $prefix);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  $result[$k] .= '</div></div>';
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -3399,7 +3409,7 @@ class Database
 | 
	
		
			
				|  |  |       *
 | 
	
		
			
				|  |  |       * @return string
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  | -    public function create_update_html($key, $value, $data = array(), $index = false)
 | 
	
		
			
				|  |  | +    public function create_update_html($key, $value, $data = array(), $index = false, $prefix = '')
 | 
	
		
			
				|  |  |      {
 | 
	
		
			
				|  |  |          $result = '';
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -3427,7 +3437,7 @@ class Database
 | 
	
		
			
				|  |  |          if (!$index) {
 | 
	
		
			
				|  |  |              $index = $key;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        $this->update_html($value, $key, $index, $data, $result);
 | 
	
		
			
				|  |  | +        $this->update_html($value, $key, $index, $data, $result, $prefix);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          return $result;
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -3437,13 +3447,14 @@ class Database
 | 
	
		
			
				|  |  |       *
 | 
	
		
			
				|  |  |       * @return string
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  | -    public function update_html($param, $key, $index, $data, &$result)
 | 
	
		
			
				|  |  | +    public function update_html($param, $key, $index, $data, &$result, $prefix = '')
 | 
	
		
			
				|  |  |      {
 | 
	
		
			
				|  |  |          if (isset($param['name']) && $param['update'] != 'hidden' && isset($param['update'])) {
 | 
	
		
			
				|  |  |              $result .= Html::pageLeft($param);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          if ($param['update']) {
 | 
	
		
			
				|  |  | +            $order = true;
 | 
	
		
			
				|  |  |              # 名称带前缀
 | 
	
		
			
				|  |  |              $param['name'] = 'update_' . $param['ext'];
 | 
	
		
			
				|  |  |              $param['index'] = $index;
 | 
	
	
		
			
				|  | @@ -3484,15 +3495,38 @@ class Database
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              # 处理同步
 | 
	
		
			
				|  |  | -            if (isset($param['sync']) && isset($data[$param['sync'][0]]) && strpos($key, '-')) {
 | 
	
		
			
				|  |  | +            if (isset($param['sync']) && strpos($key, '-')) {
 | 
	
		
			
				|  |  |                  $temp = explode('-', $key);
 | 
	
		
			
				|  |  | -                if ($data[$param['sync'][0]] > 0) {
 | 
	
		
			
				|  |  | -                    $load = Dever::load($temp[0] . '/' . $temp[1] . '-one', array('option_' . $param['sync'][1] => $data[$param['sync'][0]]));
 | 
	
		
			
				|  |  | -                } else {
 | 
	
		
			
				|  |  | -                    $load = Dever::load($temp[0] . '/' . $temp[1] . '-one', array('option_' . $param['sync'][3] => $data[$param['sync'][2]], 'option_' . $param['sync'][4] => $data[$param['sync'][0]]));
 | 
	
		
			
				|  |  | +                if (isset($data[$param['sync'][0]])) {
 | 
	
		
			
				|  |  | +                    if (isset($temp[2])) {
 | 
	
		
			
				|  |  | +                        $m = 'one';
 | 
	
		
			
				|  |  | +                    } else {
 | 
	
		
			
				|  |  | +                        $m = 'select';
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    if ($data[$param['sync'][0]] > 0) {
 | 
	
		
			
				|  |  | +                        $load = Dever::load($temp[0] . '/' . $temp[1] . '-' . $m, array('option_' . $param['sync'][1] => $data[$param['sync'][0]], 'order' => array('id' => 'asc')));
 | 
	
		
			
				|  |  | +                    } else {
 | 
	
		
			
				|  |  | +                        $load = Dever::load($temp[0] . '/' . $temp[1] . '-' . $m, array('option_' . $param['sync'][3] => $data[$param['sync'][2]], 'option_' . $param['sync'][4] => $data[$param['sync'][0]], 'order' => array('id' => 'asc')));
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    if ($m == 'one') {
 | 
	
		
			
				|  |  | +                        $param['value'] = isset($load[$temp[2]]) ? $load[$temp[2]] : $param['default'];
 | 
	
		
			
				|  |  | +                    } else {
 | 
	
		
			
				|  |  | +                        $param['value'] = $load;
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                if (!isset($temp[2])) {
 | 
	
		
			
				|  |  | +                    $order = false;
 | 
	
		
			
				|  |  | +                    $config = Dever::db($temp[0] . '/' . $temp[1])->config;
 | 
	
		
			
				|  |  | +                    $param['update'] = $config['struct'];
 | 
	
		
			
				|  |  | +                    if (isset($config['manage']['tab'])) {
 | 
	
		
			
				|  |  | +                        $param['prefix'] = $prefix;
 | 
	
		
			
				|  |  | +                        $param['tab'] = $config['manage']['tab'];
 | 
	
		
			
				|  |  | +                        if (isset($config['manage']['tab'])) {
 | 
	
		
			
				|  |  | +                            $param['lang'] = $config['manage']['lang'];
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    //$param['value'] = Dever::db($temp[0] . '/' . $temp[1]);
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                $param['value'] = isset($load[$temp[2]]) ? $load[$temp[2]] : $param['default'];
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              $method = $param['update'];
 | 
	
	
		
			
				|  | @@ -3506,7 +3540,7 @@ class Database
 | 
	
		
			
				|  |  |                  $delete = true;
 | 
	
		
			
				|  |  |                  if (isset($param['option'])) {
 | 
	
		
			
				|  |  |                      $delete = false;
 | 
	
		
			
				|  |  | -                    $result .= '<ul class="nav nav-tabs '.$c.'">{tab}</ul>';
 | 
	
		
			
				|  |  | +                    $result .= '<ul class="nav nav-tabs '.$c.'" style="height:100%;">{tab}</ul>';
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                      $order = array
 | 
	
		
			
				|  |  |                      (
 | 
	
	
		
			
				|  | @@ -3536,23 +3570,25 @@ class Database
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  } else {
 | 
	
		
			
				|  |  | -                    $result .= '<ul class="nav nav-tabs '.$c.'">{tab}<li><a href="javascript:;" class="dever_form_add" toggle_key="' . $key . '">增加一条</a></li></ul>';
 | 
	
		
			
				|  |  | +                    $result .= '<ul class="nav nav-tabs '.$c.'" style="height:100%;">{tab}<li style="margin:0px;padding:0 15px;"><a href="javascript:;" class="dever_form_add" toggle_key="' . $key . '">增加一条</a></li></ul>';
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                    $order = array
 | 
	
		
			
				|  |  | -                    (
 | 
	
		
			
				|  |  | -                        'col'       => 'order',
 | 
	
		
			
				|  |  | -                        'name'      => '排序-按照数字正序排列',
 | 
	
		
			
				|  |  | -                        'default'   => '1',
 | 
	
		
			
				|  |  | -                        'desc'      => '排序',
 | 
	
		
			
				|  |  | -                        'match'     => 'is_string',
 | 
	
		
			
				|  |  | -                        'update'    => 'text',
 | 
	
		
			
				|  |  | -                    );
 | 
	
		
			
				|  |  | -                    array_unshift($method, $order);
 | 
	
		
			
				|  |  | +                    if ($order) {
 | 
	
		
			
				|  |  | +                        $order = array
 | 
	
		
			
				|  |  | +                        (
 | 
	
		
			
				|  |  | +                            'col'       => 'order',
 | 
	
		
			
				|  |  | +                            'name'      => '排序-按照数字正序排列',
 | 
	
		
			
				|  |  | +                            'default'   => '1',
 | 
	
		
			
				|  |  | +                            'desc'      => '排序',
 | 
	
		
			
				|  |  | +                            'match'     => 'is_string',
 | 
	
		
			
				|  |  | +                            'update'    => 'text',
 | 
	
		
			
				|  |  | +                        );
 | 
	
		
			
				|  |  | +                        array_unshift($method, $order);
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  $tab = '';
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                $this->update_child(array(), $method, $key, $result, -1, $delete);
 | 
	
		
			
				|  |  | +                $this->update_child(array(), $method, $key, $result, -1, $param, $delete);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  if (isset($param['value']) && $param['value']) {
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -3567,7 +3603,7 @@ class Database
 | 
	
		
			
				|  |  |                              if (is_string($k)) {
 | 
	
		
			
				|  |  |                                  $k = $i;
 | 
	
		
			
				|  |  |                              }
 | 
	
		
			
				|  |  | -                            $this->update_child($v, $method, $key, $result, $k, $delete);
 | 
	
		
			
				|  |  | +                            $this->update_child($v, $method, $key, $result, $k, $param, $delete);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                              $active = '';
 | 
	
		
			
				|  |  |                              if ($k == 0) {
 | 
	
	
		
			
				|  | @@ -3580,15 +3616,15 @@ class Database
 | 
	
		
			
				|  |  |                              if (!is_string($n)) {
 | 
	
		
			
				|  |  |                                  $n = '第' . $k . '条';
 | 
	
		
			
				|  |  |                              }
 | 
	
		
			
				|  |  | -                            $tab .= '<li class="' . $active . '"><a href="javascript:;" id="tab-' . $key . '-child-' . $k . '" toggle_key="' . $key . '" toggle_id="' . $k . '" toggle_child=".dever_' . $key . '_child" toggle="#' . $key . '-child-' . $k . '" onclick="showToggle($(this))">'.$n.'</a></li>';
 | 
	
		
			
				|  |  | +                            $tab .= '<li class="' . $active . '" style="margin:0px;padding:0 15px;"><a href="javascript:;" id="tab-' . $key . '-child-' . $k . '" toggle_key="' . $key . '" toggle_id="' . $k . '" toggle_child=".dever_' . $key . '_child" toggle="#' . $key . '-child-' . $k . '" onclick="showToggle($(this))">'.$n.'</a></li>';
 | 
	
		
			
				|  |  |                              $i++;
 | 
	
		
			
				|  |  |                          }
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                      
 | 
	
		
			
				|  |  |                  } else {
 | 
	
		
			
				|  |  | -                    $this->update_child(array(), $method, $key, $result, 0, $delete);
 | 
	
		
			
				|  |  | +                    $this->update_child(array(), $method, $key, $result, 0, $param, $delete);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                    $tab = '<li class="active layui-this"><a href="javascript:;" id="tab-' . $key . '-child-1" toggle_key="' . $key . '" toggle_id="1" toggle_child=".dever_' . $param['col'] . '_child" toggle="#' . $key . '-child-1" onclick="showToggle($(this))">第1条</a></li>';
 | 
	
		
			
				|  |  | +                    $tab = '<li class="active layui-this" style="margin:0px;padding:0 15px;"><a href="javascript:;" id="tab-' . $key . '-child-1" toggle_key="' . $key . '" toggle_id="1" toggle_child=".dever_' . $param['col'] . '_child" toggle="#' . $key . '-child-1" onclick="showToggle($(this))">第1条</a></li>';
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  $result = str_replace('{tab}', $tab, $result);
 | 
	
	
		
			
				|  | @@ -3619,45 +3655,109 @@ class Database
 | 
	
		
			
				|  |  |       *
 | 
	
		
			
				|  |  |       * @return array
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  | -    private function update_child($data, $param, $key, &$result, $index, $delete = true)
 | 
	
		
			
				|  |  | +    private function update_child($data, $param, $key, &$result, $index, $config, $delete = true)
 | 
	
		
			
				|  |  |      {
 | 
	
		
			
				|  |  | -        $style = 'style="margin:10px"';
 | 
	
		
			
				|  |  | -        if ($index != 0) {
 | 
	
		
			
				|  |  | -            $style = 'style="display:none;margin:10px"';
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        $result .= '<div id="' . $key . '-child-' . ($index + 1) . '" class="dever_' . $key . '_child dever_form_add_child" ' . $style . '>';
 | 
	
		
			
				|  |  | +        if (isset($config['tab']) && $config['tab']) {
 | 
	
		
			
				|  |  | +            if ($index != 0) {
 | 
	
		
			
				|  |  | +                $style = 'display:none;';
 | 
	
		
			
				|  |  | +            } else {
 | 
	
		
			
				|  |  | +                $style = '';
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            $result .= '<div class="layui-tab layui-tab-brief dever_' . $key . '_child dever_form_add_child" lay-filter="component-tabs-brief" style="'.$style.'" id="' . $key . '-child-' . ($index + 1) . '"><ul class="layui-tab-title">';
 | 
	
		
			
				|  |  | +            $tab = '<div class="layui-tab-content">';
 | 
	
		
			
				|  |  | +            $i = 0;
 | 
	
		
			
				|  |  | +            foreach ($config['tab'] as $k => $v) {
 | 
	
		
			
				|  |  | +                $content = $this->update_child_data($data, $param, $key, $index, $k, $config);
 | 
	
		
			
				|  |  | +                if ($content) {
 | 
	
		
			
				|  |  | +                    $class_0 = $class_1 = '';
 | 
	
		
			
				|  |  | +                    if ($i == 0) {
 | 
	
		
			
				|  |  | +                        $class_0 = 'layui-this';
 | 
	
		
			
				|  |  | +                        $class_1 = 'layui-show';
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    $result .= '<li class="'.$class_0.'">'.$v.'</li>';
 | 
	
		
			
				|  |  | +                    $tab .= '<div class="layui-tab-item '.$class_1.'">'.$content.'</div>';
 | 
	
		
			
				|  |  | +                    $i++;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            $tab .= '</div>';
 | 
	
		
			
				|  |  | +            $result .= '</ul>' . $tab . '</div>';
 | 
	
		
			
				|  |  | +        } else {
 | 
	
		
			
				|  |  | +            $style = 'margin:10px;';
 | 
	
		
			
				|  |  | +            if ($index != 0) {
 | 
	
		
			
				|  |  | +                $style = 'display:none;margin:10px;';
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            $result .= '<div id="' . $key . '-child-' . ($index + 1) . '" class="dever_' . $key . '_child dever_form_add_child" style="' . $style . '">';
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        if ($delete) {
 | 
	
		
			
				|  |  | -            $result .= '<div class="dever_form_delete">[删除]</div>';
 | 
	
		
			
				|  |  | +            if ($delete) {
 | 
	
		
			
				|  |  | +                $result .= '<div class="dever_form_delete" style="cursor:pointer">[删除]</div>';
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            $result .= $content = $this->update_child_data($data, $param, $key, $index, -1, $config);
 | 
	
		
			
				|  |  | +            $result .= '</div>';
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    private function update_child_data($data, $param, $key, $index, $tab = -1, $config = array())
 | 
	
		
			
				|  |  | +    {
 | 
	
		
			
				|  |  | +        $result = '';
 | 
	
		
			
				|  |  |          foreach ($param as $k => $v) {
 | 
	
		
			
				|  |  | -            $v['type'] = $v['update'];
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            $prefix = '';
 | 
	
		
			
				|  |  | -            if ($index < 0) {
 | 
	
		
			
				|  |  | -                $v['ext'] = $key . '_c_' . $v['col'];
 | 
	
		
			
				|  |  | -                $prefix = $v['ext'];
 | 
	
		
			
				|  |  | -            } else {
 | 
	
		
			
				|  |  | -                $v['ext'] = $key . '_c_' . $index . '_i_' . $v['col'];
 | 
	
		
			
				|  |  | -                $prefix = $v['ext'];
 | 
	
		
			
				|  |  | +            if (is_string($k)) {
 | 
	
		
			
				|  |  | +                $v['col'] = $k;
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -            if ($v['col'] == 'order') {
 | 
	
		
			
				|  |  | -                $v['default'] = $index+1;
 | 
	
		
			
				|  |  | +            if ($this->id && $v['col'] == 'id') {
 | 
	
		
			
				|  |  | +                $v['update'] = 'hidden';
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if (!isset($v['update'])) {
 | 
	
		
			
				|  |  | +                continue;
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |              
 | 
	
		
			
				|  |  | -            $class = $this->update_class($v['col'], $v, $prefix);
 | 
	
		
			
				|  |  | +            if (isset($config['prefix']) && $config['prefix']) {
 | 
	
		
			
				|  |  | +                if (isset($config['lang']) && $config['lang'] && !in_array($v['col'], $config['lang'])) {
 | 
	
		
			
				|  |  | +                    continue;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                $v['col'] = $config['prefix'] . '_' . $v['col'];
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            $state = false;
 | 
	
		
			
				|  |  | +            if ($tab == 0) {
 | 
	
		
			
				|  |  | +                if (!isset($v['tab']) || (isset($v['tab']) && $v['tab'] == $tab)) {
 | 
	
		
			
				|  |  | +                    $state = true;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            } elseif ($tab > 0) {
 | 
	
		
			
				|  |  | +                if (isset($v['tab']) && $v['tab'] == $tab) {
 | 
	
		
			
				|  |  | +                    $state = true;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            } else {
 | 
	
		
			
				|  |  | +                $state = true;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if (isset($v['update']) && $v['update'] && $state) {
 | 
	
		
			
				|  |  | +                
 | 
	
		
			
				|  |  | +                $v['type'] = $v['update'];
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            $result .= '<div class="form-group ' . $class . '" style="margin-top:10px">';
 | 
	
		
			
				|  |  | +                $prefix = '';
 | 
	
		
			
				|  |  | +                if ($index < 0) {
 | 
	
		
			
				|  |  | +                    $v['ext'] = $key . '_c_' . $v['col'];
 | 
	
		
			
				|  |  | +                    $prefix = $v['ext'];
 | 
	
		
			
				|  |  | +                } else {
 | 
	
		
			
				|  |  | +                    $v['ext'] = $key . '_c_' . $index . '_i_' . $v['col'];
 | 
	
		
			
				|  |  | +                    $prefix = $v['ext'];
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            $this->update_html($v, $key, $v['col'], $data, $result);
 | 
	
		
			
				|  |  | +                if ($v['col'] == 'order') {
 | 
	
		
			
				|  |  | +                    $v['default'] = $index+1;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                $class = $this->update_class($v['col'], $v, $prefix);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            $result .= '</div>';
 | 
	
		
			
				|  |  | +                if ($v['update'] == 'hidden') {
 | 
	
		
			
				|  |  | +                    $result .= '<div class="form-group ' . $class . '">';
 | 
	
		
			
				|  |  | +                    $this->update_html($v, $key, $v['col'], $data, $result);
 | 
	
		
			
				|  |  | +                    $result .= '</div>';
 | 
	
		
			
				|  |  | +                } else {
 | 
	
		
			
				|  |  | +                    $result .= '<div class="form-group ' . $class . '" style="margin-top:10px">';
 | 
	
		
			
				|  |  | +                    $this->update_html($v, $key, $v['col'], $data, $result);
 | 
	
		
			
				|  |  | +                    $result .= '</div>';
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        $result .= '</div>';
 | 
	
		
			
				|  |  | +        return $result;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
	
		
			
				|  | @@ -3752,7 +3852,8 @@ class Database
 | 
	
		
			
				|  |  |                          $v = '';
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                      $temp = explode('_c_', $k);
 | 
	
		
			
				|  |  | -                    $k = str_replace('update_', $prefix . '_', $temp[0]);
 | 
	
		
			
				|  |  | +                    $h = $temp[0];
 | 
	
		
			
				|  |  | +                    $k = str_replace('update_', $prefix . '_', $h);
 | 
	
		
			
				|  |  |                      if (!isset($c[$k])) {
 | 
	
		
			
				|  |  |                          $c[$k] = array();
 | 
	
		
			
				|  |  |                      }
 | 
	
	
		
			
				|  | @@ -3767,9 +3868,34 @@ class Database
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                          $num = $c[$k][$temp[1]];
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                        $update[$i][$k][$num][$temp[1]] = $v;
 | 
	
		
			
				|  |  | -                        if ($temp[1] == 'order') {
 | 
	
		
			
				|  |  | -                            $order[$i][$k][$num] = $v;
 | 
	
		
			
				|  |  | +                        if (strpos($h, '-')) {
 | 
	
		
			
				|  |  | +                            $h = str_replace('update_', '', $h);
 | 
	
		
			
				|  |  | +                            if (isset($config['struct'][$h]) && isset($config['struct'][$h]['sync'])) {
 | 
	
		
			
				|  |  | +                                $s_col = $config['struct'][$h]['sync'][0];
 | 
	
		
			
				|  |  | +                                $m_col = $config['struct'][$h]['sync'][1];
 | 
	
		
			
				|  |  | +                                if ($s_col == 'id') {
 | 
	
		
			
				|  |  | +                                    $s_value = $this->id;
 | 
	
		
			
				|  |  | +                                } else {
 | 
	
		
			
				|  |  | +                                    $s_one = $this->load('one', $this->id);
 | 
	
		
			
				|  |  | +                                    $s_value = $s_one[$s_col];
 | 
	
		
			
				|  |  | +                                }
 | 
	
		
			
				|  |  | +                                $t = explode('-', $h);
 | 
	
		
			
				|  |  | +                                $index = $t[0] . '/' . $t[1];
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                                $update_col[$i][$index] = $m_col;
 | 
	
		
			
				|  |  | +                                $update_set[$i][$index][$num][$temp[1]] = $v;
 | 
	
		
			
				|  |  | +                                $update_add[$i][$index][$num][$temp[1]] = $v;
 | 
	
		
			
				|  |  | +                                $update_add[$i][$index][$num][$m_col] = $s_value;
 | 
	
		
			
				|  |  | +                                $update_id[$i][$index][$num][$m_col] = $s_value;
 | 
	
		
			
				|  |  | +                                if ($this->id && $temp[1] == 'id') {
 | 
	
		
			
				|  |  | +                                    $update_id[$i][$index][$num]['id'] = $v;
 | 
	
		
			
				|  |  | +                                }
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  | +                        } else {
 | 
	
		
			
				|  |  | +                            $update[$i][$k][$num][$temp[1]] = $v;
 | 
	
		
			
				|  |  | +                            if ($temp[1] == 'order') {
 | 
	
		
			
				|  |  | +                                $order[$i][$k][$num] = $v;
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  |                          }
 | 
	
		
			
				|  |  |                      } else {
 | 
	
		
			
				|  |  |                          //$update[$i][$k][$c][$temp[1]] = $v;
 | 
	
	
		
			
				|  | @@ -3810,13 +3936,16 @@ class Database
 | 
	
		
			
				|  |  |                                  $temp = explode('-', $k);
 | 
	
		
			
				|  |  |                                  $index = $temp[0] . '/' . $temp[1];
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                                $update_set[$index]['set_' . $temp[2]] = $v;
 | 
	
		
			
				|  |  | -                                //$update_set[$index]['set_' . $m_col] = $s_value;
 | 
	
		
			
				|  |  | +                                if (isset($temp[2])) {
 | 
	
		
			
				|  |  | +                                    $update_col[$i][$index] = $m_col;
 | 
	
		
			
				|  |  | +                                    $update_set[$i][$index][0][$temp[2]] = $v;
 | 
	
		
			
				|  |  | +                                    //$update_set[$i][$index][0][$m_col] = $s_value;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                                $update_add[$index]['add_' . $temp[2]] = $v;
 | 
	
		
			
				|  |  | -                                $update_add[$index]['add_' . $m_col] = $s_value;
 | 
	
		
			
				|  |  | +                                    $update_add[$i][$index][0][$temp[2]] = $v;
 | 
	
		
			
				|  |  | +                                    $update_add[$i][$index][0][$m_col] = $s_value;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                                $update_id[$index]['option_' . $m_col] = $s_value;
 | 
	
		
			
				|  |  | +                                    $update_id[$i][$index][0][$m_col] = $s_value;
 | 
	
		
			
				|  |  | +                                }
 | 
	
		
			
				|  |  |                              }
 | 
	
		
			
				|  |  |                          } else {
 | 
	
		
			
				|  |  |                              if (is_array($v)) {
 | 
	
	
		
			
				|  | @@ -3845,7 +3974,9 @@ class Database
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +            //print_r($update_set);
 | 
	
		
			
				|  |  | +            //print_r($update_id);
 | 
	
		
			
				|  |  | +            //print_r($update_add);
 | 
	
		
			
				|  |  |              //print_r($update_set);die;
 | 
	
		
			
				|  |  |              //print_r($input);
 | 
	
		
			
				|  |  |              //print_r($update_other);
 | 
	
	
		
			
				|  | @@ -3892,17 +4023,29 @@ class Database
 | 
	
		
			
				|  |  |                              $this->load($method, $v1, $this->table . '__' . $k1);
 | 
	
		
			
				|  |  |                          }
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                if (isset($update_id) && $update_id) {
 | 
	
		
			
				|  |  | -                    foreach ($update_set as $k => $v) {
 | 
	
		
			
				|  |  | -                        $check = Dever::load($k . '-one', $update_id[$k]);
 | 
	
		
			
				|  |  | -                        //print_r($check);die;
 | 
	
		
			
				|  |  | -                        if ($check) {
 | 
	
		
			
				|  |  | -                            $v['where_id'] = $check['id'];
 | 
	
		
			
				|  |  | -                            Dever::load($k . '-update', $v);
 | 
	
		
			
				|  |  | -                        } else {
 | 
	
		
			
				|  |  | -                            Dever::load($k . '-insert', $update_add[$k]);
 | 
	
		
			
				|  |  | +                    if (isset($update_id[$k]) && $update_id[$k]) {
 | 
	
		
			
				|  |  | +                        foreach ($update_set[$k] as $k1 => $v1) {
 | 
	
		
			
				|  |  | +                            $col = $update_col[$k][$k1];
 | 
	
		
			
				|  |  | +                            foreach ($v1 as $k2 => $v2) {
 | 
	
		
			
				|  |  | +                                if (isset($update_id[$k][$k1][$k2][$col])) {
 | 
	
		
			
				|  |  | +                                    $update_id[$k][$k1][$k2][$col] = $id;
 | 
	
		
			
				|  |  | +                                }
 | 
	
		
			
				|  |  | +                                if (isset($update_add[$k][$k1][$k2][$col])) {
 | 
	
		
			
				|  |  | +                                    $update_add[$k][$k1][$k2][$col] = $id;
 | 
	
		
			
				|  |  | +                                }
 | 
	
		
			
				|  |  | +                                if (isset($v2[$col])) {
 | 
	
		
			
				|  |  | +                                    $v2[$col] = $id;
 | 
	
		
			
				|  |  | +                                }
 | 
	
		
			
				|  |  | +                                $check = Dever::load($k1 . '-one', $update_id[$k][$k1][$k2]);
 | 
	
		
			
				|  |  | +                                if ($check) {
 | 
	
		
			
				|  |  | +                                    unset($v2['id']);
 | 
	
		
			
				|  |  | +                                    $v2['where_id'] = $check['id'];
 | 
	
		
			
				|  |  | +                                    Dever::load($k1 . '-update', $v2);
 | 
	
		
			
				|  |  | +                                } else {
 | 
	
		
			
				|  |  | +                                    Dever::load($k1 . '-insert', $update_add[$k][$k1][$k2]);
 | 
	
		
			
				|  |  | +                                }
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  |                          }
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                  }
 |