public function main_data() { $list = $this->data_model->inventory('', 'order by a.id desc'); $qty = 0; //库存数量 $sum = 0; //库存成本 foreach ($list as $arr => $row) { $qty += $row['qty']; $sum += $row['puamount']; } $list1 = $this->data_model->customer_arrears('and month(billdate)=' . date('m') . '', ' order by a.id'); $list2 = $this->data_model->vendor_arrears('and month(billdate)=' . date('m') . '', ' order by a.id'); $arrears1 = 0; //客户欠款 $arrears2 = 0; //供应商欠款 foreach ($list1 as $arr => $row) { $arrears1 += $row['arrears']; } foreach ($list2 as $arr => $row) { $arrears2 += $row['arrears']; } $cost = 0; //购货成本总额 $list3 = $this->data_model->invsa_rate('and month(billdate)=' . date('m') . '', 'and month(a.billdate)=' . date('m') . ''); foreach ($list3 as $arr => $row) { $cost += $row['pu_qty'] * $row['price']; //销售数量*采购单价=成购成本 } $goodsnum = $this->data_model->goodsnum(); //采购商品种类数量 $invpu = $this->cache_model->load_sum(INVPU, '(1=1) and month(billdate)=' . date('m') . '', array('amount', 'arrears')); $invsa = $this->cache_model->load_sum(INVSA, '(1=1) and month(billdate)=' . date('m') . '', array('amount', 'arrears')); $puamount = $invpu ? $invpu['amount'] : 0; $saamount = $invsa ? $invsa['amount'] : 0; $pusarate = $saamount - $cost; $data['status'] = 200; $data['msg'] = 'success'; $data['data']['items'] = array(array('mod' => 'inventory', 'total1' => str_money($qty), 'total2' => str_money($sum)), array('mod' => 'fund', 'total1' => 0, 'total2' => 100), array('mod' => 'contact', 'total1' => str_money($arrears1), 'total2' => str_money($arrears2)), array('mod' => 'sales', 'total1' => str_money($saamount), 'total2' => str_money($pusarate)), array('mod' => 'purchase', 'total1' => str_money($puamount), 'total2' => $goodsnum)); $data['data']['totalsize'] = 4; die(json_encode($data)); }
?> </td> <td width="50" align="center"><?php echo $row['unitname']; ?> </td> <td width="50" align="center"><?php echo str_money(abs($row['qty'])); ?> </td> <td width="50" align="center"><?php echo str_money($row['price']); ?> </td> <td width="50" align="center"><?php echo str_money(abs($row['amount'])); ?> </td> <td width="120"><?php echo $row['description']; ?> </td> </tr> <?php } ?> <?php for ($i = count($data); $i < 13; $i++) { ?> <tr> <td width="100" align="center"> </td>
echo str_money($row1['disamount']); ?> </td> <td colspan="2" >折扣金额:<?php echo str_money($row1['amount']); ?> </td> <td colspan="2" >本次<?php echo $row1['type'] == 1 ? '付款' : '退款'; ?> :<?php echo str_money($row1['rpamount']); ?> </td> <td colspan="2" align="right" >本次欠款: <?php echo str_money($row1['arrears']); ?> </td> </tr> <tr target="id"> <td colspan="8" > 备注:<?php echo $row1['description']; ?> </td> </tr> <tr target="id"> <td>制单人:<?php echo $row1['username']; ?> </td> <td></td>
echo str_money($disamount); ?> </td> <td >折扣金额:<?php echo str_money($amount); ?> </td> <td >本次<?php echo $type == 1 ? '付款' : '退款'; ?> :<?php echo str_money($rpamount); ?> </td> <td >本次欠款: <?php echo str_money($arrears); ?> </td> </tr> <tr target="id"> <td height="30" colspan="8" > 备注:<?php echo $description; ?> </td> </tr> <tr target="id"> <td>制单人:<?php echo $username; ?> </td> <td>收货人签字: </td>
echo str_money($row['puamount']); ?> </td> </tr> <?php } ?> <tr> <td colspan="4" class="R B">合计</td> <td class="R B"><?php echo str_money($qty); ?> </td> <td class="R B"><?php echo str_money($sum); ?> </td> </tr> </tbody> </table> </div> </div> </div> <script src="<?php echo skin_url(); ?> /js/dist/goodsBalance.js?3"></script>
</td> </tr> <?php $i++; } ?> <tr> <td colspan="3" align="right" >合计:</td> <td ><?php echo str_money($totalqty); ?> </td> <td ></td> <td ><?php echo str_money($totalamount); ?> </td> </tr> </table> <table width="900" border="0"> <tr target="id"> <td height="30" colspan="6" > 备注:<?php echo $description; ?> </td> </tr> <tr target="id"> <td>制单人:<?php
</td> </tr> <?php $qty += $row['qty']; $price += $row['price']; $amount += $row['amount']; } ?> <tr> <td colspan="2" class="R B">合计:</td> <td class="R B"><?php echo $qty; ?> </td> <td class="R B"><?php echo $qty > 0 ? str_money($amount / $qty) : 0; ?> </td> <td class="R B"><?php echo $amount; ?> </td> </tr> </tbody> </table> </div> </div> </div> <script src="<?php echo skin_url(); ?>
echo str_money($row['price']); ?> </td> <td class="R"><?php echo str_money($row['amount']); ?> </td> </tr> <?php $qty += $row['qty']; $price += $row['price']; $amount += $row['amount']; } ?> <tr> <td colspan="8" class="R B">合计:</td> <td class="R B"><?php echo str_money($qty); ?> </td> <td class="R B"><?php echo $qty > 0 ? str_money($amount / $qty) : 0; ?> </td> <td class="R B"><?php echo str_money($amount); ?> </td> </tr> </tbody> </table>
?> </td> <td class="R B"><?php echo str_money(abs($saqty)); ?> </td> <td class="R B"><?php echo str_money(abs($saqtytotal)); ?> </td> <td class="R B"><?php echo str_money(abs($qty)); ?> </td> <td class="R B"><?php echo str_money($qtytotal); ?> </td> </tr> </tbody> </table> </div> </div> </div> <script src="<?php echo skin_url(); ?> /js/dist/goods-flow-summary.js?3"></script>