コード例 #1
0
 public function update($id)
 {
     $cLog = CollectionLog::find($id);
     $cLog->update(['status' => 'done']);
     return redirect()->action('DashboardController@index');
 }
コード例 #2
0
 public function delivered($id)
 {
     $salesInvoice = SalesInvoice::find($id);
     if ($salesInvoice->Client->payment_terms == "PDC" || $salesInvoice->Client->payment_terms == "PDC 30" || $salesInvoice->Client->payment_terms == "PDC 45" || $salesInvoice->Client->payment_terms == "PDC 60" || $salesInvoice->Client->payment_terms == "PDC 90") {
         $salesInvoice->update(['status' => "Check on Hand", 'date_delivered' => Carbon::now()]);
     } else {
         $salesInvoice->update(['status' => "Delivered", 'date_delivered' => Carbon::now()]);
         if ($salesInvoice->Client->payment_terms == "Cash") {
             $salesInvoice->update(['due_date' => Carbon::now()]);
         } else {
             if ($salesInvoice->Client->payment_terms == "7 Days") {
                 $salesInvoice->update(['due_date' => Carbon::now()->addDays(7)]);
             } else {
                 if ($salesInvoice->Client->payment_terms == "15 Days") {
                     $salesInvoice->update(['due_date' => Carbon::now()->addDays(15)]);
                 } else {
                     if ($salesInvoice->Client->payment_terms == "30 Days") {
                         $salesInvoice->update(['due_date' => Carbon::now()->addDays(30)]);
                     } else {
                         if ($salesInvoice->Client->payment_terms == "45 Days") {
                             $salesInvoice->update(['due_date' => Carbon::now()->addDays(45)]);
                         } else {
                             if ($salesInvoice->Client->payment_terms == "60 Days") {
                                 $salesInvoice->update(['due_date' => Carbon::now()->addDays(60)]);
                             } else {
                                 if ($salesInvoice->Client->payment_terms == "75 Days") {
                                     $salesInvoice->update(['due_date' => Carbon::now()->addDays(75)]);
                                 } else {
                                     if ($salesInvoice->Client->payment_terms == "90 Days") {
                                         $salesInvoice->update(['due_date' => Carbon::now()->addDays(90)]);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     //create 2 collection logs
     $DueDate_Components = DB::SELECT("SELECT YEAR(due_date) as Year, MONTH(due_date) as Month, DAYOFMONTH(due_date) as Day FROM sales_invoices\n                                            WHERE sales_invoices.id = '{$id}'");
     $clientId = $salesInvoice->client_id;
     $status = $salesInvoice->status;
     $mondayOf = Carbon::create($DueDate_Components[0]->Year, $DueDate_Components[0]->Month, $DueDate_Components[0]->Day)->startOfWeek()->subweek();
     $thusOf = Carbon::create($DueDate_Components[0]->Year, $DueDate_Components[0]->Month, $DueDate_Components[0]->Day)->startOfWeek()->addDays(3);
     $siclsId = SalesInvoiceCollectionLog::where('sales_invoice_id', $id)->lists('collection_log_id');
     foreach ($siclsId as $collectionlogIDs) {
         $cLog = CollectionLog::find($collectionlogIDs)->delete();
     }
     $cLog = new CollectionLog();
     $cLog->date = $mondayOf;
     $cLog->action = 'Call and Send SOA';
     $cLog->client_id = $salesInvoice->client_id;
     $cLog->status = 'To Do';
     $cLog->save();
     $sicl = new SalesInvoiceCollectionLog();
     $sicl->sales_invoice_id = $id;
     $sicl->client_id = $cLog->client_id;
     $sicl->collection_log_id = $cLog->id;
     $sicl->save();
     // $collectionToDo = new SalesInvoiceCollectionLog;
     $cLog2 = new CollectionLog();
     $cLog2->date = $thusOf;
     $cLog2->action = 'Confirm Collection';
     $cLog2->client_id = $salesInvoice->client_id;
     $cLog2->status = 'To Do';
     $cLog2->save();
     $sicl2 = new SalesInvoiceCollectionLog();
     $sicl2->sales_invoice_id = $id;
     $sicl2->client_id = $cLog2->client_id;
     $sicl2->collection_log_id = $cLog2->id;
     $sicl2->save();
     Activity::log('Sales Invoice ' . $salesInvoice['si_no'] . ' was delivered');
     return redirect()->action('SalesInvoicesController@index');
 }
コード例 #3
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id, $client_id)
 {
     $sicls = SalesInvoiceCollectionLog::where('sales_invoice_collection_logs.collection_log_id', $id)->delete();
     $cLog = CollectionLog::find($id);
     $cLog->delete();
     return redirect()->action('CollectionLogsController@index', [$client_id]);
 }