本文整理汇总了PHP中app\Client::All方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::All方法的具体用法?PHP Client::All怎么用?PHP Client::All使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Client
的用法示例。
在下文中一共展示了Client::All方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
public function store()
{
$rules = array('year' => 'required', 'month' => 'required');
$validator = Validator::make(Input::all(), $rules);
// process the login
if ($validator->fails()) {
return Redirect::to('invoicing')->withErrors($validator);
} else {
$clients = Client::All();
$bill_date = Input::get('year') . '-' . Input::get('month') . '-' . cal_days_in_month(CAL_GREGORIAN, Input::get('month'), Input::get('year'));
$bill_date_first_day = Carbon::createFromDate(Input::get('year'), Input::get('month'), 1);
$bill_date_last_day = clone $bill_date_first_day;
$bill_date_last_day = $bill_date_last_day->addMonth();
foreach ($clients as $client) {
foreach ($client->agreements as $agreement) {
$nds = 0;
$commission_sum = 0;
$without_nds = 0;
$with_nds = 0;
$debt = 0;
$pred_with_nds = 0;
$with_nds_delivery = 0;
$repayments = 0;
foreach ($agreement->relations as $relation) {
if ($agreement->account == FALSE) {
foreach ($relation->deliveries as $delivery) {
if ($delivery->status == 'Профинансирована') {
$pred_with_nds = $delivery->dailyChargeCommission()->where('handler', false)->whereDate('created_at', '<', $bill_date_first_day)->sum('with_nds');
$repayments = $delivery->dailyChargeCommission()->where('handler', true)->whereDate('created_at', '<', $bill_date_last_day)->sum('with_nds');
$with_nds_delivery = $delivery->dailyChargeCommission()->where('handler', false)->whereYear('created_at', '=', Input::get('year'))->whereMonth('created_at', '=', Input::get('month'))->sum('with_nds');
if ($repayments > $pred_with_nds) {
if ($repayments >= $with_nds_delivery + $pred_with_nds) {
$debt += 0;
} else {
$debt += $with_nds_delivery - ($repayments - $pred_with_nds);
}
} else {
$debt += $with_nds_delivery;
}
$with_nds += $with_nds_delivery;
$nds += $delivery->dailyChargeCommission()->where('handler', false)->whereYear('created_at', '=', Input::get('year'))->whereMonth('created_at', '=', Input::get('month'))->sum('nds');
$without_nds += $delivery->dailyChargeCommission()->where('handler', false)->whereYear('created_at', '=', Input::get('year'))->whereMonth('created_at', '=', Input::get('month'))->sum('without_nds');
$bill_date = Input::get('year') . '-' . Input::get('month') . '-' . cal_days_in_month(CAL_GREGORIAN, Input::get('month'), Input::get('year'));
}
}
} else {
foreach ($relation->deliveries as $delivery) {
if ($delivery->date_of_payment != NULL and $delivery->date_of_payment->year == Input::get('year') and $delivery->date_of_payment->month == Input::get('month') and $delivery->status == 'Профинансирована') {
foreach ($delivery->dailyChargeCommission->where('handler', false) as $commission) {
$nds += $delivery->dailyChargeCommission()->where('handler', false)->sum('nds');
$without_nds += $delivery->dailyChargeCommission()->where('handler', false)->sum('without_nds');
$with_nds += $delivery->dailyChargeCommission()->where('handler', false)->sum('with_nds');
$bill_date = $delivery->date_of_payment;
$debt = 0;
}
}
}
}
}
if ($with_nds != 0) {
$bill = new Bill();
$bill->bill_date = $bill_date;
$bill->agreement_id = $agreement->id;
$bill->nds = $nds;
$bill->with_nds = $with_nds;
$bill->without_nds = $without_nds;
$bill->client_id = $client->id;
$bill->debt = $debt;
$bill->save();
}
}
}
}
}