Ejemplo n.º 1
0
<?php

use EasyFlow\Master\Models\Flow;
use EasyFlow\Master\Models\Task;
use EasyFlow\Master\Models\User;
use EasyFlow\Master\Controllers\LogController;
use EasyFlow\Master\Controllers\MailController;
require_once dirname(__DIR__) . "/includes/configuration.php";
try {
    $flows = Flow::all();
    foreach ($flows as $flow) {
        $admin = User::find($flow->flow_administrator);
        $open_tasks = Task::where('task_flow', $flow->flow_id)->where(function ($query) {
            $query->open();
        })->with(['request', 'step', 'user'])->get();
        $html = view('email.daily_admin_summary', compact('flow', 'admin', 'open_tasks'));
        MailController::sendGeneralMail([["email" => $admin->user_email]], "Resumen de tareas abiertas - " . $flow->flow_name . " - " . date("Y-m-d"), $html);
    }
    LogController::logCron('Cron ejecutado con éxito (JobDailyAdminSummary.php)', [], 'INFO');
} catch (Exception $e) {
    LogController::logCron('Error al ejecutar cron (JobDailyAdminSummary.php)', ['error' => $e->getMessage()], 'ERROR');
}
Ejemplo n.º 2
0
<?php

use EasyFlow\Master\Models\Flow;
use EasyFlow\Master\Models\Task;
use EasyFlow\Master\Models\User;
use EasyFlow\Master\Controllers\LogController;
use EasyFlow\Master\Controllers\MailController;
require_once dirname(__DIR__) . "/includes/configuration.php";
try {
    $flows = Flow::all();
    foreach ($flows as $flow) {
        $users = Task::select('task_assignedto')->where('task_flow', $flow->flow_id)->where(function ($query) {
            $query->open();
        })->distinct('task_assignedto')->groupBy('task_assignedto')->get();
        foreach ($users as $user_task) {
            $user = User::find($user_task->task_assignedto);
            $open_tasks = Task::where('task_flow', $flow->flow_id)->where('task_assignedto', $user->user_id)->where(function ($query) {
                $query->open();
            })->with(['request', 'step'])->get();
            $html = view('email.daily_user_summary', compact('user', 'open_tasks'));
            MailController::sendGeneralMail([["email" => $user->user_email]], "Tareas de usuario abiertas - " . date("Y-m-d"), $html);
        }
        LogController::logCron('Cron ejecutado con éxito (JobDailyUserSummary.php)', [], 'INFO');
    }
} catch (Exception $e) {
    LogController::logCron('Error al ejecutar cron (JobDailyUserSummary.php)', ['error' => $e->getMessage()], 'ERROR');
}