|
|
@ -13,6 +13,8 @@ use Illuminate\Support\Facades\DB; |
|
|
|
|
|
|
|
|
|
|
|
use Illuminate\Support\Facades\Http; |
|
|
|
use Illuminate\Support\Facades\Http; |
|
|
|
use Laravel\Lumen\Routing\Controller as BaseController; |
|
|
|
use Laravel\Lumen\Routing\Controller as BaseController; |
|
|
|
|
|
|
|
use RecursiveIteratorIterator; |
|
|
|
|
|
|
|
use RecursiveDirectoryIterator; |
|
|
|
|
|
|
|
|
|
|
|
class Controller extends BaseController |
|
|
|
class Controller extends BaseController |
|
|
|
{ |
|
|
|
{ |
|
|
@ -41,10 +43,10 @@ class Controller extends BaseController |
|
|
|
|
|
|
|
|
|
|
|
protected function setCustomeDirectoryUpload($company_name) |
|
|
|
protected function setCustomeDirectoryUpload($company_name) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$pathImage = 'assets/'.$company_name.'/image/'; |
|
|
|
$pathImage = 'assets/' . $company_name . '/image/'; |
|
|
|
$pathDocument = 'assets/'.$company_name.'/file/project/'; |
|
|
|
$pathDocument = 'assets/' . $company_name . '/file/project/'; |
|
|
|
$pathTmpImport = 'assets/'.$company_name.'/file/tmpimport/'; |
|
|
|
$pathTmpImport = 'assets/' . $company_name . '/file/tmpimport/'; |
|
|
|
$pathActivityDocument = 'assets/'.$company_name.'/file/activity/'; |
|
|
|
$pathActivityDocument = 'assets/' . $company_name . '/file/activity/'; |
|
|
|
|
|
|
|
|
|
|
|
return [ |
|
|
|
return [ |
|
|
|
'pathImage' => $pathImage, |
|
|
|
'pathImage' => $pathImage, |
|
|
@ -54,7 +56,19 @@ class Controller extends BaseController |
|
|
|
]; |
|
|
|
]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected function setLimitsStorage($company, $dokumen, $name, $initPath, $destinatePath) { |
|
|
|
public function storage($company_name) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$directory = 'assets/' . urldecode($company_name); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$size = 0; |
|
|
|
|
|
|
|
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $file) { |
|
|
|
|
|
|
|
$size += $file->getSize(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return round($size / 1048576, 2); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected function setLimitsStorage($company, $dokumen, $name, $initPath, $destinatePath) |
|
|
|
|
|
|
|
{ |
|
|
|
$totalSize = 0; |
|
|
|
$totalSize = 0; |
|
|
|
$sizeFile = $dokumen->getSize(); |
|
|
|
$sizeFile = $dokumen->getSize(); |
|
|
|
// Path |
|
|
|
// Path |
|
|
@ -63,11 +77,11 @@ class Controller extends BaseController |
|
|
|
$folderPathTmpImport = $destinatePath['pathTmpImport']; |
|
|
|
$folderPathTmpImport = $destinatePath['pathTmpImport']; |
|
|
|
$folderPathActivityDocument = $destinatePath['pathActivityDocument']; |
|
|
|
$folderPathActivityDocument = $destinatePath['pathActivityDocument']; |
|
|
|
// Create Directory |
|
|
|
// Create Directory |
|
|
|
if(!file_exists($initPath)) { |
|
|
|
if (!file_exists($initPath)) { |
|
|
|
mkdir($initPath, 0777, true); |
|
|
|
mkdir($initPath, 0777, true); |
|
|
|
} |
|
|
|
} |
|
|
|
// Scanning & Existing Folder |
|
|
|
// Scanning & Existing Folder |
|
|
|
if(file_exists($folderPathImage)) { |
|
|
|
if (file_exists($folderPathImage)) { |
|
|
|
$files = scandir($folderPathImage); |
|
|
|
$files = scandir($folderPathImage); |
|
|
|
foreach ($files as $file) { |
|
|
|
foreach ($files as $file) { |
|
|
|
if (is_file($folderPathImage . '/' . $file)) { |
|
|
|
if (is_file($folderPathImage . '/' . $file)) { |
|
|
@ -75,7 +89,7 @@ class Controller extends BaseController |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if(file_exists($folderPath)) { |
|
|
|
if (file_exists($folderPath)) { |
|
|
|
$filesImage = scandir($folderPath); |
|
|
|
$filesImage = scandir($folderPath); |
|
|
|
foreach ($filesImage as $file) { |
|
|
|
foreach ($filesImage as $file) { |
|
|
|
if (is_file($folderPath . '/' . $file)) { |
|
|
|
if (is_file($folderPath . '/' . $file)) { |
|
|
@ -83,7 +97,7 @@ class Controller extends BaseController |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if(file_exists($folderPathTmpImport)) { |
|
|
|
if (file_exists($folderPathTmpImport)) { |
|
|
|
$filesTmpImport = scandir($folderPathTmpImport); |
|
|
|
$filesTmpImport = scandir($folderPathTmpImport); |
|
|
|
foreach ($filesTmpImport as $file) { |
|
|
|
foreach ($filesTmpImport as $file) { |
|
|
|
if (is_file($folderPathTmpImport . '/' . $file)) { |
|
|
|
if (is_file($folderPathTmpImport . '/' . $file)) { |
|
|
@ -91,7 +105,7 @@ class Controller extends BaseController |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if(file_exists($folderPathActivityDocument)) { |
|
|
|
if (file_exists($folderPathActivityDocument)) { |
|
|
|
$filesActivityDocument = scandir($folderPathActivityDocument); |
|
|
|
$filesActivityDocument = scandir($folderPathActivityDocument); |
|
|
|
foreach ($filesActivityDocument as $file) { |
|
|
|
foreach ($filesActivityDocument as $file) { |
|
|
|
if (is_file($folderPathActivityDocument . '/' . $file)) { |
|
|
|
if (is_file($folderPathActivityDocument . '/' . $file)) { |
|
|
@ -105,16 +119,16 @@ class Controller extends BaseController |
|
|
|
->where('company_id', $company['id']); |
|
|
|
->where('company_id', $company['id']); |
|
|
|
$cloneQueryTransaction = clone $transaction; |
|
|
|
$cloneQueryTransaction = clone $transaction; |
|
|
|
$countCreate = false; |
|
|
|
$countCreate = false; |
|
|
|
if($transaction->where([['type_paket','Basic'], ['amount','!=',null]])->exists()) { |
|
|
|
if ($transaction->where([['type_paket', 'Basic'], ['amount', '!=', null]])->exists()) { |
|
|
|
$maximumSize = 500 * 1024 * 1024; |
|
|
|
$maximumSize = 500 * 1024 * 1024; |
|
|
|
$countCreate = true; |
|
|
|
$countCreate = true; |
|
|
|
} elseif ($cloneQueryTransaction->where([['type_paket','Free'], ['amount', 0]])->exists()) { |
|
|
|
} elseif ($cloneQueryTransaction->where([['type_paket', 'Free'], ['amount', 0]])->exists()) { |
|
|
|
$maximumSize = 50 * 1024 * 1024; |
|
|
|
$maximumSize = 50 * 1024 * 1024; |
|
|
|
$countCreate = true; |
|
|
|
$countCreate = true; |
|
|
|
} |
|
|
|
} |
|
|
|
if($countCreate) { |
|
|
|
if ($countCreate) { |
|
|
|
if ($totalSize > $maximumSize) { |
|
|
|
if ($totalSize > $maximumSize) { |
|
|
|
return response()->json(['status'=>'failed','message'=>'Limited storage maximum!','code'=> 500], 500); |
|
|
|
return response()->json(['status' => 'failed', 'message' => 'Limited storage maximum!', 'code' => 500], 500); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
$resultMove = $dokumen->move($folderPath, $name); |
|
|
|
$resultMove = $dokumen->move($folderPath, $name); |
|
|
|