/**
  * Handle the event.
  *
  * @param  RegularLeaveApproved  $event
  * @return void
  */
 public function handle(Event $event)
 {
     $leave = $event->leave;
     write_form(new WriteRegularLeaveForm($leave));
     $leave->notifications()->create(['sent_to' => $leave->employee->user->id, 'sent_by' => auth()->user()->id, 'subject' => 'Leave request', 'message' => 'Your leave request has been ' . $leave->status . ' by ' . auth()->user()->employee->full_name, 'icon' => 'thumbs-up', 'color' => 'danger']);
     // if ($leave->isStatus('approved')) {
     //     $employee->personnel_leave_card()->create([
     //         'particulars' => 'Filed regular leave',
     //         'vl_earned' => $incrementedVacationLeave,
     //         'vl_balance' => $employee->accumulated_leave->vacation_leave,
     //         'sl_earned' => $incrementedSickLeave,
     //         'sl_balance' => $employee->accumulated_leave->sick_leave,
     //         'remarks' => 'Increment leave credits',
     //     ]);
     // }
     $recipient = $this->checkStatus($leave);
     if ($recipient) {
         $leave->notifications()->create(['sent_to' => $recipient->user->id, 'sent_by' => $leave->employee->user->id, 'subject' => 'Leave request', 'message' => 'Leave request of ' . $leave->employee->full_name . ' is awaiting for your approval.', 'icon' => 'thumbs-up', 'color' => 'danger']);
     }
 }
 /**
  * Handle the event.
  *
  * @param  TravelOrderApproved  $event
  * @return void
  */
 public function handle(Event $event)
 {
     $travel = $event->travel;
     if ($travel->isStatus('recommended')) {
         $this->notify($travel, $travel->employee->user, $travel->finance_director->user);
     } elseif ($travel->isStatus('approved')) {
         $this->notify($travel, $travel->employee->user, $travel->approved_by->user);
     } elseif ($travel->isStatus('certified')) {
         write_form(new WriteTravelOrderForm($travel));
         $travel->notifications()->create(['sent_to' => $travel->employee->user->id, 'sent_by' => auth()->user()->id, 'subject' => 'Travel order', 'message' => 'Your leave request has been ' . $travel->status . ' by ' . auth()->user()->employee->full_name, 'icon' => 'plane', 'color' => 'success']);
     }
     // if ($travel->isStatus('certified')) {
     //     write_form(new WriteTravelOrderForm($travel));
     //     $travel->notifications()->create([
     //         'sent_to' => $travel->employee->user->id,
     //         'sent_by' => auth()->user()->id,
     //         'subject' => 'Travel order',
     //         'message' => 'Your leave request has been ' . $travel->status . ' by ' . auth()->user()->employee->full_name,
     //         'icon'    => 'plane',
     //         'color'   => 'success',
     //     ]);
     // } elseif ($travel->isStatus('recommended')) {
     //     $travel->notifications()->create([
     //         'sent_to' => $travel->approved_by->user->id,
     //         'sent_by' => $travel->employee->user->id,
     //         'subject' => 'Travel order',
     //         'message' => 'Travel order filed by ' . $travel->employee->full_name . ' is waiting for your approval.',
     //         'icon'    => 'plane',
     //         'color'   => 'success',
     //     ]);
     // } elseif ($travel->isStatus('approved')) {
     //     $travel->notifications()->create([
     //         'sent_to' => $travel->certified_by->user->id,
     //         'sent_by' => $travel->employee->user->id,
     //         'subject' => 'Travel Order',
     //         'message' => 'Travel order filed by ' . $travel->employee->full_name . ' is waiting for your approval.',
     //         'icon'    => 'plane',
     //         'color'   => 'success',
     //     ]);
     // }
 }
 public function downloadSummaryPerEmployee(Employee $employee)
 {
     $leaves = $employee->employee_special_leaves()->certified()->orderBy('date_from', 'desc')->get();
     if ($leaves->isEmpty()) {
         flash()->warning('Special leave summary is empty.');
         return redirect()->back();
     }
     write_form(new \DNSCHumanResource\FormWriters\WriteEmployeeSpecialLeaveSummary($leaves));
 }
 public function employeeSummary(Request $request, User $user)
 {
     $employee = $user->employee;
     if ($employee) {
         $travels = $employee->travel_orders()->certified()->get();
         if ($travels->isEmpty()) {
             flash()->warning('This employee has no travel orders listed.');
             return redirect()->back();
         }
         write_form(new WriteTravelOrderSummary($travels));
     }
 }
 public function download()
 {
     $events = Training::orderBy('start')->get();
     write_form(new \DNSCHumanResource\FormWriters\WriteTrainingsAndSeminarSummary($events));
 }
 /**
  * Handle the event.
  *
  * @param  RegularLeaveRejected  $event
  * @return void
  */
 public function handle(Event $event)
 {
     $leave = $event->leave;
     write_form(new WriteRegularLeaveForm($leave));
     $leave->notifications()->create(['sent_to' => $leave->employee->user->id, 'sent_by' => auth()->user()->id, 'subject' => 'Leave request', 'message' => 'Your leave request has been ' . $leave->status . ' by ' . auth()->user()->employee->full_name, 'icon' => 'thumbs-up', 'color' => 'danger']);
 }
Example #7
0
/**
 * Generates and displays the matching form, with predefined data.
 *
 * @param string $message
 * @param array $localData
 * @param string $region
 * @param array[optional] $validated
 * @return string
 */
function Gen_Form($message, $localData, $region, $validated = array())
{
    // Make sure the file exists.
    if (!is_file(CACHE_REP_FILE . $region)) {
        trigger_error('Could not find inventory report file', E_USER_ERROR);
    }
    // Read the data from the file.
    if (!($amazonData = file_get_contents(CACHE_REP_FILE . $region))) {
        trigger_error('Could not read Inventory report file', E_USER_ERROR);
    }
    // Convert data back into an array.
    $amazonData = unserialize($amazonData);
    $import = $match = array();
    while ($product = array_shift($amazonData)) {
        // Reference SKU and ASIN for use in product matching.
        $SKU = $product['sku'];
        $ASIN = $product['asin'];
        // Check if the Amazon SellerSKU matches the local model name.
        if (!empty($validated) && isset($validated[$SKU])) {
            $itemID = $validated[$SKU];
        } else {
            // Run through all local products until we find a match.
            $itemID = false;
            foreach ($localData as $prodID => $line) {
                if ($line[0] == $SKU) {
                    // Match found, set item ID for preselection in drop down.
                    $itemID = $prodID;
                    break;
                }
            }
        }
        /**
         * @todo Find out how to deal with duplicated products.
         */
        // Generate the dropdown for the local product, preselecting if we have a matching ID.
        $dropDown = Gen_Dropdown($localData, "match[{$SKU}][{$ASIN}]", 'Select product', $itemID, "\t\t\t\t");
        // Put matched and unmatched products into different arrays, for easier sorting.
        if (!$itemID) {
            $import[] = array($SKU, $ASIN, $product['name'], $product['price'], $product['desc'], $dropDown);
        } else {
            $match[] = array($SKU, $ASIN, $product['name'], $product['price'], $product['desc'], $dropDown);
        }
    }
    // Merge the two arrays, making sure unmatched products are at the top.
    $import = array_merge($import, $match);
    // Read the template file, and add all the products to the template.
    return write_form($message, $import);
}
 public function summary(Request $request)
 {
     $users = User::has('employee')->orderBy('username')->get();
     if ($users->isEmpty()) {
         flash()->error('Employee is empty.');
         return redirect()->back();
     }
     write_form(new \DNSCHumanResource\FormWriters\WriteEmployeeSummary($users));
 }
 public function update(Request $request, $id)
 {
     // Find the leave request by id
     $leave = EmployeeLeave::findOrFail($id);
     // check if the auth user is authorize to update this leave
     $this->authorize('edit', $leave);
     // update the leave request
     $data = $request->all();
     $data = array_add($data, 'file', null);
     $leave->update($data);
     write_form(new WriteRegularLeaveForm($leave));
     flash()->success('Leave request was updated!');
     return redirect()->to('/leave/personal');
 }
function write_form_error_page($msg)
{
    write_header();
    echo "<h2>Sorry, an error occurred<br />", $msg, "</h2>";
    write_form();
    write_footer();
}
 /**
  * Handle the event.
  *
  * @param  RegularLeaveFiled  $event
  * @return void
  */
 public function handle(Event $event)
 {
     $leave = $event->leave;
     write_form(new WriteRegularLeaveForm($leave));
     $leave->notifications()->create(['sent_to' => $this->checkApprovals($leave)->user->id, 'sent_by' => auth()->user()->id, 'subject' => 'Regular Leave Request', 'message' => auth()->user()->employee->full_name . ' filed a leave request and waiting for your approval.', 'icon' => 'thumbs-up', 'color' => 'danger']);
 }
 /**
  * Handle the event.
  *
  * @param  TravelOrderLeaveFiled  $event
  * @return void
  */
 public function handle(Event $event)
 {
     write_form(new WriteTravelOrderForm($event->travel));
     $event->travel->notifications()->create(['sent_to' => $this->checkApprovals($event->travel)->user->id, 'sent_by' => auth()->user()->id, 'subject' => 'Travel order', 'message' => auth()->user()->employee->full_name . ' filed a travel order and waiting for your approval.', 'icon' => 'plane', 'color' => 'success']);
 }