Anons79 Mini Shell

Directory : /home/aplikasiposinfo/public_html/duriancell.fixmate.id/app/Helpers/
Upload File :
Current File : /home/aplikasiposinfo/public_html/duriancell.fixmate.id/app/Helpers/Helper.php

<?php

namespace App\Helpers;

use App\Models\Item;
use App\Models\Permission;
use App\Models\Role;
use App\Models\Log;
use App\Models\Menu;
use App\Models\Profil;
use App\Models\StokItemToko;
use CURLFile;
use DB;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class Helper
{
    public static function profileToko()
    {
        $profil = Profil::first();
        if (isset($profil)) {
            return $profil;
        } else {
            return null;
        }
    }


    public static function hakAkses($nama_menu, $aksi)
    {
        $cek = Role::whereHas('Menu', function ($q) use ($nama_menu, $aksi) {
            $q->where('nama_menu', $nama_menu)
                ->where('aksi_menu', $aksi);
        })->where('id', Auth::user()->role_id)->count();
        if ($cek > 0) {
            return true;
        } else {
            return false;
        }
    }

    public static function hakAksesUser($user_id, $nama_menu, $aksi)
    {
        $cek = Role::whereHas('Menu', function ($q) use ($nama_menu, $aksi) {
            $q->where('nama_menu', $nama_menu)
                ->where('aksi_menu', $aksi);
        })->where('id', $user_id)->count();
        if ($cek > 0) {
            return true;
        } else {
            return false;
        }
    }

    public static function sendWa($number, $message)
    {
        // $key = env('WOOWA_API_KEY');
        // $url = 'http://116.203.92.59/api/async_send_message';
        // $data = array(
        //     "phone_no" => $number,
        //     "key"       => $key,
        //     "message"   => $message,
        //     // "url"        =>$img_url,
        // );
        // $data_string = json_encode($data);

        // $ch = curl_init($url);
        // curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
        // curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
        // curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        // curl_setopt($ch, CURLOPT_VERBOSE, 0);
        // curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
        // curl_setopt($ch, CURLOPT_TIMEOUT, 360);
        // curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        // curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
        // curl_setopt(
        //     $ch,
        //     CURLOPT_HTTPHEADER,
        //     array(
        //         'Content-Type: application/json',
        //         'Content-Length: ' . strlen($data_string)
        //     )
        // );
        // $res = curl_exec($ch);
        // curl_close($ch);

        // return $res;

        return HelperWa::SendMessage($number,$message);
    }
    public static function SchaduleMessage($number, $message, $datetimes)
    {
        // $key = env('WOOWA_API_KEY');
        // $url = 'http://116.203.191.58/api/scheduler';
        // $data = array(
        //     "phone_no" => $number,
        //     "key"       => $key,
        //     "sch_date" => $datetimes,
        //     "api_type" => 'text', // (text, image_text, image, file)
        //     "message" => $message,
        //     // "url"       => $img_url
        // );

        // $data_string = json_encode($data);

        // $ch = curl_init($url);
        // curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
        // curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
        // curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        // curl_setopt($ch, CURLOPT_VERBOSE, 0);
        // curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
        // curl_setopt($ch, CURLOPT_TIMEOUT, 360);
        // curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        // curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
        // curl_setopt(
        //     $ch,
        //     CURLOPT_HTTPHEADER,
        //     array(
        //         'Content-Type: application/json',
        //         'Content-Length: ' . strlen($data_string)
        //     )
        // );
        // echo $res = curl_exec($ch);
        // curl_close($ch);

        // return $res;

        return HelperWa::ScheduleMessage($number,$message,$datetimes);
    }
    public static function SchaduleNotaPDF($number, $file_path, $datetimes)
    {
        // $key = env('WOOWA_API_KEY');
        // $url = 'http://116.203.191.58/api/scheduler';
        // $data = array(
        //     "phone_no" => $number,
        //     "key"       => $key,
        //     "sch_date" => $datetimes,
        //     "api_type" => 'file', // (text, image_text, image, file)
        //     // "url"       => $img_url
        //     "url"       => $file_path
        // );

        // $data_string = json_encode($data);

        // $ch = curl_init($url);
        // curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
        // curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
        // curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        // curl_setopt($ch, CURLOPT_VERBOSE, 0);
        // curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
        // curl_setopt($ch, CURLOPT_TIMEOUT, 360);
        // curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        // curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
        // curl_setopt(
        //     $ch,
        //     CURLOPT_HTTPHEADER,
        //     array(
        //         'Content-Type: application/json',
        //         'Content-Length: ' . strlen($data_string)
        //     )
        // );
        // echo $res = curl_exec($ch);
        // curl_close($ch);

        // return $res;
        return HelperWa::ScheduleMessageFile($number,$file_path,$datetimes);
    }
    public static function RemoveMessage($id_pesan)
    {
        // $message_id = $id_pesan;
        // $key = env('WOOWA_API_KEY');
        // $url = 'http://116.203.191.58/api/sch_remove';
        // $data = array(
        //     "msg_id" => $message_id,
        //     "key"    => $key
        // );
        // $data_string = json_encode($data);

        // $ch = curl_init($url);
        // curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
        // curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
        // curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        // curl_setopt($ch, CURLOPT_VERBOSE, 0);
        // curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
        // curl_setopt($ch, CURLOPT_TIMEOUT, 360);
        // curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        // curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
        // curl_setopt(
        //     $ch,
        //     CURLOPT_HTTPHEADER,
        //     array(
        //         'Content-Type: application/json',
        //         'Content-Length: ' . strlen($data_string)
        //     )
        // );
        // echo $res = curl_exec($ch);
        // curl_close($ch);

        return HelperWa::RemoveScheduleMessage($id_pesan);
    }

    public static function sendNota($number, $message)
    {
        // $key = env('WOOWA_API_KEY');
        // $url = 'http://116.203.92.59/api/async_send_message';
        // $data = array(
        //     "phone_no" => $number,
        //     "key"       => $key,
        //     "message"   => $message,
        //     // "url"        =>$img_url,
        // );
        // $data_string = json_encode($data);

        // $ch = curl_init($url);
        // curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
        // curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
        // curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        // curl_setopt($ch, CURLOPT_VERBOSE, 0);
        // curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
        // curl_setopt($ch, CURLOPT_TIMEOUT, 360);
        // curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        // curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
        // curl_setopt(
        //     $ch,
        //     CURLOPT_HTTPHEADER,
        //     array(
        //         'Content-Type: application/json',
        //         'Content-Length: ' . strlen($data_string)
        //     )
        // );
        // $res = curl_exec($ch);
        // curl_close($ch);

        // return $res;

         return HelperWa::SendMessage($number,$message);
    }

    public static function sendNotaPDF($number, $file_path)
    {
        // $key = env('WOOWA_API_KEY'); //this is demo key please change with your own key
        // $url = 'http://116.203.191.58/api/async_send_file_url';

        // $data = array(
        //     "phone_no"  => $number,
        //     "key"       => $key,
        //     "url"       => $file_path
        // );
        // $data_string = json_encode($data);

        // $ch = curl_init($url);
        // curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
        // curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
        // curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        // curl_setopt($ch, CURLOPT_VERBOSE, 0);
        // curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
        // curl_setopt($ch, CURLOPT_TIMEOUT, 360);
        // curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        // curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
        // curl_setopt(
        //     $ch,
        //     CURLOPT_HTTPHEADER,
        //     array(
        //         'Content-Type: application/json',
        //         'Content-Length: ' . strlen($data_string)
        //     )
        // );
        // $res = curl_exec($ch);
        // curl_close($ch);
        // return $res;

        return HelperWa::SendMessageFile($number,$file_path);
    }

    public static function getMyIP()
    {
        $ipaddress = '';
        if (getenv('HTTP_CLIENT_IP'))
            $ipaddress = getenv('HTTP_CLIENT_IP');
        else if (getenv('HTTP_X_FORWARDED_FOR'))
            $ipaddress = getenv('HTTP_X_FORWARDED_FOR');
        else if (getenv('HTTP_X_FORWARDED'))
            $ipaddress = getenv('HTTP_X_FORWARDED');
        else if (getenv('HTTP_FORWARDED_FOR'))
            $ipaddress = getenv('HTTP_FORWARDED_FOR');
        else if (getenv('HTTP_FORWARDED'))
            $ipaddress = getenv('HTTP_FORWARDED');
        else if (getenv('REMOTE_ADDR'))
            $ipaddress = getenv('REMOTE_ADDR');
        else
            $ipaddress = 'UNKNOWN';
        return $ipaddress;
    }

    // User Log
    // Helper::addUserLog('Menambah Penjualan', $query->toArray());
    public static function addUserLog($action, $actionDetail = null, $ip = null)
    {
        if ($ip == null) {
            $ip = Helper::getMyIP();
        }

        Log::create([
            'action' => $action,
            'action_detail' => json_encode($actionDetail),
            'user_id' => Auth::user()->id,
            'ip' => $ip,
            'ip_detail' => NULL
        ]);
    }

    public static function notifItem(){


        $jumlahItemKosong = StokItemToko::join('items','items.id','=','stok_item_tokos.item_id')
        ->where(DB::raw('stok_item_tokos.stok'),'<=',DB::raw('items.stok_minimal'))
        ->where(DB::raw('items.pakai_notif'), 1)
        ->count();
        $items = StokItemToko::select('stok_item_tokos.*')->with('item','toko')
            ->join('items','items.id','=','stok_item_tokos.item_id')
            ->where(DB::raw('stok_item_tokos.stok'),'<=',DB::raw('items.stok_minimal'))
            ->where(DB::raw('items.pakai_notif'), 1)
            ->limit(10)
            ->get();
        return [
            'jumlah' => $jumlahItemKosong,
            'items' => $items
        ];
    }
}

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]