创建版本

This commit is contained in:
2021-02-22 12:17:00 +08:00
commit af555f49c3
2332 changed files with 369202 additions and 0 deletions
@@ -0,0 +1,172 @@
<?php namespace Gdoo\Index\Controllers;
use DB;
use URL;
use Request;
use App\Support\Pinyin;
use Gdoo\User\Models\User;
use Gdoo\Index\Models\Notification;
class ApiController extends Controller
{
/**
* jq导出xls
*/
public function jqexportAction()
{
$gets = Request::all();
$data = urldecode($gets['data']);
$rows = json_decode($data, true);
return writeExcel($rows['thead'], $rows['tbody'], 'jqexport');
}
/**
* 初始化JS输出
*/
public function commonAction()
{
$settings['public_url'] = URL::to('/');
$settings['upload_file_type'] = $this->setting['upload_type'];
$settings['upload_max_size'] = $this->setting['upload_max'];
$settings['openSource'] = $this->openSource;
header('Content-type: text/javascript');
echo 'var settings = '. json_encode($settings, JSON_UNESCAPED_UNICODE);
exit;
}
/**
* 任务调用
*/
public function taskAction()
{
$rows = DB::table('cron')->where('status', 1)->get();
if ($rows) {
foreach ($rows as $row) {
$cron = \Cron\CronExpression::factory($row['expression']);
// 由于定时任务无法定义秒这里特殊处理一下
if (strtotime($row['next_run']) <= time()) {
// 这里执行代码
// 记录下次执行和本次执行结果
$next = $cron->getNextRunDate()->format('Y-m-d H:i:00');
$data = [
'next_run' => $next,
'last_run' => '执行成功。'
];
DB::table('cron')->where('id', $row['id'])->update($data);
}
}
}
}
/**
* 获取单据编号
*/
public function billSeqNoAction()
{
$bill_id = Request::get('bill_id');
$date = Request::get('date');
$bill = DB::table('model_bill')->where('id', $bill_id)->first();
$model = DB::table('model')->where('id', $bill['model_id'])->first();
$make_sn = make_sn([
'table' => $model['table'],
'date' => $date,
'bill_id' => $bill['id'],
'prefix' => $bill['sn_prefix'],
'rule' => $bill['sn_rule'],
'length' => $bill['sn_length'],
]);
return $this->json($make_sn['new_value'], true);
}
/**
* 汉字转拼音
*/
public function pinyinAction()
{
$word = Request::get('name');
$type = Request::get('type');
if (empty($word)) {
return '';
}
if ($type == 'first') {
return str_replace('/', '', Pinyin::output(str_replace(' ', '', $word)));
} else {
return str_replace('/', '', Pinyin::getstr(str_replace(' ', '', $word)));
}
}
/**
* 显示位置信息
*/
public function locationAction()
{
$gets = Request::all();
return $this->render(array(
'gets' => $gets
));
}
/**
* 系统字典
*/
public function dictAction()
{
$key = Request::get('key');
$rows = option($key);
return response()->json($rows)->setEncodingOptions(JSON_UNESCAPED_UNICODE);
}
/**
* 系统选项
*/
public function optionAction()
{
$key = Request::get('key');
$rows = option($key);
return response()->json($rows)->setEncodingOptions(JSON_UNESCAPED_UNICODE);
}
/**
* 不支持浏览器提示
*/
public function unsupportedBrowserAction()
{
return $this->render();
}
/*
* 显示用户列表
*/
public function dialogAction()
{
$gets = Request::all();
return $this->render([
'gets' => $gets
]);
}
/*
* 调用省市县显示
*/
public function regionAction()
{
$parent_id = Request::get('parent_id', 0);
$layer = Request::get('layer', 1);
$names = [1=>'省' ,2=>'市', 3=>'县'];
$title[] = ['id' => '' ,'name' => $names[$layer]];
$rows = DB::table('region')
->where('parent_id', (int)$parent_id)
->where('layer', $layer)
->get()->toArray();
$rows = array_merge($title, $rows);
return response()->json($rows);
}
}
@@ -0,0 +1,222 @@
<?php namespace Gdoo\Index\Controllers;
use Session;
use Request;
use Validator;
use DB;
use Gdoo\Index\Services\AttachmentService;
use URL;
class AttachmentController extends DefaultController
{
public $permission = ['list','view','preview','create','delete','download','show', 'uploader', 'draft', 'qrcode'];
/**
* 上传文件
*/
public function uploaderAction()
{
if (Request::method() == 'POST') {
$file = Request::file('file');
/*
$rules = [
'file' => 'mimes:'.$this->setting['upload_type'],
];
$v = Validator::make(['file' => $file], $rules);
*/
$upload_type = explode(',', $this->setting['upload_type']);
if ($file->isValid()) {
// 文件后缀名
$extension = $file->getClientOriginalExtension();
// 判断文件类型
if (!in_array($extension, $upload_type)) {
return;
}
// 获取上传uri第一个目录
$key = Request::get('key', 'default');
$node = Request::get('path', 'default');
$path = $node.date('/Ym/');
$upload_path = upload_path().'/'.$path;
// 文件新名字
$filename = date('dhis_').str_random(4).'.'.$extension;
$filename = mb_strtolower($filename);
if ($file->move($upload_path, $filename)) {
$data = [
'name' => mb_strtolower($file->getClientOriginalName()),
'node' => $node,
'path' => $path.$filename,
'type' => $extension,
'key' => $key,
'size' => $file->getClientSize(),
];
$insertId = DB::table('attachment')->insertGetId($data);
$data['id'] = $insertId;
$data['success'] = true;
return json_encode($data);
}
}
}
$query = Request::all();
$SERVER_URL = url("index/attachment/uploader", $query);
return $this->render([
'SERVER_URL' => $SERVER_URL,
'key' => $query['key'],
]);
}
/**
* 新建文件
*/
public function createAction()
{
set_time_limit(0);
$file = Request::file('Filedata');
$rules = [
'file' => 'mimes:'.$this->setting['upload_type'],
];
$v = Validator::make(['file' => $file], $rules);
if ($file->isValid() && $v->passes()) {
// 获取上传uri第一个目录
$path = Request::get('path', 'main').date('/Y/m/');
$upload_path = upload_path().'/'.$path;
// 文件后缀名
$extension = $file->getClientOriginalExtension();
// 文件新名字
$filename = date('dhis_').str_random(4).'.'.$extension;
$filename = mb_strtolower($filename);
if ($file->move($upload_path, $filename)) {
return DB::table('attachment')->insertGetId([
'name' => mb_strtolower($file->getClientOriginalName()),
'path' => $path.$filename,
'type' => $extension,
'size' => $file->getClientSize(),
]);
}
}
return 0;
}
/**
* 二维码上传
*/
public function qrcodeAction()
{
$key = Request::get('key');
$path = Request::get('path');
list($table, $field) = explode('.', $key);
$model = DB::table('model')->where('table', $table)->first();
$token = Request::get('x-auth-token');
return $this->render([
'model' => $model,
'token' => $token,
'key' => $key,
], 'attachment.qrcode');
}
/**
* 获取文件列表
*/
public function listAction()
{
$id = Request::get('id');
$rows = AttachmentService::get($id);
return response()->json($rows);
}
/**
* 获取草稿列表
*/
public function draftAction()
{
$key = Request::get('key');
$rows = AttachmentService::draft($key);
return response()->json($rows);
}
/**
* 预览文件
*/
public function showAction()
{
$id = Request::get('id');
$rows = AttachmentService::get($id);
if (empty($rows)) {
return $this->error('文件不存在。');
}
$image = upload_path($rows[0]['path']);
if (is_file($image)) {
Header('Content-type:image/'.$rows[0]['type']);
return file_get_contents($image);
} else {
return $this->error('文件不存在。');
}
}
/**
* 预览文件
*/
public function previewAction()
{
$id = Request::get('id');
$file = AttachmentService::get($id)[0];
$url = '';
$stream = URL::to('uploads').'/'.$file['path'];
if (in_array($file['type'], array('jpg', 'gif', 'png'))) {
$view = 'image';
$url = "javascript:imageBox('{$file['name']}','{$file['name']}','{$file['name']}');";
} else {
return $this->back()->with('error', '此格式不支持预览。');
}
return $this->display([
'url' => $url,
'stream' => $stream,
], 'attachment.view');
}
/**
* 下载文件
*/
public function downloadAction()
{
$id = Request::get('id');
if ($id) {
$row = DB::table('attachment')->where('id', $id)->first();
$path = upload_path().'/'.$row['path'];
return response()->download($path, $row['name']);
}
}
public function deleteAction()
{
$gets = Request::all();
if ($gets['id']) {
AttachmentService::remove($gets['id']);
return 1;
}
return 0;
}
}
@@ -0,0 +1,71 @@
<?php namespace Gdoo\Index\Controllers;
use Gdoo\User\Models\UserAsset;
use Gdoo\Index\Models\Menu;
use View;
use Validator;
use DB;
use Request;
use App\Support\AES;
use App\Support\Hook;
use Gdoo\Model\Models\Bill;
use Gdoo\Model\Models\Model;
class AuditController extends DefaultController
{
public function __construct()
{
parent::__construct();
}
/**
* 审核
*/
public function auditAction()
{
if (Request::method() == 'POST') {
$key = Request::get('key');
$keys = AES::decrypt($key, config('app.key'));
list($bill_id, $data_id) = explode('.', $keys);
$bill = Bill::find($bill_id);
$model = Model::find($bill->model_id);
DB::beginTransaction();
try {
Hook::fire($model->table.'.onBeforeAudit', ['table' => $model->table, 'id' => $data_id]);
DB::table($model->table)->where('id', $data_id)->update(['status' => 1]);
DB::commit();
return $this->json($bill->name.'审核成功', true);
} catch(\Exception $e) {
DB::rollBack();
return $this->json($e->getMessage());
}
}
}
/**
* 弃审
*/
public function abortAction()
{
if (Request::method() == 'POST') {
$key = Request::get('key');
$keys = AES::decrypt($key, config('app.key'));
list($bill_id, $data_id) = explode('.', $keys);
$bill = Bill::find($bill_id);
$model = Model::find($bill->model_id);
DB::beginTransaction();
try {
Hook::fire($model->table.'.onBeforeAbort', ['table' => $model->table, 'id' => $data_id]);
DB::table($model->table)->where('id', $data_id)->update(['status' => 0]);
DB::commit();
return $this->json($bill->name.'弃审成功', true);
} catch(\Exception $e) {
DB::rollBack();
return $this->json($e->getMessage());
}
}
}
}
+181
View File
@@ -0,0 +1,181 @@
<?php namespace Gdoo\Index\Controllers;
use Session;
use View;
use URL;
use Request;
use Gdoo\Index\Services\RetService;
use Gdoo\System\Models\Setting;
use App\Http\Controllers\Controller as BaseController;
class Controller extends BaseController
{
/**
* @var 程序版本
*/
public $version = '<a target="_blank" href="http://www.gdoo.net">Gdoo</a> 2.2.1';
/**
* @var 资源版本
*/
public $resVersion = '20210221';
/**
* @var 开发商名称
*/
public $powered = 'Gdoo';
/**
* @var 是否开源版
*/
public $openSource = false;
/**
* @var 配置参数
*/
public $setting = [];
/**
* @var 跳过acl检查的方法
*/
public $permission = [];
/**
* @var 当前控制下的方法权限
*/
public $access = [];
/**
* @var layout 布局视图模板
*/
protected $layout = 'layouts.default';
/**
* @var 数据库类型
*/
public $dbType = 'sqlsrv';
/**
* 初始化ret数据
*/
public $ret = null;
/**
* @var 执行初始化工作
*/
public function __construct()
{
// 不丢失表单返回数据
header('Cache-control:private, must-revalidate');
// 获取配置数据
$this->setting = Setting::where('type', 'system')->pluck('value', 'key');
$this->setting['powered'] = $this->powered;
$this->dbType = env('DB_CONNECTION');
$this->ret = RetService::make();
View::share([
'title' => 'GdooOA',
'setting' => $this->setting,
'public_url' => URL::to('/'),
'upload_url' => URL::to('/uploads'),
'static_url' => URL::to('/static'),
'asset_url' => URL::to('/assets'),
'version' => $this->version,
'openSource' => $this->openSource,
'resVersion' => $this->resVersion,
]);
}
/**
* Ajax调用返回
*
* 返回json数据, 供前台ajax调用
* @param array $data 返回数组,支持数组
* @param boolean $status 执行状态, 1为true, 0为false
* @param string $type 返回信息类型, 默认为primary
* @return string
*/
public function json($data, $status = false)
{
return response_json($data, $status);
}
/**
* 返回页面
*/
public function back($message = null, $type = 'message')
{
$args = func_num_args();
if ($args == 0) {
return redirect()->back();
}
return redirect()->back()->with($type, $message);
}
// 操作错误返回
public function error($error = null, $type = 'error')
{
$args = func_num_args();
if ($args == 0) {
return redirect()->back();
}
return redirect()->back()->with($type, $error);
}
// 操作成功跳转
public function success($path, $params = [], $message = null, $referer = 1)
{
$args = func_num_args();
if ($args > 2) {
return $this->to($path, $params, $referer)->with('message', $message);
} else {
return $this->to($path, [], $referer)->with('message', $params);
}
}
/**
* 刷新页面附带 referer
*/
public function to($path = null, $params = [], $referer = 1)
{
return redirect(url_referer($path, $params, $referer));
}
/**
* 模板文件名
*/
public function viewFile($file)
{
if ($file === null) {
$file = Request::controller().'.'.Request::action();
} else {
if (substr_count($file, '.') === 0) {
$file = Request::controller().'.'.$file;
}
}
return $file;
}
/**
* 直接渲染模板不包含layout视图
*/
public function render($params = [], $file = null)
{
return view($this->viewFile($file), $params);
}
/**
* 渲染模板嵌套到layout视图
*/
public function display($params = [], $file = null, $layout = '')
{
$layout = $layout == '' ? $this->layout : $layout;
$layout = view($layout, $params);
return $layout->nest('content', $this->viewFile($file), $params);
}
}
@@ -0,0 +1,326 @@
<?php namespace Gdoo\Index\Controllers;
use Request;
use DB;
use Gdoo\System\Models\Menu;
use Gdoo\System\Models\Widget;
use Gdoo\User\Models\UserWidget;
class DashboardController extends DefaultController
{
public $permission = ['index', 'config', 'quickMenu', 'settingWidget', 'settingInfo'];
public function indexAction()
{
$auth = auth()->user();
$widgets = DB::table('widget')
->where('type', 1)
->where('status', 1)
->where('default', 1)
->permission('receive_id')
->orderBy('sort', 'asc')
->get();
$user_widgets = UserWidget::where('user_id', $auth['id'])
->where('type', 1)
->orderBy('sort', 'asc')
->get()->keyBy('node_id');
$widgets->transform(function ($row) use($user_widgets) {
$user_widget = $user_widgets[$row['id']];
if (not_empty($user_widget)) {
$row['id'] = $user_widget['id'];
$row['status'] = $user_widget['status'];
$row['grid'] = $user_widget['grid'];
$row['sort'] = $user_widget['sort'];
if ($user_widget['name']) {
$row['name'] = $user_widget['name'];
}
if ($user_widget['color']) {
$row['color'] = $user_widget['color'];
}
if ($user_widget['icon']) {
$row['icon'] = $user_widget['icon'];
}
$row['params'] = json_decode($user_widget['params'], true);
return $row;
}
});
$widgets = $widgets->sortBy('sort');
$infos = DB::table('widget')
->where('type', 2)
->where('status', 1)
->where('default', 1)
->permission('receive_id')
->orderBy('sort', 'asc')
->get();
$user_infos = UserWidget::where('user_id', $auth['id'])
->where('type', 2)
->orderBy('sort', 'asc')
->get()->keyBy('node_id');
$infos->transform(function ($row) use($user_infos) {
$user_info = $user_infos[$row['id']];
if (not_empty($user_info)) {
$row['id'] = $user_info['id'];
$row['status'] = $user_info['status'];
$row['sort'] = $user_info['sort'];
if ($user_info['name']) {
$row['name'] = $user_info['name'];
}
if ($user_info['color']) {
$row['color'] = $user_info['color'];
}
if ($user_info['icon']) {
$row['icon'] = $user_info['icon'];
}
$row['params'] = json_decode($user_info['params'], true);
return $row;
}
});
$infos = $infos->sortBy('sort');
$quicks = Menu::leftJoin('user_widget', 'user_widget.node_id', '=', 'menu.id')
->where('user_widget.user_id', $auth['id'])
->where('user_widget.type', 3)
->orderBy('user_widget.sort', 'asc')
->get(['menu.*','user_widget.name','user_widget.color','user_widget.icon']);
$quicks->transform(function ($row) {
$count = substr_count($row['url'], '/');
if ($count == 0) {
$row['url'] = $row['url'].'/index/index';
} else if($count == 1) {
$row['url'] = $row['url'].'/index';
}
$row['key'] = str_replace(['/', '?', '='], ['_', '_', '_'], $row['url']);
return $row;
});
$grids = ['8', '4'];
return $this->display([
'widgets' => $widgets,
'infos' => $infos,
'grids' => $grids,
'quicks' => $quicks,
]);
}
// 仪表板设置
public function configAction()
{
$auth = auth()->user();
if (Request::method() == 'POST') {
$gets = Request::all();
$widgets = $gets['widget'];
$sort = 1;
foreach($widgets as $widget) {
$widget['sort'] = $sort;
$sort ++;
$model = UserWidget::firstOrNew(['type' => 1, 'node_id' => $widget['id'], 'user_id' => $auth['id']]);
$model->fill($widget);
$model->save();
}
$infos = $gets['info'];
$sort = 1;
foreach($infos as $info) {
$info['sort'] = $sort;
if ($info['permission'] && $info['date']) {
$info['params'] = json_encode(['permission' => $info['permission'], 'date' => $info['date']], JSON_UNESCAPED_UNICODE);
}
$sort ++;
$model = UserWidget::firstOrNew(['type' => 2, 'node_id' => $info['id'], 'user_id' => $auth['id']]);
$model->fill($info);
$model->save();
}
$menus = $gets['menu'];
$sort = 1;
$nodeIds = UserWidget::where('type', 3)->where('user_id', $auth['id'])->pluck('id', 'node_id')->toArray();
foreach($menus as $menu) {
unset($nodeIds[$menu['node_id']]);
$menu['sort'] = $sort;
$sort ++;
$model = UserWidget::firstOrNew(['type' => 3, 'node_id' => $menu['node_id'], 'user_id' => $auth['id']]);
$model->fill($menu);
$model->save();
}
// 删除旧菜单
UserWidget::whereIn('id', array_values($nodeIds))->delete();
return $this->json('仪表盘设置成功', true);
}
$widgets = DB::table('widget')
->where('type', 1)
->where('status', 1)
->where('default', 1)
->permission('receive_id')
->orderBy('sort', 'asc')
->get(['id', 'name', 'color', 'icon', 'grid', 'status']);
$user_widgets = UserWidget::where('user_id', $auth['id'])
->where('type', 1)
->orderBy('sort', 'asc')
->get(['id', 'name', 'color', 'icon', 'grid', 'node_id', 'status'])->keyBy('node_id');
$widgets->transform(function ($row) use($user_widgets) {
$user_widget = $user_widgets[$row['id']];
if (not_empty($user_widget)) {
$row['sort'] = $user_widget['sort'];
$row['status'] = $user_widget['status'];
$row['node_id'] = $user_widget['node_id'];
$row['widget_id'] = $user_widget['id'];
$row['grid'] = $user_widget['grid'];
if ($user_widget['name']) {
$row['name'] = $user_widget['name'];
}
if ($user_widget['color']) {
$row['color'] = $user_widget['color'];
}
if ($user_widget['icon']) {
$row['icon'] = $user_widget['icon'];
}
}
return $row;
});
$widgets = $widgets->sortBy('sort');
$infos = DB::table('widget')
->where('type', 2)
->where('status', 1)
->where('default', 1)
->permission('receive_id')
->orderBy('sort', 'asc')
->get(['id', 'name', 'color', 'icon', 'grid', 'status']);
$user_infos = UserWidget::where('user_id', $auth['id'])
->where('type', 2)
->orderBy('sort', 'asc')
->get(['id', 'name', 'color', 'icon', 'grid', 'node_id', 'status', 'params'])->keyBy('node_id');
$infos->transform(function ($row) use($user_infos) {
$user_info = $user_infos[$row['id']];
if (not_empty($user_info)) {
$row['sort'] = $user_info['sort'];
$row['status'] = $user_info['status'];
$row['node_id'] = $user_info['node_id'];
$row['info_id'] = $user_info['id'];
if ($user_info['name']) {
$row['name'] = $user_info['name'];
}
if ($user_info['color']) {
$row['color'] = $user_info['color'];
}
if ($user_info['icon']) {
$row['icon'] = $user_info['icon'];
}
$row['params'] = json_decode($user_info['params'], true);
}
return $row;
});
$infos = $infos->sortBy('sort');
$menus = UserWidget::where('user_id', $auth['id'])
->where('type', 3)
->orderBy('sort', 'asc')
->get();
$grids = ['8', '4'];
$json = [
'widgets' => $widgets,
'infos' => $infos,
'menus' => $menus,
];
$json = json_encode($json, JSON_UNESCAPED_UNICODE);
return $this->render([
'json' => $json,
'widgets' => $widgets,
'infos' => $infos,
'grids' => $grids,
'menus' => $menus,
]);
}
// 添加快捷菜单
public function quickMenuAction()
{
$menus = DB::table('menu')->orderBy('lft', 'asc')->get();
$menus = array_nest($menus);
return $this->render([
'menus' => $menus,
]);
}
// 设置单个组件
public function settingInfoAction()
{
// 定义权限
$permissions = [
'me' => "本人",
'me2' => "本人和下属",
'department' => "本部门",
'department2' => "本部门和下属部门",
'team' => "本销售组",
'team2' => "本销售组和下属销售组",
'all' => "所有人",
];
$dates = [
'day' => '今天',
'day2' => '昨天',
'week' => '本周',
'week2' => '上周',
'month' => '本月',
'month2' => '上月',
'season' => '本季度',
'season2' => '上季度',
'year' => '本年',
'year2' => '去年',
];
$info_id = Request::input('info_id');
$row = UserWidget::where('id', $info_id)->first();
$widget = Widget::where('id', $row['node_id'])->first();
if (empty($row['date'])) {
$row['date'] = 'month';
}
if (empty($row['permission'])) {
$row['permission'] = 'department';
}
$row['widget_name'] = $widget['name'];
return $this->render([
'permissions' => $permissions,
'dates' => $dates,
'row' => $row,
]);
}
// 设置单个组件
public function settingWidgetAction()
{
$widget_id = Request::input('widget_id');
$row = UserWidget::where('id', $widget_id)->first();
$widget = Widget::where('id', $row['node_id'])->first();
if (empty($row['date'])) {
$row['date'] = 'month';
}
if (empty($row['permission'])) {
$row['permission'] = 'department';
}
$row['widget_name'] = $widget['name'];
return $this->render([
'row' => $row,
]);
}
}
@@ -0,0 +1,128 @@
<?php namespace Gdoo\Index\Controllers;
use Gdoo\User\Services\UserAssetService;
use Gdoo\Index\Models\Menu;
use View;
use DB;
use Validator;
use Request;
use App\Support\AES;
use Gdoo\Model\Models\Bill;
use Gdoo\Model\Form;
use Gdoo\Model\Services\ModelService;
use Gdoo\Index\Services\MenuService;
class DefaultController extends Controller
{
protected $user = [];
public function __construct()
{
$this->permission[] = 'store';
parent::__construct();
UserAssetService::setPermissions($this->permission);
// 登录认证和RBAC检查
$this->middleware('auth');
// 获取登录认证数据
$this->middleware(function ($request, $next) {
$this->user = $request->user();
$this->access = UserAssetService::getNowRoleAssets();
$menus = MenuService::getItems();
View::share([
'menus' => $menus,
'access' => $this->access,
]);
return $next($request);
});
}
/**
* 保存表单
*/
public function storeAction()
{
$gets = Request::all();
$master = $gets['master'];
$keys = AES::decrypt($master['key'], config('app.key'));
list($bill_id, $id) = explode('.', $keys);
$bill = Bill::find($bill_id);
$models = ModelService::getModels($bill->model_id);
$model = $models[0];
if (Request::method() == 'POST') {
// 检查表单
$valid = Form::flowRules($models, $gets);
if ($valid['rules']) {
$v = Validator::make($gets, $valid['rules'], $valid['messages'], $valid['attributes']);
if ($v->fails()) {
$errors = $v->errors()->all();
return $this->json(join('<br>', $errors));
}
}
// 保存数据
$id = Form::store($bill, $models, $gets, $id, 'store');
// 保存草稿跳转到编辑界面
$url = url($master['uri'].'/show', ['id' => $id, 'client' => $master['client']]);
return $this->json($bill['name'].'保存成功', $url);
}
}
/**
* 关闭行数据
*/
public function closeRowAction()
{
$gets = Request::all();
if (Request::method() == 'POST') {
$id = $gets['id'];
if (strpos($id, 'draft_') === 0) {
return $this->json('关闭行数据成功', true);
}
$row = DB::table($gets['table'])->where('id', $id)->first();
if ($row['use_close'] == 1) {
$use_close = 0;
} else {
$use_close = 1;
}
DB::table($gets['table'])->where('id', $id)->update(['use_close' => $use_close]);
return $this->json('关闭行数据成功', true);
}
}
/**
* 关闭所有行数据
*/
public function closeAllRowAction()
{
$gets = Request::all();
if (Request::method() == 'POST') {
$ids = [];
foreach($gets['ids'] as $id) {
if (strpos($id, 'draft_') === 0) {
continue;
}
$ids[] = $id;
}
$rows = DB::table($gets['table'])->whereIn('id', $ids)->get();
if ($rows[0]['use_close'] == 1) {
$use_close = 0;
} else {
$use_close = 1;
}
DB::table($gets['table'])->whereIn('id', $ids)->update(['use_close' => $use_close]);
return $this->json('关闭所有行数据成功', true);
}
}
}
@@ -0,0 +1,520 @@
<?php namespace Gdoo\Index\Controllers;
use DB;
use URL;
use Request;
use App\Support\Pinyin;
use Gdoo\User\Models\User;
use Gdoo\Index\Models\Notification;
class DemoController extends Controller
{
#[Attribute(Attribute::TARGET_FUNCTION)]
public function vouchAction()
{
return $this->display();
}
public function helloAction()
{
//\App\Jobs\SendEmail::dispatch('abc', ['fvzone@qq.com'], '您的验证码是0123', 'fsdafsd哈哈哈');
//\App\Jobs\SendSms::dispatch(['15182223008'], '您的验证码是01234');
$menus = DB::table('menu')->get();
foreach($menus as $menu) {
$url = str_replace('.', '/', $menu['url']);
DB::table('menu')->where('id', $menu['id'])->update([
'url' => $url,
]);
}
//\App\Jobs\SendSite::dispatch([1], '您的验证码是0123');
exit;
/*
$dbParams = array(
'dbname' => 'gdoooa_demo',
'user' => 'root',
'password' => 'root',
'host' => 'localhost:3307',
'driver' => 'pdo_mysql',
'charset' => 'utf8mb4',
'default_table_options' => [
'charset' => 'utf8mb4',
'collate' => 'utf8mb4_unicode_ci',
]
);
$paths = array(base_path(). "/abc");
$isDevMode = false;
$config = \Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration($paths, $isDevMode);
$em = \Doctrine\ORM\EntityManager::create($dbParams, $config);
$platform = $em->getConnection()->getDatabasePlatform();
$platform->registerDoctrineTypeMapping('enum', 'string');
$metadata = $em->getClassMetadata('App\\Share');
//$cmf = $em->getMetadataFactory();
//$class = $cmf->getMetadataFor('Share');
print_r($metadata);
*/
$abc['indexes'] = [
'idx_object_id' => [
'columns' => ['source_id'],
],
];
$abc['columns'] = [
'id' => [
'name' => '',
'type' => '',
'default' => '',
'notnull' => '',
'length' => '',
'unsigned' => '',
'autoincrement' => '',
'comment' => '',
], 'name' => [
'name' => '',
'type' => '',
'default' => '',
'notnull' => '',
'length' => '',
'unsigned' => '',
'autoincrement' => '',
'comment' => '',
]];
file_put_contents(base_path().'/abc.json', json_encode($abc, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
/*
$conn = \Doctrine\DBAL\DriverManager::getConnection($connectionParams);
$sm = $conn->getSchemaManager();
$columns = $sm->listTableColumns('role');
foreach ($columns as $column) {
$column->
echo $column->getName() . ': ' . $column->getType() . "\n";
}
print_r($columns);
*/
exit;
$abc = \Gdoo\Produce\Services\ProduceService::getPlanDetail('2020-08-01', '2020-08-04', 0, 0, 0);
// $abc = \Gdoo\Stock\Service\StockService::reportOrderStockInOut(139, 0, '', '', '2020-08-01', '2020-09-21', 1, 1, 0);
print_r($abc);
exit;
/*
$rows = DB::table('model_permission')->get();
foreach($rows as $row) {
$data = json_decode($row['data'], true);
print_r($data);
foreach($data as $k => $rr) {
// _product
print_r($k);
echo "\n";
}
}
exit;
*/
/*
$users = DB::table('user')
->where('group_id', 2)
->get(['id','status', 'name', 'username']);
foreach($users as $user) {
DB::table('customer')->where('user_id', $user['id'])->update([
'status' => $user['status'],
'name' => $user['name'],
'code' => $user['username'],
]);
}
echo 'demo';
exit;
*/
$gets['stock_allocation']['out_warehouse_id'] = 111;
if($gets['stock_allocation']['out_warehouse_id'] <> 140 and $gets['stock_allocation']['out_warehouse_id'] <> 139 and $gets['stock_allocation']['out_warehouse_id'] <> 20005 and $gets['stock_allocation']['out_warehouse_id'] <> 20048) {
echo '1111111111111';
}
if($gets['stock_allocation']['out_warehouse_id'] == 140 or $gets['stock_allocation']['out_warehouse_id'] == 139 or $gets['stock_allocation']['out_warehouse_id'] == 20005 or $gets['stock_allocation']['out_warehouse_id'] == 20048) {
echo '22222222222222';
exit;
}
exit;
/*
$customers = DB::table('tbb_customer')
->get(['tbb_customer.*']);
$users = [];
foreach($customers as $customer) {
$users[] = [
'id' => $customer['CustID'],
'code' => $customer['cCusCode'],
'name' => $customer['cCusName'],
'tel' => $customer['cCusPhone'],
'fax' => $customer['cCusFax'],
'address' => $customer['cCusAddress'],
'head_phone' => $customer['cCusLPersonPhone'],
'head_name' => $customer['cCusLPerson'],
'email' => $customer['cCusEmail'],
// 直营 3
'type_id' => (int)($customer['bZykh2'] == 1 ? 3 : 1),
// 是否调拨
'is_allocate' => (int)$customer['bZykh'],
// 一般纳税人
'general_taxpayer' => (int)$customer['Sfybnsr'],
'status' => (int)$customer['Status'],
'warehouse_address' => $customer['CustWhAddress'],
'warehouse_tel' => $customer['TelPhone'],
'warehouse_contact' => $customer['CustWhPerson'],
'warehouse_phone' => $customer['CustWhPhone'],
'warehouse_size' => $customer['CustWhSqure'],
];
}
*/
/*
$pwd = bcrypt('123456');
foreach($users as $user) {
DB::table('user')->insert([
'id' => $user['id'],
'username' => $user['code'],
'name' => $user['name'],
'email' => $user['email'],
'phone' => $user['head_phone'],
'status' => $user['status'],
'group_id' => 2,
'role_id' => 2,
'password' => $pwd,
]);
DB::table('customer')->insert($user);
}
exit;
$ufcustomer = DB::table('ufcustomer')->get()->toArray();
$ccodes = [];
foreach($ufcustomer as $_ufcustomer) {
$ccodes[$_ufcustomer['cCusHeadCode']][] = $_ufcustomer['cCusCode'];
}
foreach($ccodes as $cid => $_codes) {
foreach($_codes as $i => $_code) {
}
}
*/
//100189
$ufcustomer = DB::table('ufcustomer')->get()->toArray();
$ccodes = [];
foreach($ufcustomer as $_ufcustomer) {
$ccodes[$_ufcustomer['cCusHeadCode']][] = $_ufcustomer['cCusCode'];
}
$users = DB::table('user')->where('group_id', 2)->get()->keyBy('username')->toArray();
foreach($ccodes as $cid => $_codes) {
foreach($_codes as $i => $_code) {
}
}
/*
set_time_limit(0);
$rows = file_get_contents(public_path('r.json'));
$rows = json_decode($rows, true);
foreach($rows as $row) {
$id1 = DB::table('region')->insertGetId(['name' => $row['name'], 'code' => $row['code'], 'layer' => 1]);
foreach($row['cityList'] as $city) {
$id2 = DB::table('region')->insertGetId(['layer' => 2, 'parent_id' => $id1, 'name' => $city['name'], 'code' => $city['code']]);
foreach($city['areaList'] as $area) {
DB::table('region')->insertGetId(['layer' => 3, 'parent_id' => $id2, 'name' => $area['name'], 'code' => $area['code']]);
}
}
}
echo 111;
*/
exit;
/*
\App\Jobs\SendSite::dispatch([1], '您的验证码是0123');
exit;
DB::enableQueryLog();
$user = DB::table('user as u')->orderBy('id', 'desc')->orderBy('username', 'asc')->first();
print_r(DB::getQueryLog());
*/
/*
$units = option('product.unit')->pluck('id', 'name');
$rows = DB::table('product')->get();
foreach($rows as $row) {
$unit = strtolower($row['unit']);
if (isset($units[$unit])) {
$row['unit_id'] = $units[$unit];
DB::table('product')->where('id', $row['id'])->update($row);
} else {
echo $unit."\n";
}
}
*/
exit;
/*
$t1 = microtime(true);
$stocks = DB::table('stock_yonyou_data')
->groupBy('code')
->selectRaw('sum(quantity_set - quantity_get) as quantity,code')
->pluck('quantity', 'code');
$abc = 0;
foreach ($stocks as $stock) {
$abc += $stock;
}
echo $abc."<br>";
$t2 = microtime(true);
echo '耗时'.($t2 - $t1).'秒';
``
exit;
*/
//$abc = \Yunpian::send('15182223008', '您的验证码是5967');
//print_r($abc);
//exit;
/*
$agentid = 1000035;
$url = 'http://www.shenghuafood.com/article/article/view?id=1336&agentid='.$agentid;
//$url = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww42727b1e44abc7fa&redirect_uri='.$u.'&response_type=code&scope=snsapi_privateinfo&agentid='.$agentid.'&state='.$agentid.'#wechat_redirect';
$msg = array(
'touser' => 'qy01bbfb5d6f30ae009bc0e5b8fb',
'toparty' => '',
'msgtype' => 'news',
'agentid' => $agentid,
'news' => array(
"articles"=> array(
0 => array(
"title" => "有新的公告提醒",
"description" => "[公告】关于西安大军区的调整公告",
"url" => $url,
"picurl" => ""
))
)
'text' => array(
"content"=>"各部门及同事:\n".
"为更好的服务好再来大厦,满足大厦入驻员工的班车需求,现对部分班车路线及时刻做相应调整,自2016年9月20日零时生效。详情点击\n<a href=\"http://banche.hoolilai.com\">http://banche.hoolilai.com</a>"
)
);
$api = new \App\Wechat\Work\App($agentid);
var_dump($api->sendMsgToUser($msg));
*/
$xml = simplexml_load_file('tpl.xml');
/*
$attributes = $xml->record->attributes();
foreach ($attributes as $k => $v) {
print_r($k.'---'.$v);
}
*/
$form = $xml->xpath("record[@type='form']/form")[0];
foreach ($form as $key => $node) {
if ($key == 'group') {
$fields = [];
foreach ($node as $k => $field) {
if ($k == 'field') {
$attr = $field->attributes();
$col = $attr['col'] - 2;
$abc[] = '<label class="col-sm-2 control-label" for=""><span class="red">*</span> 供应商</label>';
$abc[] = '<div class="col-sm-'.$col.' control-text"><input type="text" value="180407-185" required="required" class="form-control input-sm" id="supplier_price_sn" name="supplier_price[sn]" readonly="readonly"></div>';
}
//print_r($k);
}
print_r($abc);
}
}
//$abc = Yunpian::send('15182223008', '您的验证码是5967');
//print_r($abc);
//$ab = new Hawind\Core();
// 开启 log
//DB::connection()->enableQueryLog();
//$abc = User::whereIn('user.id', [1,2,3,4])->select(['user.*','user.name as role_name'])->paginate();
// 获取已执行的查询数组
//$abc = DB::getQueryLog();
//$ab->test($abc);
//print_r($abc);
//print_r($cron->isDue());
//$cron = Cron\CronExpression::factory('0 0 0 ? 1/2 FRI#2 *');
//if ($cron->isDue()) {
// The promotion should be enabled!
//}
/*
$datas = DB::table('stock')
->where('date', '0000-00-00')
->get();
foreach ($datas as $key => $data) {
$data['date'] = date('Y-m-d', $data['add_time']);
DB::table('stock')->where('id', $data['id'])->update($data);
}
*/
/*
$logs = DB::table('model_step_log')
->where('table', 'promotion')
->where('step_status', 'next')
->where('created_id', '278')
->get();
foreach ($logs as $log) {
$data['data_30'] = date('Y-m-d', $log['created_at']);
DB::table('promotion')->where('id', $log['table_id'])->update($data);
}
*/
//$sms = new iscms\Alisms\SendsmsPusher();
//$t = "项目流程提醒! 主题:关于违反销售管理制度之扣分——龚涛天 -【销售行为】处罚等待确认!";
//$words = Yunpian::replaceWords($t);
//$t = str_replace($words[0], $words[1], $t);
//$b = mb_str_split('销售');
//print_r(var_dump($words));
//$abc = Yunpian::getBlackWord($words);
//$abc = Yunpian::getTpl('1701454');
// $abc = Yunpian::getUser();
//print_r($abc['balance'] / 0.05);
//print_r($words);
exit;
/*
$departments = DB::table('department')->pluck('name', 'id');
$roles = DB::table('role')->pluck('name', 'id');
$users = DB::table('user')->pluck('name', 'id');
$shares = DB::table('article')->get();
foreach ($shares as $share) {
$id = $name = [];
$share_user = explode(',', $share['user_id']);
foreach ($share_user as $user) {
if($users[$user]) {
$id[] = 'u'.$user;
$name[] = $users[$user];
}
}
$share_role = explode(',', $share['role_id']);
foreach ($share_role as $role) {
if($roles[$role]) {
$id[] = 'r'.$role;
$name[] = $roles[$role];
}
}
$share_department = explode(',', $share['department_id']);
foreach ($share_department as $department) {
if($departments[$department]) {
$id[] = 'd'.$department;
$name[] = $departments[$department];
}
}
DB::table('article')->where('id', $share['id'])->update([
'receive_id' => join(',', $id),
'receive_name' => join(',', $name)
]);
}
*/
/*
$users = User::get();
foreach ($users as $user) {
if($user->password_text == '' && mb_strlen($user->password) == 32) {
$user->password = \Hash::make($user->username);
$user->password_text = $user->username;
$user->save();
}
}
*/
/*
$p2 = DB::connection('sqlite')
->table('city')
->where('parent_id', 2621)
->get();
print_r($p2);
exit;
*/
// app()->configure('pcas');
// $abc = config('pcas');
// print_r(json_encode($abc, JSON_UNESCAPED_UNICODE));
/*
$users = DB::table('user')->get();
foreach ($users as $user) {
$data['warehouse_tel'] = $user['warehouse_tel'];
$data['warehouse_contact'] = $user['warehouse_contact'];
$data['warehouse_phone'] = $user['warehouse_phone'];
$data['warehouse_address'] = $user['warehouse_address'];
$data['invoice_type'] = $user['invoice'];
DB::table('customer')->where('user_id', $user['id'])->update($data);
}
*/
// print_r(123);
// exit;
// return $this->render([]);
}
}
@@ -0,0 +1,81 @@
<?php namespace Gdoo\Index\Controllers;
use Gdoo\Index\Services\InfoService;
use Request;
use Gdoo\Model\Services\ModuleService;
class IndexController extends DefaultController
{
/**
* 设置可直接访问的方法
*/
public $permission = [
'info',
'badge',
'badges',
'help',
'index',
'unsupportedBrowser',
'support',
];
public function indexAction()
{
$user = auth()->user();
return $this->render([
'user' => $user,
]);
}
public function infoAction()
{
return InfoService::getInfo("abv");
}
// 首页登录指南页面
public function helpAction()
{
return $this->render();
}
// 技术支持
public function supportAction()
{
return $this->render();
}
/*
* 通用对话框
*/
public function dialogAction()
{
$gets = Request::all();
return $this->render([
'gets' => $gets
]);
}
// 获取单个待办数量
public function badgeAction()
{
$key = Request::input('key');
if ($key) {
$badge = ModuleService::badges($key);
if ($badge) {
return response()->json($badge());
}
}
return response()->json(['total' => 0, 'data' => []]);
}
// 获取全部待办数量
public function badgesAction()
{
$badges = ModuleService::badges();
$json = [];
foreach($badges as $key => $badge) {
$json[$key] = $badge();
}
return response()->json($json);
}
}
File diff suppressed because it is too large Load Diff