query( "SELECT * FROM branch WHERE branch_id = '".$branch_id."' LIMIT 1" ) ; if ( $select_branch->num_rows == 0 ){ if ( $branch_name != '' ){ $mysqli->query( "INSERT INTO branch ( branch_id, branch_name, created_at, updated_at ) VALUES ( '".$branch_id."', '".$branch_name."', '".TODAYDATE."', '".TODAYDATE."' )" ) ; } } // check staffidno exists $staff_id = '' ; $select_staff = $mysqli->query( "SELECT staff_id FROM staff WHERE deleted_at IS NULL AND staff_idno = '".$staff_idno."' LIMIT 1" ) ; if ( $select_staff->num_rows == 0 ){ $status = '203' ; if ( $mysqli->query( "INSERT INTO staff ( branch_id, staff_idno, staff_name, staff_email, staff_mobileno, staff_tier ) VALUES ( '".$branch_id."', '".$staff_idno."', '".$staff_name."', '".$staff_email."', '".$staff_mobileno."', '9' )" ) ){ $staff_id = $mysqli->insert_id ; $status = '200' ; } }else{ $status = '202' ; $row_staff = $select_staff->fetch_assoc() ; if ( $mysqli->query( "UPDATE staff SET branch_id = '".$branch_id."', staff_name = '".$staff_name."', staff_email = '".$staff_email."', staff_mobileno = '".$staff_mobileno."' WHERE staff_id = '".$row_staff['staff_id']."'" ) ){ $staff_id = $row_staff['staff_id'] ; $status = '200' ; } } if ( $staff_id != '' ){ $select_department = $mysqli->query( "SELECT staff_department_id FROM staff_department WHERE deleted_at IS NULL AND staff_id = '".$staff_id."' LIMIT 1" ) ; if ( $select_department->num_rows == 0 ){ $mysqli->query("INSERT INTO staff_department ( staff_id, department_id, created_at, updated_at ) VALUES ( '".$staff_id."', '".$department_id."', '".TODAYDATE."', '".TODAYDATE."')" ) ; } } } require( $require_sub.'footer.php' ) ; ?>