parent
80d6ccb647
commit
a08c0ff170
@ -1,591 +0,0 @@ |
||||
<?php |
||||
|
||||
namespace frontend\controllers; |
||||
|
||||
use common\libs\MyLib; |
||||
use common\models\CarGiftT; |
||||
use common\models\EmsT; |
||||
use common\models\Gift2T; |
||||
use common\models\GiftGroupT; |
||||
use common\models\GiftT; |
||||
use common\models\GiftTicket2T; |
||||
use common\models\GiftTicketT; |
||||
use common\models\GiftType2T; |
||||
use common\models\GiftTypeT; |
||||
use common\models\GroupT; |
||||
use common\models\InsurerTypeT; |
||||
use common\models\OrderT; |
||||
use common\models\StrategyT; |
||||
use common\models\UserT; |
||||
use Yii; |
||||
use yii\data\Pagination; |
||||
use yii\web\Response; |
||||
|
||||
class Gift2Controller extends \yii\web\Controller |
||||
{ |
||||
public $my = null; |
||||
|
||||
public function init() |
||||
{ |
||||
parent::init(); |
||||
|
||||
$cookie = Yii::$app->request->cookies; |
||||
$user_id = MyLib::encrypt($cookie->get('aid'),'DECODE'); |
||||
|
||||
if($user_id != 0) |
||||
{ |
||||
$this->my = UserT::findOne(['id'=>$user_id]); |
||||
} else { |
||||
Yii::$app->response->redirect('/common/login')->send(); |
||||
exit; |
||||
} |
||||
} |
||||
|
||||
public function actionGift1Index() |
||||
{ |
||||
$request = Yii::$app->request; |
||||
$code = $request->get('code'); |
||||
$car_no = $request->get('car_no'); |
||||
$status = $request->get('status',6); |
||||
$type_id = $request->get('type_id',0); |
||||
$page = $request->get('page',1); |
||||
if($page < 1) $page = 1; |
||||
|
||||
$query = GiftTicketT::find() |
||||
->orderBy('id DESC'); |
||||
if($code != '') { |
||||
$query = $query->andWhere('code="'.$code.'"'); |
||||
} |
||||
if($car_no != '') { |
||||
$query = $query->andWhere('car_no like "'.$car_no.'"'); |
||||
} |
||||
if($status != '' && $status != 6) { |
||||
$query = $query->andWhere('status='.$status); |
||||
} |
||||
if($type_id > 0) { |
||||
$query = $query->andWhere('type_id='.$type_id); |
||||
} |
||||
// echo $query->createCommand()->rawSql; |
||||
$total = $query->count(); |
||||
|
||||
$pagination = new Pagination(['totalCount' => $total,'pageSize'=>20]); |
||||
$pagination->setPage($page-1); |
||||
|
||||
$query = $query->offset($pagination->offset)->limit($pagination->limit); |
||||
$items = $query->all(); |
||||
|
||||
$type_items = GiftType2T::find()->all(); |
||||
$page_info = MyLib::getPageInfo($pagination); |
||||
|
||||
return $this->render('gift1-index',[ |
||||
'items' => $items, |
||||
'code' => $code, |
||||
'car_no' => $car_no, |
||||
'page' => $page, |
||||
'page_info' => $page_info, |
||||
'status' => $status, |
||||
'type_items' => $type_items, |
||||
'type_id' => $type_id, |
||||
]); |
||||
} |
||||
|
||||
public function actionGift2Index() |
||||
{ |
||||
return $this->render('gift2-index'); |
||||
} |
||||
|
||||
public function actionIndex() |
||||
{ |
||||
$request = Yii::$app->request; |
||||
$code = $request->get('code'); |
||||
$car_no = $request->get('car_no'); |
||||
$page = $request->get('page',1); |
||||
if($page < 1) $page = 1; |
||||
|
||||
$query = GiftTicketT::find() |
||||
->orderBy('id DESC'); |
||||
if($code != '') { |
||||
$query = $query->andWhere('code="'.$code.'"'); |
||||
} |
||||
if($car_no != '') { |
||||
$query = $query->andWhere('car_no="'.$car_no.'"'); |
||||
} |
||||
// echo $query->createCommand()->rawSql; |
||||
$total = $query->count(); |
||||
|
||||
$pagination = new Pagination(['totalCount' => $total,'pageSize'=>20]); |
||||
$pagination->setPage($page-1); |
||||
|
||||
$query = $query->offset($pagination->offset)->limit($pagination->limit); |
||||
$items = $query->all(); |
||||
|
||||
$page_info = MyLib::getPageInfo($pagination); |
||||
|
||||
return $this->render('index',[ |
||||
'items' => $items, |
||||
'code' => $code, |
||||
'car_no' => $car_no, |
||||
'page' => $page, |
||||
'page_info' => $page_info |
||||
]); |
||||
} |
||||
|
||||
public function actionAdd() |
||||
{ |
||||
$request = Yii::$app->request; |
||||
$type_items = GiftType2T::find()->all(); |
||||
|
||||
return $this->render('add',[ |
||||
'type_items' => $type_items, |
||||
]); |
||||
} |
||||
|
||||
public function actionAddSave() |
||||
{ |
||||
Yii::$app->response->format = Response::FORMAT_JSON; |
||||
$request = Yii::$app->request; |
||||
$result = array(); |
||||
$result['success'] = false; |
||||
$result['msg'] = '保存失败'; |
||||
|
||||
if($request->isPost) { |
||||
$min_code = $request->post('min_code'); |
||||
$max_code = $request->post('max_code'); |
||||
$type_id = $request->post('type_id'); |
||||
|
||||
if($min_code == '') { |
||||
$result['msg'] = '请输入开始编号!'; |
||||
return $result; |
||||
} |
||||
if($max_code == '') { |
||||
$result['msg'] = '请输入结束编号!'; |
||||
return $result; |
||||
} |
||||
if($type_id == 0) { |
||||
$result['msg'] = '请选择类型!'; |
||||
return $result; |
||||
} |
||||
|
||||
$row = null; |
||||
for($i = $min_code; $i <= $max_code; $i++) { |
||||
$row = GiftTicketT::findOne(['code'=>$i,'type_id'=>$type_id]); |
||||
if(!$row) { |
||||
$row = new GiftTicketT(); |
||||
$row->code = $i; |
||||
$row->type_id = $type_id; |
||||
$row->input_date = date('Y-m-d H:i:s'); |
||||
$row->op_id = $this->my->id; |
||||
$row->status = 0; |
||||
$row->save(); |
||||
} |
||||
} |
||||
|
||||
$result['success'] = true; |
||||
$result['msg'] = '保存成功'; |
||||
} |
||||
return $result; |
||||
} |
||||
|
||||
public function actionOutput() |
||||
{ |
||||
$request = Yii::$app->request; |
||||
$type_items = GiftType2T::find()->all(); |
||||
|
||||
$gift_group_items = GiftGroupT::find()->all(); |
||||
|
||||
return $this->render('output',[ |
||||
'type_items' => $type_items, |
||||
'gift_group_items' => $gift_group_items, |
||||
]); |
||||
} |
||||
|
||||
public function actionOutputSave() |
||||
{ |
||||
Yii::$app->response->format = Response::FORMAT_JSON; |
||||
$request = Yii::$app->request; |
||||
$result = array(); |
||||
$result['success'] = false; |
||||
$result['msg'] = '保存失败'; |
||||
|
||||
if($request->isPost) { |
||||
$codes = $request->post('codes',array()); |
||||
$types = $request->post('types',array()); |
||||
$car_no = $request->post('car_no'); |
||||
|
||||
$tran = GiftTicketT::getDb()->beginTransaction(); |
||||
try { |
||||
foreach($types as $index => $type_id) { |
||||
if($type_id == 0) continue; |
||||
$ticket_info = GiftTicketT::findOne(['code'=>$codes[$index],'type_id'=>$type_id]); |
||||
if(!$ticket_info) { |
||||
$result['msg'] = '第'.($index+1).'组礼品编号不存在!'; |
||||
return $result; |
||||
} |
||||
if($ticket_info->status != 0) { |
||||
$result['msg'] = '第'.($index+1).'组礼品编号已经出库!'; |
||||
return $result; |
||||
} |
||||
$ticket_info->group_id = 0; |
||||
$ticket_info->car_no = $car_no; |
||||
$ticket_info->status = 1; |
||||
$ticket_info->use_date = date('Y-m-d H:i:s'); |
||||
$ticket_info->op_id = $this->my->id; |
||||
if(!$ticket_info->save()) { |
||||
var_dump($ticket_info->errors); |
||||
} |
||||
} |
||||
|
||||
$tran->commit(); |
||||
} catch(\Exception $e) { |
||||
$tran->rollBack(); |
||||
throw $e; |
||||
} |
||||
|
||||
$result['success'] = true; |
||||
$result['msg'] = '保存成功'; |
||||
} |
||||
return $result; |
||||
} |
||||
|
||||
public function actionEdit() |
||||
{ |
||||
$request = Yii::$app->request; |
||||
$id = $request->get('id',0); |
||||
$back_params = $request->get('back_params'); |
||||
if($id > 0) { |
||||
$info = GiftTicketT::findOne(['id'=>$id]); |
||||
} else { |
||||
$info = new GiftTicketT(); |
||||
} |
||||
|
||||
$type_items = GiftTypeT::find()->all(); |
||||
|
||||
return $this->render('edit',[ |
||||
'info' => $info, |
||||
'type_items' => $type_items, |
||||
'back_params' => $back_params, |
||||
]); |
||||
} |
||||
|
||||
public function actionSave() |
||||
{ |
||||
Yii::$app->response->format = Response::FORMAT_JSON; |
||||
$request = Yii::$app->request; |
||||
$result = array(); |
||||
$result['success'] = false; |
||||
$result['msg'] = '保存失败'; |
||||
|
||||
if($request->isPost) { |
||||
$id = $request->post('id'); |
||||
$status = $request->post('status'); |
||||
$car_no = $request->post('car_no'); |
||||
|
||||
$ticket_info = GiftTicketT::findOne(['id'=>$id]); |
||||
if(!$ticket_info) { |
||||
$result['msg'] = '礼品券不存在!'; |
||||
return $result; |
||||
} |
||||
|
||||
$ticket_info->car_no = $car_no; |
||||
$ticket_info->status = $status; |
||||
$ticket_info->use_date = date('Y-m-d H:i:s'); |
||||
$ticket_info->op_id = $this->my->id; |
||||
$ticket_info->save(); |
||||
|
||||
$result['success'] = true; |
||||
$result['msg'] = '保存成功'; |
||||
} |
||||
return $result; |
||||
} |
||||
|
||||
public function actionDelete() |
||||
{ |
||||
Yii::$app->response->format = Response::FORMAT_JSON; |
||||
$request = Yii::$app->request; |
||||
$result = array(); |
||||
$result['success'] = false; |
||||
$result['msg'] = '删除失败'; |
||||
|
||||
if($request->isPost) { |
||||
$id = $request->post('id',0); |
||||
|
||||
if($id > 0) { |
||||
$row = GiftTicketT::findOne(['id'=>$id]); |
||||
if($row->status == 0) { |
||||
$row->delete(); |
||||
|
||||
$result['success'] = true; |
||||
$result['msg'] = '删除成功'; |
||||
} |
||||
|
||||
} |
||||
} |
||||
return $result; |
||||
} |
||||
|
||||
public function actionTicket2List() |
||||
{ |
||||
$request = Yii::$app->request; |
||||
$code = $request->get('code'); |
||||
$car_no = $request->get('car_no'); |
||||
$type_id = $request->get('type_id',0); |
||||
$page = $request->get('page',1); |
||||
if($page < 1) $page = 1; |
||||
|
||||
$query = GiftTicketT::find() |
||||
->where('status=1') |
||||
->orderBy('id DESC'); |
||||
if($code != '') { |
||||
$query = $query->andWhere('code="'.$code.'"'); |
||||
} |
||||
if($car_no != '') { |
||||
$query = $query->andWhere('car_no like "'.$car_no.'"'); |
||||
} |
||||
if($type_id > 0) { |
||||
$query = $query->andWhere('type_id='.$type_id); |
||||
} |
||||
// echo $query->createCommand()->rawSql; |
||||
$total = $query->count(); |
||||
|
||||
$pagination = new Pagination(['totalCount' => $total,'pageSize'=>20]); |
||||
$pagination->setPage($page-1); |
||||
|
||||
$query = $query->offset($pagination->offset)->limit($pagination->limit); |
||||
$items = $query->all(); |
||||
|
||||
$type_items = GiftType2T::find()->all(); |
||||
$page_info = MyLib::getPageInfo($pagination); |
||||
|
||||
return $this->render('ticket2-list',[ |
||||
'items' => $items, |
||||
'code' => $code, |
||||
'car_no' => $car_no, |
||||
'page' => $page, |
||||
'page_info' => $page_info, |
||||
'type_items' => $type_items, |
||||
'type_id' => $type_id, |
||||
]); |
||||
} |
||||
|
||||
public function actionTicket2Output() |
||||
{ |
||||
$request = Yii::$app->request; |
||||
$id = $request->get('id',0); |
||||
if($id == 0) { |
||||
echo '无效礼券'; |
||||
exit; |
||||
} |
||||
$ticket_info = GiftTicketT::findOne(['id'=>$id]); |
||||
|
||||
$gift_items = Gift2T::find()->all(); |
||||
$type_items = GiftType2T::find()->all(); |
||||
|
||||
return $this->render('ticket2-output',[ |
||||
'ticket_info' => $ticket_info, |
||||
'gift_items' => $gift_items, |
||||
'type_items' => $type_items |
||||
]); |
||||
} |
||||
|
||||
public function actionTicket2OutputSave() |
||||
{ |
||||
Yii::$app->response->format = Response::FORMAT_JSON; |
||||
$request = Yii::$app->request; |
||||
$result = array(); |
||||
$result['success'] = false; |
||||
$result['msg'] = '保存失败'; |
||||
|
||||
if($request->isPost) { |
||||
$ticket_id = $request->post('ticket_id'); |
||||
$gift_id = (int)$request->post('gift_id'); |
||||
$send_type = $request->post('send_type'); |
||||
$send_no = $request->post('send_no'); |
||||
|
||||
$ticket_info = GiftTicketT::findOne(['id'=>$ticket_id]); |
||||
if(!$ticket_info) { |
||||
$result['msg'] = '礼品编号不存在!'; |
||||
return $result; |
||||
} |
||||
|
||||
if($gift_id == 0) { |
||||
$result['msg'] = '请选择礼品!'; |
||||
return $result; |
||||
} |
||||
|
||||
$ticket2_info = new GiftTicket2T(); |
||||
$ticket2_info->ticket_id = $ticket_info->id; |
||||
$ticket2_info->gift_id = $gift_id; |
||||
$ticket2_info->send_type = $send_type; |
||||
$ticket2_info->send_no = $send_no; |
||||
|
||||
$ticket2_info->status = 1; |
||||
$ticket2_info->op_id = $this->my->id; |
||||
$ticket2_info->use_date = date('Y-m-d H:i:s'); |
||||
|
||||
$ticket2_info->save(); |
||||
|
||||
$ticket_info->status = 2; |
||||
$ticket_info->use_date; |
||||
$ticket_info->op_id = $this->my->id; |
||||
$ticket_info->save(); |
||||
|
||||
//礼品 |
||||
$gift_info = Gift2T::findOne(['id'=>$gift_id]); |
||||
$gift_info->total = $gift_info->total - 1; |
||||
$gift_info->save(); |
||||
|
||||
$result['success'] = true; |
||||
$result['msg'] = '保存成功'; |
||||
} |
||||
return $result; |
||||
} |
||||
|
||||
public function actionTicket2Edit() |
||||
{ |
||||
$request = Yii::$app->request; |
||||
$id = $request->get('id',0); |
||||
if($id > 0) { |
||||
$info = GiftTicket2T::findOne(['id'=>$id]); |
||||
} else { |
||||
$info = new GiftTicket2T(); |
||||
} |
||||
|
||||
$gift_items = GiftT::find()->all(); |
||||
$type_items = GiftTypeT::find()->all(); |
||||
|
||||
return $this->render('ticket2-edit',[ |
||||
'info' => $info, |
||||
'gift_items' => $gift_items, |
||||
'type_items' => $type_items |
||||
]); |
||||
} |
||||
|
||||
public function actionTicket2Save() |
||||
{ |
||||
Yii::$app->response->format = Response::FORMAT_JSON; |
||||
$request = Yii::$app->request; |
||||
$result = array(); |
||||
$result['success'] = false; |
||||
$result['msg'] = '保存失败'; |
||||
|
||||
if($request->isPost) { |
||||
$id = $request->post('id',0); |
||||
$status = (int)$request->post('status'); |
||||
|
||||
$row = GiftTicket2T::findOne(['id'=>$id]); |
||||
$gift_info = $row->gift; |
||||
$gift_info->total = $gift_info->total + 1; |
||||
$gift_info->save(); |
||||
$row->status = 3; |
||||
$row->use_date = date('Y-m-d H:i:s'); |
||||
$row->save(); |
||||
|
||||
$result['success'] = true; |
||||
$result['msg'] = '保存成功'; |
||||
} |
||||
return $result; |
||||
} |
||||
|
||||
public function actionGift2List() |
||||
{ |
||||
$request = Yii::$app->request; |
||||
$name = $request->get('name'); |
||||
|
||||
$query = Gift2T::find(); |
||||
if($name != '') { |
||||
$query = $query->andWhere(['like','name',$name]); |
||||
} |
||||
$items = $query->all(); |
||||
|
||||
return $this->render('gift2-list',[ |
||||
'items' => $items, |
||||
'name' => $name |
||||
]); |
||||
} |
||||
|
||||
public function actionGift2Edit() |
||||
{ |
||||
$request = Yii::$app->request; |
||||
$id = $request->get('id',0); |
||||
if($id > 0) { |
||||
$info = Gift2T::findOne(['id'=>$id]); |
||||
} else { |
||||
$info = new GiftT(); |
||||
} |
||||
|
||||
return $this->render('gift2-edit',[ |
||||
'info' => $info |
||||
]); |
||||
} |
||||
|
||||
public function actionGift2Save() |
||||
{ |
||||
Yii::$app->response->format = Response::FORMAT_JSON; |
||||
$request = Yii::$app->request; |
||||
$result = array(); |
||||
$result['success'] = false; |
||||
$result['msg'] = '保存失败'; |
||||
|
||||
if($request->isPost) { |
||||
$id = $request->post('id',0); |
||||
$name = $request->post('name'); |
||||
$price = $request->post('price'); |
||||
$remark = $request->post('remark'); |
||||
$total = (int)$request->post('total'); |
||||
|
||||
if($name == '') { |
||||
$result['msg'] = '请输入名称!'; |
||||
return $result; |
||||
} |
||||
|
||||
$row = null; |
||||
if($id > 0) { |
||||
$row = Gift2T::findOne(['id'=>$id]); |
||||
} else { |
||||
$row = new Gift2T(); |
||||
} |
||||
$row->name = $name; |
||||
$row->price = $price; |
||||
$row->remark = $remark; |
||||
$row->total = $total; |
||||
$row->save(); |
||||
|
||||
$result['success'] = true; |
||||
$result['msg'] = '保存成功'; |
||||
} |
||||
return $result; |
||||
} |
||||
|
||||
public function actionGift2Delete() |
||||
{ |
||||
Yii::$app->response->format = Response::FORMAT_JSON; |
||||
$request = Yii::$app->request; |
||||
$result = array(); |
||||
$result['success'] = false; |
||||
$result['msg'] = '删除失败'; |
||||
|
||||
if($request->isPost) { |
||||
$id = $request->post('id',0); |
||||
|
||||
if($id > 0) { |
||||
$row = Gift2T::findOne(['id'=>$id]); |
||||
$row->delete(); |
||||
|
||||
$result['success'] = true; |
||||
$result['msg'] = '删除成功'; |
||||
} |
||||
} |
||||
return $result; |
||||
} |
||||
|
||||
public function actionStastics() |
||||
{ |
||||
$gift_type_items = GiftType2T::find()->all(); |
||||
$gift_items = Gift2T::find()->all(); |
||||
|
||||
return $this->render('stastics',[ |
||||
'gift_type_items' => $gift_type_items, |
||||
'gift_items' => $gift_items, |
||||
]); |
||||
} |
||||
} |
@ -1,141 +0,0 @@ |
||||
<?php |
||||
|
||||
namespace frontend\controllers; |
||||
|
||||
use common\libs\MyLib; |
||||
use common\models\GiftGroupT; |
||||
use common\models\GiftType2T; |
||||
use common\models\GiftType3T; |
||||
use common\models\GiftTypeT; |
||||
use common\models\UserT; |
||||
use Yii; |
||||
use yii\web\Response; |
||||
|
||||
class GiftGroupController extends \yii\web\Controller |
||||
{ |
||||
public $my = null; |
||||
|
||||
public function init() |
||||
{ |
||||
parent::init(); |
||||
|
||||
$cookie = Yii::$app->request->cookies; |
||||
$user_id = MyLib::encrypt($cookie->get('aid'),'DECODE'); |
||||
|
||||
if($user_id != 0) |
||||
{ |
||||
$this->my = UserT::findOne(['id'=>$user_id]); |
||||
} else { |
||||
Yii::$app->response->redirect('/common/login')->send(); |
||||
exit; |
||||
} |
||||
} |
||||
|
||||
public function actionIndex() |
||||
{ |
||||
$request = Yii::$app->request; |
||||
$name = $request->get('name'); |
||||
|
||||
$query = GiftGroupT::find() |
||||
->orderBy('id ASC') |
||||
->where('id>0'); |
||||
if($name != '') { |
||||
$query = $query->andWhere('name like "'.$name.'%"'); |
||||
} |
||||
$total = $query->count(); |
||||
|
||||
$items = $query->all(); |
||||
|
||||
return $this->render('index',[ |
||||
'items' => $items, |
||||
'name' => $name |
||||
]); |
||||
} |
||||
|
||||
public function actionEdit() |
||||
{ |
||||
$request = Yii::$app->request; |
||||
$id = $request->get('id',0); |
||||
$info = GiftGroupT::findOne(['id'=>$id]); |
||||
if(!$info) |
||||
$info = new GiftGroupT(); |
||||
$gifts = $info->gifts; |
||||
$gift_ids = array(); |
||||
if($gifts) { |
||||
foreach($gifts as $gift) { |
||||
$gift_ids[] = $gift->id; |
||||
} |
||||
} |
||||
|
||||
$gift_items = GiftType3T::find()->all(); |
||||
|
||||
return $this->render('edit',[ |
||||
'info'=>$info, |
||||
'gift_ids'=>$gift_ids, |
||||
'gift_items'=>$gift_items |
||||
]); |
||||
} |
||||
|
||||
public function actionSave() { |
||||
Yii::$app->response->format = Response::FORMAT_JSON; |
||||
$request = Yii::$app->request; |
||||
$result = array(); |
||||
if($request->isPost) { |
||||
$id = intval($request->post('id')); |
||||
$name = $request->post('name'); |
||||
$is_free = $request->post('is_free',0); |
||||
$is_damage = $request->post('is_damage',0); |
||||
$gift_ids = $request->post('gift_ids'); |
||||
$gift_str = join(',',$gift_ids); |
||||
$min_money = $request->post('min_money'); |
||||
$max_money = $request->post('max_money'); |
||||
$group_ids = $request->post('group_ids'); |
||||
|
||||
$row = null; |
||||
if($id > 0) { |
||||
$row = GiftGroupT::findOne(['id'=>$id]); |
||||
} else { |
||||
$row = new GiftGroupT(); |
||||
} |
||||
$row->name = $name; |
||||
$row->is_free = $is_free; |
||||
$row->is_damage = $is_damage; |
||||
$row->gift_ids = $gift_str; |
||||
$row->min_money = $min_money; |
||||
$row->max_money = $max_money; |
||||
$row->group_ids = $group_ids; |
||||
if(!$row->save()) { |
||||
var_dump($row->errors); |
||||
} |
||||
|
||||
$result['success'] = true; |
||||
$result['msg'] = '操作成功'; |
||||
return $result; |
||||
} |
||||
$result['success'] = false; |
||||
$reuslt['msg'] = '操作失败'; |
||||
return $result; |
||||
} |
||||
|
||||
public function actionDelete() |
||||
{ |
||||
Yii::$app->response->format = Response::FORMAT_JSON; |
||||
$request = Yii::$app->request; |
||||
$result = array(); |
||||
$result['success'] = false; |
||||
$result['msg'] = '删除失败'; |
||||
|
||||
if($request->isPost) { |
||||
$id = $request->post('id',0); |
||||
|
||||
if($id > 0) { |
||||
$row = GiftGroupT::findOne(['id'=>$id]); |
||||
$row->delete(); |
||||
|
||||
$result['success'] = true; |
||||
$result['msg'] = '删除成功'; |
||||
} |
||||
} |
||||
return $result; |
||||
} |
||||
} |
@ -1,298 +0,0 @@ |
||||
<?php |
||||
|
||||
namespace frontend\controllers; |
||||
|
||||
use common\libs\MyLib; |
||||
use common\models\GiftType2T; |
||||
use common\models\GiftType3T; |
||||
use common\models\GiftTypeT; |
||||
use common\models\UserT; |
||||
use Yii; |
||||
use yii\web\Response; |
||||
|
||||
class GiftTypeController extends \yii\web\Controller |
||||
{ |
||||
public $my = null; |
||||
|
||||
public function init() |
||||
{ |
||||
parent::init(); |
||||
|
||||
$cookie = Yii::$app->request->cookies; |
||||
$user_id = MyLib::encrypt($cookie->get('aid'),'DECODE'); |
||||
|
||||
if($user_id != 0) |
||||
{ |
||||
$this->my = UserT::findOne(['id'=>$user_id]); |
||||
} else { |
||||
Yii::$app->response->redirect('/common/login')->send(); |
||||
exit; |
||||
} |
||||
} |
||||
|
||||
public function actionIndex() |
||||
{ |
||||
$request = Yii::$app->request; |
||||
$name = $request->get('name'); |
||||
|
||||
$query = GiftTypeT::find(); |
||||
if($name != '') { |
||||
$query = $query->andWhere(['like','name',$name]); |
||||
} |
||||
$items = $query->all(); |
||||
|
||||
return $this->render('index',[ |
||||
'items' => $items, |
||||
'name' => $name |
||||
]); |
||||
} |
||||
|
||||
public function actionEdit() |
||||
{ |
||||
$request = Yii::$app->request; |
||||
$id = $request->get('id',0); |
||||
if($id > 0) { |
||||
$info = GiftTypeT::findOne(['id'=>$id]); |
||||
} else { |
||||
$info = new GiftTypeT(); |
||||
} |
||||
|
||||
return $this->render('edit',[ |
||||
'info' => $info |
||||
]); |
||||
} |
||||
|
||||
public function actionSave() |
||||
{ |
||||
Yii::$app->response->format = Response::FORMAT_JSON; |
||||
$request = Yii::$app->request; |
||||
$result = array(); |
||||
$result['success'] = false; |
||||
$result['msg'] = '保存失败'; |
||||
|
||||
if($request->isPost) { |
||||
$id = $request->post('id',0); |
||||
$name = $request->post('name'); |
||||
|
||||
if($name == '') { |
||||
$result['msg'] = '请输入名称!'; |
||||
return $result; |
||||
} |
||||
|
||||
$row = null; |
||||
if($id > 0) { |
||||
$row = GiftTypeT::findOne(['id'=>$id]); |
||||
} else { |
||||
$row = new GiftTypeT(); |
||||
} |
||||
$row->name = $name; |
||||
$row->save(); |
||||
|
||||
$result['success'] = true; |
||||
$result['msg'] = '保存成功'; |
||||
} |
||||
return $result; |
||||
} |
||||
|
||||
public function actionDelete() |
||||
{ |
||||
Yii::$app->response->format = Response::FORMAT_JSON; |
||||
$request = Yii::$app->request; |
||||
$result = array(); |
||||
$result['success'] = false; |
||||
$result['msg'] = '删除失败'; |
||||
|
||||
if($request->isPost) { |
||||
$id = $request->post('id',0); |
||||
|
||||
if($id > 0) { |
||||
$row = GiftTypeT::findOne(['id'=>$id]); |
||||
$row->delete(); |
||||
|
||||
$result['success'] = true; |
||||
$result['msg'] = '删除成功'; |
||||
} |
||||
} |
||||
return $result; |
||||
} |
||||
|
||||
public function actionType2List() |
||||
{ |
||||
$request = Yii::$app->request; |
||||
$name = $request->get('name'); |
||||
|
||||
$query = GiftType2T::find(); |
||||
if($name != '') { |
||||
$query = $query->andWhere(['like','name',$name]); |
||||
} |
||||
$items = $query->all(); |
||||
|
||||
return $this->render('type2-list',[ |
||||
'items' => $items, |
||||
'name' => $name |
||||
]); |
||||
} |
||||
|
||||
public function actionType2Edit() |
||||
{ |
||||
$request = Yii::$app->request; |
||||
$id = $request->get('id',0); |
||||
if($id > 0) { |
||||
$info = GiftType2T::findOne(['id'=>$id]); |
||||
} else { |
||||
$info = new GiftType2T(); |
||||
} |
||||
|
||||
return $this->render('type2-edit',[ |
||||
'info' => $info |
||||
]); |
||||
} |
||||
|
||||
public function actionType2Save() |
||||
{ |
||||
Yii::$app->response->format = Response::FORMAT_JSON; |
||||
$request = Yii::$app->request; |
||||
$result = array(); |
||||
$result['success'] = false; |
||||
$result['msg'] = '保存失败'; |
||||
|
||||
if($request->isPost) { |
||||
$id = $request->post('id',0); |
||||
$name = $request->post('name'); |
||||
|
||||
if($name == '') { |
||||
$result['msg'] = '请输入名称!'; |
||||
return $result; |
||||
} |
||||
|
||||
$row = null; |
||||
if($id > 0) { |
||||
$row = GiftType2T::findOne(['id'=>$id]); |
||||
} else { |
||||
$row = new GiftType2T(); |
||||
} |
||||
$row->name = $name; |
||||
$row->save(); |
||||
|
||||
$result['success'] = true; |
||||
$result['msg'] = '保存成功'; |
||||
} |
||||
return $result; |
||||
} |
||||
|
||||
public function actionType2Delete() |
||||
{ |
||||
Yii::$app->response->format = Response::FORMAT_JSON; |
||||
$request = Yii::$app->request; |
||||
$result = array(); |
||||
$result['success'] = false; |
||||
$result['msg'] = '删除失败'; |
||||
|
||||
if($request->isPost) { |
||||
$id = $request->post('id',0); |
||||
|
||||
if($id > 0) { |
||||
$row = GiftType2T::findOne(['id'=>$id]); |
||||
$row->delete(); |
||||
|
||||
$result['success'] = true; |
||||
$result['msg'] = '删除成功'; |
||||
} |
||||
} |
||||
return $result; |
||||
} |
||||
|
||||
public function actionType3List() |
||||
{ |
||||
$request = Yii::$app->request; |
||||
$name = $request->get('name'); |
||||
|
||||
$query = GiftType3T::find(); |
||||
if($name != '') { |
||||
$query = $query->andWhere(['like','name',$name]); |
||||
} |
||||
$items = $query->all(); |
||||
|
||||
return $this->render('type3-list',[ |
||||
'items' => $items, |
||||
'name' => $name |
||||
]); |
||||
} |
||||
|
||||
public function actionType3Edit() |
||||
{ |
||||
$request = Yii::$app->request; |
||||
$id = $request->get('id',0); |
||||
if($id > 0) { |
||||
$info = GiftType3T::findOne(['id'=>$id]); |
||||
} else { |
||||
$info = new GiftType3T(); |
||||
} |
||||
|
||||
return $this->render('type3-edit',[ |
||||
'info' => $info |
||||
]); |
||||
} |
||||
|
||||
public function actionType3Save() |
||||
{ |
||||
Yii::$app->response->format = Response::FORMAT_JSON; |
||||
$request = Yii::$app->request; |
||||
$result = array(); |
||||
$result['success'] = false; |
||||
$result['msg'] = '保存失败'; |
||||
|
||||
if($request->isPost) { |
||||
$id = $request->post('id',0); |
||||
$name = $request->post('name'); |
||||
$price = $request->post('price',0); |
||||
$total = $request->post('total',-1); |
||||
$type = $request->post('type',0); |
||||
|
||||
if($name == '') { |
||||
$result['msg'] = '请输入名称!'; |
||||
return $result; |
||||
} |
||||
|
||||
$row = null; |
||||
if($id > 0) { |
||||
$row = GiftType3T::findOne(['id'=>$id]); |
||||
} else { |
||||
$row = new GiftType3T(); |
||||
} |
||||
$row->name = $name; |
||||
$row->price = $price; |
||||
$row->total = $total; |
||||
$row->type = $type; |
||||
if(!$row->save()) { |
||||
var_dump($row->errors); |
||||
} |
||||
|
||||
$result['success'] = true; |
||||
$result['msg'] = '保存成功'; |
||||
} |
||||
return $result; |
||||
} |
||||
|
||||
public function actionType3Delete() |
||||
{ |
||||
Yii::$app->response->format = Response::FORMAT_JSON; |
||||
$request = Yii::$app->request; |
||||
$result = array(); |
||||
$result['success'] = false; |
||||
$result['msg'] = '删除失败'; |
||||
|
||||
if($request->isPost) { |
||||
$id = $request->post('id',0); |
||||
|
||||
if($id > 0) { |
||||
$row = GiftType3T::findOne(['id'=>$id]); |
||||
$row->delete(); |
||||
|
||||
$result['success'] = true; |
||||
$result['msg'] = '删除成功'; |
||||
} |
||||
} |
||||
return $result; |
||||
} |
||||
} |
@ -1,84 +0,0 @@ |
||||
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="table"> |
||||
<form id="theFrm"> |
||||
<input type="hidden" name="id" value="<?=$info->id?>">
|
||||
<tr> |
||||
<td width="100" height="25" class="td_bg">分组名称</td> |
||||
<td height="25" class="td_bg"><input class="Ainput" name="name" type="text" id="name" value="<?=$info->name?>" style="width:300px;"/></td>
|
||||
</tr> |
||||
<tr> |
||||
<td width="100" height="25" class="td_bg">针对岗位</td> |
||||
<td height="25" class="td_bg"> |
||||
<input class="Ainput" name="group_ids" type="text" id="group_ids" value="<?=$info->group_ids?>" style="width:300px;"/>
|
||||
注:如果针对全部岗位,则保持空。多个岗位之间用逗号间隔。 |
||||
</td> |
||||
</tr> |
||||
<tr> |
||||
<td width="100" height="25" class="td_bg">是否免费</td> |
||||
<td height="25" class="td_bg"> |
||||
<label> |
||||
<input name="is_free" type="checkbox" id="is_free" value="1" <?=$info->is_free==1?'checked':''?>/>是
|
||||
</label> |
||||
</td> |
||||
</tr> |
||||
<tr> |
||||
<td width="100" height="25" class="td_bg">是否需要车损险</td> |
||||
<td height="25" class="td_bg"> |
||||
<label> |
||||
<input name="is_damage" type="checkbox" id="is_damage" value="1" <?=$info->is_damage==1?'checked':''?>/>是
|
||||
</label> |
||||
</td> |
||||
</tr> |
||||
<tr> |
||||
<td width="100" height="25" class="td_bg">最低额度</td> |
||||
<td height="25" class="td_bg"><input class="Ainput" name="min_money" type="text" id="min_money" value="<?=$info->min_money?>" style="width:300px;"/></td>
|
||||
</tr> |
||||
<tr> |
||||
<td width="100" height="25" class="td_bg">最高额度</td> |
||||
<td height="25" class="td_bg"><input class="Ainput" name="max_money" type="text" id="max_money" value="<?=$info->max_money?>" style="width:300px;"/></td>
|
||||
</tr> |
||||
<tr> |
||||
<td width="100" height="25" class="td_bg">包含礼品</td> |
||||
<td height="25" class="td_bg"> |
||||
<?php |
||||
foreach($gift_items as $item) { |
||||
echo '<label><input type="checkbox" name="gift_ids[]" value="'.$item->id.'"'; |
||||
if(in_array($item->id,$gift_ids)) |
||||
echo ' checked '; |
||||
echo '>'.$item->name.'</label>'; |
||||
} |
||||
?> |
||||
</td> |
||||
</tr> |
||||
</form> |
||||
<tr> |
||||
<td height="22" colspan="2" align="center" class="td_bg"> |
||||
<input id="submit-btn" type=button class="ACT_btn" name=Submit1 value=" 提交 "/> |
||||
|
||||
<input id="back-btn" type="button" class="ACT_btn" name="Submit2" value=" 返回 "> |
||||
</td> |
||||
</tr> |
||||
</table> |
||||
<script type="text/javascript" language="javascript" src="/js/jquery-1.8.3.js"></script> |
||||
<script type="text/javascript" language="javascript" src="/js/ajax.js"></script> |
||||
<script type="text/javascript" language="javascript" src="/js/func.js"></script> |
||||
<script type="text/javascript" language="javascript"> |
||||
$(function () { |
||||
//提交按钮 |
||||
$("#submit-btn").click(function(){ |
||||
if(confirm('是否确认提交?')) { |
||||
var params = $("#theFrm").serialize(); |
||||
$.post('/gift-group/save',params,function(obj){ |
||||
alert(obj.msg); |
||||
if(obj.success) { |
||||
$('#back-btn').click(); |
||||
} |
||||
},'json'); |
||||
} |
||||
}); |
||||
|
||||
//返回按钮 |
||||
$('#back-btn').click(function(){ |
||||
window.location.href='/gift-group/index'; |
||||
}); |
||||
}) |
||||
</script> |
@ -1,79 +0,0 @@ |
||||
<?php |
||||
use \common\libs\MyLib; |
||||
?> |
||||
<script type="text/javascript" language="javascript" src="/js/jquery-1.8.3.js"></script> |
||||
<script type="text/javascript" language="javascript" src="/js/ajax.js"></script> |
||||
<script type="text/javascript" language="javascript" src="/js/func.js"></script> |
||||
<script type="text/javascript" language="javascript"> |
||||
//编辑 |
||||
function edit(id) { |
||||
window.location.href = '/gift-group/edit?id=' + id; |
||||
} |
||||
//删除 |
||||
function del(id) { |
||||
if(confirm('是否确认删除?')) { |
||||
$.post('/gift-group/delete',{id:id},function(obj){ |
||||
alert(obj.msg); |
||||
if(obj.success) { |
||||
window.location.reload(); |
||||
} |
||||
},'json'); |
||||
} |
||||
} |
||||
|
||||
$(function(){ |
||||
$("#search-btn").click(function(){ |
||||
var params = $('#searchForm').serialize(); |
||||
window.location.href = "/gift-group/index?" + params; |
||||
}); |
||||
$('#add-btn').click(function(){ |
||||
edit(0); |
||||
}); |
||||
}); |
||||
</script> |
||||
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table"> |
||||
<form id="searchForm"> |
||||
<tr> |
||||
<td class="td_bg"> |
||||
名称:<input name="name" type="text" value="<?=$name?>">
|
||||
<input type="button" class="act_btn" id="search-btn" name="search-btn" value="搜索"> |
||||
<input type="button" class="act_btn" id="add-btn" name="add-btn" value="添加"> |
||||
</td> |
||||
</tr> |
||||
</form> |
||||
</table> |
||||
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table"> |
||||
<tr> |
||||
<td align="center" width="24" align="center" class="bg_tr">ID</td> |
||||
<td width="150" align="center" align="center" class="bg_tr">分类名称</td> |
||||
<td width="50" align="center" align="center" class="bg_tr">是否免费</td> |
||||
<td width="50" align="center" align="center" class="bg_tr">是否车损险</td> |
||||
<td width="100" align="center" align="center" class="bg_tr">最低额度</td> |
||||
<td width="100" align="center" align="center" class="bg_tr">最高额度</td> |
||||
<td width="300" align="center" align="center" class="bg_tr">包含礼品</td> |
||||
<td width="30" align="center" class="bg_tr">操作</td> |
||||
</tr> |
||||
<?php |
||||
foreach($items as $index => $item) { |
||||
?> |
||||
<tr onMouseOver=overColor(this) onMouseOut=outColor(this)> |
||||
<td align="center" class="td_bg"nowrap ><?=$item->id?></td>
|
||||
<td align="left" class="td_bg"nowrap ><?=$item->name?></td>
|
||||
<td align="center" class="td_bg"nowrap ><?=$item->is_free==1?'是':''?></td>
|
||||
<td align="center" class="td_bg"nowrap ><?=$item->is_damage==1?'是':''?></td>
|
||||
<td align="center" class="td_bg"nowrap ><?=$item->min_money==0?'无限制':$item->min_money.'元'?></td>
|
||||
<td align="center" class="td_bg"nowrap ><?=$item->max_money==0?'无限制':$item->max_money.'元'?></td>
|
||||
<td align="left" class="td_bg"nowrap ><?php |
||||
if($item->gifts) foreach($item->gifts as $gift) { |
||||
echo $gift->name.', '; |
||||
} |
||||
?></td> |
||||
<td align="center" class="td_bg" nowrap> |
||||
[<a href="javascript:void(0);" onclick="edit(<?=$item->id?>)">修改</a>]
|
||||
[<a href="javascript:void(0);" onclick="del(<?=$item->id?>)">删除</a>]
|
||||
</td> |
||||
</tr> |
||||
<?php |
||||
} |
||||
?> |
||||
</table> |
@ -1,42 +0,0 @@ |
||||
<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table"> |
||||
<form id="theFrm"> |
||||
<input type="hidden" name="id" value="<?=$info->id?>">
|
||||
<tr> |
||||
<td width="100" height="25" class="td_bg">名称</td> |
||||
<td height="25" class="td_bg"> |
||||
<input name="name" type="text" id="name" value="<?=$info->name?>" style="width:400px;"/>
|
||||
</td> |
||||
</tr> |
||||
</form> |
||||
<tr> |
||||
<td height="22" colspan="2" align="center" class="td_bg"> |
||||
<input id="submit-btn" type=button class="ACT_btn" name=Submit1 value=" 提交 "/> |
||||
|
||||
<input id="back-btn" type="button" class="ACT_btn" name="Submit2" value=" 返回 "> |
||||
</td> |
||||
</tr> |
||||
</table> |
||||
<script type="text/javascript" language="javascript" src="/js/jquery-1.8.3.js"></script> |
||||
<script type="text/javascript" language="javascript" src="/js/ajax.js"></script> |
||||
<script type="text/javascript" language="javascript" src="/js/func.js"></script> |
||||
<script type="text/javascript" language="javascript"> |
||||
$(function () { |
||||
//提交按钮 |
||||
$("#submit-btn").click(function(){ |
||||
if(confirm('是否确认提交?')) { |
||||
var params = $("#theFrm").serialize(); |
||||
$.post('/gift-type/save',params,function(obj){ |
||||
alert(obj.msg); |
||||
if(obj.success) { |
||||
$('#back-btn').click(); |
||||
} |
||||
},'json'); |
||||
} |
||||
}); |
||||
|
||||
//返回按钮 |
||||
$('#back-btn').click(function(){ |
||||
window.location.href='/gift-type/index'; |
||||
}); |
||||
}) |
||||
</script> |
@ -1,64 +0,0 @@ |
||||
<?php |
||||
use \common\libs\MyLib; |
||||
?> |
||||
<script type="text/javascript" language="javascript" src="/js/jquery-1.8.3.js"></script> |
||||
<script type="text/javascript" language="javascript" src="/js/ajax.js"></script> |
||||
<script type="text/javascript" language="javascript" src="/js/func.js"></script> |
||||
<script type="text/javascript" language="javascript"> |
||||
//编辑 |
||||
function edit(id) { |
||||
window.location.href = '/gift-type/edit?id=' + id; |
||||
} |
||||
//删除 |
||||
function del(id) { |
||||
if(confirm('是否确认删除?')) { |
||||
$.post('/gift-type/delete',{id:id},function(obj){ |
||||
alert(obj.msg); |
||||
if(obj.success) { |
||||
window.location.reload(); |
||||
} |
||||
},'json'); |
||||
} |
||||
} |
||||
$(function(){ |
||||
$("#search-btn").click(function(){ |
||||
var params = $('#searchForm').serialize(); |
||||
window.location.href = "/gift-type/index?" + params; |
||||
}); |
||||
$('#add-btn').click(function(){ |
||||
edit(0); |
||||
}); |
||||
}); |
||||
</script> |
||||
<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table"> |
||||
<form id="searchForm"> |
||||
<tr> |
||||
<td class="td_bg"> |
||||
名称:<input name="name" type="text" value="<?=$name?>">
|
||||
<input type="button" class="act_btn" id="search-btn" name="search-btn" value="搜索"> |
||||
<input type="button" class="act_btn" id="add-btn" name="add-btn" value="添加"> |
||||
</td> |
||||
</tr> |
||||
</form> |
||||
</table> |
||||
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table"> |
||||
<tr> |
||||
<td width="50" align="center" align="center" class="bg_tr" nowrap>排序</td> |
||||
<td width="80%" align="center" align="center" class="bg_tr">名称</td> |
||||
<td width="30" align="center" class="bg_tr">操作</td> |
||||
</tr> |
||||
<?php |
||||
foreach($items as $index => $item) { |
||||
?> |
||||
<tr onMouseOver=overColor(this) onMouseOut=outColor(this)> |
||||
<td align="center" class="td_bg" nowrap><?=$index+1?></td>
|
||||
<td align="left" class="td_bg" nowrap><?=$item->name?></td>
|
||||
<td align="center" class="td_bg" nowrap> |
||||
[<a href="javascript:void(0);" onclick="edit(<?=$item->id?>)">修改</a>]
|
||||
[<a href="javascript:void(0);" onclick="del(<?=$item->id?>)">删除</a>]
|
||||
</td> |
||||
</tr> |
||||
<?php |
||||
} |
||||
?> |
||||
</table> |
@ -1,42 +0,0 @@ |
||||
<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table"> |
||||
<form id="theFrm"> |
||||
<input type="hidden" name="id" value="<?=$info->id?>">
|
||||
<tr> |
||||
<td width="100" height="25" class="td_bg">名称</td> |
||||
<td height="25" class="td_bg"> |
||||
<input name="name" type="text" id="name" value="<?=$info->name?>" style="width:400px;"/>
|
||||
</td> |
||||
</tr> |
||||
</form> |
||||
<tr> |
||||
<td height="22" colspan="2" align="center" class="td_bg"> |
||||
<input id="submit-btn" type=button class="ACT_btn" name=Submit1 value=" 提交 "/> |
||||
|
||||
<input id="back-btn" type="button" class="ACT_btn" name="Submit2" value=" 返回 "> |
||||
</td> |
||||
</tr> |
||||
</table> |
||||
<script type="text/javascript" language="javascript" src="/js/jquery-1.8.3.js"></script> |
||||
<script type="text/javascript" language="javascript" src="/js/ajax.js"></script> |
||||
<script type="text/javascript" language="javascript" src="/js/func.js"></script> |
||||
<script type="text/javascript" language="javascript"> |
||||
$(function () { |
||||
//提交按钮 |
||||
$("#submit-btn").click(function(){ |
||||
if(confirm('是否确认提交?')) { |
||||
var params = $("#theFrm").serialize(); |
||||
$.post('/gift-type/type2-save',params,function(obj){ |
||||
alert(obj.msg); |
||||
if(obj.success) { |
||||
$('#back-btn').click(); |
||||
} |
||||
},'json'); |
||||
} |
||||
}); |
||||
|
||||
//返回按钮 |
||||
$('#back-btn').click(function(){ |
||||
window.location.href='/gift-type/type2-list'; |
||||
}); |
||||
}) |
||||
</script> |
@ -1,64 +0,0 @@ |
||||
<?php |
||||
use \common\libs\MyLib; |
||||
?> |
||||
<script type="text/javascript" language="javascript" src="/js/jquery-1.8.3.js"></script> |
||||
<script type="text/javascript" language="javascript" src="/js/ajax.js"></script> |
||||
<script type="text/javascript" language="javascript" src="/js/func.js"></script> |
||||
<script type="text/javascript" language="javascript"> |
||||
//编辑 |
||||
function edit(id) { |
||||
window.location.href = '/gift-type/type2-edit?id=' + id; |
||||
} |
||||
//删除 |
||||
function del(id) { |
||||
if(confirm('是否确认删除?')) { |
||||
$.post('/gift-type/type2-delete',{id:id},function(obj){ |
||||
alert(obj.msg); |
||||
if(obj.success) { |
||||
window.location.reload(); |
||||
} |
||||
},'json'); |
||||
} |
||||
} |
||||
$(function(){ |
||||
$("#search-btn").click(function(){ |
||||
var params = $('#searchForm').serialize(); |
||||
window.location.href = "/gift-type/type2-list?" + params; |
||||
}); |
||||
$('#add-btn').click(function(){ |
||||
edit(0); |
||||
}); |
||||
}); |
||||
</script> |
||||
<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table"> |
||||
<form id="searchForm"> |
||||
<tr> |
||||
<td class="td_bg"> |
||||
名称:<input name="name" type="text" value="<?=$name?>">
|
||||
<input type="button" class="act_btn" id="search-btn" name="search-btn" value="搜索"> |
||||
<input type="button" class="act_btn" id="add-btn" name="add-btn" value="添加"> |
||||
</td> |
||||
</tr> |
||||
</form> |
||||
</table> |
||||
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table"> |
||||
<tr> |
||||
<td width="50" align="center" align="center" class="bg_tr" nowrap>排序</td> |
||||
<td width="80%" align="center" align="center" class="bg_tr">名称</td> |
||||
<td width="30" align="center" class="bg_tr">操作</td> |
||||
</tr> |
||||
<?php |
||||
foreach($items as $index => $item) { |
||||
?> |
||||
<tr onMouseOver=overColor(this) onMouseOut=outColor(this)> |
||||
<td align="center" class="td_bg" nowrap><?=$index+1?></td>
|
||||
<td align="left" class="td_bg" nowrap><?=$item->name?></td>
|
||||
<td align="center" class="td_bg" nowrap> |
||||
[<a href="javascript:void(0);" onclick="edit(<?=$item->id?>)">修改</a>]
|
||||
[<a href="javascript:void(0);" onclick="del(<?=$item->id?>)">删除</a>]
|
||||
</td> |
||||
</tr> |
||||
<?php |
||||
} |
||||
?> |
||||
</table> |
@ -1,65 +0,0 @@ |
||||
<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table"> |
||||
<form id="theFrm"> |
||||
<input type="hidden" name="id" value="<?=$info->id?>">
|
||||
<tr> |
||||
<td width="100" height="25" class="td_bg">名称</td> |
||||
<td height="25" class="td_bg"> |
||||
<input name="name" type="text" id="name" value="<?=$info->name?>" style="width:400px;"/>
|
||||
</td> |
||||
</tr> |
||||
<tr> |
||||
<td width="100" height="25" class="td_bg">价格</td> |
||||
<td height="25" class="td_bg"> |
||||
<input name="price" type="text" id="price" value="<?=$info->price?>" style="width:100px;"/>小于零时,为百分比。
|
||||
</td> |
||||
</tr> |
||||
<tr> |
||||
<td width="100" height="25" class="td_bg">数量</td> |
||||
<td height="25" class="td_bg"> |
||||
<input name="total" type="text" id="total" value="<?=$info->total?>" style="width:100px;"/>-1为无限数量。
|
||||
</td> |
||||
</tr> |
||||
<tr> |
||||
<td width="100" height="25" class="td_bg">类型</td> |
||||
<td height="25" class="td_bg"> |
||||
<label> |
||||
<input type="radio" name="type" value="0" <?=$info->type==0?'checked':''?>> 实物
|
||||
</label> |
||||
<label> |
||||
<input type="radio" name="type" value="1" <?=$info->type==1?'checked':''?>> 礼券
|
||||
</label> |
||||
</td> |
||||
</tr> |
||||
</form> |
||||
<tr> |
||||
<td height="22" colspan="2" align="center" class="td_bg"> |
||||
<input id="submit-btn" type=button class="ACT_btn" name=Submit1 value=" 提交 "/> |
||||
|
||||
<input id="back-btn" type="button" class="ACT_btn" name="Submit2" value=" 返回 "> |
||||
</td> |
||||
</tr> |
||||
</table> |
||||
<script type="text/javascript" language="javascript" src="/js/jquery-1.8.3.js"></script> |
||||
<script type="text/javascript" language="javascript" src="/js/ajax.js"></script> |
||||
<script type="text/javascript" language="javascript" src="/js/func.js"></script> |
||||
<script type="text/javascript" language="javascript"> |
||||
$(function () { |
||||
//提交按钮 |
||||
$("#submit-btn").click(function(){ |
||||
if(confirm('是否确认提交?')) { |
||||
var params = $("#theFrm").serialize(); |
||||
$.post('/gift-type/type3-save',params,function(obj){ |
||||
alert(obj.msg); |
||||
if(obj.success) { |
||||
$('#back-btn').click(); |
||||
} |
||||
},'json'); |
||||
} |
||||
}); |
||||
|
||||
//返回按钮 |
||||
$('#back-btn').click(function(){ |
||||
window.location.href='/gift-type/type3-list'; |
||||
}); |
||||
}) |
||||
</script> |
@ -1,70 +0,0 @@ |
||||
<?php |
||||
use \common\libs\MyLib; |
||||
?> |
||||
<script type="text/javascript" language="javascript" src="/js/jquery-1.8.3.js"></script> |
||||
<script type="text/javascript" language="javascript" src="/js/ajax.js"></script> |
||||
<script type="text/javascript" language="javascript" src="/js/func.js"></script> |
||||
<script type="text/javascript" language="javascript"> |
||||
//编辑 |
||||
function edit(id) { |
||||
window.location.href = '/gift-type/type3-edit?id=' + id; |
||||
} |
||||
//删除 |
||||
function del(id) { |
||||
if(confirm('是否确认删除?')) { |
||||
$.post('/gift-type/type3-delete',{id:id},function(obj){ |
||||
alert(obj.msg); |
||||
if(obj.success) { |
||||
window.location.reload(); |
||||
} |
||||
},'json'); |
||||
} |
||||
} |
||||
$(function(){ |
||||
$("#search-btn").click(function(){ |
||||
var params = $('#searchForm').serialize(); |
||||
window.location.href = "/gift-type/type3-list?" + params; |
||||
}); |
||||
$('#add-btn').click(function(){ |
||||
edit(0); |
||||
}); |
||||
}); |
||||
</script> |
||||
<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table"> |
||||
<form id="searchForm"> |
||||
<tr> |
||||
<td class="td_bg"> |
||||
名称:<input name="name" type="text" value="<?=$name?>">
|
||||
<input type="button" class="act_btn" id="search-btn" name="search-btn" value="搜索"> |
||||
<input type="button" class="act_btn" id="add-btn" name="add-btn" value="添加"> |
||||
</td> |
||||
</tr> |
||||
</form> |
||||
</table> |
||||
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table"> |
||||
<tr> |
||||
<td width="50" align="center" align="center" class="bg_tr" nowrap>排序</td> |
||||
<td width="70%" align="center" align="center" class="bg_tr">名称</td> |
||||
<td width="50" align="center" class="bg_tr">价格</td> |
||||
<td width="50" align="center" class="bg_tr">数量</td> |
||||
<td width="50" align="center" class="bg_tr">类型</td> |
||||
<td width="30" align="center" class="bg_tr">操作</td> |
||||
</tr> |
||||
<?php |
||||
foreach($items as $index => $item) { |
||||
?> |
||||
<tr onMouseOver=overColor(this) onMouseOut=outColor(this)> |
||||
<td align="center" class="td_bg" nowrap><?=$index+1?></td>
|
||||
<td align="left" class="td_bg" nowrap><?=$item->name?></td>
|
||||
<td align="center" class="td_bg" nowrap><?=$item->price?><?=$item->price<0?'%':'元'?></td>
|
||||
<td align="center" class="td_bg" nowrap><?=$item->total<0?'无限':$item->total?></td>
|
||||
<td align="center" class="td_bg" nowrap><?=$item->type==0?'实物':'礼券'?></td>
|
||||
<td align="center" class="td_bg" nowrap> |
||||
[<a href="javascript:void(0);" onclick="edit(<?=$item->id?>)">修改</a>]
|
||||
[<a href="javascript:void(0);" onclick="del(<?=$item->id?>)">删除</a>]
|
||||
</td> |
||||
</tr> |
||||
<?php |
||||
} |
||||
?> |
||||
</table> |
@ -0,0 +1,167 @@ |
||||
<?php |
||||
use \common\libs\MyLib; |
||||
?> |
||||
<?php $this->beginBlock('header_css'); ?> |
||||
<link href="/assets/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet"> |
||||
<?php $this->endBlock(); ?> |
||||
|
||||
<div class="wrapper wrapper-content animated fadeInRight"> |
||||
<div class="ibox float-e-margins"> |
||||
<div class="ibox-title"> |
||||
<h5>礼品出库</h5> |
||||
<div class="ibox-tools"> |
||||
<a class="btn btn-primary btn-xs edit-btn" data-id="0" href="javascript:void(0);" onclick="$('#listTable').bootstrapTable('refresh');"> |
||||
<i class="fa fa-refresh"></i> 刷新 |
||||
</a> |
||||
</div> |
||||
</div> |
||||
<div class="ibox-content"> |
||||
<form role="form" class="form-inline" onsubmit="return search();"> |
||||
<div class="form-group" style="margin-bottom: 8px;"> |
||||
<label for="code">礼品编号</label> |
||||
<input type="text" id="code" name="code" class="form-control"> |
||||
</div> |
||||
<div class="form-group" style="margin-bottom: 8px;"> |
||||
<label for="car_no">车牌</label> |
||||
<input type="text" id="car_no" name="car_no" class="form-control"> |
||||
</div> |
||||
<div class="form-group" style="margin-bottom: 8px;"> |
||||
<label for="frame_no">车架号</label> |
||||
<input type="text" id="frame_no" name="frame_no" class="form-control"> |
||||
</div> |
||||
<div class="form-group" style="margin-bottom: 8px;"> |
||||
<label for="engine_no">发动机号</label> |
||||
<input type="text" id="engine_no" name="engine_no" class="form-control"> |
||||
</div> |
||||
<div class="form-group" style="margin-bottom: 8px;"> |
||||
<label for="status">状态</label> |
||||
<select name="status" id="status" class="form-control"> |
||||
<option value="0" >全部</option> |
||||
<option value="1">未使用</option> |
||||
<option value="2">使用中</option> |
||||
<option value="3">使用完</option> |
||||
</select> |
||||
</div> |
||||
<div class="form-group" style="margin-bottom: 8px;"> |
||||
<label for="type_id">分类</label> |
||||
<select name="type_id" id="type_id" class="form-control"> |
||||
<option value="0">---请选择---</option> |
||||
<?php |
||||
foreach($type_items as $item) { |
||||
echo '<option value="'.$item->id.'"'; |
||||
echo '>'.$item->name.'</option>'; |
||||
} |
||||
?> |
||||
</select> |
||||
</div> |
||||
<div class="form-group" style="margin-bottom: 8px;"> |
||||
<label for="username">业务工号</label> |
||||
<input type="text" id="username" name="username" class="form-control"> |
||||
</div> |
||||
<div class="form-group" style="margin-bottom: 8px;"> |
||||
<label for="insurer1_no">商业保单号</label> |
||||
<input type="text" id="insurer1_no" name="insurer1_no" class="form-control"> |
||||
</div> |
||||
<div class="form-group" style="margin-bottom: 8px;"> |
||||
<label for="datepicker1">提单日期</label> |
||||
<div class="input-daterange input-group" id="datepicker1"> |
||||
<input type="text" class="input-sm form-control" id="s_start_date" name="s_start_date" autocomplete="off" value="" /> |
||||
<span class="input-group-addon">到</span> |
||||
<input type="text" class="input-sm form-control" id="s_end_date" name="s_end_date" autocomplete="off" value="" /> |
||||
</div> |
||||
</div> |
||||
<div class="form-group" style="margin-bottom: 8px;"> |
||||
<label for="datepicker2">正本日期</label> |
||||
<div class="input-daterange input-group" id="datepicker2"> |
||||
<input type="text" class="input-sm form-control" id="p_start_date" name="p_start_date" autocomplete="off" value="" /> |
||||
<span class="input-group-addon">到</span> |
||||
<input type="text" class="input-sm form-control" id="p_end_date" name="p_end_date" autocomplete="off" value="" /> |
||||
</div> |
||||
</div> |
||||
<button type="submit" class="btn btn-primary mb-8">搜索</button> |
||||
</form> |
||||
<div class="row"> |
||||
<div class="col-md-12"> |
||||
<table id="listTable"> |
||||
<thead> |
||||
<tr> |
||||
<th width="50" data-field="id">ID</th> |
||||
<th data-field="code">礼品编号</th> |
||||
<th data-field="name">礼品</th> |
||||
<th data-field="car_no">车牌号</th> |
||||
<th data-field="car_frame_no">车架号</th> |
||||
<th data-field="submit_user">提单人</th> |
||||
<th data-field="use_date">出库日期</th> |
||||
<th data-field="status">状态</th> |
||||
<th data-field="username">操作员</th> |
||||
<th data-formatter="opFormatter">操作</th> |
||||
</tr> |
||||
</thead> |
||||
</table> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
|
||||
|
||||
<?php $this->beginBlock('footer_js'); ?> |
||||
<script src="/assets/js/plugins/bootstrap-table/bootstrap-table.min.js"></script> |
||||
<script src="/assets/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script> |
||||
<script src="/assets/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script> |
||||
<script> |
||||
function opFormatter(value, row, index) { |
||||
var opStr = []; |
||||
opStr.push('<a href="javascript:void(0);" onclick="edit(' + row.id + ')">'); |
||||
if(row.use_num > row.finish_num) { |
||||
opStr.push('<i class="fa fa-edit" title="出库"></i>'); |
||||
} else { |
||||
opStr.push('<i class="fa fa-file-o" title="详情"></i>'); |
||||
} |
||||
opStr.push('</a>'); |
||||
|
||||
return opStr.join(' '); |
||||
} |
||||
function edit(id) { |
||||
title = '礼品核销'; |
||||
layer_show(title, '/gift/gift-use-edit?id='+id); |
||||
} |
||||
function refreshList() { |
||||
$('#listTable').bootstrapTable('refresh'); |
||||
} |
||||
|
||||
function search() { |
||||
$('#listTable').bootstrapTable('destroy'); |
||||
$('#listTable').bootstrapTable({ |
||||
url: "/gift/gift-use-json", |
||||
pagination: true, |
||||
sidePagination: 'server', |
||||
queryParams: function(params) { |
||||
params.code = $('#code').val(); |
||||
params.car_no = $('#car_no').val(); |
||||
params.frame_no = $('#frame_no').val(); |
||||
params.engine_no = $('#engine_no').val(); |
||||
params.status = $('#status').val(); |
||||
params.type_id = $('#type_id').val(); |
||||
params.username = $('#username').val(); |
||||
params.insurer1_no = $('#insurer1_no').val(); |
||||
params.s_start_date = $('#s_start_date').val(); |
||||
params.s_end_date = $('#s_end_date').val(); |
||||
params.p_start_date = $('#p_start_date').val(); |
||||
params.p_end_date = $('#p_end_date').val(); |
||||
return params; |
||||
} |
||||
}); |
||||
return false; |
||||
} |
||||
|
||||
$(function() { |
||||
$('.input-daterange').datepicker({ |
||||
keyboardNavigation: false, |
||||
forceParse: false, |
||||
autoclose: true |
||||
}); |
||||
search(); |
||||
}); |
||||
</script> |
||||
<?php $this->endBlock(); ?> |
Loading…
Reference in new issue