/
home
/
sjslayjy
/
public_html
/
cropnet
/
app
/
Helpers
/
Upload File
HOME
<?php function getModelById($modal,$id){ $modal = "\App\\".$modal; $result = $modal::find($id); if($result!=null){ return $result; }else{ return new $modal; } } function getModelBympp($modal,$mpp_code,$mcc_code){ $result = \DB::table($modal)->where('mpp_code', $mpp_code)->where('mcc_code', $mcc_code)->first(); if($result!=null){ return $result; }else{ return new $modal; } } function checkUpdateBtnAuthority($steps, $uStatus, $match) { $found = 0; $mfound = 0; if(!is_null($uStatus)) { foreach($steps as $key=>$step){ if($step == $match){ $found = 1; } } if(count($uStatus)){ if(!array_key_exists($match, $uStatus)){ $mfound = 1; } } if($found == $mfound){ return true; } } else { foreach($steps as $key=>$step){ if($step == $match){ $found = 1; } } if($found){ return true; } } return false; } function checkUpdateBtnColorAuthority($steps, $uStatus, $match) { $found = 0; $mfound = 0; if(!is_null($uStatus)) { foreach($steps as $key=>$step){ if($step == $match){ $found = 1; } } if(count($uStatus)){ if(!array_key_exists($match, $uStatus)){ $mfound = 1; } } if($found == $mfound){ return false; } } else { foreach($steps as $key=>$step){ if($step == $match){ $found = 1; } } if($found){ return false; } } return true; } function correctDateFormate($wrong_date_formate) { $date = explode('/', $wrong_date_formate); if(count($date) > 1) { if(strlen($date[0]) == 4) { // 2023/04/03 $year = $date[0]; $month = (strlen($date[1]) == 1)?'0'.$date[1]:$date[1]; $day = (strlen($date[2]) == 1)?'0'.$date[2]:$date[2]; $correct_date = $day.'-'.$month.'-'.$year; } else { // 04/03/2023 $year = $date[2]; $month = (strlen($date[1]) == 1)?'0'.$date[1]:$date[1]; $day = (strlen($date[0]) == 1)?'0'.$date[0]:$date[0]; $correct_date = $day.'-'.$month.'-'.$year; } }else { $date = explode('-', $wrong_date_formate); if(strlen($date[0]) == 4) { //2023-05-23 $year = $date[0]; $month = (strlen($date[1]) == 1)?'0'.$date[1]:$date[1]; $day = (strlen($date[2]) == 1)?'0'.$date[2]:$date[2]; $correct_date = $day.'-'.$month.'-'.$year; } else { //05-05-2023 $year = $date[2]; $month = (strlen($date[1]) == 1)?'0'.$date[1]:$date[1]; $day = (strlen($date[0]) == 1)?'0'.$date[0]:$date[0]; $correct_date = $day.'-'.$month.'-'.$year; } } return $correct_date; } function checkRejectBtnAuthority() { } ?>