huwhois 4 years ago
parent
commit
a979c3b2f6

+ 3 - 1
application/admin/controller/Index.php

@ -1,7 +1,9 @@
1 1
<?php
2 2
namespace app\admin\controller;
3 3
4
Class Index extends \BaseController
4
use daswork\Controller;
5
6
Class Index extends \Controller
5 7
{
6 8
    public function index()
7 9
    {

+ 16 - 9
application/index/controller/Company.php

@ -10,29 +10,35 @@ use app\index\model\Company as CompanyModel;
10 10
class Company extends Controller
11 11
{
12 12
    private $model;
13
    protected $params;
14 13
15 14
    public function __construct()
16 15
    {
17 16
        parent::__construct();
18 17
        $this->model = new CompanyModel();
19
        $this->params = escapeString($_POST);
20 18
    }
21 19
22 20
    public function index()
23 21
    {
24
        $name = isset($_GET['company_name']) ? $_GET['company_name'] : '';
25
        $data = $this->model->listByName($name, "name");
22
        $key = isset($_GET['key']) ? $_GET['key'] : '';
23
        $where = '';
24
        if ($key) {
25
            $where = "WHERE name LIKE '$key%' ";
26
            $this->assign('key', $key);
27
        }
28
        
29
        $page = isset($_GET['page']) ? escapeString($_GET['page']) : 1;
30
        $data = $this->model->pageList($where, $page, 20);
31
26 32
        $this->assign("data", $data);
27
        $this->assign("company_name", $name);
28 33
        $this->fetch();
29 34
    }
30 35
31 36
    public function save()
32 37
    {
33
        $id = $this->params['id'];
34
        $name = $this->params['name'];
35
        $initial_balance = $this->params['initial_balance'];
38
        $params = escapeString($_POST);
39
        $id = $params['id'];
40
        $name = $params['name'];
41
        $initial_balance = $params['initial_balance'];
36 42
        if ($id) {
37 43
            $res = $this->model->exec("UPDATE `company` SET `name`='$name', `initial_balance`='$initial_balance' WHERE `id`=$id;");
38 44
            // var_dump($res);
@ -48,7 +54,8 @@ class Company extends Controller
48 54
49 55
    public function delete()
50 56
    {
51
        $res = $this->model->exec("DELETE FROM `company` WHERE `id`=$this->params['id'];");
57
        $id = escapeString($_POST['id']);
58
        $res = $this->model->exec("DELETE FROM `company` WHERE `id`=$id;");
52 59
        if ($res===false) {
53 60
            echo json_encode(['code' => 1, "msg"=>$this->model->lastErrorMsg()]);
54 61
        } else {

+ 3 - 10
application/index/controller/Index.php

@ -44,7 +44,7 @@ class Index extends Controller
44 44
        $tepi_dp1 = 0;
45 45
        $tepi_dp2 = 0;
46 46
        $dp_c_rate = 0.014;
47
        $dp_t_rate = 0.014;
47
        $dp_t_rate = 0.0014;
48 48
49 49
        $all_money = 0;
50 50
@ -109,7 +109,7 @@ class Index extends Controller
109 109
        $data[$i+2]['c_rate'] = $dp_c_rate;
110 110
        $data[$i+2]['c_money'] = $total_profit_dp1 * $dp_c_rate;
111 111
        $data[$i+2]['tepi'] = $tepi_dp1;
112
        $data[$i+2]['t_rate'] = $dp_c_rate;
112
        $data[$i+2]['t_rate'] = $dp_t_rate;
113 113
        $data[$i+2]['t_money'] = $tepi_dp1 * $dp_t_rate;
114 114
        $data[$i+2]['s_money'] = $data[$i+2]['c_money'] + $data[$i+2]['t_money'];
115 115
@ -128,7 +128,7 @@ class Index extends Controller
128 128
        $data[$i+3]['c_rate'] = $dp_c_rate;
129 129
        $data[$i+3]['c_money'] = $total_profit_dp2 * $dp_c_rate;
130 130
        $data[$i+3]['tepi'] = $tepi_dp2;
131
        $data[$i+3]['t_rate'] = $dp_c_rate;
131
        $data[$i+3]['t_rate'] = $dp_t_rate;
132 132
        $data[$i+3]['t_money'] = $tepi_dp2 *$dp_t_rate;
133 133
        $data[$i+3]['s_money'] = $row['c_money'] + $row['t_money'];
134 134
        
@ -151,13 +151,6 @@ class Index extends Controller
151 151
        $this->fetch();
152 152
    }
153 153
154
    public function test()
155
    {
156
        $data = "test--dasdsd";
157
        $this->assign('data', $data);
158
        $this->fetch();
159
    }
160
161 154
    public function salesData()
162 155
    {
163 156
        $sales = new Sales();

+ 39 - 0
application/index/model/MySqlite.php

@ -92,6 +92,45 @@ class MySqlite
92 92
    /**
93 93
     * 列表结果集
94 94
     */
95
    public function dataList($where='', $order= '', $desc = false, $limit = 0)
96
    {
97
        if ($order) {
98
            $where .= " order by $order";
99
            if ($desc) {
100
                $where .= " desc";
101
            } else {
102
                $where .= " asc";
103
            }
104
        }
105
106
        if ($limit) {
107
            $where .= " limit " . $limit;
108
        }
109
110
        $sql = "select * from $this->tablename $where;";
111
        
112
        return $this->select($sql);
113
    }
114
115
    /**
116
     * 分页结果
117
     */
118
    public function pageList($where, $page = 1, $limit = 10)
119
    {
120
        $res = $this->query("select count(*) as total from $this->tablename $where;"); 
121
        $data = $res->fetchArray(SQLITE3_ASSOC);
122
        
123
        $offset = ($page - 1) * $limit;
124
        $sql = "select * from $this->tablename $where limit $offset, $limit;";
125
        $list = $this->select($sql);
126
        $data['list'] = $list;
127
        $data['page'] = $page;
128
        $data['limit'] = $limit;
129
        
130
        return $data;
131
    }
132
    
133
95 134
    public function list($where='')
96 135
    {
97 136
        $sql = "select * from $this->tablename $where;";

+ 1 - 1
application/index/model/Sales.php

@ -78,7 +78,7 @@ class Sales
78 78
            for($j = 'A'; $j <= 'P'; $j++ ){  // 有用的数据只到 P
79 79
                $key = $j.$k;
80 80
                // $value = $curSheet->getCell($key)->getValue();  // 含公式
81
                $row[] = $curSheet->getCell($key)->getFormattedValue(); // 公式计算后的值
81
                $row[] = trim($curSheet->getCell($key)->getFormattedValue()); // 公式计算后的值
82 82
            }
83 83
            $data[] = $row;
84 84
        }

+ 26 - 24
application/index/view/commission/index.php

@ -160,31 +160,33 @@
160 160
                    </tbody>
161 161
                </table>
162 162
            </div>
163
            <!-- <div style="text-align:right;">
164
                <ul class="pagination">
165
                    <li><a href=" #">&laquo;</a></li>
166
                    <li><a href="#">1</a></li>
167
                    <li><a href="#">2</a></li>
168
                    <li><a href="#">3</a></li>
169
                    <li><a href="#">4</a></li>
170
                    <li><a href="#">5</a></li>
171
                    <li><a href="#">&raquo;</a></li>
172
                </ul>
173
            </div> -->
174
            <!-- <div style="margin-left:50px;">
175
                <div class="row" style="margin:0 auto;">
176
                    <span class="col-md-1" style="line-height: 40px;margin-right:50px;">制表:</span>
177
                    <span class="col-md-1" style="line-height: 40px;margin-right:50px;">复核:</span>
178
                    <span class="col-md-1" style="line-height: 40px;margin-right:50px;">审批:</span>
179
                    <span class="col-md-1" style="line-height: 40px;margin-right:50px;">制表:</span>
180
                </div>
181
                <div class="row" style="margin:0 auto;">
182
                    <span class="col-md-1" style="line-height: 40px;margin-right:50px;">日期:</span>
183
                    <span class="col-md-1" style="line-height: 40px;margin-right:50px;">日期:</span>
184
                    <span class="col-md-1" style="line-height: 40px;margin-right:50px;">日期:</span>
185
                    <span class="col-md-1" style="line-height: 40px;margin-right:50px;">日期:</span>
186
                </div>
187
            </div> -->
163 188
        </div>
164
        <!-- <div style="text-align:right;">
165
            <ul class="pagination">
166
                <li><a href=" #">&laquo;</a></li>
167
                <li><a href="#">1</a></li>
168
                <li><a href="#">2</a></li>
169
                <li><a href="#">3</a></li>
170
                <li><a href="#">4</a></li>
171
                <li><a href="#">5</a></li>
172
                <li><a href="#">&raquo;</a></li>
173
            </ul>
174
        </div> -->
175
        <!-- <div class="footer" style="width: 1600px;">
176
            <div class="row text_center" style="margin:0 auto;">
177
                <div class="col-md-2" style="line-height: 40px;">制表:</div>
178
                <div class="col-md-2" style="line-height: 40px;">复核:</div>
179
                <div class="col-md-2" style="line-height: 40px;">审批:</div>
180
                <div class="col-md-2" style="line-height: 40px;">制表:</div>
181
                <div class="col-md-2" style="line-height: 40px;">日期:</div>
182
                <div class="col-md-2" style="line-height: 40px;">日期:</div>
183
                <div class="col-md-2" style="line-height: 40px;">日期:</div>
184
                <div class="col-md-2" style="line-height: 40px;">日期:</div>
185
            </div>
186
        </div> -->
187
        <?php include_once(__DIR__ . DS . 'input.php'); ?>
189
        <?php include_once(__DIR__ . DS . 'input.html'); ?>
188 190
    </div>
189 191
190 192
    <script>

+ 11 - 10
application/index/view/commission/input.php

@ -264,7 +264,8 @@ function edit(id) {
264 264
        success: function(res) {
265 265
            if (res.code == 0) {
266 266
                dataForm = res.data;
267
                console.log(dataForm);
267
                // console.log(dataForm.company);
268
                // return  false;
268 269
                $("#id").val(dataForm.id);
269 270
                $('#company').selectpicker('val', dataForm.company);
270 271
                getContractNoByCompany(dataForm.company, dataForm.former_id);
@ -356,6 +357,7 @@ function getContractNoByCompany(company, former_id=0) {
356 357
    var key=1;
357 358
    for (var i=1; i < salesData.length; i++) { 
358 359
        row = salesData[i];
360
        // console.log(row);
359 361
        if (row[3] == company) {
360 362
            option.contract_no = row[12];
361 363
            option.goods_category = row[6];
@ -368,16 +370,15 @@ function getContractNoByCompany(company, former_id=0) {
368 370
            option.former_id = row[0];
369 371
            conpanySalesData[key] = option;
370 372
            if (option.former_id == former_id) {
371
                str += '<option value="' + key + '" selected>' + option.contract_no +','+option.goods_category+','+ option.goods_type+','+ option.amount+','+ option.price+','+ option.contract_value+'</option>';
373
                str += '<option value="' + key + '" selected>'+ option.former_id +','+ option.contract_no +','+option.goods_category+','+ option.goods_type+','+ option.amount+','+ option.price+','+ option.contract_value+'</option>';
372 374
            } else {
373
                str += '<option value="' + key + '">' + option.contract_no +','+option.goods_category+','+ option.goods_type+','+ option.amount+','+ option.price+','+ option.contract_value+'</option>';
375
                str += '<option value="' + key + '">'+ option.former_id +','+ option.contract_no +','+option.goods_category+','+ option.goods_type+','+ option.amount+','+ option.price+','+ option.contract_value+'</option>';
374 376
            }
375 377
            key++;
376 378
            option = {};
377 379
        }
378 380
    }
379
380
    $('#conpany_sales_data').html(str)
381
    $('#conpany_sales_data').html(str);
381 382
}
382 383
383 384
// update 上期结余
@ -536,10 +537,7 @@ function doSave() {
536 537
        dataType: 'json',
537 538
        success: function(res) {
538 539
            if (res.code == 0) {
539
                dataForm.id = 0;
540
                $('#id').val(0)
541
                $('#myModal').modal('hide');
542
                $("#market-form")[0].reset();
540
                alert('保存成功');
543 541
                window.location.reload();
544 542
            } else {
545 543
                alert(res.msg);
@ -554,8 +552,11 @@ function updatecahce() {
554 552
}
555 553
556 554
function cel() {
555
    dataForm.id = 0;
556
    $('#id').val(0);
557
    $('#company').selectpicker('val', '');
558
    $('#conpany_sales_data').html('');
557 559
    $('#myModal').modal('hide');
558 560
    $("#market-form")[0].reset();
559
    $('#company').selectpicker('deselectAll');
560 561
}
561 562
</script>

+ 70 - 20
application/index/view/company/index.php

@ -31,18 +31,15 @@
31 31
                <div class="col-md-3 text_center">
32 32
                    <h4>销售单位管理</h4>
33 33
                </div>
34
                <div class="col-md-3" style="text-align:right;">
35
                    <div class="btn-group ">
36
                        <button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">新增</button>
37
                    </div>
38
                </div>
34
                
39 35
            </div>
40 36
            <div class="row">
41 37
                <form action="/index/company/index" method="get">
42
                    <div class="col-md-2">
38
                    <div class="col-md-1">
39
43 40
                    </div>
44
                    <div class="col-md-5 text_center">
45
                        <input type="text" class="form-control" name="company_name" id="company_name" value="<?php echo $company_name;?>" placeholder="请输入公司名称">
41
                    <div class="col-md-4">
42
                        <input type="text" class="form-control" name="key" id="key" value="<?php echo isset($key) ? $key: '';?>" placeholder="请输入公司名称">
46 43
                    </div>
47 44
                    <div class="col-md-3" style="text-align:left;">
48 45
                        <div class="btn-group ">
@ -53,8 +50,13 @@
53 50
                        </div>
54 51
                    </div>
55 52
                </form>
53
                <div class="col-md-3" style="text-align:right;">
54
                    <div class="btn-group ">
55
                        <button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">新增</button>
56
                    </div>
57
                </div>
56 58
            </div>
57
            <div class="col-md-10" style="margin-top: 20px;">
59
            <div class="col-md-12" style="margin-top: 20px;">
58 60
                <table class=" table table-hover table-bordered">
59 61
                    <thead>
60 62
                        <tr>
@ -66,7 +68,7 @@
66 68
                    </thead>
67 69
                    <tbody>
68 70
                        <?php
69
                        foreach ($data as $key => $value) {
71
                        foreach ($data['list'] as $value) {
70 72
                        ?>
71 73
                            <tr>
72 74
                                <td class="text-center"><?php echo $value['id'] ?></td>
@ -74,7 +76,7 @@
74 76
                                <td class="text-center"><?php echo $value['initial_balance'] ?></td>
75 77
                                <td class="text-center">
76 78
                                    <button class="btn btn-primary radius btn-xs" type="button" onClick="modify(<?php echo $value['id']; ?>,'<?php echo $value['name']; ?>','<?php echo $value['initial_balance']; ?>')">修改</button>
77
                                    <button class="btn btn-danger radius btn-xs" type="button" onClick="del(<?php echo $value['id']; ?>)">删除</button></td>
79
                                    <button class="btn btn-danger radius btn-xs" type="button" onClick="del(<?php echo $value['id']; ?>, this)">删除</button></td>
78 80
                            </tr>
79 81
                        <?php
80 82
                        }
@ -83,6 +85,46 @@
83 85
                </table>
84 86
            </div>
85 87
        </div>
88
        <div>
89
            <nav aria-label="Page navigation" class="page_navigation">
90
                <ul class="pagination">
91
                    <li>
92
                        <a href="?page=1<?php echo isset($key) ? '&key='.$key : '';?>">
93
                            <span aria-hidden="true">首页</span>
94
                        </a>
95
                    </li>
96
                    <?php
97
                        $total = $data['total'];
98
                        $page = $data['page'];
99
                        $limit = $data['limit'];
100
                        $pages = intval($total/$limit) + 1;
101
                    ?>
102
                    <li>
103
                        <a href="?page=<?php echo ($page-1)==0 ? 1 : $page-1; ?><?php echo isset($key) ? '&key='.$key : '';?>" aria-label="Previous">
104
                            <span aria-hidden="true">&laquo;</span>
105
                        </a>
106
                    </li>
107
                    <?php
108
                        $li = (($pages - $page) >= 5 ? 4 : $pages - $page) + 1; 
109
                        for ($i=0;$i<$li;$i++) {
110
                    ?>
111
                            <li><a href="?page=<?php echo $i + $page; ?><?php echo isset($key) ? '&key='.$key : '';?>"><?php echo $i + $page; ?></a></li>
112
                    <?php        
113
                        }
114
                    ?>
115
                    <li>
116
                        <a href="?page=<?php echo ($page+1)>=$pages ? $pages : $page+1; ?><?php echo isset($key) ? '&key='.$key : '';?>" aria-label="Next">
117
                            <span aria-hidden="true">&raquo;</span>
118
                        </a>
119
                    </li>
120
                    <li>
121
                        <a href="?page=<?php echo $pages;?><?php echo isset($key) ? '&key='.$key : '';?>">
122
                            <span aria-hidden="true">尾页</span>
123
                        </a>
124
                    </li>
125
                </ul>
126
            </nav>
127
        </div>
86 128
    </div>
87 129
88 130
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
@ -110,6 +152,7 @@
110 152
                                    <input type="text" class="form-control" name="name" id="name" value="" placeholder="公司名称">
111 153
                                </div>
112 154
                            </div>
155
                            <span style='color:red;' id="error_msg"></span>
113 156
                        </div>
114 157
                        <div class="row">
115 158
                            <div class="col-md-2">
@ -126,14 +169,20 @@
126 169
                    </form>
127 170
                </div>
128 171
                <div class="modal-footer">
129
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
130
                    <button type="button" class="btn btn-primary" id="tj">提交</button>
172
                    <button type="button" class="btn btn-default" onclick="closeModel()">关闭</button>
173
                    <button type="button" class="btn btn-primary" onclick="save()">保存</button>
131 174
                </div>
132 175
            </div><!-- /.modal-content -->
133 176
        </div><!-- /.modal -->
134 177
    </div>
135 178
136 179
    <script>
180
        function closeModel() {
181
            $("#error_msg").html('');
182
            $("#company-form")[0].reset();
183
            $('#myModal').modal('hide');
184
        }
185
137 186
        function modify(id, name, initial_balance) {
138 187
            $("#id").val(id);
139 188
            $("#name").val(name);
@ -141,12 +190,13 @@
141 190
            $('#myModal').modal('show');
142 191
        }
143 192
144
        function del(id) {
193
        function del(id, obj) {
145 194
            $.post('/index/company/delete', {
146 195
                'id': id,
147 196
            }, function(res) {
148 197
                if (res.code == 0) {
149
                    window.location.reload();
198
                    $(obj).parents('tr').remove();
199
                    // window.location.reload();
150 200
                } else {
151 201
                    alert(res.msg);
152 202
                }
@ -155,28 +205,28 @@
155 205
            return false;
156 206
        }
157 207
158
        $("#tj").click(function() {
208
        function save(params) {
159 209
            var id = $("#id").val();
160 210
            var name = $("#name").val();
161 211
            var initial_balance = Number($("#initial_balance").val());
162
163 212
            $.post('/index/company/save', {
164 213
                'id': id,
165 214
                'name': name,
166 215
                'initial_balance': initial_balance
167 216
            }, function(res) {
168 217
                if (res.code == 0) {
218
                    alert('保存成功');
169 219
                    $('#myModal').modal('hide');
170 220
                    $("#company-form")[0].reset();
171 221
                    window.location.reload();
172 222
                } else {
173
                    // alert(res.msg);
174
                    $("#company-form").children('div:first').append("<span style='color:red;'>" + res.msg + "</span")
223
                    // $("#company-form").children('div:first').append("<span style='color:red;'>" + res.msg + "</span>");
224
                    $("#error_msg").html(res.msg);
175 225
                }
176 226
                return false;
177 227
            }, 'json');
178 228
            return false;
179
        })
229
        }
180 230
    </script>
181 231
182 232
</body>

application/index/view/index/index.php → application/index/view/index/index.html


+ 14 - 6
application/index/view/seller/index.php

@ -80,7 +80,7 @@
80 80
                    </h4>
81 81
                </div>
82 82
                <div class="modal-body">
83
                    <form role="form" id="seller-form">
83
                    <form role="form" id="form-seller">
84 84
                        <input type="hidden" name="id" id="id" value="0">
85 85
                        <div class="row">
86 86
                            <div class="col-md-2">
@ -93,6 +93,7 @@
93 93
                                    <input type="text" class="form-control" name="name" id="name" value="" placeholder="销售员">
94 94
                                </div>
95 95
                            </div>
96
                            <span style='color:red;' id="error_msg"></span>
96 97
                        </div>
97 98
                        <div class="row">
98 99
                            <div class="col-md-2">
@ -112,15 +113,21 @@
112 113
                    </form>
113 114
                </div>
114 115
                <div class="modal-footer">
115
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
116
                    <button type="button" class="btn btn-primary" onclick="doSave()">提交</button>
116
                    <button type="button" class="btn btn-default" onclick="closeModel()">关闭</button>
117
                    <button type="button" class="btn btn-primary" onclick="save()">提交</button>
117 118
                </div>
118 119
            </div><!-- /.modal-content -->
119 120
        </div><!-- /.modal -->
120 121
    </div>
121 122
122 123
    <script>
123
        function doSave() {
124
        function closeModel() {
125
            $("#error_msg").html('');
126
            $("#form-seller")[0].reset();
127
            $('#myModal').modal('hide');
128
        }
129
130
        function save() {
124 131
            var id = $("#id").val();
125 132
            var name = $("#name").val();
126 133
            var department = $("#department").val();
@ -131,12 +138,13 @@
131 138
                'department': department
132 139
            }, function(res) {
133 140
                if (res.code == 0) {
141
                    alert('保存成功');
134 142
                    $('#myModal').modal('hide');
135 143
                    $("#seller-form")[0].reset();
136 144
                    window.location.reload();
137 145
                } else {
138
                    // alert(res.msg);
139
                    $("#seller-form").children('div:first').append("<span style='color:red;'>" + res.msg + "</span")
146
                    // $("#seller-form").children('div:first').append("<span style='color:red;'>" + res.msg + "</span");
147
                    $("#error_msg").html(res.msg);
140 148
                }
141 149
                return false;
142 150
            }, 'json');

+ 0 - 170
daswork/main/App.php

@ -25,173 +25,3 @@ class App{
25 25
        Config::load();
26 26
    }
27 27
}
28
29
30
    // /**
31
    //  * 执行应用程序
32
    //  * @access public
33
    //  * @param Request $request Request对象
34
    //  * @return Response
35
    //  * @throws Exception
36
    //  */
37
    // public static function run(Request $request = null)
38
    // {
39
    //     is_null($request) && $request = Request::instance();
40
41
    //     try {
42
    //         $config = self::initCommon();
43
    //         if (defined('BIND_MODULE')) {
44
    //             // 模块/控制器绑定
45
    //             BIND_MODULE && Route::bind(BIND_MODULE);
46
    //         } elseif ($config['auto_bind_module']) {
47
    //             // 入口自动绑定
48
    //             $name = pathinfo($request->baseFile(), PATHINFO_FILENAME);
49
    //             if ($name && 'index' != $name && is_dir(APP_PATH . $name)) {
50
    //                 Route::bind($name);
51
    //             }
52
    //         }
53
54
    //         $request->filter($config['default_filter']);
55
56
    //         // 默认语言
57
    //         Lang::range($config['default_lang']);
58
    //         if ($config['lang_switch_on']) {
59
    //             // 开启多语言机制 检测当前语言
60
    //             Lang::detect();
61
    //         }
62
    //         $request->langset(Lang::range());
63
64
    //         // 加载系统语言包
65
    //         Lang::load([
66
    //             THINK_PATH . 'lang' . DS . $request->langset() . EXT,
67
    //             APP_PATH . 'lang' . DS . $request->langset() . EXT,
68
    //         ]);
69
70
    //         // 获取应用调度信息
71
    //         $dispatch = self::$dispatch;
72
    //         if (empty($dispatch)) {
73
    //             // 进行URL路由检测
74
    //             $dispatch = self::routeCheck($request, $config);
75
    //         }
76
    //         // 记录当前调度信息
77
    //         $request->dispatch($dispatch);
78
79
    //         // 记录路由和请求信息
80
    //         if (self::$debug) {
81
    //             Log::record('[ ROUTE ] ' . var_export($dispatch, true), 'info');
82
    //             Log::record('[ HEADER ] ' . var_export($request->header(), true), 'info');
83
    //             Log::record('[ PARAM ] ' . var_export($request->param(), true), 'info');
84
    //         }
85
86
    //         // 监听app_begin
87
    //         Hook::listen('app_begin', $dispatch);
88
    //         // 请求缓存检查
89
    //         $request->cache($config['request_cache'], $config['request_cache_expire'], $config['request_cache_except']);
90
91
    //         $data = self::exec($dispatch, $config);
92
    //     } catch (HttpResponseException $exception) {
93
    //         $data = $exception->getResponse();
94
    //     }
95
96
    //     // 清空类的实例化
97
    //     Loader::clearInstance();
98
99
    //     // 输出数据到客户端
100
    //     if ($data instanceof Response) {
101
    //         $response = $data;
102
    //     } elseif (!is_null($data)) {
103
    //         // 默认自动识别响应输出类型
104
    //         $isAjax   = $request->isAjax();
105
    //         $type     = $isAjax ? Config::get('default_ajax_return') : Config::get('default_return_type');
106
    //         $response = Response::create($data, $type);
107
    //     } else {
108
    //         $response = Response::create();
109
    //     }
110
111
    //     // 监听app_end
112
    //     Hook::listen('app_end', $response);
113
114
    //     return $response;
115
    // }
116
117
    // <?php
118
    // namespace daswork;
119
    
120
    // class Daswork{
121
    //     static $config;
122
        
123
    //     static function run(){
124
    //         // self::init_path();
125
    //         // self::init_autoload();		//加载文件
126
    //         self::config();
127
    //         self::dispatch();
128
    //     }
129
    
130
    // // 加载配置文件
131
    //     static function config(){
132
    //         self::$config = require(APP_PATH.'/config.php');
133
    //     }
134
    // // 获取当前url
135
    //     static function get_url()
136
    //     {
137
    //         $default_m = self::$config['conf_url']['m'];
138
    //         $default_c = self::$config['conf_url']['c'];
139
    //         $default_a = self::$config['conf_url']['a'];
140
    
141
    //         $request_url =strtolower( $_SERVER['REQUEST_URI'] );
142
    
143
    //         $url = array();
144
    //         $real_url = array();
145
    //         $array_url=explode('/',$request_url);
146
    //         foreach($array_url as $v){
147
    //             if($v != ''){
148
    //                 $url[] = $v;
149
    //             }
150
    //         }
151
            
152
    //         // var_dump($url);exit;
153
    //         $url_count = count($url);
154
    //         switch ($url_count) {
155
    //             case 0:
156
    //                 $real_url['m'] = $default_m;
157
    //                 $real_url['c'] = $default_c;
158
    //                 $real_url['a'] = $default_a;
159
    //                 break;
160
    //             case 1:
161
    //                 $real_url['m'] = $url[0];
162
    //                 $real_url['c'] = $default_c;
163
    //                 $real_url['a'] = $default_a;
164
    //                 break;
165
                    
166
    //             case 2:
167
    //                 $real_url['m'] = $url[0];
168
    //                 $real_url['c'] = $url[1];
169
    //                 $real_url['a'] = $default_a;
170
    //                 break;
171
    //             default:
172
    //                 $real_url['m']  = $url[0];
173
    //                 $real_url['c']  = $url[1];
174
    //                 $real_url['a']  = $url[2];
175
    //                 break;
176
    //         }
177
    //         // var_dump($real_url);
178
    //         return $real_url;
179
    //     }
180
    
181
    //     //加载类并实例化,调用指定方法
182
    //     static function dispatch(){
183
    //         $real_url =self::get_url();
184
    //         define("MODULE",$real_url['m']);
185
    //         define("CONTROLLER",ucwords($real_url['c']));
186
    //         define("ACTION",$real_url['a']);
187
    
188
    //         require_once(APP_PATH.'/'.MODULE.'/controller/'.CONTROLLER.'.php');
189
    
190
    //         //需要加上命名空间
191
    //         $classname = '\app\\'.MODULE.'\controller\\'.CONTROLLER;
192
    //         $a = ACTION;
193
    //         $controller = new $classname; //控制器
194
    
195
    //         return $controller->$a(); // 调用指定方法
196
    //     }
197
    // }

+ 2 - 2
daswork/main/Controller.php

@ -11,9 +11,9 @@ class Controller
11 11
		$this->view = new View();
12 12
	}
13 13
	
14
	public function fetch($file=""){
14
	public function fetch($file = ""){
15 15
16
		return $this->view->fetch();
16
		return $this->view->fetch($file);
17 17
	}
18 18
19 19
	public function assign($name,$value)

+ 4 - 109
daswork/main/Model.php

@ -4,116 +4,11 @@ class Model
4 4
{
5 5
	protected $db;
6 6
	
7
	function __construct(){
8
		
9
		//$this->db = mysqlidb::getInstance();
10
		$this->db = new MysqlidbModel();
11
	}
12
	
13
	function add($data){
14
		
15
		//列名数组
16
		$cols=array();
17
		//列值数组
18
		$vals=array();
19
		
20
		foreach($data as $key=>$val){
21
			$cols[]="`".$key."`"; 
22
			$vals[]="'".$val."'";
23
		}
24
		
25
		//$cols=array(0=>'`titlekey`',1=>'`contentkey`'); //
26
		//$vals=array(0=>"'titleval'",1=>"'contentval'"); //
27
		
28
		
29
		//用","将数组每个元素重新拼接起来
30
		$str_cols=implode(',',$cols);  //$str_cols=  `titlekey`,`contentkey` 
31
		$str_vals=implode(',',$vals);  //$str_vals=  'titleval','contentval'
32
		
33
		//执行插入数据
34
		$sql="insert into ".$this->tablename."($str_cols) values($str_vals);";
35
		
36
		return $this->db->insert($sql );
37
	}
38
	
39
	
40
	function update($data,$where){
41
		
42
		
43
		$wherestr = '';
44
		if(!empty($where)){
45
			$wherestr .=' where '.$where;
46
		}
47
		
48
		$par_array=array();
49
		foreach($data as $key=>$val){
50
			$par_array[]="`".$key."`="."'".$val."'";
51
		}
52
		
53
		//用","将修改列和列值的数组里每个元素重新拼接起来
54
		$param=implode(',',$par_array); 
55
			
56
		$sql = "update ".$this->tablename." set ".$param." ".$wherestr." ";
57
		
58
		return $this->db->query($sql);
59
		
60
	}
61
	
62
	function get_lists($where, $limit=''){
63
		
64
		$wherestr = '';
65
		if(!empty($where)){
66
			$wherestr .=' where '.$where;
67
		}
68
		$sql = 'select * from '.$this->tablename.$wherestr . $limit;
69
//		echo $sql;
70
		return $this->db->select($sql);
7
	public function __construct(){
8
		$this->db = new \mysqli('localhost', 'root', 'root001', 'test');
71 9
	}
72 10
73
	function get_sum($where){
74
		$wherestr = '';
75
		if(!empty($where)){
76
			$wherestr .=' where '.$where;
77
		}
78
		
79
		$sql = "select count(*) as sum from ".$this->tablename.$wherestr;
80
		
81
		$data = $this->db->get_row($sql);
82
		
83
		return $data['sum'];
84
	}
85
	
86
	
87
	
88
	function get_one($where){
89
		
90
		$wherestr = '';
91
		if(!empty($where)){
92
			$wherestr .=' where '.$where;
93
		}
94
		
95
		$sql = "select * from ".$this->tablename.$wherestr;
96
		
97
		//var_dump($sql);exit;
98
		
99
		$data = $this->db->get_row($sql);
100
		
101
		return $data;
102
	}
103
	
104
	function del($where){
105
		
106
		$wherestr = '';
107
		if(!empty($where)){
108
			$wherestr .=' where '.$where;
109
		}
110
		
111
		
112
		$sql = "delete from  ".$this->tablename.$wherestr;
113
		//echo $sql;exit;
114
		$flag = $this->db->query($sql);
115
		
116
		return $flag;
117
		
11
	public function query($sql) {
12
		return $this->db->query($sql);
118 13
	}
119 14
}

+ 2 - 2
daswork/main/View.php

@ -28,7 +28,7 @@ class View
28 28
    //     }
29 29
    // }
30 30
31
    public function fetch($file=""){
31
    public function fetch($file = ""){
32 32
        if (!empty($this->assign)) {
33 33
            extract($this->assign);
34 34
        }
@ -36,7 +36,7 @@ class View
36 36
            $namearary = explode(".",$file);
37 37
            $typename = end($namearary);
38 38
            if(!in_array($typename,['html','tpl','htm','php'] )){
39
                $file=$file . '.' . TPL;
39
                $file = $file . '.' . TPL;
40 40
            }
41 41
            
42 42
            $filename = APP_PATH."/".$GLOBALS['model']."/view/" . strtolower($GLOBALS['ctrl']) . "/".$file;

+ 2 - 2
daswork/start.php

@ -3,7 +3,7 @@ namespace daswork;
3 3
4 4
//定义系统常量
5 5
define('EXT', '.php');
6
define('TPL', '.php');
6
define('TPL', '.html');
7 7
define("DS", DIRECTORY_SEPARATOR);
8 8
define("DAS_PATH", __DIR__);
9 9
define("CORE_PATH", DAS_PATH . DS . "main" . DS);
@ -20,7 +20,7 @@ define('IS_WIN', strpos(PHP_OS, 'WIN') !== false);
20 20
require CORE_PATH . 'Loader.php';
21 21
// 注册自动加载
22 22
\daswork\Loader::register();
23
// 加载函数库
23
// 加载公共函数库
24 24
require CORE_PATH . "common" . DS . "function.php";
25 25
26 26
// 执行应用

+ 46 - 28
public/static/css/index.css

@ -1,54 +1,72 @@
1 1
.wrap {
2
  width: 1300px;
3
  /* margin: 0 auto; */
4
  margin-left: 20px;
2
    width: 1400px;
3
    /* margin: 0 auto; */
4
    margin-left: 10px;
5 5
}
6
6 7
.header {
7
  line-height: 60px;
8
  box-sizing: border-box;
8
    line-height: 60px;
9
    box-sizing: border-box;
9 10
}
11
10 12
.header span {
11
  margin-right: 40px;
12
  color: black;
13
  font-size: 20px;
13
    margin-right: 40px;
14
    color: black;
15
    font-size: 20px;
14 16
}
17
15 18
.aside {
16
  width: 150px;
17
  margin-top: 50px;
18
  float: left;
19
    width: 150px;
20
    margin-top: 50px;
21
    float: left;
19 22
}
20
.aside div{
21
  margin-top:30px;
23
24
.aside div {
25
    margin-top: 30px;
22 26
}
27
23 28
.time {
24
  line-height: 50px;
29
    line-height: 50px;
25 30
}
31
26 32
.content {
27
  width: 1060px;
28
  /* height: 300px; */
29
  margin-top: 30px;
30
  float: left;
33
    width: 1200px;
34
    /* height: 300px; */
35
    margin-top: 30px;
36
    float: left;
31 37
}
38
32 39
.content a {
33
  display: inline-block;
34
  width: 100%;
35
  line-height: 60px;
40
    display: inline-block;
41
    width: 100%;
42
    line-height: 60px;
36 43
}
44
37 45
.footer {
38
  height: 300px;
46
    height: 300px;
39 47
}
48
40 49
.footer .col-md {
41
  text-align: center ;
50
    text-align: center;
42 51
}
52
43 53
.text_center {
44
  text-align: center;
54
    text-align: center;
45 55
}
56
46 57
.content_nav {
47
  height: 100%;
58
    height: 100%;
48 59
}
49
.table > tbody > tr > th {
50
  line-height: 30px;
60
61
.table>tbody>tr>th {
62
    line-height: 30px;
51 63
}
64
52 65
.modal-content {
53
  width: 800px;
66
    width: 800px;
54 67
}
68
69
.page_navigation {
70
    float: right;
71
}
72

+ 1 - 1
public/static/js/init.js

@ -20,7 +20,7 @@ function storageSalesData(refresh = false) {
20 20
    console.log(refresh);
21 21
    $.ajax({
22 22
        url: "/index/index/sales_data",
23
        // async: false, //改为同步方式 
23
        // async: false, //改为同步方式
24 24
        type: "post",
25 25
        data: {},
26 26
        dataType: 'json',