<?php
namespace Admin\Controller;
class SupplierbalanceLogController extends BaseController{
	public function index(){
		$suppliers_id=I('id');
		$map['id']=$suppliers_id;
		$info=M('Suppliers')->field(true)->where($map)->find();
		$where['suppliers_id']=$suppliers_id;
		$list=$this->lists('SupplierbalanceLog',$where,'id desc');
		$this->assign($info);
		$this->assign('list',$list);
		$this->display();	
	}
	public function re_js(){
		$suppliers_id=I('id');
		$js_money=idtoname($suppliers_id,'Suppliers','onbalance');
		if($js_money <= 0){$this->error('暂无要结算的金额');}
		supplier_balance_log($suppliers_id,1,$js_money,'供货商结算,待结算金额减少','','onbalance');
		$res=supplier_balance_log($suppliers_id,0,$js_money,'供货商结算,营业总额增加','','total_revenues');
		if($res){
			action_log('do_balance', 'Admin', $res, UID);//操作日志
			$this->success('结算成功',U('SupplierbalanceLog/index',array('id'=>$suppliers_id)));
		}else{
			$this->error('结算失败',U('SupplierbalanceLog/index',array('id'=>$suppliers_id)));
		}
		
	
	}

}