Ejemplo n.º 1
0
 public function store(Request $request)
 {
     $object = new Model();
     $params = $request->only('email', 'locale', 'type');
     $filter = $object->validator($params);
     if ($filter->fails()) {
         return $this->responseAnswer(true, $params, $filter->errors());
     }
     $delivery = $object->findByEmail($params['email']);
     if (count($delivery)) {
         $delivery->locale = $params['locale'];
         $delivery->{$params}['type'] = 1;
     } else {
         $delivery = new Model();
         $delivery->email = $params['email'];
         $delivery->locale = $params['locale'];
         $delivery->{$params}['type'] = 1;
     }
     $delivery->save();
     if ($request->ajax()) {
         return $this->responseAnswer(false, [$delivery, 'message' => trans('front-end' . DS . 'info' . DS . $params['type'] . '.delivery')]);
     } else {
         return redirect()->back();
     }
 }
Ejemplo n.º 2
0
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function order()
 {
     $data = Input::all();
     $pay = Pay_method::where('pseudo_name', $data['payment'])->firstOrFail();
     $delivery = Delivery::where('pseudo_name', $data['delivery'])->firstOrFail();
     $order = new Order();
     $order->name = $data['name'];
     $order->telephone = $data['phone'];
     $order->adress = $data['address'];
     $order->email = $data['email'];
     $order->payment_method_id = $pay->id;
     $order->delivery_id = $delivery->id;
     $order->comment = $data['info'];
     $order->status = 'new';
     $order->total_cost = $data['sum'];
     $order->save();
     foreach ($data['cart'] as $name => $value) {
         $prod = Product::where('pseudo_name', $name)->firstOrFail();
         $ord_prod = new OrderProduct();
         $ord_prod->product_id = $prod->id;
         $ord_prod->count = $value;
         $ord_prod->order_id = $order->id;
         $ord_prod->save();
     }
     Mail::send('emails.order_success', ['data' => $data], function ($message) {
         $message->setEncoder(Swift_Encoding::get8BitEncoding());
         $message->to('*****@*****.**', 'John Smith')->subject('New order!');
     });
     return 1;
 }
Ejemplo n.º 3
0
 public function destroy($id)
 {
     $object = Model::find($id);
     if ($object) {
         $object->delete();
     }
     return redirect()->back();
 }
Ejemplo n.º 4
0
 public function store()
 {
     $idDeliveryArray = Input::get('arrayFinance');
     $stek = [];
     $sum = 0;
     $waybillCount = 0;
     $i = 0;
     foreach ($idDeliveryArray as $id) {
         $delivery = Delivery::find($id);
         $stek[$i][0] = $delivery->client->name;
         $stek[$i][1] = $delivery->first_payment_amount;
         $stek[$i][2] = $delivery->registry;
         $stek[$i][3] = $delivery->date_of_registry;
         $stek[$i][4] = $delivery->id;
         $i++;
     }
     $size = count($stek);
     if ($size > 1) {
         usort($stek, function ($a, $b) {
             return $a[2] - $b[2];
         });
     }
     $keyStek = [];
     $client = $stek[0][0];
     $sum = (double) $stek[0][1];
     $number_of_waybill = 1;
     $registry = $stek[0][2];
     $date_of_registry = $stek[0][3];
     array_push($keyStek, $stek[0][4]);
     if ($size > 1) {
         for ($i = 1; $i < $size; $i++) {
             if ($registry === $stek[$i][2]) {
                 $sum = $sum + (double) $stek[$i][1];
                 $number_of_waybill++;
                 array_push($keyStek, $stek[$i][4]);
                 if ($i === $size - 1) {
                     $this->saveFinance($client, $sum, $number_of_waybill, $registry, $date_of_registry, $keyStek);
                 }
             } else {
                 $this->saveFinance($client, $sum, $number_of_waybill, $registry, $date_of_registry, $keyStek);
                 $keyStek = [];
                 $size = count($stek);
                 $client = $stek[$i][0];
                 $sum = (double) $stek[$i][1];
                 $number_of_waybill = 1;
                 $registry = $stek[$i][2];
                 $date_of_registry = $stek[$i][3];
                 array_push($keyStek, $stek[$i][4]);
                 if ($i === $size - 1) {
                     $this->saveFinance($client, $sum, $number_of_waybill, $registry, $date_of_registry, $keyStek);
                 }
             }
         }
     } else {
         $this->saveFinance($client, $sum, $number_of_waybill, $registry, $date_of_registry, $keyStek);
     }
 }
Ejemplo n.º 5
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(StoreVimeoRequest $request)
 {
     $values = $this->getFieldValues($request->all());
     $delivery = Delivery::firstOrCreate(['dipID' => $values['id'], 'name' => $values['name']]);
     $delivery->status = isset($delivery->status) ? $delivery->status : 0;
     $vimeo = new Vimeo($values);
     $delivery->vimeo()->save($vimeo);
     return $delivery->vimeo;
 }
 public function getFilterData()
 {
     $client_id = Input::get('ClientId');
     $debtor_id = Input::get('DebtorId');
     $status = Input::get('Status');
     $deliveries = Delivery::where('status', '=', 'Профинансирована');
     if ($status == 1) {
         $deliveries->where('state', true);
     }
     if ($status == 2) {
         $deliveries->where('state', false);
     }
     $commissions = array();
     if (!empty($client_id)) {
         $deliveries->where('client_id', '=', $client_id);
     }
     if (!empty($debtor_id)) {
         $deliveries->where('debtor_id', '=', $debtor_id);
     }
     //$ChargeCommission->delivery()->orderBy('waybill');
     $deliveries = $deliveries->get();
     $view = view('chargeCommission.tableRow', ['deliveries' => $deliveries])->render();
     $callback = 'success';
     return $view;
 }
Ejemplo n.º 7
0
 public function buy(Delivery $delivery, OrderController $orderController, OrderItemController $orderItemController, SendMailController $sendMailController)
 {
     $products = Input::get('basked');
     $deliveryId = Input::get('deliveryId');
     $deliveryInfo = $delivery->getPriceDelivery($deliveryId);
     $user = Input::get('user');
     $info = $orderController->Order($user, $deliveryInfo, $products, $orderItemController);
     $id = $info['id'];
     Session::forget('product');
     Session::forget('bascedCount');
     $sendMailController->checkMail($user, $info, $deliveryInfo);
     return $id;
 }
Ejemplo n.º 8
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $delivery = (new Delivery())->find($id);
     if (!$delivery) {
         return;
     }
     $vimeo = $delivery->vimeo;
     Vimeo::destroy($vimeo['id']);
     Event::where('deliveryID', '=', $id)->delete();
     return Delivery::destroy($delivery['id']);
 }
Ejemplo n.º 9
0
 public function getPopapDelivery()
 {
     $data = Input::get('data');
     $deliveries = [];
     $messageArray = [];
     $relationId = Delivery::find($data[0])->relation_id;
     $stop = false;
     foreach ($data as $id) {
         $delivery = Delivery::find($id);
         if ($delivery->relation_id != $relationId) {
             $stop = true;
         }
         array_push($deliveries, $delivery);
     }
     if ($stop == false) {
         $callback = 'success';
         $messageShot = '';
         $message = '';
         $data = view('delivery.verificationModalRow', ['deliveries' => $deliveries])->render();
     } else {
         $callback = 'danger';
         $messageShot = 'Ошибка! ';
         $message = 'Выбраны поставки по разным связям!';
         $data = '';
     }
     $messageArray = ['callback' => $callback, 'message' => $message, 'message_shot' => $messageShot, 'data' => $data];
     return $messageArray;
 }
Ejemplo n.º 10
0
 public function index(Request $request)
 {
     Carbon::setLocale('ru');
     $clients_filter = Client::whereHas('deliveries', function ($query) {
         $query->where('status', '=', 'Профинансирована');
     })->get();
     if ($request->ajax()) {
         $bills = Bill::where('id', '>', 0);
         if (Input::get('year') != Null) {
             $bills = $bills->whereYear('bill_date', '=', Input::get('year'));
         }
         if (Input::get('month') != Null) {
             $bills = $bills->whereMonth('bill_date', '=', Input::get('month'));
         }
         if (Input::get('client_id') != 'all') {
             $bills = $bills->where('client_id', '=', Input::get('client_id'));
         }
         $sum = array();
         $sum['without_nds'] = $bills->sum('without_nds');
         $sum['nds'] = $bills->sum('nds');
         $sum['with_nds'] = $bills->sum('with_nds');
         $bills = $bills->get();
         $clients = Client::All();
         $debts_full = array();
         $monthRepayment = array();
         $bill_date_first_day = Carbon::createFromDate(Input::get('year'), Input::get('month'), 1);
         foreach ($clients as $client) {
             foreach ($client->agreements as $agreement) {
                 $debt = 0;
                 foreach ($agreement->relations as $relation) {
                     if ($agreement->account == FALSE) {
                         foreach ($relation->deliveries as $delivery) {
                             if ($delivery->status == 'Профинансирована') {
                                 //echo $client->name.": долг перед месяцем:";
                                 $pred_with_nds = $delivery->dailyChargeCommission()->where('handler', false)->whereDate('created_at', '<', $bill_date_first_day)->sum('with_nds');
                                 // var_dump($pred_with_nds);
                                 // echo $client->name.": погашения:";
                                 $repayments = $delivery->dailyChargeCommission()->where('handler', true)->sum('with_nds');
                                 // var_dump($repayments);echo $client->name.": начисленные комиссии:";
                                 $with_nds_delivery = $delivery->dailyChargeCommission()->where('handler', false)->whereYear('created_at', '=', Input::get('year'))->whereMonth('created_at', '=', Input::get('month'))->sum('with_nds');
                                 // var_dump($with_nds_delivery);
                                 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;
                                 }
                                 // echo $client->name.": текущий долг:";
                                 // var_dump($debt);
                                 // echo "\n";
                             }
                         }
                     } else {
                         $debt = 0;
                     }
                 }
                 // var_dump($debt);
                 $monthRepayment[$agreement->id] = $debt;
             }
         }
         // var_dump($monthRepayment);
         $stop = Delivery::where('stop_commission', '=', true)->get();
         return view('invoicing.indexAjax', ['stop' => $stop, 'bills' => $bills, 'debts_full' => $debts_full, 'monthRepayment' => $monthRepayment, 'sum' => $sum]);
     } else {
         $dt = Carbon::now()->startOfMonth();
         $dates = DailyChargeCommission::select('created_at')->whereDate('created_at', '<', $dt)->orderBy('created_at', 'desc')->groupBy('created_at')->get();
         $year = '';
         $month = '';
         $i_month = 0;
         $i_year = 0;
         $dates_for_filter = array();
         foreach ($dates as $date) {
             $dates_for_filter[$date->created_at->year][$date->created_at->month] = $date->created_at->month;
         }
         return view('invoicing.index', ['clients' => $clients_filter, 'dt' => $dates_for_filter]);
     }
 }
Ejemplo n.º 11
0
 public function createDailyCharge($dailyArray, $deliveryId, $repaymentId, $handler)
 {
     $daily = new DailyChargeCommission();
     $delivery = Delivery::find($deliveryId);
     $repayment = Repayment::find($repaymentId);
     $daily->delivery_id = $delivery->id;
     $daily->charge_commission_id = $delivery->chargeCommission->id;
     $daily->fixed_charge = $dailyArray['dailyFixed'];
     $daily->percent = $dailyArray['dailyPercent'];
     $daily->udz = $dailyArray['dailyUdz'];
     $daily->deferment_penalty = $dailyArray['dailyDeferment'];
     $daily->nds = $dailyArray['dailyNds'];
     $daily->without_nds = $dailyArray['dailyWithoutNds'];
     $daily->with_nds = $dailyArray['dailyWithNds'];
     $daily->handler = $handler;
     $daily->fixed_charge_nds = $dailyArray['dailyFixedNds'];
     $daily->percent_nds = $dailyArray['dailyPercentNds'];
     $daily->udz_nds = $dailyArray['dailyUdzNds'];
     $daily->deferment_penalty_nds = $dailyArray['dailyDefermentNds'];
     if ($handler == true) {
         $daily->created_at = $repayment->date;
         $daily->repayment_id = $repaymentId;
         $daily->repayment_sum = $dailyArray['dailyRepaymentSum'];
         $daily->first_payment_sum = $dailyArray['dayliFirstPaymentSum'];
         $daily->first_payment_debt_after = $dailyArray['dayliFirstPaymentDebtAfter'];
         $daily->first_payment_debt_before = $dailyArray['dayliFirstPaymentDebtBefore'];
         $daily->balance_owed_after = $dailyArray['dayliBalanceOwedAfter'];
         $daily->to_client = $dailyArray['dayliToClient'];
         $daily->type_of_payment = $dailyArray['dailyTypeOfPayment'];
     } else {
         $daily->created_at = $dailyArray['dateNow'];
     }
     $daily->save();
 }
Ejemplo n.º 12
0
 public function run()
 {
     DB::table('deliveries')->delete();
     Delivery::create(['name' => 'доставка курьером по адресу', 'pseudo_name' => 'courier']);
     Delivery::create(['name' => 'самовывоз', 'pseudo_name' => 'pickup']);
 }
Ejemplo n.º 13
0
 public function setDeliveries($dateNow)
 {
     $deliveries = Delivery::where('state', false)->get();
     foreach ($deliveries as $delivery) {
         //Сегодняшнее число
         $dateOfRecourse = new Carbon($delivery->date_of_recourse);
         $actualDeferment = $dateOfRecourse->diffInDays($dateNow, false);
         //Фактическая просрочка
         $delivery->the_actual_deferment = $actualDeferment;
         $delivery->save();
     }
 }