Files
click-erp/app/Http/Controllers/UtilityController.php

150 lines
5.0 KiB
PHP

<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models;
use Spatie\Activitylog\Models\Activity;
// use Illuminate\Contracts\Mail\Mailer;
class UtilityController extends Controller
{
public function underconstruction(){
return view('utility.underconstruction');
}
public function EmailTest(Mailer $mailer)
{
$emails = ['kwesi@click-mobile.com', 'kwesi_banson@hotmail.com'];
$data = [
'client' => 'test client',
'created_by' => 'Kwesi',
'services' => 'test services',
'notes_body' => 'test notes'
];
$mailer->send('emails.new-notes', $data, function ($message) use ($data, $emails) {
$message->from('erp@click-mobile.com', 'Click Mobile ERP');
$message->to($emails)->subject('New Notes');
});
}
/**
* maptest function to display the map view.
*
* @return Illuminate\View\View
*/
public function maptest(){
return view('utility.map');
}
public function showPage(){
return view('utility.arraylogic');
}
public function ntfyTest(){
$this->sendNtfy('In the ERP');
}
public function paperlessTest(){
$file_path = "documents/oasl.pdf";
$tags_arr = [1,2];
$created_at = date('Y-m-d H:i:s');
$document_type = 1;
$title = "OASL has entered the chat";
$top = $this->sendToPaperless($file_path, $tags_arr, $created_at, $document_type, $title);
dd($top);
}
function getPaperlessAttributes($name){
$retval = $this->getToPaperlessParamValues($name);
// dd($retval['results']);
$tip = json_decode($retval);
dd($tip);
foreach ($tip->results as $value) {
dd($value);
}
dd($tip->results);
}
function insertOnboardingProgress(){
$all_clients = Models\Client::get();
$count_cl = 0;
foreach ($all_clients as $row) {
$get_stage_subs_items = Models\ClientOnboardingSubItem::get();
foreach ($get_stage_subs_items as $value) {
$stage_id = ['stage_id' => $value->stage_id, 'client_id' => $row->id, 'name' => $value->name ];
$progress_arr = [
'status' => 'PENDING'
];
$clients_onboarding_progress = Models\ClientOnboardingProgress::updateOrCreate($stage_id, $progress_arr);
}
$count_cl++;
}
dump($count_cl);
}
function massOnboardingProgress($client_id){
//todo : update
/*
-- client_onboarding_sub_items -- this holds all sub items
-- client_onboarding_progress -- update to completed
-- in the clients table
-- onboarding_progress_stage == update to complete,
-- progress_indicator to complete,
-- progress_indicator_score to 100
*/
$get_stage_subs_items = Models\ClientOnboardingSubItem::get();
foreach ($get_stage_subs_items as $value) {
$progress_arr = [
'stage_id' => $value->stage_id,
'client_id' => $client_id,
'name' => $value->name,
'status' => 'COMPLETE'
];
$clients_onboarding_progress = Models\ClientOnboardingProgress::create($progress_arr);
}
$all_clients = Models\Client::get();
$count_cl = 0;
foreach ($all_clients as $row) {
$get_stage_subs_items = Models\ClientOnboardingSubItem::get();
foreach ($get_stage_subs_items as $value) {
$stage_id = ['stage_id' => $value->stage_id, 'client_id' => $row->id, 'name' => $value->name ];
$progress_arr = [
'status' => 'PENDING'
];
$clients_onboarding_progress = Models\ClientOnboardingProgress::updateOrCreate($stage_id, $progress_arr);
}
$count_cl++;
}
dump($count_cl);
}
function loggingTest(){
$rando = uniqid();
$newsItem = Models\Utility::create([
'name' => 'original name : ' . $rando,
'type' => 'Lorum'
]);
$activity = Activity::all()->last();
dump($activity->description); //returns 'created'
dump($activity->subject); //returns the instance of NewsItem that was created
dump($activity->changes); //returns ['attributes' => ['name' => 'original name', 'text' => 'Lorum']];
//
$rando = uniqid();
$newsItem->name = 'updated name to something like this ' . $rando;
$newsItem->type = 'franko';
$newsItem->save();
//updating the newsItem will cause an activity being logged
$activity_up = Activity::all()->last();
dump($activity_up);
dump($activity_up->description); //returns 'updated'
dump($activity_up->subject); //returns the instance of NewsItem that was created
dump($activity_up->changes);
}
}
// https://www.tokyvideo.com/video/sheena-the-queen-of-the-jungle-1984-movie-with-tanya-roberts-ted-wass-donovan-scott