/**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $lasts = Last::all();
     foreach ($lasts as $key) {
         $created = new \Carbon\Carbon($key->date);
         $now = \Carbon\Carbon::now();
         $difference = $created->diffInDays($now);
         $key['dateWords'] = $created->format('l, F jS, Y');
         $key['datediff'] = $difference;
     }
     return view('welcome.index', ['lasts' => $lasts]);
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $lasts = Last::all();
     foreach ($lasts as $key) {
         $created = new \Carbon\Carbon($key->date);
         $now = \Carbon\Carbon::now();
         $difference = $created->diffInDays($now);
         $key['dateWords'] = $created->format('l, F jS, Y');
         $key['datediff'] = $difference;
     }
     $now = \Carbon\Carbon::now();
     foreach ($lasts as $l) {
         if ($now > $l->lastNotify) {
             Mail::send('email.daysago', ['l' => $l], function ($m) {
                 $m->from('*****@*****.**', 'The last time @samyerkes...');
                 $m->to('*****@*****.**', 'samyerkes')->subject('Keep going...');
             });
             unset($l->dateWords, $l->datediff);
             $l->lastNotify = \Carbon\Carbon::now()->addDays($l->notifyInteger);
             $l->save();
         }
     }
     echo 'emails sent';
 }
Ejemplo n.º 3
0
 /**
  * Group stream announcements by date and by "-/+" logic.
  *
  * @param string $format Date format for output.
  * @param User $user Show only stream for specific user.
  * @return array
  */
 public function groupedByDate($format, $user = null)
 {
     $output = array();
     $query = $this->announcements()->orderBy('created_at');
     if ($user) {
         $query->where('series_id', '=', $user->announcement_stream)->where('created_at', '>=', $user->announcement_start);
     }
     // Group by date.
     $result = array();
     $count = 0;
     foreach ($query->get() as $a) {
         $date = $a->created_at->format($format);
         $dateKey = $a->created_at->format('Y-m-d');
         if (empty($result[$dateKey])) {
             $day = new stdClass();
             $day->date = $date;
             $day->announcements = array();
             $result[$dateKey] = $day;
         }
         $result[$dateKey]->announcements[] = $a;
         $count++;
     }
     // Add current date if needed.
     $today = new \Carbon\Carbon();
     $todayDate = $today->format($format);
     $dateKey = $today->format('Y-m-d');
     if (empty($result[$dateKey])) {
         $day = new stdClass();
         $day->date = $todayDate;
         $day->announcements = array();
         $result[$dateKey] = $day;
     }
     // Group by "+/-".
     foreach ($result as $date => $data) {
         $announcements = array();
         $currentSet = array();
         foreach ($data->announcements as $a) {
             // If announcement is success add it to currentSet and show it.
             if ($a->success == Announcement::SUCCESS) {
                 $currentSet[] = $a;
                 $announcements[] = $currentSet;
                 $currentSet = array();
                 continue;
             }
             // Add failed to currentSet.
             $currentSet[] = $a;
             // If all 3 are minus set it complete, show it.
             if (count($currentSet) == 3) {
                 $announcements[] = $currentSet;
                 $currentSet = array();
             }
         }
         // Add last 1-2 failed.
         if (!empty($currentSet)) {
             $announcements[] = $currentSet;
         }
         // Build output for date.
         $day = new stdClass();
         $day->date = $data->date;
         $day->announcements = $announcements;
         $output[$date] = $day;
     }
     uksort($output, function ($a, $b) {
         return -strcmp($a, $b);
     });
     $result = array('count' => $count, 'data' => $output);
     return $result;
 }
Ejemplo n.º 4
0
        <th>Acciones</th>

    </tr>
    </thead>
    <tbody class="facturas">


    @foreach($facturas as $f)

        <?php 
$aux = $f->numero;
$aux = strlen($aux);
$aux = 5 - $aux;
$ffin = new \Carbon\Carbon($f->fin);
//Formateamos la fecha fin
$fechaFin = $ffin->format('j-m-Y');
$ffin->subYears(1);
//Formateamos la fecha de inicio
$fechaInicio = new \Carbon\Carbon($f->inicio);
$fechaInicio = $fechaInicio->format('j-m-Y');
?>



        <tr class="factura{{$f->id}}">
            @if($f->serie=="N")
                <td>Manteminiento Nicho</td>
                <td>{{$f->serie}}{{str_repeat("0", $aux)}}{{$f->numero}}-{{substr($f->created_at,0,4)}}</td>
                <td>{{substr($f->inicio,0,4)}}</td>
                <td>{{substr($ffin,0,4)}}</td>
                <td>{{$f->nombre_titular}}</td>
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $spreadsheetPath = \Input::file('statement')->getRealPath();
     $testProcess = \Request::get('test');
     if ($testProcess) {
         $testProcess = true;
         echo "Test Mode - no payment records are being created<br /><br />";
     } else {
         $testProcess = false;
         echo "Live Mode - Payments have been created<br /><br />";
     }
     $reader = new SpreadsheetReader($spreadsheetPath);
     $reader->ChangeSheet(0);
     $stringMatchUsers = User::active()->where('import_match_string', '!=', '')->get();
     $users = User::active()->get();
     echo '<br />' . PHP_EOL;
     echo '<table width="100%">';
     foreach ($reader as $i => $row) {
         echo "<tr>";
         $subPayment = false;
         $balancePayment = false;
         $paymentReference = null;
         //print_r($row);
         //If the payment isn't a credit then we don't care about it
         //if (($row[1] != 'CR') && ($row[1]) != 'BP')
         if ($row[1] != 'CR') {
             continue;
         }
         if (strpos(strtoupper($row[2]), 'GC C1 BUILDBRIGHTO') !== false) {
             continue;
         }
         if (strpos(strtoupper($row[2]), 'STRIPE TRANSFER') !== false) {
             continue;
         }
         if (strpos(strtoupper($row[2]), 'EVENTBRITE') !== false) {
             continue;
         }
         $date = new \Carbon\Carbon($row[0]);
         echo "<td>" . $date->format('d/m/y') . '</td>';
         //echo "<td>".$row[1].'</td>';
         if (strpos(strtoupper($row[2]), 'SUB') !== false) {
             $subPayment = true;
         } elseif (strpos($row[2], 'MEMBERSHIP') !== false) {
             $subPayment = true;
         } elseif (strpos($row[2], '-BALANCE-') !== false) {
             $balancePayment = true;
             $descriptionParts = explode('-BALANCE-', $row[2]);
             if (is_array($descriptionParts) && count($descriptionParts) > 1) {
                 $paymentReference = strtolower($descriptionParts[1]);
             }
         }
         if ($subPayment) {
             echo '<td>SUB</td>';
             $reasonString = 'subscription';
         } elseif ($balancePayment) {
             echo '<td>Balance</td>';
             $reasonString = 'balance';
         } else {
             echo '<td></td>';
             $reasonString = 'unknown';
         }
         $matchedUser = false;
         $paymentDescription = strtolower($row[2]);
         //Try matching against specific match strings first
         foreach ($stringMatchUsers as $user) {
             if (strpos($paymentDescription, strtolower($user->import_match_string)) !== false) {
                 $matchedUser = $user;
                 break;
             }
         }
         //If there was no match do a general surname match
         if (!$matchedUser) {
             foreach ($users as $user) {
                 if (strpos($paymentDescription, strtolower($user->family_name)) !== false) {
                     $matchedUser = $user;
                     break;
                 }
             }
         }
         if ($matchedUser) {
             echo '<td>' . $matchedUser->name . '</td>';
             if ($subPayment) {
                 $subCharge = $this->subscriptionChargeRepository->findCharge($matchedUser->id, $date);
                 if ($subCharge) {
                     echo '<td>Subscription Payment</td>';
                 } else {
                     echo '<td style="background-color: #ff8c14;">Unknown: Recording as balance top up</td>';
                     $subPayment = false;
                     $reasonString = 'balance';
                 }
             }
         } else {
             echo '<td style="background-color: #F00;">Unknown</td><td></td>';
         }
         echo '<td>' . $row[2] . '</td>';
         //echo '<td>'.$row[3].'</td>';
         echo '<td>' . $row[4] . '</td>';
         echo "</tr>";
         if (!$testProcess && $matchedUser) {
             if ($subPayment) {
                 if (isset($subCharge) && $subCharge) {
                     $paymentReference = $subCharge->id;
                     $this->subscriptionChargeRepository->markChargeAsPaid($subCharge->id, $date, $row[4]);
                 }
             }
             Payment::create(['created_at' => $date, 'reason' => $reasonString, 'source' => 'standing-order', 'user_id' => $matchedUser->id, 'amount' => $row[4], 'fee' => 0, 'amount_minus_fee' => $row[4], 'status' => 'paid', 'reference' => $paymentReference]);
             if ($subPayment) {
                 if ($matchedUser->payment_method == 'standing-order') {
                     $matchedUser->monthly_subscription = $row[4];
                 }
                 $matchedUser->save();
             }
         }
     }
     echo "</table>";
     exit;
 }