Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Sts\WebToko\BO;
- use Sts\PleafCore\BusinessFunction;
- use Sts\PleafCore\DefaultBusinessFunction;
- use Sts\PleafCore\CoreException;
- use Sts\PleafCore\Util\ValidationUtil;
- use DB;
- use Log;
- /**
- * @author
- * @in
- * - doc_type_id
- * - doc_date
- * - tenant_id
- * @out
- * - []
- *
- */
- class ValDocDateMaxBackDate implements BusinessFunction {
- public function getDescription(){
- return "Check doc_date Max Back Date";
- }
- public function execute($dto){
- // Log::debug($dto);
- $doc_type_id = $dto["doc_type_id"];
- $doc_date = $dto["doc_date"];
- $tenant_id = $dto["tenant_id"];
- $query = " SELECT f_get_value_system_config_by_param_code ( :tenant_id, 'BACKDATE.LIMIT') ";
- $params = [
- "tenant_id" => $tenant_id
- ];
- $max_back_date = DB::SELECT($query, $params)[0]->f_get_value_system_config_by_param_code;
- $now = time();
- $year = date("Y", $now);
- $month = date("m", $now);
- $day = date("d", $now);
- $now = mktime(0,0,0,$month,$day,$year);
- $mnl_back_date = $now - ONE_DAY * $max_back_date;
- $input = date_parse_from_format("Ymd", $doc_date);
- $doc_date_in_time = mktime( 0,0,0, $input['month'], $input['day'], $input['year']);
- if($doc_date_in_time < $mnl_back_date){
- throw new CoreException(ERROR_BACK_DATE_VALIDATION,[],
- ["doc_date" => ["Tanggal back date maksimal ".$max_back_date." hari."]]);
- }
- return [];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement