<?php
    $entry_date = $_POST['entry_date'];
    $houre = $_POST['houre'];
    $minuet = $_POST['minuet'];

    $entry_time = strtotime($entry_date.' '.$houre.':'.$minuet);
    $bazar_id = intval($_POST['bazar_id']);
    $note = $_POST['note']??'';
    $bazar = $db->get_rowData('bazar','id',$bazar_id);
    if($entry_time==false){$error=fl(); setMessage(63,'entry time');}
    elseif($entry_time<strtotime('-2 years')){$error=fl();setMessage(63,'entry time');}
    elseif($bazar_id<1){$error=fl();setMessage(36,'bazar');}
    elseif(empty($bazar)){$error=fl();setMessage(63,'bazar');}
    else{

        if(!isset($error)){
            $db->transactionStart();
            $data=[
                'entry_time'=>$entry_time,
                'bazar_id'=>$bazar_id,
                'note'=>$note,
            ];
            $db->arrayUserInfoAdd($data);
            $id = $db->insert('bazar_visit',$data,true);
            if(!$id){$error=fl(); setMessage(66);}
            $code = $db->setAutoCode('bazar_visit',$id);
            if(!$code){$error=fl();setMessage(66);}
                
            $ac = false; 
            if(!isset($error)){
                $jArray['status'] = 1;
                $ac = true;
                setMessage(2,'bazar visit successfully');
            }
            $db->transactionStop($ac);
        }

    }




