@extends('admin.template')

@section('content')

<?php 
                  $s_accounts = \App\journeys::all();
                  $total_amount_journey = 0;    

                  foreach($s_accounts as $r)  {
                    $j_net = 0;
                    $j_net = $r->journey_value - $r->journey_cost - $r->fuel_amount;
                    $total_amount_journey = $total_amount_journey + $j_net;
                  }


                  $s_accounts = \App\journeys::all();
                  $journey_cost = 0;    

                  foreach($s_accounts as $r)  {
                    $journey_cost = $journey_cost + $r->journey_cost + $r->driver_cost;
                  }


?>


    <!-- Content Header (Page header) -->
    <section class="content-header">
        <div class="container-fluid">
            <div class="row mb-2">
                <div class="col-sm-6">
                    <h1>ادارة النظام</h1>
                </div>
                <div class="col-sm-6">
                    <ol class="breadcrumb float-sm-right">
                        <li class="breadcrumb-item"><a href="#">الرئيسية</a></li>
                        <li class="breadcrumb-item active">ادارة النظام</li>
                    </ol>
                </div>
            </div>
        </div><!-- /.container-fluid -->
    </section>

    <!-- Main content -->
    <section class="content">
<?php /*
        <div class="error-content" style="margin: 0 30px 0 30px;">
            <h3>
                <i class="fas fa-tachometer-alt" style="color: #609ED8 !important;"></i>
                مرحبا بك في اللوحة الرئيسية لادارة النظام </h3>

            <p style="text-align: justify; width: 70%;">
                من هنا يمكنك ادارة جميع البيانات التي تحتاج اليها من موردين وسيارات وحسابات ... الخ

            </p>


        </div>        <!-- /.error-page --> */ ?>

             <div class="row">


        <!-- ./col -->
        <div class="col-lg-4 col-xs-6">
          <!-- small box -->
          <div class="small-box bg-green">
            <div class="inner" style="text-align: center;">
              <h3>SDG 
                <?php  echo number_format($total_amount_journey); ?> 

              </h3>

              <p>صافي الرحلات</p>
            </div>
            <div class="icon">
              <i class="ion ion-stats-bars"></i>
            </div>
            <a href="/admin/journeys" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a> 
          </div>
        </div>


        <!-- ./col -->
        <div class="col-lg-4 col-xs-6">
          <!-- small box -->
          <div class="small-box bg-yellow">
            <div class="inner" style="text-align: center;">
              <h3>SDG 
                <?php  echo number_format($journey_cost); ?> 
            </h3>

              <p>تكاليف الرحلات</p>
            </div>
            <div class="icon">
              <i class="ion ion-stats-bars"></i>
            </div>
            <a href="/admin/journeys" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a> 
          </div>
        </div>

        <div class="col-lg-4 col-xs-6">

          <div class="small-box bg-red">
            <div class="inner" style="text-align: center;">

                <?php
                  $s_accounts = \App\expenses::all();
                  $total_amount = 0;    

                  foreach($s_accounts as $r)  {
                    $total_amount = $total_amount + $r->expense_price;
                  }
                ?>

              <h3>SDG 
                <?php  echo number_format($total_amount); ?> 
                <sup style="font-size: 20px">  </sup></h3>

              <p>اجمالي المنصرفات</p>
            </div>
            <div class="icon">
              <i class="ion ion-bag"></i>
            </div>
            <a href="/admin/expenses" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a>
          </div>
      </div>


        <div class="col-lg-4 col-xs-6">

          <div class="small-box bg-red">
            <div class="inner" style="text-align: center;">

                <?php
             $s_accounts = \App\special_accounts::where('type','depit')->get();
             //  $s_accounts = \App\special_accounts::all();
                  $total_amount = 0;    

                  foreach($s_accounts as $r)  {
                    $total_amount = $total_amount + $r->amount;
                  }
                ?>

              <h3>SDG 
                <?php  echo number_format($total_amount); ?> 
                <sup style="font-size: 20px">  </sup></h3>

              <p>مجموع الديون</p>
            </div>
            <div class="icon">
              <i class="ion ion-bag"></i>
            </div>
            <a href="/admin/special_accounts" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a>
          </div>
      </div>






              <div class="col-lg-4 col-xs-6">

          <div class="small-box bg-yellow">
            <div class="inner" style="text-align: center;">

                <?php
                  $s_accounts = \App\car_problems::all();
                  $total_amount = 0;    

                  foreach($s_accounts as $r)  {
                    $total_amount = $total_amount + $r->spare_price + $r->mechanic_price;
                  }
                ?>

              <h3>SDG 
                <?php  echo number_format($total_amount); ?> 
                <sup style="font-size: 20px">  </sup></h3>

              <p>مجموع تكلفة صيانة السيارات</p>
            </div>
            <div class="icon">
              <i class="ion ion-bag"></i>
            </div>
            <a href="/admin/car_problems" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a>
          </div>
      </div>







              <div class="col-lg-4 col-xs-6">

          <div class="small-box bg-green">
            <div class="inner" style="text-align: center;">

                <?php
                  $s_accounts = \App\suppliers::all();
                  $kmya = 0;    

                  foreach($s_accounts as $r)  {
                    $kmya = $kmya + $r->quantity;
                  }
                ?>

                <?php
                  $s_accounts = \App\suppliers::all();
                  $total_amount = 0;    

                  foreach($s_accounts as $r)  {
                    $unit_p = ($r->myprice - $r->price) * $r->quantity;
                    $total_amount = $total_amount + $unit_p;
                  }
                ?>

              <h3>
                <span style="font-size: 20px;">SDG 
                <?php  echo number_format($total_amount); ?>  </span>
                
                <sup style="font-size: 16px"> <?php echo "(".number_format($kmya).")"; ?> الكمية </sup></h3>

              <p>أرباح الكميات المشحونة </p>
            </div>
            <div class="icon">
              <i class="ion ion-bag"></i>
            </div>
            <a href="/admin/suppliers" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a>
          </div>
      </div>








      </div>



    </section>
    <!-- /.content -->

@endsection
