コード例 #1
0
 public function destroy($id)
 {
     $object = Model::find($id);
     if ($object) {
         $object->delete();
     }
     return redirect()->back();
 }
コード例 #2
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);
     }
 }
コード例 #3
0
ファイル: DeliveryController.php プロジェクト: DGZN/monitor
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $delivery = (new Delivery())->find($id)->update($request->all());
     if ($request->get('events')) {
         Event::where('deliveryID', '=', $id)->delete();
         $delivery->activeTask = 'Pending';
         $delivery->save();
     }
     return Delivery::find($id);
 }
コード例 #4
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;
 }
コード例 #5
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();
 }