| 
				Server : Apache System : Linux server.mata-lashes.com 3.10.0-1160.90.1.el7.x86_64 #1 SMP Thu May 4 15:21:22 UTC 2023 x86_64 User : matalashes ( 1004) PHP Version : 8.1.29 Disable Function : NONE Directory : /home/matalashes/public_html/kite.mata-lashes.com/app/Libraries/Ps/  | 
Upload File :  | 
<?php
namespace App\Libraries\Ps;
use Config\Services;
class Mylibpublic
{
    function getByHashtag($_store_items, $hashtag)
    {
        $data = array();
        foreach ($_store_items as $d) {
            if ($d->si_tag != '') {
                $arr = explode(' ', $d->si_tag);
                for ($i = 0; $i < count($arr); $i++) {
                    if ($arr[$i] == $hashtag) {
                        array_push($data, $d->ps_si_id);
                        break;
                    }
                }
            }
        }
        return $data;
    }
    function formatNumberInt($number)
    {
        return number_format($number, 0, ',', '.') . '';
    }
    function formatNumber($number)
    {
        return number_format($number, 0, ',', '.') . '';
    }
    function formatNumberRp($number)
    {
        return 'Rp ' . number_format($number, 0, ',', '.') . '';
    }
    function generateOrderNumber($prefix,$model)
    {
        $mdl = $this->getNewModel($model);
        $last_id = $mdl->count_faktur()->count;
        if(isset($last_id)){
            $last_id++;
        }
        $inc = '';
        if(strlen($last_id) == 1){
            $inc = '000'.$last_id;
        }else if(strlen($last_id) == 2){
            $inc = '00'.$last_id;
        }else if(strlen($last_id) == 0){
            $inc = '0001';
        }else{
            $inc = $last_id;
        }
        
        if($prefix == ''){
            return $inc;
        }else{
            return $prefix.'/'.$inc;
        }
    }
    function getSpace($val)
    {
        $string = '';
        for ($i = 0; $i < $val; $i++) {
            $string .= " ";
        }
        return $string;
    }
    public function getNewModel($_model)
    {
        $class = '\App\Models\\' . ucwords($_model);
        return new $class();
    }
  
}