Initial commit,修正

This commit is contained in:
2025-07-13 19:37:38 +08:00
parent 38ce288e27
commit 65bbd06981
12384 changed files with 3985464 additions and 8 deletions
+1
View File
@@ -0,0 +1 @@
+26
View File
@@ -0,0 +1,26 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>404</title>
<style>
body{
background-color:#444;
font-size:14px;
}
h3{
font-size:60px;
color:#eee;
text-align:center;
padding-top:30px;
font-weight:normal;
}
</style>
</head>
<body>
<h3>404,您请求的文件不存在!</h3>
</body>
</html>
+26
View File
@@ -0,0 +1,26 @@
<?php
namespace backend\assets;
use yii\web\AssetBundle;
/**
* Main backend application asset bundle.
*/
class AppAsset extends AssetBundle
{
public $basePath = '@webroot';
public $baseUrl = '@web';
public $css = [
'css/site.css',
'css/login.min.css',
];
public $js = [
'js/jquery-2.2.4.min.js',
// 'js/hplus.min.js',
];
public $depends = [
'yii\web\YiiAsset',
'yii\bootstrap5\BootstrapAsset',
];
}
+24
View File
@@ -0,0 +1,24 @@
<?php
/**
* User: Administrator
* Date: 2016-7-5
* Time: 16:10
* Description:
*/
namespace backend\components;
use Yii;
use yii\rbac\Rule;
class ArticleRule extends Rule
{
public $name = 'article';
public function execute($user, $item, $params)
{
// 这里先设置为false,逻辑上后面再完善
return false;
}
}
+75
View File
@@ -0,0 +1,75 @@
<?php
/**
* @Author: fm453
* @Date: 2021-09-08 00:25:51
* @Last Modified by: fm453
* @Last Modified time: 2021-09-11 10:24:46
* @Email: fm453@lukegzs.com
*/
namespace backend\components;
use Yii;
use common\models\CLog;
use common\models\User;
use common\models\Member;
use common\models\Fans;
use common\models\CAttachment;
use common\models\CSms;
use backend\models\Adminer;
class Helper {
//历史访客数
public static function getHistoryVisNum(){
$res = CLog::find()->count();
return $res;
}
//最近一个月访问量
public static function getMonthHistoryVisNum(){
$LastMonth = strtotime("-1 month");
$res = CLog::find()->where(['>','create_time',$LastMonth])->count();
return $res;
}
//运维人员总数
public static function getAdminerCount(){
$res = Adminer::find()->count();
return $res;
}
//API接口站用户总数
public static function getApierCount(){
$res = User::find()->count();
return $res;
}
//会员数据总数
public static function getMemberCount(){
$res = Member::find()->count();
return $res;
}
//粉丝数据总数
public static function getFansCount(){
$res = Fans::find()->count();
return $res;
}
//短信统计
public static function getSmsStat(){
$sms = CSms::find()->count();
$mobile = CSms::find()->groupBy('mobile')->count();
return ['sms'=>$sms,'mobile'=>$mobile];
}
//附件统计
public static function getAttachStat(){
$num = CAttachment::find()->count();
$size = CAttachment::find()->sum('filesize');
return ['num'=>$num, 'size'=>$size];
}
}
+3
View File
@@ -0,0 +1,3 @@
main-local.php
params-local.php
test-local.php
+10
View File
@@ -0,0 +1,10 @@
<?php
# @Author: 嗨噜客(三亚) <fm453>
# @Date: 2022-05-15T20:59:48+08:00
# @Email: fm453@lukegzs.com
# @Last modified by: fm453
# @Last modified time: 2022-05-15T21:00:57+08:00
# @Copyright: www.hiluker.cn
Yii::setAlias('@backend', dirname(__DIR__));
+100
View File
@@ -0,0 +1,100 @@
<?php
# @Author: 嗨噜客科技(www.hiluker.cn) <Fm453>
# @Date: 1970-01-01T08:00:00+08:00
# @Email: fm453@hiluker.com
# @Last modified by: fm453
# @Last modified time: 2022-05-15T21:14:24+08:00
$params = array_merge(
require(__DIR__ . '/../../common/config/params.php'),
require(__DIR__ . '/../../addons-'.HI_APP.'/config/citys.php'),
require(__DIR__ . '/../../addons-'.HI_APP.'/config/params-car.php'),
require(__DIR__ . '/../../addons-'.HI_APP.'/config/params-letter.php'),
require(__DIR__ . '/../../addons-'.HI_APP.'/config/params-area.php'),
require(__DIR__ . '/../../addons-'.HI_APP.'/config/params.php'),
require(__DIR__ . '/params.php')
);
$config = [
'id' => 'app-backend',
'basePath' => dirname(__DIR__),
'controllerNamespace' => 'backend\controllers',
'defaultRoute' => 'site', //默认路由
'bootstrap' => ['log'],
'modules' => [
"admin" => [
"class" => 'mdm\admin\Module',
]
],
'aliases' => [
"@mdm/admin" => "@vendor/mdmsoft/yii2-admin",
],
'as access' => [
//加了才会自动验证是否有权限
'class' => 'mdm\admin\components\AccessControl',
'allowActions' => [
//允许访问的action
//controller/action
'site/*',
'index/*'
]
],
//'layout' => 'main',//布局文件 优先级: 控制器>配置文件>系统默认
'language' => 'zh-CN', //目标语言
//组件
'components' => [
'request' => [
'csrfParam' => '_csrf-backend',
'cookieValidationKey' => 'CU5iSYmIp6kbjKKuh541KsA_oaYvTuNh',
],
//身份认证类
'user' => [
'identityClass' => 'backend\models\Adminer',
'enableAutoLogin' => true,
'identityCookie' => ['name' => '_identity-backend', 'httpOnly' => true],
// 'loginUrl' => ['site/login'], //配置登录url
],
'session' => [
// this is the name of the session cookie used for login on the backend
'name' => 'advanced-backend',
],
//Rbac权限控制
'authManager' => [
'class' => 'yii\rbac\DbManager',
'itemTable' => 'auth_item',
'assignmentTable' => 'auth_assignment',
'itemChildTable' => 'auth_item_child',
],
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
'errorHandler' => [
'errorAction' => 'site/error',
],
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => true,
'suffix' => '.hi', //后缀
'rules' => [
],
],
// 'assetManager' => [
// 'class' => 'yii\web\AssetManager',
// 'appendTimestamp' => true,
// 'forceCopy' => true,
// ],
],
'params' => $params,
];
return $config;
+11
View File
@@ -0,0 +1,11 @@
<?php
# @Author: 嗨噜客科技(www.hiluker.cn) <Fm453>
# @Date: 1970-01-01T08:00:00+08:00
# @Email: fm453@hiluker.com
# @Last modified by: fm453
# @Last modified time: 2022-05-15T21:03:53+08:00
return [
];
+9
View File
@@ -0,0 +1,9 @@
<?php
return [
'id' => 'app-backend-tests',
'components' => [
'assetManager' => [
'basePath' => __DIR__ . '/../web/assets',
],
],
];
+425
View File
@@ -0,0 +1,425 @@
<?php
/**
* @Author: fm453
* @Date: 2018-08-17 19:39:41
* @Last Modified by: fm453
* @Last Modified time: 2021-09-11 07:33:45
* @Email: fm453@lukegzs.com
*/
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\helpers\Url;
use addons\models\AcCar;
use addons\models\AcAlbums;
use addons\models\AcAlbumPics;
use addons\models\AcAlbumVersion;
class AlbumsController extends \yii\web\Controller
{
//替代常规的_construct 析构函数;其他方法调用前执行
public function init()
{
parent::init();
$session = Yii::$app->session;
if(isset($_GET['pid']) && (int)$_GET['pid']>0){
$session->set('pid',(int)$_GET['pid']);
}
$pid = $session->get('pid');
if(!$pid){
return $this->redirect(['index/index']);
}
}
//主界面
public function actionIndex()
{
global $_HI,$_FM;
return $this->render('../layouts/dev',[]);
}
//相册列表
public function actionList()
{
return $this->render('../layouts/dev');
global $_HI,$_FM;
$pid = Yii::$app->session->get('pid');
$session = Yii::$app->session;
$model = new AcAlbums();
$where = [];
$where[]='and';
$where[] = ['=','pid',$pid];
$post = Yii::$app->request->post();
$get = Yii::$app->request->get();
$searchSession = 'acalbums::search';
if(isset($post['search'])){
$search = $post['search'];
$session->set($searchSession,$search);
}elseif($session->get($searchSession)){
$search = $session->get($searchSession);
}
$search['car_id'] = isset($search['car_id']) ? (int)$search['car_id'] : '';
$CarModel = new AcCar();
if(empty($search['car_id'])){
$search['car_id'] = isset($get['car_id']) ? (int)$get['car_id'] : 0;
}
if(!empty($search['car_id'])){
$where[] = ['=','car_id',$search['car_id']];
$car = $CarModel->findOne($search['car_id']);
$search['car_title'] = isset($car->title) ? $car->title : '';
}
$search['phone'] = isset($search['phone']) ? trim($search['phone']) : '';
if(!empty($search['phone'])){
$where[] = ['or',['LIKE','phone1_1',$search['phone']],['LIKE','phone1_2',$search['phone']],['LIKE','phone2_1',$search['phone']],['LIKE','phone2_2',$search['phone']]];
}
$deleted = 0;
if(isset($_GET['deleted'])){
$deleted = isset($_GET['deleted'])?((int)$_GET['deleted']>=0?1:0):0;
}
$where[]=['=','deleted',$deleted];
$data = $model->find()->where($where);
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->indexBy('id')->all();
$status = Yii::$app->params['AlbumStatus'];
$orders = [];
foreach($res as $s){
$s = $s->toArray();
$orders[$s['id']] = $s;
}
return $this->render('list',[
'orders' => $orders,
'pager' => $pages,
'status'=>$status,
'search'=>$search
]);
}
//验新车
public function actionNewcar()
{
return $this->render('../layouts/dev');
$status = Yii::$app->params['AlbumStatus'];
$AcAlbum = new AcAlbums();
$AcAlbum->status_code = 0;
$detail = $AcAlbum->toArray();
return $this->render('modify',['status'=>$status,'detail'=>$detail]);
}
/*编辑相册*/
public function actionEdit()
{
return $this->render('../layouts/dev');
$pid = Yii::$app->session->get('pid');
$status = Yii::$app->params['OrderStatus'];
$post = Yii::$app->request->post();
$id = Yii::$app->request->get('id');
$AcOrder = new AcOrder();
$order = $AcOrder->findOne($id);
$detail = $order->toArray();
$detail['thumbs'] = json_decode($detail['thumbs']);
$model = new AcStore();
$store = $model->findOne($detail['store_id']);
if($store){
$detail['store_title'] = $store->title;
}
$model = new AcEmployee();
$employee = $model->findOne($detail['employee_id']);
if($employee){
$detail['employee_title'] = $employee->name;
}
$detail['car_owner_id']=$detail['car_brand_id']=$detail['car_series_id']=0;
$model = new AcCar();
$car = $model->findOne($detail['car_id']);
if($car){
$detail['car_owner_id'] = $car->owner_id;
$detail['car_brand_id'] = $car->brand_id;
$detail['car_series_id'] = $car->series_id;
$detail['car_number'] = $car->num_p.$car->num_area.$car->num_left;
$detail['car_number'] = $detail['car_number']?$detail['car_number']:$car->num_frame;
}
$model = new User();
$user = $model->findOne($detail['from_mid']);
$model = new AcUserExt();
$exts = [];
$_exts = $model->find()->where(['mid'=>$detail['from_mid'],'pid'=>$pid,'deleted'=>0])->indexBy('id')->all();
foreach($_exts as $ext){
$ext = $ext->toArray();
if(isset($users[$s['id']])){
if($ext['mobile']==$user->mobile){
$exts[$ext['mid']][$ext['key']] = $ext['value'];
}
}
}
$AcCarOwner = new AcCarOwner();
$owner = $AcCarOwner->findOne($detail['car_owner_id']);
if($owner){
$_owner = User::findOne($detail['car_owner_id']);
$detail['car_owner'] = $_owner->username.'【'.$_owner->mobile.'】';
}
$AcCarBrand = new AcCarBrand();
$brand = $AcCarBrand->findOne($detail['car_brand_id']);
if($brand){
$detail['car_title'] = $brand->title;
}
$AcCarSeries = new AcCarSeries();
$where = [];
$series= $AcCarSeries->findOne($detail['car_series_id']);
if($series){
$detail['car_title'] .= $series->title;
}
$op = Yii::$app->request->get('op');
$tpl = 'modify';
if($op=='print'){
$tpl = 'print';
$sn = '00000000000'; //11位
$sn = substr($sn,0,11-strlen($id));
$sn .=$id;
$detail['sn'] = $sn;
}
return $this->render($tpl,[
'status'=>$status,
'detail'=>$detail,
'store'=>$store,
'employee'=>$employee,
'id'=>$id
]
);
}
/*相册详情*/
public function actionDetail()
{
$pid = Yii::$app->session->get('pid');
$status = Yii::$app->params['OrderStatus'];
$post = Yii::$app->request->post();
$id = Yii::$app->request->get('id');
$AcOrder = new AcOrder();
$order = $AcOrder->findOne($id);
$detail = $order->toArray();
$detail['thumbs'] = json_decode($detail['thumbs']);
$model = new AcStore();
$store = $model->findOne($detail['store_id']);
if($store){
$detail['store_title'] = $store->title;
}
$model = new AcEmployee();
$employee = $model->findOne($detail['employee_id']);
if($employee){
$detail['employee_title'] = $employee->name;
}
$detail['car_owner_id']=$detail['car_brand_id']=$detail['car_series_id']=0;
$model = new AcCar();
$car = $model->findOne($detail['car_id']);
if($car){
$detail['car_owner_id'] = $car->owner_id;
$detail['car_brand_id'] = $car->brand_id;
$detail['car_series_id'] = $car->series_id;
$detail['car_number'] = $car->num_p.$car->num_area.$car->num_left;
$detail['car_number'] = $detail['car_number']?$detail['car_number']:$car->num_frame;
}
$model = new User();
$user = $model->findOne($detail['from_mid']);
$model = new AcUserExt();
$exts = [];
$_exts = $model->find()->where(['mid'=>$detail['from_mid'],'pid'=>$pid,'deleted'=>0])->indexBy('id')->all();
foreach($_exts as $ext){
$ext = $ext->toArray();
if(isset($users[$s['id']])){
if($ext['mobile']==$user->mobile){
$exts[$ext['mid']][$ext['key']] = $ext['value'];
}
}
}
$AcCarOwner = new AcCarOwner();
$owner = $AcCarOwner->findOne($detail['car_owner_id']);
if($owner){
$_owner = User::findOne($detail['car_owner_id']);
$detail['car_owner'] = $_owner->username.'【'.$_owner->mobile.'】';
}
$AcCarBrand = new AcCarBrand();
$brand = $AcCarBrand->findOne($detail['car_brand_id']);
if($brand){
$detail['car_title'] = $brand->title;
}
$AcCarSeries = new AcCarSeries();
$where = [];
$series= $AcCarSeries->findOne($detail['car_series_id']);
if($series){
$detail['car_title'] .= $series->title;
}
$sn = '00000000000'; //11位
$sn = substr($sn,0,11-strlen($id));
$sn .=$id;
$detail['sn'] = $sn;
return $this->render('detail',[
'status'=>$status,
'detail'=>$detail,
'store'=>$store,
'employee'=>$employee,
'id'=>$id
]
);
}
//站点验车
public function actionOrder()
{
return $this->render('../layouts/dev');
$post = Yii::$app->request->post();
$id = (int)$post['id'];
$pid = Yii::$app->session->get('pid');
$AcOrder = new AcOrder();
if($id){
$order = $AcOrder->findOne($id);
if($order->create_by != Yii::$app->user->identity->id){
//不允许修改非本人操作的表单
$return['msg'] = '您不是该运单的制单人,不允许进行修改!';
$return['errorcode'] = 404;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
}
//格式化数据 为空的项则不修改
//目标键=》POST键
$cols = ['start_province'=>'start_province','start_city'=>'start_city','aim_province'=>'aim_province','aim_city'=>'aim_city','signer'=>'signer','sender_name'=>'sender_name','sender_idcard'=>'sender_idcard','sender_mobiles'=>'sender_mobiles','receiver_name'=>'receiver_name','receiver_idcard'=>'receiver_idcard','receiver_mobiles'=>'receiver_mobiles','aim_address'=>'aim_address','thumb_f'=>'thumb_f','thumb_b'=>'thumb_b','thumb_l'=>'thumb_l','thumb_r'=>'thumb_r','car_extra'=>'car_extra','bind'=>'bind','driving_lisence'=>'driving_lisence'];
foreach($cols as $col=>$key){
if(isset($post[$key]) && $post[$key] !=''){
$data[$col] = trim($post[$key]);
}
// $data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
}
$cols = ['car_id'=>'car_id','employee_id'=>'employee_id','car_value'=>'car_value','fee_insurance'=>'fee_insurance','fee_truck'=>'fee_truck','fee_deliver'=>'fee_deliver','fee_pickup'=>'fee_pickup','fee_urgent'=>'fee_urgent','fee_extra'=>'fee_extra','fee_total'=>'fee_total','pay_send'=>'pay_send','pay_receive'=>'pay_receive','is_checked'=>'is_checked','no_driving_lisence'=>'no_driving_lisence','start_km'=>'start_km','not_insurance'=>'not_insurance'];
foreach($cols as $col=>$key){
if(isset($post[$key]) && $post[$key] !=''){
$data[$col] = (int)$post[$key];
}
// $data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
}
//图片组处理
$cols = ['thumbs'=>'thumbs'];
foreach($cols as $col=>$key){
if(isset($post[$key]) && !empty($post[$key])){
$imgs = $post[$key]; //数组格式
$imgs = array_unique($imgs);
$imgs = json_encode($imgs);
$data[$col] = $imgs;
}
}
$cols = ['remark'=>'editor'];
foreach($cols as $col=>$key){
if(isset($post[$key]) && $post[$key] !=''){
$data[$col] = htmlspecialchars($post[$key]);
}
// $data[$col] = isset($post[$key]) ? htmlspecialchars($post[$key]) : '';
}
$sign_date = isset($post['sign_date']) ? strtotime($post['sign_date']) : '';
if(!$id){
$data['create_by'] = Yii::$app->user->identity->id;
$data['sign_date'] = $sign_date ? $sign_date : time();
}
//部分规则校验
$has_err = false;
$data['is_cwqr'] = 0; //修改财务确认状态为待确认
if(!$id){
$data['status_code'] = 1;
}
/*不投保的,保额不超过20W,保费为0*/
if($data['not_insurance']){
if($data['fee_insurance']){
$data['fee_insurance']=0;
\Yii::$app->getSession()->setFlash('warning', '勾选了不投保,已强制修改保费为0!');
}
if($data['car_value']>Yii::$app->params['DefaultCarInsuranceValueMax']){
$has_err = true;
$data['car_value'] = Yii::$app->params['DefaultCarInsuranceValueMax'];
\Yii::$app->getSession()->setFlash('danger', '勾选了不投保,默认最高赠送的运输险保额不超过'.Yii::$app->params['DefaultCarInsuranceValueMax'].'万元,已自动强制校正');
}
}
$fee_total = $data['fee_truck']+$data['fee_insurance']+$data['fee_deliver']+$data['fee_pickup']+$data['fee_urgent']+$data['fee_extra'];
$fee_pay = $data['pay_send']+$data['pay_receive'];
if(!$data['fee_truck']){
$has_err = true;
\Yii::$app->getSession()->setFlash('danger', '请注意,运费未正确填写!');
}
if(!$data['pay_send']&&!$data['pay_receive']){
$has_err = true;
\Yii::$app->getSession()->setFlash('danger', '请注意,到收运费及起运地预收运费均未填写!');
}
if($fee_total !=$data['fee_total']){
$has_err = true;
\Yii::$app->getSession()->setFlash('danger', '请注意,所填运费、保费、提车费、送车费、额外费用、加急费等各项费用汇总的值与所填写的总费用不一致,请检查并更新');
}
if($fee_pay !=$data['fee_total']){
$has_err = true;
\Yii::$app->getSession()->setFlash('danger', '请注意,所填起运地预付运费、到收运费的汇总值与所填写的总费用不一致,请检查并更新');
}
$data['create_at'] = time();
$data['update_at'] = $data['create_at'];
$data['pid'] = $pid;
$model = new AcEmployee();
$employee = $model->findOne($data['employee_id']);
if($employee){
$data['store_id'] = $employee->store_id;
}
//保存资料
if($id){
unset($data['create_at']);
$res = $AcOrder->updateAll($data,['id'=>$id]);
}else{
foreach($data as $key=>$val){
$AcOrder->$key = $val;
}
$res = $AcOrder->save();
$id = $AcOrder->attributes['id']; //获取插入后id
}
if($res){
if($has_err){
\Yii::$app->getSession()->setFlash('success', '订单保存成功,但有价格数据录入错误,请根据情况检查更新!');
}else{
\Yii::$app->getSession()->setFlash('success', '订单保存成功!');
}
return $this->redirect(['edit','id'=>$id]);
}else{
\Yii::$app->getSession()->setFlash('warning', '订单保存失败!');
return $this->goBack();
}
}
}
+538
View File
@@ -0,0 +1,538 @@
<?php
/**
* @Author: fm453
* @Date: 2018-08-17 19:39:41
# @Last modified by: fm453
# @Last modified time: 2021-09-14T11:44:34+08:00
* @Email: fm453@lukegzs.com
*/
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\helpers\Url;
use addons\models\AcCar;
use addons\models\AcCarOwner;
use addons\models\AcCarBrand;
use addons\models\AcCarSeries;
use common\models\Fans;
class CarController extends \yii\web\Controller
{
//替代常规的_construct 析构函数;其他方法调用前执行
public function init()
{
parent::init();
$session = Yii::$app->session;
if(isset($_GET['pid']) && (int)$_GET['pid']>0){
$session->set('pid',(int)$_GET['pid']);
}
$pid = $session->get('pid');
if(!$pid){
return Yii::$app->response->redirect(['index/index']);
}
}
//主界面
public function actionIndex()
{
return $this->render('../layouts/dev',[]);
}
//车辆列表
public function actionList()
{
$pid = Yii::$app->session->get('pid');
$session = Yii::$app->session;
$AcCar = new AcCar();
$where = $where2 = [];
$where['pid'] = $pid;
$post = Yii::$app->request->post();
$search = [];
$searchSession = 'cars::search';
if(isset($_GET['reset']) && $_GET['reset']==1){
$post['search'] = [];
}
if(isset($post['search'])){
$search = $post['search'];
$session->set($searchSession,$search);
// }elseif($session->get($searchSession)){
// $search = $session->get($searchSession);
}
$search['title'] = isset($search['title']) ? trim(htmlspecialchars_decode($search['title'])) : '';
if(!empty($search['title'])){
$where2[] = 'or';
$where2[] = ['LIKE','num_left',$search['title']];
$where2[] = ['LIKE','num_frame',$search['title']];
}
$search['brand'] = isset($search['brand_id']) ? trim(htmlspecialchars_decode($search['brand'])) : '';
$search['brand_id'] = isset($search['brand_id']) ? (int)$search['brand_id'] : 0;
if(!empty($search['brand_id'])){
$where['brand_id'] = $search['brand_id'];
}
$where['deleted'] = 0;
$data = $AcCar->find()->where($where);
if($search['title']){
$data = $data->andwhere($where2);
}
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->orderby('id DESC')->all();
$oids = $mids = $bids = $sids = [];
if($res){
foreach($res as $r){
$oids[] = $r->owner_id;
$mids[] = $r->mid;
$bids[] = $r->brand_id;
$sids[] = $r->series_id;
}
}
$status = Yii::$app->params['CommonStatus'];
$AcCarOwner = new AcCarOwner();
$where = [];
$where['pid'] = $pid;
$_owners = $AcCarOwner->find()->where($where)->andwhere(['in','id',$oids])->all();
$owners = [];
foreach($_owners as $s){
$owners[$s->id] = $s->toArray();
}
$User = new Fans();
$where = [];
$_users = $User->find()->where(['in','id',$mids])->all();
$users = [];
foreach($_users as $s){
$users[$s->id] = $s->toArray();
}
$AcCarSeries = new AcCarSeries();
$where = [];
$series = [];
$_series = $AcCarSeries->find()->where($where)->andwhere(['in','id',$sids])->all();
if($_series){
foreach($_series as $r){
$series[$r->id] = $r->toArray();
}
}
$AcCarBrand = new AcCarBrand();
$where = [];
$_brands = $AcCarBrand->find()->where($where)->andwhere(['in','id',$bids])->all();
if($_brands){
foreach($_brands as $r){
$brands[$r->id] = $r->toArray();
}
}
$cars = [];
if($res){
foreach($res as $r){
$car = $r->toArray();
$t = '';
if(isset($series[$r->series_id]['title'])){
$t .= $brands[$r->brand_id]['title'];
}
$t .= '-';
if(isset($series[$r->series_id]['title'])){
$t .= $series[$r->series_id]['title'];
}
$car['title2'] = $t;
$car['numbers'] = $car['num_p'].$car['num_area'].$car['num_left'];
$car['numbers'] = $car['numbers']?$car['numbers']:$car['num_frame'];
$cars[$r->id] = $car;
}
}
return $this->render('list',[
'cars'=>$cars,
'pager' => $pages,
'owners'=>$owners,
'users'=>$users,
'status'=>$status,
'search'=>$search
]);
}
public function actionSelect()
{
$pid = Yii::$app->session->get('pid');
$session = Yii::$app->session;
$AcCar = new AcCar();
$where = $where2 = [];
$where['pid'] = $pid;
$post = Yii::$app->request->post();
$search = [];
$searchSession = 'cars::search';
if(isset($_GET['reset']) && $_GET['reset']==1){
$post['search'] = [];
}
if(isset($post['search'])){
$search = $post['search'];
$session->set($searchSession,$search);
// }elseif($session->get($searchSession)){
// $search = $session->get($searchSession);
}
$search['title'] = isset($search['title']) ? trim(htmlspecialchars_decode($search['title'])) : '';
if(!empty($search['title'])){
$where2[] = 'or';
$where2[] = ['LIKE','num_left',$search['title']];
$where2[] = ['LIKE','num_frame',$search['title']];
}
$search['brand'] = isset($search['brand_id']) ? trim(htmlspecialchars_decode($search['brand'])) : '';
$search['brand_id'] = isset($search['brand_id']) ? (int)$search['brand_id'] : 0;
if(!empty($search['brand_id'])){
$where['brand_id'] = $search['brand_id'];
}
$where['deleted'] = 0;
$data = $AcCar->find()->where($where);
if($search['title']){
$data = $data->andWhere($where2);
}
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->orderby(' id DESC')->all();
$oids = $mids = $bids = $sids = [];
if($res){
foreach($res as $r){
$oids[] = $r->owner_id;
$mids[] = $r->mid;
$bids[] = $r->brand_id;
$sids[] = $r->series_id;
}
}
$status = Yii::$app->params['CommonStatus'];
$AcCarOwner = new AcCarOwner();
$where = [];
$where['pid'] = $pid;
$_owners = $AcCarOwner->find()->where($where)->andwhere(['in','id',$oids])->all();
$owners = [];
foreach($_owners as $s){
$owners[$s->id] = $s->toArray();
}
$User = new Fans();
$where = [];
$_users = $User->find()->where(['in','id',$mids])->all();
$users = [];
foreach($_users as $s){
$users[$s->id] = $s->toArray();
}
$AcCarSeries = new AcCarSeries();
$where = [];
$series = [];
$_series = $AcCarSeries->find()->where($where)->andwhere(['in','id',$sids])->all();
if($_series){
foreach($_series as $r){
$series[$r->id] = $r->toArray();
}
}
$AcCarBrand = new AcCarBrand();
$where = [];
$_brands = $AcCarBrand->find()->where($where)->andwhere(['in','id',$bids])->all();
if($_brands){
foreach($_brands as $r){
$brands[$r->id] = $r->toArray();
}
}
$cars = [];
if($res){
foreach($res as $r){
$car = $r->toArray();
$t = '';
if(isset($series[$r->series_id]['title'])){
$t .= $brands[$r->brand_id]['title'];
}
$t .= '-';
if(isset($series[$r->series_id]['title'])){
$t .= $series[$r->series_id]['title'];
}
$car['title2'] = $t;
$car['numbers'] = $car['num_p'].$car['num_area'].$car['num_left'];
$car['numbers'] = $car['numbers']?$car['numbers']:$car['num_frame'];
$cars[$r->id] = $car;
}
}
$callback = !empty(Yii::$app->request->get('callback')) ? Yii::$app->request->get('callback') : 'truck';
return $this->render('select',[
'cars'=>$cars,
'pager' => $pages,
'owners'=>$owners,
'users'=>$users,
'status'=>$status,
'search'=>$search,
'callback'=>$callback
]);
}
public function actionNew()
{
$status = Yii::$app->params['CommonStatus'];
$AcCar = new AcCar();
$AcCar->status_code = 0;
return $this->render('modify',['status'=>$status,'detail'=>$AcCar]);
}
//编辑客车资料
public function actionEdit()
{
$model = new AcCar();
$id = Yii::$app->request->get('id');
$res = $model->find()->where(['id' => $id])->one();
if($res){
$res = $res->toArray();
}
$pid = Yii::$app->session->get('pid');
$AcCarOwner = new AcCarOwner();
$owner = $AcCarOwner->find()->where(['id' => $res['owner_id']])->one();
if($owner){
$mid = $owner->mid;
$user = Fans::findIdentity($mid);
if($user){
$res['owner_title'] = $user->mobile;
}
}
$AcCarSeries = new AcCarSeries();
$series = $AcCarSeries->find()->where(['id' => $res['series_id']])->one();
if($series){
$res['series_title'] = $series->title;
}
$AcCarBrand = new AcCarBrand();
$brand = $AcCarBrand->find()->where(['id' => $res['brand_id']])->one();
if($brand){
$res['brand_title'] = $brand->title;
}
$status = Yii::$app->params['CommonStatus'];
return $this->render('modify',['status'=>$status,'detail'=>$res]);
}
//复制客车资料后新建
public function actionCopy()
{
$model = new AcCar();
$id = Yii::$app->request->get('id');
$res = $model->find()->where(['id' => $id])->one();
if($res){
$res = $res->toArray();
}
$pid = Yii::$app->session->get('pid');
$AcCarSeries = new AcCarSeries();
$series = $AcCarSeries->find()->where(['id' => $res['series_id']])->one();
if($series){
$res['series_title'] = $series->title;
}
$AcCarBrand = new AcCarBrand();
$brand = $AcCarBrand->find()->where(['id' => $res['brand_id']])->one();
if($brand){
$res['brand_title'] = $brand->title;
}
$status = Yii::$app->params['CommonStatus'];
$res['id'] = 0;
$res['num_p'] = $res['num_area'] = $res['num_left'] = $res['num_frame'] = '';
return $this->render('modify',['status'=>$status,'detail'=>$res]);
}
//浏览客车详情
public function actionDetail()
{
$model = new AcCar();
$id = Yii::$app->request->get('id');
$res = $model->find()->where(['id' => $id])->one();
if($res){
$res = $res->toArray();
}
$pid = Yii::$app->session->get('pid');
$AcCarOwner = new AcCarOwner();
$owner = $AcCarOwner->find()->where(['id' => $res['owner_id']])->one();
$user = Fans::findIdentity($mid);
if($user){
$res['owner_title'] = $user->mobile;
}
$AcCarSeries = new AcCarSeries();
$series = $AcCarSeries->find()->where(['id' => $res['series_id']])->one();
if($series){
$res['series_title'] = $series->title;
}
$AcCarBrand = new AcCarBrand();
$brand = $AcCarBrand->find()->where(['id' => $res['brand_id']])->one();
if($brand){
$res['brand_title'] = $brand->title;
}
$status = Yii::$app->params['CommonStatus'];
return $this->render('detail',['status'=>$status,'detail'=>$res]);
}
//保存车辆资料
public function actionSave()
{
$post = Yii::$app->request->post();
$id = (int)$post['id'];
$pid = Yii::$app->session->get('pid');
//格式化数据
//目标键=》POST键
$cols = ['title'=>'title','num_frame'=>'num_frame','num_p'=>'num_p','num_area'=>'num_area','num_left'=>'num_left'];
foreach($cols as $col=>$key){
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
}
//查询车牌号是否在库
$hasCar = false;
if(!$data['num_frame']){
$hasCar = AcCar::find()->where(['num_p'=>$data['num_p'],'num_area'=>$data['num_area'],'num_left'=>$data['num_left']])->one();
}
if($hasCar){
if($id && $id!=$hasCar->id){
\Yii::$app->getSession()->setFlash('danger', '保存失败,该车牌号已在库!');
return $this->goBack();
}else{
$id = $hasCar->id;
}
}
$cols = ['brand_id'=>'brand_id','series_id'=>'series_id','owner_id'=>'owner_id','status_code'=>'status_code','deleted'=>'deleted'];
foreach($cols as $col=>$key){
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
}
$cols = ['remark'=>'editor'];
foreach($cols as $col=>$key){
$data[$col] = isset($post[$key]) ? htmlspecialchars($post[$key]) : '';
}
$data['create_at'] = time();
$data['update_at'] = $data['create_at'];
// $data['status_code'] = 1;
$data['pid'] = $pid;
//填补mid参数
$AcCarOwner = new AcCarOwner();
$owner = $AcCarOwner->findOne($data['owner_id']);
if($owner){
$data['mid'] = $owner->mid;
}
//保存车辆资料
$AcCar = new AcCar();
foreach($data as $key=>$val){
$AcCar->$key = $val;
}
if($id){
$AcCar->id = $id;
unset($data['create_at']);
$res = $AcCar->updateAll($data,['id'=>$id]);
}else{
$res = $AcCar->save();
$id = $AcCar->attributes['id']; //获取插入后id
}
if($res){
\Yii::$app->getSession()->setFlash('success', '车辆资料保存成功!');
return $this->redirect(['edit','id'=>$id]);
}else{
\Yii::$app->getSession()->setFlash('warning', '车辆资料保存失败!');
return $this->goBack();
}
}
//删除车辆
public function actionDelete()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['pid'] = Yii::$app->session->get('pid');
$where['id'] = $id;
$data['update_at'] = time();
$data['deleted'] = 1;
$model = new AcCar();
foreach($data as $key=>$val){
$model->$key = $val;
}
$model->id = $id;
$res = $model->updateAll($data,$where);
$return = [];
$return['url'] = Url::toRoute('car/list');
$return['timeout'] = 3; //3秒后自动跳转
$return['status'] = 0;
if($res){
$return['msg'] = '车辆删除成功';
$return['errorcode'] = 200;
$return['data'] = $id;
}else{
$return['msg'] = '车辆删除失败';
$return['errorcode'] = 0;
}
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
public function actionAjax()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['pid'] = Yii::$app->session->get('pid');
$where['id'] = $id;
$data['update_at'] = time();
$model = new AcCar();
$res = $model->find()->where(['id' => $id])->one();
$return = [];
$return['timeout'] = 1; //3秒后自动跳转
// $return['status_code'] = 0;
$return['ajax'] = 1;
if($res){
$res = $res->toArray();
}else{
$return['msg'] = '车辆数据不存在';
$return['errorcode'] = 404;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
switch($get['do'])
{
case 'hide':
$data['status_code'] = 0;
$model->id = $id;
$res = $model->updateAll($data,$where);
if($res){
$return['msg'] = '车辆隐藏标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'default'];
}else{
$return['msg'] = '车辆隐藏标记失败';
$return['errorcode'] = 0;
}
break;
case 'show':
$data['status_code'] = 1;
$model->id = $id;
$res = $model->updateAll($data,$where);
if($res){
$return['msg'] = '车辆显示记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'primary'];
}else{
$return['msg'] = '车辆显示标记失败';
$return['errorcode'] = 0;
}
break;
default:
break;
}
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
}
+285
View File
@@ -0,0 +1,285 @@
<?php
/**
* @Author: fm453
* @Date: 2018-11-22 03:40:46
* @Last Modified by: fm453
* @Last Modified time: 2021-09-11 07:34:13
* @Email: fm453@lukegzs.com
*/
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\helpers\Url;
use addons\models\AcCarBrand;
class CarbrandController extends \yii\web\Controller
{
//替代常规的_construct 析构函数;其他方法调用前执行
public function init()
{
parent::init();
$session = Yii::$app->session;
if(isset($_GET['pid']) && (int)$_GET['pid']>0){
$session->set('pid',(int)$_GET['pid']);
}
$pid = $session->get('pid');
if(!$pid){
return Yii::$app->response->redirect(['index/index']);
}
}
//主界面
public function actionIndex()
{
global $_HI,$_FM;
return $this->render('../layouts/dev',[]);
}
//车品牌列表
public function actionList()
{
global $_HI,$_FM;
$pid = Yii::$app->session->get('pid');
$model = new AcCarBrand();
$where = $where2 = [];
$where2[]='and';
$where['pid'] = $pid;
$post = Yii::$app->request->post();
$search = [];
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
if(!empty($search['title'])){
$where2[] = ['LIKE','title',$search['title']];
}
$where['deleted'] = 0;
$data = $model->find()->where($where);
if($search['title']){
$data = $data->andwhere($where2);
}
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
$brands=[];
foreach($res as $s){
$s = $s->toArray();
$brands[$s['id']] = $s;
}
$status = Yii::$app->params['CommonStatus'];
return $this->render('list',[
'brands' => $brands,
'pager' => $pages,
'status'=>$status,
'search'=>$search
]);
}
//车品牌列表
public function actionSelect()
{
global $_HI,$_FM;
$pid = Yii::$app->session->get('pid');
$model = new AcCarBrand();
$where = $where2 = [];
$where2[]='and';
$where['pid'] = $pid;
$post = Yii::$app->request->post();
$search = [];
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
if(!empty($search['title'])){
$where2[] = ['LIKE','title',$search['title']];
}
$where['deleted'] = 0;
$data = $model->find()->where($where);
if($search['title']){
$data = $data->andwhere($where2);
}
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
$brands=[];
foreach($res as $s){
$s = $s->toArray();
$brands[$s['id']] = $s;
}
$status = Yii::$app->params['CommonStatus'];
$callback = !empty(Yii::$app->request->get('callback')) ? Yii::$app->request->get('callback') : 'car';
return $this->render('select',[
'brands' => $brands,
'pager' => $pages,
'status'=>$status,
'search'=>$search,
'callback'=>$callback
]);
}
//新增车品牌
public function actionNew()
{
global $_HI,$_FM;
$status = Yii::$app->params['CommonStatus'];
$AcCarBrand = new AcCarBrand();
$AcCarBrand->status_code = 0;
return $this->render('modify',['status'=>$status,'detail'=>$AcCarBrand->toArray()]);
}
//更新车品牌
public function actionEdit()
{
global $_HI,$_FM;
$model = new AcCarBrand();
$id = Yii::$app->request->get('id');
$pid = Yii::$app->session->get('pid');
$res = $model->find()->where(['id' => $id])->one();
if($res){
$res = $res->toArray();
}else{
$res = [];
}
$status = Yii::$app->params['CommonStatus'];
return $this->render('modify',[
'detail'=>$res,
'status'=>$status,
'id'=>$id,
]);
}
//保存车品牌资料
public function actionSave()
{
$post = Yii::$app->request->post();
$id = (int)$post['id'];
$pid = Yii::$app->session->get('pid');
//格式化数据
$data = [];
$data['title'] = trim($post['title']);
//目标键=》POST键
$cols = ['status_code'=>'status_code','deleted'=>'deleted'];
foreach($cols as $col=>$key){
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
}
$data['create_at'] = time();
$data['update_at'] = $data['create_at'];
$data['pid'] = $pid;
//格式化资料
$AcCarBrand = new AcCarBrand();
foreach($data as $key=>$val){
$AcCarBrand->$key = $val;
}
//资料入库
if($id){
$AcCarBrand->id = $id;
unset($data['create_at']);
$res = $AcCarBrand->updateAll($data,['id'=>$id]);
}else{
$res = $AcCarBrand->save();
$id = $AcCarBrand->attributes['id']; //获取插入后id
}
if($res){
\Yii::$app->getSession()->setFlash('success', '车主资料保存成功!');
return $this->redirect(['edit','id'=>$id]);
}else{
\Yii::$app->getSession()->setFlash('warning', '车主资料保存失败!');
return $this->goBack();
}
}
//删除用户
public function actionDelete($id)
{
global $_HI,$_FM;
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['pid'] = Yii::$app->session->get('pid');
$where['id'] = $id;
$data['update_at'] = time();
$data['deleted'] = 1;
$model = new AcCarBrand();
foreach($data as $key=>$val){
$model->$key = $val;
}
$model->id = $id;
$res = $model->updateAll($data,$where);
$return = [];
$return['url'] = Url::toRoute('carbrand/list');
$return['timeout'] = 3; //3秒后自动跳转
$return['status'] = 0;
if($res){
$return['msg'] = '删除成功';
$return['errorcode'] = 200;
$return['data'] = $id;
}else{
$return['msg'] = '删除失败';
$return['errorcode'] = 0;
}
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
public function actionAjax()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['pid'] = Yii::$app->session->get('pid');
$where['id'] = $id;
$data['update_at'] = time();
$model = new AcCarBrand();
$res = $model->find()->where(['id' => $id])->one();
$return = [];
$return['timeout'] = 1; //3秒后自动跳转
$return['status_code'] = 0;
$return['ajax'] = 1;
if($res){
$res = $res->toArray();
}else{
$return['msg'] = '品牌数据不存在';
$return['errorcode'] = 404;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
switch($get['do'])
{
case 'hide':
$data['status_code'] = 0;
$model->id = $id;
$res = $model->updateAll($data,$where);
if($res){
$return['msg'] = '品牌隐藏标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'info'];
}else{
$return['msg'] = '品牌隐藏标记失败';
$return['errorcode'] = 0;
}
break;
case 'show':
$data['status_code'] = 1;
$model->id = $id;
$res = $model->updateAll($data,$where);
if($res){
$return['msg'] = '品牌显示标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'default'];
}else{
$return['msg'] = '品牌显示标记失败';
$return['errorcode'] = 0;
}
break;
default:
break;
}
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
}
+675
View File
@@ -0,0 +1,675 @@
<?php
/**
* @Author: fm453
* @Date: 2018-11-22 03:40:46
* @Last Modified by: fm453
* @Last Modified time: 2021-09-11 10:10:32
* @Email: fm453@lukegzs.com
*/
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\helpers\Url;
use addons\models\AcCar;
use addons\models\AcCarOwner;
use addons\models\AcStore;
use addons\models\AcEmployee;
use addons\models\AcFansExt;
use common\models\Fans;
use common\models\CSms;
use common\models\CVcode;
use vendor\aliyun\dysms\Sms;
class CarownerController extends \yii\web\Controller
{
//替代常规的_construct 析构函数;其他方法调用前执行
public function init()
{
parent::init();
$session = Yii::$app->session;
if(isset($_GET['pid']) && (int)$_GET['pid']>0){
$session->set('pid',(int)$_GET['pid']);
}
$pid = $session->get('pid');
if(!$pid){
return Yii::$app->response->redirect(['index/index']);
}
}
//主界面
public function actionIndex()
{
global $_HI,$_FM;
return $this->render('../layouts/dev',[]);
}
//车主用户列表
public function actionList()
{
global $_HI,$_FM;
$pid = Yii::$app->session->get('pid');
$model = new AcCarOwner();
$where = $where2 = [];
$where2[]='and';
$where['pid'] = $pid;
$post = Yii::$app->request->post();
$search = [];
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
if(!empty($search['title'])){
$where2[] = ['LIKE','name',$search['title']];
}
$where['deleted'] = 0;
$data = $model->find()->where($where);
if($search['title']){
// $data = $data->andwhere($where2);
}
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->indexBy('mid')->all();
$status = Yii::$app->params['CommonStatus'];
$gender = Yii::$app->params['gender'];
$model = new AcStore();
$where = [];
$where['pid'] = $pid;
$_stores = $model->find()->where($where)->all();
$stores = [];
foreach($_stores as $s){
$stores[$s->id] = $s->toArray();
}
$eids = $mids = [];
foreach($res as $r){
$eids[$r['employee_id']] = $r['employee_id'];
$mids[$r['mid']] = $r['mid'];
}
$model = new AcEmployee();
$employees = [];
$_employees = $model->find()->where(['in','id',$eids])->indexBy('id')->all();
foreach($_employees as $s){
$employees[$s->id] = $s->toArray();
}
$model = new Fans();
$users = [];
$_users = $model->find()->where(['in','id',$mids])->all();
foreach($_users as $s){
$s = $s->toArray();
$users[$s['id']] = $s;
}
$model = new AcFansExt();
$exts = [];
$_exts = $model->find()->where(['in','mid',$mids])->andwhere(['pid'=>$pid,'deleted'=>0])->indexBy('id')->all();
foreach($_exts as $ext){
$ext = $ext->toArray();
if(isset($users[$s['id']])){
if($ext['mobile']==$users[$s['id']]['mobile']){
$exts[$ext['mid']][$ext['key']] = $ext['value'];
}
}
}
$owners = [];
foreach($res as $s){
$s = $s->toArray();
$owners[$s['id']] = $s;
}
return $this->render('list',[
'owners' => $owners,
'pager' => $pages,
'employees'=>$employees,
'stores'=>$stores,
'users'=>$users,
'exts'=>$exts,
'status'=>$status,
'gender'=>$gender,
'search'=>$search
]);
}
//车主用户选择
public function actionSelect()
{
global $_HI,$_FM;
$pid = Yii::$app->session->get('pid');
$model = new AcCarOwner();
$where = $where2 = [];
$where2[]='and';
$where['pid'] = $pid;
$post = Yii::$app->request->post();
$search = [];
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
if(!empty($search['title'])){
$where2[] = ['LIKE','name',$search['title']];
}
$where['deleted'] = 0;
$data = $model->find()->where($where);
if($search['title']){
// $data = $data->andwhere($where2);
}
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->indexBy('mid')->all();
$status = Yii::$app->params['CommonStatus'];
$gender = Yii::$app->params['gender'];
$model = new AcStore();
$where = [];
$where['pid'] = $pid;
$_stores = $model->find()->where($where)->all();
$stores = [];
foreach($_stores as $s){
$stores[$s->id] = $s->toArray();
}
$eids = $mids = [];
foreach($res as $r){
$eids[$r['employee_id']] = $r['employee_id'];
$mids[$r['mid']] = $r['mid'];
}
$model = new AcEmployee();
$employees = [];
$_employees = $model->find()->where(['in','id',$eids])->indexBy('id')->all();
foreach($_employees as $s){
$employees[$s->id] = $s->toArray();
}
$model = new Fans();
$users = [];
$_users = $model->find()->where(['in','id',$mids])->all();
foreach($_users as $s){
$s = $s->toArray();
$users[$s['id']] = $s;
}
$model = new AcFansExt();
$exts = [];
$_exts = $model->find()->where(['in','mid',$mids])->andwhere(['pid'=>$pid,'deleted'=>0])->indexBy('id')->all();
foreach($_exts as $ext){
$ext = $ext->toArray();
if(isset($users[$s['id']])){
if($ext['mobile']==$users[$s['id']]['mobile']){
$exts[$ext['mid']][$ext['key']] = $ext['value'];
}
}
}
$owners = [];
foreach($res as $s){
$s = $s->toArray();
if(isset($exts[$s['mid']])){
foreach($exts[$s['mid']] as $col=>$val){
$s[$col] = $val;
}
}
$owners[$s['id']] = $s;
}
$callback = !empty(Yii::$app->request->get('callback')) ? Yii::$app->request->get('callback') : 'carowner';
return $this->render('select',[
'owners' => $owners,
'pager' => $pages,
'employees'=>$employees,
'stores'=>$stores,
'users'=>$users,
'exts'=>$exts,
'status'=>$status,
'gender'=>$gender,
'search'=>$search,
'callback'=>$callback
]);
}
//新增车主
public function actionNew()
{
global $_HI,$_FM;
$levels = Yii::$app->params['customerLevels'];
return $this->render('modify',['levels'=>$levels]);
}
//更新车主
public function actionEdit()
{
global $_HI,$_FM;
$levels = Yii::$app->params['customerLevels'];
$model = new AcCarOwner();
$id = Yii::$app->request->get('id');
$pid = Yii::$app->session->get('pid');
$res = $model->find()->where(['id' => $id])->one();
if($res){
$res = $res->toArray();
$res['last_send'] = $res['last_send'] ? date('Y-m-d',$res['last_send']) : '';
$res['last_contact'] = $res['last_contact'] ? date('Y-m-d',$res['last_contact']) : '';
}else{
$res = [];
}
//查询对应的系统用户
$user = Fans::findIdentity($res['mid']);
$res['mobile'] = '';
if($user){
$res['mobile'] = $user->mobile;
}
$exts = AcFansExt::find()->where(['mid' => $res['mid'],'mobile' => $res['mobile'],'pid'=>$pid,'deleted'=>0])->all();
if($exts){
foreach($exts as $ext){
$res[$ext['key']] = $ext['value'];
}
}
$store = AcStore::find()->where(['id' => $res['store_id']])->one();
if($store){
$res['store_title'] = $store->title;
}
$employee = AcEmployee::find()->where(['id' => $res['employee_id']])->one();
if($employee){
$res['employee_title'] = $employee->name;
}
// memory_get_usage();//查看当前内存,字节
return $this->render('modify',[
'detail'=>$res,
'levels'=>$levels,
'id'=>$id,
]);
}
//保存车主资料
public function actionSave()
{
$post = Yii::$app->request->post();
$id = (int)$post['id'];
$pid = Yii::$app->session->get('pid');
if(!$post['mobile']){
\Yii::$app->getSession()->setFlash('warning', '请输入主手机号码!');
$url = Url::toRoute(['carowner/edit','id'=>$id]);
return $this->redirect(['modify','id'=>$id]);
}
$mobile = $post['mobile'];
//查询对应的系统用户
$userModel = new Fans();
$user = $userModel->findByUsername($mobile);
if(empty($user)){
$pwd = isset($post['password']) ? trim($post['password']) : Yii::$app->params['defaultFansPassword'];
$userModel->mobile = $mobile;
$userModel->email = $mobile.'@hiluker.com';
$userModel->setPassword($pwd);
$userModel->generateAuthKey();
$userModel->created_at = time();
$userModel->from = 'ctms';
$userModel->save();
$user_id = $userModel->attributes['id']; //获取插入后id
}else{
$user_id = $user->id;
}
/*保存扩展资料 S*/
$AcFansExt = new AcFansExt();
//批量硬删及软删
$AcFansExt->deleteAll(['deleted'=>2,'pid'=>$pid,'mid'=>$user_id]); //硬删,变更历史3次的
$AcFansExt->updateAllCounters(['deleted'=>1],['pid'=>$pid,'mid'=>$user_id]); //更新已有数据
//开始写入新传入的数据
$datas = [];
$data = [];
$cols = ['realname'=>'realname','nickname'=>'nickname','title'=>'title','password'=>'password','mobiles'=>'mobiles','thumb'=>'thumb','province'=>'province','idcard'=>'idcard'];
foreach($cols as $col=>$key){
$data['pid'] = $pid;
$data['mid'] = $user_id;
$data['key'] = $col;
$data['mobile'] = $mobile;
$data['value'] = isset($post[$key]) ? trim($post[$key]) : '';
$datas[] = $data;
}
//批量插入
$model = clone $AcFansExt;
foreach($datas as $attributes)
{
$model->isNewRecord = true;
$model->setAttributes($attributes,false);
$model->save() && $model->id=0;
}
/*保存扩展资料 E*/
//格式化数据
$data = [];
//目标键=》POST键
$cols = ['gender'=>'gender','total_fee'=>'total_fee','level'=>'level','score'=>'score','store_id'=>'store','employee_id'=>'employee','status_code'=>'status_code','deleted'=>'deleted'];
foreach($cols as $col=>$key){
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
}
$cols = ['last_send'=>'last_send','last_contact'=>'last_contact'];
foreach($cols as $col=>$key){
$data[$col] = isset($post[$key]) ? strtotime($post[$key]) : 0;
}
$cols = ['remark'=>'editor'];
foreach($cols as $col=>$key){
$data[$col] = isset($post[$key]) ? htmlspecialchars($post[$key]) : '';
}
$data['create_at'] = time();
$data['update_at'] = $data['create_at'];
$data['pid'] = $pid;
$data['mid'] = $user_id;
//格式化车主资料
$AcCarOwner = new AcCarOwner();
foreach($data as $key=>$val){
$AcCarOwner->$key = $val;
}
//查询该车主是否在库
$carOwner = AcCarOwner::find()->where(['pid'=>$data['pid'],'mid'=>$data['mid']])->one();
if($carOwner){
$id = $carOwner->id;
}
//车主资料入库
if($id){
$AcCarOwner->id = $id;
unset($data['create_at']);
$res = $AcCarOwner->updateAll($data,['id'=>$id]);
}else{
$res = $AcCarOwner->save();
$id = $AcCarOwner->attributes['id']; //获取插入后id
}
if($res){
\Yii::$app->getSession()->setFlash('success', '车主资料保存成功!');
return $this->redirect(['edit','id'=>$id]);
}else{
\Yii::$app->getSession()->setFlash('warning', '车主资料保存失败!');
return $this->goBack();
}
// $return = [];
// if($res){
// $return['msg'] = '车主信息保存成功';
// $return['errorcode'] = 200;
// $return['url'] = Url::toRoute(['carowner/edit','id'=>$id]);
// $return['buttons'] = [
// ['title'=>'好的,我知道了','class'=>'primary','url'=>$return['url']]
// ];
// }else{
// $return['msg'] = '车主信息保存失败';
// $return['errorcode'] = 0;
// $return['url'] = Url::toRoute(['carowner/new',$post]);
// $return['buttons'] = [
// ['title'=>'好的,我知道了','class'=>'info','url'=>$return['url']]
// ];
// }
// $classes = ['0'=>'warning','200'=>'success'];
// $return['content'] = $return['msg'];
// $return['class'] = $classes[$return['errorcode']];
// Yii::$app->request->setBodyParams($return);
// return Yii::$app->runAction('index/msg');
}
//删除用户
public function actionDelete($id)
{
global $_HI,$_FM;
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['pid'] = Yii::$app->session->get('pid');
$where['id'] = $id;
$data['update_at'] = time();
$data['deleted'] = 1;
$model = new AcCarOwner();
foreach($data as $key=>$val){
$model->$key = $val;
}
$model->id = $id;
$res = $model->updateAll($data,$where);
$return = [];
$return['url'] = Url::toRoute('carowner/list');
$return['timeout'] = 3; //3秒后自动跳转
$return['status'] = 0;
if($res){
$return['msg'] = '删除成功';
$return['errorcode'] = 200;
$return['data'] = $id;
}else{
$return['msg'] = '删除失败';
$return['errorcode'] = 0;
}
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
public function actionAjax()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['pid'] = Yii::$app->session->get('pid');
$where['id'] = $id;
$data['update_at'] = time();
$model = new AcCarOwner();
$res = $model->find()->where(['id' => $id])->one();
$return = [];
$return['timeout'] = 1; //3秒后自动跳转
$return['status_code'] = 0;
$return['ajax'] = 1;
if($res){
$res = $res->toArray();
}else{
$return['msg'] = '车主数据不存在';
$return['errorcode'] = 404;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
switch($get['do'])
{
case 'hide':
$data['status_code'] = 0;
$model->id = $id;
$res = $model->updateAll($data,$where);
if($res){
$return['msg'] = '车主隐藏标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'info'];
}else{
$return['msg'] = '车主隐藏标记失败';
$return['errorcode'] = 0;
}
break;
case 'show':
$data['status_code'] = 1;
$model->id = $id;
$res = $model->updateAll($data,$where);
if($res){
$return['msg'] = '车主显示标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'default'];
}else{
$return['msg'] = '车主显示标记失败';
$return['errorcode'] = 0;
}
break;
default:
break;
}
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
//短信营销
public function actionMsg()
{
global $_HI,$_FM;
$levels = Yii::$app->params['customerLevels'];
$model = new AcCarOwner();
$id = Yii::$app->request->get('id');
$pid = Yii::$app->session->get('pid');
$res = $model->find()->where(['id' => $id])->one();
if($res){
$res = $res->toArray();
$res['last_send'] = $res['last_send'] ? date('Y-m-d',$res['last_send']) : '';
$res['last_contact'] = $res['last_contact'] ? date('Y-m-d',$res['last_contact']) : '';
}else{
$res = [];
}
//查询对应的系统用户
$userModel = new Fans();
$user = Fans::find()->where(['id'=>$res['mid']])->one();
$res['mobile'] = '';
if($user){
$res['mobile'] = $user->mobile;
}
$exts = AcFansExt::find()->where(['mid' => $res['mid'],'mobile' => $res['mobile'],'pid'=>$pid,'deleted'=>0])->all();
if($exts){
foreach($exts as $ext){
$res[$ext['key']] = $ext['value'];
}
}
$store = AcStore::find()->where(['id' => $res['store_id']])->one();
if($store){
$res['store_title'] = $store->title;
}
$employee = AcEmployee::find()->where(['id' => $res['employee_id']])->one();
if($store){
$res['employee_title'] = $employee->name;
}
$op = Yii::$app->request->get('op');
$opp = Yii::$app->request->get('opp');
if(!$op){
return $this->render('msg',[
'detail'=>$res,
'levels'=>$levels,
'id'=>$id,
]);
}elseif($op=='send'){
$option = [];
$config = [];
$config['accessKeyId'] = Yii::$app->params['aliDySms']['accessKeyId'];
$config['accessKeySecret'] = Yii::$app->params['aliDySms']['accessKeySecret'];
$config['sign'] = Yii::$app->params['aliDySms']['sign'];
$sms = new Sms($option,$config);
$phone = $res['mobile'];
$content=[];
switch($opp){
case 'vcode': //发送验证码
$code = mt_rand(1000,9999);
$content['code'] = $code;
$tmpl = Yii::$app->params['aliDySms']['tmpl']['vcode'];
//验证码入库
$vcodeModel = new CVcode();
$vcode = [];
$vcode['code'] = $code;
$vcode['mobile'] = $phone;
$vcode['create_at'] = time();
foreach($vcode as $key=>$val){
$vcodeModel->$key = $val;
}
$vcodeModel->save();
break;
case 'birthday': //发送生日祝福
$realname = isset($res['realname'])?$res['realname']:'VIP';
$content['name'] = $realname;
$content['company'] = Yii::$app->request->post('company');
$content['company'] = $content['company'] ? $content['company'] : '安诚托车';
$tmpl = Yii::$app->params['aliDySms']['tmpl']['acBirthday'];
break;
}
$result = $sms->send($phone,$tmpl,$content);
//保存发送记录
$smsModel = new CSms();
$smsdata = [];
$sid = Yii::$app->session->get('sid');
$smsdata['sid'] = (int)$sid;
$smsdata['pid'] = $pid;
$smsdata['uid'] = Yii::$app->user->identity->id;
$smsdata['mobile'] = $phone;
$smsdata['content'] = json_encode($content,JSON_UNESCAPED_UNICODE);
$smsdata['create_at'] = time();
foreach($smsdata as $key=>$val){
$smsModel->$key = $val;
}
$smsModel->save();
$return = [];
$msg = '';
if(!$result){
$msg .= "【".$phone."】发送失败,接口提示:".$sms->errors."\r\n";
$return['errorcode'] = 0;
}elseif(is_array($result) && $result['Code'] !='OK'){
$msg .= "【".$phone."】发送失败,接口提示:".$result['Message']."\r\n";
$return['errorcode'] = 0;
}else{
$msg .= "【".$phone."】发送成功"."\r\n";
$return['errorcode'] = 0;
}
$return['msg'] = $msg;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
}
//信息摘要
public function actionInfo()
{
global $_HI,$_FM;
$levels = Yii::$app->params['customerLevels'];
$model = new AcCarOwner();
$id = Yii::$app->request->get('id');
$pid = Yii::$app->session->get('pid');
$res = $model->find()->where(['id' => $id])->one();
if($res){
$res = $res->toArray();
$res['last_send'] = $res['last_send'] ? date('Y-m-d',$res['last_send']) : '';
$res['last_contact'] = $res['last_contact'] ? date('Y-m-d',$res['last_contact']) : '';
}else{
$res = [];
}
//查询对应的系统用户
$userModel = new Fans();
$user = Fans::find()->where(['id'=>$res['mid']])->one();
$res['mobile'] = '';
if($user){
$res['mobile'] = $user->mobile;
}
$exts = AcFansExt::find()->where(['mid' => $res['mid'],'mobile' => $res['mobile'],'pid'=>$pid,'deleted'=>0])->all();
if($exts){
foreach($exts as $ext){
$res[$ext['key']] = $ext['value'];
}
}
$store = AcStore::find()->where(['id' => $res['store_id']])->one();
if($store){
$res['store_title'] = $store->title;
}
$employee = AcEmployee::find()->where(['id' => $res['employee_id']])->one();
if($store){
$res['employee_title'] = $employee->name;
}
return $this->render('info',[
'detail'=>$res,
'levels'=>$levels,
'id'=>$id,
]);
}
}
+357
View File
@@ -0,0 +1,357 @@
<?php
/**
* @Author: fm453
* @Date: 2018-11-22 03:40:46
* @Last Modified by: fm453
* @Last Modified time: 2021-09-11 07:37:06
* @Email: fm453@lukegzs.com
*/
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\helpers\Url;
use addons\models\AcCarBrand;
use addons\models\AcCarSeries;
class CarseriesController extends \yii\web\Controller
{
//替代常规的_construct 析构函数;其他方法调用前执行
public function init()
{
parent::init();
$session = Yii::$app->session;
if(isset($_GET['pid']) && (int)$_GET['pid']>0){
$session->set('pid',(int)$_GET['pid']);
}
$pid = $session->get('pid');
if(!$pid){
return Yii::$app->response->redirect(['index/index']);
}
}
//主界面
public function actionIndex()
{
global $_HI,$_FM;
return $this->render('../layouts/dev',[]);
}
//车型列表
public function actionList()
{
global $_HI,$_FM;
$pid = Yii::$app->session->get('pid');
$session = Yii::$app->session;
$model = new AcCarSeries();
$where = $where2 = [];
$where2[]='and';
$where2[] = ['in','pid',[0,$pid]];
$post = Yii::$app->request->post();
$search = [];
$searchSession = 'carseries::search';
if(isset($_GET['reset']) && $_GET['reset']==1){
$post['search'] = [];
}
if(isset($post['search'])){
$search = $post['search'];
$session->set($searchSession,$search);
}elseif($session->get($searchSession)){
$search = $session->get($searchSession);
}
$search['title'] = isset($search['title']) ? trim(htmlspecialchars_decode($search['title'])) : '';
if(!empty($search['title'])){
$where2[] = ['LIKE','title',$search['title']];
}
$search['brand'] = isset($search['brand_id']) ? trim(htmlspecialchars_decode($search['brand'])) : '';
$search['brand_id'] = isset($search['brand_id']) ? (int)$search['brand_id'] : 0;
if(!empty($search['brand_id'])){
$where['brand_id'] = $search['brand_id'];
}
$where['deleted'] = 0;
$data = $model->find()->where($where);
if($search['title']){
$data = $data->andwhere($where2);
}
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->indexBy('id')->all();
$status = Yii::$app->params['CommonStatus'];
$series = $bids = [];
foreach($res as $r){
$r = $r->toArray();
$series[$r['id']] = $r;
$bids[] = $r['brand_id'];
}
$AcCarBrand = new AcCarBrand();
$brands = [];
$_brands = $AcCarBrand->find()->where(['in','id',$bids])->indexBy('id')->all();
foreach($_brands as $s){
$brands[$s->id] = $s->toArray();
}
return $this->render('list',[
'series' => $series,
'pager' => $pages,
'brands'=>$brands,
'status'=>$status,
'search'=>$search
]);
}
//车型列表
public function actionSelect()
{
global $_HI,$_FM;
$pid = Yii::$app->session->get('pid');
$session = Yii::$app->session;
$model = new AcCarSeries();
$where = $where2 = [];
$where2[]='and';
$where2[] = ['in','pid',[0,$pid]];
$post = Yii::$app->request->post();
$search = [];
$searchSession = 'carseries::search';
if(isset($_GET['reset']) && $_GET['reset']==1){
$post['search'] = [];
}
if(isset($post['search'])){
$search = $post['search'];
$session->set($searchSession,$search);
}elseif($session->get($searchSession)){
$search = $session->get($searchSession);
}
$search['title'] = isset($search['title']) ? trim(htmlspecialchars_decode($search['title'])) : '';
if(!empty($search['title'])){
$where2[] = ['LIKE','title',$search['title']];
}
// $search['brand'] = isset($search['brand']) ? trim(htmlspecialchars_decode($search['brand'])) : '';
$search['brand'] = isset($search['brand_id']) ? trim(htmlspecialchars_decode($search['brand'])) : '';
$search['brand_id'] = isset($search['brand_id']) ? (int)$search['brand_id'] : 0;
if(!empty($search['brand_id'])){
$where['brand_id'] = $search['brand_id'];
}
$where['deleted'] = 0;
$data = $model->find()->where($where);
if($search['title']){
$data = $data->andwhere($where2);
}
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->indexBy('id')->all();
$status = Yii::$app->params['CommonStatus'];
$series = $bids = [];
foreach($res as $r){
$r = $r->toArray();
$series[$r['id']] = $r;
$bids[$r['brand_id']] = $r['brand_id'];
}
$AcCarBrand = new AcCarBrand();
$brands = [];
$_brands = $AcCarBrand->find()->where(['in','id',$bids])->indexBy('id')->all();
foreach($_brands as $s){
$brands[$s->id] = $s->toArray();
}
$callback = !empty(Yii::$app->request->get('callback')) ? Yii::$app->request->get('callback') : 'car';
return $this->render('select',[
'series' => $series,
'pager' => $pages,
'brands'=>$brands,
'status'=>$status,
'search'=>$search,
'callback'=>$callback
]);
}
//新增车型
public function actionNew()
{
global $_HI,$_FM;
$status = Yii::$app->params['CommonStatus'];
$AcCarSeries = new AcCarSeries();
$AcCarSeries->status_code = 0;
return $this->render('modify',['status'=>$status,'detail'=>$AcCarSeries->toArray()]);
}
//更新车型
public function actionEdit()
{
global $_HI,$_FM;
$status = Yii::$app->params['CommonStatus'];
$model = new AcCarSeries();
$id = Yii::$app->request->get('id');
$pid = Yii::$app->session->get('pid');
$res = $model->find()->where(['id' => $id])->one();
$parmas = [];
if($res){
$res = $res->toArray();
$parmas = json_decode($res['params'],true);
}else{
$res = [];
}
//查询对应的品牌
$brand = AcCarBrand::find()->where(['id' => $res['brand_id']])->one();
if($brand){
$res['brand_title'] = $brand->title;
}
return $this->render('modify',[
'detail'=>$res,
'params'=>$parmas,
'status'=>$status,
'id'=>$id,
]);
}
//保存车型资料
public function actionSave()
{
$post = Yii::$app->request->post();
$id = (int)$post['id'];
$pid = Yii::$app->session->get('pid');
//格式化数据
$data = [];
$data['title'] = trim($post['title']);
//目标键=》POST键
$cols = ['brand_id'=>'brand_id','status_code'=>'status_code','deleted'=>'deleted'];
foreach($cols as $col=>$key){
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
}
$params = $post['p'];
$cols = ['height','length','width','kg','seat'];
foreach($cols as $col){
$params[$col] = isset($params[$col]) ? (int)$params[$col] : 0;
}
$data['params'] = json_encode($params,JSON_UNESCAPED_UNICODE);
$data['create_at'] = time();
$data['update_at'] = $data['create_at'];
$data['pid'] = $pid;
//格式化车型资料
$AcCarSeries = new AcCarSeries();
foreach($data as $key=>$val){
$AcCarSeries->$key = $val;
}
//车型资料入库
if($id){
$AcCarSeries->id = $id;
unset($data['create_at']);
$res = $AcCarSeries->updateAll($data,['id'=>$id]);
}else{
$res = $AcCarSeries->save();
$id = $AcCarSeries->attributes['id']; //获取插入后id
}
if($res){
\Yii::$app->getSession()->setFlash('success', '车型资料保存成功!');
return $this->redirect(['edit','id'=>$id]);
}else{
\Yii::$app->getSession()->setFlash('warning', '车型资料保存失败!');
return $this->goBack();
}
}
//删除车型
public function actionDelete($id)
{
global $_HI,$_FM;
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['pid'] = Yii::$app->session->get('pid');
$where['id'] = $id;
$data['update_at'] = time();
$data['deleted'] = 1;
$model = new AcCarSeries();
foreach($data as $key=>$val){
$model->$key = $val;
}
$model->id = $id;
$res = $model->updateAll($data,$where);
$return = [];
$return['url'] = Url::toRoute('carowner/list');
$return['timeout'] = 3; //3秒后自动跳转
$return['status'] = 0;
if($res){
$return['msg'] = '删除成功';
$return['errorcode'] = 200;
$return['data'] = $id;
}else{
$return['msg'] = '删除失败';
$return['errorcode'] = 0;
}
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
public function actionAjax()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['pid'] = Yii::$app->session->get('pid');
$where['id'] = $id;
$data['update_at'] = time();
$model = new AcCarSeries();
$res = $model->find()->where(['id' => $id])->one();
$return = [];
$return['timeout'] = 1; //3秒后自动跳转
$return['status_code'] = 0;
$return['ajax'] = 1;
if($res){
$res = $res->toArray();
}else{
$return['msg'] = '车型数据不存在';
$return['errorcode'] = 404;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
switch($get['do'])
{
case 'hide':
$data['status_code'] = 0;
$model->id = $id;
$res = $model->updateAll($data,$where);
if($res){
$return['msg'] = '车型隐藏标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'info'];
}else{
$return['msg'] = '车型隐藏标记失败';
$return['errorcode'] = 0;
}
break;
case 'show':
$data['status_code'] = 1;
$model->id = $id;
$res = $model->updateAll($data,$where);
if($res){
$return['msg'] = '车型显示标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'default'];
}else{
$return['msg'] = '车型显示标记失败';
$return['errorcode'] = 0;
}
break;
default:
break;
}
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
}
+53
View File
@@ -0,0 +1,53 @@
<?php
/**
* @Author: fm453
* @Date: 2018-08-17 19:39:41
* @Last Modified by: fm453
* @Last Modified time: 2021-09-11 07:37:17
* @Email: fm453@lukegzs.com
*/
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\helpers\Url;
// use addons\models\Citys;
class CityController extends \yii\web\Controller
{
//替代常规的_construct 析构函数;其他方法调用前执行
public function init()
{
parent::init();
$session = Yii::$app->session;
if(isset($_GET['pid']) && (int)$_GET['pid']>0){
$session->set('pid',(int)$_GET['pid']);
}
$pid = $session->get('pid');
if(!$pid){
return Yii::$app->response->redirect(['index/index']);
}
}
//主界面
public function actionIndex()
{
return $this->render('../layouts/dev',[]);
}
public function actionSelect()
{
$citys = Yii::$app->params['citys'];
$pager = new Pagination(['totalCount' =>count($citys), 'pageSize' => '100']);
$callback = isset($_GET['callback']) ? $_GET['callback'] : 'city';
$search=[];
return $this->render('select',[
'citys'=>$citys,
'pager' => $pager,
'search'=>$search,
'callback'=>$callback
]);
}
}
+49
View File
@@ -0,0 +1,49 @@
<?php
#
# @Author: fm453
# @Date: 2024/7/16
# @updated: 上午8:48
# @Email: 1280880631@qq.com
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\helpers\Url;
use yii\web\Controller;
class Common extends Controller
{
protected $pid = 0;
public $postdata = [];
//替代常规的_construct 析构函数;其他方法调用前执行
public function init()
{
parent::init();
$get = Yii::$app->request->get();
$session = Yii::$app->session;
$this->pid = $session->get('pid');
if (!$this->pid) {
return Yii::$app->response->redirect(['index/index']);
}
//判断请求内容类型 content-type,支持 json请求
$postdata = Yii::$app->request->post();
$headers = Yii::$app->request->headers;
$contentType = $headers->get('content-type');
if ($contentType=="application/json") {
$postdata = json_decode(file_get_contents('php://input'), true);
}
$this->postdata = $postdata;
}
public function result($msg, $data=null, $code=0)
{
$return = [];
$return['code'] = $code;
$return['msg'] = $msg;
if ($data) {
$return['data'] = $data;
}
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
}
+308
View File
@@ -0,0 +1,308 @@
<?php
/**
* @Author: fm453
* @Date: 2018-08-17 19:39:41
# @Last modified by: fm453
# @Last modified time: 2021-09-14T19:14:12+08:00
* @Email: fm453@lukegzs.com
*/
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\helpers\Url;
use addons\models\AcContact;
use common\models\Fans;
class ContactController extends \yii\web\Controller
{
// 替代常规的_construct 析构函数;其他方法调用前执行
public function init()
{
parent::init();
$session = Yii::$app->session;
if(isset($_GET['pid']) && (int)$_GET['pid']>0){
$session->set('pid',(int)$_GET['pid']);
}
$pid = $session->get('pid');
if(!$pid){
return Yii::$app->response->redirect(['index/index']);
}
}
public function actionIndex()
{
return $this->render('index');
}
//通讯录列表
public function actionList()
{
$model = new AcContact();
$where = $where2 = [];
$pid = Yii::$app->session->get('pid');
$session = Yii::$app->session;
$post = Yii::$app->request->post();
$search = [];
$searchSession = 'contact::search';
if(isset($_GET['reset']) && $_GET['reset']==1){
$post['search'] = [];
}
if(isset($post['search'])){
$search = $post['search'];
$session->set($searchSession,$search);
}elseif($session->get($searchSession)){
$search = $session->get($searchSession);
}
$search['title'] = isset($search['title']) ? trim(htmlspecialchars_decode($search['title'])) : '';
if(!empty($search['title'])){
$where2[]='or';
$where2[] = ['LIKE','name',$search['title']];
$where2[] = ['LIKE','mobile',$search['title']];
}
$where['deleted'] = 0;
$data = $model->find()->where($where);
if($search['title']){
$data = $data->andwhere($where2);
}
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
$status = Yii::$app->params['CommonStatus'];
return $this->render('list',[
'contactors'=>$res,
'pager' => $pages,
'status'=>$status,
'search'=>$search
]);
}
public function actionSelect()
{
$model = new AcContact();
$pid = Yii::$app->session->get('pid');
$session = Yii::$app->session;
$where = $where2 = [];
$where['pid'] = $pid;
$post = Yii::$app->request->post();
$search = [];
$searchSession = 'contact::search';
if(isset($_GET['reset']) && $_GET['reset']==1){
$post['search'] = [];
}
if(isset($post['search'])){
$search = $post['search'];
$session->set($searchSession,$search);
}elseif($session->get($searchSession)){
$search = $session->get($searchSession);
}
$search['title'] = isset($search['title']) ? trim(htmlspecialchars_decode($search['title'])) : '';
if(!empty($search['title'])){
$where2[]='or';
$where2[] = ['LIKE','name',$search['title']];
$where2[] = ['LIKE','mobile',$search['title']];
}
$where['deleted'] = 0;
$data = $model->find()->where($where);
if($search['title']){
$data = $data->andwhere($where2);
}
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
$status = Yii::$app->params['CommonStatus'];
$callback = !empty(Yii::$app->request->get('callback')) ? Yii::$app->request->get('callback') : 'contactor';
return $this->render('select',[
'contactors'=>$res,
'pager' => $pages,
'status'=>$status,
'search'=>$search,
'callback'=>$callback
]);
}
public function actionNew()
{
return $this->render('modify',[]);
}
//编辑通讯录资料
public function actionEdit()
{
$model = new AcContact();
$id = Yii::$app->request->get('id');
$res = $model->find()->where(['id' => $id])->one();
if($res){
$res = $res->toArray();
}
return $this->render('modify',['detail'=>$res]);
}
//保存通讯录资料
public function actionSave()
{
$post = Yii::$app->request->post();
$id = (int)$post['id'];
$pid = Yii::$app->session->get('pid');
//格式化数据
//目标键=》POST键
$cols = ['company'=>'company','name'=>'name','mobile'=>'mobile','idcard'=>'idcard'];
foreach($cols as $col=>$key){
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
}
//查询通讯录手机号是否在库
$hasContactor = AcContact::find()->where(['mobile'=>$data['mobile']])->one();
if($hasContactor){
if($id && $id==$hasContactor->id){
}else{
$id = $hasContactor->id;
\Yii::$app->getSession()->setFlash('danger', '保存失败,该手机号对应的通讯录已在库,系统自动现在为您调出该通讯录资料!');
return $this->redirect(['edit','id'=>$id]);
}
}
//查询对应的系统用户
$userModel = new Fans();
$user = $userModel->findByUsername($data['mobile']);
if(empty($user)){
$pwd = Yii::$app->params['defaultFansPassword'];
$userModel->mobile = $data['mobile'];
$userModel->email = $data['mobile'].'@hiluker.com';
$userModel->setPassword($pwd);
$userModel->generateAuthKey();
$userModel->created_at = time();
$userModel->from = 'ctms';
$userModel->save();
}
$cols = ['status_code'=>'status_code','deleted'=>'deleted'];
foreach($cols as $col=>$key){
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
}
$data['create_at'] = time();
$data['update_at'] = $data['create_at'];
$data['pid'] = $pid;
//保存通讯录资料
$AcContact = new AcContact();
foreach($data as $key=>$val){
$AcContact->$key = $val;
}
if($id){
$AcContact->id = $id;
unset($data['create_at']);
$res = $AcContact->updateAll($data,['id'=>$id]);
}else{
$res = $AcContact->save();
$id = $AcContact->attributes['id']; //获取插入后id
}
if($res){
\Yii::$app->getSession()->setFlash('success', '通讯录信息保存成功!');
return $this->redirect(['edit','id'=>$id]);
}else{
\Yii::$app->getSession()->setFlash('warning', '通讯录信息保存失败!');
return $this->goBack();
}
}
//删除
public function actionDelete()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['pid'] = Yii::$app->session->get('pid');
$where['id'] = $id;
$data['update_at'] = time();
$data['deleted'] = 1;
$model = new AcContact();
foreach($data as $key=>$val){
$model->$key = $val;
}
$model->id = $id;
$res = $model->updateAll($data,$where);
$return = [];
$return['url'] = Url::toRoute('contact/list');
$return['timeout'] = 3; //3秒后自动跳转
$return['status'] = 0;
if($res){
$return['msg'] = '通讯录删除成功';
$return['errorcode'] = 200;
$return['data'] = $id;
}else{
$return['msg'] = '通讯录删除失败';
$return['errorcode'] = 0;
}
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
public function actionAjax()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['pid'] = Yii::$app->session->get('pid');
$where['id'] = $id;
$data['update_at'] = time();
$model = new AcContact();
$res = $model->find()->where(['id' => $id])->one();
$return = [];
$return['timeout'] = 1; //3秒后自动跳转
$return['status'] = 0;
$return['ajax'] = 1;
if($res){
$res = $res->toArray();
}else{
$return['msg'] = '通讯录数据不存在';
$return['errorcode'] = 404;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
switch($get['do'])
{
case 'out':
$data['status'] = 0;
$model->id = $id;
$res = $model->updateAll($data,$where);
if($res){
$return['msg'] = '通讯录隐藏标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'info'];
}else{
$return['msg'] = '通讯录隐藏标记失败';
$return['errorcode'] = 0;
}
break;
case 'in':
$data['status'] = 1;
$model->id = $id;
$res = $model->updateAll($data,$where);
if($res){
$return['msg'] = '通讯录显示标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'default'];
}else{
$return['msg'] = '通讯录显示标记失败';
$return['errorcode'] = 0;
}
break;
default:
break;
}
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
}
+287
View File
@@ -0,0 +1,287 @@
<?php
/**
* @Author: fm453
* @Date: 2018-08-17 19:39:41
# @Last modified by: fm453
# @Last modified time: 2021-09-15T10:22:53+08:00
* @Email: fm453@lukegzs.com
*/
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\helpers\Url;
use addons\models\AcDriver;
use common\models\Member;
class DriverController extends \yii\web\Controller
{
//替代常规的_construct 析构函数;其他方法调用前执行
public function init()
{
parent::init();
$session = Yii::$app->session;
if(isset($_GET['pid']) && (int)$_GET['pid']>0){
$session->set('pid',(int)$_GET['pid']);
}
$pid = $session->get('pid');
if(!$pid){
return Yii::$app->response->redirect(['index/index']);
}
}
public function actionIndex()
{
return $this->render('index');
}
//司机列表
public function actionList()
{
$model = new AcDriver();
$where = $where2 = [];
$where2[]='and';
$where['pid'] = Yii::$app->session->get('pid');
$post = Yii::$app->request->post();
$search = [];
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
if(!empty($search['title'])){
$where2[] = ['LIKE','name',$search['title']];
}
$where['deleted'] = 0;
$data = $model->find()->where($where);
if($search['title']){
$data = $data->andwhere($where2);
}
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->orderby('order_by DESC,id DESC')->all();
$status = Yii::$app->params['DriverStatus'];
return $this->render('list',[
'drivers'=>$res,
'pager' => $pages,
'status'=>$status,
'search'=>$search
]);
}
public function actionSelect()
{
$model = new AcDriver();
$where = $where2 = [];
$where2[]='and';
$where['pid'] = Yii::$app->session->get('pid');
$post = Yii::$app->request->post();
$search = [];
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
if(!empty($search['title'])){
$where2[] = ['LIKE','name',$search['title']];
}
$where['deleted'] = 0;
$data = $model->find()->where($where);
if($search['title']){
$data = $data->andwhere($where2);
}
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->orderby('order_by DESC,id DESC')->all();
$status = Yii::$app->params['DriverStatus'];
$callback = !empty(Yii::$app->request->get('callback')) ? Yii::$app->request->get('callback') : 'driver';
return $this->render('select',[
'drivers'=>$res,
'pager' => $pages,
'status'=>$status,
'search'=>$search,
'callback'=>$callback
]);
}
public function actionNew()
{
return $this->render('modify',[]);
}
//编辑司机资料
public function actionEdit()
{
$model = new AcDriver();
$id = Yii::$app->request->get('id');
$res = $model->find()->where(['id' => $id])->one();
if($res){
$res = $res->toArray();
}
return $this->render('modify',['detail'=>$res]);
}
//保存司机资料
public function actionSave()
{
$post = Yii::$app->request->post();
$id = (int)$post['id'];
$pid = Yii::$app->session->get('pid');
//格式化数据
//目标键=》POST键
$cols = ['name'=>'name','mobile'=>'mobile','idcard'=>'idcard'];
foreach($cols as $col=>$key){
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
}
//查询司机手机号是否在库
$hasDriver = AcDriver::find()->where(['mobile'=>$data['mobile']])->one();
if($hasDriver){
if($id && $id==$hasDriver->id){
}else{
$id = $hasDriver->id;
\Yii::$app->getSession()->setFlash('danger', '保存失败,该手机号对应的司机已在库,系统自动现在为您调出该司机资料!');
return $this->redirect(['edit','id'=>$id]);
}
}
$cols = ['status_code'=>'status_code','order_by'=>'order_by','deleted'=>'deleted'];
foreach($cols as $col=>$key){
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
}
$data['create_at'] = time();
$data['update_at'] = $data['create_at'];
$data['pid'] = $pid;
//保存司机资料
$AcDriver = new AcDriver();
foreach($data as $key=>$val){
$AcDriver->$key = $val;
}
if($id){
$AcDriver->id = $id;
unset($data['create_at']);
$res = $AcDriver->updateAll($data,['id'=>$id]);
}else{
$res = $AcDriver->save();
$id = $AcDriver->attributes['id']; //获取插入后id
}
//查询司机对应的系统用户
$MemberModel = new Member();
$user = $MemberModel->find()->where(['mobile'=>$data['mobile']])->one();
if(empty($user)){
$MemberModel->username = !$data['name'] ? $data['mobile'] : $data['name'];
$MemberModel->mobile = $data['mobile'];
$MemberModel->email = $data['mobile'].'@hiluker.com';
$MemberModel->setPassword(Yii::$app->params['defaultUserPassword']);
$MemberModel->generateAuthKey();
$MemberModel->avatar = Yii::$app->params['defaultUserAvatar'];
$MemberModel->created_at = time();
$MemberModel->status = 1;
$MemberModel->save();
$user_id = $MemberModel->attributes['id']; //获取插入后id
if($user_id)
{
\Yii::$app->getSession()->setFlash('info', '已成功注册该账号!');
}
}
if($res){
\Yii::$app->getSession()->setFlash('success', '司机信息保存成功!');
return $this->redirect(['edit','id'=>$id]);
}else{
\Yii::$app->getSession()->setFlash('warning', '司机信息保存失败!');
return $this->goBack();
}
}
//删除司机
public function actionDelete()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['pid'] = Yii::$app->session->get('pid');
$where['id'] = $id;
$data['update_at'] = time();
$data['deleted'] = 1;
$model = new AcDriver();
foreach($data as $key=>$val){
$model->$key = $val;
}
$model->id = $id;
$res = $model->updateAll($data,$where);
$return = [];
$return['url'] = Url::toRoute('driver/list');
$return['timeout'] = 3; //3秒后自动跳转
$return['status'] = 0;
if($res){
$return['msg'] = '司机删除成功';
$return['errorcode'] = 200;
$return['data'] = $id;
}else{
$return['msg'] = '司机删除失败';
$return['errorcode'] = 0;
}
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
public function actionAjax()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['pid'] = Yii::$app->session->get('pid');
$where['id'] = $id;
$data['update_at'] = time();
$model = new AcDriver();
$res = $model->find()->where(['id' => $id])->one();
$return = [];
$return['timeout'] = 1; //3秒后自动跳转
$return['status'] = 0;
$return['ajax'] = 1;
if($res){
$res = $res->toArray();
}else{
$return['msg'] = '司机数据不存在';
$return['errorcode'] = 404;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
switch($get['do'])
{
case 'out':
$data['status'] = 0;
$model->id = $id;
$res = $model->updateAll($data,$where);
if($res){
$return['msg'] = '司机离职标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'info'];
}else{
$return['msg'] = '司机离职标记失败';
$return['errorcode'] = 0;
}
break;
case 'in':
$data['status'] = 1;
$model->id = $id;
$res = $model->updateAll($data,$where);
if($res){
$return['msg'] = '司机在职标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'default'];
}else{
$return['msg'] = '司机在职标记失败';
$return['errorcode'] = 0;
}
break;
default:
break;
}
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
}
+315
View File
@@ -0,0 +1,315 @@
<?php
/**
* @Author: fm453
* @Date: 2018-12-02 11:40:44
* @Last Modified by: fm453
* @Last Modified time: 2021-09-11 08:19:06
* @Email: fm453@lukegzs.com
*/
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\helpers\Url;
use addons\models\AcEmployee;
use addons\models\AcStore;
use common\models\Member;
use addons\models\AcUserExt;
class EmployeeController extends \yii\web\Controller
{
//替代常规的_construct 析构函数;其他方法调用前执行
public function init()
{
parent::init();
$session = Yii::$app->session;
if(isset($_GET['pid']) && (int)$_GET['pid']>0){
$session->set('pid',(int)$_GET['pid']);
}
$pid = $session->get('pid');
if(!$pid){
return Yii::$app->response->redirect(['index/index']);
}
}
public function actionIndex()
{
return $this->render('index');
}
//用户列表
public function actionList()
{
$model = new AcEmployee();
$where = $where2 = [];
$where2[]='and';
$where['pid'] = Yii::$app->session->get('pid');
$post = Yii::$app->request->post();
$search = [];
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
if(!empty($search['title'])){
$where2[] = ['LIKE','name',$search['title']];
}
$where['deleted'] = 0;
$data = $model->find()->where($where);
if($search['title']){
$data = $data->andwhere($where2);
}
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->orderby('status DESC,order_by DESC,id ASC')->all();
$status = Yii::$app->params['EmployeeStatus'];
$gender = Yii::$app->params['gender'];
$model = new AcStore();
$where = [];
$where['pid'] = Yii::$app->session->get('pid');
$_stores = $model->find()->where($where)->all();
$stores = [];
foreach($_stores as $s){
$stores[$s->id] = $s->toArray();
}
return $this->render('list',[
'employees'=>$res,
'pager' => $pages,
'stores'=>$stores,
'status'=>$status,
'gender'=>$gender,
'search'=>$search
]);
}
public function actionSelect()
{
$model = new AcEmployee();
$where = $where2 = [];
$where2[]='and';
$where['pid'] = Yii::$app->session->get('pid');
$post = Yii::$app->request->post();
$search = [];
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
if(!empty($search['title'])){
$where2[] = ['LIKE','name',$search['title']];
}
$where['deleted'] = 0;
$data = $model->find()->where($where);
if($search['title']){
$data = $data->andwhere($where2);
}
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->orderby('status DESC,order_by DESC,id ASC')->all();
$status = Yii::$app->params['EmployeeStatus'];
$gender = Yii::$app->params['gender'];
$model = new AcStore();
$where = [];
$where['pid'] = Yii::$app->session->get('pid');
$_stores = $model->find()->where($where)->all();
$stores = [];
foreach($_stores as $s){
$stores[$s->id] = $s->toArray();
}
$callback = !empty(Yii::$app->request->get('callback')) ? Yii::$app->request->get('callback') : 'employee';
return $this->render('select',[
'employees'=>$res,
'pager' => $pages,
'stores'=>$stores,
'status'=>$status,
'gender'=>$gender,
'search'=>$search,
'callback'=>$callback
]);
}
public function actionNew()
{
return $this->render('modify',[]);
}
//编辑员工资料
public function actionEdit()
{
$model = new AcEmployee();
$id = Yii::$app->request->get('id');
$res = $model->find()->where(['id' => $id])->one();
if($res){
$res = $res->toArray();
}
$store = AcStore::find()->where(['id' => $res['store_id']])->one();
if($store){
$res['store_title'] = $store->title;
}
return $this->render('modify',['detail'=>$res]);
}
//保存员工资料
public function actionSave()
{
$post = Yii::$app->request->post();
$id = (int)$post['id'];
$pid = Yii::$app->session->get('pid');
//格式化数据
//目标键=》POST键
$cols = ['name'=>'name','mobile'=>'mobile'];
foreach($cols as $col=>$key){
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
}
$cols = ['gender'=>'gender','status'=>'status','store_id'=>'store','order_by'=>'order_by','deleted'=>'deleted'];
foreach($cols as $col=>$key){
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
}
$cols = ['remark'=>'editor'];
foreach($cols as $col=>$key){
$data[$col] = isset($post[$key]) ? htmlspecialchars($post[$key]) : '';
}
$data['create_at'] = time();
$data['update_at'] = $data['create_at'];
$data['status_code'] = 1;
$data['pid'] = $pid;
//保存员工资料
$AcEmployee = new AcEmployee();
foreach($data as $key=>$val){
$AcEmployee->$key = $val;
}
//查询员工手机号是否在库
$employee = AcEmployee::find()->where(['mobile'=>$data['mobile']])->one();
if($employee){
$id = $employee->id;
}
if($id){
$AcEmployee->id = $id;
unset($data['create_at']);
$res = $AcEmployee->updateAll($data,['id'=>$id]);
}else{
$res = $AcEmployee->save();
$id = $AcEmployee->attributes['id']; //获取插入后id
}
//查询员工对应的系统用户
$MemberModel = new Member();
$user = $MemberModel->find()->where(['mobile'=>$data['mobile']])->one();
if(empty($user)){
$MemberModel->username = !$data['name'] ? $data['mobile'] : $data['name'];
$MemberModel->mobile = $data['mobile'];
$MemberModel->email = $data['mobile'].'@hiluker.com';
$MemberModel->setPassword(Yii::$app->params['defaultUserPassword']);
$MemberModel->generateAuthKey();
$MemberModel->avatar = Yii::$app->params['defaultUserAvatar'];
$MemberModel->created_at = time();
$MemberModel->status = 1;
$MemberModel->save();
$user_id = $MemberModel->attributes['id']; //获取插入后id
if($user_id)
{
\Yii::$app->getSession()->setFlash('info', '已成功注册该账号!');
}
}
if($res){
\Yii::$app->getSession()->setFlash('success', '员工信息保存成功!');
return $this->redirect(['edit','id'=>$id]);
}else{
\Yii::$app->getSession()->setFlash('warning', '员工信息保存失败!');
return $this->goBack();
}
}
//删除员工
public function actionDelete()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['pid'] = Yii::$app->session->get('pid');
$where['id'] = $id;
$data['update_at'] = time();
$data['deleted'] = 1;
$model = new AcEmployee();
foreach($data as $key=>$val){
$model->$key = $val;
}
$model->id = $id;
$res = $model->updateAll($data,$where);
$return = [];
$return['url'] = Url::toRoute('employee/list');
$return['timeout'] = 3; //3秒后自动跳转
$return['status'] = 0;
if($res){
$return['msg'] = '员工删除成功';
$return['errorcode'] = 200;
$return['data'] = $id;
}else{
$return['msg'] = '员工删除失败';
$return['errorcode'] = 0;
}
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
public function actionAjax()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['pid'] = Yii::$app->session->get('pid');
$where['id'] = $id;
$data['update_at'] = time();
$model = new AcEmployee();
$res = $model->find()->where(['id' => $id])->one();
$return = [];
$return['timeout'] = 1; //3秒后自动跳转
$return['status'] = 0;
$return['ajax'] = 1;
if($res){
$res = $res->toArray();
}else{
$return['msg'] = '员工数据不存在';
$return['errorcode'] = 404;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
switch($get['do'])
{
case 'out':
$data['status'] = 0;
$model->id = $id;
$res = $model->updateAll($data,$where);
if($res){
$return['msg'] = '员工离职标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'info'];
}else{
$return['msg'] = '员工离职标记失败';
$return['errorcode'] = 0;
}
break;
case 'in':
$data['status'] = 1;
$model->id = $id;
$res = $model->updateAll($data,$where);
if($res){
$return['msg'] = '员工在职标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'default'];
}else{
$return['msg'] = '员工在职标记失败';
$return['errorcode'] = 0;
}
break;
default:
break;
}
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
}
+77
View File
@@ -0,0 +1,77 @@
<?php
/**
* @Author: fm453
* @Date: 2018-08-17 19:39:41
* @Last Modified by: fm453
* @Last Modified time: 2018-10-09 04:42:25
* @Email: fm453@lukegzs.com
*/
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\helpers\Url;
class ErrorController extends \yii\web\Controller
{
public $enableCsrfValidation = false; //取消csrf令牌验证;
//主界面
public function actionIndex()
{
return $this->render('../layouts/dev',[]);
}
public function actionReport()
{
$request = Yii::$app->request;
$get = $request->get();
$url = Urldecode($get['url']);
$code = 0;
if($request->isPost){
$code = getMillisecond().'_'.rand(0,999);
$filename = $code.'.php';
$post = $request->post();
$code = $post['code']!=0 ? $post['code'] : $code;
$post['time'] = time();
fm_load()->fm_func('error');
fmFunc_error_write($filename,$post);
$msg = [];
$msg['title'] = '报错提交通知';
$msg['content'] = '感谢反馈,工程师将尽快处理!您本次的反馈工单号为<code>'.$code.'</code>';
$msg['class'] = 'success';
$btn = [];
$btn['title'] = '返回';
// $btn['url'] = Url::current();
$btn['url'] = $url;
$btn['class'] = 'primary';
$msg['buttons'][] = $btn;
$btn = [];
$btn['title'] = '查看工单';
$btn['url'] = Url::toRoute(['error/order','code'=>$code]);
$btn['class'] = 'warning';
$msg['buttons'][] = $btn;
$btn = [];
$btn['title'] = '回到首页';
$btn['url'] = Url::home();
$btn['class'] = 'info';
$msg['buttons'][] = $btn;
return $this->render('../layouts/msg',$msg);
}
return $this->render('report',['url'=>$url]);
}
public function actionOrder()
{
$request = Yii::$app->request;
$get = $request->get();
$code = Urldecode($get['code']);
$filename = $code.'.php';
fm_load()->fm_func('error');
$data = [];
$file = fmFunc_error_get($code);
include $file;
return $this->render('report',['code'=>$code,'data'=>$data,'url'=>$data['url']]);
}
}
+47
View File
@@ -0,0 +1,47 @@
<?php
/**
* @Author: fm453
* @Date: 2018-08-17 19:39:41
# @Last modified by: fm453
# @Last modified time: 2021-09-15T16:02:21+08:00
* @Email: fm453@lukegzs.com
*/
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\helpers\Url;
use addons\models\AcFeeOrder;
use addons\models\AcFeeDriver;
use addons\models\AcOrder;
use addons\models\AcOrderPre;
use addons\models\AcOrderStatus;
use addons\models\AcStore;
use addons\models\AcEmployee;
use addons\models\AcPlat;
use common\models\CVcode;
class FeeController extends \yii\web\Controller
{
//替代常规的_construct 析构函数;其他方法调用前执行
public function init()
{
parent::init();
$session = Yii::$app->session;
if(isset($_GET['pid']) && (int)$_GET['pid']>0){
$session->set('pid',(int)$_GET['pid']);
}
$pid = $session->get('pid');
if(!$pid){
return Yii::$app->response->redirect(['index/index']);
}
}
//主界面
public function actionIndex()
{
return $this->render('@app/views/layouts/dev',[]);
}
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+381
View File
@@ -0,0 +1,381 @@
<?php
/**
* @Author: fm453
* @Date: 2018-08-17 19:39:41
* @Last Modified by: fm453
* @Last Modified time: 2021-09-11 07:41:00
* @Email: fm453@lukegzs.com
*/
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\helpers\Url;
use addons\models\AcTruck;
use addons\models\AcDriver;
use addons\models\AcTruckOnline;
use addons\models\AcTruckCars;
use addons\models\AcStore;
use addons\models\AcCar;
use addons\models\AcCarBrand;
use addons\models\AcCarSeries;
use addons\models\AcOrder;
use addons\models\AcGps;
use addons\models\AcGpsRoute;
use addons\models\AcTruckRoute;
class GpsController extends \yii\web\Controller
{
//替代常规的_construct 析构函数;其他方法调用前执行
public function init()
{
parent::init();
$session = Yii::$app->session;
if(isset($_GET['pid']) && (int)$_GET['pid']>0){
$session->set('pid',(int)$_GET['pid']);
}
$pid = $session->get('pid');
if(!$pid){
return Yii::$app->response->redirect(['index/index']);
}
$online_id = Yii::$app->request->get('online_id'); //发车任务ID
if(!$online_id){
$online_id = $session->get('online_id');
}else{
$session->set('online_id',$online_id);
}
if(!$online_id){
$post = Yii::$app->request->post();
$return = [];
$return['msg'] = '请先选择好要查看的出车大板';
$return['errorcode'] = 0;
// $return['url'] = Url::toRoute(['truckol/index',$post]);
// $return['buttons'] = [
// ['title'=>'好的,我知道了','class'=>'info','url'=>$return['url']]
// ];
$return['content'] = $return['msg'];
$return['class'] = 'warning';
Yii::$app->request->setBodyParams($return);
return Yii::$app->runAction('index/msg');
}
$truckol = $session->get('truckOnline');
$AcTruckOnline = new AcTruckOnline();
$res = true;
if(!$truckol){
$res = $AcTruckOnline->findOne($online_id);
if($res){
$truck_id = $res->truck_id;
$store_id = $res->from_store;
$store2_id = $res->end_store;
$truckol = $res->toArray();
$AcStore = new AcStore();
$store = $AcStore->findOne($store_id);
if($store){
$truckol['fromstore_title'] = $store->title;
}
$store2 = $AcStore->findOne($store2_id);
if($store2){
$truckol['endstore_title'] = $store2->title;
}
$session->set('truckOnline',$truckol);
}
}
if($online_id != $truckol['id']){
$res = $AcTruckOnline->findOne($online_id);
if($res){
$truck_id = $res->truck_id;
$store_id = $res->from_store;
$store2_id = $res->end_store;
$truckol = $res->toArray();
$AcStore = new AcStore();
$store = $AcStore->findOne($store_id);
if($store){
$truckol['fromstore_title'] = $store->title;
}
$store2 = $AcStore->findOne($store2_id);
if($store2){
$truckol['endstore_title'] = $store2->title;
}
$session->set('truckOnline',$truckol);
}
}
if(!$res){
$post = Yii::$app->request->post();
$return = [];
$return['msg'] = '请先选择好要查看的出车大板';
$return['errorcode'] = 0;
$return['url'] = Url::toRoute(['truckol/index',$post]);
$return['buttons'] = [
['title'=>'好的,我知道了','class'=>'info','url'=>$return['url']]
];
$return['content'] = $return['msg'];
$return['class'] = 'warning';
Yii::$app->request->setBodyParams($return);
return Yii::$app->runAction('index/msg');
}
}
//主界面
public function actionIndex()
{
return $this->render('index',[]);
}
//所有板车位置记录列表
public function actionList()
{
$pid = Yii::$app->session->get('pid');
$post = Yii::$app->request->post();
$online_id = Yii::$app->session->get('online_id'); //发车任务ID
$truckol = Yii::$app->session->get('truckOnline'); //发车任务
$AcTruckRoute = new AcTruckRoute();
$where = [];
$where[]='and';
$where[] = ['=','pid',Yii::$app->session->get('pid')];
if($online_id){
$where[] = ['=','online_id',$online_id];
}
$where[] = ['=','deleted',0];
$data = $AcTruckRoute->find()->where($where)->orderby('orderby ASC,id DESC');
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
$truck_ids = [];
foreach($res as $r){
$truck_ids[] = $r->truck_id;
}
$AcTruck = new AcTruck();
$where = [];
$where[] = 'and';
$where[] = ['=','pid',$pid];
$where[] = ['IN','id',$truck_ids];
$where[] = ['=','deleted',0];
$trucks = $AcTruck->find()->where($where)->indexby('id')->all();
$status = Yii::$app->params['CommonStatus'];
return $this->render('list',[
'list'=>$res,
'pager' => $pages,
'status'=>$status,
'trucks'=>$trucks,
'online_id'=>$online_id,
'truckol'=>$truckol
]);
}
public function actionNew()
{
$status = Yii::$app->params['CommonStatus'];
$AcTruckRoute = [];
$AcTruckRoute['status_code'] = 0;
$online_id = Yii::$app->session->get('online_id'); //发车任务ID
$truckol = Yii::$app->session->get('truckOnline'); //发车任务
$AcTruckRoute['truck_id'] = $truckol['truck_id'];
$AcTruckRoute['truck_num'] = $truckol['truck_num'];
return $this->render('modify',['status'=>$status,'detail'=>$AcTruckRoute,'online_id'=>$online_id,'truckol'=>$truckol]);
}
//编辑板车位置信息
public function actionEdit()
{
$id = Yii::$app->request->get('id'); //记录ID
$online_id = Yii::$app->session->get('online_id'); //发车任务ID
$truckol = Yii::$app->session->get('truckOnline'); //发车任务
$AcTruckRoute = new AcTruckRoute();
$route = $AcTruckRoute->findOne($id);
if(!$route){
$post = Yii::$app->request->post();
$return = [];
$return['msg'] = '位置记录数据获取异常,请重新选择获取';
$return['errorcode'] = 0;
$return['url'] = '';
$return['buttons'] = [
['title'=>'好的,我知道了','class'=>'info','url'=>$return['url']]
];
$return['content'] = $return['msg'];
$return['class'] = 'warning';
Yii::$app->request->setBodyParams($return);
return Yii::$app->runAction('index/msg');
}
$route = $route->toArray();
$route['truck_id'] = $truckol['truck_id'];
$route['online_id'] = $online_id;
$route['truck_num'] = $truckol['truck_num'];
$status = Yii::$app->params['CommonStatus'];
return $this->render('modify',['status'=>$status,'detail'=>$route,'online_id'=>$online_id,'truckol'=>$truckol]);
}
//保存位置记录信息
public function actionSave()
{
$post = Yii::$app->request->post();
$id = (int)$post['id'];
$pid = Yii::$app->session->get('pid');
$online_id = Yii::$app->session->get('online_id');
$truckol = Yii::$app->session->get('truckOnline'); //发车任务
$data = [];
$data['truck_id'] = $truckol['truck_id'];
$data['online_id'] = $online_id;
//格式化数据
//目标键=》POST键
$cols = ['longt'=>'lng','lat'=>'lat','addr'=>'addr'];
foreach($cols as $col=>$key){
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
}
$cols = ['orderby'=>'orderby','status_code'=>'status_code'];
foreach($cols as $col=>$key){
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
}
$_time = time();
$key = 'update_at';
$data[$key] = isset($post[$key]) ? strtotime($post[$key]) : $_time;
if(!$id){
$data['create_at'] = $_time;
}
$data['pid'] = $pid;
//保存位置资料
$AcTruckRoute = new AcTruckRoute();
foreach($data as $key=>$val){
$AcTruckRoute->$key = $val;
}
if($id){
$res = $AcTruckRoute->updateAll($data,['id'=>$id]);
}else{
$res = $AcTruckRoute->save();
$id = $AcTruckRoute->attributes['id']; //获取插入后id
}
if($res){
\Yii::$app->getSession()->setFlash('success', '信息保存成功!');
return $this->redirect(['edit','id'=>$id]);
}else{
\Yii::$app->getSession()->setFlash('warning', '信息保存失败!');
return $this->goBack();
}
}
//删除记录
public function actionDelete()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$pid = Yii::$app->session->get('pid');
$return = [];
$model = new AcTruckRoute();
$route = $model->findOne($id);
if(!$route){
$return['msg'] = '数据不存在,删除失败';
$return['errorcode'] = 404;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
if($route->pid !=$pid){
$return['msg'] = '非本平台数据,不允许操作';
$return['errorcode'] = 400;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
if($route->deleted !=0){
$return['msg'] = '数据已被删除过,操作无效';
$return['errorcode'] = 400;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
$route->deleted = 1;
$res = $route->save();
$return['url'] = '';
$return['timeout'] = 1; //n秒后自动跳转
$return['status'] = 0;
if($res){
$return['msg'] = '位置记录删除成功';
$return['errorcode'] = 200;
$return['data'] = $id;
}else{
$return['msg'] = '位置记录删除失败';
$return['errorcode'] = 0;
}
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
public function actionAjax()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$pid = Yii::$app->session->get('pid');
$return = [];
$model = new AcTruckRoute();
$route = $model->findOne($id);
if(!$route){
$return['msg'] = '数据不存在,删除失败';
$return['errorcode'] = 404;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
if($route->pid !=$pid){
$return['msg'] = '非本平台数据,不允许操作';
$return['errorcode'] = 400;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
if($route->deleted !=0){
$return['msg'] = '数据已被删除,操作无效';
$return['errorcode'] = 400;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
$return['timeout'] = 1; //n秒后自动跳转
$res = true;
switch($get['do'])
{
case 'show':
if($route->status_code!=1){
$route->status_code = 1;
$res = $route->save();
}
if($res){
$return['msg'] = '记录显示标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'success'];
}else{
$return['msg'] = '客车上板标记失败';
$return['errorcode'] = 0;
}
break;
case 'hide':
if($route->status_code!=0){
$route->status_code = 0;
$res = $route->save();
}
if($res){
$return['msg'] = '记录隐藏标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'success'];
}else{
$return['msg'] = '客车上板标记失败';
$return['errorcode'] = 0;
}
break;
default:
break;
}
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
}
+205
View File
@@ -0,0 +1,205 @@
<?php
/**
* @Author: fm453
* @Date: 2018-04-23 14:25:38
# @Last modified by: fm453
# @Last modified time: 2022-03-11T10:17:21+08:00
* @Email: fm453@lukegzs.com
*/
//主入口页
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\helpers\Url;
use addons\models\AcPlat;
use common\models\CLog;
class IndexController extends \yii\web\Controller
{
public $enableCsrfValidation = false;
//替代常规的_construct 析构函数;其他方法调用前执行
public function init()
{
parent::init();
$session = Yii::$app->session;
if(isset($_GET['pid']) && (int)$_GET['pid']>0){
$session->set('pid',(int)$_GET['pid']);
}
}
public function beforeAction($action){
$session = Yii::$app->session;
$pid = $session->get('pid');
if(!$pid){
$action->actionMethod='actionIndex';
$action->id='index';
}
return parent::beforeAction($action);
}
public function actionIndex()
{
$session = Yii::$app->session;
$platModel = new AcPlat();
$_plats = $platModel->find()->where(['status_code'=>1,'deleted'=>0])->orderby('orderby DESC')->all();
$plats = [];
if($_plats){
foreach($_plats as $p){
$plats[$p->id] = $p->toArray();
}
}else{
$plats[] = ['id'=>1,'title'=>'安诚捷顺','thumb'=>'http://public.hiluker.com/qichetuoyun/logo.png'];
}
if(isset($_GET['pid'])){
$pid = (int)$_GET['pid'];
if($pid>0){
$session->set('pid',$pid);
return $this->actionWelcome();
exit;
}else{
return $this->render('index',['plats'=>$plats]);
}
}
$pid = $session->get('pid');
if(!$pid){
return $this->render('index',['plats'=>$plats]);
}else{
return $this->actionWelcome();
}
}
public function actionWelcome()
{
//登录系统欢迎界面,显示入口集
global $_HI,$_FM;
$user_id=Yii::$app->user->identity->getId();
//登录记录
$query = CLog::find();
$nowTable = CLog::tablename();
$count = $query->count();
$pages = new Pagination(['totalCount' => $count,'pageSize' => '10']);
$log = $query->offset($pages->offset)
->limit($pages->limit)
->orderBy('id desc')
->all();
$sql = "SELECT *,FROM_UNIXTIME(create_time,'%Y-%m') as period,COUNT(*) as times FROM ".$nowTable." GROUP BY period LIMIT 12";
$History = Yii::$app->db->createCommand($sql)->queryAll();
$HistoryMonthStr = '';
$HistoryMonthNum = '';
foreach($History as $val){
$HistoryMonthStr .= "'".$val['period']."',";
$HistoryMonthNum .= $val['times'].",";
}
$HistoryMonthStr = substr($HistoryMonthStr,0,-1);
$HistoryMonthNum = substr($HistoryMonthNum,0,-1);
$keywords = '';
$description = '';
return $this->render('welcome',[
'log' => $log,
'pages' => $pages,
'HistoryMonthStr' => $HistoryMonthStr,
'HistoryMonthNum' => $HistoryMonthNum,
'keywords' => $keywords,
'description' => $description,
]);
}
public function actionMenus()
{
//登录系统欢迎界面,显示入口集
global $_HI,$_FM;
$user_id=Yii::$app->user->identity->getId();
$navs = array();
$entries = array();
$entries[] = array('name'=>'车主列表','title'=>'对所运车辆的车主用户信息进行管理','url'=>Url::toRoute('carowner/list'),'icon'=>'fa fa-user','class'=>'primary');
$entries[] = array('name'=>'新增车主','title'=>'新增加一个托车车主','url'=>Url::toRoute('carowner/new'),'icon'=>'fa fa-user-plus','class'=>'primary');
$entries[] = array('name'=>'客车列表','title'=>'全部客户车辆记录','url'=>Url::toRoute('car/list'),'icon'=>'fa fa-car','class'=>'primary');
$entries[] = array('name'=>'新增客车','title'=>'新增一条客户车辆记录','url'=>Url::toRoute('car/new'),'icon'=>'fa fa-edit','class'=>'primary');
$navs[] = array('name'=>'客户管理','entries'=>$entries);
$entries = array();
$entries[] = array('name'=>'合同列表','title'=>'点击查看全部已签合同单','url'=>Url::toRoute('order/list'),'icon'=>'fa fa-list','class'=>'primary');
$entries[] = array('name'=>'新签合同','title'=>'新签一份托车合同单','url'=>Url::toRoute('order/new'),'icon'=>'fa fa-pencil','class'=>'primary');
$entries[] = array('name'=>'装车安排','title'=>'板车装车任务管理','url'=>Url::toRoute('truckol/list'),'icon'=>'fa fa-hourglass-half fa-spin','class'=>'primary');
$entries[] = array('name'=>'出车单','title'=>'查看在途板车的出车清单','url'=>Url::toRoute('truckol/index'),'icon'=>'fa fa-list','class'=>'primary');
$entries[] = array('name'=>'咨询列表','title'=>'所有已记录咨询过的客户','url'=>Url::toRoute('orderpre/list'),'icon'=>'fa fa-calendar','class'=>'primary');
$entries[] = array('name'=>'记录咨询','title'=>'新记录一个客户咨询','url'=>Url::toRoute('orderpre/new'),'icon'=>'fa fa-calendar-plus-o','class'=>'primary');
$navs[] = array('name'=>'运单管理','entries'=>$entries);
$entries = array();
$entries[] = array('name'=>'相册列表','title'=>'全部验车相册记录','url'=>Url::toRoute('albums/list'),'icon'=>'fa fa-film','class'=>'primary');
$entries[] = array('name'=>'验商品车','title'=>'商品车提车验车','url'=>Url::toRoute('albums/newcar'),'icon'=>'fa fa-camera-retro','class'=>'primary');
$entries[] = array('name'=>'首发验车','title'=>'运单首发网点的验车记录','url'=>Url::toRoute(['albums/order','v'=>0]),'icon'=>'fa fa-camera','class'=>'primary');
$entries[] = array('name'=>'到站验车','title'=>'运单中转或到达网点的验车记录','url'=>Url::toRoute(['albums/order','v'=>1]),'icon'=>'fa fa-image','class'=>'primary');
$navs[] = array('name'=>'验车相册','entries'=>$entries);
$entries = array();
$entries[] = array('name'=>'运单费用','title'=>'所有运单相关的费用单据管理','url'=>Url::toRoute('feeorder/index'),'icon'=>'fa fa-book','class'=>'primary');
$entries[] = array('name'=>'待审运单','title'=>'所有等待财务确认的运单','url'=>Url::toRoute(['order/list','is_cwqr'=>0]),'icon'=>'fa fa-gavel','class'=>'primary');
$navs[] = array('name'=>'财务管理','entries'=>$entries);
$entries = array();
$entries[] = array('name'=>'网点列表','title'=>'对公司全部网点门店进行管理','url'=>Url::toRoute('store/list'),'icon'=>'fa fa-cubes','class'=>'primary');
$entries[] = array('name'=>'新增网点','title'=>'新增加一个网点','url'=>Url::toRoute('store/new'),'icon'=>'fa fa-cube','class'=>'primary');
$entries[] = array('name'=>'员工列表','title'=>'对公司各网点员工进行管理','url'=>Url::toRoute('employee/list'),'icon'=>'fa fa-venus-mars','class'=>'primary');
$entries[] = array('name'=>'新增员工','title'=>'新增员工','url'=>Url::toRoute('employee/new'),'icon'=>'fa fa-venus-double','class'=>'primary');
$entries[] = array('name'=>'板车管理','title'=>'公司板车列表','url'=>Url::toRoute('truck/list'),'icon'=>'fa fa-truck','class'=>'primary');
$entries[] = array('name'=>'司机管理','title'=>'公司板车司机列表','url'=>Url::toRoute('driver/list'),'icon'=>'fa fa-group','class'=>'primary');
$navs[] = array('name'=>'公司管理','entries'=>$entries);
$entries = array();
$entries[] = array('name'=>'H5端','title'=>'H5版管理端','url'=>Yii::$app->params['H5Links'].'index.html','icon'=>'fa fa-cubes','class'=>'primary');
$navs[] = array('name'=>'手机端','entries'=>$entries);
$entries = array();
$entries[] = array('name'=>'切换平台','title'=>'选择要管理的平台','url'=>Url::toRoute(['index/index','pid'=>0]),'icon'=>'fa fa-random','class'=>'primary');
if($user_id==1){
$entries[] = array('name'=>'平台列表','title'=>'选择管理平台或新增平台','url'=>Url::toRoute(['plat/list']),'icon'=>'fa fa-desktop','class'=>'primary');
}
$entries[] = array('name'=>'客车品牌','title'=>'新增或编辑小车的品牌','url'=>Url::toRoute('carbrand/list'),'icon'=>'fa fa-registered','class'=>'primary');
$entries[] = array('name'=>'车型参数','title'=>'新增或编辑小车各车系车型的基础参数','url'=>Url::toRoute('carseries/list'),'icon'=>'fa fa-pie-chart','class'=>'primary');
$navs[] = array('name'=>'平台管理','entries'=>$entries);
unset($entries);
$keywords = '';
$description = '';
return $this->render('menus',[
'navs' => $navs,
'keywords' => $keywords,
'description' => $description,
]);
}
public function actionMap()
{
$lat = (float) Yii::$app->request->get('lat');
$lng = (float) Yii::$app->request->get('lng');
if (empty($lat) || empty($lng)) {
$lat = 0;
$lng = 0;
}
$search = [];
$search['keyword'] = Yii::$app->request->get('title');
$callback = isset($_GET['callback']) ? $_GET['callback'] : 'showLatLng';
return $this->render('map',[
'lat'=>$lat,
'lng'=>$lng,
'search'=>$search,
'callback'=>$callback,
]);
}
public function actionMsg()
{
$params = Yii::$app->request->bodyParams;
return $this->render('../layouts/msg',$params);
}
}
+456
View File
@@ -0,0 +1,456 @@
<?php
#
# @Author: fm453
# @Date: 2024/7/16
# @updated: 下午3:55
# @Email: 1280880631@qq.com
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\helpers\Url;
use addons\models\AcNewsCat;
use addons\models\AcNews;
class NewsController extends Common{
public $enableCsrfValidation = false;
public function actionIndex(){
}
public function actionList(){
$options = $this->_tableOptions();
$columns = $options['columns'];
$operator = $options['operator'];
$tpl = 'list';
return $this->render($tpl, [
'columns' => json_encode($columns,JSON_UNESCAPED_UNICODE),
'operator' => json_encode($operator,JSON_UNESCAPED_UNICODE)
]);
}
public function actionSelect()
{
$pid = $this->pid;
$id = Yii::$app->request->get('id');
$callback = !empty(Yii::$app->request->get('callback')) ? Yii::$app->request->get('callback') : 'news';
if($id) $callback .= '-'.$id;
$options = $this->_tableOptions();
$columns = $options['columns'];
$operator = $options['operator'];
//不使用模板框架
// $this->layout = '@app/views/layouts/table';
$tpl = 'select';
return $this->render($tpl, [
'id' => $id,
'callback'=>$callback,
'columns' => json_encode($columns,JSON_UNESCAPED_UNICODE),
'operator' => json_encode($operator,JSON_UNESCAPED_UNICODE)
]);
}
public function actionNew()
{
$pid = $this->pid;
$tpl = 'modify';
return $this->render(
$tpl,
[
'detail'=>[],
'id'=>0
]
);
}
public function actionEdit()
{
$pid = $this->pid;
$post = $this->postdata;
$id = Yii::$app->request->get('id');
$AcNews = new AcNews();
$news = $AcNews->findOne($id);
$detail = $news->toArray();
if($detail['cid']){
$AcNewsCat = new AcNewsCat();
$cat = $AcNewsCat->findOne($detail['cid']);
if($cat){
$detail['cat_title'] = $cat->title;
}
}
$tpl = 'modify';
return $this->render(
$tpl,
[
'detail'=>$detail,
'id'=>$id
]
);
}
/*复制文章*/
public function actionCopy()
{
$pid = $this->pid;
$post = $this->postdata;
$id = Yii::$app->request->get('id');
$AcNews = new AcNews();
$news = $AcNews->findOne($id);
$detail = $news->toArray();
$detail['id'] = 0;
$tpl = 'modify';
return $this->render(
$tpl,
[
'detail'=>$detail
]
);
}
public function actionSave(){
$post = $this->postdata;
$id = isset($post['id']) ? (int)$post['id'] : 0;
$pid = Yii::$app->session->get('pid');
//格式化数据
//目标键=》POST键
$cols = ['title'=>'title','des'=>'des'];
foreach($cols as $col=>$key){
if(isset($post[$key])){
$data[$col] = trim($post[$key]);
}elseif(!$id){
$data[$col] = '';
}
}
$cols = ['content'=>'editor'];
foreach($cols as $col=>$key){
if(isset($post[$key])){
$data[$col] = htmlspecialchars($post[$key]);
}
}
$cols = ['orderby'=>'orderby','deleted'=>'deleted','cid'=>'cid','liked'=>'liked','reading'=>'reading','viewed'=>'viewed'];
foreach($cols as $col=>$key){
if(isset($post[$key])){
$data[$col] = (int)$post[$key];
}
}
$cols = ['is_show'=>'is_show'];
foreach($cols as $col=>$key){
if(!$id){
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 1;
}else{
if(isset($post[$col])){
$data[$col] = (int)$post[$key];
}
}
}
if(!$id){
$data['create_at'] = time();
}
$data['update_at'] = time();
$data['pid'] = $pid;
//保存
$msg = '数据保存失败';
$res = false;
$cpde = 0;
$model = new AcNews();
if($id){
$_rec = $model::findOne($id);
if($_rec){
foreach($data as $key=>$val){
$_rec->$key = $val;
}
$res = $_rec->save();
if($res){
$msg = '数据保存成功';
$code = 200;
}
}
}else{
foreach($data as $key=>$val){
$model->$key = $val;
}
$res = $model->save();
if($res){
$msg = '数据新增成功';
$id = $model->attributes['id']; //获取插入后id
$code = 200;
}
}
$data['id'] = $id;
$op = Yii::$app->request->get('op');
if($op){
return $this->redirect(['edit','id'=>$id]);
}
$this->result($msg,$data,200);
}
public function actionAjax(){
$op = $_GET['op']; //操作标识,只允许客户端GET传入
$post = $this->postdata;
$msg = '删除失败';
if(!isset($post['id'])){
$this->result($msg,$post,200);
}
$id = $post['id'];
$model = new AcNews();
$data = $model->findOne($id);
if(!$data){
$msg = '数据不存在,操作失败';
$this->result($msg,$post,200);
}
if($data->pid != $this->pid){
$msg = '归属平台不匹配,禁止操作';
$this->result($msg,$post,200);
}
switch($op){
case 'del':
if($data->deleted >0){
$msg = '数据已被删除过,操作无效';
$this->result($msg,$post,200);
}
$data->deleted += 1;
$_res = $data->save();
$msg = $_res ? '删除成功' : '操作失败,数据更新没有成功!';
$res = $data;
break;
default:
break;
}
$this->result($msg,$res,200);
}
public function actionJson()
{
$res = $this->search();
$list = $res['list'];
$ids = $res['ids'];
$pcats = $res['pcats'];
$cats = $res['cats'];
$newList = [];
foreach($ids as $id){
$row = $list[$id];
$row['cat_title'] = '';
if($row['cid']>0){
if(isset($cats[$row['cid']])){
$row['cat_title'] = $cats[$row['cid']]['title'];
}
}
$newList[] = $row;
}
$data = [];
$data['total'] = $res['total'];
$data['totalNotFiltered'] = $res['total'];
$data['rows'] = $newList;
header('Content-Type:application/json');
exit(json_encode($data,JSON_UNESCAPED_UNICODE)); //注意不要加强制object参数
}
private function search(){
$pid = $this->pid;
$session = Yii::$app->session;
$model = new AcNews();
$where = [];
$where[]='and';
$where[] = ['=','pid',$pid];
$post = $this->postdata;
$get = Yii::$app->request->get();
$searchSession = 'news::search';
if (isset($_GET['reset']) && $_GET['reset']==1) {
$post['search'] = [];
}
if (isset($post['search'])) {
$search = $post['search'];
$session->set($searchSession, $search);
} elseif ($session->get($searchSession)) {
$search = $session->get($searchSession);
}
$search['title'] = isset($search['title']) ? trim($search['title']) : '';
if (!empty($search['title'])) {
$where[] = ['LIKE','title',$search['title']];
}
$deleted = 0;
if (isset($_GET['deleted'])) {
$deleted = isset($_GET['deleted']) ? ((int)$_GET['deleted']>=0 ? 1 : 0) : 0;
}
$where[]=['=','deleted',$deleted];
$data = $model->find()->where($where);
$totalCount = $data->count();
$_orderby = 'orderby DESC';
$res = $data->orderby($_orderby)->all();
$list = $ids = $cids = $pcids = [];
$cats = $pcats = [];
if ($res) {
foreach ($res as $r) {
if($r->cid){
$cids[] = $r->cid;
}
$ids[] = $r->id;
$list[$r->id] = $r->toArray(); //内容按ID列出,以便后用
}
}
$CatModel = new AcNewsCat();
if($cids){
$res = $CatModel->find()->where(['IN','id',$cids])->all();
foreach ($res as $r) {
if($r->pcat_id){
$pcids[]= $r->pcat_id;
}
$cats[$r->id] = $r;
}
if($pcids){
$res = $CatModel->find()->where(['IN','id',$pcids])->all();
foreach ($res as $r) {
$pcats[$r->id] = $r;
}
}
}
$data = [];
$data['total'] = $totalCount;
$data['totalNotFiltered'] = $totalCount;
$data['cats'] = $cats;
$data['pcats'] = $pcats;
$data['list'] = $list;
$data['ids'] = $ids;
return $data;
}
private function _tableOptions(){
$columns = [];
$columns['id'] = [
'field'=>'id',
'title'=>'ID',
'footerFormatter'=>'CountTotalFooter',
'searchable'=>false
];
$columns['cat'] = [
'field'=>'cid',
'title'=>'分类',
'class'=>"resize_able",
'formatter'=>'catFormatter',
'filterControl'=>"select",
'sortable'=>true,
'searchable'=>true
];
$columns['title'] = [
'field'=>'title',
'title'=>'标题',
'class'=>"resize_able",
'editable'=>'textEditor',
'formatter'=>'textFormatter',
'searchFormatter'=>true,
'searchHighlightFormatter'=>'customSearchFmt',
'filterControl'=>"input",
'searchable'=>true
];
$columns['des'] = [
'field'=>'des',
'title'=>'简述',
'editable'=>'textEditor',
'formatter'=>'textFormatter',
'searchFormatter'=>true,
'searchHighlightFormatter'=>'customSearchFmt',
'searchable'=>true
];
$columns['orderby'] = [
'field'=>'orderby',
'title'=>'排序',
'editable'=>'textEditor',
'formatter'=>'numFormatter',
'sortable'=>true,
'searchable'=>true
];
$columns['viewCount'] = [
'field'=>'viewed',
'title'=>'浏览量',
'formatter'=>'numFormatter',
'footerFormatter'=>'NumCountFooter',
'sortable'=>true,
'searchable'=>false
];
$columns['likeCount'] = [
'field'=>'liked',
'title'=>'收藏量',
'formatter'=>'numFormatter',
'footerFormatter'=>'NumCountFooter',
'sortable'=>true,
'searchable'=>false
];
$columns['readingCount'] = [
'field'=>'reading',
'title'=>'在看',
'formatter'=>'numFormatter',
'footerFormatter'=>'NumCountFooter',
'sortable'=>true,
'searchable'=>false
];
$columns['isShow'] = [
'field'=>'is_show',
'title'=>'显示',
'editable'=>'textEditor',
'formatter'=>'yesnoFormatter',
'filterControl'=>"select",
'sortable'=>true,
'searchable'=>false
];
$columns['create_at'] = [
'field'=>'create_at',
'title'=>'创建日期',
'formatter'=>'dateFormatter',
'sortable'=>true,
'searchable'=>false
];
$columns['update_at'] = [
'field'=>'update_at',
'title'=>'更新时间',
'formatter'=>'timeFormatter',
'sortable'=>true,
'searchable'=>false
];
$operator = [];
$operator['showDetail'] = [
'class'=>'view',
'title'=>'概览',
'icon'=>'eye',
'func'=>false
];
$operator['save'] = [
'class'=>'save',
'title'=>'保存',
'icon'=>'save',
'func'=>false
];
$operator['remove'] = [
'class'=>'remove',
'title'=>'移除',
'icon'=>'trash',
'func'=>false
];
$operator['edit'] = [
'class'=>'href',
'title'=>'编辑',
'icon'=>'pencil',
'func'=>false
];
return [
'columns' => $columns,
'operator' => $operator
];
}
}
@@ -0,0 +1,447 @@
<?php
# @Author: fm453
# @Date: 2024/7/16
# @updated: 下午3:55
# @Email: 1280880631@qq.com
namespace backend\controllers;
use addons\models\AcNewsCat;use Yii;
class NewscatController extends Common{
public $enableCsrfValidation = false;
public function actionIndex(){}
public function actionList()
{
$options = $this->_tableOptions();
$columns = $options['columns'];
$operator = $options['operator'];
$tpl = 'list';
return $this->render($tpl, [
'columns' => json_encode($columns,JSON_UNESCAPED_UNICODE),
'operator' => json_encode($operator,JSON_UNESCAPED_UNICODE)
]);
}
private function _tableOptions(){
$columns = [];
$columns['id'] = [
'field'=>'id',
'title'=>'ID',
'align'=>'center',
'vlign'=>'middle',
'halign'=>'center',
'width'=>30,
'widthUnit'=>'px',
'footerFormatter'=>'CountTotalFooter',
'sortable'=>true,
'searchable'=>false
];
$columns['pcat_id'] = [
'field'=>'pcat_id',
'title'=>'上级分类',
'align'=>'center',
'vlign'=>'middle',
'halign'=>'center',
'width'=>120,
'widthUnit'=>'px',
'class'=>"resize_able",
'formatter'=>'catFormatter',
'filterControl'=>"select",
'sortable'=>true,
'searchable'=>false
];
$columns['pcat_title'] = [
'field'=>'pcat_title',
'title'=>'上级分类',
'align'=>'center',
'vlign'=>'middle',
'halign'=>'center',
'width'=>150,
'widthUnit'=>'px',
'class'=>"resize_able",
'filterControl'=>"select",
'visible'=>false,
'sortable'=>true,
'searchable'=>false
];
$columns['title'] = [
'field'=>'title',
'title'=>'标题',
'align'=>'center',
'vlign'=>'middle',
'halign'=>'center',
// 'width'=>120,
// 'widthUnit'=>'px',
'class'=>"resize_able",
'cellStyle'=>'cellStyle',
'editable'=>'textEditor',
//该列可编辑
'formatter'=>'textFormatter',
// 'filterControl'=>"input",
'searchFormatter'=>true,
'searchHighlightFormatter'=>'customSearchFmt',
'searchable'=>true
];
$columns['des'] = [
'field'=>'des',
'title'=>'简述',
'align'=>'center',
'vlign'=>'middle',
'halign'=>'center',
// 'width'=>120,
// 'widthUnit'=>'px',
'titleTooltip'=>'英文简写的代码,后期用于权限判断等场景',
'class'=>"resize_able",
'cellStyle'=>'cellStyle',
'editable'=>'textEditor',
'formatter'=>'textFormatter',
// 'filterControl'=>"select",
'searchFormatter'=>true,
'searchHighlightFormatter'=>'customSearchFmt',
'searchable'=>true
];
$columns['orderby'] = [
'field'=>'orderby',
'title'=>'排序',
'width'=>40,
'widthUnit'=>'px',
'editable'=>'textEditor',
'formatter'=>'numFormatter',
'sortable'=>true,
'searchable'=>false
];
$columns['create_at'] = [
'field'=>'create_at',
'title'=>'创建日期',
'formatter'=>'dateFormatter',
'sortable'=>true,
'searchable'=>false
];
$columns['update_at'] = [
'field'=>'update_at',
'title'=>'更新时间',
'formatter'=>'timeFormatter',
'sortable'=>true,
'searchable'=>false
];
$operator = [];
$operator['showDetail'] = [
'class'=>'view',
'title'=>'概览',
'icon'=>'eye',
'func'=>false
];
$operator['save'] = [
'class'=>'save',
'title'=>'保存',
'icon'=>'save',
'func'=>false
];
$operator['remove'] = [
'class'=>'remove',
'title'=>'移除',
'icon'=>'trash',
'func'=>false
];
return [
'columns' => $columns,
'operator' => $operator
];
}
public function actionSelect()
{
/**
* 选择分类
* @id [int] 来源页的元素数据唯一标识ID
* @cid [int] 来源页的传入的已迁选中的分类ID
* @callback [string] 来源页的元素标签标识
*/
$pid = $this->pid;
$id = Yii::$app->request->get('id');
$callback = !empty(Yii::$app->request->get('callback')) ? Yii::$app->request->get('callback') : 'newsCat';
if($id) $callback .= '-'.$id;
$cid = Yii::$app->request->get('cid');
$options = $this->_tableOptions();
$columns = $options['columns'];
unset($columns['pcat_title']);
$operator = $options['operator'];
$operator['select'] = [
'class'=>'select',
'title'=>'选择',
'icon'=>'check-square-o',
'func'=>false
];
unset($operator['remove']);
//不使用模板框架
// $this->layout = '@app/views/layouts/table';
$tpl = 'select';
return $this->render($tpl, [
'id' => $id,
'selected_id'=>$cid,
'columns' => json_encode($columns,JSON_UNESCAPED_UNICODE),
'operator' => json_encode($operator,JSON_UNESCAPED_UNICODE),
'callback'=>$callback
]);
}
public function actionPcat(){
/**
* 选择上级分类
* @id [int] 当前来源子类ID
*/
$pid = $this->pid;
$id = Yii::$app->request->get('id');
$model = new AcNewsCat();
$cat = $model->findOne($id);
$pcat_id = 0;
if($cat->pcat_id) $pcat_id = $cat->pcat_id;
$callback = !empty(Yii::$app->request->get('callback')) ? Yii::$app->request->get('callback') : 'newsCat';
if($id) $callback .= '-'.$id;
$options = $this->_tableOptions();
$columns = $options['columns'];
unset($columns['pcat_title']);
$operator = $options['operator'];
$operator['select'] = [
'class'=>'select',
'title'=>'选择',
'icon'=>'check-square-o',
'func'=>false
];
unset($operator['remove']);
//不使用模板框架
// $this->layout = '@app/views/layouts/table';
$tpl = 'pcat';
return $this->render($tpl, [
'id' => $id,
'selected_id'=>$pcat_id,
'columns' => json_encode($columns,JSON_UNESCAPED_UNICODE),
'operator' => json_encode($operator,JSON_UNESCAPED_UNICODE),
'callback'=>$callback
]);
}
public function actionJson(){
$res = $this->Search();
$list = $res['list'];
$ids = $res['ids'];
$totalCount = $res['total'];
$pcats = $res['pcats'];
$cats = $res['cats'];
$newList = [];
foreach($ids as $id){
$row = $list[$id];
if($row['pcat_id']){
$row['pcat_title'] = $list[$row['pcat_id']]['title'];
}
$newList[] = $row;
}
//客户端表格类型 bootstrapTable 或 dataTable;
// $table_type = "dataTable";
$table_type = "bootstrapTable";
$data = [];
if($table_type=="dataTable"){
$data['draw'] = 1; //客户端表是否需要重绘
$data['recordsTotal'] = $totalCount;
$data['recordsFiltered'] = $totalCount;
$data['pcats'] = $pcats;
$data['cats'] = $cats;
$data['data'] = $newList;
} elseif($table_type=="bootstrapTable"){
$data['total'] = $totalCount;
$data['totalNotFiltered'] = $totalCount;
$data['pcats'] = $pcats;
$data['cats'] = $cats;
$data['rows'] = $newList;
}
header('Content-Type:application/json');
exit(json_encode($data,JSON_UNESCAPED_UNICODE)); //注意不要加强制object参数
}
private function search(){
$pid = $this->pid;
$session = Yii::$app->session;
$model = new AcNewsCat();
$where = [];
$where[]='and';
$where[] = ['=','pid',$pid];
$post = $this->postdata;
$get = Yii::$app->request->get();
$searchSession = 'newscat::search';
if (isset($_GET['reset']) && $_GET['reset']==1) {
$post['search'] = [];
}
if (isset($post['search'])) {
$search = $post['search'];
$session->set($searchSession, $search);
} elseif ($session->get($searchSession)) {
$search = $session->get($searchSession);
}
$search['title'] = isset($search['title']) ? trim($search['title']) : '';
if (!empty($search['title'])) {
$where[] = ['LIKE','title',$search['title']];
}
$deleted = 0;
if (isset($_GET['deleted'])) {
$deleted = isset($_GET['deleted']) ? ((int)$_GET['deleted']>=0 ? 1 : 0) : 0;
}
$where[]=['=','deleted',$deleted];
$data = $model->find()->where($where);
$totalCount = $data->count();
$_orderby = 'orderby DESC';
$res = $data->orderby($_orderby)->all();
$list = $cids = $pcids = [];
$cats = $pcats = [];
if ($res) {
foreach ($res as $r) {
if($r->pcat_id){
//重排数组,保留查询结果的排序
$pcids[] = $r->pcat_id; //父类
$cids[$r->pcat_id][] = $r->id; //子分类,按父类分组
}else{
$cids['0'][] = $r->id; //无父类的
}
$ids[] = $r->id;
$list[$r->id] = $r->toArray(); //内容按ID列出,以便后用
}
}
if($pcids){
foreach ($pcids as $pcid) {
$pcats[] = $list[$pcid];
foreach($cids[$pcid] as $k=>$id){
$cats[$pcid][] = $list[$id];
}
}
foreach($cids as $pcid=>$ccids){
foreach($ccids as $k=>$id){
$cats[$pcid][] = $list[$id];
}
}
}
return ['ids'=>$ids,'list'=>$list,'total'=>$totalCount,'pcats'=>$pcats,'cats'=>$cats];
}
public function actionSave(){
$post = $this->postdata;
$id = isset($post['id']) ? (int)$post['id'] : 0;
$pid = Yii::$app->session->get('pid');
//格式化数据
//目标键=》POST键
$cols = ['title'=>'title','des'=>'des'];
foreach($cols as $col=>$key){
if(isset($post[$key])){
$data[$col] = trim($post[$key]);
}elseif(!$id){
$data[$col] = '';
}
}
$cols = ['orderby'=>'orderby','deleted'=>'deleted','pcat_id'=>'pcat_id'];
foreach($cols as $col=>$key){
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
}
$cols = ['is_show'=>'is_show'];
foreach($cols as $col=>$key){
if(!$id){
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 1;
}elseif(isset($post[$col])){
$data[$col] = (int)$post[$key];
}
}
if(!$id){
$data['create_at'] = time();
}
$data['update_at'] = time();
$data['pid'] = $pid;
//保存
$msg = '数据保存失败';
$res = false;
$cpde = 0;
$model = new AcNewsCat();
if($id){
$_rec = $model::findOne($id);
if($_rec){
foreach($data as $key=>$val){
$_rec->$key = $val;
}
$_rec->id = $id;
$res = $_rec->save();
if($res){
$msg = '数据保存成功';
$code = 200;
}
}
}else{
foreach($data as $key=>$val){
$model->$key = $val;
}
$res = $model->save();
if($res){
$msg = '数据新增成功';
$id = $model->attributes['id']; //获取插入后id
$code = 200;
}
}
$data['id'] = $id;
$this->result($msg,$data,200);
}
public function actionAjax(){
$op = $_GET['op']; //操作标识,只允许客户端GET传入
$post = $this->postdata;
$msg = '删除失败';
if(!isset($post['id'])){
$this->result($msg,$post,200);
}
$id = $post['id'];
$model = new AcNewsCat();
$data = $model->findOne($id);
if(!$data){
$msg = '数据不存在,操作失败';
$this->result($msg,$post,200);
}
if($data->pid != $this->pid){
$msg = '归属平台不匹配,禁止操作';
$this->result($msg,$post,200);
}
switch($op){
case 'del':
if($data->deleted >0){
$msg = '数据已被删除过,操作无效';
$this->result($msg,$post,200);
}
$data->deleted += 1;
$_res = $data->save();
$msg = $_res ? '删除成功' : '操作失败,数据更新没有成功!';
$res = $data;
break;
default:
break;
}
$this->result($msg,$res,200);
}
}
@@ -0,0 +1,308 @@
<?php
# @Author: fm453
# @Date: 2024/7/16
# @updated: 下午3:55
# @Email: 1280880631@qq.com
namespace backend\controllers;
use addons\models\AcNewsCat;use Yii;
class NewscatController extends Common{
public $enableCsrfValidation = false;
public function actionIndex(){}
public function actionList()
{
global $_HI,$_FM;
$pid = $this->pid;
$session = Yii::$app->session;
$model = new AcNewsCat();
$where = [];
$where[]='and';
$where[] = ['=','pid',$pid];
$post = Yii::$app->request->post();
$get = Yii::$app->request->get();
$searchSession = 'newscat::search';
if (isset($_GET['reset']) && $_GET['reset']==1) {
$post['search'] = [];
}
if (isset($post['search'])) {
$search = $post['search'];
$session->set($searchSession, $search);
} elseif ($session->get($searchSession)) {
$search = $session->get($searchSession);
}
$search['title'] = isset($search['title']) ? trim($search['title']) : '';
if (!empty($search['title'])) {
$where[] = ['LIKE','title',$search['title']];
}
$deleted = 0;
if (isset($_GET['deleted'])) {
$deleted = isset($_GET['deleted']) ? ((int)$_GET['deleted']>=0 ? 1 : 0) : 0;
}
$where[]=['=','deleted',$deleted];
$data = $model->find()->where($where);
$_orderby = 'orderby DESC';
$res = $data->orderby($_orderby)->all();
$list = $cids = $pcids = [];
$cats = $pcats = [];
if ($res) {
foreach ($res as $r) {
if($r->pcat_id){
//重排数组,保留查询结果的排序
$pcids[] = $r->pcat_id; //父类
$cids[$r->pcat_id][] = $r->id; //子分类
}
$list[$r->id] = $r->toArray(); //内容按ID列出,以便后用
}
}
if($pcids){
foreach ($pcids as $pcid) {
$pcats[] = $list[$pcid];
}
foreach($cids as $pcid=>$ids){
foreach($ids as $id){
$cats[$pcid][] = $list[$id];
}
}
}
//不使用模板框架
// $this->layout = '@app/views/layouts/table';
$tpl = 'datatable';
$tpl = 'table';
return $this->render($tpl, [
'cats' => $cats,
'pcats' => $pcats,
'search'=>$search
]);
}
public function actionSelect()
{
$pid = $this->pid;
$id = Yii::$app->request->get('id');
$callback = !empty(Yii::$app->request->get('callback')) ? Yii::$app->request->get('callback') : 'newsCat';
if($id) $callback .= '-'.$id;
//不使用模板框架
// $this->layout = '@app/views/layouts/table';
$tpl = 'select';
return $this->render($tpl, [
'id' => $id,
'callback'=>$callback
]);
}
public function actionPcat(){
/**
* 选择上级分类
* @id [int] 当前来源子类ID
*/
$pid = $this->pid;
$id = Yii::$app->request->get('id');
$callback = !empty(Yii::$app->request->get('callback')) ? Yii::$app->request->get('callback') : 'newsCat';
if($id) $callback .= '-'.$id;
//不使用模板框架
// $this->layout = '@app/views/layouts/table';
$tpl = 'select';
return $this->render($tpl, [
'id' => $id,
'callback'=>$callback
]);
}
public function actionJson(){
$pid = $this->pid;
$session = Yii::$app->session;
$model = new AcNewsCat();
$where = [];
$where[]='and';
$where[] = ['=','pid',$pid];
$post = $this->postdata;
$get = Yii::$app->request->get();
$searchSession = 'newscat::search';
if (isset($_GET['reset']) && $_GET['reset']==1) {
$post['search'] = [];
}
if (isset($post['search'])) {
$search = $post['search'];
$session->set($searchSession, $search);
} elseif ($session->get($searchSession)) {
$search = $session->get($searchSession);
}
$search['title'] = isset($search['title']) ? trim($search['title']) : '';
if (!empty($search['title'])) {
$where[] = ['LIKE','title',$search['title']];
}
$deleted = 0;
if (isset($_GET['deleted'])) {
$deleted = isset($_GET['deleted']) ? ((int)$_GET['deleted']>=0 ? 1 : 0) : 0;
}
$where[]=['=','deleted',$deleted];
$data = $model->find()->where($where);
$totalCount = $data->count();
$_orderby = 'orderby DESC';
$res = $data->orderby($_orderby)->all();
$list = $ids = $cids = $pcids = [];
$cats = $pcats = $newList = [];
if ($res) {
foreach ($res as $r) {
if($r->pcat_id){
//重排数组,保留查询结果的排序
$pcids[] = $r->pcat_id; //父类
$cids[$r->pcat_id][] = $r->id; //子分类,按父类分组
}else{
$cids['0'][] = $r->id; //无父类的
}
$ids[] = $r->id;
$list[$r->id] = $r->toArray(); //内容按ID列出,以便后用
}
}
if($pcids){
foreach ($pcids as $pcid) {
$pcats[] = $list[$pcid];
foreach($cids[$pcid] as $k=>$id){
$cats[$pcid][] = $list[$id];
}
}
foreach($cids as $pcid=>$ccids){
foreach($ccids as $k=>$id){
$cats[$pcid][] = $list[$id];
}
}
}
if(isset($post['id']) && (int)$post['id']){
$id = (int)$post['id'];
if($list[$id]){
$list[$id]['no_edit'] = $list[$id]['_isUnselectable'] = 1;
if($list[$id]['pcat_id']){
$list[$id]['_isSelected'] = 1;
}
}
}
foreach($ids as $id){
$row = $list[$id];
if($row['pcat_id']){
$row['pcat_title'] = $list[$row['pcat_id']]['title'];
}
$newList[] = $row;
}
//客户端表格类型 bootstrapTable 或 dataTable;
// $table_type = "dataTable";
$table_type = "bootstrapTable";
$data = [];
if($table_type=="dataTable"){
$data['draw'] = 1; //客户端表是否需要重绘
$data['recordsTotal'] = $totalCount;
$data['recordsFiltered'] = $totalCount;
$data['pcats'] = $pcats;
$data['cats'] = $cats;
$data['data'] = $newList;
} elseif($table_type=="bootstrapTable"){
$data['total'] = $totalCount;
$data['totalNotFiltered'] = $totalCount;
$data['pcats'] = $pcats;
$data['cats'] = $cats;
$data['rows'] = $newList;
}
header('Content-Type:application/json');
exit(json_encode($data,JSON_UNESCAPED_UNICODE)); //注意不要加强制object参数
}
public function actionSave(){
$post = $this->postdata;
$id = isset($post['id']) ? (int)$post['id'] : 0;
$pid = Yii::$app->session->get('pid');
//格式化数据
//目标键=》POST键
$cols = ['title'=>'title','des'=>'des'];
foreach($cols as $col=>$key){
if(isset($post[$key])){
$data[$col] = trim($post[$key]);
}elseif(!$id){
$data[$col] = '';
}
}
$cols = ['orderby'=>'orderby','deleted'=>'deleted','pcat_id'=>'pcat_id'];
foreach($cols as $col=>$key){
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
}
$cols = ['is_show'=>'is_show'];
foreach($cols as $col=>$key){
if(!$id){
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 1;
}elseif(isset($post[$col])){
$data[$col] = (int)$post[$key];
}
}
if(!$id){
$data['create_at'] = time();
}
$data['update_at'] = time();
$data['pid'] = $pid;
//保存
$msg = '数据保存失败';
$res = false;
$cpde = 0;
$model = new AcNewsCat();
if($id){
$_rec = $model::findOne($id);
if($_rec){
foreach($data as $key=>$val){
$_rec->$key = $val;
}
$_rec->id = $id;
$res = $_rec->save();
if($res){
$msg = '数据保存成功';
$code = 200;
}
}
}else{
foreach($data as $key=>$val){
$model->$key = $val;
}
$res = $model->save();
if($res){
$msg = '数据新增成功';
$id = $model->attributes['id']; //获取插入后id
$code = 200;
}
}
$data['id'] = $id;
$this->result($msg,$data,200);
}
public function actionAjax(){
$op = $_GET['op']; //操作标识,只允许客户端GET传入
$post = $this->postdata;
$res = [];
switch($op){
case 'del':
$msg = '软删除,假定成功';
$res = $post;
break;
default:
break;
}
$this->result($msg,$res,200);
}
}
+346
View File
@@ -0,0 +1,346 @@
<?php
#
# @Author: fm453
# @Date: 2024/7/16
# @updated: 下午3:55
# @Email: 1280880631@qq.com
namespace backend\controllers;
use addons\models\AcNotice;use Yii;
class NoticeController extends Common{
public $enableCsrfValidation = false;
public function actionIndex(){
}
public function actionList(){
$options = $this->_tableOptions();
$columns = $options['columns'];
$operator = $options['operator'];
$tpl = 'list';
return $this->render($tpl, [
'columns' => json_encode($columns,JSON_UNESCAPED_UNICODE),
'operator' => json_encode($operator,JSON_UNESCAPED_UNICODE)
]);
}
private function _tableOptions(){
$columns = [];
$columns['id'] = [
'field'=>'id',
'title'=>'ID',
'footerFormatter'=>'CountTotalFooter',
'searchable'=>false
];
$columns['title'] = [
'field'=>'title',
'title'=>'标题',
'class'=>"resize_able",
'editable'=>'textEditor',
'formatter'=>'textFormatter',
'searchFormatter'=>true,
'searchHighlightFormatter'=>'customSearchFmt',
'filterControl'=>"input",
'searchable'=>true
];
$columns['content'] = [
'field'=>'content',
'title'=>'内容',
'editable'=>'textEditor',
'formatter'=>'textFormatter',
'searchFormatter'=>true,
'searchHighlightFormatter'=>'customSearchFmt',
'searchable'=>true
];
$columns['isShow'] = [
'field'=>'is_show',
'title'=>'显示',
'editable'=>'textEditor',
'formatter'=>'yesnoFormatter',
'filterControl'=>"select",
'sortable'=>true,
'searchable'=>false
];
$columns['create_at'] = [
'field'=>'create_at',
'title'=>'创建日期',
'formatter'=>'dateFormatter',
'sortable'=>true,
'searchable'=>false
];
$columns['update_at'] = [
'field'=>'update_at',
'title'=>'更新时间',
'formatter'=>'timeFormatter',
'sortable'=>true,
'searchable'=>false
];
$operator = [];
$operator['showDetail'] = [
'class'=>'view',
'title'=>'概览',
'icon'=>'eye',
'func'=>false
];
$operator['save'] = [
'class'=>'save',
'title'=>'保存',
'icon'=>'save',
'func'=>false
];
$operator['remove'] = [
'class'=>'remove',
'title'=>'移除',
'icon'=>'trash',
'func'=>false
];
return [
'columns' => $columns,
'operator' => $operator
];
}
public function actionSelect()
{
$pid = $this->pid;
$id = Yii::$app->request->get('id');
$callback = !empty(Yii::$app->request->get('callback')) ? Yii::$app->request->get('callback') : 'news';
if($id) $callback .= '-'.$id;
$options = $this->_tableOptions();
$columns = $options['columns'];
$operator = $options['operator'];
//不使用模板框架
// $this->layout = '@app/views/layouts/table';
$tpl = 'select';
return $this->render($tpl, [
'id' => $id,
'callback'=>$callback,
'columns' => json_encode($columns,JSON_UNESCAPED_UNICODE),
'operator' => json_encode($operator,JSON_UNESCAPED_UNICODE)
]);
}
public function actionNew()
{
$pid = $this->pid;
$tpl = 'modify';
return $this->render(
$tpl,
[
'detail'=>[],
'id'=>0
]
);
}
public function actionEdit()
{
$pid = $this->pid;
$post = $this->postdata;
$id = Yii::$app->request->get('id');
$AcNotice = new AcNotice();
$notice = $AcNotice->findOne($id);
$detail = $notice->toArray();
$tpl = 'modify';
return $this->render(
$tpl,
[
'detail'=>$detail,
'id'=>$id
]
);
}
public function actionSave(){
$post = $this->postdata;
$id = isset($post['id']) ? (int)$post['id'] : 0;
$pid = Yii::$app->session->get('pid');
//格式化数据
//目标键=》POST键
$cols = ['title'=>'title','content'=>'content'];
foreach($cols as $col=>$key){
if(isset($post[$key])){
$data[$col] = trim($post[$key]);
}elseif(!$id){
$data[$col] = '';
}
}
$cols = ['deleted'=>'deleted'];
foreach($cols as $col=>$key){
if(isset($post[$key])){
$data[$col] = (int)$post[$key];
}elseif(!$id){
$data[$col] = 0;
}
}
$cols = ['is_show'=>'is_show'];
foreach($cols as $col=>$key){
if(!$id){
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 1;
}else{
if(isset($post[$col])){
$data[$col] = (int)$post[$key];
}
}
}
if(!$id){
$data['create_at'] = time();
}
$data['update_at'] = time();
$data['pid'] = $pid;
//保存
$msg = '数据保存失败';
$res = false;
$cpde = 0;
$model = new AcNotice();
if($id){
$_rec = $model::findOne($id);
if($_rec){
foreach($data as $key=>$val){
$_rec->$key = $val;
}
$res = $_rec->save();
if($res){
$msg = '数据保存成功';
$code = 200;
}
}
}else{
foreach($data as $key=>$val){
$model->$key = $val;
}
$res = $model->save();
if($res){
$msg = '数据新增成功';
$id = $model->attributes['id']; //获取插入后id
$code = 200;
}
}
$data['id'] = $id;
$op = Yii::$app->request->get('op');
if($op){
return $this->redirect(['edit','id'=>$id]);
}
$this->result($msg,$data,200);
}
public function actionAjax(){
$op = $_GET['op']; //操作标识,只允许客户端GET传入
$post = $this->postdata;
$res = [];
$msg = '删除失败';
if(!isset($post['id'])){
$this->result($msg,$post,200);
}
$id = $post['id'];
$model = new AcNotice();
$data = $model->findOne($id);
if(!$data){
$msg = '数据不存在,操作失败';
$this->result($msg,$post,200);
}
if($data->pid != $this->pid){
$msg = '归属平台不匹配,禁止操作';
$this->result($msg,$post,200);
}
switch($op){
case 'del':
if($data->deleted >0){
$msg = '数据已被删除过,操作无效';
$this->result($msg,$post,200);
}
$data->deleted += 1;
$_res = $data->save();
$msg = $_res ? '删除成功' : '操作失败,数据更新没有成功!';
$res = $data;
break;
default:
break;
}
$this->result($msg,$res,200);
}
public function actionJson()
{
$res = $this->search();
$list = $res['list'];
$ids = $res['ids'];
$newList = [];
foreach($ids as $id){
$row = $list[$id];
$newList[] = $row;
}
$data = [];
$data['total'] = $res['total'];
$data['totalNotFiltered'] = $res['total'];
$data['rows'] = $newList;
header('Content-Type:application/json');
exit(json_encode($data,JSON_UNESCAPED_UNICODE)); //注意不要加强制object参数
}
private function search(){
$pid = $this->pid;
$session = Yii::$app->session;
$model = new AcNotice();
$where = [];
$where[]='and';
$where[] = ['=','pid',$pid];
$post = $this->postdata;
$get = Yii::$app->request->get();
$searchSession = 'notice::search';
if (isset($_GET['reset']) && $_GET['reset']==1) {
$post['search'] = [];
}
if (isset($post['search'])) {
$search = $post['search'];
$session->set($searchSession, $search);
} elseif ($session->get($searchSession)) {
$search = $session->get($searchSession);
}
$search['title'] = isset($search['title']) ? trim($search['title']) : '';
if (!empty($search['title'])) {
$where[] = ['LIKE','title',$search['title']];
}
$deleted = 0;
if (isset($_GET['deleted'])) {
$deleted = isset($_GET['deleted']) ? ((int)$_GET['deleted']>=0 ? 1 : 0) : 0;
}
$where[]=['=','deleted',$deleted];
$data = $model->find()->where($where);
$totalCount = $data->count();
$_orderby = 'id ASC';
$res = $data->orderby($_orderby)->all();
$list = $ids = [];
if ($res) {
foreach ($res as $r) {
$ids[] = $r->id;
$list[$r->id] = $r->toArray(); //内容按ID列出,以便后用
}
}
$data = [];
$data['total'] = $totalCount;
$data['totalNotFiltered'] = $totalCount;
$data['list'] = $list;
$data['ids'] = $ids;
return $data;
}
}
File diff suppressed because it is too large Load Diff
+862
View File
@@ -0,0 +1,862 @@
<?php
/**
* @Author: fm453
* @Date: 2018-08-17 19:39:41
* @Email: fm453@lukegzs.com
*/
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\helpers\Url;
use addons\models\AcCar;
use addons\models\AcCarOwner;
use addons\models\AcCarBrand;
use addons\models\AcCarSeries;
use addons\models\AcStore;
use addons\models\AcEmployee;
use addons\models\AcOrder;
use addons\models\AcOrderPre;
use addons\models\AcOrderStatus;
use addons\models\AcPlat;
use common\models\CVcode;
use addons\models\AcContact;
use common\models\Member as User;
use addons\models\AcUserExt;
use common\models\Fans;
use addons\models\AcFansExt;
class OrderpreController extends Common
{
//替代常规的_construct 析构函数;其他方法调用前执行
public function init()
{
parent::init();
}
//主界面
public function actionIndex()
{
global $_HI,$_FM;
return $this->render('../layouts/dev', []);
}
//订单列表
public function actionList()
{
global $_HI,$_FM;
$pid = $this->pid;
$session = Yii::$app->session;
$model = new AcOrderPre();
$where = [];
$where[]='and';
$where[] = ['=','pid',$pid];
$post = Yii::$app->request->post();
$get = Yii::$app->request->get();
$searchSession = 'orderPre::search';
if (isset($_GET['reset']) && $_GET['reset']==1) {
$post['search'] = [];
}
if (isset($post['search'])) {
$search = $post['search'];
$session->set($searchSession, $search);
} elseif ($session->get($searchSession)) {
$search = $session->get($searchSession);
}
$search['car_no'] = isset($search['car_no']) ? trim($search['car_no']) : '';
if (!empty($search['car_no'])) {
$where[] = ['=','car_no',$search['car_no']];
}
$search['car_title'] = isset($search['car_title']) ? trim($search['car_title']) : '';
if (!empty($search['car_title'])) {
$where[] = ['LIKE','car_no',$search['car_no']];
}
$search['store_id'] = isset($search['store_id']) ? (int)$search['store_id'] : '';
if (empty($search['store_id'])) {
$search['store_id'] = isset($get['store_id']) ? (int)$get['store_id'] : 0;
}
$StoreModel = new AcStore();
if (!empty($search['store_id'])) {
$where[] = ['=','store_id',$search['store_id']];
$store = $StoreModel->findOne($search['store_id']);
$search['store_title'] = isset($store->title) ? $store->title : '';
}
$search['from_mid'] = isset($search['from_mid']) ? (int)$search['from_mid'] : '';
$UserModel = new User();
if (!empty($search['from_mid'])) {
$where[] = ['=','from_mid',$search['from_mid']];
$user = $UserModel->findById(['id' => $search['from_mid']]);
$search['from_mtitle'] = isset($user->username) ? $user->username : '';
}
$search['start_province'] = isset($search['start_province']) ? trim($search['start_province']) : '';
if (!empty($search['start_province'])) {
$where[] = ['=','start_province',$search['start_province']];
}
$search['start_city'] = isset($search['start_city']) ? trim($search['start_city']) : '';
if (!empty($search['start_city'])) {
$where[] = ['LIKE','start_city',$search['start_city']];
}
$search['aim_province'] = isset($search['aim_province']) ? trim($search['aim_province']) : '';
if (!empty($search['aim_province'])) {
$where[] = ['=','aim_province',$search['aim_province']];
}
$search['aim_city'] = isset($search['aim_city']) ? trim($search['aim_city']) : '';
if (!empty($search['aim_city'])) {
$where[] = ['LIKE','aim_city',$search['aim_city']];
}
$search['from_name'] = isset($search['from_name']) ? trim($search['from_name']) : '';
if (!empty($search['from_name'])) {
$where[] = ['LIKE','from_name',$search['from_name']];
}
$search['from_phone'] = isset($search['from_phone']) ? trim($search['from_phone']) : '';
if (!empty($search['from_phone'])) {
$where[] = ['LIKE','from_phone',$search['from_phone']];
}
if (isset($search['status_code']) && $search['status_code'] !='all') {
$search['status_code'] = (int)$search['status_code'];
$where[] = ['=','status_code',$search['status_code']];
} else {
unset($search['status_code']);
}
//计划日期筛选
$search['sign_m'] = isset($search['sign_m']) ? $search['sign_m'] : '';
$search['sign_after'] = isset($search['sign_after']) ? $search['sign_after'] : '';
$search['sign_before'] = isset($search['sign_before']) ? $search['sign_before'] : '';
//按月份筛选
if (!empty($search['sign_m'])) {
$start = strtotime($search['sign_m']);
$s = date("Y-m-d H:i:s", $start);
$ldm = strtotime("last day of ".$s);
$m = date("Y-m-d", $ldm)." 23:59:59";
$end = strtotime($m);
$where[] = ['between','date',$start,$end];
}
//按指定时段筛选
elseif (!empty($search['sign_after']) && !empty($search['sign_before'])) {
$start = strtotime($search['sign_after']);
$end = strtotime($search['sign_before']);
$where[] = ['between','date',$start,$end];
}
//按指定时间临界点筛选(以不早于为优先筛选条件)
elseif (!empty($search['sign_after'])) {
$start = strtotime($search['sign_after']);
$where[] = ['>=','date',$start];
} elseif (!empty($search['sign_before'])) {
$end = strtotime($search['sign_before']);
$where[] = ['<=','date',$end];
}
if (isset($search['onlyme']) && $search['onlyme']==1) {
$where[] = ['=','create_by',Yii::$app->user->identity->id];
}
$deleted = 0;
if (isset($_GET['deleted'])) {
$deleted = isset($_GET['deleted']) ? ((int)$_GET['deleted']>=0 ? 1 : 0) : 0;
}
$where[]=['=','deleted',$deleted];
$data = $model->find()->where($where);
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$_orderby = 'id DESC';
if (isset($search['orderby']) && $search['orderby']=='date') {
$_orderby = 'date DESC,id DESC';
}
$res = $data->offset($pages->offset)->limit($pages->limit)->orderby($_orderby)->all();
$status = Yii::$app->params['OrderPreStatus'];
$sids = $eids = $uids = $mids = [];
if ($res) {
foreach ($res as $r) {
$sids[$r->store_id] = $r->store_id;
$mids[$r->from_mid] = $r->from_mid;
$uids[$r->from_uid] = $r->from_uid;
$eids[$r->employee_id] = $r->employee_id;
}
}
$model = new AcStore();
$where = [];
$where['pid'] = Yii::$app->session->get('pid');
$_stores = $model->find()->where(['in','id',$sids])->all();
$stores = [];
foreach ($_stores as $s) {
$stores[$s->id] = $s->toArray();
}
$model = new AcEmployee();
$employees = [];
$_employees = $model->find()->where(['in','id',$eids])->indexBy('id')->all();
foreach ($_employees as $s) {
$employees[$s->id] = $s->toArray();
}
// $model = new User();
// $users = [];
// $_users = $model->find()->where(['in','id',$mids])->all();
// foreach($_users as $s){
// $s = $s->toArray();
// $users[$s['id']] = $s;
// }
//
// $model = new AcUserExt();
// $exts = [];
// $_exts = $model->find()->where(['in','mid',$mids])->andwhere(['pid'=>$pid,'deleted'=>0])->indexBy('id')->all();
// foreach($_exts as $ext){
// $ext = $ext->toArray();
// if(isset($users[$s['id']])){
// if($ext['mobile']==$users[$s['id']]['mobile']){
// $exts[$ext['mid']][$ext['key']] = $ext['value'];
// }
// }
// }
$model = new Fans();
$users = [];
$_users = $model->find()->where(['in','id',$uids])->all();
foreach ($_users as $s) {
$s = $s->toArray();
$users[$s['id']] = $s;
}
$model = new AcFansExt();
$exts = [];
$_exts = $model->find()->where(['in','mid',$mids])->andwhere(['pid'=>$pid,'deleted'=>0])->indexBy('id')->all();
foreach ($_exts as $ext) {
$ext = $ext->toArray();
if (isset($users[$s['id']])) {
if ($ext['mobile']==$users[$s['id']]['mobile']) {
$exts[$ext['mid']][$ext['key']] = $ext['value'];
}
}
}
$orders = [];
foreach ($res as $s) {
$s = $s->toArray();
if (isset($exts[$s['from_mid']])) {
foreach ($exts[$s['from_mid']] as $col=>$val) {
$s[$col] = $val;
}
}
$orders[$s['id']] = $s;
}
if (isset($get['export']) && $get['export']=='all') {
$this->export($orders, $stores, $users, $exts, $status);
die;
}
return $this->render('list', [
'orders' => $orders,
'pager' => $pages,
'stores'=>$stores,
'employees'=>$employees,
'exts'=>$exts,
'users'=>$users,
'status'=>$status,
'search'=>$search,
'totalCount'=>$data->count()
]);
}
//导出数据
public function export($orders, $stores, $users, $exts, $status)
{
/* 输入到CSV文件 */
$html = "\xEF\xBB\xBF";//UTF8标记
$html .= "\n";
/* 输出表头 */
$filter = array(
'id' => '序号',
'car_no' => '车牌/架号',
'car_title' => '品牌车型',
'from_name' => '联系人',
'from_mobile' => '联系电话',
'date' => '计划时间',
'start_where' => '始发地',
'end_where' => '目的地',
'store' => '网点',
'employee' => '经办人',
'receptionist' => '接待员',
'bind' => '介绍人',
'car_value' => '车辆保价',
'price' => '报价',
'car' => '客户备注'
);
foreach ($filter as $key => $title) {
$html .= $title . ",\t";
}
$html .= "\n";//换行
$htmldata = "";
foreach ($orders as $vo) {
foreach ($filter as $key => $title) {
switch ($key) {
case 'date':
$htmldata .= date('Y年m月d日', $vo['date']).",\t";
break;
case 'start_where':
$htmldata .= isset(Yii::$app->params['regionAreas'][$vo['start_province']]) ? Yii::$app->params['regionAreas'][$vo['start_province']] : '';
$htmldata .= '-';
$htmldata .= isset($vo['start_city']) ? $vo['start_city'] : '';
$htmldata .= ",\t";
break;
case 'end_where':
$htmldata .= isset(Yii::$app->params['regionAreas'][$vo['aim_province']]) ? Yii::$app->params['regionAreas'][$vo['aim_province']] : '';
$htmldata .= '-';
$htmldata .= isset($vo['aim_city']) ? $vo['aim_city'] : '';
$htmldata .= ",\t";
break;
case 'store':
$htmldata .= isset($stores[$vo['store_id']]['title']) ? $stores[$vo['store_id']]['title'] : '';
$htmldata .= ",\t";
break;
case 'employee':
$htmldata .= isset($employees[$vo['employee_id']]['name']) ? $employees[$vo['employee_id']]['name'] : '';
$htmldata .= ",\t";
break;
case 'car':
$htmldata .= strip_tags(htmlspecialchars_decode($vo['car'])).",\t";
break;
case 'status':
$htmldata .= $status[$vo['status_code']].",\t";
break;
case 'price':
case 'car_value':
$htmldata .= isset($vo[$key]) ? (int)$vo[$key] : 0;
$htmldata .= ",\t";
break;
default:
$htmldata .= isset($vo[$key]) ? $vo[$key] : '';
$htmldata .= ",\t";
break;
}
}
$htmldata .= "\n";
}
$html .=$htmldata;
/* 输出XLS文件 */
header("Content-type:text/xls");
header("Content-Type:application/force-download");
header("Content-Type:application/vnd.ms-execl");
header("Content-Type:text/comma-separated-values;charset=UTF-8");
header("Content-Type:application/octet-stream");
header("Content-Type:application/download");
header("Content-Transfer-Encoding:binary");
header("Content-Disposition:attachment; filename=预约列表".date('ymd').".xls");
echo $html;
}
//选择匹配
public function actionSelect()
{
global $_HI,$_FM;
$pid = Yii::$app->session->get('pid');
$session = Yii::$app->session;
$model = new AcOrderPre();
$where = [];
$where[]='and';
$where[] = ['=','pid',$pid];
$post = Yii::$app->request->post();
$get = Yii::$app->request->get();
$searchSession = 'orderPre::search';
if (isset($_GET['reset']) && $_GET['reset']==1) {
$post['search'] = [];
}
if (isset($post['search'])) {
$search = $post['search'];
$session->set($searchSession, $search);
} elseif ($session->get($searchSession)) {
$search = $session->get($searchSession);
}
$search['car_no'] = isset($search['car_no']) ? trim($search['car_no']) : '';
if (!empty($search['car_no'])) {
$where[] = ['=','car_no',$search['car_no']];
}
$search['car_title'] = isset($search['car_title']) ? trim($search['car_title']) : '';
if (!empty($search['car_title'])) {
$where[] = ['LIKE','car_no',$search['car_no']];
}
$search['store_id'] = isset($search['store_id']) ? (int)$search['store_id'] : '';
if (empty($search['store_id'])) {
$search['store_id'] = isset($get['store_id']) ? (int)$get['store_id'] : 0;
}
$StoreModel = new AcStore();
if (!empty($search['store_id'])) {
$where[] = ['=','store_id',$search['store_id']];
$store = $StoreModel->findOne($search['store_id']);
$search['store_title'] = isset($store->title) ? $store->title : '';
}
$search['from_mid'] = isset($search['from_mid']) ? (int)$search['from_mid'] : '';
$UserModel = new User();
if (!empty($search['from_mid'])) {
$where[] = ['=','from_mid',$search['from_mid']];
$user = $UserModel->findById(['id' => $search['from_mid']]);
$search['from_mtitle'] = isset($user->username) ? $user->username : '';
}
$search['start_province'] = isset($search['start_province']) ? trim($search['start_province']) : '';
if (!empty($search['start_province'])) {
$where[] = ['=','start_province',$search['start_province']];
}
$search['start_city'] = isset($search['start_city']) ? trim($search['start_city']) : '';
if (!empty($search['start_city'])) {
$where[] = ['LIKE','start_city',$search['start_city']];
}
$search['aim_province'] = isset($search['aim_province']) ? trim($search['aim_province']) : '';
if (!empty($search['aim_province'])) {
$where[] = ['=','aim_province',$search['aim_province']];
}
$search['aim_city'] = isset($search['aim_city']) ? trim($search['aim_city']) : '';
if (!empty($search['aim_city'])) {
$where[] = ['LIKE','aim_city',$search['aim_city']];
}
$search['from_name'] = isset($search['from_name']) ? trim($search['from_name']) : '';
if (!empty($search['from_name'])) {
$where[] = ['LIKE','from_name',$search['from_name']];
}
$search['from_phone'] = isset($search['from_phone']) ? trim($search['from_phone']) : '';
if (!empty($search['from_phone'])) {
$where[] = ['LIKE','from_phone',$search['from_phone']];
}
if (isset($search['status_code']) && $search['status_code'] !='all') {
$search['status_code'] = (int)$search['status_code'];
$where[] = ['=','status_code',$search['status_code']];
} else {
unset($search['status_code']);
}
//计划日期筛选
$search['sign_m'] = isset($search['sign_m']) ? $search['sign_m'] : '';
$search['sign_after'] = isset($search['sign_after']) ? $search['sign_after'] : '';
$search['sign_before'] = isset($search['sign_before']) ? $search['sign_before'] : '';
//按月份筛选
if (!empty($search['sign_m'])) {
$start = strtotime($search['sign_m']);
$s = date("Y-m-d H:i:s", $start);
$ldm = strtotime("last day of ".$s);
$m = date("Y-m-d", $ldm)." 23:59:59";
$end = strtotime($m);
$where[] = ['between','date',$start,$end];
}
//按指定时段筛选
elseif (!empty($search['sign_after']) && !empty($search['sign_before'])) {
$start = strtotime($search['sign_after']);
$end = strtotime($search['sign_before']);
$where[] = ['between','date',$start,$end];
}
//按指定时间临界点筛选(以不早于为优先筛选条件)
elseif (!empty($search['sign_after'])) {
$start = strtotime($search['sign_after']);
$where[] = ['>=','date',$start];
} elseif (!empty($search['sign_before'])) {
$end = strtotime($search['sign_before']);
$where[] = ['<=','date',$end];
}
if (isset($search['onlyme']) && $search['onlyme']==1) {
$where[] = ['=','create_by',Yii::$app->user->identity->id];
}
$deleted = 0;
if (isset($_GET['deleted'])) {
$deleted = isset($_GET['deleted']) ? ((int)$_GET['deleted']>=0 ? 1 : 0) : 0;
}
$where[]=['=','deleted',$deleted];
$data = $model->find()->where($where);
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$_orderby = 'id DESC';
if (isset($search['orderby']) && $search['orderby']=='date') {
$_orderby = 'date DESC,id DESC';
}
$res = $data->offset($pages->offset)->limit($pages->limit)->orderby($_orderby)->all();
$status = Yii::$app->params['OrderPreStatus'];
$sids = $eids = $uids = $mids = [];
if ($res) {
foreach ($res as $r) {
$sids[$r->store_id] = $r->store_id;
$mids[$r->from_mid] = $r->from_mid;
$uids[$r->from_uid] = $r->from_uid;
$eids[$r->employee_id] = $r->employee_id;
}
}
$model = new AcStore();
$where = [];
$where['pid'] = Yii::$app->session->get('pid');
$_stores = $model->find()->where(['in','id',$sids])->all();
$stores = [];
foreach ($_stores as $s) {
$stores[$s->id] = $s->toArray();
}
$model = new AcEmployee();
$employees = [];
$_employees = $model->find()->where(['in','id',$eids])->indexBy('id')->all();
foreach ($_employees as $s) {
$employees[$s->id] = $s->toArray();
}
$model = new Fans();
$users = [];
$_users = $model->find()->where(['in','id',$uids])->all();
foreach ($_users as $s) {
$s = $s->toArray();
$users[$s['id']] = $s;
}
$model = new AcFansExt();
$exts = [];
$_exts = $model->find()->where(['in','mid',$mids])->andwhere(['pid'=>$pid,'deleted'=>0])->indexBy('id')->all();
foreach ($_exts as $ext) {
$ext = $ext->toArray();
if (isset($users[$s['id']])) {
if ($ext['mobile']==$users[$s['id']]['mobile']) {
$exts[$ext['mid']][$ext['key']] = $ext['value'];
}
}
}
$orders = [];
foreach ($res as $s) {
$s = $s->toArray();
if (isset($exts[$s['from_mid']])) {
foreach ($exts[$s['from_mid']] as $col=>$val) {
$s[$col] = $val;
}
}
$orders[$s['id']] = $s;
}
$callback = !empty(Yii::$app->request->get('callback')) ? Yii::$app->request->get('callback') : 'order';
return $this->render('select', [
'orders' => $orders,
'pager' => $pages,
'employees'=>$employees,
'stores'=>$stores,
'exts'=>$exts,
'users'=>$users,
'status'=>$status,
'search'=>$search,
'callback'=>$callback
]);
}
public function actionNew()
{
$status = Yii::$app->params['OrderPreStatus'];
$AcOrder = new AcOrderPre();
$AcOrder->status_code = 0;
$detail = $AcOrder->toArray();
return $this->render('modify', ['status'=>$status,'detail'=>$detail]);
}
public function actionEdit()
{
$pid = Yii::$app->session->get('pid');
$status = Yii::$app->params['OrderPreStatus'];
$post = Yii::$app->request->post();
$id = Yii::$app->request->get('id');
$AcOrderPre = new AcOrderPre();
$order = $AcOrderPre->findOne($id);
$detail = $order->toArray();
$model = new AcStorePre();
$store = $model->findOne($detail['store_id']);
if ($store) {
$detail['store_title'] = $store->title;
}
$model = new AcEmployee();
$employee = $model->findOne($detail['employee_id']);
if ($employee) {
$detail['employee_title'] = $employee->name;
}
$model = new Fans();
$user = $model->findOne($detail['from_uid']);
$model = new AcFansExt();
$exts = [];
$_exts = $model->find()->where(['mid'=>$detail['from_uid'],'pid'=>$pid,'deleted'=>0])->indexBy('id')->all();
foreach ($_exts as $ext) {
$ext = $ext->toArray();
if (isset($users[$s['id']])) {
if ($ext['mobile']==$user->mobile) {
$exts[$ext['mid']][$ext['key']] = $ext['value'];
}
}
}
$op = Yii::$app->request->get('op');
$tpl = 'modify';
if ($op=='print') {
$tpl = 'print';
$sn = '00000000000'; //11位
$sn = substr($sn, 0, 11-strlen($id));
$sn .=$id;
$detail['sn'] = $sn;
}
return $this->render(
$tpl,
[
'status'=>$status,
'detail'=>$detail,
'store'=>$store,
'employee'=>$employee,
'id'=>$id
]
);
}
/*复制订单*/
public function actionCopy()
{
$pid = Yii::$app->session->get('pid');
$status = Yii::$app->params['OrderStatus'];
$post = Yii::$app->request->post();
$id = Yii::$app->request->get('id');
$AcOrder = new AcOrderPre();
$order = $AcOrder->findOne($id);
$detail = $order->toArray();
$detail['remark'] = '';
$detail['car'] = '';
unset($detail['id']);
$model = new AcStore();
$store = $model->findOne($detail['store_id']);
if ($store) {
$detail['store_title'] = $store->title;
}
$model = new AcEmployee();
$employee = $model->findOne($detail['employee_id']);
if ($employee) {
$detail['employee_title'] = $employee->name;
}
$tpl = 'modify';
return $this->render(
$tpl,
[
'status'=>$status,
'detail'=>$detail,
'store'=>$store,
'employee'=>$employee,
'id'=>0
]
);
}
//保存运单信息
public function actionSave()
{
$post = Yii::$app->request->post();
$id = (int)$post['id'];
$pid = Yii::$app->session->get('pid');
$AcOrderPre = new AcOrderPre();
if ($id) {
$order = $AcOrderPre->findOne($id);
}
//格式化数据 为空的项则不修改
//目标键=》POST键
$cols = ['start_province'=>'start_province','start_city'=>'start_city','aim_province'=>'aim_province','aim_city'=>'aim_city','car_title'=>'car_title','car_no'=>'car_no','bind'=>'bind','from_mobile'=>'from_mobile','from_name'=>'from_name','receptionist'=>'receptionist'];
foreach ($cols as $col=>$key) {
if (isset($post[$key]) && $post[$key] !='') {
$data[$col] = trim($post[$key]);
}
}
$cols = ['store_id'=>'store_id','employee_id'=>'employee_id','from_mid'=>'from_mid','car_value'=>'car_value','from_uid'=>'from_uid','from_gender'=>'from_gender'];
foreach ($cols as $col=>$key) {
$data[$col] = 0;
if (isset($post[$key]) && $post[$key] !='') {
$data[$col] = (int)$post[$key];
}
}
$cols = ['remark'=>'remark','car'=>'car'];
foreach ($cols as $col=>$key) {
if (isset($post[$key]) && $post[$key] !='') {
$data[$col] = htmlspecialchars($post[$key]);
}
}
$sign_date = isset($post['date']) ? strtotime($post['date']) : '';
$data['date'] = !$sign_date ? time() : $sign_date;
//部分规则校验
$has_err = true;
$data['create_at'] = time();
$data['update_at'] = $data['create_at'];
$data['pid'] = $pid;
$model = new AcEmployee();
$data['employee_id'] = $data['employee_id'] ?? 0;
$employee = $model->findOne($data['employee_id']);
if ($employee) {
$data['store_id'] = $employee->store_id;
$data['status_code'] = 1; //员工跟进中
$data['receptionist'] = $data['receptionist'] ?? $employee->name;
}
//保存资料
if ($id) {
unset($data['create_at']);
$res = $AcOrderPre->updateAll($data, ['id'=>$id]);
} else {
foreach ($data as $key=>$val) {
$AcOrderPre->$key = $val;
}
$res = $AcOrderPre->save();
$id = $AcOrderPre->attributes['id']; //获取插入后id
}
if ($res) {
if ($has_err) {
\Yii::$app->getSession()->setFlash('success', '订单保存成功,但有部分数据录入错误,请根据情况检查更新!');
} else {
\Yii::$app->getSession()->setFlash('success', '订单保存成功!');
}
return $this->redirect(['edit','id'=>$id]);
} else {
\Yii::$app->getSession()->setFlash('warning', '订单保存失败!');
return $this->goBack();
}
}
public function actionDelete()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$return = [];
$model = new AcOrderPre();
$order = $model->findOne($id);
if (!$order) {
$return['msg'] = '订单数据不存在';
$return['errorcode'] = 404;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
} else {
if ($order->deleted>0) {
$return['msg'] = '订单已被删除了';
$return['errorcode'] = 101;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
if ($order->status_code!=0) {
$return['msg'] = '订单非初始状态,不可删除;如果该订单不正确,可取消操作';
$return['errorcode'] = 102;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
}
// $data = $where = [];
// $where['pid'] = Yii::$app->session->get('pid');
// $where['id'] = $id;
// $data['update_at'] = time();
// $data['deleted'] = 1;
//
// $model->id = $id;
// $res = $model->updateAll($data, $where);
$order->deleted = 1;
$order->update_at = time();
$res = $order->save();
$return = [];
$return['url'] = Url::toRoute('order/list');
$return['timeout'] = 3; //3秒后自动跳转
$return['status'] = 0;
if ($res) {
$return['msg'] = '订单删除成功';
$return['errorcode'] = 200;
$return['data'] = $id;
} else {
$return['msg'] = '订单删除失败';
$return['errorcode'] = 0;
}
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
public function actionAjax()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['id'] = $id;
$data['update_at'] = time();
$model = new AcOrderPre();
$res = $model->findOne($id);
$return = [];
$return['timeout'] = 1; //几秒后自动跳转
$return['status'] = 0;
$return['ajax'] = 1;
if (!$res) {
$return['msg'] = '订单数据不存在';
$return['errorcode'] = 404;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
} else {
$order = $res;
if ($order->deleted>0) {
$return['msg'] = '订单已被删除了,无法操作';
$return['errorcode'] = 404;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
}
switch ($get['do']) {
case 'cancel':
if ($order->status_code>1) {
$return['msg'] = '订单已进入处理流程,无法操作取消';
$return['errorcode'] = 403;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
if ($order->status_code==-1) {
$return['msg'] = '订单已经是被取消状态';
$return['errorcode'] = 100;
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
$data['status_code'] = -1;
$model->id = $id;
$res = $model->updateAll($data, $where);
if ($res) {
$return['msg'] = '订单取消成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'btn-info'];
} else {
$return['msg'] = '订单取消失败';
$return['errorcode'] = 0;
}
break;
default:
break;
}
exit(json_encode($return, JSON_UNESCAPED_UNICODE));
}
}
+260
View File
@@ -0,0 +1,260 @@
<?php
/**
* @Author: fm453
* @Date: 2018-08-17 19:39:41
* @Last Modified by: fm453
* @Last Modified time: 2021-09-11 07:41:49
* @Email: fm453@lukegzs.com
*/
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\helpers\Url;
use addons\models\AcPlat;
class PlatController extends \yii\web\Controller
{
//替代常规的_construct 析构函数;其他方法调用前执行
public function init()
{
parent::init();
$session = Yii::$app->session;
if(isset($_GET['pid']) && (int)$_GET['pid']>0){
$session->set('pid',(int)$_GET['pid']);
}
}
//主界面
public function actionIndex()
{
return $this->render('../layouts/dev',[]);
}
public function actionList()
{
$model = new AcPlat();
$search = $where = [];
$where[] = 'and';
if(isset($_POST['title']) && $_POST['title']!=''){
$search['title'] = $_POST['title'];
$where[] = ['LIKE','title',$search['title']];
}
$where[] = ['=','deleted',0];
$data = $model->find()->where($where);
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '5']);
$res = $data->orderby('orderby DESC')->offset($pages->offset)->limit($pages->limit)->all();
$status = Yii::$app->params['CommonStatus'];
$plats = [];
foreach($res as $r){
$plats[$r->id] = $r->toArray();
}
return $this->render('list',[
'plats'=>$plats,
'pager' => $pages,
'search'=>$search,
'status'=>$status
]);
}
public function actionNew()
{
return $this->render('modify',[]);
}
public function actionEdit()
{
$model = new AcPlat();
$id = Yii::$app->request->get('id');
$res = $model->findOne($id);
if($res){
$res = $res->toArray();
}
return $this->render('modify',['detail'=>$res]);
}
public function actionSave()
{
$post = Yii::$app->request->post();
$data = [];
$id = $post['id'];
//目标键=》POST键
$cols = ['title'=>'title','thumb'=>'thumb'];
foreach($cols as $col=>$key){
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
}
$cols = ['orderby'=>'orderby','deleted'=>'deleted'];
foreach($cols as $col=>$key){
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
}
$data['update_at'] = time();
$data['create_at'] = $data['update_at'];
$model = new AcPlat();
foreach($data as $key=>$val){
$model->$key = $val;
}
if($id){
$model->id = $id;
$res = $model->updateAll($data,['id'=>$id]);
}else{
$res = $model->save();
$id = $model->attributes['id']; //获取插入后id
}
if($res){
\Yii::$app->getSession()->setFlash('success', '平台保存成功!');
return $this->redirect(['edit','id'=>$id]);
}else{
\Yii::$app->getSession()->setFlash('warning', '平台保存失败!');
return $this->goBack();
}
}
public function actionExt()
{
$session = Yii::$app->session;
if(isset($_GET['pid']) && (int)$_GET['pid']>0){
$session->set('pid',(int)$_GET['pid']);
}
$pid = $session->get('pid');
if(!$pid){
$url = Url::toRoute(['index/index','pid'=>0]);
header('location:'.$url);
exit;
}
$model = new AcPlat();
$res = $model->findOne($pid);
$detail = [];
if($res){
$detail = json_decode($res->remark,true);
}
return $this->render('ext',['detail'=>$detail]);
}
public function actionExtsave()
{
$user_id=Yii::$app->user->identity->getId();
if($user_id !=1){
\Yii::$app->getSession()->setFlash('warning', '修改失败,平台配置仅支持超级管理员修改!');
return $this->redirect(['plat/ext']);
}
$post = Yii::$app->request->post();
$session = Yii::$app->session;
$pid = $session->get('pid');
$data = [];
//目标键=》POST键
$cols = ['cw_phone'=>'cw_phone'];
foreach($cols as $col=>$key){
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
}
$remark = json_encode($data,JSON_UNESCAPED_UNICODE);
$model = new AcPlat();
$model->remark = $remark;
$res = $model->updateAll(['remark'=>$remark],['id'=>$pid]);
if($res){
\Yii::$app->getSession()->setFlash('success', '参数保存成功!');
}else{
\Yii::$app->getSession()->setFlash('warning', '参数保存失败!');
}
return $this->redirect(['plat/ext']);
}
public function actionDelete()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['pid'] = Yii::$app->session->get('pid');
$where['id'] = $id;
$data['update_at'] = time();
$data['deleted'] = 1;
$model = new AcPlat();
foreach($data as $key=>$val){
$model->$key = $val;
}
$model->id = $id;
$res = $model->updateAll($data,$where);
$return = [];
$return['url'] = Url::toRoute('plat/list');
$return['timeout'] = 3; //3秒后自动跳转
$return['status'] = 0;
if($res){
$return['msg'] = '平台删除成功';
$return['errorcode'] = 200;
$return['data'] = $id;
}else{
$return['msg'] = '平台删除失败';
$return['errorcode'] = 0;
}
exit(json_encode($return));
}
public function actionAjax()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['id'] = $id;
$data['update_at'] = time();
$model = new AcPlat();
$res = $model->findOne($id);
$return = [];
$return['timeout'] = 1; //3秒后自动跳转
$return['status'] = 0;
$return['ajax'] = 1;
if($res){
$res = $res->toArray();
}else{
$return['msg'] = '平台数据不存在';
$return['errorcode'] = 404;
exit(json_encode($return));
}
switch($get['do'])
{
case 'hide':
$data['status_code'] = 0;
$model->id = $id;
$res = $model->updateAll($data,$where);
if($res){
$return['msg'] = '平台隐藏成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'info'];
}else{
$return['msg'] = '平台隐藏失败';
$return['errorcode'] = 0;
}
break;
case 'show':
$data['status_code'] = 1;
$model->id = $id;
$res = $model->updateAll($data,$where);
if($res){
$return['msg'] = '平台显示成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'default'];
}else{
$return['msg'] = '平台显示失败';
$return['errorcode'] = 0;
}
break;
default:
break;
}
exit(json_encode($return));
}
}
+123
View File
@@ -0,0 +1,123 @@
<?php
/**
* @Author: fm453
* @Date: 2018-04-23 14:29:56
* @Last Modified by: fm453
* @Last Modified time: 2021-09-11 07:52:06
* @Email: fm453@lukegzs.com
*/
namespace backend\controllers;
use Yii;
use yii\web\Controller;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
use backend\models\LoginForm;
use backend\models\Menu;
use backend\components\Helper;
/**
* Site controller
*/
class SiteController extends Controller
{
/**
* @inheritdoc
*/
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'actions' => ['login', 'error'],
'allow' => true,
],
[
'actions' => ['logout', 'index'],
'allow' => true,
'roles' => ['@'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'logout' => ['get'],
],
],
];
}
/**
* @inheritdoc
*/
public function actions()
{
return [
'error' => [
'class' => 'yii\web\ErrorAction',
],
];
}
public function actionIndex()
{
$user_id=Yii::$app->user->identity->getId();
$user_info = Yii::$app->authManager->getRolesByUser($user_id);
$roleType = key($user_info);
$menu = array();
// $menu2 = new Menu();
// $menu2 = $menu2->getLeftMenuList();
// print_r($menu2['2']);die;
if(isset($_GET['debug']) && $_GET['debug']){
if(in_array($roleType,['站长','超级管理员'])){ //只有在以站长或超级管理员身份手动开启调试模式,才可以使用管理权限菜单
$menu = yii\helpers\ArrayHelper::merge(
require(Yii::getAlias('@backend').'/menus/'.'0.php'),
require(Yii::getAlias('@backend').'/menus/'.'admin.php')
);
}else{
$menu = require(Yii::getAlias('@backend').'/menus/'.'0.php');
}
}else{
$menu = require(Yii::getAlias('@backend').'/menus/'.'0.php');
}
return $this->render('index',[
'menu' => $menu,
'user_info' => $roleType
]);
}
public function actionLogin()
{
if (!Yii::$app->user->isGuest) {
return $this->goHome();
}
$model = new LoginForm();
if ($model->load(Yii::$app->request->post()) && $model->login()) {
$model->loginLog();
return $this->goBack();
} else {
return $this->render('login', [
'model' => $model,
]);
}
}
public function actionLogout()
{
Yii::$app->user->logout();
return $this->goHome();
}
public function actionError($e){
echo $e;
}
}
+284
View File
@@ -0,0 +1,284 @@
<?php
/**
* @Author: fm453
* @Date: 2018-06-04 11:06:07
* @Last Modified by: fm453
* @Last Modified time: 2021-09-11 07:42:02
* @Email: fm453@lukegzs.com
*/
namespace backend\controllers;
use Yii;
use yii\helpers\Url;
use vendor\aliyun\dysms\Sms;
use common\models\CSms;
use common\models\CVcode;
use addons\models\AcPlat;
class SmsController extends \yii\web\Controller
{
public $enableCsrfValidation = false;//取消对POST数据的csrf令牌验证
//替代常规的_construct 析构函数;其他方法调用前执行
public function init()
{
parent::init();
$session = Yii::$app->session;
if(isset($_GET['pid']) && (int)$_GET['pid']>0){
$session->set('pid',(int)$_GET['pid']);
}
$pid = $session->get('pid');
if(!$pid){
return Yii::$app->response->redirect(['index/index']);
}
}
public function actionIndex()
{
global $_HI;
global $_FM;
$_HI['action'] = 'index';
/*自定义常量*/
/*默认配置*/
$_HI['accessKeyId'] = 'LTAIQrJFtHfqsyOt'; // AccessKeyId
$_HI['accessKeySecret'] = 'tvGieI3vNI7Si3imauCB4rJ3OX4AR8'; // AccessKeySecret
$_HI['sign'] = '嗨路客';
$_HI['tmpl'] = 'SMS_116695055';
$_HI['reportQueueName'] = 'Alicom-Queue-31737903-SmsReport'; //状态报告接收
$_HI['UpQueueName'] = 'Alicom-Queue-31737903-SmsUp'; //上行消息接收
return $this->render('index');
}
public function actionGsend()
{
global $_HI;
global $_FM;
$session = Yii::$app->session;
$session->set('sms::success',0);
$session->set('sms::msg','');
$session->set('sms::guests',[]);
/*自定义常量*/
/*默认配置*/
$_HI['accessKeyId'] = Yii::$app->params['aliDySms']['accessKeyId']; // AccessKeyId
$_HI['accessKeySecret'] = Yii::$app->params['aliDySms']['accessKeySecret']; // AccessKeySecret
$_HI['sign'] = Yii::$app->params['aliDySms']['sign'];
$_HI['tmpl'] = Yii::$app->params['aliDySms']['tmpl']['acGongxue'];
$_HI['reportQueueName'] = Yii::$app->params['aliDySms']['reportQueueName']; //状态报告接收
$_HI['UpQueueName'] = Yii::$app->params['aliDySms']['UpQueueName']; //上行消息接收
return $this->render('gsend');
}
public function actionSend()
{
global $_HI;
global $_FM;
global $START_TIME;
$session = Yii::$app->session;
//数据取出方法
$dataPost = Yii::$app->request->post(); //YII应用内的真实或模拟POST数据
$dataGet = Yii::$app->request->get(); //YII应用内的真实或模拟GET数据
$params = Yii::$app->params;
$config = array();
$config['accessKeyId'] = isset($dataPost['accessKeyId']) ? $dataPost['accessKeyId'] : $params['aliDySms']['accessKeyId'];
$config['accessKeySecret'] = isset($dataPost['accessKeySecret']) ? $dataPost['accessKeySecret'] : $params['aliDySms']['accessKeySecret'];
$config['sign'] = isset($dataPost['sign']) ? $dataPost['sign'] : $params['aliDySms']['sign'];
if($config){
$session->set('sms::config',$config);
}else{
$config = $session->get('sms::config');
}
$option = array();
$sms = new Sms($option,$config);
$address = isset($dataPost['address']) ? $dataPost['address'] : '';
if($address){
$session->set('sms::address',$address);
}else{
$address = $session->get('sms::address');
}
$tmpl = isset($dataPost['tmpl']) ? $dataPost['tmpl'] : '';
if($tmpl){
$session->set('sms::tmpl',$tmpl);
}else{
$tmpl = $session->get('sms::tmpl');
}
$_guests = isset($dataPost['guests']) ? $dataPost['guests'] : '';
if(!$_guests){
$guests = $session->get('sms::guests');
}else{
$_guests = explode("\r\n",$_guests);
$guests = array();
foreach($_guests as $c){
$_c = explode(',', $c);
if(count($_c)>1){
$k = trim($_c[1]);
$v = trim($_c[0]);
$guests[$k] = $v;
}
}
unset($_c);unset($k);unset($v);
$guests = array_unique($guests);
}
if(!$guests){
$i = (int)$session->get('sms::success');
$session->set('sms::success',0);
$msg = $session->get('sms::msg');
$session->set('sms::msg','');
\Yii::$app->getSession()->setFlash('info', '群发完成,共成功发送'.$i.'条;详情:'.$msg);
return $this->render('gsend');
}
$results = array();
$msg = "";
$content = [];
$content['address'] = $address;
$i = 0;
$j = 50;
foreach($guests as $p=>$username){
$j--;
$content['name'] = !empty($username) ? $username.'安诚托车' : '安诚捷顺运车';
$result = $sms->send($p,$tmpl,$content);
$results[$p] = $result;
if(!$result){
$msg .= "【".$p."】发送失败,接口提示:".$sms->errors."\r\n";
}elseif($result->Code !='OK'){
$msg .= "【".$p."】发送失败,接口提示:".$result->Message."\r\n";
}else{
$i++;
$msg .= "【".$p."】发送成功"."\r\n";
}
unset($guests[$p]);
if($j==0){
break;
}
}
$session->set('sms::guests',$guests);
$i += (int)$session->get('sms::success');
$session->set('sms::success',$i);
$msg .= $session->get('sms::msg');
$session->set('sms::msg',$msg);
\Yii::$app->getSession()->setFlash('info', '群发完成,共成功发送'.$i.'条;详情:'.$msg);
return $this->render('ajax');
}
//发送验证码
public function actionVcode()
{
global $_HI,$_FM;
$pid = Yii::$app->session->get('pid');
$plat = AcPlat::findOne($pid);
$platExt = json_decode($plat->remark,true);
//数据取出方法
$dataPost = Yii::$app->request->post(); //YII应用内的真实或模拟POST数据
$dataGet = Yii::$app->request->get(); //YII应用内的真实或模拟GET数据
$params = Yii::$app->params;
$config = array();
$config['accessKeyId'] = isset($dataPost['accessKeyId']) ? $dataPost['accessKeyId'] : $params['aliDySms']['accessKeyId'];
$config['accessKeySecret'] = isset($dataPost['accessKeySecret']) ? $dataPost['accessKeySecret'] : $params['aliDySms']['accessKeySecret'];
$config['sign'] = isset($dataPost['sign']) ? $dataPost['sign'] : $params['aliDySms']['sign'];
$option = array();
$sms = new Sms($option,$config);
$op = Yii::$app->request->get('op');
$content=[];
switch($op){
case 'caiwu':
$phone = $platExt['cw_phone'];
$codetype = 'caiwu';
if(!$phone){
$return = [];
$return['errorcode'] = 1;
$return['msg'] = '还没有配置财务手机号,请联系站长管理员进行设置';
exit(json_encode($return));
}
$vcodeModel = new CVcode();
//查询上次发送记录
$_time = time();
$where=[];
$where['mobile'] = $phone;
$where['deleted'] = 0;
$where['type'] = $codetype;
$res = $vcodeModel->find()->where($where)->one();
if($res){
if(($_time-$res->create_at)<7200){
$code = $res->code;
$return = [];
$return['errorcode'] = 2;
$return['msg'] = '上次发送的验证码仍然可用;请注意查看财务手机';
exit(json_encode($return));
}else{
$res->deleted = 1;
$res->save();
}
}
$code = mt_rand(1000,9999);
$content['code'] = $code;
$tmpl = Yii::$app->params['aliDySms']['tmpl']['cwVcode'];
//验证码入库
$vcode = [];
$vcode['code'] = $code;
$vcode['type'] = $codetype;
$vcode['mobile'] = $phone;
$vcode['create_at'] = time();
foreach($vcode as $key=>$val){
$vcodeModel->$key = $val;
}
break;
default:
$mobile = Yii::$app->request->post('mobile');
break;
}
$result = $sms->send($phone,$tmpl,$content);
//保存发送记录
$smsModel = new CSms();
$smsdata = [];
$sid = Yii::$app->params['siteId'];
$smsdata['sid'] = (int)$sid;
$smsdata['pid'] = $pid;
$smsdata['uid'] = Yii::$app->user->identity->id;
$smsdata['mobile'] = $phone;
$smsdata['content'] = json_encode($content,JSON_UNESCAPED_UNICODE);
$smsdata['create_at'] = time();
foreach($smsdata as $key=>$val){
$smsModel->$key = $val;
}
$smsModel->save();
$return = [];
$msg = '';
if(!$result){
$msg .= "发送失败,接口提示:".$sms->errors."\r\n";
$return['errorcode'] = 3;
}elseif(is_array($result) && $result['Code'] !='OK'){
$msg .= "发送失败,接口提示:".$result['Message']."\r\n";
$return['errorcode'] = 4;
}else{
$vcodeModel->save();
$msg .= "发送成功"."\r\n";
$return['errorcode'] = 0;
}
$return['msg'] = $msg;
exit(json_encode($return));
}
}
+251
View File
@@ -0,0 +1,251 @@
<?php
/**
* @Author: fm453
* @Date: 2018-08-17 19:39:41
* @Last Modified by: fm453
* @Last Modified time: 2021-09-11 07:42:08
* @Email: fm453@lukegzs.com
*/
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\helpers\Url;
use addons\models\AcStore;
class StoreController extends \yii\web\Controller
{
//替代常规的_construct 析构函数;其他方法调用前执行
public function init()
{
parent::init();
$session = Yii::$app->session;
if(isset($_GET['pid']) && (int)$_GET['pid']>0){
$session->set('pid',(int)$_GET['pid']);
}
$pid = $session->get('pid');
if(!$pid){
return Yii::$app->response->redirect(['index/index']);
}
}
//主界面
public function actionIndex()
{
return $this->render('../layouts/dev',[]);
}
public function actionList()
{
$model = new AcStore();
$where = [];
$where['pid'] = Yii::$app->session->get('pid');
$citys = Yii::$app->params['citys'];
$post = Yii::$app->request->post();
$where['deleted'] = 0;
$data = $model->find()->where($where);
$search = [];
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
if(!empty($search['title'])){
$where2 = ['LIKE','title',$search['title']];
$data = $data->andwhere($where2);
}
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->orderby('order_by DESC,id ASC')->all();
$status = Yii::$app->params['CommonStatus'];
return $this->render('list',[
'stores'=>$res,
'pager' => $pages,
'citys'=>$citys,
'status'=>$status,
'search'=>$search
]);
}
public function actionSelect()
{
$model = new AcStore();
$where = [];
$where['pid'] = Yii::$app->session->get('pid');
$citys = Yii::$app->params['citys'];
$post = Yii::$app->request->post();
$where['deleted'] = 0;
$where['status_code'] = 1;
$data = $model->find()->where($where);
$search = [];
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
if(!empty($search['title'])){
$where2 = ['LIKE','title',$search['title']];
$data = $data->andwhere($where2);
}
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->orderby('order_by DESC,id ASC')->all();
$status = ['0'=>'隐藏','1'=>'正常'];
$callback = !empty(Yii::$app->request->get('callback')) ? Yii::$app->request->get('callback') : 'store';
return $this->render('select',[
'stores'=>$res,
'pager' => $pages,
'citys'=>$citys,
'status'=>$status,
'search'=>$search,
'callback'=>$callback
]);
}
public function actionNew()
{
return $this->render('modify',[]);
}
public function actionEdit()
{
$model = new AcStore();
$id = Yii::$app->request->get('id');
$res = $model->find()->where(['id' => $id])->one();
if($res){
$res = $res->toArray();
}
$citys = Yii::$app->params['citys'];
$res['city_title'] = isset($citys[$res['city']]['name']) ? $citys[$res['city']]['name'] : '';
return $this->render('modify',['detail'=>$res]);
}
public function actionSave()
{
$post = Yii::$app->request->post();
$data = [];
$data['pid'] = Yii::$app->session->get('pid');
$id = $post['id'];
//目标键=》POST键
$cols = ['title'=>'title','longt'=>'lng','lat'=>'lat','addr'=>'addr'];
foreach($cols as $col=>$key){
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
}
$cols = ['city'=>'city','order_by'=>'order_by','deleted'=>'deleted'];
foreach($cols as $col=>$key){
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
}
$data['update_at'] = time();
$data['create_at'] = time();
$data['status_code'] = 1;
$model = new AcStore();
foreach($data as $key=>$val){
$model->$key = $val;
}
if($id){
$model->id = $id;
$res = $model->updateAll($data,['id'=>$id]);
}else{
$res = $model->save();
$id = $model->attributes['id']; //获取插入后id
}
if($res){
\Yii::$app->getSession()->setFlash('success', '门店网点保存成功!');
return $this->redirect(['edit','id'=>$id]);
}else{
\Yii::$app->getSession()->setFlash('warning', '门店网点保存失败!');
return $this->goBack();
}
}
public function actionDelete()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['pid'] = Yii::$app->session->get('pid');
$where['id'] = $id;
$data['update_at'] = time();
$data['deleted'] = 1;
$model = new AcStore();
foreach($data as $key=>$val){
$model->$key = $val;
}
$model->id = $id;
$res = $model->updateAll($data,$where);
$return = [];
$return['url'] = Url::toRoute('store/list');
$return['timeout'] = 3; //3秒后自动跳转
$return['status'] = 0;
if($res){
$return['msg'] = '门店删除成功';
$return['errorcode'] = 200;
$return['data'] = $id;
}else{
$return['msg'] = '门店删除失败';
$return['errorcode'] = 0;
}
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
public function actionAjax()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['pid'] = Yii::$app->session->get('pid');
$where['id'] = $id;
$data['update_at'] = time();
$model = new AcStore();
$res = $model->find()->where(['id' => $id])->one();
$return = [];
$return['timeout'] = 1; //3秒后自动跳转
$return['status'] = 0;
$return['ajax'] = 1;
if($res){
$res = $res->toArray();
}else{
$return['msg'] = '门店数据不存在';
$return['errorcode'] = 404;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
switch($get['do'])
{
case 'hide':
$data['status_code'] = 0;
$model->id = $id;
$res = $model->updateAll($data,$where);
if($res){
$return['msg'] = '门店隐藏成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'info'];
}else{
$return['msg'] = '门店隐藏失败';
$return['errorcode'] = 0;
}
break;
case 'show':
$data['status_code'] = 1;
$model->id = $id;
$res = $model->updateAll($data,$where);
if($res){
$return['msg'] = '门店显示成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'default'];
}else{
$return['msg'] = '门店显示失败';
$return['errorcode'] = 0;
}
break;
default:
break;
}
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
}
+438
View File
@@ -0,0 +1,438 @@
<?php
/**
* @Author: fm453
* @Date: 2018-08-17 19:39:41
* @Last Modified by: fm453
* @Last Modified time: 2021-09-11 07:42:17
* @Email: fm453@lukegzs.com
*/
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\helpers\Url;
use addons\models\AcTruck;
use addons\models\AcDriver;
class TruckController extends \yii\web\Controller
{
//替代常规的_construct 析构函数;其他方法调用前执行
public function init()
{
parent::init();
$session = Yii::$app->session;
if(isset($_GET['pid']) && (int)$_GET['pid']>0){
$session->set('pid',(int)$_GET['pid']);
}
$pid = $session->get('pid');
if(!$pid){
return Yii::$app->response->redirect(['index/index']);
}
}
//主界面
public function actionIndex()
{
return $this->render('../layouts/dev',[]);
}
//板车列表
public function actionList()
{
$AcTruck = new AcTruck();
$where = $where2 = [];
$where2[]='and';
$where['pid'] = Yii::$app->session->get('pid');
$post = Yii::$app->request->post();
$search = [];
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
if(!empty($search['title'])){
$where2[] = ['LIKE','num_left',$search['title']];
}
$where['deleted'] = 0;
$data = $AcTruck->find()->where($where);
if($search['title']){
$data = $data->andwhere($where2);
}
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->orderby('order_by DESC,id DESC')->all();
$status = Yii::$app->params['TruckStatus'];
$AcDriver = new AcDriver();
$where = [];
$where['pid'] = Yii::$app->session->get('pid');
$_drivers = $AcDriver->find()->where($where)->all();
$drivers = [];
foreach($_drivers as $s){
$drivers[$s->id] = $s->toArray();
}
return $this->render('list',[
'trucks'=>$res,
'pager' => $pages,
'drivers'=>$drivers,
'status'=>$status,
'search'=>$search
]);
}
public function actionSelect()
{
$AcTruck = new AcTruck();
$where = $where2 = [];
$where2[]='and';
$where['pid'] = Yii::$app->session->get('pid');
$post = Yii::$app->request->post();
$search = [];
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
if(!empty($search['title'])){
$where2[] = ['LIKE','num_left',$search['title']];
}
$where['deleted'] = 0;
$data = $AcTruck->find()->where($where);
if($search['title']){
$data = $data->andwhere($where2);
}
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->orderby('order_by DESC,id DESC')->all();
$status = Yii::$app->params['TruckStatus'];
$AcDriver = new AcDriver();
$where = [];
$where['pid'] = Yii::$app->session->get('pid');
$_drivers = $AcDriver->find()->where($where)->all();
$drivers = [];
foreach($_drivers as $s){
$drivers[$s->id] = $s->toArray();
}
$callback = !empty(Yii::$app->request->get('callback')) ? Yii::$app->request->get('callback') : 'truck';
return $this->render('select',[
'trucks'=>$res,
'pager' => $pages,
'drivers'=>$drivers,
'status'=>$status,
'search'=>$search,
'callback'=>$callback
]);
}
public function actionNew()
{
$status = Yii::$app->params['TruckStatus'];
$AcTruck = new AcTruck();
$AcTruck->status_code = 0;
return $this->render('modify',['status'=>$status,'detail'=>$AcTruck]);
}
//编辑板车资料
public function actionEdit()
{
$model = new AcTruck();
$id = Yii::$app->request->get('id');
$res = $model->find()->where(['id' => $id])->one();
if($res){
$res = $res->toArray();
}
$AcDriver = new AcDriver();
$driver = $AcDriver->find()->where(['id' => $res['driver_id']])->one();
if($driver){
$res['driver_title'] = $driver->name;
}
$driver2 = $AcDriver->find()->where(['id' => $res['driver2_id']])->one();
if($driver2){
$res['driver2_title'] = $driver2->name;
}
$status = Yii::$app->params['TruckStatus'];
return $this->render('modify',['status'=>$status,'detail'=>$res]);
}
//保存板车资料
public function actionSave()
{
$post = Yii::$app->request->post();
$id = (int)$post['id'];
$pid = Yii::$app->session->get('pid');
//格式化数据
//目标键=》POST键
$cols = ['num_p'=>'num_p','num_area'=>'num_area','num_left'=>'num_left'];
foreach($cols as $col=>$key){
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
}
//查询车牌号是否在库
$hasTruck = AcTruck::find()->where(['num_p'=>$data['num_p'],'num_area'=>$data['num_area'],'num_left'=>$data['num_left']])->one();
if($hasTruck){
if($id && $id!=$hasTruck->id){
\Yii::$app->getSession()->setFlash('danger', '保存失败,该车牌号已在库!');
return $this->goBack();
}else{
$id = $hasTruck->id;
}
}
$cols = ['driver_id'=>'driver','driver2_id'=>'driver2','max_cars'=>'max_cars','order_by'=>'order_by','deleted'=>'deleted'];
foreach($cols as $col=>$key){
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
}
$cols = ['remark'=>'editor'];
foreach($cols as $col=>$key){
$data[$col] = isset($post[$key]) ? htmlspecialchars($post[$key]) : '';
}
$data['create_at'] = time();
$data['update_at'] = $data['create_at'];
$data['pid'] = $pid;
//保存板车资料
$AcTruck = new AcTruck();
foreach($data as $key=>$val){
$AcTruck->$key = $val;
}
if($id){
$AcTruck->id = $id;
unset($data['create_at']);
$res = $AcTruck->updateAll($data,['id'=>$id]);
}else{
$res = $AcTruck->save();
$id = $AcTruck->attributes['id']; //获取插入后id
}
if($res){
\Yii::$app->getSession()->setFlash('success', '板车资料保存成功!');
return $this->redirect(['edit','id'=>$id]);
}else{
\Yii::$app->getSession()->setFlash('warning', '板车资料保存失败!');
return $this->goBack();
}
}
//删除板车
public function actionDelete()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['pid'] = Yii::$app->session->get('pid');
$where['id'] = $id;
$data['update_at'] = time();
$data['deleted'] = 1;
$model = new AcTruck();
foreach($data as $key=>$val){
$model->$key = $val;
}
$model->id = $id;
$res = $model->updateAll($data,$where);
$return = [];
$return['url'] = Url::toRoute('truck/list');
$return['timeout'] = 3; //3秒后自动跳转
$return['status'] = 0;
if($res){
$return['msg'] = '板车删除成功';
$return['errorcode'] = 200;
$return['data'] = $id;
}else{
$return['msg'] = '板车删除失败';
$return['errorcode'] = 0;
}
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
public function actionAjax()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['pid'] = Yii::$app->session->get('pid');
$where['id'] = $id;
$data['update_at'] = time();
$model = new AcTruck();
$res = $model->find()->where(['id' => $id])->one();
$return = [];
$return['timeout'] = 1; //3秒后自动跳转
$return['ajax'] = 1;
if($res){
$res = $res->toArray();
}else{
$return['msg'] = '板车数据不存在';
$return['errorcode'] = 404;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
switch($get['do'])
{
case 'hide':
$data['status_code'] = 0;
$model->id = $id;
$res = $model->updateAll($data,$where);
if($res){
$return['msg'] = '板车停用标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'default'];
}else{
$return['msg'] = '板车停用标记失败';
$return['errorcode'] = 0;
}
break;
case 'show':
$data['status_code'] = 1;
$model->id = $id;
$res = $model->updateAll($data,$where);
if($res){
$return['msg'] = '板车入库记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'primary'];
}else{
$return['msg'] = '板车入库标记失败';
$return['errorcode'] = 0;
}
break;
case 'lock':
$data['status_code'] = 99;
$model->id = $id;
$res = $model->updateAll($data,$where);
if($res){
$return['msg'] = '板车锁定标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'danger'];
}else{
$return['msg'] = '板车锁定标记失败';
$return['errorcode'] = 0;
}
break;
case 'repair':
$data['status_code'] = 2;
$model->id = $id;
$res = $model->updateAll($data,$where);
if($res){
$return['msg'] = '板车检修标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'warning'];
}else{
$return['msg'] = '板车检修标记失败';
$return['errorcode'] = 0;
}
break;
case 'reset':
$data['status_code'] = 2;
$model->id = $id;
$res = $model->updateAll($data,$where);
if($res){
$return['msg'] = '板车保养标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'info'];
}else{
$return['msg'] = '板车保养标记失败';
$return['errorcode'] = 0;
}
break;
case 'working':
$data['status_code'] = 1;
$model->id = $id;
$res = $model->updateAll($data,$where);
if($res){
$return['msg'] = '板车恢复正常,标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'success'];
}else{
$return['msg'] = '板车恢复标记失败';
$return['errorcode'] = 0;
}
break;
default:
break;
}
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
//发车
public function actionFache()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$AcTruck = new AcTruck();
$truck = $AcTruck->findOne($id);
if(!$truck){
$return['msg'] = '板车数据不存在';
$return['errorcode'] = 404;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
if($truck->status_code==4){
$return = [];
// $return['url'] = Url::toRoute('truckol/modify');
$return['timeout'] = 3; //3秒后自动跳转
$return['status'] = 0;
$return['msg'] = '当前板车已在装车中,发车操作无效';
$return['errorcode'] = 400;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}elseif($truck->status_code==5){
$return = [];
// $return['url'] = Url::toRoute('truckol/modify');
$return['timeout'] = 3; //3秒后自动跳转
$return['status'] = 0;
$return['msg'] = '当前板车已在运输途中,发车操作无效';
$return['errorcode'] = 400;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}elseif($truck->status_code!=1){
$return['msg'] = '当前板车状态不允许发车,请先确认板车已归为正常状态';
$return['errorcode'] = 400;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
$data = $where = [];
$where['pid'] = Yii::$app->session->get('pid');
$where['id'] = $id;
$data['update_at'] = time();
$data['status_code'] = 4;
foreach($data as $key=>$val){
$AcTruck->$key = $val;
}
$res = $AcTruck->updateAll($data,$where);
$return = [];
// $return['url'] = Url::toRoute('truckol/modify');
$return['timeout'] = 3; //3秒后自动跳转
$return['status'] = 0;
if($res){
$return['msg'] = '发车成功,请进行下一步操作';
$return['errorcode'] = 200;
$return['data'] = $id;
}else{
$return['msg'] = '发车操作失败';
$return['errorcode'] = 0;
}
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
//浏览板车资料
public function actionDetail()
{
$model = new AcTruck();
$id = Yii::$app->request->get('id');
$res = $model->find()->where(['id' => $id])->one();
if($res){
$res = $res->toArray();
}
$AcDriver = new AcDriver();
$driver = $AcDriver->find()->where(['id' => $res['driver_id']])->one();
if($driver){
$res['driver_title'] = $driver->name;
$res['driver_mobile'] = $driver->mobile;
}
$driver2 = $AcDriver->find()->where(['id' => $res['driver2_id']])->one();
if($driver2){
$res['driver2_title'] = $driver2->name;
$res['driver2_mobile'] = $driver2->mobile;
}
$status = Yii::$app->params['TruckStatus'];
return $this->render('detail',['status'=>$status,'detail'=>$res]);
}
}
+577
View File
@@ -0,0 +1,577 @@
<?php
/**
* @Author: fm453
* @Date: 2018-08-17 19:39:41
* @Last Modified by: fm453
* @Last Modified time: 2021-09-11 07:42:13
* @Email: fm453@lukegzs.com
*/
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\helpers\Url;
use addons\models\AcTruck;
use addons\models\AcDriver;
use addons\models\AcTruckOnline;
use addons\models\AcTruckCars;
use addons\models\AcStore;
use addons\models\AcCar;
use addons\models\AcCarBrand;
use addons\models\AcCarSeries;
use addons\models\AcOrder;
use addons\models\AcGps;
use addons\models\AcGpsRoute;
class TruckcarController extends \yii\web\Controller
{
//替代常规的_construct 析构函数;其他方法调用前执行
public function init()
{
parent::init();
$session = Yii::$app->session;
if(isset($_GET['pid']) && (int)$_GET['pid']>0){
$session->set('pid',(int)$_GET['pid']);
}
$pid = $session->get('pid');
if(!$pid){
return Yii::$app->response->redirect(['index/index']);
}
}
//主界面
public function actionIndex()
{
return $this->render('../layouts/dev',[]);
}
//所有装车记录列表
public function actionList()
{
$pid = Yii::$app->session->get('pid');
$post = Yii::$app->request->post();
$online_id = Yii::$app->request->get('online_id'); //发车任务ID
$AcTruckCars = new AcTruckCars();
$where = [];
$where[]='and';
$where[] = ['=','pid',Yii::$app->session->get('pid')];
$search = isset($post['search'])?$post['search']:[];
$search['start_city'] = isset($search['start_city']) ? trim(htmlspecialchars_decode($search['start_city'])) : '';
if(!empty($search['start_city'])){
$where[] = ['LIKE','from_city',$search['start_city']];
}
$search['aim_city'] = isset($search['aim_city']) ? trim(htmlspecialchars_decode($search['aim_city'])) : '';
if(!empty($search['aim_city'])){
$where[] = ['LIKE','to_city',$search['aim_city']];
}
$search['car_id'] = isset($search['car_id']) ? (int)$search['car_id']: 0;
$CarModel = new AcCar();
if(!empty($search['car_id'])){
$where[] = ['=','car_id',$search['car_id']];
$car = $CarModel->findOne($search['car_id']);
$search['car_title'] = isset($car->title) ? $car->title : '';
}
$search['status_code'] = isset($search['status_code']) ? $search['status_code']: 'all';
if($search['status_code']!='all'){
$where[] = ['=','status_code',(int)$search['status_code']];
}
//按月份筛选
$search['start_m'] = isset($search['start_m']) ? $search['start_m'] : '';
if(!empty($search['start_m'])){
$start = strtotime($search['start_m']);
$s = date("Y-m-d H:i:s", $start);
$ldm = strtotime("last day of ".$s);
$m = date("Y-m-d",$ldm)." 23:59:59";
$end = strtotime($m);
$where[] = ['between','from_time',$start,$end];
}
$where[] = ['=','deleted',0];
$data = $AcTruckCars->find()->where($where);
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->orderby('status_code ASC,id DESC')->all();
$car_ids = [];
foreach($res as $r){
$car_ids[] = $r->car_id;
}
$AcCar = new AcCar();
$where = [];
$where[] = 'and';
$where[] = ['=','pid',$pid];
$where[] = ['IN','id',$car_ids];
$where[] = ['=','deleted',0];
$cars = $AcCar->find()->where($where)->indexby('id')->all();
$status = Yii::$app->params['TruckCarsStatus'];
return $this->render('list',[
'list'=>$res,
'pager' => $pages,
'status'=>$status,
'cars'=>$cars,
'search'=>$search
]);
}
public function actionNew()
{
$status = Yii::$app->params['TruckCarsStatus'];
$AcTruckCars = [];
$AcTruckCars['status_code'] = 0;
$online_id = Yii::$app->request->get('online_id'); //发车任务ID
$AcTruckCars['online_id'] = $online_id;
$order_id = Yii::$app->request->get('order_id'); //待承运订单ID
$AcTruckCars['order_id'] = $order_id;
$car_id = Yii::$app->request->get('car_id'); //待装客车ID
$AcTruckCars['car_id'] = $car_id;
return $this->render('create',['status'=>$status,'detail'=>$AcTruckCars]);
}
//编辑客车上板信息
public function actionEdit()
{
$id = Yii::$app->request->get('id'); //承运单ID
$truck_id = $online_id = $store_id = $store2_id = 0;
$truckCar = $truckol = [];
$AcTruckCars = new AcTruckCars();
$res = $AcTruckCars->findOne($id);
if($res){
$truckCar = $res->toArray();
$online_id = $res->online_id;
$store2_id = $res->to_store;
$store_id = $res->from_store;
$order_id = $res->order_id;
}
$AcOrder = new AcOrder;
$order = $AcOrder->findOne($order_id);
$AcTruckOnline = new AcTruckOnline();
$res = $AcTruckOnline->findOne($online_id);
if($res){
$truck_id = $res->truck_id;
$truckol = $res->toArray();
}
$AcTruck = new AcTruck();
$truck = $AcTruck->findOne($truck_id);
if(!$truck){
$post = Yii::$app->request->post();
$return = [];
$return['msg'] = '关联板车数据获取异常,发车任务编辑失败';
$return['errorcode'] = 0;
$return['url'] = Url::toRoute(['truck/list',$post]);
$return['buttons'] = [
['title'=>'好的,我知道了','class'=>'info','url'=>$return['url']]
];
$return['content'] = $return['msg'];
$return['class'] = 'warning';
Yii::$app->request->setBodyParams($return);
return Yii::$app->runAction('index/msg');
}
$truckCar['truck_id'] = $truck_id;
$truckCar['truck_title'] = $truck->num_p.$truck->num_area.$truck->num_left;
$truckCar['truck_num'] = $truckCar['truck_title']?$truckCar['truck_title']:$truckol['truck_num'];
$AcStore = new AcStore();
$store = $AcStore->findOne($store_id);
if($store){
$truckCar['fromstore_title'] = $store->title;
}
$store2 = $AcStore->findOne($store2_id);
if($store2){
$truckCar['endstore_title'] = $store2->title;
}
$AcDriver = new AcDriver();
$driver = $AcDriver->find()->where(['id' => $truck->driver_id])->one();
$truckCar['driver_title'] = $truckCar['driver_mobile'] = '';
if($driver){
$truckCar['driver_title'] = $driver->name;
$truckCar['driver_mobile'] = $driver->mobile;
}
$truckCar['from_time'] = !empty($truckCar['from_time'])?$truckCar['from_time']:$truckol['from_date'];
$truckCar['to_time'] = !empty($truckCar['to_time'])?$truckCar['to_time']:$truckol['end_date'];
$from_city = $order->start_city;
$truckCar['from_city'] = !empty($truckCar['from_city'])?$truckCar['from_city']:$from_city;
$truckCar['from_city'] = $truckCar['from_city'] ? $truckCar['from_city'] : $truckol['from_city'];
$end_city = $order->aim_city;
$truckCar['to_city'] = !empty($truckCar['to_city'])?$truckCar['to_city']:$end_city;
$truckCar['to_city'] = $truckCar['to_city'] ? $truckCar['to_city'] : $truckol['end_city'];
$truckCar['driver_name'] = isset($truckCar['driver_name'])?$truckCar['driver_name']:$truckol['driver_name'];
$truckCar['driver_mobiles'] = isset($truckCar['driver_mobiles'])?$truckCar['driver_mobiles']:$truckol['driver_mobiles'];
$status = Yii::$app->params['TruckCarsStatus'];
return $this->render('modify',['status'=>$status,'detail'=>$truckCar]);
}
//保存客车上板信息(直接指派方式)
public function actionSave()
{
$post = Yii::$app->request->post();
$id = (int)$post['id'];
$pid = Yii::$app->session->get('pid');
//格式化数据
//目标键=》POST键
$cols = ['from_city'=>'from_city','to_city'=>'to_city'];
foreach($cols as $col=>$key){
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
}
$cols = ['online_id'=>'online_id','from_store'=>'from_store','to_store'=>'to_store'];
if(isset($_GET['debug'])&&($_GET['debug']==1)){
$cols['status_code'] = 'status_code';
}
foreach($cols as $col=>$key){
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
}
/*出车计划判断*/
$online_id = $data['online_id'];
if(!$online_id){
$return['msg'] = '未关联板车出车计划信息,保存失败';
$return['errorcode'] = 400;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
$AcTruckOnline = new AcTruckOnline();
$truckol = $AcTruckOnline->findOne($online_id);
if(!$truckol){
$return['msg'] = '未找到指定板车出车计划,保存失败';
$return['errorcode'] = 404;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
$key = 'remark';
$data[$key] = isset($post[$key]) ? htmlspecialchars(trim($post[$key])) : '';
$_time = time();
$key = 'to_time';
if(isset($post[$key]) && $post[$key]!=""){
$data[$key] = strtotime($post[$key]);
}
$key = 'from_time';
if(isset($post[$key]) && $post[$key]!=""){
$data[$key] = strtotime($post[$key]);
}
if(!$id){
$data['create_at'] = $_time;
}
$data['update_at'] = $_time;
$data['pid'] = $pid;
//保存上板信息
$AcTruckCars = new AcTruckCars();
foreach($data as $key=>$val){
$AcTruckCars->$key = $val;
}
if($id){
$res = $AcTruckCars->updateAll($data,['id'=>$id]);
}else{
$res = $AcTruckCars->save();
$id = $AcTruckCars->attributes['id']; //获取插入后id
}
if($res){
//修改对应运单状态
$_code = 0;
if(isset($data['status_code'])){
if($data['status_code'] == 1){
$_code = 2;
}elseif($data['status_code'] == 99){
$_code = 3;
}
}
if($_code){
$order_id = isset($post['order_id']) ? (int)$post['order_id'] : 0;
if(!$order_id){
$car = $AcTruckCars->findOne($id);
$order_id = $car->order_id;
}
$AcOrder = new AcOrder();
$order = $AcOrder->findOne($order_id);
$order->update_at = $_time;
$order->status_code = $_code;
$order->save();
}
\Yii::$app->getSession()->setFlash('success', '信息保存成功!');
return $this->redirect(['edit','id'=>$id]);
}else{
\Yii::$app->getSession()->setFlash('warning', '信息保存失败!');
return $this->goBack();
}
}
//保存客车上板信息(板车出车界面车辆管理方式)
public function actionSave2()
{
$post = Yii::$app->request->post();
$id = (int)$post['id'];
$pid = Yii::$app->session->get('pid');
//格式化数据
//目标键=》POST键
$cols = ['from_city'=>'from_city','to_city'=>'to_city'];
foreach($cols as $col=>$key){
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
}
$cols = ['online_id'=>'online_id','from_store'=>'from_store','to_store'=>'to_store','order_id'=>'order_id','car_id'=>'car_id'];
if(isset($_GET['debug'])&&($_GET['debug']==1)){
$cols['status_code'] = 'status_code';
}
foreach($cols as $col=>$key){
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
}
/*出车计划判断*/
$online_id = $data['online_id'];
if(!$online_id){
$return['msg'] = '未关联板车出车计划信息,保存失败';
$return['errorcode'] = 400;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
$AcTruckOnline = new AcTruckOnline();
$truckol = $AcTruckOnline->findOne($online_id);
if(!$truckol){
$return['msg'] = '未找到指定板车出车计划,保存失败';
$return['errorcode'] = 404;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
$key = 'remark';
$data[$key] = isset($post[$key]) ? htmlspecialchars(trim($post[$key])) : '';
$_time = time();
$key = 'to_time';
if(isset($post[$key]) && $post[$key]!=""){
$data[$key] = strtotime($post[$key]);
}
$key = 'from_time';
if(isset($post[$key]) && $post[$key]!=""){
$data[$key] = strtotime($post[$key]);
}
if(!$id){
$data['create_at'] = $_time;
}
$data['update_at'] = $_time;
$data['pid'] = $pid;
//保存上板信息
$AcTruckCars = new AcTruckCars();
foreach($data as $key=>$val){
$AcTruckCars->$key = $val;
}
if($id){
$res = $AcTruckCars->updateAll($data,['id'=>$id]);
}else{
$res = $AcTruckCars->save();
$id = $AcTruckCars->attributes['id']; //获取插入后id
}
if($res){
//修改对应运单状态
$_code = 0;
if(isset($data['status_code'])){
if($data['status_code'] == 1){
$_code = 2;
}elseif($data['status_code'] == 99){
$_code = 3;
}
}
if($_code){
$order_id = isset($post['order_id']) ? (int)$post['order_id'] : 0;
if(!$order_id){
$car = $AcTruckCars->findOne($id);
$order_id = $car->order_id;
}
$AcOrder = new AcOrder();
$order = $AcOrder->findOne($order_id);
$order->update_at = $_time;
$order->status_code = $_code;
$order->save();
}
\Yii::$app->getSession()->setFlash('success', '信息保存成功!');
return $this->redirect(['edit','id'=>$id]);
}else{
\Yii::$app->getSession()->setFlash('warning', '信息保存失败!');
return $this->goBack();
}
}
//删除板车
public function actionDelete()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$pid = Yii::$app->session->get('pid');
$data = $return = [];
$data['update_at'] = time();
$data['deleted'] = 1;
$model = new AcTruckCars();
$car = $model->findOne($id);
if(!$car){
$return['msg'] = '数据不存在,删除失败';
$return['errorcode'] = 404;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
if($car->pid !=$pid){
$return['msg'] = '非本平台数据,不允许操作';
$return['errorcode'] = 400;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
if($car->deleted !=0){
$return['msg'] = '数据已被删除过,操作无效';
$return['errorcode'] = 400;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
foreach($data as $key=>$val){
$model->$key = $val;
}
$model->id = $id;
$res = $model->updateAll($data,['id'=>$id]);
$return['url'] = Url::toRoute('truckcar/list');
$return['timeout'] = 3; //3秒后自动跳转
$return['status'] = 0;
if($res){
$return['msg'] = '上板记录删除成功';
$return['errorcode'] = 200;
$return['data'] = $id;
}else{
$return['msg'] = '上板记录删除失败';
$return['errorcode'] = 0;
}
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
public function actionAjax()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$pid = Yii::$app->session->get('pid');
$data = $return = [];
$_time = time();
$data['update_at'] = $_time;
$model = new AcTruckCars();
$car = $model->findOne($id);
if(!$car){
$return['msg'] = '数据不存在,删除失败';
$return['errorcode'] = 404;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
if($car->pid !=$pid){
$return['msg'] = '非本平台数据,不允许操作';
$return['errorcode'] = 400;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
if($car->deleted !=0){
$return['msg'] = '数据已被删除,操作无效';
$return['errorcode'] = 400;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
$online_id = $car->online_id;
$AcTruckOnline = new AcTruckOnline();
$truckol = $AcTruckOnline->findOne($online_id);
$order_id = $car->order_id;
$AcOrder = new AcOrder();
$order = $AcOrder->findOne($order_id);
$return['timeout'] = 1; //n秒后自动跳转
$where = ['id'=>$id];
switch($get['do'])
{
case 'intruck':
if($car->status_code !=0){
$return['msg'] = '当前运单并非待承运状态,操作无效';
$return['errorcode'] = 400;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
$data['status_code'] = 1;
$data['from_time'] = $_time;
$res = $model->updateAll($data,$where);
if($res){
//增加板车一辆装车统计
$truckol->update_at = $_time;
$truckol->updateCounters(['cars'=>1]);
$truckol->save();
//修改对应订单的状态
$order->update_at = $_time;
$order->status_code = 2;
$order->save();
$return['msg'] = '客车上板标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'success'];
}else{
$return['msg'] = '客车上板标记失败';
$return['errorcode'] = 0;
}
break;
case 'arrive':
if($car->status_code ==0){
$return['msg'] = '当前任务尚待承运,操作无效';
$return['errorcode'] = 400;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
$data['status_code'] = 99;
$data['to_time'] = $_time;
$res = $model->updateAll($data,$where);
if($res){
//修改对应订单的状态
$order->update_at = $_time;
$order->status_code = 3;
$order->save();
$return['msg'] = '客车运达标记记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'primary'];
}else{
$return['msg'] = '客车运达标记失败';
$return['errorcode'] = 0;
}
break;
case 'fix':
$data['status_code'] = 80;
if($car->status_code != 1){
$return['msg'] = '当前运单并非运输中状态,操作无效';
$return['errorcode'] = 400;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
$res = $model->updateAll($data,$where);
if($res){
$return['msg'] = '客车运达标记记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'primary'];
}else{
$return['msg'] = '客车运达标记失败';
$return['errorcode'] = 0;
}
break;
default:
break;
}
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
}
+937
View File
@@ -0,0 +1,937 @@
<?php
/**
* @Author: fm453
* @Date: 2018-08-17 19:39:41
* @Last Modified by: fm453
* @Last Modified time: 2021-09-11 07:42:21
* @Email: fm453@lukegzs.com
*/
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\helpers\Url;
use addons\models\AcTruck;
use addons\models\AcDriver;
use addons\models\AcTruckOnline;
use addons\models\AcTruckCars;
use addons\models\AcStore;
use addons\models\AcCar;
use addons\models\AcCarBrand;
use addons\models\AcCarSeries;
use addons\models\AcOrder;
use addons\models\AcEmployee;
use addons\models\AcGps;
use addons\models\AcGpsRoute;
class TruckolController extends \yii\web\Controller
{
//替代常规的_construct 析构函数;其他方法调用前执行
public function init()
{
parent::init();
$session = Yii::$app->session;
if(isset($_GET['pid']) && (int)$_GET['pid']>0){
$session->set('pid',(int)$_GET['pid']);
}
$pid = $session->get('pid');
if(!$pid){
return Yii::$app->response->redirect(['index/index']);
}
}
//出车单
public function actionIndex()
{
$AcTruckOnline = new AcTruckOnline();
$where = [];
$where[]='and';
$where[] = ['=','pid',Yii::$app->session->get('pid')];
$where[] = ['>','status_code',0];
$post = Yii::$app->request->post();
$search = [];
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
if(!empty($search['title'])){
$where[] = ['LIKE','num_left',$search['title']];
}
$where[] = ['=','deleted',0];
$data = $AcTruckOnline->find()->where($where);
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '10']);
$res = $data->offset($pages->offset)->limit($pages->limit)->orderby('id DESC')->all();
$status = Yii::$app->params['TruckOnlineStatus'];
$stores = [];
$AcStore = new AcStore();
if($res){
$store_ids = [];
foreach($res as $r){
$store_ids[$r->from_store] = $r->from_store;
$store_ids[$r->end_store] = $r->end_store;
}
array_unique($store_ids);
$_stores = $AcStore->find()->where(['IN','id',$store_ids])->all();
if($_stores){
foreach($_stores as $r){
$stores[$r->id] = $r->toArray();
}
}
}
return $this->render('index',[
'list'=>$res,
'pager' => $pages,
'status'=>$status,
'stores'=>$stores,
'search'=>$search
]);
}
//在线板车列表(标记了发车状态——装车中的)
public function actionList()
{
$AcTruck = new AcTruck();
$where = [];
$where[]='and';
$where[] = ['=','pid',Yii::$app->session->get('pid')];
$where[] = ['=','status_code',4];
$post = Yii::$app->request->post();
$search = [];
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
if(!empty($search['title'])){
$where[] = ['LIKE','num_left',$search['title']];
}
$where[] = ['=','deleted',0];
$data = $AcTruck->find()->where($where);
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
$status = Yii::$app->params['TruckStatus'];
$AcDriver = new AcDriver();
$where = [];
$where['pid'] = Yii::$app->session->get('pid');
$_drivers = $AcDriver->find()->where($where)->all();
$drivers = [];
foreach($_drivers as $s){
$drivers[$s->id] = $s->toArray();
}
return $this->render('list',[
'trucks'=>$res,
'pager' => $pages,
'drivers'=>$drivers,
'status'=>$status,
'search'=>$search
]);
}
//选择可装车的板车
public function actionSelect()
{
$AcTruck = new AcTruck();
$where = [];
$where[]='and';
$where[] = ['=','pid',Yii::$app->session->get('pid')];
$where[] = ['=','status_code',4];
$post = Yii::$app->request->post();
$search = [];
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
if(!empty($search['title'])){
$where[] = ['LIKE','num_left',$search['title']];
}
$where[] = ['=','deleted',0];
$data = $AcTruck->find()->where($where);
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
$status = Yii::$app->params['TruckStatus'];
$AcDriver = new AcDriver();
$where = [];
$where['pid'] = Yii::$app->session->get('pid');
$_drivers = $AcDriver->find()->where($where)->all();
$drivers = [];
foreach($_drivers as $s){
$drivers[$s->id] = $s->toArray();
}
$callback = !empty(Yii::$app->request->get('callback')) ? Yii::$app->request->get('callback') : 'truckol';
return $this->render('select',[
'trucks'=>$res,
'pager' => $pages,
'drivers'=>$drivers,
'status'=>$status,
'search'=>$search,
'callback'=>$callback
]);
}
public function actionSelect2()
{
$AcTruckOnline = new AcTruckOnline();
$where = [];
$where[]='and';
$where[] = ['=','pid',Yii::$app->session->get('pid')];
$where[] = ['>','status_code',0];
$post = Yii::$app->request->post();
$search = [];
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
if(!empty($search['title'])){
$where[] = ['LIKE','num_left',$search['title']];
}
$where[] = ['=','deleted',0];
$data = $AcTruckOnline->find()->where($where);
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '10']);
$res = $data->offset($pages->offset)->limit($pages->limit)->orderby('id DESC')->all();
$status = Yii::$app->params['TruckOnlineStatus'];
$stores = [];
$AcStore = new AcStore();
if($res){
$store_ids = [];
foreach($res as $r){
$store_ids[$r->from_store] = $r->from_store;
$store_ids[$r->end_store] = $r->end_store;
}
array_unique($store_ids);
$_stores = $AcStore->find()->where(['IN','id',$store_ids])->all();
if($_stores){
foreach($_stores as $r){
$stores[$r->id] = $r->toArray();
}
}
}
$callback = !empty(Yii::$app->request->get('callback')) ? Yii::$app->request->get('callback') : 'truckol';
return $this->render('select2',[
'list'=>$res,
'pager' => $pages,
'status'=>$status,
'stores'=>$stores,
'search'=>$search,
'callback'=>$callback
]);
}
public function actionNew()
{
$status = Yii::$app->params['TruckOnlineStatus'];
$AcTruckOnline = [];
$AcTruckOnline['status_code'] = 0;
return $this->render('edit',['status'=>$status,'detail'=>$AcTruckOnline]);
}
//编辑板车装车计划资料
public function actionEdit()
{
// $id = Yii::$app->request->get('id'); //装车任务ID
$id = 0;
$truck_id = Yii::$app->request->get('truck_id'); //板车ID
$store_id = $store2_id = 0;
$pid = Yii::$app->session->get('pid');
$AcTruckOnline = new AcTruckOnline();
$AcTruck = new AcTruck();
$truckol = [];
$truck = $AcTruck->findOne($truck_id);
if(!$truck){
$post = Yii::$app->request->post();
$return = [];
$return['msg'] = '关联板车数据获取异常,发车任务编辑失败';
$return['errorcode'] = 0;
$return['url'] = Url::toRoute(['truck/list',$post]);
$return['buttons'] = [
['title'=>'好的,我知道了','class'=>'info','url'=>$return['url']]
];
$return['content'] = $return['msg'];
$return['class'] = 'warning';
Yii::$app->request->setBodyParams($return);
return Yii::$app->runAction('index/msg');
}
if(!$id){
$where = [];
$where[] = 'and';
$where[] = ['=','pid',$pid];
$where[] = ['=','truck_id',$truck_id];
$where[] = ['<','status_code',99];
$where[] = ['=','deleted',0];
$res = $AcTruckOnline->find()->where($where)->orderby('id ASC')->one();
if($res){
$id = $res->id;
$store_id = $res->from_store;
$store2_id = $res->end_store;
$truckol = $res->toArray();
}
}
$truckol['truck_id'] = $truck_id;
$truckol['truck_title'] = $truck->num_p.$truck->num_area.$truck->num_left;
$truckol['truck_num'] = $truckol['truck_title']?$truckol['truck_title']:$truckol['truck_num'];
$AcStore = new AcStore();
$store = $AcStore->findOne($store_id);
if($store){
$truckol['fromstore_title'] = $store->title;
}
$store2 = $AcStore->findOne($store2_id);
if($store2){
$truckol['endstore_title'] = $store2->title;
}
$AcDriver = new AcDriver();
$driver = $AcDriver->find()->where(['id' => $truck->driver_id])->one();
$truckol['driver_title'] = $truckol['driver_mobile'] = '';
if($driver){
$truckol['driver_title'] = $driver->name;
$truckol['driver_mobile'] = $driver->mobile;
}
$truckol['driver_name'] = isset($truckol['driver_name'])?$truckol['driver_name']:$truckol['driver_title'];
$truckol['driver_mobiles'] = isset($truckol['driver_mobiles'])?$truckol['driver_mobiles']:$truckol['driver_mobile'];
$status = Yii::$app->params['TruckOnlineStatus'];
return $this->render('edit',['status'=>$status,'detail'=>$truckol]);
}
//更新板车装车任务资料
public function actionModify()
{
$id = Yii::$app->request->get('id'); //装车任务ID
// $truck_id = Yii::$app->request->get('truck_id'); //板车ID
$truck_id = 0;
$store_id = $store2_id = 0;
$pid = Yii::$app->session->get('pid');
$AcTruckOnline = new AcTruckOnline();
$AcTruck = new AcTruck();
$truckol = [];
$res = $AcTruckOnline->findOne($id);
if($res){
$truck_id = $res->truck_id;
$store_id = $res->from_store;
$store2_id = $res->end_store;
$truckol = $res->toArray();
}
$truck = $AcTruck->findOne($truck_id);
if(!$truck){
$post = Yii::$app->request->post();
$return = [];
$return['msg'] = '关联板车数据获取异常,发车任务编辑失败';
$return['errorcode'] = 0;
$return['url'] = Url::toRoute(['truck/list',$post]);
$return['buttons'] = [
['title'=>'好的,我知道了','class'=>'info','url'=>$return['url']]
];
$return['content'] = $return['msg'];
$return['class'] = 'warning';
Yii::$app->request->setBodyParams($return);
return Yii::$app->runAction('index/msg');
}
$truckol['truck_id'] = $truck_id;
$truckol['truck_title'] = $truck->num_p.$truck->num_area.$truck->num_left;
$truckol['truck_num'] = $truckol['truck_title']?$truckol['truck_title']:$truckol['truck_num'];
$AcStore = new AcStore();
$store = $AcStore->findOne($store_id);
if($store){
$truckol['fromstore_title'] = $store->title;
}
$store2 = $AcStore->findOne($store2_id);
if($store2){
$truckol['endstore_title'] = $store2->title;
}
$AcDriver = new AcDriver();
$driver = $AcDriver->find()->where(['id' => $truck->driver_id])->one();
$truckol['driver_title'] = $truckol['driver_mobile'] = '';
if($driver){
$truckol['driver_title'] = $driver->name;
$truckol['driver_mobile'] = $driver->mobile;
}
$truckol['driver_name'] = isset($truckol['driver_name'])?$truckol['driver_name']:$truckol['driver_title'];
$truckol['driver_mobiles'] = isset($truckol['driver_mobiles'])?$truckol['driver_mobiles']:$truckol['driver_mobile'];
$status = Yii::$app->params['TruckOnlineStatus'];
return $this->render('modify',['status'=>$status,'detail'=>$truckol]);
}
//保存装车基础资料
public function actionSave()
{
$post = Yii::$app->request->post();
$id = (int)$post['id'];
$pid = Yii::$app->session->get('pid');
//格式化数据
//目标键=》POST键
$cols = ['driver_name'=>'driver_name','driver_mobiles'=>'driver_mobiles','driver_idcard'=>'driver_idcard','truck_num'=>'truck_num','end_city'=>'end_city','from_city'=>'from_city'];
foreach($cols as $col=>$key){
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
}
$cols = ['truck_id'=>'truck_id','from_store'=>'from_store','end_store'=>'end_store'];
foreach($cols as $col=>$key){
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
}
$key = 'status_code';
if(isset($post[$key])){
$data[$key] = (int)$post[$key];
}
/*板车规则判断
*一辆板车只能有一条可用装车任务表单
**/
$truck_id = $data['truck_id'];
if(!$truck_id){
$return['msg'] = '未指定板车信息,保存失败';
$return['errorcode'] = 400;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
$AcTruck = new AcTruck();
$truck = $AcTruck->findOne($truck_id);
if(!$truck){
$return['msg'] = '未找到指定板车,保存失败';
$return['errorcode'] = 404;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
$AcTruckOnline = new AcTruckOnline();
$where = [];
$where[] = 'and';
$where[] = ['=','pid',$pid];
$where[] = ['=','truck_id',$truck_id];
$where[] = ['<','status_code',99];
$where[] = ['=','deleted',0];
$truckol = $AcTruckOnline->find()->where($where)->orderby('id ASC')->one();
if($truckol){
if($id != $truckol->id){
$return['msg'] = '该板车已有未完成的托运任务,不允许重复指派';
$return['errorcode'] = 400;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
}
$key = 'remark';
$data[$key] = isset($post[$key]) ? htmlspecialchars(trim($post[$key])) : '';
$_time = time();
$key = 'from_date';
$data[$key] = isset($post[$key]) ? strtotime($post[$key]) : $_time;
$key = 'end_date';
if(isset($post[$key])){
$data[$key] = strtotime($post[$key]);
}
if(!$id){
$data['create_at'] = $_time;
}
$data['update_at'] = $_time;;
$data['pid'] = $pid;
//保存板车资料
$AcTruckOnline = new AcTruckOnline();
foreach($data as $key=>$val){
$AcTruckOnline->$key = $val;
}
if($id){
$res = $AcTruckOnline->updateAll($data,['id'=>$id]);
}else{
$res = $AcTruckOnline->save();
$id = $AcTruckOnline->attributes['id']; //获取插入后id
}
if($res){
\Yii::$app->getSession()->setFlash('success', '信息保存成功!');
return $this->redirect(['modify','id'=>$id]);
}else{
\Yii::$app->getSession()->setFlash('warning', '信息保存失败!');
return $this->goBack();
}
}
//随车车辆管理
public function actionCars()
{
$pid = Yii::$app->session->get('pid');
$id = Yii::$app->request->get('id'); //装车任务ID
$AcTruckOnline = new AcTruckOnline();
$truckol = [];
$res = $AcTruckOnline->findOne($id);
if(!$res){
$post = Yii::$app->request->post();
$return = [];
$return['msg'] = '发车任务记录获取失败,请重新获取';
$return['errorcode'] = 0;
$return['url'] = Url::toRoute(['truckol/list',$post]);
$return['buttons'] = [
['title'=>'好的,我知道了','class'=>'info','url'=>$return['url']]
];
$return['content'] = $return['msg'];
$return['class'] = 'warning';
Yii::$app->request->setBodyParams($return);
return Yii::$app->runAction('index/msg');
}
$truck_id = $res->truck_id;
$store_id = $res->from_store;
$store2_id = $res->end_store;
$truckol = $res->toArray();
$AcTruck = new AcTruck();
$truck = $AcTruck->findOne($truck_id);
$AcStore = new AcStore();
$store = $AcStore->findOne($store_id);
if($store){
$truckol['fromstore_title'] = $store->title;
}
$store2 = $AcStore->findOne($store2_id);
if($store2){
$truckol['endstore_title'] = $store2->title;
}
$online_id = $id;
$AcTruckCars = new AcTruckCars();
$where = [];
$where[] = 'and';
$where[] = ['=','pid',$pid];
$where[] = ['=','online_id',$online_id];
$where[] = ['=','deleted',0];
$truckcars = $AcTruckCars->find()->where($where)->orderby('update_at DESC')->all();
$carids = $orderids = [];
if($truckcars){
foreach($truckcars as $t){
$carids[] = $t->car_id;
$orderids[] = $t->order_id;
}
}
$AcCar = new AcCar();
$where = [];
$where[] = 'and';
$where[] = ['=','pid',$pid];
$where[] = ['IN','id',$carids];
$where[] = ['=','deleted',0];
$cars = $AcCar->find()->where($where)->indexby('id')->all();
$status = Yii::$app->params['TruckCarsStatus'];
$truckOnLineStatus = Yii::$app->params['TruckOnlineStatus'];
return $this->render('cars',[
'status'=>$status,
'truckOnLineStatus'=>$truckOnLineStatus,
'truckol'=>$truckol,
'cars'=>$cars,
'truckcars'=>$truckcars
]);
}
//保存装车随车资料
public function actionCarssave()
{
$post = Yii::$app->request->post();
$online_id = (int)$post['id'];
$pid = Yii::$app->session->get('pid');
//格式化数据
//目标键=》POST键
$cols = ['car_id','order_id'];
foreach($cols as $key){
if(!isset($post[$key])){
$return['msg'] = '未传入的运单或车辆信息,保存失败';
$return['errorcode'] = 400;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
}
$car_ids = $post['car_id'];
if(!is_array($car_ids)){
$return['msg'] = '传入的车辆数据不正确,保存失败';
$return['errorcode'] = 400;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
$order_ids = $post['order_id'];
if(!is_array($order_ids)){
$return['msg'] = '传入的运单数据不正确,保存失败';
$return['errorcode'] = 400;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
if(count($car_ids) != count($order_ids)){
$return['msg'] = '传入的车辆数据与运单数据不匹配,保存失败';
$return['errorcode'] = 400;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
/*筛除已在运输中的运单及车辆数据 TBD*/
$AcTruckCars = new AcTruckCars();
$cars = [];
$_time = time();
foreach($car_ids as $k=>$car_id){
$car = [];
$car['pid'] = $pid;
$car['online_id'] = $online_id;
$car['car_id'] = $car_id;
$car['order_id'] = $order_ids[$k];
$car['create_at'] = $_time;
$car['update_at'] = $_time;
$cars[] = $car;
$model = clone $AcTruckCars;
foreach($car as $key=>$val){
$model->$key = $val;
}
$model->save();
}
$return['msg'] = '操作完成,请刷新页面并检查数据';
$return['errorcode'] = 200;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
//板车出发
public function actionChufa()
{
$id = Yii::$app->request->get('id'); //装车任务ID
$return = [];
$AcTruckOnline = new AcTruckOnline();
$truckol = [];
$res = $AcTruckOnline->findOne($id);
if(!$res){
$post = Yii::$app->request->post();
$return['msg'] = '发车任务记录获取失败,请重新获取';
$return['errorcode'] = 404;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
if($res->status_code!=0){
$return['msg'] = '关联出车任务非“待出发”状态,操作失败';
$return['errorcode'] = 400;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
$truck_id = $res->truck_id;
$truckol = $res->toArray();
$AcTruck = new AcTruck();
$truck = $AcTruck->findOne($truck_id);
if(!$truck){
$return['msg'] = '关联板车数据获取异常,操作失败';
$return['errorcode'] = 404;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
/*更新数据*/
$_time = time();
$data = [];
$data['update_at'] = $_time;
$data['status_code'] = 1;
$res = $AcTruckOnline->updateAll($data,['id'=>$id]);
$data = [];
$data['update_at'] = $_time;
$data['status_code'] = 5;
$AcTruck->updateAll($data,['id'=>$truck_id]);
if($res){
$return['msg'] = '出车任务出发标记操作成功';
$return['errorcode'] = 200;
}else{
$return['msg'] = '出发标记操作失败';
$return['errorcode'] = 100;
}
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
//板车到达
public function actionArrive()
{
$id = Yii::$app->request->get('id'); //装车任务ID
$return = [];
$AcTruckOnline = new AcTruckOnline();
$truckol = [];
$res = $AcTruckOnline->findOne($id);
if(!$res){
$post = Yii::$app->request->post();
$return['msg'] = '发车任务记录获取失败,请重新获取';
$return['errorcode'] = 404;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
if($res->status_code!=1){
$return['msg'] = '关联出车任务非“进行中”(在途)状态,操作失败';
$return['errorcode'] = 400;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
$truck_id = $res->truck_id;
$truckol = $res->toArray();
$AcTruck = new AcTruck();
$truck = $AcTruck->findOne($truck_id);
if(!$truck){
$return['msg'] = '关联板车数据获取异常,操作失败';
$return['errorcode'] = 404;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
/*更新数据*/
$_time = time();
$data = [];
$data['update_at'] = $_time;
$data['status_code'] = 99;
$res = $AcTruckOnline->updateAll($data,['id'=>$id]);
$data = [];
$data['update_at'] = $_time;
$data['status_code'] = 0;
$AcTruck->updateAll($data,['id'=>$truck_id]);
if($res){
$return['msg'] = '出车任务运达标记操作成功';
$return['errorcode'] = 200;
}else{
$return['msg'] = '运达标记操作失败';
$return['errorcode'] = 100;
}
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
//删除板车装车任务
public function actionDelete()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['pid'] = Yii::$app->session->get('pid');
$where['id'] = $id;
$data['update_at'] = time();
$data['deleted'] = 1;
$model = new AcTruck();
$res = $model->updateAll($data,$where);
$return = [];
$return['url'] = Url::toRoute('truckol/index');
$return['timeout'] = 3; //3秒后自动跳转
$return['status'] = 0;
if($res){
$return['msg'] = '板车装车任务删除成功';
$return['errorcode'] = 200;
$return['data'] = $id;
}else{
$return['msg'] = '板车装车任务删除失败';
$return['errorcode'] = 0;
}
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
//打印出车单
public function actionPrint()
{
$pid = Yii::$app->session->get('pid');
$id = Yii::$app->request->get('id'); //装车任务ID
$AcTruckOnline = new AcTruckOnline();
$truckol = [];
$res = $AcTruckOnline->findOne($id);
if(!$res){
$post = Yii::$app->request->post();
$return = [];
$return['msg'] = '发车任务记录获取失败,请重新获取';
$return['errorcode'] = 0;
$return['url'] = Url::toRoute(['truckol/list',$post]);
$return['buttons'] = [
['title'=>'好的,我知道了','class'=>'info','url'=>$return['url']]
];
$return['content'] = $return['msg'];
$return['class'] = 'warning';
Yii::$app->request->setBodyParams($return);
return Yii::$app->runAction('index/msg');
}
$truck_id = $res->truck_id;
$store_id = $res->from_store;
$store2_id = $res->end_store;
$truckol = $res->toArray();
$AcTruck = new AcTruck();
$truck = $AcTruck->findOne($truck_id);
$AcStore = new AcStore();
$store = $AcStore->findOne($store_id);
if($store){
$truckol['fromstore_title'] = $store->title;
}
$store2 = $AcStore->findOne($store2_id);
if($store2){
$truckol['endstore_title'] = $store2->title;
}
$online_id = $id;
$AcTruckCars = new AcTruckCars();
$where = [];
$where[] = 'and';
$where[] = ['=','pid',$pid];
$where[] = ['=','online_id',$online_id];
$where[] = ['=','deleted',0];
$where[] = ['>','status_code',0];
$truckcars = $AcTruckCars->find()->where($where)->orderby('update_at DESC')->all();
$carids = $orderids = [];
if($truckcars){
foreach($truckcars as $t){
$carids[] = $t->car_id;
$orderids[] = $t->order_id;
}
}
$counts = [];
$AcCar = new AcCar();
$where = [];
$where[] = 'and';
$where[] = ['=','pid',$pid];
$where[] = ['IN','id',$carids];
$where[] = ['=','deleted',0];
$cars = $AcCar->find()->where($where)->indexby('id')->all();
$AcOrder = new AcOrder();
$where = [];
$where[] = 'and';
$where[] = ['=','pid',$pid];
$where[] = ['IN','id',$orderids];
$where[] = ['=','deleted',0];
$orders = $AcOrder->find()->where($where)->indexby('id')->all();
$employee_ids = [];
$count['fee_total'] = $count['pay_receive'] = 0;
foreach($orders as $v){
$employee_ids[] = $v->employee_id;
$count['fee_total'] += $v->fee_total;
$count['pay_receive'] += $v->pay_receive;
}
$AcEmployee = new AcEmployee();
$where = [];
$where[] = 'and';
$where[] = ['=','pid',$pid];
$where[] = ['IN','id',$employee_ids];
$where[] = ['=','deleted',0];
$employees = $AcEmployee->find()->where($where)->indexby('id')->all();
$count['cars'] = count($truckcars);
$status = Yii::$app->params['TruckCarsStatus'];
$truckOnLineStatus = Yii::$app->params['TruckOnlineStatus'];
return $this->render('print',[
'status'=>$status,
'truckOnLineStatus'=>$truckOnLineStatus,
'truckol'=>$truckol,
'cars'=>$cars,
'orders'=>$orders,
'employees'=>$employees,
'truckcars'=>$truckcars,
'count'=>$count
]);
}
//浏览详情
public function actionDetail()
{
$pid = Yii::$app->session->get('pid');
$id = Yii::$app->request->get('id'); //装车任务ID
$AcTruckOnline = new AcTruckOnline();
$truckol = [];
$res = $AcTruckOnline->findOne($id);
if(!$res){
$post = Yii::$app->request->post();
$return = [];
$return['msg'] = '发车任务记录获取失败,请重新获取';
$return['errorcode'] = 0;
$return['url'] = Url::toRoute(['truckol/list',$post]);
$return['buttons'] = [
['title'=>'好的,我知道了','class'=>'info','url'=>$return['url']]
];
$return['content'] = $return['msg'];
$return['class'] = 'warning';
Yii::$app->request->setBodyParams($return);
return Yii::$app->runAction('index/msg');
}
$truck_id = $res->truck_id;
$store_id = $res->from_store;
$store2_id = $res->end_store;
$truckol = $res->toArray();
$AcTruck = new AcTruck();
$truck = $AcTruck->findOne($truck_id);
$AcStore = new AcStore();
$store = $AcStore->findOne($store_id);
if($store){
$truckol['fromstore_title'] = $store->title;
}
$store2 = $AcStore->findOne($store2_id);
if($store2){
$truckol['endstore_title'] = $store2->title;
}
$online_id = $id;
$AcTruckCars = new AcTruckCars();
$where = [];
$where[] = 'and';
$where[] = ['=','pid',$pid];
$where[] = ['=','online_id',$online_id];
$where[] = ['=','deleted',0];
$where[] = ['>','status_code',1];
$truckcars = $AcTruckCars->find()->where($where)->orderby('update_at DESC')->all();
$carids = $orderids = [];
if($truckcars){
foreach($truckcars as $t){
$carids[] = $t->car_id;
$orderids[] = $t->order_id;
}
}
$counts = [];
$AcCar = new AcCar();
$where = [];
$where[] = 'and';
$where[] = ['=','pid',$pid];
$where[] = ['IN','id',$carids];
$where[] = ['=','deleted',0];
$cars = $AcCar->find()->where($where)->indexby('id')->all();
$AcOrder = new AcOrder();
$where = [];
$where[] = 'and';
$where[] = ['=','pid',$pid];
$where[] = ['IN','id',$orderids];
$where[] = ['=','deleted',0];
$orders = $AcOrder->find()->where($where)->indexby('id')->all();
$employee_ids = [];
$count['fee_total'] = $count['pay_receive'] = 0;
foreach($orders as $v){
$employee_ids[] = $v->employee_id;
$count['fee_total'] += $v->fee_total;
$count['pay_receive'] += $v->pay_receive;
}
$AcEmployee = new AcEmployee();
$where = [];
$where[] = 'and';
$where[] = ['=','pid',$pid];
$where[] = ['IN','id',$employee_ids];
$where[] = ['=','deleted',0];
$employees = $AcEmployee->find()->where($where)->indexby('id')->all();
$count['cars'] = count($truckcars);
$status = Yii::$app->params['TruckCarsStatus'];
$truckOnLineStatus = Yii::$app->params['TruckOnlineStatus'];
return $this->render('detail',[
'status'=>$status,
'truckOnLineStatus'=>$truckOnLineStatus,
'truckol'=>$truckol,
'cars'=>$cars,
'orders'=>$orders,
'employees'=>$employees,
'truckcars'=>$truckcars,
'count'=>$count
]);
}
}
+381
View File
@@ -0,0 +1,381 @@
<?php
/**
* @Author: fm453
* @Date: 2018-08-17 19:39:41
* @Last Modified by: fm453
* @Last Modified time: 2021-09-11 07:42:25
* @Email: fm453@lukegzs.com
*/
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\helpers\Url;
use addons\models\AcTruck;
use addons\models\AcDriver;
use addons\models\AcTruckOnline;
use addons\models\AcTruckCars;
use addons\models\AcStore;
use addons\models\AcCar;
use addons\models\AcCarBrand;
use addons\models\AcCarSeries;
use addons\models\AcOrder;
use addons\models\AcGps;
use addons\models\AcGpsRoute;
use addons\models\AcTruckRoute;
class TruckrouteController extends \yii\web\Controller
{
//替代常规的_construct 析构函数;其他方法调用前执行
public function init()
{
parent::init();
$session = Yii::$app->session;
if(isset($_GET['pid']) && (int)$_GET['pid']>0){
$session->set('pid',(int)$_GET['pid']);
}
$pid = $session->get('pid');
if(!$pid){
return Yii::$app->response->redirect(['index/index']);
}
$online_id = Yii::$app->request->get('online_id'); //发车任务ID
if(!$online_id){
$online_id = $session->get('online_id');
}else{
$session->set('online_id',$online_id);
}
if(!$online_id){
$post = Yii::$app->request->post();
$return = [];
$return['msg'] = '请先选择好要查看的出车大板';
$return['errorcode'] = 0;
$return['url'] = Url::toRoute(['truckol/index',$post]);
$return['buttons'] = [
['title'=>'好的,我知道了','class'=>'info','url'=>$return['url']]
];
$return['content'] = $return['msg'];
$return['class'] = 'warning';
Yii::$app->request->setBodyParams($return);
return Yii::$app->runAction('index/msg');
}
$truckol = $session->get('truckOnline');
$AcTruckOnline = new AcTruckOnline();
$res = true;
if(!$truckol){
$res = $AcTruckOnline->findOne($online_id);
if($res){
$truck_id = $res->truck_id;
$store_id = $res->from_store;
$store2_id = $res->end_store;
$truckol = $res->toArray();
$AcStore = new AcStore();
$store = $AcStore->findOne($store_id);
if($store){
$truckol['fromstore_title'] = $store->title;
}
$store2 = $AcStore->findOne($store2_id);
if($store2){
$truckol['endstore_title'] = $store2->title;
}
$session->set('truckOnline',$truckol);
}
}
if($online_id != $truckol['id']){
$res = $AcTruckOnline->findOne($online_id);
if($res){
$truck_id = $res->truck_id;
$store_id = $res->from_store;
$store2_id = $res->end_store;
$truckol = $res->toArray();
$AcStore = new AcStore();
$store = $AcStore->findOne($store_id);
if($store){
$truckol['fromstore_title'] = $store->title;
}
$store2 = $AcStore->findOne($store2_id);
if($store2){
$truckol['endstore_title'] = $store2->title;
}
$session->set('truckOnline',$truckol);
}
}
if(!$res){
$post = Yii::$app->request->post();
$return = [];
$return['msg'] = '请先选择好要查看的出车大板';
$return['errorcode'] = 0;
$return['url'] = Url::toRoute(['truckol/index',$post]);
$return['buttons'] = [
['title'=>'好的,我知道了','class'=>'info','url'=>$return['url']]
];
$return['content'] = $return['msg'];
$return['class'] = 'warning';
Yii::$app->request->setBodyParams($return);
return Yii::$app->runAction('index/msg');
}
}
//主界面
public function actionIndex()
{
return $this->render('../layouts/dev',[]);
}
//所有板车位置记录列表
public function actionList()
{
$pid = Yii::$app->session->get('pid');
$post = Yii::$app->request->post();
$online_id = Yii::$app->session->get('online_id'); //发车任务ID
$truckol = Yii::$app->session->get('truckOnline'); //发车任务
$AcTruckRoute = new AcTruckRoute();
$where = [];
$where[]='and';
$where[] = ['=','pid',Yii::$app->session->get('pid')];
if($online_id){
$where[] = ['=','online_id',$online_id];
}
$where[] = ['=','deleted',0];
$data = $AcTruckRoute->find()->where($where)->orderby('orderby ASC,id DESC');
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
$truck_ids = [];
foreach($res as $r){
$truck_ids[] = $r->truck_id;
}
$AcTruck = new AcTruck();
$where = [];
$where[] = 'and';
$where[] = ['=','pid',$pid];
$where[] = ['IN','id',$truck_ids];
$where[] = ['=','deleted',0];
$trucks = $AcTruck->find()->where($where)->indexby('id')->all();
$status = Yii::$app->params['CommonStatus'];
return $this->render('list',[
'list'=>$res,
'pager' => $pages,
'status'=>$status,
'trucks'=>$trucks,
'online_id'=>$online_id,
'truckol'=>$truckol
]);
}
public function actionNew()
{
$status = Yii::$app->params['CommonStatus'];
$AcTruckRoute = [];
$AcTruckRoute['status_code'] = 0;
$online_id = Yii::$app->session->get('online_id'); //发车任务ID
$truckol = Yii::$app->session->get('truckOnline'); //发车任务
$AcTruckRoute['truck_id'] = $truckol['truck_id'];
$AcTruckRoute['truck_num'] = $truckol['truck_num'];
return $this->render('modify',['status'=>$status,'detail'=>$AcTruckRoute,'online_id'=>$online_id,'truckol'=>$truckol]);
}
//编辑板车位置信息
public function actionEdit()
{
$id = Yii::$app->request->get('id'); //记录ID
$online_id = Yii::$app->session->get('online_id'); //发车任务ID
$truckol = Yii::$app->session->get('truckOnline'); //发车任务
$AcTruckRoute = new AcTruckRoute();
$route = $AcTruckRoute->findOne($id);
if(!$route){
$post = Yii::$app->request->post();
$return = [];
$return['msg'] = '位置记录数据获取异常,请重新选择获取';
$return['errorcode'] = 0;
$return['url'] = '';
$return['buttons'] = [
['title'=>'好的,我知道了','class'=>'info','url'=>$return['url']]
];
$return['content'] = $return['msg'];
$return['class'] = 'warning';
Yii::$app->request->setBodyParams($return);
return Yii::$app->runAction('index/msg');
}
$route = $route->toArray();
$route['truck_id'] = $truckol['truck_id'];
$route['online_id'] = $online_id;
$route['truck_num'] = $truckol['truck_num'];
$status = Yii::$app->params['CommonStatus'];
return $this->render('modify',['status'=>$status,'detail'=>$route,'online_id'=>$online_id,'truckol'=>$truckol]);
}
//保存位置记录信息
public function actionSave()
{
$post = Yii::$app->request->post();
$id = (int)$post['id'];
$pid = Yii::$app->session->get('pid');
$online_id = Yii::$app->session->get('online_id');
$truckol = Yii::$app->session->get('truckOnline'); //发车任务
$data = [];
$data['truck_id'] = $truckol['truck_id'];
$data['online_id'] = $online_id;
//格式化数据
//目标键=》POST键
$cols = ['longt'=>'lng','lat'=>'lat','addr'=>'addr'];
foreach($cols as $col=>$key){
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
}
$cols = ['orderby'=>'orderby','status_code'=>'status_code'];
foreach($cols as $col=>$key){
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
}
$_time = time();
$key = 'update_at';
$data[$key] = isset($post[$key]) ? strtotime($post[$key]) : $_time;
if(!$id){
$data['create_at'] = $_time;
}
$data['pid'] = $pid;
//保存位置资料
$AcTruckRoute = new AcTruckRoute();
foreach($data as $key=>$val){
$AcTruckRoute->$key = $val;
}
if($id){
$res = $AcTruckRoute->updateAll($data,['id'=>$id]);
}else{
$res = $AcTruckRoute->save();
$id = $AcTruckRoute->attributes['id']; //获取插入后id
}
if($res){
\Yii::$app->getSession()->setFlash('success', '信息保存成功!');
return $this->redirect(['edit','id'=>$id]);
}else{
\Yii::$app->getSession()->setFlash('warning', '信息保存失败!');
return $this->goBack();
}
}
//删除记录
public function actionDelete()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$pid = Yii::$app->session->get('pid');
$return = [];
$model = new AcTruckRoute();
$route = $model->findOne($id);
if(!$route){
$return['msg'] = '数据不存在,删除失败';
$return['errorcode'] = 404;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
if($route->pid !=$pid){
$return['msg'] = '非本平台数据,不允许操作';
$return['errorcode'] = 400;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
if($route->deleted !=0){
$return['msg'] = '数据已被删除过,操作无效';
$return['errorcode'] = 400;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
$route->deleted = 1;
$res = $route->save();
$return['url'] = '';
$return['timeout'] = 1; //n秒后自动跳转
$return['status'] = 0;
if($res){
$return['msg'] = '位置记录删除成功';
$return['errorcode'] = 200;
$return['data'] = $id;
}else{
$return['msg'] = '位置记录删除失败';
$return['errorcode'] = 0;
}
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
public function actionAjax()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$pid = Yii::$app->session->get('pid');
$return = [];
$model = new AcTruckRoute();
$route = $model->findOne($id);
if(!$route){
$return['msg'] = '数据不存在,删除失败';
$return['errorcode'] = 404;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
if($route->pid !=$pid){
$return['msg'] = '非本平台数据,不允许操作';
$return['errorcode'] = 400;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
if($route->deleted !=0){
$return['msg'] = '数据已被删除,操作无效';
$return['errorcode'] = 400;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
$return['timeout'] = 1; //n秒后自动跳转
$res = true;
switch($get['do'])
{
case 'show':
if($route->status_code!=1){
$route->status_code = 1;
$res = $route->save();
}
if($res){
$return['msg'] = '记录显示标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'success'];
}else{
$return['msg'] = '客车上板标记失败';
$return['errorcode'] = 0;
}
break;
case 'hide':
if($route->status_code!=0){
$route->status_code = 0;
$res = $route->save();
}
if($res){
$return['msg'] = '记录隐藏标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'success'];
}else{
$return['msg'] = '客车上板标记失败';
$return['errorcode'] = 0;
}
break;
default:
break;
}
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
}
+252
View File
@@ -0,0 +1,252 @@
<?php
/**
* @Author: fm453
* @Date: 2018-08-17 19:39:41
* @Last Modified by: fm453
* @Last Modified time: 2021-04-26 22:56:16
* @Email: fm453@lukegzs.com
*/
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\helpers\Url;
use common\models\CAttachment;
use common\components\Attachment;
class UploadController extends \yii\web\Controller
{
public $enableCsrfValidation = false; //取消csrf令牌验证;不取消的话文件上传会失败
public function checkPid()
{
parent::init();
$session = Yii::$app->session;
if(isset($_GET['pid']) && (int)$_GET['pid']>0){
$session->set('pid',(int)$_GET['pid']);
}
$pid = $session->get('pid');
if(!$pid){
return Yii::$app->response->redirect(['index/index']);
}
return $pid;
}
//主界面
public function actionIndex()
{
return $this->render('../layouts/dev',[]);
}
public function actionImage()
{
global $_HI,$_FM;
$this->checkPid();
$siteId = Yii::$app->params['siteId'];
$session = Yii::$app->session;
$pid = (int)$session->get('pid');
$model = new CAttachment();
$search = $where = [];
$where[] = 'and';
$where[] = ['=','status_code',1];
$where[] = ['=','type',0];
$where[] = ['=','siteid',$siteId];
$where[] = ['=','pid',$pid];
$post = Yii::$app->request->post();
if(isset($post['search'])){
$search = $post['search'];
$session->set('images::search',$search);
}elseif($session->get('images::search')){
$search = $session->get('images::search');
}
if($search){
if($search['create_m']){
$start = strtotime($search['create_m']);
$s = date("Y-m-d H:i:s", $start);
$ldm = strtotime("last day of ".$s);
$m = date("Y-m-d",$ldm)." 23:59:59";
$end = strtotime($m);
$where[] = ['between','create_at',$start,$end];
}elseif(!empty($search['create_after']) && !empty($search['create_before'])){
$start = strtotime($search['create_after']);
$end = strtotime($search['create_before']);
$where[] = ['between','create_at',$start,$end];
}elseif(!empty($search['create_after'])){
$start = strtotime($search['create_after']);
$where[] = ['>=','create_at',$start];
}elseif(!empty($search['create_before'])){
$end = strtotime($search['create_before']);
$where[] = ['<=','create_at',$end];
}
if($search['title']){
$where[] = ['LIKE','title',$search['title']];
}
}
//分页
$orderby = ['id' => SORT_DESC];
$Attachment = new Attachment();
$list = $Attachment->getData($model,$where,$orderby);
$pager = $Attachment->getPagination();
//附件网址前缀
$src = Url::base(true)."/../../upload"; //在网站根目录下使用upload/pics目录;适合使用yii框架主目录入口而非绑定子域名的情形
if($_SERVER['DOCUMENT_ROOT'].'/upload' != Yii::getAlias("@upload")){
// $src = Url::toRoute(['attach/index','img'=>'']); //换用网络加载转换的方式-反应慢
$src = Yii::$app->params['attachSrc'].Yii::$app->params['attachDir'];
}
$callback = isset($_GET['callback']) ? $_GET['callback'] : 'thumb';
return $this->render('image',[
'list'=>$list,
'pager' => $pager,
'src'=>$src,
'callback'=>$callback
]);
}
public function actionImages()
{
global $_HI,$_FM;
$this->checkPid();
$siteId = Yii::$app->params['siteId'];
$session = Yii::$app->session;
$pid = (int)$session->get('pid');
$model = new CAttachment();
$search = $where = [];
$where[] = 'and';
$where[] = ['=','status_code',1];
$where[] = ['=','type',0];
$where[] = ['=','siteid',$siteId];
$where[] = ['=','pid',$pid];
$post = Yii::$app->request->post();
if(isset($post['search'])){
$search = $post['search'];
$session->set('images::search',$search);
}elseif($session->get('images::search')){
$search = $session->get('images::search');
}
if($search){
if($search['create_m']){
$start = strtotime($search['create_m']);
$s = date("Y-m-d H:i:s", $start);
$ldm = strtotime("last day of ".$s);
$m = date("Y-m-d",$ldm)." 23:59:59";
$end = strtotime($m);
$where[] = ['between','create_at',$start,$end];
}elseif(!empty($search['create_after']) && !empty($search['create_before'])){
$start = strtotime($search['create_after']);
$end = strtotime($search['create_before']);
$where[] = ['between','create_at',$start,$end];
}elseif(!empty($search['create_after'])){
$start = strtotime($search['create_after']);
$where[] = ['>=','create_at',$start];
}elseif(!empty($search['create_before'])){
$end = strtotime($search['create_before']);
$where[] = ['<=','create_at',$end];
}
if($search['title']){
$where[] = ['LIKE','title',$search['title']];
}
}
//分页
$orderby = ['id' => SORT_DESC];
$Attachment = new Attachment();
$list = $Attachment->getData($model,$where,$orderby);
$pager = $Attachment->getPagination();
//附件网址前缀
$src = Url::base(true)."/../../upload"; //在网站根目录下使用upload/pics目录;适合使用yii框架主目录入口而非绑定子域名的情形
if($_SERVER['DOCUMENT_ROOT'].'/upload' != Yii::getAlias("@upload")){
// $src = Url::toRoute(['attach/index','img'=>'']); //换用网络加载转换的方式-反应慢
$src = Yii::$app->params['attachSrc'].Yii::$app->params['attachDir'];
}
$callback = isset($_GET['callback']) ? $_GET['callback'] : 'thumb';
return $this->render('images',[
'list'=>$list,
'search'=>$search,
'pager' => $pager,
'src'=>$src,
'callback'=>$callback
]);
}
public function actionImage_save()
{
global $_HI,$_FM;
$post = Yii::$app->request->post();
if(!$post['root']){
die(json_encode('没有传入文件路径'));
}
// 文件附件目录
$attachDir = Yii::getAlias('@upload'); //附件所在目录
$targetDir = "/pics"; //开始构建目标转存目录
if (!file_exists($attachDir . $targetDir)) {
@mkdir($attachDir . $targetDir);
}
$session = Yii::$app->session;
$siteId = Yii::$app->params['siteId'];
$targetDir .= '/'.$siteId;
if (!file_exists($attachDir . $targetDir)) {
@mkdir($attachDir . $targetDir);
}
$pid = (int)$session->get('pid');
$targetDir .= '/'.$pid;
if (!file_exists($attachDir . $targetDir)) {
@mkdir($attachDir . $targetDir);
}
$timeDir = date('Ym');
$targetDir .= "/".$timeDir;
if (!file_exists($attachDir . $targetDir)) {
@mkdir($attachDir . $targetDir);
}
//处理请求的文件信息
$title = isset($post['name']) ? $post['name'] : md5(TIMESTAMP).'.jpg';
//取后缀名
if($post['ext']){
$suffix = strtolower($post['ext']);
}else{
$_names = explode('.',$title);
$suffix = tolower($_names[count($_names)-1]);
}
$newName = date('dHis',TIMESTAMP).'_'.md5($title);
$root = $post['root'];
$newFile = $attachDir . $targetDir."/".$newName.".".$suffix;
$tempfile = $post['root'];
//文件移动,【完整文件名-含路径,目标目录】
rename($tempfile,$newFile);
$options = json_encode($post['params']);
//文件入库
$model = new CAttachment();
$model->siteid = $siteId;
$model->pid = $pid;
$model->uid = $_FM['user']['uid'];
$model->mid = 0;
$model->type = 0;
$model->status_code = 1;
$model->title = $title;
$model->filesize = $post['size'];
$model->route = $targetDir."/".$newName.".".$suffix;
$model->options = $options;
$model->update_at = $model->create_at = time();
$model->save();
$id = $model->attributes['id']; //获取插入后id
$return=[];
$return['msg'] = '';
$return['code'] = 0;
$return['path'] = $model->route;
if(!$id){
$return['code'] = 453100;
$return['msg'] = $model->getErrors();
}
$return['data'] = ['id'=>$id];
die(json_encode($return,JSON_UNESCAPED_UNICODE));
}
}
+307
View File
@@ -0,0 +1,307 @@
<?php
/**
* @Author: fm453
* @Date: 2018-06-04 11:06:07
* @Last Modified by: fm453
* @Last Modified time: 2021-09-11 08:07:18
* @Email: fm453@lukegzs.com
*/
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\helpers\Url;
use addons\models\AcWeituoren;
use common\models\Fans;
class WeituorenController extends \yii\web\Controller
{
//替代常规的_construct 析构函数;其他方法调用前执行
public function init()
{
parent::init();
$session = Yii::$app->session;
if(isset($_GET['pid']) && (int)$_GET['pid']>0){
$session->set('pid',(int)$_GET['pid']);
}
$pid = $session->get('pid');
if(!$pid){
return Yii::$app->response->redirect(['index/index']);
}
}
//主界面
public function actionIndex()
{
return $this->render('../layouts/dev',[]);
}
//列表
public function actionList()
{
$model = new AcWeituoren();
$pid = Yii::$app->session->get('pid');
$session = Yii::$app->session;
$where = $where2 = [];
$where2[]='and';
$where['pid'] = $pid;
$post = Yii::$app->request->post();
$search = [];
$searchSession = 'weituoren::search';
if(isset($_GET['reset']) && $_GET['reset']==1){
$post['search'] = [];
}
if(isset($post['search'])){
$search = $post['search'];
$session->set($searchSession,$search);
}elseif($session->get($searchSession)){
$search = $session->get($searchSession);
}
$search['title'] = isset($search['title']) ? trim(htmlspecialchars_decode($search['title'])) : '';
if(!empty($search['title'])){
$where2[] = ['LIKE','company',$search['title']];
}
$where['deleted'] = 0;
$data = $model->find()->where($where);
if($search['title']){
$data = $data->andwhere($where2);
}
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
$status = Yii::$app->params['CommonStatus'];
return $this->render('list',[
'weituorens'=>$res,
'pager' => $pages,
'status'=>$status,
'search'=>$search
]);
}
public function actionSelect()
{
$model = new AcWeituoren();
$pid = Yii::$app->session->get('pid');
$session = Yii::$app->session;
$where = $where2 = [];
$where2[]='and';
$where['pid'] = $pid;
$post = Yii::$app->request->post();
$search = [];
$searchSession = 'weituoren::search';
if(isset($_GET['reset']) && $_GET['reset']==1){
$post['search'] = [];
}
if(isset($post['search'])){
$search = $post['search'];
$session->set($searchSession,$search);
}elseif($session->get($searchSession)){
$search = $session->get($searchSession);
}
$search['title'] = isset($search['title']) ? trim(htmlspecialchars_decode($search['title'])) : '';
if(!empty($search['title'])){
$where2[] = ['LIKE','company',$search['title']];
}
$where['deleted'] = 0;
$data = $model->find()->where($where);
if($search['title']){
$data = $data->andwhere($where2);
}
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
$status = Yii::$app->params['CommonStatus'];
$callback = !empty(Yii::$app->request->get('callback')) ? Yii::$app->request->get('callback') : 'weituoren';
return $this->render('select',[
'weituorens'=>$res,
'pager' => $pages,
'status'=>$status,
'search'=>$search,
'callback'=>$callback
]);
}
public function actionNew()
{
return $this->render('modify',[]);
}
//编辑资料
public function actionEdit()
{
$model = new AcWeituoren();
$id = Yii::$app->request->get('id');
$res = $model->find()->where(['id' => $id])->one();
if($res){
$res = $res->toArray();
}
return $this->render('modify',['detail'=>$res]);
}
//保存资料
public function actionSave()
{
$post = Yii::$app->request->post();
$id = (int)$post['id'];
$pid = Yii::$app->session->get('pid');
//格式化数据
//目标键=》POST键
$cols = ['company'=>'company','name'=>'name','mobile'=>'mobile'];
foreach($cols as $col=>$key){
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
}
//查询手机号是否在库
$hasWeituoren = AcWeituoren::find()->where(['mobile'=>$data['mobile']])->one();
if($hasWeituoren){
if($id && $id==$hasWeituoren->id){
}else{
$id = $hasWeituoren->id;
\Yii::$app->getSession()->setFlash('danger', '保存失败,该手机号对应的委托单位已在库,系统自动现在为您调出其资料!');
return $this->redirect(['edit','id'=>$id]);
}
}
//查询对应的系统用户
$userModel = new Fans();
$user = $userModel->findByUsername($data['mobile']);
if(empty($user)){
$pwd = Yii::$app->params['defaultFansPassword'];
$userModel->mobile = $data['mobile'];
$userModel->email = $data['mobile'].'@hiluker.com';
$userModel->setPassword($pwd);
$userModel->generateAuthKey();
$userModel->created_at = time();
$userModel->from = 'ctms';
$userModel->save();
}
$cols = ['status_code'=>'status_code','deleted'=>'deleted'];
foreach($cols as $col=>$key){
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
}
$data['create_at'] = time();
$data['update_at'] = $data['create_at'];
$data['pid'] = $pid;
//保存通讯录资料
$AcWeituoren = new AcWeituoren();
foreach($data as $key=>$val){
$AcWeituoren->$key = $val;
}
if($id){
$AcWeituoren->id = $id;
unset($data['create_at']);
$res = $AcWeituoren->updateAll($data,['id'=>$id]);
}else{
$res = $AcWeituoren->save();
$id = $AcWeituoren->attributes['id']; //获取插入后id
}
if($res){
\Yii::$app->getSession()->setFlash('success', '委托单位信息保存成功!');
return $this->redirect(['edit','id'=>$id]);
}else{
\Yii::$app->getSession()->setFlash('warning', '委托单位信息保存失败!');
return $this->goBack();
}
}
//删除
public function actionDelete()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['pid'] = Yii::$app->session->get('pid');
$where['id'] = $id;
$data['update_at'] = time();
$data['deleted'] = 1;
$model = new AcWeituoren();
foreach($data as $key=>$val){
$model->$key = $val;
}
$model->id = $id;
$res = $model->updateAll($data,$where);
$return = [];
$return['url'] = Url::toRoute('weituoren/list');
$return['timeout'] = 3; //3秒后自动跳转
$return['status'] = 0;
if($res){
$return['msg'] = '委托单位删除成功';
$return['errorcode'] = 200;
$return['data'] = $id;
}else{
$return['msg'] = '委托单位删除失败';
$return['errorcode'] = 0;
}
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
public function actionAjax()
{
$get = Yii::$app->request->get();
$post = Yii::$app->request->post();
$id = (int)$get['id'];
$data = $where = [];
$where['pid'] = Yii::$app->session->get('pid');
$where['id'] = $id;
$data['update_at'] = time();
$model = new AcWeituoren();
$res = $model->find()->where(['id' => $id])->one();
$return = [];
$return['timeout'] = 1; //3秒后自动跳转
$return['status'] = 0;
$return['ajax'] = 1;
if($res){
$res = $res->toArray();
}else{
$return['msg'] = '委托单位数据不存在';
$return['errorcode'] = 404;
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
switch($get['do'])
{
case 'out':
$data['status'] = 0;
$model->id = $id;
$res = $model->updateAll($data,$where);
if($res){
$return['msg'] = '委托单位隐藏标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'info'];
}else{
$return['msg'] = '委托单位隐藏标记失败';
$return['errorcode'] = 0;
}
break;
case 'in':
$data['status'] = 1;
$model->id = $id;
$res = $model->updateAll($data,$where);
if($res){
$return['msg'] = '委托单位显示标记成功';
$return['errorcode'] = 200;
$return['data'] = ['css'=>'default'];
}else{
$return['msg'] = '委托单位显示标记失败';
$return['errorcode'] = 0;
}
break;
default:
break;
}
exit(json_encode($return,JSON_UNESCAPED_UNICODE));
}
}
+22
View File
@@ -0,0 +1,22 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>恭喜,站点创建成功!</title>
<link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.4/css/bootstrap.min.css">
<script src="//cdn.bootcss.com/jquery/1.11.2/jquery.min.js"></script>
<script src="//cdn.bootcss.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container" style="margin-top:9%;">
<div class="jumbotron">
<div class="panel panel-success">
<div class="panel-heading"><h1>恭喜, 站点创建成功!</h1></div>
</div>
<p><h3>站点创建成功,本页面由系统自动生成。</h3></p>
<p><li>本页面在FTP根目录下的index.html</li></p>
<p><li>您可以删除或覆盖本页面</li></p>
</div>
</div>
</body>
</html>
+317
View File
@@ -0,0 +1,317 @@
<?php
#
# @Author: fm453
# @Date: 2018-08-17 17:56:16
# @Last modified by: fm453
# @Last modified time: 2024-07-13T16:31:49+08:00
# @Email: fm453@lukegzs.com
$menu = $v2 = array();
$v2[] = array(
'name' => '欢迎页',
'route' => '/index/welcome',
'data' => '',
);
$v2[] = array(
'name' => '全部功能',
'route' => '/index/menus',
'data' => '',
);
$menu[] = array(
'name' => '主工作台',
'parent' => null,
'route' => '',
'data' => '{"icon":"fa fa-home"}',
'_child' => $v2
);
$v2 = array();
$v3 = array();
$v3[] = array(
'name' => '合同列表',
'route' => '/order/list',
'data' => '',
);
$v3[] = array(
'name' => '新签合同',
'route' => '/order/new',
'data' => '',
);
$v3[] = array(
'name' => '预约清单',
'route' => '/orderpre/list',
'data' => '',
);
$v2[] = array(
'name' => '订单管理',
'route' => '/order/index',
'data' => '{"icon":"fa fa-list"}',
'_child'=>$v3
);
$v2[] = array(
'name' => '装车安排',
'route' => '/truckol/list',
'data' => '{"icon":"fa fa-hourglass-half fa-spin"}',
);
$v2[] = array(
'name' => '承运清单',
'route' => '/truckcar/list',
'data' => '{"icon":"fa fa-industry"}',
);
$v2[] = array(
'name' => '出车清单',
'route' => '/truckol/index',
'data' => '{"icon":"fa fa-bus"}',
);
$menu[] = array(
'name' => '业务管理',
'parent' => null,
'route' => '',
'data' => '{"icon":"fa fa-desktop"}',
'_child' => $v2
);
$v2 = array();
$v3 = array();
$v3[] = array(
'name' => '车主列表',
'route' => '/carowner/list',
'data' => '',
);
$v3[] = array(
'name' => '新增车主',
'route' => '/carowner/new',
'data' => '',
);
$v2[] = array(
'name' => '车主管理',
'route' => '/carowner/index',
'data' => '{"icon":"fa fa-users"}',
'_child'=>$v3
);
$v3 = array();
$v3[] = array(
'name' => '客车列表',
'route' => '/car/list',
'data' => '',
);
$v3[] = array(
'name' => '新增客车',
'route' => '/car/new',
'data' => '',
);
$v2[] = array(
'name' => '客车管理',
'route' => '/car/index',
'data' => '{"icon":"fa fa-car"}',
'_child'=>$v3
);
$v3 = array();
$v3[] = array(
'name' => '客户清单',
'route' => '/contact/list',
'data' => '',
);
$v3[] = array(
'name' => '新增客户',
'route' => '/contact/new',
'data' => '',
);
$v2[] = array(
'name' => '客户清单',
'route' => '/contact/index',
'data' => '{"icon":"fa fa-users"}',
'_child'=>$v3
);
$v3 = array();
$v3[] = array(
'name' => '单位列表',
'route' => '/weituoren/list',
'data' => ''
);
$v3[] = array(
'name' => '新增单位',
'route' => '/weituoren/new',
'data' => '',
);
$v2[] = array(
'name' => '合作单位',
'route' => '/weituoren/index',
'data' => '{"icon":"fa fa-server"}',
'_child'=>$v3
);
$menu[] = array(
'name' => '客户管理',
'parent' => null,
'route' => '',
'data' => '{"icon":"fa fa-users"}',
'_child' => $v2
);
$v2 = array();
$v3 = array();
$v3[] = array(
'name' => '运单费用',
'route' => '/feeorder/index',
'data' => '',
);
$v3[] = array(
'name' => '出车款',
'route' => '/feedriver/index',
'data' => '',
);
$v3[] = array(
'name' => '其他费用',
'route' => '/fee/index',
'data' => '',
);
$v3[] = array(
'name' => '待审合同',
'route' => '/order/list',
'data' => '',
);
$v2[] = array(
'name' => '财务管理',
'route' => '/oa/fee',
'data' => '{"icon":"fa fa-money"}',
'_child'=>$v3
);
$v3 = array();
$v3[] = array(
'name' => '网点清单',
'route' => '/store/list',
'data' => '',
);
$v3[] = array(
'name' => '新增网点',
'route' => '/store/new',
'data' => '',
);
$v2[] = array(
'name' => '网点管理',
'route' => '/store/index',
'data' => '{"icon":"fa fa-cubes"}',
'_child'=>$v3
);
$v3 = array();
$v3[] = array(
'name' => '员工清单',
'route' => '/employee/list',
'data' => '',
);
$v3[] = array(
'name' => '新增员工',
'route' => '/employee/new',
'data' => '',
);
$v2[] = array(
'name' => '员工管理',
'route' => '/employee/index',
'data' => '{"icon":"fa fa-users"}',
'_child'=>$v3
);
$v2[] = array(
'name' => '板车管理',
'route' => '/truck/list',
'data' => '{"icon":"fa fa-truck"}',
);
$v2[] = array(
'name' => '司机管理',
'route' => '/driver/list',
'data' => '{"icon":"fa fa-male"}',
);
$v2[] = array(
'name' => '群发短信',
'route' => '/sms/gsend',
'data' => '{"icon":"fa fa-fax"}'
);
$v2[] = array(
'name' => 'GPS分布',
'route' => '/gps/index',
'data' => '{"icon":"fa fa-map-o"}'
);
$menu[] = array(
'name' => '办公管理',
'parent' => null,
'route' => '',
'data' => '{"icon":"fa fa-coffee"}',
'_child' => $v2
);
$v2 = [];
$v3 = [];
$v3[] = array(
'name' => '文章列表',
'route' => '/news/list',
'data' => '',
);
$v3[] = array(
'name' => '新增文章',
'route' => '/news/new',
'data' => '',
);
$v3[] = array(
'name' => '文章分类',
'route' => '/newscat/list',
'data' => '',
);
$v2[] = array(
'name' => '文章管理',
'route' => '/news/index',
'data' => '{"icon":"fa fa-sliders"}',
'_child'=>$v3
);
$v2[] = array(
'name' => '公告',
'route' => '/notice/list',
'data' => '{"icon":"fa fa-res"}'
);
$menu[] = array(
'name' => '内容管理',
'parent' => null,
'route' => '',
'data' => '{"icon":"fa fa-list"}',
'_child' => $v2
);
$v2 = array();
$v2[] = array(
'name' => '平台配置',
'route' => '/plat/ext',
'data' => '',
);
$v3 = array();
$v3[] = array(
'name' => '品牌列表',
'route' => '/carbrand/list',
'data' => '',
);
$v3[] = array(
'name' => '车型清单',
'route' => '/carseries/list',
'data' => '',
);
$v2[] = array(
'name' => '客车参数',
'route' => '/carowner/list',
'data' => '{"icon":"fa fa-legal"}',
'_child'=>$v3
);
$menu[] = array(
'name' => '系统管理',
'parent' => null,
'route' => '',
'data' => '{"icon":"fa fa-gears"}',
'_child' => $v2
);
return $menu;
+24
View File
@@ -0,0 +1,24 @@
<?php
/**
* @Author: fm453
* @Date: 2018-08-17 17:56:16
* @Last Modified by: fm453
* @Last Modified time: 2021-09-10 21:01:53
* @Email: fm453@lukegzs.com
*/
$menu = $v2 = array();
$v2[] = array(
'name' => '功能路径',
'route' => '/admin/route/index',
'data' => '',
);
$menu[] = array(
'name' => '权限申请',
'parent' => null,
'route' => '',
'data' => '{"icon":"fa fa-key"}',
'_child' => $v2
);
return $menu;
+1
View File
@@ -0,0 +1 @@
*
+220
View File
@@ -0,0 +1,220 @@
<?php
/**
* @Author: fm453
* @Date: 2021-09-10 17:33:23
* @Last Modified by: fm453
* @Last Modified time: 2021-09-10 17:34:36
* @Email: fm453@lukegzs.com
*/
namespace backend\models;
use Yii;
use yii\db\ActiveRecord;
use yii\behaviors\TimestampBehavior;
use yii\base\NotSupportedException;
use backend\models\AuthAssignment;
use yii\web\IdentityInterface;
class Adminer extends ActiveRecord implements IdentityInterface
{
public $password;
const STATUS_DELETE = 0;
const STATUS_ACTIVE = 10;
public static $statusTexts = [
self::STATUS_DELETE => '禁用',
self::STATUS_ACTIVE => '启用',
];
public static $statusStyles = [
self::STATUS_DELETE => 'label-warning',
self::STATUS_ACTIVE => 'label-info',
];
public static function tableName() {
return '{{%c_adminer}}';
}
public function behaviors() {
return [
TimestampBehavior::className(),
];
}
public function rules() {
return [
[['username', 'email'], 'required'],
[['username'], 'string', 'length' => [5, 32]],
[['nickname'],'string','max'=>32],
[['password'], 'required', 'on' => ['create']],
[['auth_key'], 'string', 'length' => 32],
[['username', 'email','mobile'], 'unique'],
[['email'], 'email'],
['status', 'default', 'value' => self::STATUS_ACTIVE],
['status', 'in', 'range' => [
self::STATUS_DELETE,self::STATUS_ACTIVE,1
]], //状态值1是软删除
[['status', 'created_at', 'updated_at'], 'integer'],
[['username', 'password_hash', 'password_reset_token', 'email'], 'string', 'max' => 255],
//去除首尾空白
[['username', 'nickname', 'mobile', 'email'], 'filter', 'filter' => 'trim'],
];
}
public function attributeLabels() {
return [
'id' => 'ID',
'username' => Yii::t('common' ,'Username'),
'nickname' => '姓名',
'auth_key' => Yii::t('common' ,'Password'),
'password_hash' => 'Password Hash',
'email' => Yii::t('common' ,'Email'),
'mobile' => Yii::t('common' ,'Mobile'),
'status' => '状态',
'created_at' => 'Created At',
'updated_at' => 'Updated At',
'user_role' => '所属角色',
'role' => Yii::t('common' ,'Role'),
];
}
public function scenarios() {
$scenarios = parent::scenarios();
$scenarios['create'] = ['username', 'email', 'password', 'status'];
$scenarios['update'] = ['username', 'email', 'password', 'status'];
return $scenarios;
}
/*用户组 S*/
public function getUsergrouplist()
{
/**
* 第一个参数为要关联的字表模型类名称,
*第二个参数指定 通过子表的 customer_id 去关联主表的 id 字段
*/
return $this->hasMany(AuthAssignment::className(), ['user_id' => 'id']);
}
public function getUsergroup()
{
/**
* 第一个参数为要关联的字表模型类名称,
*第二个参数指定 通过子表的 customer_id 去关联主表的 id 字段
*/
return $this->hasOne(AuthAssignment::className(), ['user_id' => 'id']);
}
/*用户组 E*/
/**
* Generates "remember me" authentication key
*/
public function generateAuthKey()
{
$this->auth_key = Yii::$app->security->generateRandomString();
}
public function beforeSave($insert) {
if($this->isNewRecord) {
$this->generateAuthKey();
}
if(!empty($this->password)) $this->setPassword($this->password);
return parent::beforeSave($insert);
}
/**
* 生成加密后的密码
* @param [string] $password [用户密码]
*/
public function setPassword($password) {
$this->password_hash = Yii::$app->security->generatePasswordHash($password);
}
/*获取所有用户*/
public function get_all_user(){
// $user = Yii::$app->db->createCommand('select * from '. tableName())->queryAll();
$user = static::findAll();
return $user;
}
/**
* 获取账号信息
* @param [int] $id [后台用户id]
*/
public static function findIdentity($id) {
return static::findOne(['id' => $id, 'status' => self::STATUS_ACTIVE]);
}
public static function findIdentityByAccessToken($token, $type = null) {
throw new NotSupportedException('"findIdentityByAccessToken" is not implemented.');
}
/**
* 获取账号信息
* @param [string] $username [用户名]
*/
public static function findByUsername($username) {
return static::findOne(['username' => $username, 'status' => self::STATUS_ACTIVE]);
}
//获取用户所在的用户组
public function getGroup() {
return implode(',', array_keys(Yii::$app->authManager->getRolesByUser($this->id)));
}
/**
* 获取账号主键值(id)
*/
public function getId() {
return $this->getPrimaryKey();
}
/**
* 获取账号auth_key值
*/
public function getAuthKey() {
return $this->auth_key;
}
/**
* 验证auth_key
* @param [string] $authKey [auth key]
*/
public function validateAuthKey($authKey) {
return $this->getAuthKey() === $authKey;
}
/**
* 验证用户密码
* @param [string] $password [用户密码]
*/
public function validatePassword($password) {
return Yii::$app->security->validatePassword($password, $this->password_hash);
return true;
}
/**
* 获取账号状态
*/
public function getStatus() {
return self::$statusTexts[$this->status];
}
/**
* 获取账号状态样式
*/
public function getStatusStyle() {
return self::$statusStyles[$this->status];
}
/**
* 获取状态
*/
public function getStatusTexts() {
return self::$statusTexts;
}
}
+65
View File
@@ -0,0 +1,65 @@
<?php
/**
* @Author: fm453
* @Date: 2021-09-10 17:34:17
* @Last Modified by: fm453
* @Last Modified time: 2021-09-10 17:34:25
* @Email: fm453@lukegzs.com
*/
namespace backend\models;
use Yii;
/**
* This is the model class for table "auth_assignment".
*
* @property string $item_name
* @property string $user_id
* @property integer $created_at
*
* @property AuthItem $itemName
*/
class AuthAssignment extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return '{{%auth_assignment}}';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['item_name', 'user_id'], 'required'],
[['created_at'], 'integer'],
[['item_name', 'user_id'], 'string', 'max' => 64],
[['item_name'], 'exist', 'skipOnError' => true, 'targetClass' => AuthItem::className(), 'targetAttribute' => ['item_name' => 'name']],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'item_name' => 'Item Name',
'user_id' => 'User ID',
'created_at' => 'Created At',
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getItemName()
{
return $this->hasOne(AuthItem::className(), ['name' => 'item_name']);
}
}
+224
View File
@@ -0,0 +1,224 @@
<?php
/**
* @Author: fm453
* @Date: 2021-09-10 17:35:20
* @Last Modified by: fm453
* @Last Modified time: 2021-09-10 17:35:48
* @Email: fm453@lukegzs.com
*/
namespace backend\models;
use Yii;
use common\models\base\BaseModel;
use backend\models\Menu;
/**
* This is the model class for table "auth_item".
*
* @property string $name
* @property integer $type
* @property string $description
* @property string $rule_name
* @property string $data
* @property integer $created_at
* @property integer $updated_at
*
* @property AuthAssignment[] $authAssignments
* @property AuthRule $ruleName
* @property AuthItemChild[] $authItemChildren
* @property AuthItemChild[] $authItemChildren0
* @property AuthItem[] $children
* @property AuthItem[] $parents
*/
class AuthItem extends BaseModel
{
const T_ROLE = 1; //角色
const T_POWER = 2; //权限
//定义场景
const SCENARIOS_CREATE = 'create';
const SCENARIOS_DELETE = 'delete';
const SCENARIOS_UPDATE = 'update';
/**
* @inheritdoc
*/
public static function tableName()
{
return '{{%auth_item}}';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['name', 'type'], 'required'],
[['type', 'created_at', 'updated_at'], 'integer'],
[['description', 'data'], 'string'],
[['name', 'rule_name'], 'string', 'max' => 64],
[['rule_name'], 'exist', 'skipOnError' => true, 'targetClass' => AuthRule::className(), 'targetAttribute' => ['rule_name' => 'name']],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'name' => '名称',
'type' => '类型',
'description' => '描述',
'rule_name' => '规则名称',
'data' => 'Data',
'created_at' => '创建时间',
'updated_at' => '更新时间',
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getAuthAssignments()
{
return $this->hasMany(AuthAssignment::className(), ['item_name' => 'name']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getRuleName()
{
return $this->hasOne(AuthRule::className(), ['name' => 'rule_name']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getAuthItemChildren()
{
return $this->hasMany(AuthItemChild::className(), ['parent' => 'name']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getAuthItemChildren0()
{
return $this->hasMany(AuthItemChild::className(), ['child' => 'name']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getChildren()
{
return $this->hasMany(AuthItem::className(), ['name' => 'child'])->viaTable('auth_item_child', ['parent' => 'name']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getParents()
{
return $this->hasMany(AuthItem::className(), ['name' => 'parent'])->viaTable('auth_item_child', ['child' => 'name']);
}
/**
* 场景设置
* @see \yii\base\Model::scenarios()
*/
public function scenarios()
{
$scenarios = [
self:: SCENARIOS_CREATE => ['name', 'type', 'description'],
self:: SCENARIOS_DELETE => ['name'],
self:: SCENARIOS_UPDATE => ['name', 'type', 'description'],
];
return array_merge(parent:: scenarios(), $scenarios);
}
/**
* 角色&权限的创建方法
* @return boolean 返回成功或者失败的状态值
*/
public function addItem()
{
//实例化AuthManager类
$auth = Yii::$app->authManager;
if($this->type == self::T_ROLE){
$item = $auth->createRole($this->name);
$item->description = $this->description?:'创建['.$this->name.']角色';
}else{
$item = $auth->createPermission($this->name);
$item->description = $this->description?:'创建['.$this->name.']权限';
}
return $auth->add($item);
}
/**
* 角色&权限的删除方法
* @return boolean 返回成功或者失败的状态值
*/
public function romoveItem()
{
$this->name = trim($this->name);
if($this->validate()){
$auth = Yii::$app->authManager;
$item = $auth->getRole($this->name)?:$auth->getPermission($this->name);
return $auth->remove($item);
}
return false;
}
/**
* 获取权限
* @param unknown $id
* @throws \Exception
*/
public function getItem($id) {
$model = AuthItem:: findOne(['name'=>$id]);
if(!$model)
throw new \Exception( '编辑的角色或权限不存在!' );
$this-> name = $model-> name;
$this-> type = $model-> type;
$this-> description = $model-> description;
return $this;
}
/**
* 编辑权限
* @param unknown $item_name
* @return boolean
*/
public function updateItem($item_name)
{
$auth = Yii:: $app-> authManager;
if($this->type == self::T_ROLE){
$item = $auth->createRole($this-> name);
$item-> description = $this-> description?: '创建['.$this-> name. ']角色';
}else{
$item = $auth->createPermission($this-> name);
$item-> description = $this-> description?: '创建['.$this-> name. ']权限';
}
return $auth->update($item_name, $item);
}
//获取所有的权限
public function getAllPermission(){
$permission = self::find()->where(['type'=>2])->all();
return $permission;
}
//关联菜单数据
public function getPermissionName(){
return $this->hasOne(Menu::className(), ['route' => 'name']);
}
}
+77
View File
@@ -0,0 +1,77 @@
<?php
/**
* @Author: fm453
* @Date: 2021-04-26 08:32:06
* @Last Modified by: fm453
* @Last Modified time: 2021-09-10 17:36:26
* @Email: fm453@lukegzs.com
*/
namespace backend\models;
use Yii;
/**
* This is the model class for table "auth_item_child".
*
* @property string $parent
* @property string $child
*
* @property AuthItem $parent0
* @property AuthItem $child0
*/
class AuthItemChild extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return '{{%auth_item_child}}';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['parent', 'child'], 'required'],
[['parent', 'child'], 'string', 'max' => 64],
[['parent'], 'exist', 'skipOnError' => true, 'targetClass' => AuthItem::className(), 'targetAttribute' => ['parent' => 'name']],
[['child'], 'exist', 'skipOnError' => true, 'targetClass' => AuthItem::className(), 'targetAttribute' => ['child' => 'name']],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'parent' => 'Parent',
'child' => 'Child',
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getParent0()
{
return $this->hasOne(AuthItem::className(), ['name' => 'parent']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getChild0()
{
return $this->hasOne(AuthItem::className(), ['name' => 'child']);
}
public function getPermission($id){
$permission = self::find()->where(['parent'=>$id])->asArray()->all();
return $permission;
}
}
+67
View File
@@ -0,0 +1,67 @@
<?php
/**
* @Author: fm453
* @Date: 2021-09-10 17:36:45
* @Last Modified by: fm453
* @Last Modified time: 2021-09-10 17:40:19
* @Email: fm453@lukegzs.com
*/
namespace backend\models;
use Yii;
/**
* This is the model class for table "auth_rule".
*
* @property string $name
* @property string $data
* @property integer $created_at
* @property integer $updated_at
*
* @property AuthItem[] $authItems
*/
class AuthRule extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return '{{%auth_rule}}';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['name'], 'required'],
[['data'], 'string'],
[['created_at', 'updated_at'], 'integer'],
[['name'], 'string', 'max' => 64],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'name' => 'Name',
'data' => 'Data',
'created_at' => 'Created At',
'updated_at' => 'Updated At',
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getAuthItems()
{
return $this->hasMany(AuthItem::className(), ['rule_name' => 'name']);
}
}
+85
View File
@@ -0,0 +1,85 @@
<?php
/**
* @Author: fm453
* @Date: 2021-09-10 17:37:16
* @Last Modified by: fm453
* @Last Modified time: 2021-09-10 17:40:11
* @Email: fm453@lukegzs.com
*/
namespace backend\models;
/**
* @author Xianan Huang
*
*/
use Yii;
use yii\base\Model;
use backend\models\AuthRule;
class ItemForm extends Model
{
public $name;
public $type;
public $description;
const T_ROLE = 1; //角色
const T_POWER = 2; //权限
//定义场景
const SCENARIOS_CREATE = 'create';
const SCENARIOS_DELETE = 'delete';
public function rules()
{
return [
[['name', 'type'], 'required'],
['name', 'unique', 'targetClass' => '\common\models\AuthItemModel', 'message' => '此名称已经被占用。'],
['type', 'integer'],
[['name', 'description'], 'string', 'max' => 25],
[['rule_name'], 'exist', 'skipOnError' => true, 'targetClass' => AuthRule::className(), 'targetAttribute' => ['rule_name' => 'name']]
];
}
public function attributeLabels()
{
return [
'name' => '名称',
'type' => '类型',
'description' => '描述',
];
}
/**
* 场景设置
* @see \yii\base\Model::scenarios()
*/
public function scenarios()
{
$scenarios = [
self:: SCENARIOS_CREATE => ['name', 'type', 'description'],
self:: SCENARIOS_DELETE => ['name'],
];
return array_merge(parent:: scenarios(), $scenarios);
}
/**
* 角色&权限的创建方法
* @return boolean 返回成功或者失败的状态值
*/
public function addItem()
{
//实例化AuthManager类
$auth = Yii::$app->authManager;
if($this->type == self::T_ROLE){
$item = $auth->createRole($this->name);
$item->description = $this->description?:'创建['.$this->name.']角色';
}else{
$item = $auth->createPermission($this->name);
$item->description = $this->description?:'创建['.$this->name.']权限';
}
return $auth->add($item);
}
}
+133
View File
@@ -0,0 +1,133 @@
<?php
/**
* @Author: fm453
* @Date: 2021-09-09 22:59:04
* @Last Modified by: fm453
* @Last Modified time: 2021-09-10 19:55:54
* @Email: fm453@lukegzs.com
*/
namespace backend\models;
use Yii;
use yii\base\Model;
use common\models\CLog;
use backend\models\Adminer;
/**
* Login form
*/
class LoginForm extends Model
{
public $username;
public $password;
public $rememberMe = true;
private $_user; //防止被外部程序修改
/**
* @inheritdoc
*/
public function rules()
{
return [
// username and password are both required
[['username', 'password'], 'required'],
// rememberMe must be a boolean value
['rememberMe', 'boolean'],
// password is validated by validatePassword()
['password', 'validatePassword'],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'username' => Yii::t('common','Username'),
'password' => Yii::t('common','Password'),
'rememberMe' => Yii::t('common','Remember Me'),
];
}
/**
* Validates the password.
* This method serves as the inline validation for password.
*
* @param string $attribute the attribute currently being validated
* @param array $params the additional name-value pairs given in the rule
*/
public function validatePassword($attribute, $params)
{
if (!$this->hasErrors()) {
$user = $this->getUser();
if (!$user || !$user->validatePassword($this->password)) {
$this->addError($attribute, Yii::t('common','Incorrect username or password.'));
}
}
}
/**
* Logs in a user using the provided username and password.
*
* @return bool whether the user is logged in successfully
*/
public function login()
{
if ($this->validate()) {
return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0);
}
return false; //如果为true 将允许任意密码登陆
}
/**
* Finds user by [[username]]
*
* @return User|null
*/
protected function getUser()
{
if ($this->_user === null) {
$this->_user = Adminer::findByUsername($this->username); //千万注意后端的登陆使用的是Adminer模型,不是User
}
return $this->_user;
}
//登录记录
public function loginLog(){
$request = Yii::$app->getRequest();
$nowFile = $request -> getScriptFile();
$data = "登陆系统|途径:".$nowFile;
$model = new CLog();
$model->username = $this->username;
$model->ip = Yii::$app->request->userIP;
$model->data = $data;
$model->create_time = time();
$model->save();
//编制邮件发送通知
$message = Yii::$app->mailer->compose();
$message->setFrom(Yii::$app->params['noticeEmail']);
//给登陆者发送
$subject = "账号登陆提醒";
$body = "您的账号【".$this->username."】刚刚登陆了网站:".Yii::$app->getRequest()->absoluteUrl;
$message->setTo(Yii::$app->user->identity->email)
->setSubject($subject)
->setTextBody($body)
->send();
//给管理人员发送
$subject = "账号登陆提醒";
$body = "运维账号【".$this->username."】刚刚登陆了网站:".Yii::$app->getRequest()->absoluteUrl;
$message->setTo('1280880631@qq.com')
->setSubject($subject)
->setTextBody($body)
->send();
}
}
+159
View File
@@ -0,0 +1,159 @@
<?php
/**
* @Author: fm453
* @Date: 2021-09-10 17:39:57
* @Last Modified by: fm453
* @Last Modified time: 2021-09-10 17:40:04
* @Email: fm453@lukegzs.com
*/
namespace backend\models;
use Yii;
/**
* This is the model class for table "c_menu".
*
* @property integer $id
* @property string $name
* @property integer $parent
* @property string $route
* @property integer $order
* @property string $data
*/
class Menu extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return '{{%c_menu}}';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['name'], 'required'],
[['parent', 'sort'], 'integer'],
[['data'], 'string'],
[['status'], 'string'],
[['name'], 'string', 'max' => 128],
[['route'], 'string', 'max' => 256],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'name' => '名称',
'parent' => '父级',
'route' => '路由',
'sort' => '排序',
'data' => '描述',
];
}
//获取顶级菜单列表
public function getAllMenu(){
$menu = Yii::$app->db->createCommand("SELECT * FROM ".$this->tableName()." WHERE parent='0' ")->queryAll();
return $menu;
}
//获取所有菜单列表
public function getMenuList(){
$menu = Yii::$app->db->createCommand("SELECT * FROM ".$this->tableName()." ORDER BY sort ASC ")->queryAll();
$menu = self::list_to_tree($menu,'id','parent');
return $menu;
}
//获取左侧菜单列表
public function getLeftMenuList(){
$uid = Yii::$app->user->identity->getId();
$auth = Yii::$app->authManager;
$Permission = $auth->getPermissionsByUser($uid);
$RoutesList = '';
foreach($Permission as $vo){
$RoutesList .= "'".$vo->name."',";
}
$RoutesList = substr($RoutesList,0,-1);
if($RoutesList == ''){
$RoutesList = "'/index/welcome','/site/index'";
}
$menu = Yii::$app->db->createCommand("SELECT * FROM ".$this->tableName()." WHERE route IN ($RoutesList) ORDER BY `order` ASC")->queryAll();
$menu = Yii::$app->db->createCommand("SELECT * FROM ".$this->tableName()." ORDER BY `order` ASC")->queryAll();
$menu = self::list_to_tree2($menu,'id','parent');
return $menu;
}
//通过id找到router
public function getRouteById($id){
$router = Yii::$app->db->createCommand("SELECT * FROM `".$this->tableName()."` WHERE id='$id'")->queryOne();
return $router['route'];
}
/**
* 把返回的数据集转换成Tree
* @param array $list 要转换的数据集
* @param string $pid parent标记字段
* @param string $level level标记字段
* @return array
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
*/
function list_to_tree($list, $pk='id', $pid = 'pid', $child = '_child', $root = 0) {
// 创建Tree
$tree = array();
if(is_array($list)) {
// 创建基于主键的数组引用
$refer = array();
foreach ($list as $key => $data) {
$refer[$data[$pk]] =& $list[$key];
}
foreach ($list as $key => $data) {
// 判断是否存在parent
$parentId = $data[$pid];
if ($root == $parentId) {
$tree[] =& $list[$key];
}else{
if (isset($refer[$parentId])) {
$parent =& $refer[$parentId];
$list[$key]['name'] ='&nbsp;&nbsp;&nbsp;&nbsp;|--'.$list[$key]['name'];
$parent[$child][] =& $list[$key];
}
}
}
}
return $tree;
}
function list_to_tree2($list, $pk='id', $pid = 'pid', $child = '_child', $root = 0) {
// 创建Tree
$tree = array();
if(is_array($list)) {
// 创建基于主键的数组引用
$refer = array();
foreach ($list as $key => $data) {
$refer[$data[$pk]] =& $list[$key];
}
foreach ($list as $key => $data) {
// 判断是否存在parent
$parentId = $data[$pid];
if ($root == $parentId) {
$tree[] =& $list[$key];
}else{
if (isset($refer[$parentId])) {
$parent =& $refer[$parentId];
$list[$key]['name'] =$list[$key]['name'];
$parent[$child][] =& $list[$key];
}
}
}
}
return $tree;
}
}
+124
View File
@@ -0,0 +1,124 @@
安诚托运物流管理系统
__版本变更_______
2.2.20210910
M:变更主版本号;
M:优化主界面框架显示;
F:梳理主框架数据表关联,明确各用户表使用场景;
M:优化后台超管模式的各项功能;
A:前端会员(Member)可通过用户名或者手机号进行登陆;
M:1号管理员(ID=1)可编辑全部订单;
A:添加后台隐性管理员权限菜单;
M:调整车主CarOwner表、订单Order表、客户清单Contact表、合作单位Weituoren表的操作,将相应的会员数据录入到核心Fans表中;
M:优化订单表中联系信息录入保存时的动作,可同步更新到客户清单;
M:抽离项目共用的数据表模型,集中到顶层目录/*public*/中
A:添加数据看板;暂放在欢迎页(待抽离)
F:修复车主表的数据关联问题:原使用mid关联到UserExt表的,重新建表对应;使用“AcFansExt”模型;
——参考代码——
$model = new AcFansExt();
$exts = [];
$_exts = $model->find()->where(['in','mid',$mids])->andwhere(['pid'=>$pid,'deleted'=>0])->indexBy('id')->all();
foreach($_exts as $ext){
$ext = $ext->toArray();
if(isset($users[$s['id']])){
if($ext['mobile']==$users[$s['id']]['mobile']){
$exts[$ext['mid']][$ext['key']] = $ext['value'];
}
}
}
$exts = AcFansExt::find()->where(['mid' => $res['mid'],'mobile' => $res['mobile'],'pid'=>$pid,'deleted'=>0])->all();
if($exts){
foreach($exts as $ext){
$res[$ext['key']] = $ext['value'];
}
}
/*保存扩展资料 S*/
$AcFansExt = new AcFansExt();
//批量硬删及软删
$AcFansExt->deleteAll(['deleted'=>2,'pid'=>$pid,'mid'=>$user_id]); //硬删,变更历史3次的
$AcFansExt->updateAllCounters(['deleted'=>1],['pid'=>$pid,'mid'=>$user_id]); //更新已有数据
//开始写入新传入的数据
$datas = [];
$data = [];
$cols = ['realname'=>'realname','nickname'=>'nickname','title'=>'title','password'=>'password','mobiles'=>'mobiles','thumb'=>'thumb','province'=>'province','idcard'=>'idcard'];
foreach($cols as $col=>$key){
$data['pid'] = $pid;
$data['mid'] = $user_id;
$data['key'] = $col;
$data['mobile'] = $mobile;
$data['value'] = isset($post[$key]) ? trim($post[$key]) : '';
$datas[] = $data;
}
//批量插入
$model = clone $AcFansExt;
foreach($datas as $attributes)
{
$model->isNewRecord = true;
$model->setAttributes($attributes,false);
$model->save() && $model->id=0;
}
/*保存扩展资料 E*/
Todo:
车主表的数据关联问题:目前仅修复了车主列表、选择及编辑、保存;
前端用户登陆目前暂用Member表数据——————面向各网点工作人员及司机;
复制前端用户,调整为Fans数据————面向托运客户;
Beta 2.1.10
调整入口,增加普通用户界面
Beta 2.1.9
对板车、司机、员工、网点等列表项增加排序功能;
对已离职员工、已下线板车等显示进行降权;
调整发车清单内的信息细节——
(1)同行委托单强调展示同行信息;
(2)体现具体送地要求;
Beta 2.1.8
升级框架版本,支持php8.3;
Beta 1.1.8
完善订单列表导出功能细节,增加提车费项目;
完善订单筛选查询功能细节,增加交车单筛选;
订单细节增加“验车人”项,方便查找验车记录;
Beta 1.1.7
修复车辆列表搜索分页不能延续搜索条件的BUG;
修复车型列表搜索分页不能延续搜索条件的BUG;
修复通讯录搜索分页不能延续搜索条件的BUG;
修复合作单位搜索分页不能延续搜索条件的BUG;
Beta 1.1.6
增加订单的“交车补单”标记字段,用于交车信息筛选;
Beta 1.1.5
增加出车单费用管理功能;
优化出车单逻辑,可直接在待发运订单列表中为车辆安排出车单;
修复办事处列表检索等问题;
优化订单列表界面,增加排序条件、按创建工号筛选;
Beta 1.1.4
调整订单列表,增加订单复制功能;
调整客车列表,增加客车复制功能;
Beta 1.1.3
调整大车出车任务、小车承运相关状态名词;
优化单图上传组件;
修复已有列表与选择功能界面的URL生成方法,加入平台ID参数;
Beta 1.1.2:
完善板车出车单逻辑,修复已知错误;
修改“装车清单”为“承运订单”;
增加出车单、承运单等关联表单的部分字段,以细化具体记录项;
Beta 1.1.1:
运单名词“签约人”更改为“委托人”;
添加通讯录功能,将运单中用到的联系系统进行汇总;
运单添加weituo字段,对应“委托人ID”,增加wtdw字段,对应“委托单位”;
添加合作单位功能,对委托单位进行汇总管理;
Binary file not shown.
@@ -0,0 +1 @@
a:2:{i:0;s:21:"0.22537300 1721799649";i:1;N;}
File diff suppressed because one or more lines are too long
Binary file not shown.
+100302
View File
File diff suppressed because it is too large Load Diff
+9
View File
@@ -0,0 +1,9 @@
<?php
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'test');
defined('YII_APP_BASE_PATH') or define('YII_APP_BASE_PATH', __DIR__.'/../../');
require_once(YII_APP_BASE_PATH . '/vendor/autoload.php');
require_once(YII_APP_BASE_PATH . '/vendor/yiisoft/yii2/Yii.php');
require_once(YII_APP_BASE_PATH . '/common/config/bootstrap.php');
require_once(__DIR__ . '/../config/bootstrap.php');
View File
+13
View File
@@ -0,0 +1,13 @@
<?php
return [
[
'username' => 'erau',
'auth_key' => 'tUu1qHcde0diwUol3xeI-18MuHkkprQI',
// password_0
'password_hash' => '$2y$13$nJ1WDlBaGcbCdbNC5.5l4.sgy.OMEKCqtDQOdQ2OWpgiKRWYyzzne',
'password_reset_token' => 'RkD_Jw0_8HEedzLk7MM-ZKEFfYR7VbMr_1392559490',
'created_at' => '1392559490',
'updated_at' => '1392559490',
'email' => 'sfriesen@jenkins.info',
],
];
+2
View File
@@ -0,0 +1,2 @@
*
!.gitignore
+1
View File
@@ -0,0 +1 @@
_generated
+25
View File
@@ -0,0 +1,25 @@
<?php
namespace backend\tests;
/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
*
* @SuppressWarnings(PHPMD)
*/
class FunctionalTester extends \Codeception\Actor
{
use _generated\FunctionalTesterActions;
/**
* Define custom actions here
*/
}
+25
View File
@@ -0,0 +1,25 @@
<?php
namespace backend\tests;
/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
*
* @SuppressWarnings(PHPMD)
*/
class UnitTester extends \Codeception\Actor
{
use _generated\UnitTesterActions;
/**
* Define custom actions here
*/
}
+4
View File
@@ -0,0 +1,4 @@
class_name: FunctionalTester
modules:
enabled:
- Yii2
+36
View File
@@ -0,0 +1,36 @@
<?php
namespace backend\tests\functional;
use \backend\tests\FunctionalTester;
use common\fixtures\User as UserFixture;
/**
* Class LoginCest
*/
class LoginCest
{
public function _before(FunctionalTester $I)
{
$I->haveFixtures([
'user' => [
'class' => UserFixture::className(),
'dataFile' => codecept_data_dir() . 'login_data.php'
]
]);
}
/**
* @param FunctionalTester $I
*/
public function loginUser(FunctionalTester $I)
{
$I->amOnPage('/site/login');
$I->fillField('Username', 'erau');
$I->fillField('Password', 'password_0');
$I->click('login-button');
$I->see('Logout (erau)', 'form button[type=submit]');
$I->dontSeeLink('Login');
$I->dontSeeLink('Signup');
}
}
+16
View File
@@ -0,0 +1,16 @@
<?php
/**
* Here you can initialize variables via \Codeception\Util\Fixtures class
* to store data in global array and use it in Cests.
*
* ```php
* // Here _bootstrap.php
* \Codeception\Util\Fixtures::add('user1', ['name' => 'davert']);
* ```
*
* In Cests
*
* ```php
* \Codeception\Util\Fixtures::get('user1');
* ```
*/
+1
View File
@@ -0,0 +1 @@
class_name: UnitTester
+16
View File
@@ -0,0 +1,16 @@
<?php
/**
* Here you can initialize variables via \Codeception\Util\Fixtures class
* to store data in global array and use it in Tests.
*
* ```php
* // Here _bootstrap.php
* \Codeception\Util\Fixtures::add('user1', ['name' => 'davert']);
* ```
*
* In Tests
*
* ```php
* \Codeception\Util\Fixtures::get('user1');
* ```
*/
+420
View File
@@ -0,0 +1,420 @@
<?php
/**
* @Author: fm453
* @Date: 2018-11-23 12:17:02
* @Last Modified by: fm453
* @Last Modified time: 2020-09-12 22:48:52
* @Email: fm453@lukegzs.com
*/
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yii\helpers\Url;
use yii\widgets\LinkPager;
$this->title = '运单列表';
$this->params['breadcrumbs'][] = $this->title;
?>
<!--日期时间选择器-->
<?=Html::jsFile('@web/js/plugins/layer/laydate/laydate.js')?>
<?=Html::cssFile('@web/js/plugins/layer/laydate/need/laydate.css')?>
<?=Html::cssFile('@web/js/plugins/layer/laydate/skins/molv/laydate.css')?>
<style>
.laydate_body .laydate_top{
padding:0;
}
.laydate_body .laydate_ym{
/*margin:0;
padding:5px;*/
}
.laydate_body .laydate_table{
border:0;
border-bottom: 1px solid rgb(204, 204, 204);
}
.laydate_body .laydate_bottom {
border: 0;
margin-bottom: 10px;
}
</style>
<!--滑块选择器-->
<?=Html::cssFile('@web/css/plugins/ionRangeSlider/ion.rangeSlider.css')?>
<?=Html::cssFile('@web/css/plugins/ionRangeSlider/ion.rangeSlider.skinFlat.css')?>
<?=Html::jsFile('@web/js/plugins/ionRangeSlider/ion.rangeSlider.min.js')?>
<!--下拉选择、选项框-->
<?=Html::cssFile('@web/css/plugins/chosen/chosen.css')?>
<?=Html::jsFile('@web/js/plugins/chosen/chosen.jquery.js')?>
<div class="wrapper wrapper-content">
<div class="row">
<div class="col-sm-12">
<div class="ibox float-e-margins">
<div class="ibox-content" style="text-align: center;">
<h1>搜索与筛选</h1>
<form role="form" class="form-horizontal m-t" action="<?=Url::current(['pid' => Yii::$app->session->get('pid')], false);?>" method="post">
<input type="hidden" name="_csrf-backend" value="<?= Yii::$app->getRequest()->getCsrfToken();?>" />
<div class="form-group">
<div class="col-sm-4">
<div class="input-group">
<span class="input-group-btn">
<button type="button" class="btn btn-sm btn-primary">签约月份</button>
</span>
<input class="input-sm form-control layer-date" type="text" name="search[sign_m]" placeholder="请选择月份" autocomplete="off" onclick="laydate({istime: false, format: 'YYYY-MM'})" value="<?=isset($search['sign_m'])?$search['sign_m']:''?>">
</div>
</div>
<div class="col-sm-4">
<div class="input-group">
<span class="input-group-btn">
<button type="button" class="btn btn-sm btn-primary">签约时间不早于</button>
</span>
<input class="input-sm form-control layer-date" type="text" name="search[sign_after]" placeholder="请选择日期" autocomplete="off" onclick="laydate({istime: false, format: 'YYYY-MM-DD'})" value="<?=isset($search['sign_after'])?$search['sign_after']:''?>">
</div>
</div>
<div class="col-sm-4">
<div class="input-group">
<span class="input-group-btn">
<button type="button" class="btn btn-sm btn-primary">签约时间不晚于</button>
</span>
<input class="input-sm form-control layer-date" type="text" name="search[sign_before]" placeholder="请选择日期" autocomplete="off" onclick="laydate({istime: false, format: 'YYYY-MM-DD'})" value="<?=isset($search['sign_before'])?$search['sign_before']:''?>">
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-3">
<select data-placeholder="选择订单状态..." class="select-sm form-control chosen-select" tabindex="2" name="search[status_code]">
<option value="all">选择订单状态</option>
<?php foreach($status as $key=>$val){?>
<option value="<?=$key?>" hassubinfo="true" <?=isset($search['status_code']) && $search['status_code']==$key ? 'selected':'';?>><?=$val?></option>
<?php }?>
</select>
</div>
<div class="col-sm-3">
<div class="input-group">
<input type="text" class="form-control" name="store_title" id="store-title" value="<?=isset($search['store_title'])?$search['store_title']:'';?>" placeholder="点击选择接单网点" autocomplete="off" href="<?=Url::toRoute(['store/select','callback'=>'store']);?>" w="80%;" h="90%;" title="选择接单网点" mini="load">
<input type="hidden" class="form-control" name="search[store_id]" id="store-value" value="<?=isset($search['store_id'])?$search['store_id']:0;?>">
<span class="input-group-btn">
<button type="button" class="btn btn-info" onclick="clearStore('store')">清除选择</button>
</span>
</div>
<script>
function selectStore(title,id,callback)
{
layer.closeAll();
layer.msg('已选择');
$('#'+callback+'-value').val(id);
$('#'+callback+'-title').val(title);
}
function clearStore(id)
{
$('#'+id+'-value').val('');
$('#'+id+'-title').val('');
}
</script>
</div>
<div class="col-sm-3">
<div class="input-group">
<input type="text" class="form-control" name="employee_title" id="employee-title" value="<?=isset($search['employee_title'])?$search['employee_title']:'';?>" placeholder="点击选择该运单的派单员工" autocomplete="off" href="<?=Url::toRoute(['employee/select','callback'=>'employee']);?>" w="80%;" h="90%;" title="选择派单员工" mini="load">
<input type="hidden" class="form-control" name="search[employee]" id="employee-value" value="<?=isset($search['employee'])?$search['employee']:0;?>">
<span class="input-group-btn">
<button type="button" class="btn btn-info" onclick="clearEmployee('employee')">清除选择</button>
</span>
</div>
<script>
function selectEmployee(title,id,callback)
{
layer.closeAll();
layer.msg('已选择');
$('#'+callback+'-value').val(id);
$('#'+callback+'-title').val(title);
}
function clearEmployee(id)
{
$('#'+id+'-value').val('');
$('#'+id+'-title').val('');
}
</script>
</div>
<div class="col-sm-3">
<div class="input-group">
<input type="text" class="form-control" name="car_title" id="car-title" value="<?=isset($search['car_title'])?$search['car_title']:'';?>" placeholder="点击选择关联客户车辆" autocomplete="off" href="<?=Url::toRoute(['car/select','callback'=>'car']);?>" w="80%;" h="90%;" title="选择关联客户车辆" mini="load">
<input type="hidden" class="form-control" name="search[car_id]" id="car-value" value="<?=isset($search['car_id'])?$search['car_id']:0;?>">
<span class="input-group-btn">
<button type="button" class="btn btn-info" onclick="clearCar('car')">清除选择</button>
</span>
</div>
</div>
<script>
function selectCar(title,id,callback)
{
layer.closeAll();
layer.msg('已选择');
$('#'+callback+'-value').val(id);
$('#'+callback+'-title').val(title);
}
function clearCar(id)
{
$('#'+id+'-value').val('');
$('#'+id+'-title').val('');
}
</script>
</div>
<div class="form-group">
<div class="col-sm-3">
<div class="input-group">
<input class="form-control" type="text" placeholder="模糊检索介绍人名字" name="search[bind]" id="bind" value="<?=isset($search['bind'])?$search['bind']:'';?>">
<span class="input-group-btn">
<button type="button" class="btn btn-info" onclick="clearBind('bind')">清除</button>
</span>
</div>
</div>
<script>
function clearBind(id)
{
$('#'+id).val('');
}
</script>
<div class="col-sm-3">
<div class="input-group">
<input class="form-control" type="text" placeholder="模糊检索签约人名字" name="search[signer]" id="signer" value="<?=isset($search['signer'])?$search['signer']:'';?>">
<span class="input-group-btn">
<button type="button" class="btn btn-info" onclick="clearSigner('signer')">清除</button>
</span>
</div>
</div>
<script>
function clearSigner(id)
{
$('#'+id).val('');
}
</script>
<div class="col-sm-3">
<div class="input-group">
<input class="form-control" type="text" placeholder="模糊检索发车人名字" name="search[sender_name]" id="sender_name" value="<?=isset($search['sender_name'])?$search['sender_name']:'';?>">
<span class="input-group-btn">
<button type="button" class="btn btn-info" onclick="clearSender('sender_name')">清除</button>
</span>
</div>
</div>
<script>
function clearSender(id)
{
$('#'+id).val('');
}
</script>
<div class="col-sm-3">
<div class="input-group">
<input class="form-control" type="text" placeholder="模糊检索接车人名字" name="search[receiver_name]" id="receiver_name" value="<?=isset($search['receiver_name'])?$search['receiver_name']:'';?>">
<span class="input-group-btn">
<button type="button" class="btn btn-info" onclick="clearReceiver('receiver_name')">清除</button>
</span>
</div>
</div>
<script>
function clearReceiver(id)
{
$('#'+id).val('');
}
</script>
</div>
<div class="form-group">
<div class="col-sm-3">
<select data-placeholder="选择起运省份..." class="form-control chosen-select" tabindex="2" name="search[start_province]">
<option value="">选择起运省份</option>
<?php foreach(Yii::$app->params['regionAreas'] as $key=>$val){?>
<option value="<?=$key?>" hassubinfo="true" <?=isset($search['start_province']) && $search['start_province']==$key ? 'selected':'';?>><?=$val?></option>
<?php }?>
</select>
</div>
<div class="col-sm-3">
<div class="input-group">
<input class="form-control" type="text" placeholder="检索起运城市名称" name="start_city" id="start_city" value="<?=isset($search['start_city'])?$search['start_city']:'';?>">
<span class="input-group-btn">
<button type="button" class="btn btn-info" onclick="clearInput(this)">清除</button>
</span>
</div>
</div>
<div class="col-sm-3">
<select data-placeholder="选择运达省份..." class="select-sm form-control chosen-select" tabindex="2" name="search[aim_province]">
<option value="">选择运达省份</option>
<?php foreach(Yii::$app->params['regionAreas'] as $key=>$val){?>
<option value="<?=$key?>" hassubinfo="true" <?=isset($search['aim_province']) && $search['aim_province']==$val ? 'selected':'';?>><?=$val?></option>
<?php }?>
</select>
</div>
<div class="col-sm-3">
<div class="input-group">
<input class="form-control" type="text" placeholder="检索目标运达城市名称" name="aim_city" id="aim_city" value="<?=isset($search['aim_city'])?$search['aim_city']:'';?>">
<span class="input-group-btn">
<button type="button" class="btn btn-info" onclick="clearInput(this)">清除</button>
</span>
</div>
</div>
</div>
<script>
function clearInput(obj)
{
$(obj).parent().prev().val('');
}
</script>
<div class="form-group">
<div class="col-sm-12">
<button type="submit" class="btn btn-sm btn-warning"> 搜索</button>
<a class="btn btn-info btn-sm" href="<?= Url::toRoute('order/new')?>">新增运单</a>
</div>
</div>
</form>
</div>
<!--分页-->
<div class="ibox-content" style="padding:0;text-align: center;">
<div class="f-r">
<?= LinkPager::widget([
'pagination'=>$pager,
'firstPageLabel' => '首页',
'nextPageLabel' => '下一页',
'prevPageLabel' => '上一页',
'lastPageLabel' => '末页',
]) ?>
</div>
</div>
<div class="ibox-title"><?= Html::encode($this->title) ?></div>
<div class="ibox-content">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>序号</th>
<th>车辆</th>
<!-- <th>发车人</th>
<th>接车人</th> -->
<th>托运信息</th>
<th>网点员工</th>
<th>关联信息</th>
<th>状态</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<?php foreach($orders as $vo):?>
<tr>
<td><?=$vo['id']?></td>
<td>
<kbd>车牌</kbd> <?=isset($cars[$vo['car_id']]['num_p']) ? $cars[$vo['car_id']]['num_p']:''?><?=isset($cars[$vo['car_id']]['num_area']) ? $cars[$vo['car_id']]['num_area']:''?><?=isset($cars[$vo['car_id']]['num_left']) ? $cars[$vo['car_id']]['num_left']:''?><br>
<kbd>车架号</kbd><?=isset($cars[$vo['car_id']]['num_frame']) ? $cars[$vo['car_id']]['num_frame']:''?><br>
<kbd>品牌车型</kbd><?=isset($cars[$vo['car_id']]['title']) ? $cars[$vo['car_id']]['title']:''?>
</td>
<!-- <td>
【姓名】<?=isset($vo['sender_name']) ? $vo['sender_name']:''?><br>
【手机】<?=isset($vo['sender_mobiles']) ? $vo['sender_mobiles']:''?><br>
【身份证号】<?=isset($vo['sender_idcard']) ? $vo['sender_idcard']:''?><br>
</td>
<td>
【姓名】<?=isset($vo['receiver_name']) ? $vo['receiver_name']:''?><br>
【手机】<?=isset($vo['receiver_mobiles']) ? $vo['receiver_mobiles']:''?><br>
【身份证号】<?=isset($vo['receiver_idcard']) ? $vo['receiver_idcard']:''?><br>
</td> -->
<td>
【签约时间】<?=isset($vo['sign_date']) && $vo['sign_date']>0 ? date('Y-m-d',$vo['sign_date']) : '未记录'?><br>
【始发地】<?=isset(Yii::$app->params['regionAreas'][$vo['start_province']]) ? Yii::$app->params['regionAreas'][$vo['start_province']] : ''?> <?=isset($vo['start_city']) ? $vo['start_city'] : ''?><br>
【目的地】<?=isset(Yii::$app->params['regionAreas'][$vo['aim_province']]) ? Yii::$app->params['regionAreas'][$vo['aim_province']] : ''?> <?=isset($vo['aim_city']) ? $vo['aim_city'] : ''?><br>
</td>
<td>
【网点门店】<code><?=isset($stores[$vo['store_id']]['title'])?$stores[$vo['store_id']]['title']:'未设置'?></code><br>
【经办人】<code><?=isset($employees[$vo['employee_id']]['name'])?$employees[$vo['employee_id']]['name']:'未关联'?></code>
</td>
<td>
<!-- 【签约人】<?=isset($vo['signer']) ? $vo['signer'] : ''?> <br> -->
【保险】保价<code><?=isset($vo['car_value']) ? $vo['car_value'] : 0?></code><kbd>万元</kbd>; 保费<code><?=isset($vo['fee_insurance']) ? $vo['fee_insurance'] : 0?></code><kbd>元</kbd>; <br>
【费用】运费<code><?=isset($vo['fee_truck']) ? $vo['fee_truck'] : 0?></code><kbd>元</kbd>
总费用<code><?=isset($vo['fee_total']) ? $vo['fee_total'] : 0?></code><kbd>元</kbd> <br>
现付<code><?=isset($vo['pay_send']) ? $vo['pay_send'] : 0?></code><kbd>元</kbd>;到收<code><?=isset($vo['pay_receive']) ? $vo['pay_receive'] : 0?></code><kbd>元</kbd> <br>
</td>
<td>
<?php if($vo['status_code']<=0){?>
<label class="btn btn-default btn-xs"><?=$status[$vo['status_code']]?></label>
<?php }else{?>
<label class="btn btn-info btn-xs"><?=$status[$vo['status_code']]?></label>
<?php }?>
<?php if($vo['is_cwqr']==0){?>
<label class="btn btn-default btn-xs">待财务确认</label>
<?php }else{?>
<label class="btn btn-info btn-xs">财务已确认</label>
<?php }?>
</td>
<td>
<p>
<a class="btn btn-primary btn-xs" href="<?=Url::toRoute(['order/edit','id'=>$vo['id']])?>"><i class="fa fa-edit"></i>编辑</a>
<a title="点击将删除" href="<?=Url::toRoute(['order/delete','id'=>$vo['id']])?>" class="btn btn-xs btn-danger" mini="act"><i class="fa fa-trash bigger-120"></i>删除</a>
<a title="点击将取消这张订单" href="<?=Url::toRoute(['order/ajax','id'=>$vo['id'],'do'=>'cancel'])?>" class="btn btn-xs btn-warning" mini="ajax"><i class="fa fa-trash-o bigger-120"></i>取消</a>
</p>
<p>
<a class="btn btn-success btn-xs" href="<?=Url::toRoute(['order/caiwu','id'=>$vo['id']])?>" w="100%;" h="90%;" title="财务审核" mini="load">财务审核</a>
<a class="btn btn-info btn-xs" href="<?=Url::toRoute(['order/commission','id'=>$vo['id']])?>" w="50%;" h="80%;" title="佣金管理" mini="load">佣金管理</a>
<a class="btn btn-warning btn-xs" href="<?=Url::toRoute(['feeorder/index','oid'=>$vo['id']])?>" w="100%;" h="90%;" title="费用管理" mini="load">费用管理</a>
</p>
<p>
<a class="btn btn-primary btn-xs" href="<?=Url::toRoute(['order/edit','id'=>$vo['id'],'op'=>'print'])?>" w="90%;" h="90%;" title="打印订单" mini="load"><i class="fa fa-print"></i> 打印订单</a>
</p>
</td>
</tr>
<?php endforeach;?>
</tbody>
</table>
</div>
</div>
<!--分页-->
<div class="ibox-content" style="padding:0;text-align: center;">
<div class="f-r">
<?= LinkPager::widget([
'pagination'=>$pager,
'firstPageLabel' => '首页',
'nextPageLabel' => '下一页',
'prevPageLabel' => '上一页',
'lastPageLabel' => '末页',
]) ?>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
laydate.skin('molv');
$(document).ready(function() {
var config = {
".chosen-select": {},
".chosen-select-deselect": {
allow_single_deselect: !0
},
".chosen-select-no-single": {
disable_search_threshold: 10
},
".chosen-select-no-results": {
no_results_text: "Oops, nothing found!"
},
".chosen-select-width": {
width: "95%"
}
};
for (var selector in config) $(selector).chosen(config[selector]);
});
</script>
+144
View File
@@ -0,0 +1,144 @@
<?php
use yii\helpers\Html;
use yii\helpers\Url;
?>
<!--下拉选择、选项框-->
<?=Html::cssFile('@web/css/plugins/chosen/chosen.css')?>
<?=Html::jsFile('@web/js/plugins/chosen/chosen.jquery.js')?>
<div class="wrapper wrapper-content">
<div class="row">
<div class="col-sm-12">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>基础资料</h5>
<div class="ibox-tools">
<a class="collapse-link">
<i class="fa fa-chevron-up"></i>
</a>
<a class="close-link">
<i class="fa fa-times"></i>
</a>
</div>
</div>
<div class="ibox-content">
<div class="alert alert-info">
选择相应的订单并为之创建相应的验车相册
</div>
<form role="form" class="form-horizontal m-t" method="post" action="<?=Url::toRoute('albums/save')?>" >
<input type="hidden" name="_csrf-backend" value="<?=Yii::$app->getRequest()->getCsrfToken();?>" />
<input type="hidden" name="id" value="<?=isset($detail['id'])?$detail['id']:0;?>">
<div class="form-group draggable">
<label class="col-sm-1 control-label"> <span class="red">*</span> 托运车辆:</label>
<div class="col-sm-4">
<div class="input-group">
<span class="input-group-btn">
<button type="button" class="btn btn-info" href="<?=Url::toRoute(['car/select','callback'=>'car']);?>" w="80%;" h="90%;" title="选择车辆" mini="load">选择车辆</button>
</span>
<input type="text" class="form-control" name="car_title" id="car-title" value="<?=isset($detail['car_title'])?$detail['car_title']:'';?>" placeholder="点击选择需要托运的车辆(如无,可新创建)" autocomplete="off" href="<?=Url::toRoute(['car/select','callback'=>'car']);?>" w="80%;" h="90%;" title="选择车辆" mini="load">
<input type="hidden" class="form-control" name="car_id" id="car-id" value="<?=isset($detail['car_id'])?$detail['car_id']:0;?>">
</div>
</div>
<script>
function selectCar(title,car_id,numbers,carowner,callback)
{
/*车品牌+车型组成的车名;车ID;车牌或车架号;车主信息;回调标识*/
layer.closeAll();
layer.msg('已选择');
$('#'+callback+'-id').val(car_id);
$('#'+callback+'-title').val(title);
$('#'+callback+'-number').val(numbers);
$('#'+callback+'-owner').val(carowner);
}
</script>
<div class="col-sm-4">
<div class="input-group">
<span class="input-group-btn">
<button type="button" class="btn btn-primary">车牌或车架号</button>
</span>
<input class="form-control" type="text" name="car_number" id="car-number" placeholder="自动关联;无须手动填写" autocomplete="off" disabled="true" value="<?=isset($detail['car_number'])?$detail['car_number']:'';?>">
</div>
</div>
<div class="col-sm-3">
<div class="input-group">
<span class="input-group-btn">
<button type="button" class="btn btn-primary">对应车主</button>
</span>
<input class="form-control" type="text" name="car_owner" id="car-owner" placeholder="自动关联;无须手动填写" autocomplete="off" disabled="true" value="<?=isset($detail['car_owner'])?$detail['car_owner']:'';?>">
</div>
</div>
</div>
<div class="form-group draggable">
<label class="col-sm-2 control-label"><span class="red">*</span>发车人手机号:</label>
<div class="col-sm-2">
<input class="form-control" type="text" name="phone1_1" placeholder="请输入客户的手机号" autocomplete="off" value="<?=isset($detail['phone1_1'])?$detail['phone1_1']:'';?>">
</div>
<label class="col-sm-2 control-label">发车人备用手机号:</label>
<div class="col-sm-2">
<input class="form-control" type="text" name="phone1_2" placeholder="请输入客户的手机号" autocomplete="off" value="<?=isset($detail['phone1_2'])?$detail['phone1_2']:'';?>">
</div>
</div>
<div class="form-group draggable">
<label class="col-sm-2 control-label">接车人手机号:</label>
<div class="col-sm-2">
<input class="form-control" type="text" name="phone2_1" placeholder="请输入客户的手机号" autocomplete="off" value="<?=isset($detail['phone2_1'])?$detail['phone2_1']:'';?>">
</div>
<label class="col-sm-2 control-label">接车人备用手机号:</label>
<div class="col-sm-2">
<input class="form-control" type="text" name="phone2_1" placeholder="请输入客户的手机号" autocomplete="off" value="<?=isset($detail['phone2_1'])?$detail['phone2_1']:'';?>">
</div>
</div>
<div class="form-group draggable">
<label class="col-sm-1 control-label">备注:</label>
<div class="col-sm-9">
<input class="form-control" type="text" name="remark" placeholder="" autocomplete="off" value="<?=isset($detail['remark'])?$detail['remark']:'';?>">
</div>
</div>
<div class="form-group draggable">
<label class="col-sm-1 control-label">是否显示:
</label>
<div class="col-sm-9">
<div class="radio radio-primary radio-inline">
<input type="radio" <?=(isset($detail['status_code'])&&$detail['status_code']==1)?'checked':'';?> value="1" id="status_code" name="status_code">
<label for="status_code">是</label>
</div>
<div class="radio radio-primary radio-inline">
<input type="radio" <?=((!isset($detail['status_code']))||isset($detail['status_code'])&&$detail['status_code']==0)?'checked':'';?> value="0" id="status_code" name="status_code">
<label for="status_code">否</label>
</div>
</div>
</div>
<div class="hr-line-dashed"></div>
<div class="form-group draggable">
<div class="col-sm-12 col-sm-offset-3">
<button class="btn btn-primary" type="submit">保存内容</button>
<button class="btn btn-white" type="submit">取消</button>
<a class="btn btn-info" href="<?=Url::toRoute('albums/list')?>">相册列表</a>
</div>
</div>
</form>
<div class="clearfix"></div>
</div>
</div>
</div>
</div>
</div>
<style>
.chosen-container-single .chosen-single{
line-height:30px;
}
</style>
+38
View File
@@ -0,0 +1,38 @@
<?php
use yii\helpers\Html;
use yii\helpers\Url;
?>
<div class="wrapper wrapper-content">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>车辆资料</h5>
</div>
<div class="ibox-content">
<div class="row">
<div class="col-sm-12">
<table class="table">
<tbody>
<tr>
<td>车牌:</td>
<td>车架号</td>
<td>车主</td>
<td>品牌车型</td>
<td>车型名称</td>
<!-- <td>状态</td> -->
</tr>
<tr>
<td><?=$detail['num_p']?><?=$detail['num_area']?><?=$detail['num_left']?></td>
<td><?=$detail['num_frame']?></td>
<td><?=isset($detail['owner_title'])?$detail['owner_title']:'';?></td>
<td><?=isset($detail['series_title'])?$detail['series_title']:'';?></td>
<td><?=isset($detail['title'])?$detail['title']: ''?></td>
<!-- <td><?=$status[$detail['status_code']];?></td> -->
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
+120
View File
@@ -0,0 +1,120 @@
<?php
/**
* @Author: fm453
* @Date: 2018-11-23 12:17:02
* @Last Modified by: fm453
* @Last Modified time: 2020-12-13 09:29:31
* @Email: fm453@lukegzs.com
*/
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yii\helpers\Url;
use yii\widgets\LinkPager;
$this->title = '车辆列表';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="wrapper wrapper-content">
<div class="row">
<div class="col-sm-12">
<div class="ibox float-e-margins">
<div class="ibox-content">
<h1><?= Html::encode($this->title) ?></h1>
<div class="row">
<form action="<?=Url::current(['pid' => Yii::$app->session->get('pid')], false);?>" method="post">
<input type="hidden" name="_csrf-backend" value="<?= Yii::$app->getRequest()->getCsrfToken();?>" />
<div class="col-sm-3">
<a class="btn btn-info btn-sm" href="<?= Url::toRoute('car/new')?>">新增车辆</a>
</div>
<div class="col-sm-3 pull-right">
<div class="input-group">
<input class="input-sm form-control" type="text" placeholder="请输入车牌尾数或车架号" name="search[title]" value="<?=$search['title']?>">
<span class="input-group-btn">
<button type="submit" class="btn btn-sm btn-primary"> 搜索</button>
</span>
</div>
</div>
<div class="col-sm-3 pull-right">
<div class="input-group">
<input class="input-sm form-control" type="text" placeholder="点击按品牌筛选" name="search[brand]" id="brand-title" value="<?=$search['brand']?>" autocomplete="off" href="<?=Url::toRoute(['carbrand/select','callback'=>'brand']);?>" w="80%;" h="90%;" title="选择品牌车型" mini="load">
<span class="input-group-btn">
<button type="submit" class="btn btn-sm btn-primary"> 筛选</button>
</span>
</div>
<input type="hidden" name="search[brand_id]" id="brand-value" value="<?=$search['brand_id']?>" />
<script>
function selectCarBrand(title,id,callback)
{
layer.closeAll();
layer.msg('已选择');
$('#'+callback+'-value').val(id);
$('#'+callback+'-title').val(title);
}
</script>
</div>
</form>
</div>
<hr>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>序号</th>
<th style="width:100px;">车主</th>
<th style="width:120px;">品牌车型</th>
<th style="width:120px;">车架号</th>
<th>车牌</th>
<th>状态</th>
<th style="width:150px;">操作</th>
</tr>
</thead>
<tbody>
<?php foreach($cars as $vo):?>
<tr>
<td><?=$vo['id']?></td>
<td>【<code><?=isset($users[$vo['mid']]['username'])?$users[$vo['mid']]['username']:'未设置'?></code>】</td>
<td><?=$vo['title']?><br><?=$vo['title2']?></td>
<td><?=$vo['num_frame']?></td>
<td><?=$vo['num_p'].$vo['num_area']?>・<?=$vo['num_left']?></td>
<td>
<?php if($vo['status_code']==1){?>
<label class="btn btn-info btn-xs"><?=isset($status[$vo['status_code']]) ? $status[$vo['status_code']] : '未知'?></label>
<?php }else{?>
<label class="btn btn-default btn-xs"><?=isset($status[$vo['status_code']]) ? $status[$vo['status_code']] : '未知'?></label>
<?php }?>
</td>
<td>
<a class="btn btn-primary btn-sm" href="<?=Url::toRoute(['car/ajax','id'=>$vo['id'],'do'=>'show'])?>" mini="ajax" data-toggle="tooltip" data-placement="top" data-title="设置该车辆为显示状态" trigger="hover|focus">显</a>
<a class="btn btn-default btn-sm" href="<?=Url::toRoute(['car/ajax','id'=>$vo['id'],'do'=>'hide'])?>" mini="ajax" data-toggle="tooltip" data-placement="top" data-title="设置该车辆为隐藏状态" trigger="hover|focus">隐</a>
<a title="点击将删除" href="<?=Url::toRoute(['car/delete','id'=>$vo['id']])?>" class="btn btn-danger btn-sm" mini="act" data-toggle="tooltip" data-placement="top" data-title="删除该车辆信息" trigger="hover|focus"><i class="fa fa-trash bigger-120"></i></a>
<a class="btn btn-primary btn-sm" href="<?=Url::toRoute(['car/edit','id'=>$vo['id']])?>" data-toggle="tooltip" data-placement="top" data-title="编辑该车辆信息" trigger="hover|focus"><i class="fa fa-edit bigger-120"></i></a>
<a class="btn btn-success btn-sm" href="<?=Url::toRoute(['car/copy','id'=>$vo['id']])?>" w="100%;" h="90%;" title="复制车辆信息" mini="load" data-toggle="tooltip" data-placement="top" data-title="复制车辆信息后新增" trigger="hover|focus"><i class="fa fa-copy bigger-120"></i></a>
</td>
</tr>
<?php endforeach;?>
</tbody>
</table>
<!--分页-->
<div class="f-r">
<?= LinkPager::widget([
'pagination'=>$pager,
'firstPageLabel' => '首页',
'nextPageLabel' => '下一页',
'prevPageLabel' => '上一页',
'lastPageLabel' => '末页',
]) ?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
+140
View File
@@ -0,0 +1,140 @@
<?php
use yii\helpers\Html;
use yii\helpers\Url;
?>
<!--下拉选择、选项框-->
<?=Html::cssFile('@web/css/plugins/chosen/chosen.css')?>
<?=Html::jsFile('@web/js/plugins/chosen/chosen.jquery.js')?>
<div class="wrapper wrapper-content">
<div class="row">
<div class="col-sm-12">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>车辆资料</h5>
<div class="ibox-tools">
<a class="collapse-link">
<i class="fa fa-chevron-up"></i>
</a>
<a class="close-link">
<i class="fa fa-times"></i>
</a>
</div>
</div>
<div class="ibox-content">
<div class="alert alert-info">
此处录入公司客户车辆的基础资料
</div>
<form role="form" class="form-horizontal m-t" method="post" action="<?=Url::toRoute('car/save')?>" >
<input type="hidden" name="_csrf-backend" value="<?=Yii::$app->getRequest()->getCsrfToken();?>" />
<input type="hidden" name="id" value="<?=isset($detail['id'])?$detail['id']:0;?>">
<div class="form-group draggable">
<label class="col-sm-1 control-label">车牌:</label>
<div class="col-sm-9">
<div class="input-group">
<span class="input-group-btn">
<button type="button" class="btn btn-primary">省份标识</button>
</span>
<select data-placeholder="" class="form-control chosen-select" tabindex="3" name="num_p">
<option value=""></option>
<?php foreach(Yii::$app->params['carRegion'] as $key=>$val){?>
<option value="<?=$val?>" hassubinfo="true" <?=isset($detail['num_p']) && $detail['num_p']==$val ? 'selected':'';?>><?=$val?></option>
<?php }?>
</select>
<span class="input-group-btn">
<button type="button" class="btn btn-primary">区域代码</button>
</span>
<select data-placeholder="" class="form-control chosen-select" tabindex="4" name="num_area">
<option value=""></option>
<?php foreach(Yii::$app->params['letters'] as $val){?>
<option value="<?=$val?>" hassubinfo="true" <?=isset($detail['num_area']) && $detail['num_area']==$val ? 'selected':'';?>><?=$val?></option>
<?php }?>
</select>
<span class="input-group-btn">
<button type="button" class="btn btn-primary">尾号</button>
</span>
<input class="form-control" type="text" name="num_left" placeholder="车牌尾数" autocomplete="off" value="<?=isset($detail['num_left'])?$detail['num_left']: ''?>">
</div>
</div>
</div>
<div class="form-group draggable">
<label class="col-sm-1 control-label">车架号:</label>
<div class="col-sm-4">
<input class="form-control" type="text" name="num_frame" placeholder="车架号" autocomplete="off" value="<?=isset($detail['num_frame'])?$detail['num_frame']: ''?>">
</div>
<label class="col-sm-1 control-label">车主:</label>
<div class="col-sm-4">
<input type="text" class="form-control" name="owner_title" id="owner-title" value="<?=isset($detail['owner_title'])?$detail['owner_title']:'';?>" placeholder="点击选择关联车主" autocomplete="off" href="<?=Url::toRoute(['carowner/select','callback'=>'owner']);?>" w="80%;" h="90%;" title="选择关联车主" mini="load">
<input type="hidden" class="form-control" name="owner_id" id="owner-value" value="<?=isset($detail['owner_id'])?$detail['owner_id']:0;?>">
</div>
<script>
function selectCarOwner(title,id,callback)
{
layer.closeAll();
layer.msg('已选择');
$('#'+callback+'-value').val(id);
$('#'+callback+'-title').val(title);
}
</script>
</div>
<div class="form-group draggable">
<label class="col-sm-1 control-label">品牌车型:</label>
<div class="col-sm-4">
<input type="text" class="form-control" name="series_title" id="car-series-title" value="<?=isset($detail['brand_title'])?$detail['brand_title']:'';?><?=isset($detail['series_title'])?$detail['series_title']:'';?>" placeholder="点击选择品牌车型" autocomplete="off" href="<?=Url::toRoute(['carseries/select','callback'=>'car']);?>" w="80%;" h="90%;" title="选择品牌车型" mini="load">
<input type="hidden" class="form-control" name="series_id" id="car-series-value" value="<?=isset($detail['series_id'])?$detail['series_id']:0;?>">
<input type="hidden" class="form-control" name="brand_id" id="car-brand-value" value="<?=isset($detail['brand_id'])?$detail['brand_id']:0;?>">
</div>
<script>
function selectCarSeries(title,series_id,brand_id,callback)
{
layer.closeAll();
layer.msg('已选择');
$('#'+callback+'-series-value').val(series_id);
$('#'+callback+'-brand-value').val(brand_id);
$('#'+callback+'-series-title').val(title);
$('#series-title').val(title);
}
</script>
<label class="col-sm-1 control-label">车型名称:</label>
<div class="col-sm-4">
<input class="form-control" type="title" name="title" id="series-title" placeholder="直接输入对应的车型名称即可" autocomplete="off" value="<?=isset($detail['title'])?$detail['title']: ''?>">
</div>
</div>
<div class="form-group draggable">
<label class="col-sm-1 control-label">车辆状态:</label>
<div class="col-sm-9">
<?php foreach($status as $vo=>$ko):?>
<div class="radio radio-primary radio-inline">
<input type="radio" <?=((isset($detail['status_code'])&&$detail['status_code']==$vo)||(!isset($detail['status_code'])&&$vo==1))?'checked':'';?> value="<?=$vo?>" id="status_code" name="status_code">
<label for="status_code"><?=$ko?></label>
</div>
<?php endforeach;?>
</div>
</div>
<div class="hr-line-dashed"></div>
<div class="form-group draggable">
<div class="col-sm-12 col-sm-offset-3">
<button class="btn btn-primary" type="submit">保存内容</button>
<button class="btn btn-white" type="submit">取消</button>
<a class="btn btn-info" href="<?=Url::toRoute('list')?>">全部车辆</a>
</div>
</div>
</form>
<div class="clearfix"></div>
</div>
</div>
</div>
</div>
</div>
+114
View File
@@ -0,0 +1,114 @@
<?php
/**
* @Author: fm453
* @Date: 2018-11-23 12:17:02
* @Last Modified by: fm453
* @Last Modified time: 2020-12-13 09:44:32
* @Email: fm453@lukegzs.com
*/
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yii\helpers\Url;
use yii\widgets\LinkPager;
$this->title = '车辆列表';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="wrapper wrapper-content">
<div class="row">
<div class="col-sm-12">
<div class="ibox float-e-margins">
<div class="ibox-content">
<h1><?= Html::encode($this->title) ?></h1>
<div class="row">
<form action="<?=Url::current(['pid' => Yii::$app->session->get('pid')], false);?>" method="post">
<input type="hidden" name="_csrf-backend" value="<?= Yii::$app->getRequest()->getCsrfToken();?>" />
<div class="col-sm-3">
<a class="btn btn-info btn-sm" href="<?= Url::toRoute('car/new')?>">新增车辆</a>
</div>
<div class="col-sm-3 pull-right">
<div class="input-group">
<input class="input-sm form-control" type="text" placeholder="请输入车牌尾数或车架号" name="search[title]" value="<?=$search['title']?>">
<span class="input-group-btn">
<button type="submit" class="btn btn-sm btn-primary"> 搜索</button>
</span>
</div>
</div>
<div class="col-sm-3 pull-right">
<div class="input-group">
<input class="input-sm form-control" type="text" placeholder="点击按品牌筛选" name="search[brand]" id="brand-title" value="<?=$search['brand']?>" autocomplete="off" href="<?=Url::toRoute(['carbrand/select','callback'=>'brand']);?>" w="80%;" h="90%;" title="选择品牌车型" mini="load">
<span class="input-group-btn">
<button type="submit" class="btn btn-sm btn-primary"> 筛选</button>
</span>
</div>
<input type="hidden" name="search[brand_id]" id="brand-value" value="<?=$search['brand_id']?>" />
<script>
function selectCarBrand(title,id,callback)
{
layer.closeAll();
layer.msg('已选择');
$('#'+callback+'-value').val(id);
$('#'+callback+'-title').val(title);
}
</script>
</div>
</form>
</div>
<hr>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>序号</th>
<th>车主</th>
<th>品牌车型</th>
<th>车架号</th>
<th>车牌</th>
<th>状态</th>
<th><a class="btn btn-primary btn-xs" onclick="parent.selectCar('','','<?=$callback?>');">清除选择</a></th>
</tr>
</thead>
<tbody>
<?php foreach($cars as $vo):?>
<tr>
<td><?=$vo['id']?></td>
<td>【<code><?=isset($users[$vo['mid']]['username'])?$users[$vo['mid']]['username']:'未设置'?></code>】</td>
<td><?=$vo['title']?><br><?=$vo['title2']?></td>
<td><?=$vo['num_frame']?></td>
<td><?=$vo['num_p'].$vo['num_area']?>・<?=$vo['num_left']?></td>
<td>
<?php if($vo['status_code']==1){?>
<label class="btn btn-info btn-xs"><?=isset($status[$vo['status_code']]) ? $status[$vo['status_code']] : '未知'?></label>
<?php }else{?>
<label class="btn btn-default btn-xs"><?=isset($status[$vo['status_code']]) ? $status[$vo['status_code']] : '未知'?></label>
<?php }?>
</td>
<td>
<a class="btn btn-primary btn-xs" onclick="parent.selectCar('<?=$vo['title']?>','<?=$vo['id']?>','<?=$vo['numbers']?>','<?=isset($users[$vo['mid']]['username'])?$users[$vo['mid']]['username']:''?>','<?=$callback?>');">选择</a>
</td>
</tr>
<?php endforeach;?>
</tbody>
</table>
<!--分页-->
<div class="f-r">
<?= LinkPager::widget([
'pagination'=>$pager,
'firstPageLabel' => '首页',
'nextPageLabel' => '下一页',
'prevPageLabel' => '上一页',
'lastPageLabel' => '末页',
]) ?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
+93
View File
@@ -0,0 +1,93 @@
<?php
/**
* @Author: fm453
* @Date: 2018-11-23 12:17:02
* @Last Modified by: fm453
* @Last Modified time: 2020-09-12 21:21:50
* @Email: fm453@lukegzs.com
*/
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yii\helpers\Url;
use yii\widgets\LinkPager;
$this->title = '轿车品牌列表';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="wrapper wrapper-content">
<div class="row">
<div class="col-sm-12">
<div class="ibox float-e-margins">
<div class="ibox-content">
<h1><?= Html::encode($this->title) ?></h1>
<div class="row">
<div class="col-sm-3">
<a class="btn btn-info btn-sm" href="<?= Url::toRoute('carbrand/new')?>">新增品牌</a>
</div>
<div class="col-sm-3 pull-right">
<form action="<?=Url::current(['pid' => Yii::$app->session->get('pid')], false);?>" method="post">
<input type="hidden" name="_csrf-backend" value="<?= Yii::$app->getRequest()->getCsrfToken();?>" />
<div class="input-group">
<input class="input-sm form-control" type="text" placeholder="请输入品牌名" name="title" value="<?=$search['title']?>">
<span class="input-group-btn">
<button type="submit" class="btn btn-sm btn-primary"> 搜索</button>
</span>
</div>
</form>
</div>
</div>
<hr>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>序号</th>
<th>品牌</th>
<th>状态</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<?php foreach($brands as $vo):?>
<tr>
<td><?=$vo['id']?></td>
<td><?=$vo['title']?></td>
<td>
<?php if($vo['status_code']==1){?>
<label class="btn btn-info btn-xs"><?=isset($status[$vo['status_code']]) ? $status[$vo['status_code']] : '未知'?></label>
<?php }else{?>
<label class="btn btn-default btn-xs"><?=isset($status[$vo['status_code']]) ? $status[$vo['status_code']] : '未知'?></label>
<?php }?>
</td>
<td>
<p>
<a class="btn btn-primary btn-xs" href="<?=Url::toRoute(['carbrand/ajax','id'=>$vo['id'],'do'=>'show'])?>" mini="ajax">显示</a>
<a class="btn btn-default btn-xs" href="<?=Url::toRoute(['carbrand/ajax','id'=>$vo['id'],'do'=>'hide'])?>" mini="ajax">隐藏</a>
</p>
<a class="btn btn-primary btn-xs" href="<?=Url::toRoute(['carbrand/edit','id'=>$vo['id']])?>"><i class="fa fa-edit"></i>编辑</a>
<a title="点击将删除" href="<?=Url::toRoute(['carbrand/delete','id'=>$vo['id']])?>" class="btn btn-xs btn-danger" mini="act"><i class="fa fa-trash bigger-120"></i>删除</a>
</td>
</tr>
<?php endforeach;?>
</tbody>
</table>
<!--分页-->
<div class="f-r">
<?= LinkPager::widget([
'pagination'=>$pager,
'firstPageLabel' => '首页',
'nextPageLabel' => '下一页',
'prevPageLabel' => '上一页',
'lastPageLabel' => '末页',
]) ?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
+64
View File
@@ -0,0 +1,64 @@
<?php
use yii\helpers\Html;
use yii\helpers\Url;
?>
<div class="wrapper wrapper-content">
<div class="row">
<div class="col-sm-12">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>品牌信息</h5>
<div class="ibox-tools">
<a class="collapse-link">
<i class="fa fa-chevron-up"></i>
</a>
<a class="close-link">
<i class="fa fa-times"></i>
</a>
</div>
</div>
<div class="ibox-content">
<div class="alert alert-info">
此处录入轿车品牌的信息
</div>
<form role="form" class="form-horizontal m-t" method="post" action="<?=Url::toRoute('carbrand/save')?>" >
<input type="hidden" name="_csrf-backend" value="<?=Yii::$app->getRequest()->getCsrfToken();?>" />
<input type="hidden" name="id" value="<?=isset($detail['id'])?$detail['id']:0;?>">
<div class="form-group draggable">
<label class="col-sm-1 control-label">品牌:</label>
<div class="col-sm-9">
<input class="form-control" type="title" name="title" placeholder="品牌名称" autocomplete="off" value="<?=isset($detail['title'])?$detail['title']: ''?>">
</div>
</div>
<div class="form-group draggable">
<label class="col-sm-1 control-label">状态:</label>
<div class="col-sm-9">
<?php foreach($status as $vo=>$ko):?>
<div class="radio radio-primary radio-inline">
<input type="radio" <?=((isset($detail['status_code'])&&$detail['status_code']==$vo)||(!isset($detail['status_code'])&&$vo==1))?'checked':'';?> value="<?=$vo?>" id="status_code" name="status_code">
<label for="status_code"><?=$ko?></label>
</div>
<?php endforeach;?>
</div>
</div>
<div class="hr-line-dashed"></div>
<div class="form-group draggable">
<div class="col-sm-12 col-sm-offset-3">
<button class="btn btn-primary" type="submit">保存内容</button>
<button class="btn btn-white" type="submit">取消</button>
<a class="btn btn-info" href="<?=Url::toRoute('list')?>">全部品牌</a>
</div>
</div>
</form>
<div class="clearfix"></div>
</div>
</div>
</div>
</div>
</div>
+88
View File
@@ -0,0 +1,88 @@
<?php
/**
* @Author: fm453
* @Date: 2018-11-23 12:17:02
* @Last Modified by: fm453
* @Last Modified time: 2020-09-12 19:24:27
* @Email: fm453@lukegzs.com
*/
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yii\helpers\Url;
use yii\widgets\LinkPager;
$this->title = '轿车品牌列表';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="wrapper wrapper-content">
<div class="row">
<div class="col-sm-12">
<div class="ibox float-e-margins">
<div class="ibox-content">
<h1><?= Html::encode($this->title) ?></h1>
<div class="row">
<div class="col-sm-3">
<a class="btn btn-info btn-sm" href="<?= Url::toRoute('carbrand/new')?>">新增品牌</a>
</div>
<div class="col-sm-3 pull-right">
<form action="<?=Url::current(['pid' => Yii::$app->session->get('pid')], false);?>" method="post">
<input type="hidden" name="_csrf-backend" value="<?= Yii::$app->getRequest()->getCsrfToken();?>" />
<div class="input-group">
<input class="input-sm form-control" type="text" placeholder="请输入品牌名" name="title" value="<?=$search['title']?>">
<span class="input-group-btn">
<button type="submit" class="btn btn-sm btn-primary"> 搜索</button>
</span>
</div>
</form>
</div>
</div>
<hr>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>序号</th>
<th>品牌</th>
<th>状态</th>
<th><a class="btn btn-primary btn-xs" onclick="parent.selectCarBrand('','','<?=$callback?>');">清除选择</a></th>
</tr>
</thead>
<tbody>
<?php foreach($brands as $vo):?>
<tr>
<td><?=$vo['id']?></td>
<td><?=$vo['title']?></td>
<td>
<?php if($vo['status_code']==1){?>
<label class="btn btn-info btn-xs"><?=isset($status[$vo['status_code']]) ? $status[$vo['status_code']] : '未知'?></label>
<?php }else{?>
<label class="btn btn-default btn-xs"><?=isset($status[$vo['status_code']]) ? $status[$vo['status_code']] : '未知'?></label>
<?php }?>
</td>
<td>
<a class="btn btn-primary btn-xs" onclick="parent.selectCarBrand('<?=$vo['title']?>','<?=$vo['id']?>','<?=$callback?>');">选择</a>
</td>
</tr>
<?php endforeach;?>
</tbody>
</table>
<!--分页-->
<div class="f-r">
<?= LinkPager::widget([
'pagination'=>$pager,
'firstPageLabel' => '首页',
'nextPageLabel' => '下一页',
'prevPageLabel' => '上一页',
'lastPageLabel' => '末页',
]) ?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
+60
View File
@@ -0,0 +1,60 @@
<?php
use yii\helpers\Html;
use yii\helpers\Url;
?>
<div class="wrapper wrapper-content animated fadeInRight">
<div class="row">
<div class="col-sm-4"></div>
<div class="col-sm-4">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5 style="margin-right:10px;"><kbd>昵称</kbd><?=isset($detail['nickname'])?$detail['nickname']:'';?> </h5>
<h5 style="margin-right:10px;"><kbd>称谓</kbd><?=isset($detail['title'])?$detail['title']:'';?> </h5>
</div>
<div>
<div class="no-padding border-left-right" style="text-align:center;">
<img alt="image" class="img-responsive" src="<?=isset($detail['thumb'])? Url::base(true)."/../../upload".$detail['thumb']:Yii::getAlias("@web").'/img/nopic.jpg';?>" style="display:inline;border-radius:15px;width:180px;">
</div>
<div class="ibox-content profile-content">
<h4>姓名:<strong><?=isset($detail['realname'])?$detail['realname']:'';?></strong></h4>
<h4>手机号:<strong><?=isset($detail['mobile'])?$detail['mobile']:'';?></strong></h4>
<div class="row m-t-lg">
<div class="col-sm-12">
<h5>
<div class="radio radio-primary radio-inline">
<input name="sex" id="sex" value="2" type="radio" <?php if(isset($detail['gender']) && $detail['gender']==2){echo 'checked';}else{echo '';}?> >
<label> <i></i> 女</label>
</div>
<div class="radio radio-primary radio-inline">
<input name="sex" id="sex" value="1" type="radio" <?php if(isset($detail['gender']) && $detail['gender']==1){echo 'checked';}else{echo '';}?> >
<label> <i></i> 男</label>
</div>
<div class="radio radio-primary radio-inline">
<input name="sex" id="sex" value="0" type="radio" <?php if(isset($detail['gender']) && $detail['gender']==0){echo 'checked';}else{echo '';}?> >
<label> <i></i> 保密</label>
</div>
</h5>
</div>
</div>
<div class="row m-t-lg">
<div class="col-sm-4">
<h5><span class="bar">生日:</span>
<strong><?=isset($detail['birthday'])?date('m-d',$detail['birthday']):'';?></strong> </h5>
</div>
<div class="col-sm-4">
<h5><span class="bar">积分:</span>
<strong><?=isset($detail['integral'])?$detail['integral']:0;?></strong> </h5>
</div>
<div class="col-sm-4">
<h5><span class="bar">余额:</span>
<strong><?=isset($detail['money'])?$detail['money']/100:0;?></strong> 元</h5>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-sm-4"></div>
</div>
</div>
+115
View File
@@ -0,0 +1,115 @@
<?php
/**
* @Author: fm453
* @Date: 2018-11-23 12:17:02
* @Last Modified by: fm453
* @Last Modified time: 2020-09-12 21:20:22
* @Email: fm453@lukegzs.com
*/
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yii\helpers\Url;
use yii\widgets\LinkPager;
$this->title = '车主列表';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="wrapper wrapper-content">
<div class="row">
<div class="col-sm-12">
<div class="ibox float-e-margins">
<div class="ibox-content">
<h1><?= Html::encode($this->title) ?></h1>
<div class="row">
<div class="col-sm-3">
<a class="btn btn-info btn-sm" href="<?= Url::toRoute('carowner/new')?>">新增车主</a>
</div>
<div class="col-sm-3 pull-right">
<form action="<?=Url::current(['pid' => Yii::$app->session->get('pid')], false);?>" method="post">
<input type="hidden" name="_csrf-backend" value="<?= Yii::$app->getRequest()->getCsrfToken();?>" />
<div class="input-group">
<input class="input-sm form-control" type="text" placeholder="请输入车主姓名" name="title" value="<?=$search['title']?>">
<span class="input-group-btn">
<button type="submit" class="btn btn-sm btn-primary"> 搜索</button>
</span>
</div>
</form>
</div>
</div>
<hr>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>序号</th>
<th>网点门店及业务员</th>
<th>姓名</th>
<th>联系方式</th>
<th>备忘</th>
<th>状态</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<?php foreach($owners as $vo):?>
<tr>
<td><?=$vo['id']?></td>
<td>
【网点】<code><?=isset($stores[$vo['store_id']]['title'])?$stores[$vo['store_id']]['title']:'未设置'?></code><br>
【业务员】<?=isset($employees[$vo['employee_id']]['name'])?$employees[$vo['employee_id']]['name']:'未关联'?>
</td>
<td>
<kbd>姓名</kbd><?=isset($exts[$vo['mid']]) ? (isset($exts[$vo['mid']]['realname']) ? $exts[$vo['mid']]['realname'] : '') : ''?><code>【<?=$gender[$vo['gender']]?>】</code><br>
<kbd>昵称</kbd><?=isset($exts[$vo['mid']])?(isset($exts[$vo['mid']]['nickname'])?$exts[$vo['mid']]['nickname']:''):''?><br>
<kbd>称谓</kbd><?=isset($exts[$vo['mid']])?(isset($exts[$vo['mid']]['title'])?$exts[$vo['mid']]['title']:''):''?>
</td>
<td>
【手机】<?=isset($users[$vo['mid']]['mobile'])?$users[$vo['mid']]['mobile']:''?><br>
【常在省份】<?=isset($vo['province']) ? (isset(Yii::$app->params['regionAreas'][$vo['province']])?Yii::$app->params['regionAreas'][$vo['province']]:'') : ''?>
</td>
<td>
【上次发车时间】<?=isset($vo['last_send']) && $vo['last_send']>0 ? date('Y-m-d',$vo['last_send']) : '未记录'?><br>
【上次联系时间】<?=isset($vo['last_contact']) && $vo['last_contact']>0 ? date('Y-m-d',$vo['last_contact']) : '未记录'?><br>
【评分|星级】<?=isset($vo['score']) ? $vo['score'].'分': ''?><?=isset($vo['level']) ? $vo['level'].'级': ''?><br>
</td>
<td>
<?php if($vo['status_code']==1){?>
<a class="btn btn-info btn-xs" href="<?=Url::toRoute(['carowner/ajax','id'=>$vo['id'],'do'=>'hide'])?>" mini="ajax"><?=isset($status[$vo['status_code']]) ? $status[$vo['status_code']] : '未知'?></a>
<?php }else{?>
<a class="btn btn-default btn-xs" href="<?=Url::toRoute(['carowner/ajax','id'=>$vo['id'],'do'=>'show'])?>" mini="ajax"><?=isset($status[$vo['status_code']]) ? $status[$vo['status_code']] : '未知'?></a>
<?php }?>
</td>
<td>
<p>
<a class="btn btn-primary btn-xs" href="<?=Url::toRoute(['carowner/edit','id'=>$vo['id']])?>"><i class="fa fa-edit"></i>编辑</a>
<a title="点击将删除" href="<?=Url::toRoute(['carowner/delete','id'=>$vo['id']])?>" class="btn btn-xs btn-danger" mini="act"><i class="fa fa-trash bigger-120"></i>删除</a>
</p>
<p>
<a class="btn btn-primary btn-xs" href="<?=Url::toRoute(['carowner/info','id'=>$vo['id']])?>" w="30%;" h="90%;" title="用户信息摘要" mini="load"><i class="fa fa-child"></i> 信息摘要</a>
<a class="btn btn-primary btn-xs" href="<?=Url::toRoute(['carowner/msg','id'=>$vo['id']])?>" w="80%;" h="90%;" title="短信营销" mini="load"><i class="fa fa-commenting-o"></i> 短信营销</a>
</p>
</td>
</tr>
<?php endforeach;?>
</tbody>
</table>
<!--分页-->
<div class="f-r">
<?= LinkPager::widget([
'pagination'=>$pager,
'firstPageLabel' => '首页',
'nextPageLabel' => '下一页',
'prevPageLabel' => '上一页',
'lastPageLabel' => '末页',
]) ?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
+389
View File
@@ -0,0 +1,389 @@
<?php
use yii\helpers\Html;
use yii\helpers\Url;
?>
<!--百度编辑器-->
<?=Html::jsFile('@web/plugins/ueditor/ueditor.config.js')?>
<!--建议手动加在语言,避免在ie下有时因为加载语言失败导致编辑器加载失败-->
<!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型,比如你在配置项目里配置的是英文,这里加载的中文,那最后就是中文-->
<?=Html::jsFile('@web/plugins/ueditor/ueditor.all.min.js')?>
<?=Html::jsFile('@web/plugins/ueditor/lang/zh-cn/zh-cn.js')?>
<!--日期时间选择器-->
<?=Html::jsFile('@web/js/plugins/layer/laydate/laydate.js')?>
<?=Html::cssFile('@web/js/plugins/layer/laydate/need/laydate.css')?>
<?=Html::cssFile('@web/js/plugins/layer/laydate/skins/molv/laydate.css')?>
<!--滑块选择器-->
<?=Html::cssFile('@web/css/plugins/ionRangeSlider/ion.rangeSlider.css')?>
<?=Html::cssFile('@web/css/plugins/ionRangeSlider/ion.rangeSlider.skinFlat.css')?>
<?=Html::jsFile('@web/js/plugins/ionRangeSlider/ion.rangeSlider.min.js')?>
<!--旋扭输入-->
<?=Html::jsFile('@web/js/plugins/jsKnob/jquery.knob.js')?>
<!--下拉选择、选项框-->
<?=Html::cssFile('@web/css/plugins/chosen/chosen.css')?>
<?=Html::jsFile('@web/js/plugins/chosen/chosen.jquery.js')?>
<div class="wrapper wrapper-content">
<div class="row">
<div class="col-sm-12">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>基础资料</h5>
<div class="ibox-tools">
<a class="collapse-link">
<i class="fa fa-chevron-up"></i>
</a>
<a class="close-link">
<i class="fa fa-times"></i>
</a>
</div>
</div>
<div class="ibox-content">
<div class="alert alert-info">
在此处录入车主客户的基础资料,如果是新客户,系统将自动为其新建一份档案;
</div>
<form role="form" class="form-horizontal m-t" method="post" action="<?=Url::toRoute('carowner/save')?>" >
<input type="hidden" name="_csrf-backend" value="<?=Yii::$app->getRequest()->getCsrfToken();?>" />
<input type="hidden" name="id" value="<?=isset($detail['id'])?$detail['id']:0;?>">
<div class="form-group draggable">
<label class="col-sm-1 control-label">姓名:</label>
<div class="col-sm-2">
<input class="form-control" type="text" name="realname" placeholder="请输入客户的姓名" autocomplete="off" value="<?=isset($detail['realname'])?$detail['realname']:'';?>">
<span class="help-block m-b-none">这里输入车主的真实姓名,如果没有则不填</span>
</div>
<label class="col-sm-1 control-label">昵称:</label>
<div class="col-sm-2">
<input class="form-control" type="text" name="nickname" placeholder="请输入客户的昵称" autocomplete="off" value="<?=isset($detail['nickname'])?$detail['nickname']:'';?>">
<span class="help-block m-b-none">这里输入车主的昵称,如<code>板爷</code>、<code>方少</code></span>
</div>
<label class="col-sm-1 control-label">称谓:</label>
<div class="col-sm-3">
<input class="form-control" type="text" name="title" placeholder="请输入客户的称谓" autocomplete="off" value="<?=isset($detail['title'])?$detail['title']:'';?>">
<span class="help-block m-b-none">这里输入车主的称谓,如“马老师”、“李叔”、“王教授”</span>
</div>
</div>
<div class="form-group draggable">
<label class="col-sm-1 control-label"><span class="red">*</span>主手机号:</label>
<div class="col-sm-2">
<input class="form-control" type="text" name="mobile" placeholder="请输入客户的手机号" autocomplete="off" value="<?=isset($detail['mobile'])?$detail['mobile']:'';?>">
<span class="help-block m-b-none">如<code>18608981880</code></span>
</div>
<label class="col-sm-1 control-label">密码框:</label>
<div class="col-sm-2">
<input class="form-control" type="password" name="password" placeholder="请输入密码,可用于平台后期开放的用户端登陆" autocomplete="off" value="<?=isset($detail['password'])?$detail['password']: Yii::$app->params['defaultUserPassword']?>">
<span class="help-block m-b-none">预留功能,如不填写,将默认使用初始密码<code><?=Yii::$app->params['defaultUserPassword']?></code></span>
</div>
<label class="col-sm-1 control-label">性别:</label>
<div class="col-sm-3">
<select class="form-control" name="gender">
<option value="0" <?php if(isset($detail['gender']) && $detail['gender']==0){echo 'selected';}else{echo '';}?>>未知</option>
<option value="1" <?php if(isset($detail['gender']) && $detail['gender']==1){echo 'selected';}else{echo '';}?>>男</option>
<option value="2" <?php if(isset($detail['gender']) && $detail['gender']==2){echo 'selected';}else{echo '';}?>>女</option>
</select>
</div>
</div>
<div class="form-group draggable">
<label class="col-sm-1 control-label">总消费额:</label>
<div class="col-sm-2">
<div class="input-group">
<input type="text" class="form-control" name="total_fee" id="total_fee-value" placeholder="该客户的总消费金额" autocomplete="off" value="<?=isset($detail['total_fee'])?$detail['total_fee']:0;?>">
<span class="input-group-btn">
<button type="button" class="btn btn-primary">元</button>
</span>
</div>
</div>
<label class="col-sm-1 control-label">常在省份:</label>
<div class="col-sm-2">
<select data-placeholder="选择省份..." class="form-control chosen-select" tabindex="2" name="province">
<option value="">请选择省份</option>
<?php foreach(Yii::$app->params['regionAreas'] as $key=>$val){?>
<option value="<?=$key?>" hassubinfo="true" <?=isset($detail['province']) && $detail['province']==$key ? 'selected':'';?>><?=$val?></option>
<?php }?>
</select>
</div>
<label class="col-sm-1 control-label">身份证号:</label>
<div class="col-sm-3">
<input type="text" class="form-control" name="idcard" id="idcard-value" placeholder="请输入车主身份证号" autocomplete="off" value="<?=isset($detail['idcard'])?$detail['idcard']:'';?>">
</div>
</div>
<div class="form-group draggable">
<label class="col-sm-1 control-label">评分:</label>
<div class="col-sm-9">
<input id="score" name="score" type="number" value="<?=isset($detail['score'])?($detail['score']>=100?100:$detail['score']):60?>">
</div>
<script>
var score = <?=isset($detail['score'])?($detail['score']>=100?100:$detail['score']):60?>;
score = score < 0 ? 0 : score;
$("#score").ionRangeSlider({
min: 0,
max: 100,
postfix: " 分",
from: score
});
</script>
</div>
<div class="form-group draggable">
<label class="col-sm-1 control-label">星级</label>
<div class="col-sm-9">
<div class="m-r-md inline">
<input type="text" name="level" id="level" value="<?=isset($detail['level'])?$detail['level']:0?>" class="dial m-r-sm" data-fgColor="#ED5565" data-width="85" data-height="85" data-cursor=true data-thickness=.3/>
</div>
<script>
$("#level").knob({
'min':0,
'max':5
});
</script>
<span class="help-block m-b-none">星级范围为0~5,默认为0</span>
</div>
</div>
<div class="form-group draggable">
<label class="col-sm-1 control-label">更多手机号:</label>
<div class="col-sm-9">
<input class="form-control" type="text" name="mobiles" placeholder="请输入其他手机号" autocomplete="off" value="<?=isset($detail['mobiles'])?$detail['mobiles']:'';?>">
<span class="help-block m-b-none">多个手机号时,号码间用逗号(<kbd>,</kbd> )隔开;如<code>18608981880</code><kbd>,</kbd><code>13812345678</code>。</span>
</div>
</div>
<div class="form-group draggable">
<label class="col-sm-1 control-label">车主照片:</label>
<div class="col-sm-9">
<div class="input-group">
<input type="text" class="form-control" name="thumb" id="thumb-value" placeholder="如有车主照片,可上传一张" autocomplete="off" value="<?=isset($detail['thumb'])?$detail['thumb']:'';?>"> <span class="input-group-btn"> <button type="button" class="btn btn-primary" data-id="thumb-value" href="<?= Url::toRoute(['upload/image','multi'=>false,'callback'=>'thumb']);?>" w="80%;" h="90%;" title="选择或上传图片" mini="load">选择图片
</button> </span>
</div>
<!-- <div class="input-group">
<input type="text" class="form-control" name="thumb" id="thumb-value" placeholder="如有车主照片,可上传一张" autocomplete="off"> <span class="input-group-btn"> <button type="button" class="btn btn-primary" onclick="showImageFrame(this);" data-id="thumb-value" data-src="<?= Url::toRoute(['upload/image','multi'=>false]);?>" data-width="80%;" data-height="90%;" data-title="选择或上传图片">选择图片
</button> </span>
</div> -->
<div class="input-group " style="margin-top:.5em;">
<img id="thumb-preview" src="<?=isset($detail['thumb'])? Url::base(true)."/../../upload".$detail['thumb']:Yii::getAlias("@web").'/img/nopic.jpg';?>" onerror="this.src='../img/nopic.jpg'; this.title='图片未找到.'" class="img-responsive img-thumbnail" width="150">
<em class="close" style="position:absolute; top: 0px; right: -14px;" title="删除这张图片" onclick="deleteImage(this)">×</em>
</div>
</div>
</div>
<div class="form-group draggable">
<label class="col-sm-1 control-label"><span class="red">*</span> 归属网点:</label>
<div class="col-sm-4">
<input type="text" class="form-control" name="store_title" id="store-title" value="<?=isset($detail['store_title'])?$detail['store_title']:'';?>" placeholder="点击选择所在网点" autocomplete="off" href="<?=Url::toRoute(['store/select','callback'=>'store']);?>" w="80%;" h="90%;" title="选择所在网点" mini="load">
<input type="hidden" class="form-control" name="store" id="store-value" value="<?=isset($detail['store_id'])?$detail['store_id']:0;?>">
</div>
<script>
function selectStore(title,id,callback)
{
layer.closeAll();
layer.msg('已选择');
$('#'+callback+'-value').val(id);
$('#'+callback+'-title').val(title);
}
</script>
<label class="col-sm-1 control-label">关联员工:</label>
<div class="col-sm-4">
<input type="text" class="form-control" name="employee_title" id="employee-title" value="<?=isset($detail['employee_title'])?$detail['employee_title']:'';?>" placeholder="点击选择该车主的介绍人" autocomplete="off" href="<?=Url::toRoute(['employee/select','callback'=>'employee']);?>" w="80%;" h="90%;" title="选择该车主的介绍人" mini="load">
<input type="hidden" class="form-control" name="employee" id="employee-value" value="<?=isset($detail['employee_id'])?$detail['employee_id']:0;?>">
</div>
<script>
function selectEmployee(title,id,callback)
{
layer.closeAll();
layer.msg('已选择');
$('#'+callback+'-value').val(id);
$('#'+callback+'-title').val(title);
}
</script>
</div>
<div class="form-group draggable">
<label class="col-sm-1 control-label">上次发车时间:</label>
<div class="col-sm-4">
<input class="form-control layer-date" type="text" name="last_send" placeholder="请选择时间" autocomplete="off" onclick="laydate({istime: true, format: 'YYYY-MM-DD'})" value="<?=isset($detail['last_send'])?$detail['last_send']:''?>">
</div>
<label class="col-sm-1 control-label">上次业务联系时间:</label>
<div class="col-sm-4">
<input class="form-control layer-date" type="text" name="last_contact" placeholder="请选择时间" autocomplete="off" onclick="laydate({istime: true, format: 'YYYY-MM-DD'})" value="<?=isset($detail['last_contact'])?$detail['last_contact']:''?>">
</div>
</div>
<div class="form-group draggable">
<label class="col-sm-1 control-label">是否显示:
</label>
<div class="col-sm-9">
<div class="radio radio-primary radio-inline">
<input type="radio" <?=(isset($detail['status_code'])&&$detail['status_code']==1)?'checked':'';?> value="1" id="status_code" name="status_code">
<label for="status_code">是</label>
</div>
<div class="radio radio-primary radio-inline">
<input type="radio" <?=((!isset($detail['status_code']))||isset($detail['status_code'])&&$detail['status_code']==0)?'checked':'';?> value="0" id="status_code" name="status_code">
<label for="status_code">否</label>
</div>
</div>
</div>
<div class="form-group draggable">
<label class="col-sm-1 control-label">备注:</label>
<div class="col-sm-9">
<textarea id="editor" name="editor" style="min-height:300px;"><?=isset($detail['remark'])?$detail['remark']:''?></textarea>
</div>
</div>
<div class="hr-line-dashed"></div>
<div class="form-group draggable">
<div class="col-sm-12 col-sm-offset-3">
<button class="btn btn-primary" type="submit">保存内容</button>
<button class="btn btn-white" type="submit">取消</button>
<a class="btn btn-info" href="<?=Url::toRoute('carowner/list')?>">车主列表</a>
</div>
</div>
</form>
<div class="clearfix"></div>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
function showImageFrame(obj){
//取预设参数
var id,title,width,height,url;
id = $(obj).attr('data-id');
title = $(obj).attr('data-title');
width = $(obj).attr('data-width');
height = $(obj).attr('data-height');
url = $(obj).attr('data-src');
//iframe层
parent.layer.open({
type: 2,
title: title,
shadeClose: true,
shade: 0.8,
area: [width, height],
content: url //iframe的url
});
}
function deleteImage(elm){
$(elm).prev().attr("src", "../img/nopic.jpg");
$(elm).parent().prev().find("input").val("");
parent.layer.msg('图片已删除;您可重新上传');
}
function selectImage(title,path,src,callback)
{
layer.closeAll();
layer.msg('图片已选择');
$('#'+callback+'-value').val(path);
$('#'+callback+'-preview').attr('src',src);
}
</script>
<script type="text/javascript">
//实例化编辑器
//建议使用工厂方法getEditor创建和引用编辑器实例,如果在某个闭包下引用该编辑器,直接调用UE.getEditor('editor')就能拿到相关的实例
var ue = UE.getEditor('editor');
/* 传入参数表,添加到已有参数表里 */
ue.ready(function() {
ue.execCommand('serverparam', {
'siteId': "<?=Yii::$app->params['siteId']?>",
'pid': "<?=Yii::$app->session->get('pid')?>"
});
});
</script>
<script>
laydate.skin('molv');
$(document).ready(function() {
var config = {
".chosen-select": {},
".chosen-select-deselect": {
allow_single_deselect: !0
},
".chosen-select-no-single": {
disable_search_threshold: 10
},
".chosen-select-no-results": {
no_results_text: "Oops, nothing found!"
},
".chosen-select-width": {
width: "95%"
}
};
for (var selector in config) $(selector).chosen(config[selector]);
});
</script>
<style>
.laydate_body .laydate_top{
padding:0;
}
.laydate_body .laydate_ym{
/*margin:0;
padding:5px;*/
}
.laydate_body .laydate_table{
border:0;
border-bottom: 1px solid rgb(204, 204, 204);
}
.laydate_body .laydate_bottom {
border: 0;
margin-bottom: 10px;
}
</style>
<style>
.chosen-container-single .chosen-single{
line-height:30px;
}
</style>
<!-- <script>
laydate(
{elem:"#hello",event:"focus"}
);
var start={
elem:"#start",
format:"YYYY/MM/DD hh:mm:ss",
min:laydate.now(),
max:"2099-06-16 23:59:59",
istime:true,
istoday:false,
choose:function(datas){
end.min=datas;
end.start=datas
}
};
var end={
elem:"#end",
format:"YYYY/MM/DD hh:mm:ss",
min:laydate.now(),
max:"2099-06-16 23:59:59",
istime:true,
istoday:false,
choose:function(datas){
start.max=datas
}
};
laydate(start);
laydate(end);
</script> -->
+67
View File
@@ -0,0 +1,67 @@
<?php
use yii\helpers\Html;
use yii\helpers\Url;
?>
<div class="wrapper wrapper-content animated fadeInRight">
<div class="row">
<div class="col-sm-12"></div>
<div class="col-sm-12">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5 style="margin-right:10px;"><kbd>昵称</kbd><?=isset($detail['nickname'])?$detail['nickname']:'';?> </h5>
<h5 style="margin-right:10px;"><kbd>称谓</kbd><?=isset($detail['title'])?$detail['title']:'';?> </h5>
</div>
<div>
<div class="no-padding border-left-right" style="text-align:center;">
<img alt="image" class="img-responsive" src="<?=isset($detail['thumb'])? Url::base(true)."/../../upload".$detail['thumb']:Yii::getAlias("@web").'/img/nopic.jpg';?>" style="display:inline;border-radius:15px;width:180px;">
</div>
<div class="ibox-content profile-content">
<h4>姓名:<strong><?=isset($detail['realname'])?$detail['realname']:'';?></strong></h4>
<h4>手机号:<strong><?=isset($detail['mobile'])?$detail['mobile']:'';?></strong></h4>
<div class="row m-t-lg">
<div class="col-sm-12">
<h5>
<div class="radio radio-primary radio-inline">
<input name="sex" id="sex" value="2" type="radio" <?php if(isset($detail['gender']) && $detail['gender']==2){echo 'checked';}else{echo '';}?> >
<label> <i></i> 女</label>
</div>
<div class="radio radio-primary radio-inline">
<input name="sex" id="sex" value="1" type="radio" <?php if(isset($detail['gender']) && $detail['gender']==1){echo 'checked';}else{echo '';}?> >
<label> <i></i> 男</label>
</div>
<div class="radio radio-primary radio-inline">
<input name="sex" id="sex" value="0" type="radio" <?php if(isset($detail['gender']) && $detail['gender']==0){echo 'checked';}else{echo '';}?> >
<label> <i></i> 保密</label>
</div>
</h5>
</div>
</div>
<div class="row m-t-lg">
<div class="col-sm-4">
<h5><span class="bar">生日:</span>
<strong><?=isset($detail['birthday'])?date('m-d',$detail['birthday']):'';?></strong> </h5>
</div>
<div class="col-sm-4">
<h5><span class="bar">积分:</span>
<strong><?=isset($detail['integral'])?$detail['integral']:0;?></strong> </h5>
</div>
<div class="col-sm-4">
<h5><span class="bar">余额:</span>
<strong><?=isset($detail['money'])?$detail['money']/100:0;?></strong> 元</h5>
</div>
</div>
<div class="hr-line-dashed"></div>
<div class="row m-t-lg">
<div class="col-sm-12">
<a title="发送验证码" href="<?=Url::toRoute(['carowner/msg','op'=>'send','opp'=>'vcode','id'=>$id])?>" class="btn btn-xs btn-danger" mini="act"><i class="fa fa-commenting-o bigger-120"></i>发送验证码</a>
<a title="生日祝福" href="<?=Url::toRoute(['carowner/msg','op'=>'send','opp'=>'birthday','id'=>$id])?>" class="btn btn-xs btn-success" mini="act"><i class="fa fa-commenting-o bigger-120"></i>生日祝福</a>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-sm-4"></div>
</div>
</div>
+108
View File
@@ -0,0 +1,108 @@
<?php
/**
* @Author: fm453
* @Date: 2018-11-23 12:17:02
* @Last Modified by: fm453
* @Last Modified time: 2020-09-12 21:22:14
* @Email: fm453@lukegzs.com
*/
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yii\helpers\Url;
use yii\widgets\LinkPager;
$this->title = '车主列表';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="wrapper wrapper-content">
<div class="row">
<div class="col-sm-12">
<div class="ibox float-e-margins">
<div class="ibox-content">
<h1><?= Html::encode($this->title) ?></h1>
<div class="row">
<div class="col-sm-3">
<a class="btn btn-info btn-sm" href="<?= Url::toRoute('carowner/new')?>">新增车主</a>
</div>
<div class="col-sm-3 pull-right">
<form action="<?=Url::current(['pid' => Yii::$app->session->get('pid')], false);?>" method="post">
<input type="hidden" name="_csrf-backend" value="<?= Yii::$app->getRequest()->getCsrfToken();?>" />
<div class="input-group">
<input class="input-sm form-control" type="text" placeholder="请输入车主姓名" name="title" value="<?=$search['title']?>">
<span class="input-group-btn">
<button type="submit" class="btn btn-sm btn-primary"> 搜索</button>
</span>
</div>
</form>
</div>
</div>
<hr>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>序号</th>
<th>网点门店及业务员</th>
<th>姓名</th>
<th>联系方式</th>
<th>备忘</th>
<th>状态</th>
<th><a class="btn btn-primary btn-xs" onclick="parent.selectCarOwner('','','<?=$callback?>');">清除选择</a></th>
</tr>
</thead>
<tbody>
<?php foreach($owners as $vo):?>
<tr>
<td><?=$vo['id']?></td>
<td>
【网点】<code><?=isset($stores[$vo['store_id']]['title'])?$stores[$vo['store_id']]['title']:'未设置'?></code><br>
【业务员】<?=isset($employees[$vo['employee_id']]['name'])?$employees[$vo['employee_id']]['name']:'未关联'?>
</td>
<td>
<kbd>姓名</kbd><?=isset($exts[$vo['mid']]) ? (isset($exts[$vo['mid']]['realname']) ? $exts[$vo['mid']]['realname'] : '') : ''?><code>【<?=$gender[$vo['gender']]?>】</code><br>
<kbd>昵称</kbd><?=isset($exts[$vo['mid']])?(isset($exts[$vo['mid']]['nickname'])?$exts[$vo['mid']]['nickname']:''):''?><br>
<kbd>称谓</kbd><?=isset($exts[$vo['mid']])?(isset($exts[$vo['mid']]['title'])?$exts[$vo['mid']]['title']:''):''?>
</td>
<td>
【手机】<?=$users[$vo['mid']]['mobile']?><br>
【常在省份】<?=isset($vo['province']) ? (isset(Yii::$app->params['regionAreas'][$vo['province']])?Yii::$app->params['regionAreas'][$vo['province']]:'') : ''?>
</td>
<td>
【上次发车时间】<?=isset($vo['last_send']) && $vo['last_send']>0 ? date('Y-m-d',$vo['last_send']) : '未记录'?><br>
【上次联系时间】<?=isset($vo['last_contact']) && $vo['last_contact']>0 ? date('Y-m-d',$vo['last_contact']) : '未记录'?><br>
【评分|星级】<?=isset($vo['score']) ? $vo['score'].'分': ''?><?=isset($vo['level']) ? $vo['level'].'级': ''?><br>
</td>
<td>
<?php if($vo['status_code']==1){?>
<label class="btn btn-info btn-xs"><?=$status[$vo['status_code']]?></label>
<?php }else{?>
<label class="btn btn-default btn-xs"><?=$status[$vo['status_code']]?></label>
<?php }?>
</td>
<td>
<a class="btn btn-primary btn-xs" onclick="parent.selectCarOwner('<?=isset($exts[$vo['mid']]) ? (isset($exts[$vo['mid']]['realname']) ? $exts[$vo['mid']]['realname'] : '') : ''?>','<?=$vo['id']?>','<?=$callback?>');">选择</a>
</td>
</tr>
<?php endforeach;?>
</tbody>
</table>
<!--分页-->
<div class="f-r">
<?= LinkPager::widget([
'pagination'=>$pager,
'firstPageLabel' => '首页',
'nextPageLabel' => '下一页',
'prevPageLabel' => '上一页',
'lastPageLabel' => '末页',
]) ?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
+114
View File
@@ -0,0 +1,114 @@
<?php
/**
* @Author: fm453
* @Date: 2018-11-23 12:17:02
* @Last Modified by: fm453
* @Last Modified time: 2020-12-13 09:47:52
* @Email: fm453@lukegzs.com
*/
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yii\helpers\Url;
use yii\widgets\LinkPager;
$this->title = '车型列表';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="wrapper wrapper-content">
<div class="row">
<div class="col-sm-12">
<div class="ibox float-e-margins">
<div class="ibox-content">
<h1><?= Html::encode($this->title) ?></h1>
<div class="row">
<div class="col-sm-3">
<a class="btn btn-info btn-sm" href="<?= Url::toRoute('carseries/new')?>">新增车型</a>
</div>
<form action="<?=Url::current(['pid' => Yii::$app->session->get('pid')], false);?>" method="post">
<input type="hidden" name="_csrf-backend" value="<?= Yii::$app->getRequest()->getCsrfToken();?>" />
<div class="col-sm-3 pull-right">
<div class="input-group">
<input class="input-sm form-control" type="text" placeholder="请输入车型名称" name="search[title]" value="<?=$search['title']?>">
<span class="input-group-btn">
<button type="submit" class="btn btn-sm btn-primary"> 搜索</button>
</span>
</div>
</div>
<div class="col-sm-3 pull-right">
<div class="input-group">
<input class="input-sm form-control" type="text" placeholder="点击按品牌筛选" name="search[brand]" id="brand-title" value="<?=$search['brand']?>" autocomplete="off" href="<?=Url::toRoute(['carbrand/select','callback'=>'brand']);?>" w="80%;" h="90%;" title="选择品牌车型" mini="load">
<span class="input-group-btn">
<button type="submit" class="btn btn-sm btn-primary"> 筛选</button>
</span>
</div>
<input type="hidden" name="search[brand_id]" id="brand-value" value="<?=$search['brand_id']?>" />
<script>
function selectCarBrand(title,id,callback)
{
layer.closeAll();
layer.msg('已选择');
$('#'+callback+'-value').val(id);
$('#'+callback+'-title').val(title);
}
</script>
</div>
</form>
</div>
<hr>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>序号</th>
<th>车品牌</th>
<th>型号</th>
<th>状态</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<?php foreach($series as $vo):?>
<tr>
<td><?=$vo['id']?></td>
<td>【<code><?=isset($brands[$vo['brand_id']]['title'])?$brands[$vo['brand_id']]['title']:'未设置'?></code>】</td>
<td><?=$vo['title']?></td>
<td>
<?php if($vo['status_code']==1){?>
<label class="btn btn-info btn-xs"><?=isset($status[$vo['status_code']]) ? $status[$vo['status_code']] : '未知'?></label>
<?php }else{?>
<label class="btn btn-default btn-xs"><?=isset($status[$vo['status_code']]) ? $status[$vo['status_code']] : '未知'?></label>
<?php }?>
</td>
<td>
<p>
<a class="btn btn-primary btn-xs" href="<?=Url::toRoute(['carseries/ajax','id'=>$vo['id'],'do'=>'show'])?>" mini="ajax">显示</a>
<a class="btn btn-default btn-xs" href="<?=Url::toRoute(['carseries/ajax','id'=>$vo['id'],'do'=>'hide'])?>" mini="ajax">隐藏</a>
</p>
<a class="btn btn-primary btn-xs" href="<?=Url::toRoute(['carseries/edit','id'=>$vo['id']])?>"><i class="fa fa-edit"></i>编辑</a>
<a title="点击将删除" href="<?=Url::toRoute(['carseries/delete','id'=>$vo['id']])?>" class="btn btn-xs btn-danger" mini="act"><i class="fa fa-trash bigger-120"></i>删除</a>
</td>
</tr>
<?php endforeach;?>
</tbody>
</table>
<!--分页-->
<div class="f-r">
<?= LinkPager::widget([
'pagination'=>$pager,
'firstPageLabel' => '首页',
'nextPageLabel' => '下一页',
'prevPageLabel' => '上一页',
'lastPageLabel' => '末页',
]) ?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
+127
View File
@@ -0,0 +1,127 @@
<?php
use yii\helpers\Html;
use yii\helpers\Url;
?>
<!--下拉选择、选项框-->
<?=Html::cssFile('@web/css/plugins/chosen/chosen.css')?>
<?=Html::jsFile('@web/js/plugins/chosen/chosen.jquery.js')?>
<div class="wrapper wrapper-content">
<div class="row">
<div class="col-sm-12">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>车型资料</h5>
<div class="ibox-tools">
<a class="collapse-link">
<i class="fa fa-chevron-up"></i>
</a>
<a class="close-link">
<i class="fa fa-times"></i>
</a>
</div>
</div>
<div class="ibox-content">
<div class="alert alert-info">
此处录入车辆车型的参数资料
</div>
<form role="form" class="form-horizontal m-t" method="post" action="<?=Url::toRoute('carseries/save')?>" >
<input type="hidden" name="_csrf-backend" value="<?=Yii::$app->getRequest()->getCsrfToken();?>" />
<input type="hidden" name="id" value="<?=isset($detail['id'])?$detail['id']:0;?>">
<div class="form-group draggable">
<label class="col-sm-1 control-label">选择品牌:</label>
<div class="col-sm-4">
<input type="text" class="form-control" name="brand_title" id="brand-title" value="<?=isset($detail['brand_title'])?$detail['brand_title']:'';?>" placeholder="点击选择品牌" autocomplete="off" href="<?=Url::toRoute(['carbrand/select','callback'=>'brand']);?>" w="80%;" h="90%;" title="选择品牌车型" mini="load">
<input type="hidden" class="form-control" name="brand_id" id="brand-value" value="<?=isset($detail['brand_id'])?$detail['brand_id']:0;?>">
</div>
<script>
function selectCarBrand(title,id,callback)
{
layer.closeAll();
layer.msg('已选择');
$('#'+callback+'-value').val(id);
$('#'+callback+'-title').val(title);
}
</script>
<label class="col-sm-1 control-label">车型名称:</label>
<div class="col-sm-4">
<input class="form-control" type="title" name="title" placeholder="车型名称" autocomplete="off" value="<?=isset($detail['title'])?$detail['title']: ''?>">
</div>
</div>
<div class="form-group draggable">
<label class="col-sm-1 control-label">车型参数:</label>
<div class="col-sm-10">
<div class="input-group">
<span class="input-group-btn">
<button type="button" class="btn btn-primary">长</button>
</span>
<input class="form-control" type="text" name="p[length]" placeholder="输入数字" autocomplete="off" value="<?=isset($params['length'])?$params['length']: 0?>">
<span class="input-group-btn">
<button type="button" class="btn btn-info">厘米</button>
</span>
<span class="input-group-btn">
<button type="button" class="btn btn-primary">宽</button>
</span>
<input class="form-control" type="text" name="p[width]" placeholder="输入数字" autocomplete="off" value="<?=isset($params['width'])?$params['width']: 0?>">
<span class="input-group-btn">
<button type="button" class="btn btn-info">厘米</button>
</span>
<span class="input-group-btn">
<button type="button" class="btn btn-primary">高</button>
</span>
<input class="form-control" type="text" name="p[height]" placeholder="输入数字" autocomplete="off" value="<?=isset($params['height'])?$params['height']: 0?>">
<span class="input-group-btn">
<button type="button" class="btn btn-info">厘米</button>
</span>
<span class="input-group-btn">
<button type="button" class="btn btn-primary">净重</button>
</span>
<input class="form-control" type="text" name="p[kg]" placeholder="输入数字" autocomplete="off" value="<?=isset($params['kg'])?$params['kg']: 0?>">
<span class="input-group-btn">
<button type="button" class="btn btn-info">Kg</button>
</span>
<span class="input-group-btn">
<button type="button" class="btn btn-primary">厢型</button>
</span>
<input class="form-control" type="text" name="p[seat]" placeholder="输入数字" autocomplete="off" value="<?=isset($params['seat'])?$params['seat']: 0?>">
<span class="input-group-btn">
<button type="button" class="btn btn-info">座</button>
</span>
</div>
</div>
</div>
<div class="form-group draggable">
<label class="col-sm-1 control-label">车型状态:</label>
<div class="col-sm-9">
<?php foreach($status as $vo=>$ko):?>
<div class="radio radio-primary radio-inline">
<input type="radio" <?=((isset($detail['status_code'])&&$detail['status_code']==$vo)||(!isset($detail['status_code'])&&$vo==1))?'checked':'';?> value="<?=$vo?>" id="status_code" name="status_code">
<label for="status_code"><?=$ko?></label>
</div>
<?php endforeach;?>
</div>
</div>
<div class="hr-line-dashed"></div>
<div class="form-group draggable">
<div class="col-sm-12 col-sm-offset-3">
<button class="btn btn-primary" type="submit">保存内容</button>
<button class="btn btn-white" type="submit">取消</button>
<a class="btn btn-info" href="<?=Url::toRoute('list')?>">全部车型</a>
</div>
</div>
</form>
<div class="clearfix"></div>
</div>
</div>
</div>
</div>
</div>
+109
View File
@@ -0,0 +1,109 @@
<?php
/**
* @Author: fm453
* @Date: 2018-11-23 12:17:02
* @Last Modified by: fm453
* @Last Modified time: 2020-12-13 10:49:31
* @Email: fm453@lukegzs.com
*/
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yii\helpers\Url;
use yii\widgets\LinkPager;
$this->title = '品牌车型列表';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="wrapper wrapper-content">
<div class="row">
<div class="col-sm-12">
<div class="ibox float-e-margins">
<div class="ibox-content">
<h1><?= Html::encode($this->title) ?></h1>
<div class="row">
<div class="col-sm-3">
<a class="btn btn-info btn-sm" href="<?= Url::toRoute('carseries/new')?>">新增车型</a>
</div>
<form action="<?=Url::current(['pid' => Yii::$app->session->get('pid')], false);?>" method="post">
<input type="hidden" name="_csrf-backend" value="<?= Yii::$app->getRequest()->getCsrfToken();?>" />
<div class="col-sm-3 pull-right">
<div class="input-group">
<input class="input-sm form-control" type="text" placeholder="请输入车型名称" name="search[title]" value="<?=$search['title']?>">
<span class="input-group-btn">
<button type="submit" class="btn btn-sm btn-primary"> 搜索</button>
</span>
</div>
</div>
<div class="col-sm-3 pull-right">
<div class="input-group">
<input class="input-sm form-control" type="text" placeholder="点击按品牌筛选" name="search[brand]" id="brand-title" value="<?=$search['brand']?>" autocomplete="off" href="<?=Url::toRoute(['carbrand/select','callback'=>'brand']);?>" w="80%;" h="90%;" title="选择品牌车型" mini="load">
<span class="input-group-btn">
<button type="submit" class="btn btn-sm btn-primary"> 筛选</button>
</span>
</div>
<input type="hidden" name="search[brand_id]" id="brand-value" value="<?=$search['brand_id']?>" />
<script>
function selectCarBrand(title,id,callback)
{
layer.closeAll();
layer.msg('已选择');
$('#'+callback+'-value').val(id);
$('#'+callback+'-title').val(title);
}
</script>
</div>
</form>
</div>
<hr>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>序号</th>
<th>车品牌</th>
<th>型号</th>
<th>状态</th>
<th><a class="btn btn-primary btn-xs" onclick="parent.selectCarSeries('','','','<?=$callback?>');">清除选择</a></th>
</tr>
</thead>
<tbody>
<?php foreach($series as $vo):?>
<tr>
<td><?=$vo['id']?></td>
<td>【<code><?=isset($brands[$vo['brand_id']]['title'])?$brands[$vo['brand_id']]['title']:'未设置'?></code>】</td>
<td><?=$vo['title']?></td>
<td>
<?php if($vo['status_code']==1){?>
<label class="btn btn-info btn-xs"><?=isset($status[$vo['status_code']]) ? $status[$vo['status_code']] : '未知'?></label>
<?php }else{?>
<label class="btn btn-default btn-xs"><?=isset($status[$vo['status_code']]) ? $status[$vo['status_code']] : '未知'?></label>
<?php }?>
</td>
<td>
<a class="btn btn-primary btn-xs" onclick="parent.selectCarSeries('<?=isset($brands[$vo['brand_id']]['title'])?$brands[$vo['brand_id']]['title']:''?><?=$vo['title']?>','<?=$vo['id']?>','<?=$vo['brand_id']?>','<?=$callback?>');">选择</a>
</td>
</tr>
<?php endforeach;?>
</tbody>
</table>
<!--分页-->
<div class="f-r">
<?= LinkPager::widget([
'pagination'=>$pager,
'firstPageLabel' => '首页',
'nextPageLabel' => '下一页',
'prevPageLabel' => '上一页',
'lastPageLabel' => '末页',
]) ?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
+82
View File
@@ -0,0 +1,82 @@
<?php
use yii\helpers\Html;
use yii\helpers\Url;
use yii\bootstrap\ActiveForm;
use yii\widgets\LinkPager;
$this->title = '城市列表';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="wrapper wrapper-content">
<div class="row">
<div class="col-xs-12">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>搜索</h5>
</div>
<div class="ibox-content">
<div class="row">
<div class="table-responsive">
<form class="form-search" method="get" action="<?=Url::current(['pid' => Yii::$app->session->get('pid')], false);?>" role="form">
<input type="hidden" name="_csrf-backend" value="<?= Yii::$app->getRequest()->getCsrfToken();?>" />
<div class="form-group draggable">
<div class="col-sm-5">
<div class="input-group">
<input type="text" class="form-control" name="title" value="<?=isset($search['title']) ? $search['title']:''?>" placeholder="输入城市名称;支持模糊检索" autocomplete="off">
<span class="input-group-btn"> <button type="button" class="btn btn-primary">搜索
</button> </span>
<span class="hidden input-group-btn"> <a class="btn btn-info" href="<?=Url::toRoute('city/new')?>" target="_blank">去新增一个
</a> </span>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<div class="col-sm-12">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h1><?= Html::encode($this->title) ?></h1>
</div>
<div class="ibox-content">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>ID</th>
<th>城市</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<?php foreach($citys as $vo):?>
<tr>
<td><?=$vo['id']?></td>
<td><?=$vo['name']?></td>
<td>
<a onclick="parent.selectCity('<?=$vo['name']?>','<?=$vo['id']?>','<?=$callback?>');" href="javascript:void(0);" class="btn btn-xs btn-info">选择</a>
</td>
</tr>
<?php endforeach;?>
</tbody>
</table>
<!--分页-->
<div class="f-r">
<?= LinkPager::widget([
'pagination'=>$pager,
'firstPageLabel' => '首页',
'nextPageLabel' => '下一页',
'prevPageLabel' => '上一页',
'lastPageLabel' => '末页',
]) ?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
+95
View File
@@ -0,0 +1,95 @@
<?php
/**
* @Author: fm453
* @Date: 2018-11-23 12:17:02
* @Last Modified by: fm453
* @Last Modified time: 2020-12-13 10:23:44
* @Email: fm453@lukegzs.com
*/
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yii\helpers\Url;
use yii\widgets\LinkPager;
$this->title = '通讯簿';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="wrapper wrapper-content">
<div class="row">
<div class="col-sm-12">
<div class="ibox float-e-margins">
<div class="ibox-content">
<h1><?= Html::encode($this->title) ?></h1>
<div class="row">
<div class="col-sm-3">
<a class="btn btn-info btn-sm" href="<?= Url::toRoute('contact/new')?>">新增通讯名单</a>
</div>
<div class="col-sm-5 pull-right">
<form action="<?=Url::current(['pid' => Yii::$app->session->get('pid')], false);?>" method="post">
<input type="hidden" name="_csrf-backend" value="<?= Yii::$app->getRequest()->getCsrfToken();?>" />
<div class="input-group">
<input class="input-sm form-control" type="text" placeholder="姓名或手机号" name="search[title]" value="<?=$search['title']?>">
<span class="input-group-btn">
<button type="submit" class="btn btn-sm btn-primary"> 搜索</button>
</span>
</div>
</form>
</div>
</div>
<hr>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>序号</th>
<th>单位</th>
<th>姓名</th>
<th>手机</th>
<th>状态</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<?php foreach($contactors as $vo):?>
<tr>
<td><?=$vo['id']?></td>
<td><?=$vo['company']?></td>
<td><?=$vo['name']?></td>
<td><?=$vo['mobile']?></td>
<td>
<?php if($vo['status_code']==1){?>
<a class="btn btn-info btn-xs" href="<?=Url::toRoute(['contact/ajax','id'=>$vo['id'],'do'=>'out'])?>" mini="ajax"><?=$status[$vo['status_code']]?></a>
<?php }elseif($vo['status_code']==0){?>
<a class="btn btn-default btn-xs" href="<?=Url::toRoute(['contact/ajax','id'=>$vo['id'],'do'=>'in'])?>" mini="ajax"><?=$status[$vo['status_code']]?></a>
<?php }else{?>
<button class="btn btn-success btn-xs"><?=$status[$vo['status_code']]?></button>
<?php }?>
</td>
<td>
<a class="btn btn-primary btn-xs" href="<?=Url::toRoute(['contact/edit','id'=>$vo['id']])?>"><i class="fa fa-edit"></i>编辑</a>
<a title="点击将删除" href="<?=Url::toRoute(['contact/delete','id'=>$vo['id']])?>" class="btn btn-xs btn-danger" mini="act"><i class="fa fa-trash bigger-120"></i>删除</a>
</td>
</tr>
<?php endforeach;?>
</tbody>
</table>
<!--分页-->
<div class="f-r">
<?= LinkPager::widget([
'pagination'=>$pager,
'firstPageLabel' => '首页',
'nextPageLabel' => '下一页',
'prevPageLabel' => '上一页',
'lastPageLabel' => '末页',
]) ?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
+92
View File
@@ -0,0 +1,92 @@
<?php
use yii\helpers\Html;
use yii\helpers\Url;
?>
<div class="wrapper wrapper-content">
<div class="row">
<div class="col-sm-12">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>通讯录管理</h5>
<div class="ibox-tools">
<a class="collapse-link">
<i class="fa fa-chevron-up"></i>
</a>
<a class="close-link">
<i class="fa fa-times"></i>
</a>
</div>
</div>
<div class="ibox-content">
<div class="alert alert-info">
此处录入通讯信息
</div>
<form class="form-horizontal m-t" method="post" action="<?=Url::toRoute('contact/save')?>" role="form">
<input type="hidden" name="_csrf-backend" value="<?=Yii::$app->getRequest()->getCsrfToken();?>" />
<input type="hidden" name="id" value="<?=isset($detail['id'])?$detail['id']:0;?>">
<div class="form-group draggable">
<label class="col-sm-1 control-label"><span class="red">*</span> 姓名:</label>
<div class="col-sm-2">
<input class="form-control" type="text" name="name" value="<?=isset($detail['name'])?$detail['name']:'';?>" placeholder="请输入姓名" autocomplete="off">
</div>
<label class="col-sm-1 control-label"><span class="red">*</span> 手机号:</label>
<div class="col-sm-2">
<input class="form-control" type="text" name="mobile" value="<?=isset($detail['mobile'])?$detail['mobile']:'';?>" placeholder="请输入手机号码" autocomplete="off">
</div>
<label class="col-sm-1 control-label"> 身份证号:</label>
<div class="col-sm-3">
<input class="form-control" type="text" name="idcard" value="<?=isset($detail['idcard'])?$detail['idcard']:'';?>" placeholder="请输入身份证号码" autocomplete="off">
</div>
</div>
<div class="form-group draggable">
<label class="col-sm-1 control-label"> 所在单位:</label>
<div class="col-sm-3">
<input class="form-control" type="text" name="company" value="<?=isset($detail['company'])?$detail['company']:'';?>" placeholder="请输入单位名称" autocomplete="off">
</div>
</div>
<div class="form-group draggable">
<label class="col-sm-1 control-label">是否显示:
</label>
<div class="col-sm-9">
<label class="radio-inline">
<input type="radio" <?=(isset($detail['status_code'])&&$detail['status_code']==1)?'checked':'';?> value="1" id="status_code1" name="status_code">是</label>
<label class="radio-inline">
<input type="radio" <?=((!isset($detail['status_code']))||isset($detail['status_code'])&&$detail['status_code']==0)?'checked':'';?> value="0" id="status_code2" name="status_code">否</label>
</div>
</div>
<div class="form-group draggable">
<label class="col-sm-1 control-label">是否删除:
</label>
<div class="col-sm-9">
<label class="radio-inline">
<input type="radio" <?=(isset($detail['deleted'])&&$detail['deleted']==1)?'checked':'';?> value="1" id="deleted1" name="deleted">是</label>
<label class="radio-inline">
<input type="radio" <?=((!isset($detail['deleted']))||isset($detail['deleted'])&&$detail['deleted']==0)?'checked':'';?> value="0" id="deleted2" name="deleted">否</label>
</div>
</div>
<div class="hr-line-dashed"></div>
<div class="form-group draggable">
<div class="col-sm-12 col-sm-offset-3">
<button class="btn btn-primary" type="submit">保存</button>
<button class="btn btn-white" type="reset">清空</button>
<a class="btn btn-white" href="<?=Yii::$app->request->referrer?>">取消并返回</a>
<a class="btn btn-info" href="<?=Url::toRoute('contact/list')?>">全部名单</a>
</div>
</div>
</form>
<div class="clearfix"></div>
</div>
</div>
</div>
</div>
</div>
+84
View File
@@ -0,0 +1,84 @@
<?php
/**
* @Author: fm453
* @Date: 2018-11-23 12:17:02
* @Last Modified by: fm453
* @Last Modified time: 2020-12-13 10:24:49
* @Email: fm453@lukegzs.com
*/
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yii\helpers\Url;
use yii\widgets\LinkPager;
$this->title = '通讯簿';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="wrapper wrapper-content">
<div class="row">
<div class="col-sm-12">
<div class="ibox float-e-margins">
<div class="ibox-content">
<h1><?= Html::encode($this->title) ?></h1>
<div class="row">
<div class="col-sm-3">
<a class="btn btn-info btn-sm" href="<?= Url::toRoute('contact/new')?>">新增通讯名单</a>
</div>
<div class="col-sm-5 pull-right">
<form action="<?=Url::current(['pid' => Yii::$app->session->get('pid')], false);?>" method="post">
<input type="hidden" name="_csrf-backend" value="<?= Yii::$app->getRequest()->getCsrfToken();?>" />
<div class="input-group">
<input class="input-sm form-control" type="text" placeholder="姓名或手机号" name="search[title]" value="<?=$search['title']?>">
<span class="input-group-btn">
<button type="submit" class="btn btn-sm btn-primary"> 搜索</button>
</span>
</div>
</form>
</div>
</div>
<hr>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>序号</th>
<th>单位</th>
<th>姓名</th>
<th>手机</th>
<th><a class="btn btn-primary btn-xs" onclick="parent.selectContactor('','','','','<?=$callback?>');">全选</a></th>
</tr>
</thead>
<tbody>
<?php foreach($contactors as $vo):?>
<tr>
<td><?=$vo['id']?></td>
<td><?=$vo['company']?></td>
<td><?=$vo['name']?></td>
<td><?=$vo['mobile']?></td>
<td>
<a class="btn btn-primary btn-xs" onclick="parent.selectContactor('<?=$vo['company']?>','<?=$vo['name']?>','<?=$vo['mobile']?>','<?=$vo['idcard']?>','<?=$vo['id']?>','<?=$callback?>');">选择</a>
</td>
</tr>
<?php endforeach;?>
</tbody>
</table>
<!--分页-->
<div class="f-r">
<?= LinkPager::widget([
'pagination'=>$pager,
'firstPageLabel' => '首页',
'nextPageLabel' => '下一页',
'prevPageLabel' => '上一页',
'lastPageLabel' => '末页',
]) ?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
+93
View File
@@ -0,0 +1,93 @@
<?php
/**
* @Author: fm453
* @Date: 2018-11-23 12:17:02
* @Last Modified by: fm453
* @Last Modified time: 2021-07-23 23:59:37
* @Email: fm453@lukegzs.com
*/
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yii\helpers\Url;
use yii\widgets\LinkPager;
$this->title = '司机列表';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="wrapper wrapper-content">
<div class="row">
<div class="col-sm-12">
<div class="ibox float-e-margins">
<div class="ibox-content">
<h1><?= Html::encode($this->title) ?></h1>
<div class="row">
<div class="col-sm-3">
<a class="btn btn-info btn-sm" href="<?= Url::toRoute('driver/new')?>">新增司机</a>
</div>
<div class="col-sm-3 pull-right">
<form action="<?=Url::current(['pid' => Yii::$app->session->get('pid')], false);?>" method="post">
<input type="hidden" name="_csrf-backend" value="<?= Yii::$app->getRequest()->getCsrfToken();?>" />
<div class="input-group">
<input class="input-sm form-control" type="text" placeholder="请输入司机姓名" name="title" value="<?=$search['title']?>">
<span class="input-group-btn">
<button type="submit" class="btn btn-sm btn-primary"> 搜索</button>
</span>
</div>
</form>
</div>
</div>
<hr>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>序号</th>
<th>姓名</th>
<th>手机</th>
<th>状态</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<?php foreach($drivers as $vo):?>
<tr>
<td><?=$vo['id']?></td>
<td><?=$vo['name']?></td>
<td><?=$vo['mobile']?></td>
<td>
<?php if($vo['status_code']==1){?>
<a class="btn btn-info btn-xs" href="<?=Url::toRoute(['driver/ajax','id'=>$vo['id'],'do'=>'out'])?>" mini="ajax"><?=$status[$vo['status_code']]?></a>
<?php }elseif($vo['status_code']==0){?>
<a class="btn btn-default btn-xs" href="<?=Url::toRoute(['driver/ajax','id'=>$vo['id'],'do'=>'in'])?>" mini="ajax"><?=$status[$vo['status_code']]?></a>
<?php }else{?>
<button class="btn btn-success btn-xs"><?=$status[$vo['status_code']]?></button>
<?php }?>
</td>
<td>
<a class="btn btn-primary btn-xs" href="<?=Url::toRoute(['driver/edit','id'=>$vo['id']])?>"><i class="fa fa-edit"></i>编辑</a>
<a title="点击将删除" href="<?=Url::toRoute(['driver/delete','id'=>$vo['id']])?>" class="btn btn-xs btn-danger" mini="act"><i class="fa fa-trash bigger-120"></i>删除</a>
</td>
</tr>
<?php endforeach;?>
</tbody>
</table>
<!--分页-->
<div class="f-r">
<?= LinkPager::widget([
'pagination'=>$pager,
'firstPageLabel' => '首页',
'nextPageLabel' => '下一页',
'prevPageLabel' => '上一页',
'lastPageLabel' => '末页',
]) ?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
+91
View File
@@ -0,0 +1,91 @@
<?php
use yii\helpers\Html;
use yii\helpers\Url;
?>
<div class="wrapper wrapper-content">
<div class="row">
<div class="col-sm-12">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>司机管理</h5>
<div class="ibox-tools">
<a class="collapse-link">
<i class="fa fa-chevron-up"></i>
</a>
<a class="close-link">
<i class="fa fa-times"></i>
</a>
</div>
</div>
<div class="ibox-content">
<div class="alert alert-info">
此处录入板车司机资料
</div>
<form class="form-horizontal m-t" method="post" action="<?=Url::toRoute('driver/save')?>" role="form">
<input type="hidden" name="_csrf-backend" value="<?=Yii::$app->getRequest()->getCsrfToken();?>" />
<input type="hidden" name="id" value="<?=isset($detail['id'])?$detail['id']:0;?>">
<div class="form-group draggable">
<label class="col-sm-1 control-label"><span class="red">*</span> 姓名:</label>
<div class="col-sm-2">
<input class="form-control" type="text" name="name" value="<?=isset($detail['name'])?$detail['name']:'';?>" placeholder="请输入司机姓名" autocomplete="off">
</div>
<label class="col-sm-1 control-label"><span class="red">*</span> 手机号:</label>
<div class="col-sm-2">
<input class="form-control" type="text" name="mobile" value="<?=isset($detail['mobile'])?$detail['mobile']:'';?>" placeholder="请输入手机号码" autocomplete="off">
</div>
<label class="col-sm-1 control-label"> 身份证号:</label>
<div class="col-sm-3">
<input class="form-control" type="text" name="idcard" value="<?=isset($detail['idcard'])?$detail['idcard']:'';?>" placeholder="请输入身份证号码" autocomplete="off">
</div>
</div>
<div class="form-group draggable">
<label class="col-sm-1 control-label">在职状态:
</label>
<div class="col-sm-5">
<label class="radio-inline">
<input type="radio" <?=(isset($detail['status_code'])&&$detail['status_code']==1)?'checked':'';?> value="1" id="status_code1" name="status_code">是</label>
<label class="radio-inline">
<input type="radio" <?=((!isset($detail['status_code']))||isset($detail['status_code'])&&$detail['status_code']==0)?'checked':'';?> value="0" id="status_code2" name="status_code">否</label>
<label class="radio-inline">
<input type="radio" <?=(isset($detail['status_code'])&&$detail['status_code']==2)?'checked':'';?> value="2" id="status_code2" name="status_code">外援</label>
</div>
<label class="col-sm-1 control-label">排序:</label>
<div class="col-sm-2">
<input class="form-control" type="text" name="order_by" placeholder="" autocomplete="off" value="<?=isset($detail['order_by'])?$detail['order_by']: ''?>">
</div>
</div>
<div class="form-group draggable">
<label class="col-sm-1 control-label">是否删除:
</label>
<div class="col-sm-9">
<label class="radio-inline">
<input type="radio" <?=(isset($detail['deleted'])&&$detail['deleted']==1)?'checked':'';?> value="1" id="deleted1" name="deleted">是</label>
<label class="radio-inline">
<input type="radio" <?=((!isset($detail['deleted']))||isset($detail['deleted'])&&$detail['deleted']==0)?'checked':'';?> value="0" id="deleted2" name="deleted">否</label>
</div>
</div>
<div class="hr-line-dashed"></div>
<div class="form-group draggable">
<div class="col-sm-12 col-sm-offset-3">
<button class="btn btn-primary" type="submit">保存</button>
<button class="btn btn-white" type="reset">清空</button>
<a class="btn btn-white" href="<?=Yii::$app->request->referrer?>">取消并返回</a>
<a class="btn btn-info" href="<?=Url::toRoute('driver/list')?>">全部司机</a>
</div>
</div>
</form>
<div class="clearfix"></div>
</div>
</div>
</div>
</div>
</div>
+92
View File
@@ -0,0 +1,92 @@
<?php
/**
* @Author: fm453
* @Date: 2018-11-23 12:17:02
* @Last Modified by: fm453
* @Last Modified time: 2020-09-12 22:36:33
* @Email: fm453@lukegzs.com
*/
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yii\helpers\Url;
use yii\widgets\LinkPager;
$this->title = '司机列表';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="wrapper wrapper-content">
<div class="row">
<div class="col-sm-12">
<div class="ibox float-e-margins">
<div class="ibox-content">
<h1><?= Html::encode($this->title) ?></h1>
<div class="row">
<div class="col-sm-3">
<a class="btn btn-info btn-sm" href="<?= Url::toRoute('driver/new')?>">新增司机</a>
</div>
<div class="col-sm-3 pull-right">
<form action="<?=Url::current(['pid' => Yii::$app->session->get('pid')], false);?>" method="post">
<input type="hidden" name="_csrf-backend" value="<?= Yii::$app->getRequest()->getCsrfToken();?>" />
<div class="input-group">
<input class="input-sm form-control" type="text" placeholder="请输入司机姓名" name="title" value="<?=$search['title']?>">
<span class="input-group-btn">
<button type="submit" class="btn btn-sm btn-primary"> 搜索</button>
</span>
</div>
</form>
</div>
</div>
<hr>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>序号</th>
<th>姓名</th>
<th>手机</th>
<th>状态</th>
<th><a class="btn btn-primary btn-xs" onclick="parent.selectDriver('已清空','','<?=$callback?>');">全选</a></th>
</tr>
</thead>
<tbody>
<?php foreach($drivers as $vo):?>
<tr>
<td><?=$vo['id']?></td>
<td><?=$vo['name']?></td>
<td><?=$vo['mobile']?></td>
<td>
<?php if($vo['status_code']==1){?>
<label class="btn btn-info btn-xs"><?=$status[$vo['status_code']]?></label>
<?php }elseif($vo['status_code']==0){?>
<a class="btn btn-default btn-xs" href="<?=Url::toRoute(['driver/ajax','id'=>$vo['id'],'do'=>'in'])?>" mini="ajax"><?=$status[$vo['status_code']]?></a>
<?php }else{?>
<button class="btn btn-success btn-xs"><?=$status[$vo['status_code']]?></button>
<?php }?>
</td>
<td>
<a class="btn btn-primary btn-xs" onclick="parent.selectDriver('<?=$vo['name']?>','<?=$vo['id']?>','<?=$callback?>');">选择</a>
</td>
</tr>
<?php endforeach;?>
</tbody>
</table>
<!--分页-->
<div class="f-r">
<?= LinkPager::widget([
'pagination'=>$pager,
'firstPageLabel' => '首页',
'nextPageLabel' => '下一页',
'prevPageLabel' => '上一页',
'lastPageLabel' => '末页',
]) ?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
+96
View File
@@ -0,0 +1,96 @@
<?php
/**
* @Author: fm453
* @Date: 2018-11-23 12:17:02
* @Last Modified by: fm453
* @Last Modified time: 2020-09-12 22:36:43
* @Email: fm453@lukegzs.com
*/
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yii\helpers\Url;
use yii\widgets\LinkPager;
$this->title = '员工列表';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="wrapper wrapper-content">
<div class="row">
<div class="col-sm-12">
<div class="ibox float-e-margins">
<div class="ibox-content">
<h1><?= Html::encode($this->title) ?></h1>
<div class="row">
<div class="col-sm-3">
<a class="btn btn-info btn-sm" href="<?= Url::toRoute('employee/new')?>">新增员工</a>
</div>
<div class="col-sm-3 pull-right">
<form action="<?=Url::current(['pid' => Yii::$app->session->get('pid')], false);?>" method="post">
<input type="hidden" name="_csrf-backend" value="<?= Yii::$app->getRequest()->getCsrfToken();?>" />
<div class="input-group">
<input class="input-sm form-control" type="text" placeholder="请输入员工姓名" name="title" value="<?=$search['title']?>">
<span class="input-group-btn">
<button type="submit" class="btn btn-sm btn-primary"> 搜索</button>
</span>
</div>
</form>
</div>
</div>
<hr>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>序号</th>
<th>网点门店</th>
<th>姓名</th>
<th>手机</th>
<th>性别</th>
<th>状态</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<?php foreach($employees as $vo):?>
<tr>
<td><?=$vo['id']?></td>
<td>【<code><?=isset($stores[$vo['store_id']]['title'])?$stores[$vo['store_id']]['title']:'未设置'?></code>】</td>
<td><?=$vo['name']?></td>
<td><?=$vo['mobile']?></td>
<td><?=$gender[$vo['gender']]?></td>
<td>
<?php if($vo['status']==1){?>
<a class="btn btn-info btn-xs" href="<?=Url::toRoute(['employee/ajax','id'=>$vo['id'],'do'=>'out'])?>" mini="ajax"><?=$status[$vo['status']]?></a>
<?php }else{?>
<a class="btn btn-default btn-xs" href="<?=Url::toRoute(['employee/ajax','id'=>$vo['id'],'do'=>'in'])?>" mini="ajax"><?=$status[$vo['status']]?></a>
<?php }?>
</td>
<td>
<a class="btn btn-primary btn-xs" href="<?=Url::toRoute(['employee/edit','id'=>$vo['id']])?>"><i class="fa fa-edit"></i>编辑</a>
<a class="btn btn-info btn-xs" href="<?=Url::toRoute(['order/list','employee_id'=>$vo['id']])?>"> 经手运单</a>
<a title="点击将删除" href="<?=Url::toRoute(['employee/delete','id'=>$vo['id']])?>" class="btn btn-xs btn-danger" mini="act"><i class="fa fa-trash bigger-120"></i>删除</a>
</td>
</tr>
<?php endforeach;?>
</tbody>
</table>
<!--分页-->
<div class="f-r">
<?= LinkPager::widget([
'pagination'=>$pager,
'firstPageLabel' => '首页',
'nextPageLabel' => '下一页',
'prevPageLabel' => '上一页',
'lastPageLabel' => '末页',
]) ?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
+176
View File
@@ -0,0 +1,176 @@
<?php
use yii\helpers\Html;
use yii\helpers\Url;
?>
<!--百度编辑器-->
<?=Html::jsFile('@web/plugins/ueditor/ueditor.config.js')?>
<!--建议手动加在语言,避免在ie下有时因为加载语言失败导致编辑器加载失败-->
<!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型,比如你在配置项目里配置的是英文,这里加载的中文,那最后就是中文-->
<?=Html::jsFile('@web/plugins/ueditor/ueditor.all.min.js')?>
<?=Html::jsFile('@web/plugins/ueditor/lang/zh-cn/zh-cn.js')?>
<div class="wrapper wrapper-content">
<div class="row">
<div class="col-sm-12">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>员工管理</h5>
<div class="ibox-tools">
<a class="collapse-link">
<i class="fa fa-chevron-up"></i>
</a>
<a class="close-link">
<i class="fa fa-times"></i>
</a>
</div>
</div>
<div class="ibox-content">
<div class="alert alert-info">
此处录入各网点/门店/办事处/分公司的员工资料
</div>
<form class="form-horizontal m-t" method="post" action="<?=Url::toRoute('employee/save')?>" role="form">
<input type="hidden" name="_csrf-backend" value="<?=Yii::$app->getRequest()->getCsrfToken();?>" />
<input type="hidden" name="id" value="<?=isset($detail['id'])?$detail['id']:0;?>">
<div class="form-group draggable">
<label class="col-sm-1 control-label"><span class="red">*</span> 姓名:</label>
<div class="col-sm-2">
<input class="form-control" type="text" name="name" value="<?=isset($detail['name'])?$detail['name']:'';?>" placeholder="请输入员工姓名" autocomplete="off">
</div>
<label class="col-sm-1 control-label"><span class="red">*</span> 手机号:</label>
<div class="col-sm-2">
<input class="form-control" type="text" name="mobile" value="<?=isset($detail['mobile'])?$detail['mobile']:'';?>" placeholder="请输入手机号码" autocomplete="off">
</div>
<label class="col-sm-1 control-label"><span class="red">*</span> 性别:</label>
<div class="col-sm-2">
<select class="form-control" name="gender">
<option value="0" <?php if(isset($detail['gender']) && $detail['gender']==0){echo 'selected';}else{echo '';}?>>未知</option>
<option value="1" <?php if(isset($detail['gender']) && $detail['gender']==1){echo 'selected';}else{echo '';}?>>男</option>
<option value="2" <?php if(isset($detail['gender']) && $detail['gender']==2){echo 'selected';}else{echo '';}?>>女</option>
</select>
</div>
</div>
<div class="form-group draggable">
<label class="col-sm-1 control-label"><span class="red">*</span> 对应网点:</label>
<div class="col-sm-9">
<input type="text" class="form-control" name="store_title" id="store-title" value="<?=isset($detail['store_title'])?$detail['store_title']:'';?>" placeholder="点击选择所在网点" autocomplete="off" href="<?=Url::toRoute(['store/select','callback'=>'store']);?>" w="80%;" h="90%;" title="选择所在网点" mini="load">
<input type="hidden" class="form-control" name="store" id="store-value" value="<?=isset($detail['store_id'])?$detail['store_id']:0;?>">
</div>
<script>
function selectStore(title,id,callback)
{
layer.closeAll();
layer.msg('已选择');
$('#'+callback+'-value').val(id);
$('#'+callback+'-title').val(title);
}
</script>
</div>
<div class="form-group draggable">
<label class="col-sm-1 control-label">备注:</label>
<div class="col-sm-9">
<textarea id="editor" name="editor" style="min-height:300px;"><?=isset($detail['remark'])?$detail['remark']:''?></textarea>
<script type="text/javascript">
//实例化编辑器
//建议使用工厂方法getEditor创建和引用编辑器实例,如果在某个闭包下引用该编辑器,直接调用UE.getEditor('editor')就能拿到相关的实例
var ue = UE.getEditor('editor');
/* 传入参数表,添加到已有参数表里 */
ue.ready(function() {
ue.execCommand('serverparam', {
'siteId': "<?=Yii::$app->params['siteId']?>",
'pid': "<?=Yii::$app->session->get('pid')?>",
'attachSrc': "<?=Yii::$app->params['attachSrc']?>",
'attachDir': "<?=Yii::$app->params['attachDir']?>"
});
});
</script>
</div>
</div>
<div class="form-group draggable">
<label class="col-sm-1 control-label">排序:</label>
<div class="col-sm-2">
<input class="form-control" type="text" name="order_by" placeholder="" autocomplete="off" value="<?=isset($detail['order_by'])?$detail['order_by']: ''?>">
</div>
</div>
<div class="form-group draggable">
<label class="col-sm-1 control-label">是否在职:
</label>
<div class="col-sm-9">
<label class="radio-inline">
<input type="radio" <?=(isset($detail['status'])&&$detail['status']==1)?'checked':'';?> value="1" id="status1" name="status">是</label>
<label class="radio-inline">
<input type="radio" <?=((!isset($detail['status']))||isset($detail['status'])&&$detail['status']==0)?'checked':'';?> value="0" id="status2" name="status">否</label>
</div>
</div>
<div class="form-group draggable">
<label class="col-sm-1 control-label">是否删除:
</label>
<div class="col-sm-9">
<label class="radio-inline">
<input type="radio" <?=(isset($detail['deleted'])&&$detail['deleted']==1)?'checked':'';?> value="1" id="deleted1" name="deleted">是</label>
<label class="radio-inline">
<input type="radio" <?=((!isset($detail['deleted']))||isset($detail['deleted'])&&$detail['deleted']==0)?'checked':'';?> value="0" id="deleted2" name="deleted">否</label>
</div>
</div>
<div class="hr-line-dashed"></div>
<div class="form-group draggable">
<div class="col-sm-12 col-sm-offset-3">
<button class="btn btn-primary" type="submit">保存</button>
<button class="btn btn-white" type="reset">清空</button>
<a class="btn btn-white" href="<?=Yii::$app->request->referrer?>">取消并返回</a>
<a class="btn btn-info" href="<?=Url::toRoute('employee/list')?>">全部员工</a>
</div>
</div>
</form>
<div class="clearfix"></div>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
function showImageFrame(obj){
//取预设参数
var id,title,width,height,url;
id = $(obj).attr('data-id');
title = $(obj).attr('data-title');
width = $(obj).attr('data-width');
height = $(obj).attr('data-height');
url = $(obj).attr('data-src');
//iframe层
parent.layer.open({
type: 2,
title: title,
shadeClose: true,
shade: 0.8,
area: [width, height],
content: url //iframe的url
});
}
function deleteImage(elm){
$(elm).prev().attr("src", "../img/nopic.jpg");
$(elm).parent().prev().find("input").val("");
parent.layer.msg('图片已删除;您可重新上传');
}
function selectImage(title,path,src,callback)
{
layer.closeAll();
layer.msg('图片已选择');
$('#'+callback+'-value').val(path);
$('#'+callback+'-preview').attr('src',src);
}
</script>
+94
View File
@@ -0,0 +1,94 @@
<?php
/**
* @Author: fm453
* @Date: 2018-11-23 12:17:02
* @Last Modified by: fm453
* @Last Modified time: 2020-09-12 22:36:48
* @Email: fm453@lukegzs.com
*/
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yii\helpers\Url;
use yii\widgets\LinkPager;
$this->title = '员工列表';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="wrapper wrapper-content">
<div class="row">
<div class="col-sm-12">
<div class="ibox float-e-margins">
<div class="ibox-content">
<h1><?= Html::encode($this->title) ?></h1>
<div class="row">
<div class="col-sm-3">
<a class="btn btn-info btn-sm" href="<?= Url::toRoute('employee/new')?>">新增员工</a>
</div>
<div class="col-sm-3 pull-right">
<form action="<?=Url::current(['pid' => Yii::$app->session->get('pid')], false);?>" method="post">
<input type="hidden" name="_csrf-backend" value="<?= Yii::$app->getRequest()->getCsrfToken();?>" />
<div class="input-group">
<input class="input-sm form-control" type="text" placeholder="请输入员工姓名" name="title" value="<?=$search['title']?>">
<span class="input-group-btn">
<button type="submit" class="btn btn-sm btn-primary"> 搜索</button>
</span>
</div>
</form>
</div>
</div>
<hr>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>序号</th>
<th>网点门店</th>
<th>姓名</th>
<th>手机</th>
<th>性别</th>
<th>状态</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<?php foreach($employees as $vo):?>
<tr>
<td><?=$vo['id']?></td>
<td>【<code><?=isset($stores[$vo['store_id']]['title'])?$stores[$vo['store_id']]['title']:'未设置'?></code>】</td>
<td><?=$vo['name']?></td>
<td><?=$vo['mobile']?></td>
<td><?=$gender[$vo['gender']]?></td>
<td>
<?php if($vo['status']==1){?>
<label class="btn btn-info btn-xs"><?=$status[$vo['status']]?></label>
<?php }else{?>
<label class="btn btn-default btn-xs"><?=$status[$vo['status']]?></label>
<?php }?>
</td>
<td>
<a class="btn btn-primary btn-xs" onclick="parent.selectEmployee('<?=$vo['name']?>','<?=$vo['id']?>','<?=$callback?>');">选择</a>
</td>
</tr>
<?php endforeach;?>
</tbody>
</table>
<!--分页-->
<div class="f-r">
<?= LinkPager::widget([
'pagination'=>$pager,
'firstPageLabel' => '首页',
'nextPageLabel' => '下一页',
'prevPageLabel' => '上一页',
'lastPageLabel' => '末页',
]) ?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
+90
View File
@@ -0,0 +1,90 @@
<?php
# @Author: 嗨噜客科技(www.hiluker.cn) <fm453>
# @Date: 1970-01-01T08:00:00+08:00
# @Email: fm453@hiluker.com
# @Last modified by: fm453
# @Last modified time: 2021-09-15T17:48:03+08:00
use yii\helpers\Html;
use yii\helpers\Url;
$this->title = isset($title) ? $title : '提示';
?>
<div class="site-error">
<div style="text-align: center;">
<h1>温馨提示</h1><br>
</div>
<h4 style="margin: 10px auto;text-align: center;background-color: #1ab394; color: #ffffff;width: 90%;line-height: 50px;border-radius: 5px;"><i class="fa fa-spinner fa-spin"></i> 系统已记录您的操作请求,敬请稍候。为了便于工程师进行检查,烦请您对您发现的情况尽可能准确地说明告知,感谢您的反馈……</h4>
<form role="form" class="form-horizontal m-t" action="" method="post">
<input name="_csrf" type="hidden" id="_csrf" value="<?= Yii::$app->request->csrfToken ?>">
<input name="code" type="hidden" id="code" value="<?= isset($code) ? $code : 0 ?>">
<div class="form-group draggable">
<label class="col-sm-2 control-label"><i class="fa fa-spin" style="color:#f00;">*</i>出错页面:</label>
<div class="col-sm-9">
<input class="form-control" type="text" name="url" placeholder="当前报错页面的网址" autocomplete="off" value="<?= Html::encode($url) ?>">
<span class="help-block m-b-none">页面网址由系统自动获取,您也可以直接填入修改</span>
</div>
</div>
<div class="form-group draggable">
<label class="col-sm-2 control-label">错误描述:</label>
<div class="col-sm-9">
<textarea class="form-control" type="text" name="desc" placeholder="请描述一下您遇到的问题,比如在什么情况下出现的,出错时您正在操作页面的什么东西,等" autocomplete="off"><?php if(isset($data['desc'])){?><?= Html::encode($data['desc']) ?><?php }?></textarea>
<span class="help-block m-b-none">您描述的越详细、清楚,越有利于工程师排查问题</span>
</div>
</div>
<div class="form-group draggable">
<label class="col-sm-2 control-label">您的称谓:</label>
<div class="col-sm-9">
<input class="form-control" type="text" name="name" placeholder="怎么称呼您呢?" value="<?php if(isset($data['name'])){?><?= Html::encode($data['name']) ?><?php }?>">
</div>
</div>
<div class="form-group draggable">
<label class="col-sm-2 control-label">联系方式:</label>
<div class="col-sm-9">
<input class="form-control" type="text" name="mobile" placeholder="请输入您的手机号,以便工程师与您联系咨询" value="<?php if(isset($data['mobile'])){?><?= Html::encode($data['mobile']) ?><?php }?>">
</div>
</div>
<div class="form-group draggable">
<label class="col-sm-2 control-label">QQ:</label>
<div class="col-sm-9">
<input class="form-control" type="text" name="QQ" placeholder="请输入您的QQ号,以便工程师与您联系咨询" value="<?php if(isset($data['QQ'])){?><?= Html::encode($data['QQ']) ?><?php }?>">
</div>
</div>
<div class="form-group draggable">
<label class="col-sm-2 control-label">微信:</label>
<div class="col-sm-9">
<input class="form-control" type="text" name="wechat" placeholder="请输入您的微信号,以便工程师与您联系咨询" value="<?php if(isset($data['wechat'])){?><?= Html::encode($data['wechat']) ?><?php }?>">
</div>
</div>
<div class="form-group draggable">
<label class="col-sm-2 control-label">反馈时间:</label>
<div class="col-sm-9">
<p class="form-control-static"><?php if(isset($data['time'])){?><?= Html::encode($data['time']) ?><?php }else{echo date('Y-m-d h:i');}?></p>
</div>
</div>
<div class="form-group draggable">
<label class="col-sm-2 control-label">接收通知:</label>
<div class="col-sm-9">
<label class="radio-inline">
<input type="radio" value="1" <?php if(isset($data['is_notice']) && $data['is_notice']==1){?> checked="true" <?php }?> id="optionsRadios1" name="is_notice">问题解决后,请联系我</label>
<label class="radio-inline">
<input type="radio" <?php if(isset($data['is_notice']) && $data['is_notice']==0){?> checked="true" <?php }?> value="0" id="optionsRadios2" name="is_notice">我不需要接收该报错的解决结果通知</label>
</div>
</div>
<div class="hr-line-dashed"></div>
<div class="form-group draggable">
<div class="col-sm-12 col-sm-offset-3">
<button class="btn btn-primary" type="submit">反馈</button>
<button class="btn btn-white" type="button">取消</button>
</div>
</div>
</form>
<div class="alert alert-info alert-dismissible fade in" role="alert">
<button type="button" class="close" data-dismiss="alert">×</button>
<h4>您还可以扫描工程师客服微信直接反馈(遇忙时,工程师可能无法快速响应,请耐心等待);申请添加好友时请备注“运车系统反馈”
</h4>
<div style="text-align: center;"><img class="img-round" src="<?=Yii::getAlias('@web')?>/img/fm-qrcode.jpg" width="230px" height="230px"></div>
</div>
</div>
</div>

Some files were not shown because too many files have changed in this diff Show More