Example #1
0
 public function bootstrap()
 {
     $data = array();
     foreach ($this->bootstrapConfigs as $k => $v) {
         if (in_array($k, $this->supportResponseBaseConfigKeys)) {
             $data[$k] = $v;
         }
     }
     // 已启用应用
     $data['loaded_apps'] = array_merge(AppService::$activeApps, AppService::$baseApps);
     // 已授权节点
     $data['authed_nodes'] = get_array_to_kv(AuthorizeService::$authed_nodes, "flag", "node");
     // 用户信息
     $data['all_users'] = UserService::get_all_basic_data();
     // 当前用户信息
     $data['user_info'] = D('Account/User')->get_current_user();
     // 系统首选项
     $system_preference = D('Home/Config', 'Service')->get_kv_config();
     foreach ($system_preference as $k => $v) {
         $system_preference[$k] = Schema::data_field_format($v['val'], $v['data_type']);
     }
     $data['system_preference'] = $system_preference;
     // 个人首选项
     $user_preference = D('Account/UserPreference', 'Service')->get_preference();
     foreach ($user_preference as $k => $v) {
         $user_preference[$k] = Schema::data_field_format($v['data'], $v['data_type']);
     }
     $data['user_preference'] = $user_preference;
     // 主页面包含
     $data['main_include'] = D('Home/Config', 'Service')->get_main_include();
     tag('before_bootstrap_config_response', $data);
     $this->response($data);
 }
Example #2
0
 public function on_read()
 {
     $model = D('Home/Config', 'Service');
     $configs = $model->get_kv_config();
     foreach ($configs as $k => $v) {
         $configs[$k] = Schema::data_field_format($v['val'], $v['data_type']);
     }
     $this->response($configs);
 }
 public function on_read()
 {
     $model = D('Account/UserPreference', 'Service');
     $configs = $model->get_preference();
     foreach ($configs as $k => $v) {
         $configs[$k] = Schema::data_field_format($v['data'], $v['data_type']);
     }
     $this->response($configs);
 }
Example #4
0
 public static function getSchemaByApp($app)
 {
     $cache_key = "schema/" . $app;
     $schemas = (array) S($cache_key);
     if (DEBUG || !$schemas) {
         $path = sprintf("%s%s/Schema", APP_PATH, ucfirst($app));
         foreach (new RecursiveFileFilterIterator($path, null, "yml") as $item) {
             $schemas = array_merge($schemas, (array) parse_yml($item));
         }
         // 需返回的数据表
         $tables = I("get.table") ? explode(".", I("get.table")) : array_keys($schemas);
         $schemas = Schema::parse($app, $schemas, $tables);
         S($cache_key, $schemas);
     }
     return $schemas;
 }
Example #5
0
 public function get_full_data($id)
 {
     if (!$this->check_params()) {
         $this->error = __('common.System Error');
         return false;
     }
     $meta = D($this->main_model, 'Model')->where(['id' => $id])->find();
     if (!$meta) {
         // @todo error_message
         return false;
     }
     if ($this->is_locked($meta['status'])) {
         $meta['locked'] = true;
     }
     $meta = Schema::data_format($meta, $this->main_table, true);
     $detail_model = D($this->detail_model, 'Model');
     $rows = $detail_model->where([$this->detail_main_foreign => $id])->select();
     // 本次出入库数量
     if ($this->include_this_time_quantity && $this->balance_direction) {
         foreach ($rows as $k => $v) {
             $this_time_quantity_field = sprintf('this_time_%s_quantity', $this->balance_direction);
             $rows[$k][$this_time_quantity_field] = round($v['quantity'] - $v['already_' . $this->balance_direction], DBC('decimal_scale'));
         }
     }
     $rows = Schema::data_format($rows, $this->detail_table, true);
     // 工作流进程
     $progress_service = D('Bpm/WorkflowProgress');
     $meta['workflow_progress'] = $progress_service->get_progress($meta['workflow_id'], $meta['id']);
     // 产品属性
     if (AppService::is_app_active('productAttribute')) {
         $rows = D('ProductAttribute/ProductAttribute')->assign_to_by_product_unique($rows, $this->detail_model_alias);
     }
     return ['meta' => $meta, 'rows' => $rows];
 }
Example #6
0
 public function get_workflow($workflow_id = null, $module = null)
 {
     if (!$module && !$workflow_id) {
         return false;
     }
     $map = [];
     if ($module) {
         $map['module'] = $module;
     }
     if ($workflow_id) {
         $map['id'] = $workflow_id;
     } else {
         $map['is_default'] = 1;
     }
     $workflow = $this->where($map)->find();
     if (!$workflow && $module) {
         $workflow = $this->where(['module' => $module])->find();
     }
     if (!$workflow) {
         $this->error = __('bpm.Can not find workflow');
         return false;
     }
     $workflow = Schema::data_format($workflow, 'workflow', true);
     $nodes = $this->get_nodes($workflow['id']);
     foreach ($nodes as $k => $node) {
         if ($node['node_type'] === 'start') {
             $workflow['start_node'] = $node;
         }
         //            $serialized_config = unserialize($node['widget_config']);
         //            $serialized_config = $serialized_config ? $serialized_config : [];
         //            $nodes[$k] = array_merge($node, $serialized_config);
     }
     $nodes = Schema::data_format($nodes, 'workflow_node', true);
     $workflow['nodes'] = $nodes;
     return $workflow;
 }
Example #7
0
 protected function response($data, $model = null, $is_table = false)
 {
     /*
      * 格式化数据
      * **/
     if ($model) {
         $data = Schema::data_format($data, $model, $is_table);
     }
     return parent::response($data, 'json');
 }
Example #8
0
 public function get_full_data($id)
 {
     if (!$this->check_params()) {
         $this->error = __('common.System Error');
         return false;
     }
     $meta = D($this->main_model, 'Model')->where(['id' => $id])->find();
     if (!$meta) {
         // @todo error_message
         return false;
     }
     if ($this->is_locked($meta['status'])) {
         $meta['locked'] = true;
     }
     $meta = Schema::data_format($meta, $this->main_table, true);
     $detail_model = D($this->detail_model, 'Model');
     $rows = $detail_model->where([$this->detail_main_foreign => $id])->select();
     $rows = Schema::data_format($rows, $this->detail_table, true);
     // 工作流进程
     $progress_service = D('Bpm/WorkflowProgress');
     $meta['workflow_progress'] = $progress_service->get_progress($meta['workflow_id'], $meta['id']);
     // 产品属性
     if (AppService::is_app_active('productAttribute')) {
         $rows = D('ProductAttribute/ProductAttribute')->assign_to($rows, $this->detail_model_alias);
     }
     return ['meta' => $meta, 'rows' => $rows];
 }