ayHaru vor 4 Jahren
Ursprung
Commit
0f3048449a
2 geänderte Dateien mit 48 neuen und 30 gelöschten Zeilen
  1. 28 2
      admin/control/merchant.php
  2. 20 28
      admin/templates/default/merchant.orderlimit.php

+ 28 - 2
admin/control/merchant.php

@@ -151,22 +151,48 @@ class merchantControl extends SystemControl
 
     public function orderDayLimitOp()
     {
+        if (chksubmit()) {
+            $mchids = $_POST['mchid'];
+            $petrochinas = $_POST['petrochina'];
+            $sinopecs = $_POST['sinopec'];
+            foreach ($mchids as $key => $mchid) {
+                $data['mchid'] = $mchid;
+                $data['petrochina'] = ['100' => $petrochinas[100][$key] , '200' => $petrochinas[200][$key] , '500' => $petrochinas[500][$key] , '1000' => $petrochinas[1000][$key]];
+                $data['sinopec'] = ['100' => $sinopecs[100][$key] , '200' => $sinopecs[200][$key] , '500' => $sinopecs[500][$key] , '1000' => $sinopecs[1000][$key]];
+                $result[$mchid] = $data;
+            }
+            wcache('order_limit' , ['data' => serialize($result)] , 'merchant-');
+            showMessage('编辑成功', 'index.php?act=merchant&op=merchant');
+        }
         $order_limit = rcache('order_limit' , 'merchant-');
+
         if(empty($order_limit)){
             $order_limit = [];
         }else{
             $order_limit = unserialize($order_limit['data']);
         }
+        $default = function ($merchant) {
+            $amount = [
+                '100' => 0,
+                '200' => 0,
+                '500' => 0,
+                '1000' => 0
+            ];
+            $data['mchid'] = $merchant['mchid'];
+            $data['petrochina'] = $data['sinopec'] = $amount;
+            return $data;
+        };
         $model_merchant = model('merchant');
-        $merchant_list = $model_merchant->getMerchantList([], 1000, 'mchid asc' , 'mchid');
+        $merchant_list = $model_merchant->getMerchantList([], 1000, 'mchid asc' , 'mchid,company_name');
         foreach ($merchant_list as $merchant)
         {
             if(array_key_exists($merchant['mchid'] , $order_limit)) {
                 $result[$merchant['mchid']] = $order_limit[$merchant['mchid']];
             }else{
-
+                $result[$merchant['mchid']] = $default($merchant);
             }
         }
+        Tpl::output('data', $result);
         Tpl::showpage('merchant.orderlimit');
     }
 

+ 20 - 28
admin/templates/default/merchant.orderlimit.php

@@ -99,7 +99,7 @@
                 <table class="spec_table tb-type2" style="width: 800px">
                     <tr class="w500" rowspan="2">
                         <th class="align-center" rowspan="2" style="width: 100px">机构号</th>
-                        <th class="align-center" rowspan="2">机构名称</th>
+<!--                        <th class="align-center" rowspan="2">机构名称</th>-->
                         <th class=" align-center" colspan="6">
                             中石油
                         </th>
@@ -120,50 +120,40 @@
                         <th style="text-align: center">1000</th>
                     </tr>
                     <tbody class="tbody">
+                    <?php if (!empty($output['data']) && is_array($output['data'])) { ?>
+                    <?php foreach ($output['data'] as $k => $v) { ?>
                         <tr class="w500">
                             <td class="w50 align-center">
-                                1
-                            </td>
-                            <td class="w50 align-center">
-                                xyxy
+                                <?php echo $v['mchid'];?>
+                                <input type="hidden" name="mchid[]" value="<?php echo $v['mchid'];?>">
                             </td>
+<!--                            <td class="w50 align-center">-->
+<!--                                --><?php //echo $v['merchant_name'];?>
+<!--                            </td>-->
                             <td class="w50 align-center" style="width:30px">
                             </td>
+                        <?php foreach ($v['petrochina'] as $amount => $limit) { ?>
                             <td class="w50 align-center">
-                                <input type="text" name="spec[]" value="10" style="width:50px">
-                            </td>
-                            <td class="w50 align-center">
-                                <input type="text" name="spec[]" value="10" style="width:50px">
-                            </td>
-                            <td class="w50 align-center">
-                                <input type="text" name="spec[]" value="10" style="width:50px">
-                            </td>
-                            <td class="w50 align-center">
-                                <input type="text" name="spec[]" value="10" style="width:50px">
+                                <input type="text" class="petrochina" name="petrochina[<?php echo $amount;?>][]" value="<?php echo $limit?>" style="width:50px">
                             </td>
+                        <?php } ?>
                             <td class="w50 align-center" style="width:30px">
                             </td>
+                        <?php foreach ($v['sinopec'] as $amount => $limit) { ?>
                             <td class="w50 align-center">
-                                <input type="text" name="spec[]" value="10" style="width:50px">
-                            </td>
-                            <td class="w50 align-center">
-                                <input type="text" name="spec[]" value="10" style="width:50px">
-                            </td>
-                            <td class="w50 align-center">
-                                <input type="text" name="spec[]" value="10" style="width:50px">
-                            </td>
-                            <td class="w50 align-center">
-                                <input type="text" name="spec[]" value="10" style="width:50px">
+                                <input type="text" class="sinopec" name="sinopec[<?php echo $amount;?>][]" value="<?php echo $limit?>" style="width:50px">
                             </td>
+                        <?php } ?>
                         </tr>
+                    <?php } ?>
+                    <?php } ?>
                     </tbody>
                 </table>
             </tr>
             </tbody>
             <tfoot>
             <tr class="tfoot">
-                <td colspan="15"><a href="JavaScript:void(0);" class="btn"
-                                    id="submitBtn"><span><?php echo $lang['nc_submit']; ?></span></a></td>
+                <td colspan="15"><a href="JavaScript:void(0);" class="btn" id="submitBtn"><span><?php echo $lang['nc_submit']; ?></span></a></td>
             </tr>
             </tfoot>
         </table>
@@ -178,6 +168,8 @@
       id="cssfile2"/>
 <script type="text/javascript">
     $(function () {
-
+        $("#submitBtn").click(function () {
+            $("#price_form").submit();
+        })
     });
 </script>