|
@@ -1 +1,83 @@
|
|
<?php
|
|
<?php
|
|
|
|
+
|
|
|
|
+class refill_thirdControl extends SystemControl
|
|
|
|
+{
|
|
|
|
+ public function __construct()
|
|
|
|
+ {
|
|
|
|
+ parent::__construct();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function indexOp()
|
|
|
|
+ {
|
|
|
|
+ $mod = Model('refill_third');
|
|
|
|
+
|
|
|
|
+ $condition = [];
|
|
|
|
+ if (trim($_GET['product_name']) != '') {
|
|
|
|
+ $condition['product_name'] = ['like', '%' . $_GET['product_name'] . '%'];
|
|
|
|
+ }
|
|
|
|
+ $list = $mod->getThirdProductList($condition, 30);
|
|
|
|
+
|
|
|
|
+ Tpl::output('product_list', $list);
|
|
|
|
+ Tpl::output('page', $mod->showpage());
|
|
|
|
+ Tpl::showpage('third.product.list');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function product_addOp()
|
|
|
|
+ {
|
|
|
|
+ if (chksubmit()) {
|
|
|
|
+ $obj_validate = new Validator();
|
|
|
|
+ $obj_validate->validateparam = [
|
|
|
|
+ ["input" => trim($_POST["product_name"]), "require" => "true", "message" => '产品名称不能为空'],
|
|
|
|
+ ["input" => trim($_POST["refill_amount"]), "require" => "true", "message" => '产品面值不能为空'],
|
|
|
|
+ ];
|
|
|
|
+ $error = $obj_validate->validate();
|
|
|
|
+ if ($error != '') {
|
|
|
|
+ showMessage($error);
|
|
|
|
+ } else {
|
|
|
|
+ $mod = Model('refill_third');
|
|
|
|
+ $insert['product_name'] = trim($_POST['product_name']);
|
|
|
|
+ $insert['refill_amount'] = trim($_POST['refill_amount']);
|
|
|
|
+ $last_item = $mod->table('third_product')->order('system_code desc')->find();
|
|
|
|
+ if (empty($last_item)) {
|
|
|
|
+ $system_code = 'XYZ100001';
|
|
|
|
+ } else {
|
|
|
|
+ $last_code = $last_item['system_code'];
|
|
|
|
+ $last_code = explode('XYZ',$last_code);
|
|
|
|
+ $system_code = intval($last_code[1] + 1);
|
|
|
|
+ $system_code = "XYZ{$system_code}";
|
|
|
|
+ }
|
|
|
|
+ $insert['system_code'] = $system_code;
|
|
|
|
+ $result = $mod->addThirdProduct($insert);
|
|
|
|
+ if ($result) {
|
|
|
|
+ showMessage('添加成功', 'index.php?act=refill_third&op=index');
|
|
|
|
+ } else {
|
|
|
|
+ showMessage('添加失败');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ Tpl::showpage('third.product.add');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function product_editOp()
|
|
|
|
+ {
|
|
|
|
+ $system_code = $_GET['system_code'] ?? $_POST['system_code'];
|
|
|
|
+ $mod = Model('refill_third');
|
|
|
|
+ $third_product = $mod->findThirdProduct($system_code);
|
|
|
|
+ if(empty($third_product)) {
|
|
|
|
+ showMessage('产品不存在');
|
|
|
|
+ }
|
|
|
|
+ if(chksubmit()) {
|
|
|
|
+ $updata['product_name'] = trim($_POST['product_name']);
|
|
|
|
+ $updata['refill_amount'] = trim($_POST['refill_amount']);
|
|
|
|
+ $result = $mod->editGroup($system_code, $updata);
|
|
|
|
+ if ($result) {
|
|
|
|
+ showMessage('编辑成功', 'index.php?act=refill_third&op=index');
|
|
|
|
+ } else {
|
|
|
|
+ showMessage('编辑失败');
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ Tpl::output('third_product', $third_product);
|
|
|
|
+ Tpl::showpage('third.product.edit');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|